@skdx/web-components-charts 0.39.0 → 0.40.0
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.
- package/dist/area.cjs +38 -35
- package/dist/area.d.cts +1 -1
- package/dist/area.d.ts +1 -1
- package/dist/area.js +28 -25
- package/dist/bar.cjs +38 -35
- package/dist/bar.d.cts +1 -1
- package/dist/bar.d.ts +1 -1
- package/dist/bar.js +28 -25
- package/dist/boxplot.cjs +33 -30
- package/dist/boxplot.d.cts +1 -1
- package/dist/boxplot.d.ts +1 -1
- package/dist/boxplot.js +40 -37
- package/dist/bubble.cjs +37 -34
- package/dist/bubble.d.cts +1 -1
- package/dist/bubble.d.ts +1 -1
- package/dist/bubble.js +25 -22
- package/dist/bullet.cjs +40 -37
- package/dist/bullet.d.cts +1 -1
- package/dist/bullet.d.ts +1 -1
- package/dist/bullet.js +38 -35
- package/dist/bump.cjs +38 -35
- package/dist/bump.d.cts +1 -1
- package/dist/bump.d.ts +1 -1
- package/dist/bump.js +38 -35
- package/dist/candlestick.cjs +40 -37
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +35 -32
- package/dist/chord.cjs +26 -23
- package/dist/chord.d.cts +1 -1
- package/dist/chord.d.ts +1 -1
- package/dist/chord.js +40 -37
- package/dist/circle-packing.cjs +26 -23
- package/dist/circle-packing.d.cts +1 -1
- package/dist/circle-packing.d.ts +1 -1
- package/dist/circle-packing.js +40 -37
- package/dist/combo.cjs +38 -35
- package/dist/combo.d.cts +1 -1
- package/dist/combo.d.ts +1 -1
- package/dist/combo.js +28 -25
- package/dist/dumbbell.cjs +32 -29
- package/dist/dumbbell.d.cts +1 -1
- package/dist/dumbbell.d.ts +1 -1
- package/dist/dumbbell.js +40 -37
- package/dist/funnel.cjs +30 -27
- package/dist/funnel.d.cts +1 -1
- package/dist/funnel.d.ts +1 -1
- package/dist/funnel.js +40 -37
- package/dist/gantt.cjs +40 -37
- package/dist/gantt.d.cts +1 -1
- package/dist/gantt.d.ts +1 -1
- package/dist/gantt.js +30 -27
- package/dist/gauge.cjs +34 -31
- package/dist/gauge.d.cts +1 -1
- package/dist/gauge.d.ts +1 -1
- package/dist/gauge.js +39 -36
- package/dist/heatmap.cjs +40 -37
- package/dist/heatmap.d.cts +1 -1
- package/dist/heatmap.d.ts +1 -1
- package/dist/heatmap.js +30 -27
- package/dist/histogram.cjs +30 -27
- package/dist/histogram.d.cts +1 -1
- package/dist/histogram.d.ts +1 -1
- package/dist/histogram.js +30 -27
- package/dist/icicle.cjs +45 -42
- package/dist/icicle.d.cts +1 -1
- package/dist/icicle.d.ts +1 -1
- package/dist/icicle.js +45 -42
- package/dist/{index-oF5ss8v9.d.cts → index-D44-61v7.d.cts} +11 -5
- package/dist/{index-oF5ss8v9.d.ts → index-D44-61v7.d.ts} +11 -5
- package/dist/index.cjs +40 -37
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +40 -37
- package/dist/line.cjs +38 -35
- package/dist/line.d.cts +1 -1
- package/dist/line.d.ts +1 -1
- package/dist/line.js +28 -25
- package/dist/linear-gauge.cjs +40 -37
- package/dist/linear-gauge.d.cts +1 -1
- package/dist/linear-gauge.d.ts +1 -1
- package/dist/linear-gauge.js +38 -35
- package/dist/map.cjs +40 -37
- package/dist/map.d.cts +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.js +40 -37
- package/dist/marimekko.cjs +31 -28
- package/dist/marimekko.d.cts +1 -1
- package/dist/marimekko.d.ts +1 -1
- package/dist/marimekko.js +32 -29
- package/dist/network.cjs +26 -23
- package/dist/network.d.cts +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.js +40 -37
- package/dist/organization.cjs +29 -26
- package/dist/organization.d.cts +1 -1
- package/dist/organization.d.ts +1 -1
- package/dist/organization.js +40 -37
- package/dist/parallel.cjs +25 -22
- package/dist/parallel.d.cts +1 -1
- package/dist/parallel.d.ts +1 -1
- package/dist/parallel.js +37 -34
- package/dist/pareto.cjs +30 -27
- package/dist/pareto.d.cts +1 -1
- package/dist/pareto.d.ts +1 -1
- package/dist/pareto.js +30 -27
- package/dist/pie.cjs +40 -37
- package/dist/pie.d.cts +1 -1
- package/dist/pie.d.ts +1 -1
- package/dist/pie.js +39 -36
- package/dist/polar-area.cjs +40 -37
- package/dist/polar-area.d.cts +1 -1
- package/dist/polar-area.d.ts +1 -1
- package/dist/polar-area.js +40 -37
- package/dist/radar.cjs +27 -24
- package/dist/radar.d.cts +1 -1
- package/dist/radar.d.ts +1 -1
- package/dist/radar.js +40 -37
- package/dist/radial.cjs +39 -36
- package/dist/radial.d.cts +1 -1
- package/dist/radial.d.ts +1 -1
- package/dist/radial.js +39 -36
- package/dist/range.cjs +30 -27
- package/dist/range.d.cts +1 -1
- package/dist/range.d.ts +1 -1
- package/dist/range.js +30 -27
- package/dist/sankey.cjs +31 -28
- package/dist/sankey.d.cts +1 -1
- package/dist/sankey.d.ts +1 -1
- package/dist/sankey.js +40 -37
- package/dist/scatter.cjs +28 -25
- package/dist/scatter.d.cts +1 -1
- package/dist/scatter.d.ts +1 -1
- package/dist/scatter.js +29 -26
- package/dist/sparkline.cjs +23 -20
- package/dist/sparkline.d.cts +1 -1
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.js +38 -35
- package/dist/sunburst.cjs +40 -37
- package/dist/sunburst.d.cts +1 -1
- package/dist/sunburst.d.ts +1 -1
- package/dist/sunburst.js +40 -37
- package/dist/swarm.cjs +36 -33
- package/dist/swarm.d.cts +1 -1
- package/dist/swarm.d.ts +1 -1
- package/dist/swarm.js +37 -34
- package/dist/timeline.cjs +24 -21
- package/dist/timeline.d.cts +1 -1
- package/dist/timeline.d.ts +1 -1
- package/dist/timeline.js +40 -37
- package/dist/tree.cjs +25 -22
- package/dist/tree.d.cts +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +40 -37
- package/dist/treemap.cjs +27 -24
- package/dist/treemap.d.cts +1 -1
- package/dist/treemap.d.ts +1 -1
- package/dist/treemap.js +40 -37
- package/dist/waffle.cjs +38 -35
- package/dist/waffle.d.cts +1 -1
- package/dist/waffle.d.ts +1 -1
- package/dist/waffle.js +38 -35
- package/dist/waterfall.cjs +31 -28
- package/dist/waterfall.d.cts +1 -1
- package/dist/waterfall.d.ts +1 -1
- package/dist/waterfall.js +34 -31
- package/package.json +3 -3
package/dist/pareto.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t,r)=>{for(var i=r>1?void 0:r?qr(n,t):n,o=e.length-1,s;o>=0;o--)(s=e[o])&&(i=(r?s(n,t,i):s(i))||i);return r&&i&&Kr(n,t,i),i};import{customElement as Vi,property as re}from"lit/decorators.js";var Xn=e=>Number(e.toPrecision(12)),Xr,Yn=e=>(Xr??(Xr=new Intl.NumberFormat)).format(Xn(e)),Yr=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=s=>String(s).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function Ce(e){if(e===void 0)return Yn;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=u=>i?h=>u(h)+i:u,l=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},c=u=>{let h=new Intl.NumberFormat(t,u);return s(p=>h.format(Xn(p)))},d=u=>{let h=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return p=>h.format(p)};switch(n){case"integer":return c({maximumFractionDigits:0});case"decimal":return c(l(2));case"percent":return c({style:"percent",...l(0)});case"currency":return c({style:"currency",currency:e.currency??"USD",...l()});case"compact":return c({notation:"compact",...l(1)});case"scientific":return c({notation:"scientific",...l(2)});case"date":return d({dateStyle:"medium"});case"time":return d({timeStyle:"short"});case"datetime":return d({dateStyle:"medium",timeStyle:"short"});case"duration":return s(Yr)}}function et(e,n){if(typeof e=="string")return e;let t=e instanceof Date?e.getTime():e;return n?Ce(n)(t):e instanceof Date?new Intl.DateTimeFormat().format(e):Yn(t)}var ce=e=>{if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let n=Number(e);return Number.isFinite(n)&&e.trim()!==""?n:Date.parse(e)};function Ie([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function ve(e,n,t=5){if(e===n)return[e];let r=(n-e)/Math.max(1,t),i=10**Math.floor(Math.log10(r)),o=r/i,s=(o<1.5?1:o<3.5?2:o<7.5?5:10)*i,l=Math.floor(e/s)*s,c=Math.ceil(n/s)*s,d=[];for(let u=l;u<=c+s/2;u+=s)d.push(Jn(u));return d}function Qn(e,[n,t],r=.2){let i=e===0?0:(t-n)/e,o=i*(1-Math.max(0,Math.min(.9,r)));return{step:i,bandwidth:o,start:s=>n+s*i+(i-o)/2,center:s=>n+(s+.5)*i}}var Jn=e=>Number(e.toPrecision(12)),m=e=>Number(e.toFixed(2)),$=e=>typeof e=="number"&&Number.isFinite(e),de=e=>e.filter($);function ue(e){let n=1/0,t=-1/0;for(let r of e)$(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}function ke(e,n="linear"){if(e.length===0)return"";let t=e[0];if(n==="step"||n==="stepBefore"||n==="stepAfter"){let d=`M${t.x} ${t.y}`;for(let u=1;u<e.length;u++){let h=e[u-1],p=e[u];n==="stepAfter"?d+=`H${p.x}V${p.y}`:n==="stepBefore"?d+=`V${p.y}H${p.x}`:d+=`H${m((h.x+p.x)/2)}V${p.y}H${p.x}`}return d}if(n==="linear"||e.length<3)return`M${e.map(d=>`${d.x} ${d.y}`).join("L")}`;let r=e.length,i=e.slice(1).map((d,u)=>d.x-e[u].x),o=e.slice(1).map((d,u)=>d.y-e[u].y),s=i.map((d,u)=>d===0?0:o[u]/d),l=[s[0]];for(let d=1;d<r-1;d++){let u=s[d-1],h=s[d];l.push(u*h<=0?0:(u+h)/2)}l.push(s[r-2]);for(let d=0;d<r-1;d++){let u=s[d];if(u===0){l[d]=0,l[d+1]=0;continue}let h=l[d]/u,p=l[d+1]/u,v=Math.hypot(h,p);v>3&&(l[d]=3*h*u/v,l[d+1]=3*p*u/v)}let c=`M${t.x} ${t.y}`;for(let d=0;d<r-1;d++){let u=e[d],h=e[d+1],p=i[d]/3;c+=`C${m(u.x+p)} ${m(u.y+p*l[d])} ${m(h.x-p)} ${m(h.y-p*l[d+1])} ${h.x} ${h.y}`}return c}var Pe=1e3,Ne=60*Pe,Fe=60*Ne,Ge=24*Fe,Qr=[Pe,5*Pe,15*Pe,30*Pe,Ne,5*Ne,15*Ne,30*Ne,Fe,3*Fe,6*Fe,12*Fe,Ge,2*Ge,7*Ge,14*Ge];function er(e,n,t=6){if(!(n>e))return[e];let r=n-e,i=Qr.find(h=>r/h<=t),o=[];if(i!==void 0){for(let h=Math.ceil(e/i)*i;h<=n;h+=i)o.push(h);return o.length?o:[e,n]}let s=r/(30*Ge),l=[1,2,3,6,12,24,60,120].find(h=>s/h<=t)??240,c=new Date(e),d=c.getUTCFullYear(),u=Math.ceil((c.getUTCMonth()+(c.getUTCDate()>1?1:0))/l)*l;for(let h=Date.UTC(d,u,1);h<=n;)o.push(h),u+=l,u>=12&&(d+=Math.floor(u/12),u%=12),h=Date.UTC(d,u,1);return o.length?o:[e,n]}function tr(e,n){let t=Math.floor(Math.log10(e)),r=Math.ceil(Math.log10(n)),i=r-t<=1?[1,2,5]:[1],o=[];for(let s=t;s<=r;s++)for(let l of i)o.push(Jn(l*10**s));return o.filter(s=>s>=e/1.0001&&s<=n*1.0001)}function tt(e,n={}){if(n.thresholds&&n.thresholds.length>=2)return[...n.thresholds].filter(Number.isFinite).sort((c,d)=>c-d);let[t,r]=n.domain??ue(e),i=Math.max(1,e.length),o=Math.max(1,n.bins??Math.ceil(Math.log2(i)+1)),s=n.binWidth??(r>t?(r-t)/o:1),l=r>t?Math.max(1,Math.ceil((r-t)/s-1e-9)):1;return Array.from({length:l+1},(c,d)=>Number((t+d*s).toPrecision(12)))}function nt(e,n){let t=[];for(let o=0;o+1<n.length;o++)t.push({x0:n[o],x1:n[o+1],count:0});if(t.length===0)return t;let r=n[0],i=n[n.length-1];for(let o of de(e)){if(o<r||o>i)continue;let s=0,l=t.length-1;for(;s<l;){let c=s+l+1>>1;t[c].x0<=o?s=c:l=c-1}t[s].count++}return t}var Jr=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,ei=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,ti={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function ni(e,n,t){return e.replace(ei,(r,i,o)=>{let s=ti[i];if(s===void 0)return i+o;let c=(o.match(Jr)??[]).map((d,u)=>{let h=Number(d);if(s===-1)return String(h+n);if(s===-2)return String(h+t);let p=u%s;return s===7?p===5?String(h+n):p===6?String(h+t):d:String(p%2===0?h+n:h+t)});return i+c.join(" ")})}var nr=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:ni(r.d,n,t)}}});var Lt=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),V={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"},rt=(e="neutral")=>e==="neutral"?V.axis:`var(--skdx-color-${e}-500)`,Rt=(e="neutral")=>e==="neutral"?V.label:e==="primary"?"var(--skdx-color-text-accent)":`var(--skdx-color-text-${e})`,rr=(e,n)=>n??Lt[e%Lt.length];var te={top:16,right:16,bottom:32,left:48};function ir(e,n,t=te){return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}function _e(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function Bt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var or=e=>e.crosshair===!0||Bt(e).trigger==="axis",it=20,ri=120,sr=e=>{let n=_e(e);return n&&(n.position==="left"||n.position==="right")?n.width??ri:0},ot=(e,n=600,t=300)=>({width:(e.width??n)-sr(e),height:(e.height??t)-(_e(e)?.position==="bottom"?it:0)}),ar=(e,n,t)=>{let r=_e(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,dr(n,t??ot(e).width,r)):1)*it},ie=6.5,lr=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:rr(n)),cr=(e,n)=>e.hiddenSeries?.includes(n)??!1;function Vt(e,n,t=[],r={},i=10,o=8,s=!1){let l=[],c=r.maxItems,d=c!==void 0&&c>=0&&e.length>c?e.slice(0,c):e,u=e.length-d.length,h=r.interactive??!0,p=o,v=i,y=(b,S,w,f)=>{let M=(S?18:4)+b.length*ie;p>o&&(s||p+M>n-8)&&(p=o,v+=it),S&&l.push({kind:"rect",part:"legend-swatch",x:p,y:v-5,width:10,height:10,fill:S,opacity:f?.3:void 0,item:w}),l.push({kind:"text",part:"legend-label",x:p+(S?14:0),y:v,text:b,baseline:"middle",fill:f?V.grid:V.label,item:w}),p+=M+12};for(let b of d){let S=t.includes(b.name),w=h?{label:b.name,series:b.name,legend:!0}:void 0;y(r.formatter?.(b.name)??b.name,b.color,w,S)}return u>0&&y(`+${u} more`,void 0,void 0,!1),r.align==="end"?ii(l,n):l}function ii(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(l=>l.kind==="rect"?l.x+l.width:l.x+l.text.length*ie)),s=n-8-o;for(let l of i)r.push({...l,x:l.x+s})}return r}var dr=(e,n,t={})=>new Set(Vt(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Dt(e,n,t,r=[]){let i=_e(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=Bt(e),l=o?.position==="bottom",c=sr(e),d=e.hiddenSeries??[],u=o?c?Vt(r,1/0,d,o,10,(o.position==="right"?n:0)+8,!0):Vt(r,n,d,o,l?t+10:10):[],h=l?dr(r,n,o):0;return{width:n+c,height:l?t+Math.max(1,h)*it:t,legendOffset:o?.position==="left"?c:void 0,tooltip:s.enabled,tooltipFormatter:s.formatter,axisTooltipFormatter:s.axisFormatter,tooltipPortal:s.portal,tooltipPlacement:s.placement,tooltipAnchored:s.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:u}}function Pt(e){let n=e.legendOffset;if(!n)return e;let t=[...nr(e.shapes.filter(c=>!c.part.startsWith("legend-")),n,0),...e.shapes.filter(c=>c.part.startsWith("legend-"))],r=c=>({...c,x:c.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(c=>c+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,s=o?{...o,scale:c=>o.scale(c)+n,invert:c=>o.invert(c-n),bars:o.bars.map(c=>({...c,x0:c.x0+n,x1:c.x1+n}))}:void 0,l=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:s,map:l,legendOffset:void 0}}function st(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],l=Math.max(...s.map(p=>p.length))*ie+12,c=6+s.length*16,d=o==="top"?{x:e-l/2,y:n-c-8}:o==="bottom"?{x:e-l/2,y:n+8}:o==="left"?{x:e-l-8,y:n-c/2}:o==="right"?{x:e+8,y:n-c/2}:{x:e+12,y:n-c-6},u=Math.max(0,Math.min(r-l,d.x)),h=Math.max(0,Math.min(i-c,d.y));return[{kind:"rect",part:"tooltip",x:m(u),y:m(h),width:m(l),height:c,fill:"var(--skdx-color-surface-raised)",stroke:V.axis,rx:3},...s.map((p,v)=>({kind:"text",part:"tooltip-label",x:m(u+6),y:m(h+11+v*16),text:p,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&v===0?"bold":void 0}))]}function ur([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,s=Ce(o.format??i),l=o.min??e,c=o.max??n;o.reversed&&(t=[t[1],t[0]]);let d={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let b=O=>Math.sign(O)*Math.sqrt(Math.abs(O)),S=o.nice===!1?[l,c]:ve(l,c,o.ticks),w=o.min??S[0],f=o.max??S[S.length-1],M=Ie([b(w),b(f)],t),I=O=>M(b(O)),k=ve(w,f,o.ticks).filter(O=>O>=w-1e-9&&O<=f+1e-9);return{...d,scale:I,domain:[w,f],format:s,ticks:(k.length>=2?k:[w,f]).map(O=>({pos:m(I(O)),label:s(O)})),zero:m(I(Math.min(Math.max(0,w),f)))}}if(o.scale==="log"){let b=Math.max(l,Number.EPSILON),S=Math.max(c,b),w=tr(b,S),f=[Math.log10(b),Math.log10(S)],M=Ie(f,t),I=k=>M(Math.log10(Math.max(k,Number.EPSILON)));return{...d,scale:I,domain:f,format:s,ticks:w.map(k=>({pos:m(I(k)),label:s(k)})),zero:m(t[0])}}let u=ve(l,c,o.ticks),h=[o.min??(o.nice===!1?l:u[0]),o.max??(o.nice===!1?c:u[u.length-1])],p=Ie(h,t),v=u.filter(b=>b>=h[0]-1e-9&&b<=h[1]+1e-9),y=(v.length>=2?v:[h[0],h[1]]).map(b=>({pos:m(p(b)),label:s(b)}));return{...d,scale:p,domain:h,format:s,ticks:y,zero:m(p(Math.min(Math.max(0,h[0]),h[1])))}}var hr=([e,n],t)=>Math.max(te.left,ve(e,n).reduce((r,i)=>Math.max(r,t(i).length),0)*ie+14),fr=e=>e?.grid!==!1;function at(e,n){if(e.length<2)return e;let t=e.reduce((i,o)=>Math.max(i,o.label.length),0)*ie+8,r=Math.max(1,Math.ceil(e.length*t/Math.max(1,n)));return r===1?e:e.filter((i,o)=>o%r===0)}var Nt=(e,n,t,r)=>`${e}, ${n}: ${r(t)}`;function mr(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:s}=ot(e,t,r),l=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",c=[];return i==="loading"&&c.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),c.push({kind:"text",part:`state-${i}`,x:m(o/2),y:m(s/2),text:l,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":V.label}),{...Dt(e,o,s),shapes:c,tooltip:!1}}var pr=(e,n,t)=>{let r=n.length*ie/2;return e+r>t?"end":e-r<0?"start":"middle"};function Ft(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,s=t.x+t.width,l=t.y+t.height,c=[],d=n.grid??!0,u=(y,b)=>b?{kind:"line",part:"grid",x1:y.pos,x2:y.pos,y1:t.y,y2:l,stroke:V.grid}:{kind:"line",part:"grid",x1:t.x,x2:s,y1:y.pos,y2:y.pos,stroke:V.grid},h=n.x?.tickRotation??0,p=(y,b,S,w)=>h?q(y,b,S,{part:w,anchor:h<0?"end":"start",baseline:"middle",rotate:h}):q(y,b,S,{part:w,anchor:pr(y,S,e.width)}),v=(y,b,S,w,f)=>{for(let M of y)c.push(b==="x"?{kind:"line",part:"tick",x1:M.pos,x2:M.pos,y1:S,y2:m(S+w*f),stroke:V.axis}:{kind:"line",part:"tick",x1:S,x2:m(S+w*f),y1:M.pos,y2:M.pos,stroke:V.axis})};if(n.categoryGrid)for(let y of r)c.push(u(y,!n.horizontal));if(n.horizontal){let y=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(d)for(let b of i)c.push(u(b,!0));y[0]?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:l,stroke:V.axis});for(let b of y){let S=b.position==="top"||b.position==="right",w=m(S?t.y-b.offset:l+b.offset),f=S||b.offset>0;b.showLine&&f&&c.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:w,y2:w,stroke:V.axis}),b.showTicks&&v(b.ticks,"x",w,S?-1:1,b.tickSize??4);let M=m(S?w-8:w+20);for(let I of b.ticks)c.push(S?q(I.pos,M,I.label,{part:"x-label-top",anchor:pr(I.pos,I.label,e.width)}):p(I.pos,M,I.label,"x-label"));b.label&&c.push(f?q(4,M,b.label,{part:"axis-title",anchor:"start",baseline:S?void 0:"middle"}):q(4,t.y-6,b.label,{part:"axis-title",anchor:"start"}))}n.x?.showLine&&c.push({kind:"line",part:"axis",x1:n.rtl?s:t.x,x2:n.rtl?s:t.x,y1:t.y,y2:l,stroke:V.axis}),n.x?.showTicks&&v(r,"y",n.rtl?s:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let b of r)c.push(n.rtl?q(s+8,b.pos,b.label,{part:"y-label",anchor:"start",baseline:"middle"}):q(t.x-8,b.pos,b.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(d)for(let b of i)c.push(u(b,!1));n.y?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:o,y2:o,stroke:V.axis});let y=n.axes??[{ticks:i,position:"left",offset:0,label:n.yLabel,...n.y},...n.rightTicks?[{ticks:n.rightTicks,position:"right",offset:0,label:n.rightLabel}]:[]];for(let b of y){let S=b.position==="left",w=S?t.x-b.offset:s+b.offset,f=S?"y-label":"y-label-right";b.showLine&&c.push({kind:"line",part:"axis",x1:m(w),x2:m(w),y1:t.y,y2:l,stroke:V.axis}),b.showTicks&&v(b.ticks,"y",m(w),S?-1:1,b.tickSize??4);for(let M of b.ticks)c.push(q(m(S?w-8:w+8),M.pos,M.label,{part:f,anchor:S?"end":"start",baseline:"middle"}));b.label&&c.push(q(m(S?b.offset===0?4:Math.max(4,w-40):b.offset===0?e.width-4:Math.min(e.width-4,w+40)),t.y-6,b.label,{part:"axis-title",anchor:S?"start":"end"}))}n.x?.showTicks&&v(r,"x",l,1,n.x.tickSize??4);for(let b of r)c.push(p(b.pos,l+(h?12:20),b.label,"x-label"))}return n.xLabel&&c.push(q(m(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&c.push(q(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),c}var q=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:V.label,...r}),je=(e,n,t,r,i,o)=>({kind:"circle",part:"point",cx:e,cy:n,r:t,fill:r,title:i,item:o});function Gt(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height,s=c=>Math.max(r.x,Math.min(i,c)),l=c=>Math.max(r.y,Math.min(o,c));for(let c of e??[]){let d=c.color??rt(c.variant),u=c.color??Rt(c.variant),h={part:"reference-label",fill:u},p=n.horizontal===!0;if("y"in c){let v=m(n.y(c.y,c.axis??"left"));if(p){let y=s(v);t.push(...gr(y,r.y,o,d,c.label,h))}else{let y=l(v);t.push(...br(r.x,i,y,d,c.label,h))}}else if("x"in c){let v=n.x(c.x);if(v===void 0)continue;p?t.push(...br(r.x,i,l(m(v)),d,c.label,h)):t.push(...gr(s(m(v)),r.y,o,d,c.label,h))}else if("y1"in c){let v=m(n.y(c.y1,c.axis??"left")),y=m(n.y(c.y2,c.axis??"left"));p?t.push(...yr(s(Math.min(v,y)),s(Math.max(v,y)),r,d,c.label,u)):t.push(...xr(l(Math.min(v,y)),l(Math.max(v,y)),r,d,c.label,u))}else{let v=n.x(c.x1),y=n.x(c.x2);if(v===void 0||y===void 0)continue;let b=m(Math.min(v,y)),S=m(Math.max(v,y));p?t.push(...xr(l(b),l(S),r,d,c.label,u)):t.push(...yr(s(b),s(S),r,d,c.label,u))}}return t}function br(e,n,t,r,i,o){let s={kind:"line",part:"reference",x1:e,x2:n,y1:t,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[s,q(n-4,t-5,i,{...o,anchor:"end"})]:[s]}function gr(e,n,t,r,i,o){let s={kind:"line",part:"reference",x1:e,x2:e,y1:n,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[s,q(e+4,n+10,i,{...o,anchor:"start"})]:[s]}function xr(e,n,t,r,i,o){let s={kind:"rect",part:"reference-area",x:t.x,y:e,width:t.width,height:m(Math.max(0,n-e)),fill:r,opacity:.12,title:i};return i?[s,q(t.x+t.width-4,e+12,i,{part:"reference-label",fill:o,anchor:"end"})]:[s]}function yr(e,n,t,r,i,o){let s={kind:"rect",part:"reference-area",x:e,y:t.y,width:m(Math.max(0,n-e)),height:t.height,fill:r,opacity:.12,title:i};return i?[s,q(e+4,t.y+12,i,{part:"reference-label",fill:o,anchor:"start"})]:[s]}function vr(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height;for(let s of e??[]){let l=s.color??rt(s.variant),c=s.color??Rt(s.variant),d=(y,b,S)=>{let w=n.x(y);if(w===void 0)return;let f=n.y(b,S??"left");return n.horizontal?{x:m(f),y:m(w)}:{x:m(w),y:m(f)}},u=s.id??s.label,h=y=>({label:y,id:u,name:s.label});if(s.type==="line"||s.type==="band"){let{type:y,id:b,...S}=s;t.push(...Gt([S],n));continue}if(s.type==="rect"){let y=d(s.x1,s.y1,s.axis),b=d(s.x2,s.y2,s.axis);if(!y||!b)continue;let S=Math.max(r.x,Math.min(y.x,b.x)),w=Math.max(r.y,Math.min(y.y,b.y)),f=s.label??"";t.push({kind:"rect",part:"annotation-rect",x:m(S),y:m(w),width:m(Math.max(0,Math.min(i,Math.max(y.x,b.x))-S)),height:m(Math.max(0,Math.min(o,Math.max(y.y,b.y))-w)),fill:l,opacity:.12,stroke:l,title:f||void 0,item:f?h(f):void 0}),s.label&&t.push(q(m(S+4),m(w+12),s.label,{part:"annotation-label",fill:c}));continue}let p=d(s.x,s.y,s.axis);if(!p)continue;if(s.type==="text"){t.push(q(p.x,p.y,s.text,{part:"annotation-text",fill:c,anchor:"middle",baseline:"middle",title:s.label}));continue}let v=s.label??`${String(s.x)}, ${s.y}`;if(t.push({kind:"circle",part:"annotation-point",cx:p.x,cy:p.y,r:5,fill:l,stroke:"var(--skdx-color-surface-default)",title:v,item:h(v)}),s.type==="callout"&&s.label){let[y,b]=s.offset??[16,-16],S=m(Math.max(r.x,Math.min(i,p.x+y))),w=m(Math.max(r.y,Math.min(o,p.y+b)));t.push({kind:"line",part:"annotation-leader",x1:p.x,y1:p.y,x2:S,y2:w,stroke:l},q(S,w,s.label,{part:"annotation-label",fill:c,anchor:y>=0?"start":"end",baseline:"middle"}))}}return t}var _t=2e3;function oi(e){if(e!=="none")return e===void 0||e==="auto"?{strategy:"lttb",threshold:_t}:typeof e=="string"?{strategy:e,threshold:_t}:{strategy:e.strategy,threshold:e.threshold??_t}}function si(e,n){let t=e.length;if(n>=t||n<3)return e.map((l,c)=>c);let r=[0],i=[],o=(t-2)/(n-2),s=0;for(let l=0;l<n-2;l++){let c=Math.floor((l+1)*o)+1,d=Math.min(t-1,Math.floor((l+2)*o)+1),u=0,h=0,p=0;for(let M=c;M<d;M++){let I=e[M];$(I)&&(u+=M,h+=I,p++)}u=p?u/p:(c+d)/2,h=p?h/p:0;let v=Math.floor(l*o)+1,y=Math.min(t-1,Math.floor((l+1)*o)+1),b=e[s],S=$(b)?b:0,w=-1,f=-1;for(let M=v;M<y;M++){let I=e[M];if(!$(I)){i.push(M);continue}let k=Math.abs((s-u)*(I-S)-(s-M)*(h-S));k>f&&(f=k,w=M)}w<0&&(w=v),r.push(w),s=w}return r.push(t-1),i.length?[...new Set([...r,...i])].sort((l,c)=>l-c):r}function ai(e,n){let t=e.length,r=Math.max(1,Math.floor(n/2));if(r*2>=t)return e.map((s,l)=>l);let i=[],o=t/r;for(let s=0;s<r;s++){let l=Math.floor(s*o),c=s===r-1?t:Math.floor((s+1)*o),d=-1,u=-1;for(let h=l;h<c;h++){let p=e[h];if(!$(p)){i.push(h);continue}(d<0||p<e[d])&&(d=h),(u<0||p>e[u])&&(u=h)}d>=0&&i.push(Math.min(d,u)),u>=0&&u!==d&&i.push(Math.max(d,u))}return[...new Set(i)].sort((s,l)=>s-l)}function li(e,n){let t=e.length,r=Math.max(1,Math.floor(n/4));if(r*4>=t)return e.map((s,l)=>l);let i=[],o=t/r;for(let s=0;s<r;s++){let l=Math.floor(s*o),c=s===r-1?t:Math.floor((s+1)*o),d=-1,u=-1,h=-1,p=-1;for(let v=l;v<c;v++){let y=e[v];if(!$(y)){i.push(v);continue}h<0&&(h=v),p=v,(d<0||y<e[d])&&(d=v),(u<0||y>e[u])&&(u=v)}for(let v of[h,d,u,p])v>=0&&i.push(v)}return[...new Set(i)].sort((s,l)=>s-l)}function kr(e,n,t){let r=oi(t);if(!r||n<=r.threshold||e.length===0)return;let i=r.strategy==="minmax"?ai:r.strategy==="m4"?li:si,o=new Set;for(let s of e)for(let l of i(s.slice(0,n),r.threshold))o.add(l);return[...o].sort((s,l)=>s-l)}function wr(e,n,t,r,i,o,s,l){if(r==="circle")return{...je(e,n,t,i,o,s),part:l};let c=r==="square"?`M${m(e-t)} ${m(n-t)}h${m(2*t)}v${m(2*t)}h${m(-2*t)}Z`:r==="diamond"?`M${m(e)} ${m(n-t*1.3)}L${m(e+t*1.3)} ${m(n)}L${m(e)} ${m(n+t*1.3)}L${m(e-t*1.3)} ${m(n)}Z`:`M${m(e)} ${m(n-t*1.2)}L${m(e+t*1.15)} ${m(n+t*.9)}L${m(e-t*1.15)} ${m(n+t*.9)}Z`;return{kind:"path",part:l,d:c,fill:i,title:o,item:s}}var ci=e=>{let n=0;return e.map(t=>$(t)?n+=t:null)},di=e=>e.map((n,t)=>{let r=e[t-1];return t>0&&$(n)&&$(r)?n-r:null}),ui=e=>e.map((n,t)=>{let r=e[t-1];return t>0&&$(n)&&$(r)&&r!==0?(n-r)/Math.abs(r):null});function hi(e,n){let t=Math.max(1,Math.floor(n));return e.map((r,i)=>{if(i<t-1)return null;let o=0;for(let s=i-t+1;s<=i;s++){let l=e[s];if(!$(l))return null;o+=l}return o/t})}function fi(e,n="max"){let t=0;for(let r of e)$(r)&&(t=n==="sum"?t+r:Math.max(t,r));return e.map(r=>$(r)?t===0?0:r/t:null)}function mi(e,n="desc"){let t=e.filter($).sort((r,i)=>n==="asc"?r-i:i-r);return e.map(r=>$(r)?t.indexOf(r)+1:null)}var pi=(e,n=-1/0,t=1/0)=>e.map(r=>$(r)&&r>=n&&r<=t?r:null),bi=(e,n="asc")=>[...e].sort((t,r)=>$(t)?$(r)?n==="asc"?t-r:r-t:-1:$(r)?1:0);function gi(e,n,t="sum"){let r=Math.max(1,Math.floor(n)),i=[];for(let o=0;o<e.length;o+=r){let s=e.slice(o,o+r).filter($);if(s.length===0){i.push(null);continue}let l=s.reduce((c,d)=>c+d,0);i.push(t==="sum"?l:t==="mean"?l/s.length:t==="min"?Math.min(...s):Math.max(...s))}return i}function xi(e,n={}){let t=e.filter($),r=tt(t,n);return{edges:r,counts:nt(t,r).map(i=>i.count)}}function jt(e,n){let t=[...e];for(let r of n??[])switch(r.type){case"cumulative":t=ci(t);break;case"difference":t=di(t);break;case"percentageChange":t=ui(t);break;case"movingAverage":t=hi(t,r.window);break;case"normalize":t=fi(t,r.to);break;case"rank":t=mi(t,r.order);break;case"filter":t=pi(t,r.min,r.max);break;case"sort":t=bi(t,r.order);break;case"aggregate":t=gi(t,r.every,r.method);break;case"bin":t=xi(t,r).counts;break}return t}var yi=100,vi=2e3,Mr=32,Sr=28,ct=e=>e.position==="right"||e.position==="top";function ki(e){let t=(e.yAxis===void 0?[]:Array.isArray(e.yAxis)?e.yAxis:[e.yAxis]).map((i,o)=>({...i,id:i.id??(o===0?"left":o===1?"right":String(o)),position:i.position??(o===1?"right":"left")}));t.length===0&&t.push({id:"left",position:"left"});let r=t.some(i=>i.id==="right"||ct(i));return e.rightAxis?t.push({...e.rightAxis,id:"right",position:"right"}):!r&&e.series.some(i=>i.axis==="right")&&t.push({id:"right",position:"right"}),t}function Cr(e,n){let t=e[0]?.id;return n===void 0||n==="left"?t:n==="right"?(e.find(r=>r.id==="right")??e.find(ct))?.id:e.find(r=>r.id===n)?.id}var lt=e=>e.kind==="bar"||e.kind==="range"&&e.style==="bar";function Ir(e,n){let t=Ce(e.format),{series:r,categories:i,issues:o,axes:s}=Mi(e,n,t),l=e.direction==="rtl",c=e.baseline??0,d=Math.max(i.length,...r.map(a=>Math.max(a.data.length,a.low.length))),u=r.every(a=>de(a.data).length===0&&de(a.high).length===0),h=mr(e,u);if(h)return{...h,issues:o};let p=e.xAxis?.type??"category",v=p!=="category"&&i.length>0&&i.every(a=>typeof a!="string"||p==="time"&&$(ce(a))),y=v?i.map(ce):[],[b,S]=ue(y),w=e.xAxis?.format??(p==="time"?{style:S-b<2*864e5?"time":"date"}:void 0),f=Array.from({length:d},(a,x)=>{let C=i[x];return C===void 0?String(x+1):et(C,w)}),M=wi(e.zoom,d),I=Array.from({length:M.end-M.start},(a,x)=>M.start+x),k=e.orientation==="horizontal",F=r.map(a=>({...a,hidden:a.hidden||k&&!lt(a)})).filter(a=>!a.hidden),j=F.some(a=>!lt(a))?kr(F.filter(a=>!lt(a)).map(a=>I.map(x=>(a.kind==="range"?a.high[x]:a.data[x])??null)),I.length,e.sampling):void 0,B=j?j.map(a=>I[a]):I,X=e.stacked==="percent"||e.stackOffset==="expand",Q=e.stackOffset??"zero",se=new Map,me=new Map,bt=new Map;for(let a of F)a.stack!==void 0&&a.kind!=="range"&&bt.set(a.stack,[...bt.get(a.stack)??[],a]);for(let a of bt.values()){let x=new Array(d).fill(c),C=new Array(d).fill(c),G=new Array(d).fill(0);if(X)for(let P of a)P.data.forEach((L,_)=>{$(L)&&(G[_]=G[_]+Math.abs(L))});for(let P of a){let L=[],_=[];for(let D=0;D<d;D++){let N=P.data[D];if(!$(N)){L.push(null),_.push(null);continue}let z=G[D],T=X?z>0?N/z:0:N,H=T>=0?x:C;L.push(H[D]),H[D]=H[D]+T,_.push(H[D])}se.set(P,L),me.set(P,_)}if(Q==="silhouette"||Q==="wiggle"){let P=new Array(d).fill(0);if(Q==="silhouette")for(let L=0;L<d;L++)P[L]=-(x[L]-c)/2;else{let L=0;for(let _=0;_<d;_++){let D=a.length,N=0;for(let T=0;T<D;T++){let H=a[T],W=H.data[_],K=H.data[_-1],J=_>0&&$(W)&&$(K)?W-K:0;N+=(D-T-.5)*J}let z=x[_]-c;L=_===0?-z/2:L-(z>0?N/Math.max(1,D):0),P[_]=L}}for(let L of a){let _=se.get(L),D=me.get(L);for(let N=0;N<d;N++){let z=_[N],T=D[N];$(z)&&(_[N]=z+P[N]),$(T)&&(D[N]=T+P[N])}}}}let $n=a=>a.kind==="range"?{from:a.low,to:a.high}:{from:se.get(a)??new Array(d).fill(c),to:me.get(a)??a.data},Cn=a=>{let x=[],C=!1;for(let L of F){if(L.axis!==a)continue;let{from:_,to:D}=$n(L);for(let N of B){let z=D[N];if($(z)&&x.push(z),L.kind==="range"||L.stack!==void 0){let T=_[N];$(T)&&x.push(T)}}if(L.errors)for(let N of B){let z=$r(L.data[N],L.errors[N]);z&&x.push(z[0],z[1])}(L.kind==="bar"||L.kind==="area")&&Q==="zero"&&(C=!0)}let[G,P]=ue(x);return C?[Math.min(c,G),Math.max(c,P)]:[G,P]},{width:In,height:Tn}=ot(e),Fr=e.brush?Mr+Sr:0,An=B.reduce((a,x)=>Math.max(a,f[x].length),0)*ie,On=X?{style:"percent"}:void 0,Gr=a=>{if(a.scale==="log")return te.left;let[x,C]=Cn(a.id),G=Ce(a.format??On??e.format);return hr([a.min??x,a.max??C],G)+(a.showTicks?a.tickSize??4:0)},gt=a=>k?ct(a)?"top":"bottom":ct(a)!==l?"right":"left",zn=a=>k?24+(a.showTicks?a.tickSize??4:0):Gr(a),_r=new Set(F.map(a=>a.axis)),xt=s.filter(a=>_r.has(a.id)||s.length>1),Ln=new Map,we={left:0,right:0,top:0,bottom:0};for(let a of xt){let x=gt(a);Ln.set(a.id,we[x]),we[x]+=zn(a)}let Rn=xt.find(a=>gt(a)==="bottom"),jr={top:te.top+ar(e)+(s.some(a=>a.label)?12:0)+we.top,right:k?l?Math.max(te.left,An+16):te.right:Math.max(te.right,we.right),bottom:te.bottom+Fr+(e.xAxis?.label?14:0)+(e.xAxis?.tickRotation?24:0)+we.bottom-(Rn?zn(Rn):0),left:k?l?te.right:Math.max(te.left,An+16):Math.max(te.left,we.left)},U=ir(In,Tn,jr),Hr=k?l?[U.x+U.width,U.x]:[U.x,U.x+U.width]:[U.y+U.height,U.y],Vn=k?[U.y,U.y+U.height]:l?[U.x+U.width,U.x]:[U.x,U.x+U.width],yt=new Map(s.map(a=>[a.id,{...ur(Cn(a.id),Hr,{format:On,...a},e.format),position:gt(a),offset:Ln.get(a.id)??0}])),Bn=s[0]?.id,Ee=yt.get(Bn),vt=a=>yt.get(Cr(s,a)??Bn)??Ee,ae=(a,x)=>vt(x).scale(a),Dn=a=>m(a.scale(Math.min(Math.max(c,Math.min(...a.domain)),Math.max(...a.domain)))),Ue=Qn(B.length,Vn,e.barGap),kt=B.map(a=>y[a]),wt=[...kt].sort((a,x)=>a-x),Me=1/0;for(let a=1;a<wt.length;a++)Me=Math.min(Me,wt[a]-wt[a-1]);let[Se,ze]=ue(kt),le=Me===1/0?Math.max(1,Math.abs(ze)*.05||1):Me/2,Le=Ie([Se-le,ze+le],Vn),Ke=a=>m(v?Le(kt[a]):Ue.center(a)),Pn=v?Math.abs(Le(Se+(Me===1/0?le:Me))-Le(Se))*.8:Ue.bandwidth,Nn=a=>v?Ke(a)-Pn/2:Ue.start(a),Wr=v?(p==="time"?er(Se-le,ze+le):ve(Se-le,ze+le)).filter(a=>a>=Se-le&&a<=ze+le).map(a=>({pos:m(Le(a)),label:et(a,w)})):at(B.map((a,x)=>({pos:Ke(x),label:f[a]})),k?1/0:U.width/Math.max(.2,Math.abs(Math.cos((e.xAxis?.tickRotation??0)*Math.PI/180)))),Mt={...Dt(e,In,Tn,r.map(a=>({name:a.name,color:a.color}))),plot:U,xTicks:Wr,yTicks:k?at(Ee.ticks,U.width):Ee.ticks,baseline:Dn(Ee)},Zr=s[0],Fn=Ft(Mt,{horizontal:k,rtl:l,axes:xt.map(a=>{let x=yt.get(a.id);return{ticks:k?at(x.ticks,U.width):x.ticks,position:x.position,offset:x.offset??0,label:a.label,showLine:a.showLine,showTicks:a.showTicks,tickSize:a.tickSize}}),xLabel:e.xAxis?.label,grid:fr(Zr),categoryGrid:e.xAxis?.grid===!0,x:e.xAxis}),Er=a=>{if(typeof a=="number"&&i.every(C=>typeof C=="string"))return a;let x=typeof a=="string"?a:ce(a);for(let C=0;C<d;C++){let G=i[C];if(G!==void 0&&(typeof x=="string"?G===x||f[C]===x:ce(G)===x))return C}},Gn={plot:U,horizontal:k,x:a=>{if(v&&(typeof a!="string"||$(ce(a))))return Le(ce(a));let x=Er(a),C=x===void 0?-1:B.indexOf(x);return C<0?void 0:Ue.center(C)},y:(a,x)=>ae(a,x)};Fn.push(...Gt(e.references,Gn));let St=[],$t=new Map;for(let a of F){if(!lt(a))continue;let x=a.stack??a,C=St.indexOf(x);C<0&&(C=St.push(x)-1),$t.set(a,C)}let qe=Pn/Math.max(1,St.length),pe=Math.min(qe,e.barWidth??1/0),_n=(qe-pe)/2,Ct=[],Xe=[],It=[],Tt=[],At=[],jn=[],Ye=[],Qe=a=>vt(a.axis).format,Ot=Math.max(0,e.minBarSize??0),Ur=(a,x,C)=>{let G=Math.abs(x-a);if(G>=Ot)return[Math.min(a,x),G];let L=a+(k?C?1:-1:C?-1:1)*Ot;return[Math.min(a,L),Ot]},Re=(a,x,C,G)=>({label:G,series:a.name,seriesId:a.id??a.name,category:f[x],index:x,value:C}),Hn=(a,x,C,G)=>{let P=$r(G,a.errors?.[x]);if(!P)return;let L=m(ae(P[0],a.axis)),_=m(ae(P[1],a.axis)),D=4,N="var(--skdx-color-text-default)",z=`${a.name}, ${f[x]}: ${Qe(a)(P[0])} \u2013 ${Qe(a)(P[1])}`;jn.push(k?{kind:"line",part:"error-bar",x1:L,x2:_,y1:C,y2:C,stroke:N,title:z}:{kind:"line",part:"error-bar",x1:C,x2:C,y1:L,y2:_,stroke:N,title:z},k?{kind:"line",part:"error-cap",x1:L,x2:L,y1:m(C-D),y2:m(C+D),stroke:N}:{kind:"line",part:"error-cap",x1:m(C-D),x2:m(C+D),y1:L,y2:L,stroke:N},k?{kind:"line",part:"error-cap",x1:_,x2:_,y1:m(C-D),y2:m(C+D),stroke:N}:{kind:"line",part:"error-cap",x1:m(C-D),x2:m(C+D),y1:_,y2:_,stroke:N})};for(let a of F){let{from:x,to:C}=$n(a),G=Qe(a),P=B.length<=vi;if(a.kind==="bar"){let z="";B.forEach((T,H)=>{let W=a.data[T],K=x[T],J=C[T];if(!$(W)||!$(K)||!$(J))return;let $e=ae(K,a.axis),ye=ae(J,a.axis),[Ve,Be]=Ur($e,ye,J>=K),De=Nn(H)+$t.get(a)*qe+_n,Zn=m(k?Ve:De),En=m(k?De:Ve),zt=m(k?Be:pe),Un=m(k?pe:Be);if(!P){z+=`M${Zn} ${En}h${zt}v${Un}h${-zt}Z`;return}let Kn=Nt(a.name,f[T],X?J-K:W,G);if(Xe.push({kind:"rect",part:"bar",x:Zn,y:En,width:zt,height:Un,fill:a.color,rx:e.radius,title:Kn,item:Re(a,T,W,Kn)}),Hn(a,T,m(De+pe/2),W),e.labels){let qn=G(X?J-K:W);At.push(k?q(m(Math.max($e,ye)+4),m(De+pe/2),qn,{baseline:"middle"}):q(m(De+pe/2),m(Math.min($e,ye)-4),qn,{anchor:"middle"}))}}),z&&Xe.push({kind:"path",part:"bars",d:z,fill:a.color,title:a.name});continue}if(a.kind==="range"&&a.style==="bar"){B.forEach((z,T)=>{let H=x[z],W=C[z];if(!$(H)||!$(W))return;let K=ae(Math.min(H,W),a.axis),J=ae(Math.max(H,W),a.axis),$e=Nn(T)+$t.get(a)*qe+_n,ye=`${a.name}, ${f[z]}: ${G(Math.min(H,W))} \u2013 ${G(Math.max(H,W))}`,Ve=Re(a,z,W,ye),Be=Math.max(1,Math.abs(J-K));Xe.push(k?{kind:"rect",part:"range",x:m(Math.min(K,J)),y:m($e),width:m(Be),height:m(pe),fill:a.color,rx:e.radius,title:P?ye:void 0,item:Ve}:{kind:"rect",part:"range",x:m($e),y:m(Math.min(K,J)),width:m(pe),height:m(Be),fill:a.color,rx:e.radius,title:P?ye:void 0,item:Ve})});continue}let L=e.nulls==="connect"||e.nulls===void 0&&e.connectNulls,_=[],D=[];B.forEach((z,T)=>{let H=x[z],W=C[z];if(!$(W)||!$(H)){!L&&D.length&&(_.push(D),D=[]);return}D.push({x:Ke(T),y:m(ae(W,a.axis)),y0:m(ae(H,a.axis)),i:z})}),D.length&&_.push(D);let N=a.markers??B.length<=yi;for(let z of _){let T=ke(z,a.curve);if(a.kind==="range"&&a.style==="line"){It.push({kind:"path",part:"range-high",d:T,stroke:a.color,strokeWidth:2,strokeLinejoin:"round"},{kind:"path",part:"range-low",d:ke(z.map(H=>({x:H.x,y:H.y0})),a.curve),stroke:a.color,strokeWidth:2,strokeLinejoin:"round",dash:"4 3"});continue}if(a.kind==="range"){let H=ke([...z].reverse().map(W=>({x:W.x,y:W.y0})),a.curve);Ct.push({kind:"path",part:"range",d:`${T}L${H.slice(1)}Z`,fill:a.color,fillOpacity:.2,title:a.name});continue}if(a.kind==="area"){let H=Dn(vt(a.axis)),W=a.stack!==void 0?ke([...z].reverse().map(J=>({x:J.x,y:J.y0})),a.curve).slice(1):`${z[z.length-1]?.x} ${H}L${z[0]?.x} ${H}`,K=`skdx-g-${a.index}`;a.gradient&&!Ye.some(J=>J.id===K)&&Ye.push({id:K,vertical:!0,stops:[{offset:0,color:a.color,opacity:a.fillOpacity},{offset:1,color:a.color,opacity:0}]}),Ct.push({kind:"path",part:"area",d:`${T}L${W}Z`,fill:a.gradient?`url(#${K})`:a.color,fillOpacity:a.gradient?void 0:a.fillOpacity})}It.push({kind:"path",part:"line",d:T,stroke:a.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",dash:a.dash})}if(a.kind==="range"&&P)for(let z of _)for(let T of z){let H=a.low[T.i],W=a.high[T.i],K=`${a.name}, ${f[T.i]}: ${G(Math.min(H,W))} \u2013 ${G(Math.max(H,W))}`;Tt.push({...je(T.x,T.y,.01,a.color,K,Re(a,T.i,W,K)),part:"anchor"})}if(a.kind!=="range")for(let z of _)for(let T of z){if(!N&&!P&&!e.labels&&!a.errors)continue;let H=a.data[T.i],W=X?C[T.i]-x[T.i]:H,K=Nt(a.name,f[T.i],W,G);(N||P)&&Tt.push(N&&a.symbol!=="circle"?wr(T.x,T.y,a.markerSize,a.symbol,a.color,P?K:void 0,Re(a,T.i,H,K),"point"):{...je(T.x,T.y,N?a.markerSize:.01,a.color,P?K:void 0,Re(a,T.i,H,K)),part:N?"point":"anchor"}),P&&Hn(a,T.i,k?T.y:T.x,C[T.i]),e.labels&&At.push(q(T.x,T.y-8,G(W),{anchor:"middle"}))}}let Wn={plot:U,xs:k?[]:B.map((a,x)=>Ke(x)),rows:B.map(a=>[f[a],...F.map(x=>{let C=Qe(x);if(x.kind==="range"){let P=x.low[a],L=x.high[a];return`${x.name}: ${$(P)&&$(L)?`${C(P)} \u2013 ${C(L)}`:"\u2014"}`}let G=x.data[a];return`${x.name}: ${$(G)?C(X?(me.get(x)?.[a]??0)-(se.get(x)?.[a]??0):G):"\u2014"}`})]),count:d,zoom:M,crosshair:or(e)},Je=[];if(e.brush&&!k){let a={x:U.x,y:U.y+U.height+Sr,width:U.width,height:Mr},x=F.find(G=>G.kind!=="range"),C={x:m(a.x+M.start/Math.max(1,d)*a.width),y:a.y,width:m((M.end-M.start)/Math.max(1,d)*a.width),height:a.height};if(Je.push({kind:"rect",part:"brush",x:a.x,y:a.y,width:a.width,height:a.height,fill:"var(--skdx-color-surface-sunken)",stroke:V.grid}),x){let G=de(x.data),[P,L]=ue(G),_=d>1?a.width/(d-1):0,D=x.data.flatMap((z,T)=>$(z)?[{x:m(a.x+T*_),y:m(a.y+a.height-(L===P?.5:(z-P)/(L-P))*(a.height-4)-2)}]:[]),N=ke(D);D.length>1&&Je.push({kind:"path",part:"brush-series",d:`${N}L${D[D.length-1]?.x} ${a.y+a.height}L${D[0]?.x} ${a.y+a.height}Z`,fill:x.color,fillOpacity:.3})}Je.push({kind:"rect",part:"brush-window",...C,fill:"var(--skdx-color-primary-500)",opacity:.15,stroke:V.axis},{kind:"rect",part:"brush-handle",x:m(C.x-3),y:a.y+8,width:6,height:a.height-16,fill:V.axis,rx:2},{kind:"rect",part:"brush-handle",x:m(C.x+C.width-3),y:a.y+8,width:6,height:a.height-16,fill:V.axis,rx:2}),Wn.brush={box:a,window:C}}return{...Mt,shapes:[...Fn,...Ct,...Xe,...It,...jn,...Tt,...At,...vr(e.annotations,Gn),...Je,...Mt.shapes],hit:Wn,issues:o,defs:Ye.length?Ye:void 0}}function $r(e,n){if(!(!$(e)||n===null||n===void 0))return typeof n=="number"?$(n)?[e-Math.abs(n),e+Math.abs(n)]:void 0:$(n[0])&&$(n[1])?[Math.min(n[0],n[1]),Math.max(n[0],n[1])]:void 0}function wi(e,n){if(!e||n<2)return{start:0,end:n};let t=Math.max(0,Math.min(n-1,Math.floor(e.start))),r=Math.max(t+1,Math.min(n,Math.ceil(e.end)));return r-t<2&&n>=2?{start:Math.min(t,n-2),end:Math.min(t,n-2)+2}:{start:t,end:r}}function Mi(e,n,t){let r=f=>f.type??n,i=[],o=ki(e),s=e.categories??[],l=(e.transforms??[]).filter(f=>f.type==="sort"||f.type==="bin"||f.type==="aggregate"),c=(e.transforms??[]).filter(f=>!l.includes(f)),d=e.stacked||e.stackOffset!==void 0&&e.stackOffset!=="zero",u=(f,M,I)=>{let k=I.filter(O=>O!==null&&!(typeof O=="number"&&Number.isFinite(O))).length;k&&i.push({code:"invalid-value",severity:"warning",message:`Series "${f}" has ${k} value${k===1?"":"s"} that ${k===1?"is":"are"} neither a number nor null; drawn as gaps.`,itemId:M??f}),s.length&&I.length!==s.length&&!e.transform&&i.push({code:"length-mismatch",severity:"warning",message:`Series "${f}" has ${I.length} values for ${s.length} categories.`,itemId:M??f})},h=e.series.map((f,M)=>{let I=r(f),k=d?!0:void 0,O=f.type==="range"?void 0:f.stack,F=O===!1?void 0:O===!0||O===void 0&&k?`${I}`:O;f.type==="range"?(u(f.name,f.id,f.low),u(f.name,f.id,f.high)):u(f.name,f.id,f.data);let j=X=>e.nulls==="zero"?X.map(Q=>$(Q)?Q:0):X,B=Cr(o,f.axis);return B===void 0&&i.push({code:"unknown-axis",severity:"warning",message:`Series "${f.name}" names axis "${String(f.axis)}", which is not defined; drawn on the first axis.`,itemId:f.id??f.name}),{name:f.name,id:f.id,color:lr(e,M,f.color),axis:B??o[0]?.id,hidden:cr(e,f.name),index:M,kind:I,data:f.type==="range"?[]:j(jt(jt(f.data,c),f.transforms)),low:f.type==="range"?f.low:[],high:f.type==="range"?f.high:[],curve:f.curve??e.curve??"linear",dash:f.type==="range"?void 0:f.dash,markers:f.type==="range"?void 0:f.markers,symbol:f.type==="range"?"circle":f.symbol??"circle",markerSize:f.type==="range"?3:f.markerSize??3,errors:f.type==="range"?void 0:f.errors,stack:I==="range"||I==="line"?void 0:F,style:f.type==="range"?f.style??"area":"area",fillOpacity:(f.type==="range"?void 0:f.fillOpacity)??e.fillOpacity??.25,gradient:f.type!=="range"&&f.gradient===!0}}),p=()=>Math.max(s.length,...h.map(f=>Math.max(f.data.length,f.low.length))),v=f=>{let M=k=>k.length?f.map(O=>k[O]??null):k,I=Array.from({length:p()},(k,O)=>s[O]??String(O+1));s=f.map(k=>I[k]),h=h.map(k=>({...k,data:M(k.data),low:M(k.low),high:M(k.high)}))},y=(f,M)=>{let I=(M!==void 0?h.find(O=>O.name===M):void 0)??h.find(O=>!O.hidden&&O.kind!=="range")??h[0];M!==void 0&&!h.some(O=>O.name===M)&&i.push({code:"unknown-series",severity:"warning",message:`sort.by names "${M}", which is not a series; sorted by the first series.`});let k=Array.from({length:p()},(O,F)=>F).sort((O,F)=>{let j=I?.data[O]??I?.high[O],B=I?.data[F]??I?.high[F],X=$(j)?j:-1/0,Q=$(B)?B:-1/0;return f==="asc"?X-Q:Q-X});v(k)},b=f=>{let M=h.flatMap(k=>de(k.data)),I=tt(M,f);s=I.slice(1).map((k,O)=>`${t(I[O])}\u2013${t(k)}`),h=h.map(k=>{let O=de(k.data),F=0,j=nt(O,I).map(B=>e.binMode==="density"?O.length?B.count/(O.length*(B.x1-B.x0)):0:e.binMode==="cumulative"?F+=B.count:B.count);return{...k,data:j}})},S=(f,M)=>{let I=Math.max(1,Math.floor(f)),k=p(),O=j=>{if(!j.length)return j;let B=[];for(let X=0;X<k;X+=I){let Q=de(j.slice(X,X+I));B.push(Q.length===0?null:M==="sum"?Q.reduce((se,me)=>se+me,0):M==="mean"?Q.reduce((se,me)=>se+me,0)/Q.length:M==="min"?Math.min(...Q):Math.max(...Q))}return B};s=Array.from({length:k},(j,B)=>s[B]??String(B+1)).filter((j,B)=>B%I===0),h=h.map(j=>({...j,data:O(j.data),low:O(j.low),high:O(j.high)}))};e.transform==="histogram"?b({bins:e.bins,binWidth:e.binWidth,domain:e.binDomain}):e.transform==="cumulative"&&(h=h.map(f=>{let M=0;return{...f,data:f.data.map(I=>$(I)?M+=I:M)}}));for(let f of l)f.type==="sort"?y(f.order??"desc"):f.type==="bin"?b(f):f.type==="aggregate"&&S(f.every,f.method??"sum");typeof e.sort=="string"?y(e.sort):e.sort&&y(e.sort.order,e.sort.by);let w=e.xAxis?.domain;if(w){let f=p(),M=Array.from({length:f},(F,j)=>s[j]??String(j+1)),I=F=>{let j=typeof F=="string"?F:ce(F);return M.findIndex(B=>typeof j=="string"?B===j||et(B)===j:ce(B)===j)},k=w.map(I),O=F=>F.length?k.map(j=>j<0?null:F[j]??null):F;s=[...w],h=h.map(F=>({...F,data:O(F.data),low:O(F.low),high:O(F.high)}))}return{series:h,categories:s,issues:i,axes:o}}function dt(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Ht=e=>e.id??e.name??e.series,Tr=e=>e.seriesId??e.series;function he(e,n){let t=!1;return n.id!==void 0&&(t=!0,Ht(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,Tr(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function be(e){let n={},t=Ht(e);t!==void 0&&(n.id=t);let r=Tr(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Wt=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Zt(e,n,t){let r=dt(e),i=be(n),o=r.some(s=>he(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!he(n,s)):[...r,i]}var Si=.2;function $i(e){let n=V.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var Ci=(e,n)=>e.kind==="text"?{...e,fill:V.grid}:{...e,opacity:(e.opacity??1)*n};function Et(e,n){let t=dt(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:dt(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},s=[],l=u=>!i||r.some(h=>he(u,h))?!0:o.highlighted==="series"?r.some(h=>h.series!==void 0&&he(u,{series:h.series})):!1,c=u=>{if(!i||o.faded==="none"||l(u))return!1;if(o.faded==="series"){let h=i.series;return h!==void 0&&he(u,{series:h})}return!0},d=e.shapes.map(u=>{let h=u.item;if(!h||h.legend)return u;if(t.some(p=>he(h,p))){let p=$i(u);p&&s.push(p)}return c(h)?Ci(u,Si):u});return s.length?{...e,shapes:[...d,...s]}:{...e,shapes:d}}function Oe(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Ut=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Ar(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let s=Math.abs(i-n);s<r&&(r=s,t=o)}),t}function He(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Ar(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Kt(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[Ar(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:V.axis,dash:"3 3"}}function qt(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Ut(r.plot,n,t))return[];let i=Kt(e,n),{rows:o}=He(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...st(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Xt(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return qt(e,i,t.plot.y+8)}function Yt(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:c,y:d}=Oe(t,r,i,e.width,e.height);if(Ut(e.hit.plot,c,d)){let u=He(e,c),h=Kt(e,c);if(u&&h)return{lines:u.rows,shapes:[h]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?ge(e,n)?.item:void 0,l=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(c=>c.tagName.toLowerCase()==="title")?.textContent;return l?{lines:Array.isArray(l)?l:[l],shapes:[]}:{lines:[],shapes:[]}}function Or(e,n,t,r,i,o,s){let l=e?.closest?.("[data-skdx-part]"),c=s&&s.tooltipFormatter?ge(s,e)?.item:void 0,d=c&&s?.tooltipFormatter?.(c)||l&&Array.from(l.children).find(y=>y.tagName.toLowerCase()==="title")?.textContent;if(!d)return[];let u=s?.tooltipAnchored?ge(s,e):void 0,h=u?s?.shapes[u.index]:void 0,{x:p,y:v}=h?We(h):Oe(n,t,r,i,o);return st(p,v,d,i,o,s?.tooltipPlacement)}function Qt(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=Oe(t,r,i,e.width,e.height),l=qt(e,o,s);if(l.length>0)return l}return Or(n,t,r,i,e.width,e.height,e)}function Jt(e,n){let t=ge(e,n);return t&&!t.item.legend?be(t.item):null}var Ii=(e,n)=>{let{x:t,y:r}=We(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function en(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!Ii(i,n))continue;let o=be(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var tn=e=>({kind:"rect",part:"selection-box",x:m(e.x),y:m(e.y),width:m(e.width),height:m(e.height),fill:V.focus,opacity:.12,stroke:V.focus}),ht=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function zr(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let s=e[i],l=e[o];s.y>t!=l.y>t&&n<(l.x-s.x)*(t-s.y)/(l.y-s.y)+s.x&&(r=!r)}return r}function nn(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:s}=We(i),l=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!zr(n,o,l))continue;let c=be(i.item),d=JSON.stringify(c);t.has(d)||(t.add(d),r.push(c))}return r}var rn=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${m(n.x)} ${m(n.y)}`).join("L")}`:"",fill:V.focus,fillOpacity:.12,stroke:V.focus,dash:"4 3"}),ut=6;function on(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-ut||n>i.x1+ut))return Math.abs(n-i.x0)<=ut?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=ut?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function sn(e,n,t){let r=e.edit;return Lr(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function an(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(c=>c.index===n);if(!o)return;let s=t.altKey?t.shiftKey?"start":"end":"move",l=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return Lr(r,{bar:o,mode:s},i*l)}function Lr(e,{bar:n,mode:t},r){let i=l=>e.snap?Math.round(l/e.snap)*e.snap:l,o=n.start,s=n.end;return t==="move"?(o=i(n.start+r),s=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):s=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:s}}function ln(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:m(Math.min(i,o)),y:m(n.bar.y),width:m(Math.max(1,Math.abs(o-i))),height:m(n.bar.height),fill:V.focus,opacity:.25,stroke:V.focus,rx:2}}var Ti=64,Ai=e=>Math.max(1,Math.min(Ti,e));function cn(e,n,t,r){let i=n>0?.8:1.25,o=Ai(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:l}=e,[c,d]=e.view.center,u=(t-(s.x+s.width/2))/l,h=(r-(s.y+s.height/2))/l,p=e.view.zoom/o;return{center:[c+u*(1-p),e.fromY(e.toY(d)-h*(1-p))],zoom:o}}function dn(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function ge(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var ft=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function We(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function un(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=V.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*ie+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:s}=We(t),l=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...l?st(m(o),m(s),l,e.width,e.height):[]]}function hn(e,n,t){let r=ft(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var Te=2,Ae=(e,n,t)=>{let r=Math.max(Te,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Rr=(e,n)=>!e||e.start<=0&&e.end>=n;function fn(e,n,t){if(e.count<=Te||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,l=Math.max(Te,Math.min(e.count,Math.round(o*s)));if(l===o)return n>0&&!Rr(e.zoom,e.count)?Ae(r,l,e.count):void 0;let c=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),d=r+c*o;return Ae(d-c*l,l,e.count)}function mn(e,n,t,r){let i=n.end-n.start,o=Math.max(Te,Math.min(e.count,Math.round(i/Math.max(.05,t)))),s=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return Ae(n.start+s*i-s*o,o,e.count)}function pn(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return Ae(n.start-t/i,r,e.count)}function bn(e,n,t){let r=e.brush;if(!r||!Ut(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,s=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:Ae(s-o/2,o,e.count)}}function gn(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return Ae(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-Te,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+Te,Math.round(t.end+o)));return{start:t.start,end:s}}function yn(e,n){switch(n.type){case"svg":return Promise.resolve(xn(e,n.label,n.resolve));case"csv":return Promise.resolve(Pr(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=xn(e,n.label,n.resolve);return Dr(t,e.width,e.height,n.scale,n.background)}}}var fe=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),Ze=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${fe(String(t))}"`).join("");function Vr(e){let n=e.title?`<title>${fe(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${Ze([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${Ze([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${Ze([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${Ze([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${Ze([t,["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${fe(e.text)}</text>`}}function Br(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${fe(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${fe(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function xn(e,n,t){let r=Br(e)+e.shapes.map(Vr).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${fe(n)}" font-family="${fe(V.fontFamily)}" font-size="${fe(V.fontSize)}"><title>${fe(n)}</title>${r}</svg>`}function Dr(e,n,t,r=2,i){return new Promise((o,s)=>{let l=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(l);let d=document.createElement("canvas");d.width=Math.round(n*r),d.height=Math.round(t*r);let u=d.getContext("2d");if(!u)return s(new Error("canvas 2d context unavailable"));i&&(u.fillStyle=i,u.fillRect(0,0,d.width,d.height)),u.drawImage(c,0,0,d.width,d.height),d.toBlob(h=>h?o(h):s(new Error("toBlob failed")),"image/png")},c.onerror=()=>{URL.revokeObjectURL(l),s(new Error("svg could not be decoded"))},c.src=l})}function Pr(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
|
|
2
|
-
`)}function vn(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let l=r.rows[0];if(r.rows.length>t)return;let c=["",...l.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],d=r.rows.map(u=>[u[0],...u.slice(1).map(h=>h.slice(h.lastIndexOf(": ")+2))]);return[c,...d]}let i=e.shapes.flatMap(l=>l.item&&!l.item.legend&&!(l.part==="anchor"&&!l.title)?[l.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(l=>i.some(c=>c[l]!==void 0)),s=(l,c)=>l[c]===void 0?"":String(l[c]);return[o.map(l=>l[0]?.toUpperCase()+l.slice(1)),...i.map(l=>o.map(c=>s(l,c)))]}var kn=new Map;function mt(e){let n=kn.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&kn.delete(e)}},publish(o,s){Object.assign(r,o);for(let l of t)l(o,s)}};return kn.set(e,{group:i,listeners:t}),i}var Nr='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',wn=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Nr}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${Nr}{animation:none;transition:none}}`;function Mn(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function Sn(e){let n=[],r=e.data.filter(u=>{let h=$(u.value)&&u.value>=0;return h||n.push({code:"invalid-value",severity:"warning",message:`"${u.name}" has no valid non-negative value and was dropped.`,itemId:u.id??u.name}),h}).map((u,h)=>({d:u,i:h})).sort((u,h)=>h.d.value-u.d.value||u.i-h.i),i=r.reduce((u,{d:h})=>u+h.value,0),o=0,s=r.map(({d:u})=>i>0?(o+=u.value)/i:0),l=e.threshold,c=Ir({...e,categories:r.map(({d:u})=>u.name),series:[{name:e.name??"Value",type:"bar",data:r.map(({d:u})=>u.value),color:r[0]?.d.color},{name:e.cumulativeLabel??"Cumulative",type:"line",axis:"right",data:s,curve:"linear"}],rightAxis:{min:0,max:1,format:{style:"percent"}},references:l!==void 0&&$(l)?[{y:l,axis:"right",label:`${Math.round(l*100)}%`,variant:"primary"}]:void 0},"bar"),d=c.shapes.map(u=>{if(u.part!=="bar"||u.kind!=="rect"||!u.item||u.item.index===void 0)return u;let h=r[u.item.index]?.d;return h?{...u,fill:h.color??u.fill,item:{...u.item,id:h.id??h.name,name:h.name}}:u});return{...c,shapes:d,issues:[...n,...c.issues??[]]}}import{css as Oi,html as xe,LitElement as zi,nothing as Y,svg as ne}from"lit";import{property as A,state as oe}from"lit/decorators.js";import{ifDefined as E}from"lit/directives/if-defined.js";var Li={fromAttribute:()=>!1},R=class extends zi{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:s}=this.viewBox(t,r);this.overlay=[tn(ht(i.x,i.y,o,s))];return}if(i?.grab==="lasso"){let{x:o,y:s}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:s}],this.overlay=[rn(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=sn(r,i.gantt,o-i.x),this.overlay=[ln(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:s}=this.viewBox(t,r);this.setView(dn(r.map,i.view,o-i.x,s-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[s,l]=[...this.pointers.values()];if(s===void 0||l===void 0||!i.distance)return;this.setZoom(mn(r.hit,i.zoom,Math.abs(s-l)/i.distance,(s+l)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?pn(r.hit,i.zoom,o-i.x):gn(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Yt(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=s,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=Qt(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(Jt(r,t.target)),this.syncId&&r.hit?.crosshair){let o=He(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),s=ge(r,t.target)?.item.legend,l=this.canEdit(r)?on(r,i,o):void 0;if(l){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:l},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!s){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let d=r.map.plot;if(i<d.x||i>d.x+d.width||o<d.y||o>d.y+d.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let c=r.hit;if(!(!c||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[d,u]=[...this.pointers.values()];this.drag={x:(d+u)/2,y:o,zoom:c.zoom,grab:"pinch",distance:Math.abs(d-u)||1}}else{let d=bn(c,i,o);if(d)this.drag={x:i,y:o,zoom:d.zoom,grab:d.grab},d.zoom!==c.zoom&&this.setZoom(d.zoom);else if(this.zoomable&&i>=c.plot.x&&i<=c.plot.x+c.plot.width&&o>=c.plot.y&&o<=c.plot.y+c.plot.height)this.drag={x:i,y:o,zoom:c.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:s,y:l}=this.viewBox(t,o);if(Math.abs(s-i.x)>2||Math.abs(l-i.y)>2){i.grab==="select"?this.setSelected(en(o,ht(i.x,i.y,s,l))):i.grab==="lasso"?this.setSelected(nn(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;t.preventDefault(),this.setView(cn(r.map,t.deltaY,i,o));return}let s=r.hit;if(!s||!this.canZoom(r)||o<s.plot.y||o>s.plot.y+s.plot.height)return;let l=fn(s,t.deltaY,i);l&&(t.preventDefault(),this.setZoom(l))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=ge(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let l=r.shapes[this.focused]?.item;l&&(t.preventDefault(),this.select(l),this.emit("skdx-item-click",l));return}let i=this.canEdit(r)?an(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=hn(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let s=o===null?void 0:r.shapes[o]?.item;this.highlight(s?be(s):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:s,palette:l,loading:c,error:d,emptyMessage:u,description:h,decorative:p,animated:v,responsive:y,highlighted:b,highlightScope:S,accessibleTable:w}=this;return{...typeof y=="object"&&this.measured!==void 0&&this.measured<(y.breakpoint??480)?y.compact:void 0,width:y&&this.measured?this.measured:t,height:r,animate:v,responsive:y,legend:i,tooltip:o,format:s,palette:l,loading:c,error:d,emptyMessage:u,description:h,decorative:p,highlighted:b===void 0?this.highlightState:b,highlightScope:S,accessibleTable:w,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&mt(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=mt(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&Wt(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.syncId&&(this.highlightState=t,this.publish({highlighted:t})))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(Zt(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return Oe(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&he(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?yn(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Et(Pt(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let w of o.issues??[])this.emit("skdx-data-issue",w)}let s=this.canZoom(o),l=this.canPan(o),c=this.canEdit(o),d=this.brushing(),u=s||l||c||d,h=!o.decorative&&ft(o).length>0,p=o.description?`${r}-desc`:void 0,v=Mn(o),y=vn(o,this.accessibleTable),b=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,S=this.portal;return xe`<svg
|
|
1
|
+
var ti=Object.defineProperty;var ni=Object.getOwnPropertyDescriptor;var x=(e,n,t,r)=>{for(var i=r>1?void 0:r?ni(n,t):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(i=(r?a(n,t,i):a(i))||i);return r&&i&&ti(n,t,i),i};import{customElement as ji,property as ie}from"lit/decorators.js";var tr=e=>Number(e.toPrecision(12)),ri,nr=e=>(ri??(ri=new Intl.NumberFormat)).format(tr(e)),ii=e=>{let n=Math.round(Math.abs(e)),t=e<0?"-":"",r=Math.floor(n/3600),i=Math.floor(n%3600/60),o=a=>String(a).padStart(2,"0");return r>0?`${t}${r}h ${o(i)}m`:i>0?`${t}${i}m ${o(n%60)}s`:`${t}${n}s`};function Ce(e){if(e===void 0)return nr;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,a=u=>i?h=>u(h)+i:u,l=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},c=u=>{let h=new Intl.NumberFormat(t,u);return a(b=>h.format(tr(b)))},d=u=>{let h=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return b=>h.format(b)};switch(n){case"integer":return c({maximumFractionDigits:0});case"decimal":return c(l(2));case"percent":return c({style:"percent",...l(0)});case"currency":return c({style:"currency",currency:e.currency??"USD",...l()});case"compact":return c({notation:"compact",...l(1)});case"scientific":return c({notation:"scientific",...l(2)});case"date":return d({dateStyle:"medium"});case"time":return d({timeStyle:"short"});case"datetime":return d({dateStyle:"medium",timeStyle:"short"});case"duration":return a(ii)}}function et(e,n){if(typeof e=="string")return e;let t=e instanceof Date?e.getTime():e;return n?Ce(n)(t):e instanceof Date?new Intl.DateTimeFormat().format(e):nr(t)}var ce=e=>{if(e instanceof Date)return e.getTime();if(typeof e=="number")return e;let n=Number(e);return Number.isFinite(n)&&e.trim()!==""?n:Date.parse(e)};function Ie([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function ke(e,n,t=5){if(e===n)return[e];let r=(n-e)/Math.max(1,t),i=10**Math.floor(Math.log10(r)),o=r/i,a=(o<1.5?1:o<3.5?2:o<7.5?5:10)*i,l=Math.floor(e/a)*a,c=Math.ceil(n/a)*a,d=[];for(let u=l;u<=c+a/2;u+=a)d.push(ir(u));return d}function rr(e,[n,t],r=.2){let i=e===0?0:(t-n)/e,o=i*(1-Math.max(0,Math.min(.9,r)));return{step:i,bandwidth:o,start:a=>n+a*i+(i-o)/2,center:a=>n+(a+.5)*i}}var ir=e=>Number(e.toPrecision(12)),m=e=>Number(e.toFixed(2)),$=e=>typeof e=="number"&&Number.isFinite(e),de=e=>e.filter($);function ue(e){let n=1/0,t=-1/0;for(let r of e)$(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}function ve(e,n="linear"){if(e.length===0)return"";let t=e[0];if(n==="step"||n==="stepBefore"||n==="stepAfter"){let d=`M${t.x} ${t.y}`;for(let u=1;u<e.length;u++){let h=e[u-1],b=e[u];n==="stepAfter"?d+=`H${b.x}V${b.y}`:n==="stepBefore"?d+=`V${b.y}H${b.x}`:d+=`H${m((h.x+b.x)/2)}V${b.y}H${b.x}`}return d}if(n==="linear"||e.length<3)return`M${e.map(d=>`${d.x} ${d.y}`).join("L")}`;let r=e.length,i=e.slice(1).map((d,u)=>d.x-e[u].x),o=e.slice(1).map((d,u)=>d.y-e[u].y),a=i.map((d,u)=>d===0?0:o[u]/d),l=[a[0]];for(let d=1;d<r-1;d++){let u=a[d-1],h=a[d];l.push(u*h<=0?0:(u+h)/2)}l.push(a[r-2]);for(let d=0;d<r-1;d++){let u=a[d];if(u===0){l[d]=0,l[d+1]=0;continue}let h=l[d]/u,b=l[d+1]/u,v=Math.hypot(h,b);v>3&&(l[d]=3*h*u/v,l[d+1]=3*b*u/v)}let c=`M${t.x} ${t.y}`;for(let d=0;d<r-1;d++){let u=e[d],h=e[d+1],b=i[d]/3;c+=`C${m(u.x+b)} ${m(u.y+b*l[d])} ${m(h.x-b)} ${m(h.y-b*l[d+1])} ${h.x} ${h.y}`}return c}var Pe=1e3,Ne=60*Pe,Fe=60*Ne,Ge=24*Fe,oi=[Pe,5*Pe,15*Pe,30*Pe,Ne,5*Ne,15*Ne,30*Ne,Fe,3*Fe,6*Fe,12*Fe,Ge,2*Ge,7*Ge,14*Ge];function or(e,n,t=6){if(!(n>e))return[e];let r=n-e,i=oi.find(h=>r/h<=t),o=[];if(i!==void 0){for(let h=Math.ceil(e/i)*i;h<=n;h+=i)o.push(h);return o.length?o:[e,n]}let a=r/(30*Ge),l=[1,2,3,6,12,24,60,120].find(h=>a/h<=t)??240,c=new Date(e),d=c.getUTCFullYear(),u=Math.ceil((c.getUTCMonth()+(c.getUTCDate()>1?1:0))/l)*l;for(let h=Date.UTC(d,u,1);h<=n;)o.push(h),u+=l,u>=12&&(d+=Math.floor(u/12),u%=12),h=Date.UTC(d,u,1);return o.length?o:[e,n]}function ar(e,n){let t=Math.floor(Math.log10(e)),r=Math.ceil(Math.log10(n)),i=r-t<=1?[1,2,5]:[1],o=[];for(let a=t;a<=r;a++)for(let l of i)o.push(ir(l*10**a));return o.filter(a=>a>=e/1.0001&&a<=n*1.0001)}function tt(e,n={}){if(n.thresholds&&n.thresholds.length>=2)return[...n.thresholds].filter(Number.isFinite).sort((c,d)=>c-d);let[t,r]=n.domain??ue(e),i=Math.max(1,e.length),o=Math.max(1,n.bins??Math.ceil(Math.log2(i)+1)),a=n.binWidth??(r>t?(r-t)/o:1),l=r>t?Math.max(1,Math.ceil((r-t)/a-1e-9)):1;return Array.from({length:l+1},(c,d)=>Number((t+d*a).toPrecision(12)))}function nt(e,n){let t=[];for(let o=0;o+1<n.length;o++)t.push({x0:n[o],x1:n[o+1],count:0});if(t.length===0)return t;let r=n[0],i=n[n.length-1];for(let o of de(e)){if(o<r||o>i)continue;let a=0,l=t.length-1;for(;a<l;){let c=a+l+1>>1;t[c].x0<=o?a=c:l=c-1}t[a].count++}return t}var ai=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,si=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,li={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function ci(e,n,t){return e.replace(si,(r,i,o)=>{let a=li[i];if(a===void 0)return i+o;let c=(o.match(ai)??[]).map((d,u)=>{let h=Number(d);if(a===-1)return String(h+n);if(a===-2)return String(h+t);let b=u%a;return a===7?b===5?String(h+n):b===6?String(h+t):d:String(b%2===0?h+n:h+t)});return i+c.join(" ")})}var sr=(e,n,t)=>e.map(r=>{switch(r.kind){case"rect":return{...r,x:r.x+n,y:r.y+t};case"circle":return{...r,cx:r.cx+n,cy:r.cy+t};case"line":return{...r,x1:r.x1+n,x2:r.x2+n,y1:r.y1+t,y2:r.y2+t};case"text":return{...r,x:r.x+n,y:r.y+t};case"path":return{...r,d:ci(r.d,n,t)}}});var Vt=["primary","success","warning","danger","neutral"].flatMap(e=>[500,700].map(n=>`var(--skdx-color-${e}-${n})`)).sort((e,n)=>Number(e.endsWith("700)"))-Number(n.endsWith("700)"))),R={axis:"var(--skdx-color-border-strong)",grid:"var(--skdx-color-border-subtle)",label:"var(--skdx-color-text-muted)",focus:"var(--skdx-color-focus-ring)",positive:"var(--skdx-color-success-500)",negative:"var(--skdx-color-danger-500)",fontFamily:"var(--skdx-font-family)",fontSize:"var(--skdx-font-size-xs)"},rt=(e="neutral")=>e==="neutral"?R.axis:`var(--skdx-color-${e}-500)`,Bt=(e="neutral")=>e==="neutral"?R.label:e==="primary"?"var(--skdx-color-text-accent)":`var(--skdx-color-text-${e})`,lr=(e,n)=>n??Vt[e%Vt.length];var ne={top:16,right:16,bottom:32,left:48};function cr(e,n,t=ne){return{x:t.left,y:t.top,width:Math.max(0,e-t.left-t.right),height:Math.max(0,n-t.top-t.bottom)}}function _e(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function Pt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var dr=e=>e.crosshair===!0||Pt(e).trigger==="axis",it=20,di=120,ur=e=>{let n=_e(e);return n&&(n.position==="left"||n.position==="right")?n.width??di:0},ot=(e,n=600,t=300)=>({width:(e.width??n)-ur(e),height:(e.height??t)-(_e(e)?.position==="bottom"?it:0)}),hr=(e,n,t)=>{let r=_e(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,pr(n,t??ot(e).width,r)):1)*it},te=6.5;function Nt(e,n){let t=Array.from(e),r=Math.max(0,Math.floor(n/te));return t.length<=r?e:r===0?"":`${t.slice(0,r-1).join("")}\u2026`}var fr=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:lr(n)),mr=(e,n)=>e.hiddenSeries?.includes(n)??!1;function Dt(e,n,t=[],r={},i=10,o=8,a=!1){let l=[],c=r.maxItems,d=c!==void 0&&c>=0&&e.length>c?e.slice(0,c):e,u=e.length-d.length,h=r.interactive??!0,b=o,v=i,y=(p,k,w,f)=>{let M=(k?18:4)+p.length*te;b>o&&(a||b+M>n-8)&&(b=o,v+=it),k&&l.push({kind:"rect",part:"legend-swatch",x:b,y:v-5,width:10,height:10,fill:k,opacity:f?.3:void 0,item:w}),l.push({kind:"text",part:"legend-label",x:b+(k?14:0),y:v,text:p,baseline:"middle",fill:f?R.grid:R.label,item:w}),b+=M+12};for(let p of d){let k=t.includes(p.name),w=h?{label:p.name,series:p.name,legend:!0}:void 0;y(r.formatter?.(p.name)??p.name,p.color,w,k)}return u>0&&y(`+${u} more`,void 0,void 0,!1),r.align==="end"?ui(l,n):l}function ui(e,n){let t=new Map;for(let i of e){let o=i.kind==="rect"?i.y+5:i.y;t.set(o,[...t.get(o)??[],i])}let r=[];for(let i of t.values()){let o=Math.max(...i.map(l=>l.kind==="rect"?l.x+l.width:l.x+l.text.length*te)),a=n-8-o;for(let l of i)r.push({...l,x:l.x+a})}return r}var pr=(e,n,t={})=>new Set(Dt(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Ft(e,n,t,r=[]){let i=_e(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,a=Pt(e),l=o?.position==="bottom",c=ur(e),d=e.hiddenSeries??[],u=o?c?Dt(r,1/0,d,o,10,(o.position==="right"?n:0)+8,!0):Dt(r,n,d,o,l?t+10:10):[],h=l?pr(r,n,o):0;return{width:n+c,height:l?t+Math.max(1,h)*it:t,legendOffset:o?.position==="left"?c:void 0,tooltip:a.enabled,tooltipFormatter:a.formatter,axisTooltipFormatter:a.axisFormatter,tooltipPortal:a.portal,tooltipPlacement:a.placement,tooltipAnchored:a.followPointer===!1?!0:void 0,description:e.description,decorative:e.decorative,animate:e.animate===!0?300:e.animate||void 0,responsive:!!e.responsive,shapes:u}}function Gt(e){let n=e.legendOffset;if(!n)return e;let t=[...sr(e.shapes.filter(c=>!c.part.startsWith("legend-")),n,0),...e.shapes.filter(c=>c.part.startsWith("legend-"))],r=c=>({...c,x:c.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(c=>c+n),brush:e.hit.brush?{box:r(e.hit.brush.box),window:r(e.hit.brush.window)}:void 0}:void 0,o=e.edit,a=o?{...o,scale:c=>o.scale(c)+n,invert:c=>o.invert(c-n),bars:o.bars.map(c=>({...c,x0:c.x0+n,x1:c.x1+n}))}:void 0,l=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:a,map:l,legendOffset:void 0}}function at(e,n,t,r,i,o="auto"){let a=Array.isArray(t)?t:[t],l=Math.max(1,Math.floor((r-12)/te)),c=a.flatMap(k=>{let w=[],f=Array.from(k);for(;f.length>l;){let M=f.slice(0,l+1).lastIndexOf(" ");M<1&&(M=l),w.push(f.slice(0,M).join("")),f=f.slice(M),f[0]===" "&&f.shift()}return w.push(f.join("")),w}),d=Math.max(1,Math.floor((i-6)/16)),u=c.slice(0,d);c.length>d&&(u[d-1]=Nt(`${u[d-1]}\u2026`,r-12));let h=Math.min(r,Math.max(0,...u.map(k=>Array.from(k).length))*te+12),b=Math.min(i,6+u.length*16),v=o==="top"?{x:e-h/2,y:n-b-8}:o==="bottom"?{x:e-h/2,y:n+8}:o==="left"?{x:e-h-8,y:n-b/2}:o==="right"?{x:e+8,y:n-b/2}:{x:e+12,y:n-b-6},y=Math.max(0,Math.min(r-h,v.x)),p=Math.max(0,Math.min(i-b,v.y));return[{kind:"rect",part:"tooltip",title:a.join(`
|
|
2
|
+
`),x:m(y),y:m(p),width:m(h),height:b,fill:"var(--skdx-color-surface-raised)",stroke:R.axis,rx:8},...u.map((k,w)=>({kind:"text",part:"tooltip-label",x:m(y+6),y:m(p+11+w*16),text:k,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:u.length>1&&w===0?"bold":void 0}))]}function br([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,a=Ce(o.format??i),l=o.min??e,c=o.max??n;o.reversed&&(t=[t[1],t[0]]);let d={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let p=O=>Math.sign(O)*Math.sqrt(Math.abs(O)),k=o.nice===!1?[l,c]:ke(l,c,o.ticks),w=o.min??k[0],f=o.max??k[k.length-1],M=Ie([p(w),p(f)],t),I=O=>M(p(O)),S=ke(w,f,o.ticks).filter(O=>O>=w-1e-9&&O<=f+1e-9);return{...d,scale:I,domain:[w,f],format:a,ticks:(S.length>=2?S:[w,f]).map(O=>({pos:m(I(O)),label:a(O)})),zero:m(I(Math.min(Math.max(0,w),f)))}}if(o.scale==="log"){let p=Math.max(l,Number.EPSILON),k=Math.max(c,p),w=ar(p,k),f=[Math.log10(p),Math.log10(k)],M=Ie(f,t),I=S=>M(Math.log10(Math.max(S,Number.EPSILON)));return{...d,scale:I,domain:f,format:a,ticks:w.map(S=>({pos:m(I(S)),label:a(S)})),zero:m(t[0])}}let u=ke(l,c,o.ticks),h=[o.min??(o.nice===!1?l:u[0]),o.max??(o.nice===!1?c:u[u.length-1])],b=Ie(h,t),v=u.filter(p=>p>=h[0]-1e-9&&p<=h[1]+1e-9),y=(v.length>=2?v:[h[0],h[1]]).map(p=>({pos:m(b(p)),label:a(p)}));return{...d,scale:b,domain:h,format:a,ticks:y,zero:m(b(Math.min(Math.max(0,h[0]),h[1])))}}var xr=([e,n],t)=>Math.max(ne.left,ke(e,n).reduce((r,i)=>Math.max(r,t(i).length),0)*te+14),gr=e=>e?.grid!==!1;function st(e,n){if(e.length<2)return e;let t=e.reduce((i,o)=>Math.max(i,o.label.length),0)*te+8,r=Math.max(1,Math.ceil(e.length*t/Math.max(1,n)));return r===1?e:e.filter((i,o)=>o%r===0)}var _t=(e,n,t,r)=>`${e}, ${n}: ${r(t)}`;function yr(e,n,t,r){let i=e.error!==void 0?"error":e.loading?"loading":n?"empty":null;if(!i)return null;let{width:o,height:a}=ot(e,t,r),l=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",c=[];return i==="loading"&&c.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:a,fill:"var(--skdx-color-surface-sunken)",rx:8}),c.push({kind:"text",part:`state-${i}`,x:m(o/2),y:m(a/2),text:l,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":R.label}),{...Ft(e,o,a),shapes:c,tooltip:!1}}var jt=(e,n,t)=>{let r=n.length*te/2;return e+r>t?"end":e-r<0?"start":"middle"};function Et(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,a=t.x+t.width,l=t.y+t.height,c=[],d=n.grid??!0,u=(y,p)=>p?{kind:"line",part:"grid",x1:y.pos,x2:y.pos,y1:t.y,y2:l,stroke:R.grid}:{kind:"line",part:"grid",x1:t.x,x2:a,y1:y.pos,y2:y.pos,stroke:R.grid},h=n.x?.tickRotation??0,b=(y,p,k,w)=>h?q(y,p,k,{part:w,anchor:h<0?"end":"start",baseline:"middle",rotate:h}):hi(y,p,k,e.width,{part:w,anchor:jt(y,k,e.width)}),v=(y,p,k,w,f)=>{for(let M of y)c.push(p==="x"?{kind:"line",part:"tick",x1:M.pos,x2:M.pos,y1:k,y2:m(k+w*f),stroke:R.axis}:{kind:"line",part:"tick",x1:k,x2:m(k+w*f),y1:M.pos,y2:M.pos,stroke:R.axis})};if(n.categoryGrid)for(let y of r)c.push(u(y,!n.horizontal));if(n.horizontal){let y=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(d)for(let p of i)c.push(u(p,!0));y[0]?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:l,stroke:R.axis});for(let p of y){let k=p.position==="top"||p.position==="right",w=m(k?t.y-p.offset:l+p.offset),f=k||p.offset>0;p.showLine&&f&&c.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:w,y2:w,stroke:R.axis}),p.showTicks&&v(p.ticks,"x",w,k?-1:1,p.tickSize??4);let M=m(k?w-8:w+20);for(let I of p.ticks)c.push(k?q(I.pos,M,I.label,{part:"x-label-top",anchor:jt(I.pos,I.label,e.width)}):b(I.pos,M,I.label,"x-label"));p.label&&c.push(f?q(4,M,p.label,{part:"axis-title",anchor:"start",baseline:k?void 0:"middle"}):q(4,t.y-6,p.label,{part:"axis-title",anchor:"start"}))}n.x?.showLine&&c.push({kind:"line",part:"axis",x1:n.rtl?a:t.x,x2:n.rtl?a:t.x,y1:t.y,y2:l,stroke:R.axis}),n.x?.showTicks&&v(r,"y",n.rtl?a:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let p of r)c.push(n.rtl?q(a+8,p.pos,p.label,{part:"y-label",anchor:"start",baseline:"middle"}):q(t.x-8,p.pos,p.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(d)for(let p of i)c.push(u(p,!1));n.y?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:t.x,x2:a,y1:o,y2:o,stroke:R.axis});let y=n.axes??[{ticks:i,position:"left",offset:0,label:n.yLabel,...n.y},...n.rightTicks?[{ticks:n.rightTicks,position:"right",offset:0,label:n.rightLabel}]:[]];for(let p of y){let k=p.position==="left",w=k?t.x-p.offset:a+p.offset,f=k?"y-label":"y-label-right";p.showLine&&c.push({kind:"line",part:"axis",x1:m(w),x2:m(w),y1:t.y,y2:l,stroke:R.axis}),p.showTicks&&v(p.ticks,"y",m(w),k?-1:1,p.tickSize??4);for(let M of p.ticks)c.push(q(m(k?w-8:w+8),M.pos,M.label,{part:f,anchor:k?"end":"start",baseline:"middle"}));p.label&&c.push(q(m(k?p.offset===0?4:Math.max(4,w-40):p.offset===0?e.width-4:Math.min(e.width-4,w+40)),t.y-6,p.label,{part:"axis-title",anchor:k?"start":"end"}))}n.x?.showTicks&&v(r,"x",l,1,n.x.tickSize??4);for(let p of r)c.push(b(p.pos,l+(h?12:20),p.label,"x-label"))}return n.xLabel&&c.push(q(m(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&c.push(q(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),c}var q=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:R.label,...r});function hi(e,n,t,r,i={}){let o=Math.max(4,Math.min(r-4,e)),a=i.anchor??"start",l=a==="middle"?2*Math.min(o-4,r-o-4):a==="end"?o-4:r-o-4,c=Nt(t,l);return{kind:"text",part:"label",x:o,y:n,fill:R.label,...i,text:c,title:c===t?i.title:t}}function kr(e){return e.flatMap(n=>{if(n.kind!=="text"||n.fill!=="var(--skdx-color-text-on-accent)"&&n.part!=="reference-label")return[n];let t=n.text.length*te+8,r=n.x-(n.anchor==="middle"?t/2:n.anchor==="end"?t-4:4),i=n.y-(n.baseline==="hanging"?2:n.baseline==="middle"?9:14);return[{kind:"rect",part:"label-background",x:r,y:i,width:t,height:18,rx:8,fill:"var(--skdx-color-surface-raised)"},{...n,fill:n.part==="reference-label"?n.fill:"var(--skdx-color-text-default)"}]})}var je=(e,n,t,r,i,o)=>({kind:"circle",part:"point",cx:e,cy:n,r:t,fill:r,title:i,item:o});function Ht(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height,a=c=>Math.max(r.x,Math.min(i,c)),l=c=>Math.max(r.y,Math.min(o,c));for(let c of e??[]){let d=c.color??rt(c.variant),u=c.color??Bt(c.variant),h={part:"reference-label",fill:u},b=n.horizontal===!0;if("y"in c){let v=m(n.y(c.y,c.axis??"left"));if(b){let y=a(v);t.push(...Mr(y,r.y,o,d,c.label,h))}else{let y=l(v);t.push(...vr(r.x,i,y,d,c.label,h))}}else if("x"in c){let v=n.x(c.x);if(v===void 0)continue;b?t.push(...vr(r.x,i,l(m(v)),d,c.label,h)):t.push(...Mr(a(m(v)),r.y,o,d,c.label,h))}else if("y1"in c){let v=m(n.y(c.y1,c.axis??"left")),y=m(n.y(c.y2,c.axis??"left"));b?t.push(...Sr(a(Math.min(v,y)),a(Math.max(v,y)),r,d,c.label,u)):t.push(...wr(l(Math.min(v,y)),l(Math.max(v,y)),r,d,c.label,u))}else{let v=n.x(c.x1),y=n.x(c.x2);if(v===void 0||y===void 0)continue;let p=m(Math.min(v,y)),k=m(Math.max(v,y));b?t.push(...wr(l(p),l(k),r,d,c.label,u)):t.push(...Sr(a(p),a(k),r,d,c.label,u))}}return t}function vr(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:n,y1:t,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,q(n-4,t-5,i,{...o,anchor:"end"})]:[a]}function Mr(e,n,t,r,i,o){let a={kind:"line",part:"reference",x1:e,x2:e,y1:n,y2:t,stroke:r,dash:"6 4",strokeWidth:1.5,title:i};return i?[a,q(e+4,n+10,i,{...o,anchor:"start"})]:[a]}function wr(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:t.x,y:e,width:t.width,height:m(Math.max(0,n-e)),fill:r,opacity:.12,title:i};return i?[a,q(t.x+t.width-4,e+12,i,{part:"reference-label",fill:o,anchor:"end"})]:[a]}function Sr(e,n,t,r,i,o){let a={kind:"rect",part:"reference-area",x:e,y:t.y,width:m(Math.max(0,n-e)),height:t.height,fill:r,opacity:.12,title:i};return i?[a,q(e+4,t.y+12,i,{part:"reference-label",fill:o,anchor:"start"})]:[a]}function $r(e,n){let t=[],{plot:r}=n,i=r.x+r.width,o=r.y+r.height;for(let a of e??[]){let l=a.color??rt(a.variant),c=a.color??Bt(a.variant),d=(y,p,k)=>{let w=n.x(y);if(w===void 0)return;let f=n.y(p,k??"left");return n.horizontal?{x:m(f),y:m(w)}:{x:m(w),y:m(f)}},u=a.id??a.label,h=y=>({label:y,id:u,name:a.label});if(a.type==="line"||a.type==="band"){let{type:y,id:p,...k}=a;t.push(...Ht([k],n));continue}if(a.type==="rect"){let y=d(a.x1,a.y1,a.axis),p=d(a.x2,a.y2,a.axis);if(!y||!p)continue;let k=Math.max(r.x,Math.min(y.x,p.x)),w=Math.max(r.y,Math.min(y.y,p.y)),f=a.label??"";t.push({kind:"rect",part:"annotation-rect",x:m(k),y:m(w),width:m(Math.max(0,Math.min(i,Math.max(y.x,p.x))-k)),height:m(Math.max(0,Math.min(o,Math.max(y.y,p.y))-w)),fill:l,opacity:.12,stroke:l,title:f||void 0,item:f?h(f):void 0}),a.label&&t.push(q(m(k+4),m(w+12),a.label,{part:"annotation-label",fill:c}));continue}let b=d(a.x,a.y,a.axis);if(!b)continue;if(a.type==="text"){t.push(q(b.x,b.y,a.text,{part:"annotation-text",fill:c,anchor:"middle",baseline:"middle",title:a.label}));continue}let v=a.label??`${String(a.x)}, ${a.y}`;if(t.push({kind:"circle",part:"annotation-point",cx:b.x,cy:b.y,r:5,fill:l,stroke:"var(--skdx-color-surface-default)",title:v,item:h(v)}),a.type==="callout"&&a.label){let[y,p]=a.offset??[16,-16],k=m(Math.max(r.x,Math.min(i,b.x+y))),w=m(Math.max(r.y,Math.min(o,b.y+p)));t.push({kind:"line",part:"annotation-leader",x1:b.x,y1:b.y,x2:k,y2:w,stroke:l},q(k,w,a.label,{part:"annotation-label",fill:c,anchor:y>=0?"start":"end",baseline:"middle"}))}}return t}var Wt=2e3;function fi(e){if(e!=="none")return e===void 0||e==="auto"?{strategy:"lttb",threshold:Wt}:typeof e=="string"?{strategy:e,threshold:Wt}:{strategy:e.strategy,threshold:e.threshold??Wt}}function mi(e,n){let t=e.length;if(n>=t||n<3)return e.map((l,c)=>c);let r=[0],i=[],o=(t-2)/(n-2),a=0;for(let l=0;l<n-2;l++){let c=Math.floor((l+1)*o)+1,d=Math.min(t-1,Math.floor((l+2)*o)+1),u=0,h=0,b=0;for(let M=c;M<d;M++){let I=e[M];$(I)&&(u+=M,h+=I,b++)}u=b?u/b:(c+d)/2,h=b?h/b:0;let v=Math.floor(l*o)+1,y=Math.min(t-1,Math.floor((l+1)*o)+1),p=e[a],k=$(p)?p:0,w=-1,f=-1;for(let M=v;M<y;M++){let I=e[M];if(!$(I)){i.push(M);continue}let S=Math.abs((a-u)*(I-k)-(a-M)*(h-k));S>f&&(f=S,w=M)}w<0&&(w=v),r.push(w),a=w}return r.push(t-1),i.length?[...new Set([...r,...i])].sort((l,c)=>l-c):r}function pi(e,n){let t=e.length,r=Math.max(1,Math.floor(n/2));if(r*2>=t)return e.map((a,l)=>l);let i=[],o=t/r;for(let a=0;a<r;a++){let l=Math.floor(a*o),c=a===r-1?t:Math.floor((a+1)*o),d=-1,u=-1;for(let h=l;h<c;h++){let b=e[h];if(!$(b)){i.push(h);continue}(d<0||b<e[d])&&(d=h),(u<0||b>e[u])&&(u=h)}d>=0&&i.push(Math.min(d,u)),u>=0&&u!==d&&i.push(Math.max(d,u))}return[...new Set(i)].sort((a,l)=>a-l)}function bi(e,n){let t=e.length,r=Math.max(1,Math.floor(n/4));if(r*4>=t)return e.map((a,l)=>l);let i=[],o=t/r;for(let a=0;a<r;a++){let l=Math.floor(a*o),c=a===r-1?t:Math.floor((a+1)*o),d=-1,u=-1,h=-1,b=-1;for(let v=l;v<c;v++){let y=e[v];if(!$(y)){i.push(v);continue}h<0&&(h=v),b=v,(d<0||y<e[d])&&(d=v),(u<0||y>e[u])&&(u=v)}for(let v of[h,d,u,b])v>=0&&i.push(v)}return[...new Set(i)].sort((a,l)=>a-l)}function Cr(e,n,t){let r=fi(t);if(!r||n<=r.threshold||e.length===0)return;let i=r.strategy==="minmax"?pi:r.strategy==="m4"?bi:mi,o=new Set;for(let a of e)for(let l of i(a.slice(0,n),r.threshold))o.add(l);return[...o].sort((a,l)=>a-l)}function Ir(e,n,t,r,i,o,a,l){if(r==="circle")return{...je(e,n,t,i,o,a),part:l};let c=r==="square"?`M${m(e-t)} ${m(n-t)}h${m(2*t)}v${m(2*t)}h${m(-2*t)}Z`:r==="diamond"?`M${m(e)} ${m(n-t*1.3)}L${m(e+t*1.3)} ${m(n)}L${m(e)} ${m(n+t*1.3)}L${m(e-t*1.3)} ${m(n)}Z`:`M${m(e)} ${m(n-t*1.2)}L${m(e+t*1.15)} ${m(n+t*.9)}L${m(e-t*1.15)} ${m(n+t*.9)}Z`;return{kind:"path",part:l,d:c,fill:i,title:o,item:a}}var xi=e=>{let n=0;return e.map(t=>$(t)?n+=t:null)},gi=e=>e.map((n,t)=>{let r=e[t-1];return t>0&&$(n)&&$(r)?n-r:null}),yi=e=>e.map((n,t)=>{let r=e[t-1];return t>0&&$(n)&&$(r)&&r!==0?(n-r)/Math.abs(r):null});function ki(e,n){let t=Math.max(1,Math.floor(n));return e.map((r,i)=>{if(i<t-1)return null;let o=0;for(let a=i-t+1;a<=i;a++){let l=e[a];if(!$(l))return null;o+=l}return o/t})}function vi(e,n="max"){let t=0;for(let r of e)$(r)&&(t=n==="sum"?t+r:Math.max(t,r));return e.map(r=>$(r)?t===0?0:r/t:null)}function Mi(e,n="desc"){let t=e.filter($).sort((r,i)=>n==="asc"?r-i:i-r);return e.map(r=>$(r)?t.indexOf(r)+1:null)}var wi=(e,n=-1/0,t=1/0)=>e.map(r=>$(r)&&r>=n&&r<=t?r:null),Si=(e,n="asc")=>[...e].sort((t,r)=>$(t)?$(r)?n==="asc"?t-r:r-t:-1:$(r)?1:0);function $i(e,n,t="sum"){let r=Math.max(1,Math.floor(n)),i=[];for(let o=0;o<e.length;o+=r){let a=e.slice(o,o+r).filter($);if(a.length===0){i.push(null);continue}let l=a.reduce((c,d)=>c+d,0);i.push(t==="sum"?l:t==="mean"?l/a.length:t==="min"?Math.min(...a):Math.max(...a))}return i}function Ci(e,n={}){let t=e.filter($),r=tt(t,n);return{edges:r,counts:nt(t,r).map(i=>i.count)}}function Zt(e,n){let t=[...e];for(let r of n??[])switch(r.type){case"cumulative":t=xi(t);break;case"difference":t=gi(t);break;case"percentageChange":t=yi(t);break;case"movingAverage":t=ki(t,r.window);break;case"normalize":t=vi(t,r.to);break;case"rank":t=Mi(t,r.order);break;case"filter":t=wi(t,r.min,r.max);break;case"sort":t=Si(t,r.order);break;case"aggregate":t=$i(t,r.every,r.method);break;case"bin":t=Ci(t,r).counts;break}return t}var Ii=100,Ti=2e3,Tr=32,Ar=28,ct=e=>e.position==="right"||e.position==="top";function Ai(e){let t=(e.yAxis===void 0?[]:Array.isArray(e.yAxis)?e.yAxis:[e.yAxis]).map((i,o)=>({...i,id:i.id??(o===0?"left":o===1?"right":String(o)),position:i.position??(o===1?"right":"left")}));t.length===0&&t.push({id:"left",position:"left"});let r=t.some(i=>i.id==="right"||ct(i));return e.rightAxis?t.push({...e.rightAxis,id:"right",position:"right"}):!r&&e.series.some(i=>i.axis==="right")&&t.push({id:"right",position:"right"}),t}function zr(e,n){let t=e[0]?.id;return n===void 0||n==="left"?t:n==="right"?(e.find(r=>r.id==="right")??e.find(ct))?.id:e.find(r=>r.id===n)?.id}var lt=e=>e.kind==="bar"||e.kind==="range"&&e.style==="bar";function Lr(e,n){let t=Ce(e.format),{series:r,categories:i,issues:o,axes:a}=zi(e,n,t),l=e.direction==="rtl",c=e.baseline??0,d=Math.max(i.length,...r.map(s=>Math.max(s.data.length,s.low.length))),u=r.every(s=>de(s.data).length===0&&de(s.high).length===0),h=yr(e,u);if(h)return{...h,issues:o};let b=e.xAxis?.type??"category",v=b!=="category"&&i.length>0&&i.every(s=>typeof s!="string"||b==="time"&&$(ce(s))),y=v?i.map(ce):[],[p,k]=ue(y),w=e.xAxis?.format??(b==="time"?{style:k-p<2*864e5?"time":"date"}:void 0),f=Array.from({length:d},(s,g)=>{let C=i[g];return C===void 0?String(g+1):et(C,w)}),M=Oi(e.zoom,d),I=Array.from({length:M.end-M.start},(s,g)=>M.start+g),S=e.orientation==="horizontal",F=r.map(s=>({...s,hidden:s.hidden||S&&!lt(s)})).filter(s=>!s.hidden),j=F.some(s=>!lt(s))?Cr(F.filter(s=>!lt(s)).map(s=>I.map(g=>(s.kind==="range"?s.high[g]:s.data[g])??null)),I.length,e.sampling):void 0,B=j?j.map(s=>I[s]):I,X=e.stacked==="percent"||e.stackOffset==="expand",J=e.stackOffset??"zero",ae=new Map,me=new Map,xt=new Map;for(let s of F)s.stack!==void 0&&s.kind!=="range"&&xt.set(s.stack,[...xt.get(s.stack)??[],s]);for(let s of xt.values()){let g=new Array(d).fill(c),C=new Array(d).fill(c),G=new Array(d).fill(0);if(X)for(let P of s)P.data.forEach((L,_)=>{$(L)&&(G[_]=G[_]+Math.abs(L))});for(let P of s){let L=[],_=[];for(let D=0;D<d;D++){let N=P.data[D];if(!$(N)){L.push(null),_.push(null);continue}let z=G[D],T=X?z>0?N/z:0:N,E=T>=0?g:C;L.push(E[D]),E[D]=E[D]+T,_.push(E[D])}ae.set(P,L),me.set(P,_)}if(J==="silhouette"||J==="wiggle"){let P=new Array(d).fill(0);if(J==="silhouette")for(let L=0;L<d;L++)P[L]=-(g[L]-c)/2;else{let L=0;for(let _=0;_<d;_++){let D=s.length,N=0;for(let T=0;T<D;T++){let E=s[T],W=E.data[_],K=E.data[_-1],Q=_>0&&$(W)&&$(K)?W-K:0;N+=(D-T-.5)*Q}let z=g[_]-c;L=_===0?-z/2:L-(z>0?N/Math.max(1,D):0),P[_]=L}}for(let L of s){let _=ae.get(L),D=me.get(L);for(let N=0;N<d;N++){let z=_[N],T=D[N];$(z)&&(_[N]=z+P[N]),$(T)&&(D[N]=T+P[N])}}}}let An=s=>s.kind==="range"?{from:s.low,to:s.high}:{from:ae.get(s)??new Array(d).fill(c),to:me.get(s)??s.data},On=s=>{let g=[],C=!1;for(let L of F){if(L.axis!==s)continue;let{from:_,to:D}=An(L);for(let N of B){let z=D[N];if($(z)&&g.push(z),L.kind==="range"||L.stack!==void 0){let T=_[N];$(T)&&g.push(T)}}if(L.errors)for(let N of B){let z=Or(L.data[N],L.errors[N]);z&&g.push(z[0],z[1])}(L.kind==="bar"||L.kind==="area")&&J==="zero"&&(C=!0)}let[G,P]=ue(g);return C?[Math.min(c,G),Math.max(c,P)]:[G,P]},{width:gt,height:zn}=ot(e),Wr=e.brush?Tr+Ar:0,Ln=B.reduce((s,g)=>Math.max(s,f[g].length),0)*te,Rn=X?{style:"percent"}:void 0,Zr=s=>{if(s.scale==="log")return ne.left;let[g,C]=On(s.id),G=Ce(s.format??Rn??e.format);return xr([s.min??g,s.max??C],G)+(s.showTicks?s.tickSize??4:0)},yt=s=>S?ct(s)?"top":"bottom":ct(s)!==l?"right":"left",Vn=s=>S?24+(s.showTicks?s.tickSize??4:0):Zr(s),Ur=new Set(F.map(s=>s.axis)),kt=a.filter(s=>Ur.has(s.id)||a.length>1),Bn=new Map,Me={left:0,right:0,top:0,bottom:0};for(let s of kt){let g=yt(s);Bn.set(s.id,Me[g]),Me[g]+=Vn(s)}let Dn=kt.find(s=>yt(s)==="bottom"),Pn=r.map(s=>({name:s.name,color:s.color})),Kr={top:ne.top+hr(e,Pn,gt)+(a.some(s=>s.label)?12:0)+Me.top,right:S?l?Math.max(ne.left,Ln+16):ne.right:Math.max(ne.right,Me.right),bottom:ne.bottom+Wr+(e.xAxis?.label?14:0)+(e.xAxis?.tickRotation?24:0)+Me.bottom-(Dn?Vn(Dn):0),left:S?l?ne.right:Math.max(ne.left,Ln+16):Math.max(ne.left,Me.left)},U=cr(gt,zn,Kr),qr=S?l?[U.x+U.width,U.x]:[U.x,U.x+U.width]:[U.y+U.height,U.y],Nn=S?[U.y,U.y+U.height]:l?[U.x+U.width,U.x]:[U.x,U.x+U.width],vt=new Map(a.map(s=>[s.id,{...br(On(s.id),qr,{format:Rn,...s},e.format),position:yt(s),offset:Bn.get(s.id)??0}])),Fn=a[0]?.id,Ze=vt.get(Fn),Mt=s=>vt.get(zr(a,s)??Fn)??Ze,se=(s,g)=>Mt(g).scale(s),Gn=s=>m(s.scale(Math.min(Math.max(c,Math.min(...s.domain)),Math.max(...s.domain)))),Ue=rr(B.length,Nn,e.barGap),wt=B.map(s=>y[s]),St=[...wt].sort((s,g)=>s-g),we=1/0;for(let s=1;s<St.length;s++)we=Math.min(we,St[s]-St[s-1]);let[Se,ze]=ue(wt),le=we===1/0?Math.max(1,Math.abs(ze)*.05||1):we/2,Le=Ie([Se-le,ze+le],Nn),Ke=s=>m(v?Le(wt[s]):Ue.center(s)),_n=v?Math.abs(Le(Se+(we===1/0?le:we))-Le(Se))*.8:Ue.bandwidth,jn=s=>v?Ke(s)-_n/2:Ue.start(s),Xr=v?(b==="time"?or(Se-le,ze+le):ke(Se-le,ze+le)).filter(s=>s>=Se-le&&s<=ze+le).map(s=>({pos:m(Le(s)),label:et(s,w)})):st(B.map((s,g)=>({pos:Ke(g),label:f[s]})),S?1/0:U.width/Math.max(.2,Math.abs(Math.cos((e.xAxis?.tickRotation??0)*Math.PI/180)))),$t={...Ft(e,gt,zn,Pn),plot:U,xTicks:Xr,yTicks:S?st(Ze.ticks,U.width):Ze.ticks,baseline:Gn(Ze)},Yr=a[0],En=Et($t,{horizontal:S,rtl:l,axes:kt.map(s=>{let g=vt.get(s.id);return{ticks:S?st(g.ticks,U.width):g.ticks,position:g.position,offset:g.offset??0,label:s.label,showLine:s.showLine,showTicks:s.showTicks,tickSize:s.tickSize}}),xLabel:e.xAxis?.label,grid:gr(Yr),categoryGrid:e.xAxis?.grid===!0,x:e.xAxis}),Jr=s=>{if(typeof s=="number"&&i.every(C=>typeof C=="string"))return s;let g=typeof s=="string"?s:ce(s);for(let C=0;C<d;C++){let G=i[C];if(G!==void 0&&(typeof g=="string"?G===g||f[C]===g:ce(G)===g))return C}},Hn={plot:U,horizontal:S,x:s=>{if(v&&(typeof s!="string"||$(ce(s))))return Le(ce(s));let g=Jr(s),C=g===void 0?-1:B.indexOf(g);return C<0?void 0:Ue.center(C)},y:(s,g)=>se(s,g)},Wn=Ht(e.references,Hn);En.push(...Wn.filter(s=>s.part!=="reference-label"));let Qr=kr(Wn.filter(s=>s.part==="reference-label")),Ct=[],It=new Map;for(let s of F){if(!lt(s))continue;let g=s.stack??s,C=Ct.indexOf(g);C<0&&(C=Ct.push(g)-1),It.set(s,C)}let qe=_n/Math.max(1,Ct.length),pe=Math.min(qe,e.barWidth??1/0),Zn=(qe-pe)/2,Tt=[],Xe=[],At=[],Ot=[],zt=[],Un=[],Ye=[],Je=s=>Mt(s.axis).format,Lt=Math.max(0,e.minBarSize??0),ei=(s,g,C)=>{let G=Math.abs(g-s);if(G>=Lt)return[Math.min(s,g),G];let L=s+(S?C?1:-1:C?-1:1)*Lt;return[Math.min(s,L),Lt]},Re=(s,g,C,G)=>({label:G,series:s.name,seriesId:s.id??s.name,category:f[g],index:g,value:C}),Kn=(s,g,C,G)=>{let P=Or(G,s.errors?.[g]);if(!P)return;let L=m(se(P[0],s.axis)),_=m(se(P[1],s.axis)),D=4,N="var(--skdx-color-text-default)",z=`${s.name}, ${f[g]}: ${Je(s)(P[0])} \u2013 ${Je(s)(P[1])}`;Un.push(S?{kind:"line",part:"error-bar",x1:L,x2:_,y1:C,y2:C,stroke:N,title:z}:{kind:"line",part:"error-bar",x1:C,x2:C,y1:L,y2:_,stroke:N,title:z},S?{kind:"line",part:"error-cap",x1:L,x2:L,y1:m(C-D),y2:m(C+D),stroke:N}:{kind:"line",part:"error-cap",x1:m(C-D),x2:m(C+D),y1:L,y2:L,stroke:N},S?{kind:"line",part:"error-cap",x1:_,x2:_,y1:m(C-D),y2:m(C+D),stroke:N}:{kind:"line",part:"error-cap",x1:m(C-D),x2:m(C+D),y1:_,y2:_,stroke:N})};for(let s of F){let{from:g,to:C}=An(s),G=Je(s),P=B.length<=Ti;if(s.kind==="bar"){let z="";B.forEach((T,E)=>{let W=s.data[T],K=g[T],Q=C[T];if(!$(W)||!$(K)||!$(Q))return;let $e=se(K,s.axis),ye=se(Q,s.axis),[Ve,Be]=ei($e,ye,Q>=K),De=jn(E)+It.get(s)*qe+Zn,Xn=m(S?Ve:De),Yn=m(S?De:Ve),Rt=m(S?Be:pe),Jn=m(S?pe:Be);if(!P){z+=`M${Xn} ${Yn}h${Rt}v${Jn}h${-Rt}Z`;return}let Qn=_t(s.name,f[T],X?Q-K:W,G);if(Xe.push({kind:"rect",part:"bar",x:Xn,y:Yn,width:Rt,height:Jn,fill:s.color,rx:e.radius,title:Qn,item:Re(s,T,W,Qn)}),Kn(s,T,m(De+pe/2),W),e.labels){let er=G(X?Q-K:W);zt.push(S?q(m(Math.max($e,ye)+4),m(De+pe/2),er,{baseline:"middle"}):q(m(De+pe/2),m(Math.min($e,ye)-4),er,{anchor:"middle"}))}}),z&&Xe.push({kind:"path",part:"bars",d:z,fill:s.color,title:s.name});continue}if(s.kind==="range"&&s.style==="bar"){B.forEach((z,T)=>{let E=g[z],W=C[z];if(!$(E)||!$(W))return;let K=se(Math.min(E,W),s.axis),Q=se(Math.max(E,W),s.axis),$e=jn(T)+It.get(s)*qe+Zn,ye=`${s.name}, ${f[z]}: ${G(Math.min(E,W))} \u2013 ${G(Math.max(E,W))}`,Ve=Re(s,z,W,ye),Be=Math.max(1,Math.abs(Q-K));Xe.push(S?{kind:"rect",part:"range",x:m(Math.min(K,Q)),y:m($e),width:m(Be),height:m(pe),fill:s.color,rx:e.radius,title:P?ye:void 0,item:Ve}:{kind:"rect",part:"range",x:m($e),y:m(Math.min(K,Q)),width:m(pe),height:m(Be),fill:s.color,rx:e.radius,title:P?ye:void 0,item:Ve})});continue}let L=e.nulls==="connect"||e.nulls===void 0&&e.connectNulls,_=[],D=[];B.forEach((z,T)=>{let E=g[z],W=C[z];if(!$(W)||!$(E)){!L&&D.length&&(_.push(D),D=[]);return}D.push({x:Ke(T),y:m(se(W,s.axis)),y0:m(se(E,s.axis)),i:z})}),D.length&&_.push(D);let N=s.markers??B.length<=Ii;for(let z of _){let T=ve(z,s.curve);if(s.kind==="range"&&s.style==="line"){At.push({kind:"path",part:"range-high",d:T,stroke:s.color,strokeWidth:2,strokeLinejoin:"round"},{kind:"path",part:"range-low",d:ve(z.map(E=>({x:E.x,y:E.y0})),s.curve),stroke:s.color,strokeWidth:2,strokeLinejoin:"round",dash:"4 3"});continue}if(s.kind==="range"){let E=ve([...z].reverse().map(W=>({x:W.x,y:W.y0})),s.curve);Tt.push({kind:"path",part:"range",d:`${T}L${E.slice(1)}Z`,fill:s.color,fillOpacity:.2,title:s.name});continue}if(s.kind==="area"){let E=Gn(Mt(s.axis)),W=s.stack!==void 0?ve([...z].reverse().map(Q=>({x:Q.x,y:Q.y0})),s.curve).slice(1):`${z[z.length-1]?.x} ${E}L${z[0]?.x} ${E}`,K=`skdx-g-${s.index}`;s.gradient&&!Ye.some(Q=>Q.id===K)&&Ye.push({id:K,vertical:!0,stops:[{offset:0,color:s.color,opacity:s.fillOpacity},{offset:1,color:s.color,opacity:0}]}),Tt.push({kind:"path",part:"area",d:`${T}L${W}Z`,fill:s.gradient?`url(#${K})`:s.color,fillOpacity:s.gradient?void 0:s.fillOpacity})}At.push({kind:"path",part:"line",d:T,stroke:s.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",dash:s.dash})}if(s.kind==="range"&&P)for(let z of _)for(let T of z){let E=s.low[T.i],W=s.high[T.i],K=`${s.name}, ${f[T.i]}: ${G(Math.min(E,W))} \u2013 ${G(Math.max(E,W))}`;Ot.push({...je(T.x,T.y,.01,s.color,K,Re(s,T.i,W,K)),part:"anchor"})}if(s.kind!=="range")for(let z of _)for(let T of z){if(!N&&!P&&!e.labels&&!s.errors)continue;let E=s.data[T.i],W=X?C[T.i]-g[T.i]:E,K=_t(s.name,f[T.i],W,G);(N||P)&&Ot.push(N&&s.symbol!=="circle"?Ir(T.x,T.y,s.markerSize,s.symbol,s.color,P?K:void 0,Re(s,T.i,E,K),"point"):{...je(T.x,T.y,N?s.markerSize:.01,s.color,P?K:void 0,Re(s,T.i,E,K)),part:N?"point":"anchor"}),P&&Kn(s,T.i,S?T.y:T.x,C[T.i]),e.labels&&zt.push(q(T.x,T.y-8,G(W),{anchor:"middle"}))}}let qn={plot:U,xs:S?[]:B.map((s,g)=>Ke(g)),rows:B.map(s=>[f[s],...F.map(g=>{let C=Je(g);if(g.kind==="range"){let P=g.low[s],L=g.high[s];return`${g.name}: ${$(P)&&$(L)?`${C(P)} \u2013 ${C(L)}`:"\u2014"}`}let G=g.data[s];return`${g.name}: ${$(G)?C(X?(me.get(g)?.[s]??0)-(ae.get(g)?.[s]??0):G):"\u2014"}`})]),count:d,zoom:M,crosshair:dr(e)},Qe=[];if(e.brush&&!S){let s={x:U.x,y:U.y+U.height+Ar,width:U.width,height:Tr},g=F.find(G=>G.kind!=="range"),C={x:m(s.x+M.start/Math.max(1,d)*s.width),y:s.y,width:m((M.end-M.start)/Math.max(1,d)*s.width),height:s.height};if(Qe.push({kind:"rect",part:"brush",x:s.x,y:s.y,width:s.width,height:s.height,fill:"var(--skdx-color-surface-sunken)",stroke:R.grid}),g){let G=de(g.data),[P,L]=ue(G),_=d>1?s.width/(d-1):0,D=g.data.flatMap((z,T)=>$(z)?[{x:m(s.x+T*_),y:m(s.y+s.height-(L===P?.5:(z-P)/(L-P))*(s.height-4)-2)}]:[]),N=ve(D);D.length>1&&Qe.push({kind:"path",part:"brush-series",d:`${N}L${D[D.length-1]?.x} ${s.y+s.height}L${D[0]?.x} ${s.y+s.height}Z`,fill:g.color,fillOpacity:.3})}Qe.push({kind:"rect",part:"brush-window",...C,fill:"var(--skdx-color-primary-500)",opacity:.15,stroke:R.axis},{kind:"rect",part:"brush-handle",x:m(C.x-3),y:s.y+8,width:6,height:s.height-16,fill:R.axis,rx:8},{kind:"rect",part:"brush-handle",x:m(C.x+C.width-3),y:s.y+8,width:6,height:s.height-16,fill:R.axis,rx:8}),qn.brush={box:s,window:C}}return{...$t,shapes:[...En,...Tt,...Xe,...At,...Un,...Ot,...zt,...Qr,...$r(e.annotations,Hn),...Qe,...$t.shapes],hit:qn,issues:o,defs:Ye.length?Ye:void 0}}function Or(e,n){if(!(!$(e)||n===null||n===void 0))return typeof n=="number"?$(n)?[e-Math.abs(n),e+Math.abs(n)]:void 0:$(n[0])&&$(n[1])?[Math.min(n[0],n[1]),Math.max(n[0],n[1])]:void 0}function Oi(e,n){if(!e||n<2)return{start:0,end:n};let t=Math.max(0,Math.min(n-1,Math.floor(e.start))),r=Math.max(t+1,Math.min(n,Math.ceil(e.end)));return r-t<2&&n>=2?{start:Math.min(t,n-2),end:Math.min(t,n-2)+2}:{start:t,end:r}}function zi(e,n,t){let r=f=>f.type??n,i=[],o=Ai(e),a=e.categories??[],l=(e.transforms??[]).filter(f=>f.type==="sort"||f.type==="bin"||f.type==="aggregate"),c=(e.transforms??[]).filter(f=>!l.includes(f)),d=e.stacked||e.stackOffset!==void 0&&e.stackOffset!=="zero",u=(f,M,I)=>{let S=I.filter(O=>O!==null&&!(typeof O=="number"&&Number.isFinite(O))).length;S&&i.push({code:"invalid-value",severity:"warning",message:`Series "${f}" has ${S} value${S===1?"":"s"} that ${S===1?"is":"are"} neither a number nor null; drawn as gaps.`,itemId:M??f}),a.length&&I.length!==a.length&&!e.transform&&i.push({code:"length-mismatch",severity:"warning",message:`Series "${f}" has ${I.length} values for ${a.length} categories.`,itemId:M??f})},h=e.series.map((f,M)=>{let I=r(f),S=d?!0:void 0,O=f.type==="range"?void 0:f.stack,F=O===!1?void 0:O===!0||O===void 0&&S?`${I}`:O;f.type==="range"?(u(f.name,f.id,f.low),u(f.name,f.id,f.high)):u(f.name,f.id,f.data);let j=X=>e.nulls==="zero"?X.map(J=>$(J)?J:0):X,B=zr(o,f.axis);return B===void 0&&i.push({code:"unknown-axis",severity:"warning",message:`Series "${f.name}" names axis "${String(f.axis)}", which is not defined; drawn on the first axis.`,itemId:f.id??f.name}),{name:f.name,id:f.id,color:fr(e,M,f.color),axis:B??o[0]?.id,hidden:mr(e,f.name),index:M,kind:I,data:f.type==="range"?[]:j(Zt(Zt(f.data,c),f.transforms)),low:f.type==="range"?f.low:[],high:f.type==="range"?f.high:[],curve:f.curve??e.curve??"linear",dash:f.type==="range"?void 0:f.dash,markers:f.type==="range"?void 0:f.markers,symbol:f.type==="range"?"circle":f.symbol??"circle",markerSize:f.type==="range"?3:f.markerSize??3,errors:f.type==="range"?void 0:f.errors,stack:I==="range"||I==="line"?void 0:F,style:f.type==="range"?f.style??"area":"area",fillOpacity:(f.type==="range"?void 0:f.fillOpacity)??e.fillOpacity??.25,gradient:f.type!=="range"&&f.gradient===!0}}),b=()=>Math.max(a.length,...h.map(f=>Math.max(f.data.length,f.low.length))),v=f=>{let M=S=>S.length?f.map(O=>S[O]??null):S,I=Array.from({length:b()},(S,O)=>a[O]??String(O+1));a=f.map(S=>I[S]),h=h.map(S=>({...S,data:M(S.data),low:M(S.low),high:M(S.high)}))},y=(f,M)=>{let I=(M!==void 0?h.find(O=>O.name===M):void 0)??h.find(O=>!O.hidden&&O.kind!=="range")??h[0];M!==void 0&&!h.some(O=>O.name===M)&&i.push({code:"unknown-series",severity:"warning",message:`sort.by names "${M}", which is not a series; sorted by the first series.`});let S=Array.from({length:b()},(O,F)=>F).sort((O,F)=>{let j=I?.data[O]??I?.high[O],B=I?.data[F]??I?.high[F],X=$(j)?j:-1/0,J=$(B)?B:-1/0;return f==="asc"?X-J:J-X});v(S)},p=f=>{let M=h.flatMap(S=>de(S.data)),I=tt(M,f);a=I.slice(1).map((S,O)=>`${t(I[O])}\u2013${t(S)}`),h=h.map(S=>{let O=de(S.data),F=0,j=nt(O,I).map(B=>e.binMode==="density"?O.length?B.count/(O.length*(B.x1-B.x0)):0:e.binMode==="cumulative"?F+=B.count:B.count);return{...S,data:j}})},k=(f,M)=>{let I=Math.max(1,Math.floor(f)),S=b(),O=j=>{if(!j.length)return j;let B=[];for(let X=0;X<S;X+=I){let J=de(j.slice(X,X+I));B.push(J.length===0?null:M==="sum"?J.reduce((ae,me)=>ae+me,0):M==="mean"?J.reduce((ae,me)=>ae+me,0)/J.length:M==="min"?Math.min(...J):Math.max(...J))}return B};a=Array.from({length:S},(j,B)=>a[B]??String(B+1)).filter((j,B)=>B%I===0),h=h.map(j=>({...j,data:O(j.data),low:O(j.low),high:O(j.high)}))};e.transform==="histogram"?p({bins:e.bins,binWidth:e.binWidth,domain:e.binDomain}):e.transform==="cumulative"&&(h=h.map(f=>{let M=0;return{...f,data:f.data.map(I=>$(I)?M+=I:M)}}));for(let f of l)f.type==="sort"?y(f.order??"desc"):f.type==="bin"?p(f):f.type==="aggregate"&&k(f.every,f.method??"sum");typeof e.sort=="string"?y(e.sort):e.sort&&y(e.sort.order,e.sort.by);let w=e.xAxis?.domain;if(w){let f=b(),M=Array.from({length:f},(F,j)=>a[j]??String(j+1)),I=F=>{let j=typeof F=="string"?F:ce(F);return M.findIndex(B=>typeof j=="string"?B===j||et(B)===j:ce(B)===j)},S=w.map(I),O=F=>F.length?S.map(j=>j<0?null:F[j]??null):F;a=[...w],h=h.map(F=>({...F,data:O(F.data),low:O(F.low),high:O(F.high)}))}return{series:h,categories:a,issues:i,axes:o}}function dt(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Ut=e=>e.id??e.name??e.series,Rr=e=>e.seriesId??e.series;function he(e,n){let t=!1;return n.id!==void 0&&(t=!0,Ut(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,Rr(e)!==n.series&&e.series!==n.series)||n.index!==void 0&&(t=!0,e.index!==n.index)||n.category!==void 0&&(t=!0,e.category!==n.category)?!1:t}function be(e){let n={},t=Ut(e);t!==void 0&&(n.id=t);let r=Rr(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Kt=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function qt(e,n,t){let r=dt(e),i=be(n),o=r.some(a=>he(n,a));return t==="single"?o?[]:[i]:o?r.filter(a=>!he(n,a)):[...r,i]}var Li=.2;function Ri(e){let n=R.focus;switch(e.kind){case"rect":return{kind:"rect",part:"selected",x:e.x-1.5,y:e.y-1.5,width:e.width+3,height:e.height+3,fill:"none",stroke:n,rx:e.rx};case"circle":return{kind:"circle",part:"selected",cx:e.cx,cy:e.cy,r:e.r+2.5,fill:"none",stroke:n};case"path":return{kind:"path",part:"selected",d:e.d,fill:"none",stroke:n,strokeWidth:2.5};case"line":return{...e,part:"selected",stroke:n,strokeWidth:(e.strokeWidth??1)+3,title:void 0,item:void 0};case"text":return}}var Vi=(e,n)=>e.kind==="text"?{...e,fill:R.grid}:{...e,opacity:(e.opacity??1)*n};function Xt(e,n){let t=dt(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:dt(n.highlighted),i=r[0];if(t.length===0&&!i)return e;let o={highlighted:n.highlightScope?.highlighted??"item",faded:n.highlightScope?.faded??"global"},a=[],l=u=>!i||r.some(h=>he(u,h))?!0:o.highlighted==="series"?r.some(h=>h.series!==void 0&&he(u,{series:h.series})):!1,c=u=>{if(!i||o.faded==="none"||l(u))return!1;if(o.faded==="series"){let h=i.series;return h!==void 0&&he(u,{series:h})}return!0},d=e.shapes.map(u=>{let h=u.item;if(!h||h.legend)return u;if(t.some(b=>he(h,b))){let b=Ri(u);b&&a.push(b)}return c(h)?Vi(u,Li):u});return a.length?{...e,shapes:[...d,...a]}:{...e,shapes:d}}var Vr="var(--skdx-radius-default, var(--skdx-radius-md, 0.5rem))";function ut(e){return["tooltip","skeleton","label-background","stage-label-background","brush-handle"].includes(e)?Vr:void 0}function Oe(e,n,t,r,i){let o=e.getBoundingClientRect();return{x:o.width?(n-o.left)*r/o.width:n,y:o.height?(t-o.top)*i/o.height:t}}var Yt=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Br(e,n){let t=0,r=1/0;return e.xs.forEach((i,o)=>{let a=Math.abs(i-n);a<r&&(r=a,t=o)}),t}function Ee(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Br(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Jt(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[Br(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:R.axis,dash:"3 3"}}function Qt(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Yt(r.plot,n,t))return[];let i=Jt(e,n),{rows:o}=Ee(e,n),a=e.tooltipAnchored?r.plot.y+8:t;return[i,...at(i.x1,a,o,e.width,e.height,e.tooltipPlacement)]}function en(e,n){let t=e.hit;if(!t||t.xs.length===0)return[];let r=t.rows.findIndex(o=>o[0]===n);if(r<0)return[];let i=t.xs[r];return Qt(e,i,t.plot.y+8)}function tn(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:c,y:d}=Oe(t,r,i,e.width,e.height);if(Yt(e.hit.plot,c,d)){let u=Ee(e,c),h=Jt(e,c);if(u&&h)return{lines:u.rows,shapes:[h]}}}let o=n?.closest?.("[data-skdx-part]"),a=e.tooltipFormatter?xe(e,n)?.item:void 0,l=a&&e.tooltipFormatter?.(a)||o&&Array.from(o.children).find(c=>c.tagName.toLowerCase()==="title")?.textContent;return l?{lines:Array.isArray(l)?l:[l],shapes:[]}:{lines:[],shapes:[]}}function Dr(e,n,t,r,i,o,a){let l=e?.closest?.("[data-skdx-part]"),c=a&&a.tooltipFormatter?xe(a,e)?.item:void 0,d=c&&a?.tooltipFormatter?.(c)||l&&Array.from(l.children).find(y=>y.tagName.toLowerCase()==="title")?.textContent;if(!d)return[];let u=a?.tooltipAnchored?xe(a,e):void 0,h=u?a?.shapes[u.index]:void 0,{x:b,y:v}=h?He(h):Oe(n,t,r,i,o);return at(b,v,d,i,o,a?.tooltipPlacement)}function nn(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:a}=Oe(t,r,i,e.width,e.height),l=Qt(e,o,a);if(l.length>0)return l}return Dr(n,t,r,i,e.width,e.height,e)}function rn(e,n){let t=xe(e,n);return t&&!t.item.legend?be(t.item):null}var Bi=(e,n)=>{let{x:t,y:r}=He(e),i=e.kind==="circle"?e.cy:e.kind==="rect"?e.y+e.height/2:r;return t>=n.x&&t<=n.x+n.width&&i>=n.y&&i<=n.y+n.height};function on(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!Bi(i,n))continue;let o=be(i.item),a=JSON.stringify(o);t.has(a)||(t.add(a),r.push(o))}return r}var an=e=>({kind:"rect",part:"selection-box",x:m(e.x),y:m(e.y),width:m(e.width),height:m(e.height),fill:R.focus,opacity:.12,stroke:R.focus}),ft=(e,n,t,r)=>({x:Math.min(e,t),y:Math.min(n,r),width:Math.abs(t-e),height:Math.abs(r-n)});function Pr(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let a=e[i],l=e[o];a.y>t!=l.y>t&&n<(l.x-a.x)*(t-a.y)/(l.y-a.y)+a.x&&(r=!r)}return r}function sn(e,n){if(n.length<3)return[];let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor")continue;let{x:o,y:a}=He(i),l=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:a;if(!Pr(n,o,l))continue;let c=be(i.item),d=JSON.stringify(c);t.has(d)||(t.add(d),r.push(c))}return r}var ln=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${m(n.x)} ${m(n.y)}`).join("L")}`:"",fill:R.focus,fillOpacity:.12,stroke:R.focus,dash:"4 3"}),ht=6;function cn(e,n,t){let r=e.edit;if(r){for(let i of r.bars)if(!(t<i.y||t>i.y+i.height||n<i.x0-ht||n>i.x1+ht))return Math.abs(n-i.x0)<=ht?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=ht?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function dn(e,n,t){let r=e.edit;return Nr(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function un(e,n,t){let r=e.edit,i=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;if(!r||n===null||!i||!(t.shiftKey||t.altKey))return;let o=r.bars.find(c=>c.index===n);if(!o)return;let a=t.altKey?t.shiftKey?"start":"end":"move",l=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return Nr(r,{bar:o,mode:a},i*l)}function Nr(e,{bar:n,mode:t},r){let i=l=>e.snap?Math.round(l/e.snap)*e.snap:l,o=n.start,a=n.end;return t==="move"?(o=i(n.start+r),a=o+(n.end-n.start)):t==="start"?o=Math.min(i(n.start+r),n.end):a=Math.max(i(n.end+r),n.start),{id:n.id,name:n.name,start:o,end:a}}function hn(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:m(Math.min(i,o)),y:m(n.bar.y),width:m(Math.max(1,Math.abs(o-i))),height:m(n.bar.height),fill:R.focus,opacity:.25,stroke:R.focus,rx:2}}var Di=64,Pi=e=>Math.max(1,Math.min(Di,e));function fn(e,n,t,r){let i=n>0?.8:1.25,o=Pi(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:a,scale:l}=e,[c,d]=e.view.center,u=(t-(a.x+a.width/2))/l,h=(r-(a.y+a.height/2))/l,b=e.view.zoom/o;return{center:[c+u*(1-b),e.fromY(e.toY(d)-h*(1-b))],zoom:o}}function mn(e,n,t,r){let{scale:i}=e;return{center:[n.center[0]-t/i,e.fromY(e.toY(n.center[1])+r/i)],zoom:n.zoom}}function xe(e,n){let t=n?.closest?.("[data-skdx-i]"),r=Number(t?.getAttribute("data-skdx-i")),i=Number.isInteger(r)?e.shapes[r]?.item:void 0;return i?{index:r,item:i}:void 0}var mt=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function He(e){switch(e.kind){case"rect":return{x:e.x+e.width/2,y:e.y};case"circle":return{x:e.cx,y:e.cy-e.r};case"line":return{x:(e.x1+e.x2)/2,y:Math.min(e.y1,e.y2)};case"text":return{x:e.x,y:e.y};case"path":{let n=/M\s*(-?[\d.]+)[ ,](-?[\d.]+)/.exec(e.d);return n?{x:Number(n[1]),y:Number(n[2])}:{x:0,y:0}}}}function pn(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=R.focus,i;switch(t.kind){case"rect":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-2,width:t.width+4,height:t.height+4,fill:"none",stroke:r,rx:2};break;case"circle":i={kind:"circle",part:"focus",cx:t.cx,cy:t.cy,r:t.r+3,fill:"none",stroke:r};break;case"line":i={kind:"line",part:"focus",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:r,strokeWidth:4};break;case"text":i={kind:"rect",part:"focus",x:t.x-2,y:t.y-8,width:t.text.length*te+4,height:16,fill:"none",stroke:r,rx:2};break;case"path":i={kind:"path",part:"focus",d:t.d,stroke:r,strokeWidth:2,fill:"none"};break}let{x:o,y:a}=He(t),l=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...l?at(m(o),m(a),l,e.width,e.height):[]]}function bn(e,n,t){let r=mt(e);if(r.length===0)return;let i=n===null?-1:r.indexOf(n);switch(t){case"ArrowRight":case"ArrowDown":return r[Math.min(r.length-1,i+1)];case"ArrowLeft":case"ArrowUp":return r[Math.max(0,i<=0?0:i-1)];case"Home":return r[0];case"End":return r[r.length-1];case"Escape":return null;default:return}}var Te=2,Ae=(e,n,t)=>{let r=Math.max(Te,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Fr=(e,n)=>!e||e.start<=0&&e.end>=n;function xn(e,n,t){if(e.count<=Te||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,a=n>0?1.25:.8,l=Math.max(Te,Math.min(e.count,Math.round(o*a)));if(l===o)return n>0&&!Fr(e.zoom,e.count)?Ae(r,l,e.count):void 0;let c=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),d=r+c*o;return Ae(d-c*l,l,e.count)}function gn(e,n,t,r){let i=n.end-n.start,o=Math.max(Te,Math.min(e.count,Math.round(i/Math.max(.05,t)))),a=Math.max(0,Math.min(1,(r-e.plot.x)/Math.max(1,e.plot.width)));return Ae(n.start+a*i-a*o,o,e.count)}function yn(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return Ae(n.start-t/i,r,e.count)}function kn(e,n,t){let r=e.brush;if(!r||!Yt(r.box,n,t))return;let i=r.window;if(Math.abs(n-i.x)<=6)return{grab:"left",zoom:e.zoom};if(Math.abs(n-(i.x+i.width))<=6)return{grab:"right",zoom:e.zoom};if(n>i.x&&n<i.x+i.width)return{grab:"move",zoom:e.zoom};let o=e.zoom.end-e.zoom.start,a=(n-r.box.x)/Math.max(1,r.box.width)*e.count;return{grab:"move",zoom:Ae(a-o/2,o,e.count)}}function vn(e,n,t,r){let i=e.brush;if(!i)return t;let o=r/Math.max(1,i.box.width)*e.count;if(n==="move")return Ae(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-Te,Math.round(t.start+o))),end:t.end};let a=Math.min(e.count,Math.max(t.start+Te,Math.round(t.end+o)));return{start:t.start,end:a}}function wn(e,n){switch(n.type){case"svg":return Promise.resolve(Mn(e,n.label,n.resolve));case"csv":return Promise.resolve(Er(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=Mn(e,n.label,n.resolve);return jr(t,e.width,e.height,n.scale,n.background)}}}var fe=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),We=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${fe(String(t))}"`).join("");function Gr(e){let n=e.title?`<title>${fe(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${We([t,["d",e.d],["fill",e.fill??"none"],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-linecap",e.strokeLinecap],["stroke-linejoin",e.strokeLinejoin],["stroke-dasharray",e.dash],["opacity",e.opacity],["fill-opacity",e.fillOpacity]])}>${n}</path>`;case"rect":return`<rect${We([t,["x",e.x],["y",e.y],["width",e.width],["height",e.height],["rx",e.rx],["fill",e.fill],["stroke",e.stroke],["fill-opacity",e.opacity]])}>${n}</rect>`;case"line":return`<line${We([t,["x1",e.x1],["y1",e.y1],["x2",e.x2],["y2",e.y2],["stroke",e.stroke],["stroke-width",e.strokeWidth],["stroke-dasharray",e.dash],["opacity",e.opacity]])}>${n}</line>`;case"circle":return`<circle${We([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${We([t,["aria-label",e.title],["x",e.x],["y",e.y],["text-anchor",e.anchor],["dominant-baseline",e.baseline],["fill",e.fill],["font-weight",e.weight],["transform",e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0]])}>${fe(e.text)}</text>`}}function _r(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${fe(t.id)}" x1="0" y1="0" x2="${t.vertical===!1?1:0}" y2="${t.vertical===!1?0:1}">${t.stops.map(r=>`<stop offset="${r.offset}" stop-color="${fe(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function Mn(e,n,t){let r=_r(e)+e.shapes.map(Gr).join("");return t&&(r=r.replace(/var\((--[\w-]+)\)/g,(i,o)=>t(o).trim()||i)),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e.width} ${e.height}" width="${e.width}" height="${e.height}" role="img" aria-label="${fe(n)}" font-family="${fe(R.fontFamily)}" font-size="${fe(R.fontSize)}"><title>${fe(n)}</title>${r}</svg>`}function jr(e,n,t,r=2,i){return new Promise((o,a)=>{let l=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(l);let d=document.createElement("canvas");d.width=Math.round(n*r),d.height=Math.round(t*r);let u=d.getContext("2d");if(!u)return a(new Error("canvas 2d context unavailable"));i&&(u.fillStyle=i,u.fillRect(0,0,d.width,d.height)),u.drawImage(c,0,0,d.width,d.height),d.toBlob(h=>h?o(h):a(new Error("toBlob failed")),"image/png")},c.onerror=()=>{URL.revokeObjectURL(l),a(new Error("svg could not be decoded"))},c.src=l})}function Er(e){let n=t=>{let r=t==null?"":String(t);return/[",\n\r]/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return e.map(t=>t.map(n).join(",")).join(`\r
|
|
3
|
+
`)}function Sn(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let l=r.rows[0];if(r.rows.length>t)return;let c=["",...l.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],d=r.rows.map(u=>[u[0],...u.slice(1).map(h=>h.slice(h.lastIndexOf(": ")+2))]);return[c,...d]}let i=e.shapes.flatMap(l=>l.item&&!l.item.legend&&!(l.part==="anchor"&&!l.title)?[l.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(l=>i.some(c=>c[l]!==void 0)),a=(l,c)=>l[c]===void 0?"":String(l[c]);return[o.map(l=>l[0]?.toUpperCase()+l.slice(1)),...i.map(l=>o.map(c=>a(l,c)))]}var $n=new Map;function pt(e){let n=$n.get(e);if(n)return n.group;let t=new Set,r={},i={current:r,subscribe(o){return t.add(o),()=>{t.delete(o),t.size===0&&$n.delete(e)}},publish(o,a){Object.assign(r,o);for(let l of t)l(o,a)}};return $n.set(e,{group:i,listeners:t}),i}var Hr='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',Cn=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Hr}{animation:skdx-in var(--skdx-chart-duration,0ms) ease-out;transition:${["x","y","width","height","cx","cy","r","opacity","fill-opacity","d"].map(e=>`${e} var(--skdx-chart-duration,0ms) ease-out`).join(",")}}@media (prefers-reduced-motion:reduce){${Hr}{animation:none;transition:none}}`;function In(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function Tn(e){let n=[],r=e.data.filter(u=>{let h=$(u.value)&&u.value>=0;return h||n.push({code:"invalid-value",severity:"warning",message:`"${u.name}" has no valid non-negative value and was dropped.`,itemId:u.id??u.name}),h}).map((u,h)=>({d:u,i:h})).sort((u,h)=>h.d.value-u.d.value||u.i-h.i),i=r.reduce((u,{d:h})=>u+h.value,0),o=0,a=r.map(({d:u})=>i>0?(o+=u.value)/i:0),l=e.threshold,c=Lr({...e,categories:r.map(({d:u})=>u.name),series:[{name:e.name??"Value",type:"bar",data:r.map(({d:u})=>u.value),color:r[0]?.d.color},{name:e.cumulativeLabel??"Cumulative",type:"line",axis:"right",data:a,curve:"linear"}],rightAxis:{min:0,max:1,format:{style:"percent"}},references:l!==void 0&&$(l)?[{y:l,axis:"right",label:`${Math.round(l*100)}%`,variant:"primary"}]:void 0},"bar"),d=c.shapes.map(u=>{if(u.part!=="bar"||u.kind!=="rect"||!u.item||u.item.index===void 0)return u;let h=r[u.item.index]?.d;return h?{...u,fill:h.color??u.fill,item:{...u.item,id:h.id??h.name,name:h.name}}:u});return{...c,shapes:d,issues:[...n,...c.issues??[]]}}import{css as Ni,html as ge,LitElement as Fi,nothing as Y,svg as re}from"lit";import{property as A,state as oe}from"lit/decorators.js";import{ifDefined as H}from"lit/directives/if-defined.js";var Gi={fromAttribute:()=>!1},V=class extends Fi{constructor(){super(...arguments);this.legend=!1;this.tooltip=!0;this.selectionMode="none";this.loading=!1;this.decorative=!1;this.accessibleTable=!1;this.zoomable=!1;this.editable=!1;this.crossFilter=!1;this.animated=!1;this.responsive=!1;this.tip=[];this.overlay=[];this.portal=null;this.highlightState=null;this.crossState=null;this.lastCross=null;this.pointers=new Map;this.hover=null;this.token={};this.focused=null;this.hiddenState=[];this.drag=null;this.onPointerMove=t=>{let r=this.layout;if(!r)return;this.pointers.has(t.pointerId)&&this.pointers.set(t.pointerId,this.viewBox(t,r).x);let i=this.drag;if(i?.grab==="select"){let{x:o,y:a}=this.viewBox(t,r);this.overlay=[an(ft(i.x,i.y,o,a))];return}if(i?.grab==="lasso"){let{x:o,y:a}=this.viewBox(t,r);i.points=[...i.points??[],{x:o,y:a}],this.overlay=[ln(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=dn(r,i.gantt,o-i.x),this.overlay=[hn(r,i.gantt,i.change)];return}if(i?.grab==="map"){if(!r.map||!i.view)return;let{x:o,y:a}=this.viewBox(t,r);this.setView(mn(r.map,i.view,o-i.x,a-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[a,l]=[...this.pointers.values()];if(a===void 0||l===void 0||!i.distance)return;this.setZoom(gn(r.hit,i.zoom,Math.abs(a-l)/i.distance,(a+l)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?yn(r.hit,i.zoom,o-i.x):vn(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:a}=tn(r,t.target,t.currentTarget,t.clientX,t.clientY);this.tip=a,this.portal=o.length?{x:t.clientX,y:t.clientY,lines:o}:null}else{let o=nn(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(rn(r,t.target)),this.syncId&&r.hit?.crosshair){let o=Ee(r,this.viewBox(t,r).x);this.shareCrosshair(o?r.hit.rows[o.index]?.[0]??null:null)}};this.onPointerDown=t=>{let r=this.layout;if(!r||t.button!==0)return;let{x:i,y:o}=this.viewBox(t,r),a=xe(r,t.target)?.item.legend,l=this.canEdit(r)?cn(r,i,o):void 0;if(l){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:l},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.brushing()&&!a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:this.selectionMode==="lasso"?"lasso":"select",points:[{x:i,y:o}]},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}if(this.canPan(r)&&r.map){let d=r.map.plot;if(i<d.x||i>d.x+d.width||o<d.y||o>d.y+d.height)return;this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"map",view:r.map.view},t.currentTarget.setPointerCapture(t.pointerId),this.clearTip();return}let c=r.hit;if(!(!c||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[d,u]=[...this.pointers.values()];this.drag={x:(d+u)/2,y:o,zoom:c.zoom,grab:"pinch",distance:Math.abs(d-u)||1}}else{let d=kn(c,i,o);if(d)this.drag={x:i,y:o,zoom:d.zoom,grab:d.grab},d.zoom!==c.zoom&&this.setZoom(d.zoom);else if(this.zoomable&&i>=c.plot.x&&i<=c.plot.x+c.plot.width&&o>=c.plot.y&&o<=c.plot.y+c.plot.height)this.drag={x:i,y:o,zoom:c.zoom,grab:"pan"};else{this.pointers.delete(t.pointerId);return}}t.currentTarget.setPointerCapture(t.pointerId),this.clearTip()}};this.onPointerUp=t=>{this.pointers.delete(t.pointerId);let r=t.currentTarget;r.hasPointerCapture(t.pointerId)&&r.releasePointerCapture(t.pointerId);let i=this.drag,o=this.layout;if(o&&(i?.grab==="select"||i?.grab==="lasso"||i?.grab==="edit"||i?.grab==="map")){this.overlay=[];let{x:a,y:l}=this.viewBox(t,o);if(Math.abs(a-i.x)>2||Math.abs(l-i.y)>2){i.grab==="select"?this.setSelected(on(o,ft(i.x,i.y,a,l))):i.grab==="lasso"?this.setSelected(sn(o,i.points??[])):i.grab==="edit"&&i.change&&this.emit("skdx-task-change",i.change),this.drag={...i,distance:-1};return}this.drag=null;return}(this.pointers.size===0||this.drag?.grab==="pinch")&&(this.drag=null)};this.onWheel=t=>{let r=this.layout;if(!r)return;let{x:i,y:o}=this.viewBox(t,r);if(r.map&&this.canPan(r)){let c=r.map.plot;if(i<c.x||i>c.x+c.width||o<c.y||o>c.y+c.height)return;t.preventDefault(),this.setView(fn(r.map,t.deltaY,i,o));return}let a=r.hit;if(!a||!this.canZoom(r)||o<a.plot.y||o>a.plot.y+a.plot.height)return;let l=xn(a,t.deltaY,i);l&&(t.preventDefault(),this.setZoom(l))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=xe(this.layout,t.target);r&&(r.item.range?this.setZoom(r.item.range):r.item.legend&&r.item.series!==void 0?this.toggle(r.item.series):(this.select(r.item),this.emit("skdx-item-click",r.item)))};this.onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.focused=null,this.clearTip(),this.crossState=null,this.highlight(null);return}let r=this.layout;if(!r)return;if((t.key==="Enter"||t.key===" ")&&this.focused!==null){let l=r.shapes[this.focused]?.item;l&&(t.preventDefault(),this.select(l),this.emit("skdx-item-click",l));return}let i=this.canEdit(r)?un(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=bn(r,this.focused,t.key);if(o===void 0)return;t.preventDefault(),this.focused=o;let a=o===null?void 0:r.shapes[o]?.item;this.highlight(a?be(a):null)}}connectedCallback(){super.connectedCallback(),!(typeof ResizeObserver>"u")&&(this.observer=new ResizeObserver(([t])=>{let r=Math.floor(t?.contentRect.width??0);r>0&&(this.measured=r)}),this.observer.observe(this))}disconnectedCallback(){this.observer?.disconnect(),this.leave?.(),this.leave=void 0,this.joined=void 0,super.disconnectedCallback()}sized(){let{width:t,height:r,legend:i,tooltip:o,format:a,palette:l,loading:c,error:d,emptyMessage:u,description:h,decorative:b,animated:v,responsive:y,highlighted:p,highlightScope:k,accessibleTable:w}=this;return{...typeof y=="object"&&this.measured!==void 0&&this.measured<(y.breakpoint??480)?y.compact:void 0,width:y&&this.measured?this.measured:t,height:r,animate:v,responsive:y,legend:i,tooltip:o,format:a,palette:l,loading:c,error:d,emptyMessage:u,description:h,decorative:b,highlighted:p===void 0?this.highlightState:p,highlightScope:k,accessibleTable:w,hiddenSeries:this.hiddenSeries??this.hiddenState,zoom:this.zoom??this.zoomState,selected:this.selected??this.selectedState,view:this.view??this.viewState}}emit(t,r){this.dispatchEvent(new CustomEvent(t,{detail:r,bubbles:!0,composed:!0}))}publish(t){this.syncId&&pt(this.syncId).publish(t,this.token)}join(){if(this.joined===this.syncId||(this.leave?.(),this.leave=void 0,this.joined=this.syncId,!this.syncId))return;let t=pt(this.syncId),r=i=>{"highlighted"in i&&(this.highlightState=i.highlighted??null),i.selected&&(this.selectedState=i.selected,this.crossFilter&&(this.highlightState=i.selected.length?i.selected:null)),"zoom"in i&&(this.zoomState=i.zoom),i.hiddenSeries&&(this.hiddenState=i.hiddenSeries),"crosshair"in i&&(this.crossState=i.crosshair??null)};r(t.current),this.leave=t.subscribe((i,o)=>{o!==this.token&&r(i)})}setZoom(t){this.zoomState=t,this.emit("skdx-zoom-change",t),this.publish({zoom:t})}setView(t){this.viewState=t,this.emit("skdx-view-change",t)}setSelected(t){this.selectedState=t,this.emit("skdx-selected-change",t),this.publish({selected:t})}toggle(t){let r=this.hiddenSeries??this.hiddenState,i=r.includes(t)?r.filter(o=>o!==t):[...r,t];this.hiddenState=i,this.emit("skdx-hidden-series-change",i),this.publish({hiddenSeries:i})}highlight(t){let r=this.hover;r===t||r&&t&&Kt(r,t)||(this.hover=t,this.emit("skdx-highlighted-change",t),this.highlightState=t,this.syncId&&this.publish({highlighted:t}))}select(t){let r=this.selectionMode;r!=="none"&&this.setSelected(qt(this.selected??this.selectedState,t,r==="single"?"single":"multiple"))}shareCrosshair(t){!this.syncId||this.lastCross===t||(this.lastCross=t,this.publish({crosshair:t}))}clearTip(){this.tip=[],this.portal=null,this.shareCrosshair(null)}canZoom(t){return!!(t.hit&&(this.zoomable||t.hit.brush))}canPan(t){return!!(t.map&&this.zoomable)}canEdit(t){return!!(this.editable&&t.edit)}brushing(){return this.selectionMode==="brush"||this.selectionMode==="lasso"}viewBox(t,r){return Oe(t.currentTarget,t.clientX,t.clientY,r.width,r.height)}getSvgElement(){return this.renderRoot.querySelector("svg")}getLayout(){return this.layout}resetZoom(){this.setZoom(void 0)}zoomTo(t){this.setZoom(t)}focusItem(t){let r=this.layout;if(!r)return!1;let i=r.shapes.findIndex(o=>o.item&&!o.item.legend&&he(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?wn(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Xt(Gt(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let k of o.issues??[])this.emit("skdx-data-issue",k)}let a=this.canZoom(o),l=this.canPan(o),c=this.canEdit(o),d=this.brushing(),u=a||l||c||d,h=!o.decorative&&mt(o).length>0,b=In(o),v=Sn(o,this.accessibleTable),y=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,p=this.portal;return ge`<svg
|
|
3
4
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
5
|
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
6
|
width=${o.width}
|
|
@@ -7,55 +8,55 @@ var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t
|
|
|
7
8
|
role=${o.decorative?"presentation":"img"}
|
|
8
9
|
aria-hidden=${o.decorative?"true":Y}
|
|
9
10
|
aria-label=${o.decorative?Y:i}
|
|
10
|
-
aria-
|
|
11
|
+
aria-description=${H(o.description)}
|
|
11
12
|
tabindex=${h?0:Y}
|
|
12
13
|
data-skdx-chart=${r}
|
|
13
|
-
data-zoomable=${
|
|
14
|
-
data-brushing=${d&&!(
|
|
14
|
+
data-zoomable=${a||l?"":Y}
|
|
15
|
+
data-brushing=${d&&!(a||l)?"":Y}
|
|
15
16
|
data-editable=${c?"":Y}
|
|
16
|
-
style=${
|
|
17
|
-
font-family=${
|
|
18
|
-
font-size=${
|
|
17
|
+
style=${b?`--skdx-chart-duration:${b}`:Y}
|
|
18
|
+
font-family=${R.fontFamily}
|
|
19
|
+
font-size=${R.fontSize}
|
|
19
20
|
@pointermove=${o.tooltip||u?this.onPointerMove:Y}
|
|
20
21
|
@pointerleave=${()=>{this.clearTip(),this.highlight(null)}}
|
|
21
22
|
@pointerdown=${u?this.onPointerDown:Y}
|
|
22
23
|
@pointerup=${u?this.onPointerUp:Y}
|
|
23
24
|
@pointercancel=${u?this.onPointerUp:Y}
|
|
24
|
-
@wheel=${
|
|
25
|
-
@dblclick=${
|
|
25
|
+
@wheel=${a||l?this.onWheel:Y}
|
|
26
|
+
@dblclick=${a||l?()=>l?this.setView(void 0):this.setZoom(void 0):Y}
|
|
26
27
|
@click=${this.onClick}
|
|
27
28
|
@keydown=${h?this.onKeyDown:Y}
|
|
28
29
|
@blur=${()=>{this.focused=null,this.highlight(null)}}
|
|
29
30
|
>
|
|
30
31
|
<title>${i}</title>
|
|
31
|
-
${o.description?
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
32
|
+
${o.description?re`<desc>${o.description}</desc>`:Y}
|
|
33
|
+
${b?re`<style>${Cn}</style>`:Y} ${_i(o)}
|
|
34
|
+
${bt(o.shapes)}
|
|
35
|
+
${bt(this.tip.length||!this.crossState?this.tip:en(o,this.crossState))}
|
|
36
|
+
${bt(pn(o,this.focused))} ${bt(this.overlay)}
|
|
36
37
|
</svg>
|
|
37
|
-
${
|
|
38
|
+
${p?ge`<div
|
|
38
39
|
role="tooltip"
|
|
39
40
|
data-skdx-tooltip=${r}
|
|
40
|
-
style="left:${
|
|
41
|
+
style="left:${p.x+12}px;top:${p.y+12}px"
|
|
41
42
|
>
|
|
42
|
-
${
|
|
43
|
+
${p.lines.map(k=>ge`<div>${k}</div>`)}
|
|
43
44
|
</div>`:Y}
|
|
44
|
-
${
|
|
45
|
+
${v?ge`<table data-skdx-table=${r}>
|
|
45
46
|
<caption>
|
|
46
|
-
${
|
|
47
|
+
${y}
|
|
47
48
|
</caption>
|
|
48
49
|
<thead>
|
|
49
50
|
<tr>
|
|
50
|
-
${(
|
|
51
|
+
${(v[0]??[]).map(k=>ge`<th scope="col">${k}</th>`)}
|
|
51
52
|
</tr>
|
|
52
53
|
</thead>
|
|
53
54
|
<tbody>
|
|
54
|
-
${
|
|
55
|
-
${
|
|
55
|
+
${v.slice(1).map(k=>ge`<tr>
|
|
56
|
+
${k.map((w,f)=>f===0?ge`<th scope="row">${w}</th>`:ge`<td>${w}</td>`)}
|
|
56
57
|
</tr>`)}
|
|
57
58
|
</tbody>
|
|
58
|
-
</table>`:Y}`}};
|
|
59
|
+
</table>`:Y}`}};V.styles=Ni`
|
|
59
60
|
:host {
|
|
60
61
|
display: inline-block;
|
|
61
62
|
}
|
|
@@ -63,7 +64,6 @@ var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t
|
|
|
63
64
|
display: block;
|
|
64
65
|
max-width: 100%;
|
|
65
66
|
height: auto;
|
|
66
|
-
outline: none;
|
|
67
67
|
}
|
|
68
68
|
svg[data-zoomable] {
|
|
69
69
|
cursor: grab;
|
|
@@ -78,6 +78,9 @@ var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t
|
|
|
78
78
|
}
|
|
79
79
|
:host([responsive]) {
|
|
80
80
|
display: block;
|
|
81
|
+
/* Keep centered flex/grid hosts independent of the previous SVG's intrinsic width. */
|
|
82
|
+
width: 100%;
|
|
83
|
+
min-width: 0;
|
|
81
84
|
}
|
|
82
85
|
table {
|
|
83
86
|
position: absolute;
|
|
@@ -97,7 +100,7 @@ var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t
|
|
|
97
100
|
background: var(--skdx-color-surface-raised);
|
|
98
101
|
color: var(--skdx-color-text-default);
|
|
99
102
|
border: 1px solid var(--skdx-color-border-strong);
|
|
100
|
-
border-radius:
|
|
103
|
+
border-radius: var(--skdx-radius-default, var(--skdx-radius-md, 0.5rem));
|
|
101
104
|
padding: 4px 8px;
|
|
102
105
|
font-family: var(--skdx-font-family);
|
|
103
106
|
font-size: var(--skdx-font-size-xs);
|
|
@@ -106,4 +109,4 @@ var Kr=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var g=(e,n,t
|
|
|
106
109
|
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
110
|
font-weight: bold;
|
|
108
111
|
}
|
|
109
|
-
`,
|
|
112
|
+
`,x([A({type:Number})],V.prototype,"width",2),x([A({type:Number})],V.prototype,"height",2),x([A()],V.prototype,"label",2),x([A({type:Boolean,reflect:!0})],V.prototype,"legend",2),x([A({type:Boolean,attribute:"no-tooltip",converter:Gi})],V.prototype,"tooltip",2),x([A({attribute:!1})],V.prototype,"format",2),x([A({attribute:!1})],V.prototype,"palette",2),x([A({attribute:!1})],V.prototype,"hiddenSeries",2),x([A({attribute:!1})],V.prototype,"selected",2),x([A({attribute:"selection-mode"})],V.prototype,"selectionMode",2),x([A({attribute:!1})],V.prototype,"highlighted",2),x([A({attribute:!1})],V.prototype,"highlightScope",2),x([A({type:Boolean,reflect:!0})],V.prototype,"loading",2),x([A()],V.prototype,"error",2),x([A({attribute:"empty-message"})],V.prototype,"emptyMessage",2),x([A()],V.prototype,"description",2),x([A({type:Boolean,reflect:!0})],V.prototype,"decorative",2),x([A({type:Boolean,attribute:"accessible-table"})],V.prototype,"accessibleTable",2),x([A({attribute:!1})],V.prototype,"zoom",2),x([A({attribute:!1})],V.prototype,"view",2),x([A({type:Boolean,reflect:!0})],V.prototype,"zoomable",2),x([A({type:Boolean,reflect:!0})],V.prototype,"editable",2),x([A({attribute:"sync-id"})],V.prototype,"syncId",2),x([A({type:Boolean,attribute:"cross-filter"})],V.prototype,"crossFilter",2),x([A({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],V.prototype,"animated",2),x([A({type:Boolean,reflect:!0})],V.prototype,"responsive",2),x([oe()],V.prototype,"tip",2),x([oe()],V.prototype,"overlay",2),x([oe()],V.prototype,"portal",2),x([oe()],V.prototype,"measured",2),x([oe()],V.prototype,"viewState",2),x([oe()],V.prototype,"highlightState",2),x([oe()],V.prototype,"crossState",2),x([oe()],V.prototype,"focused",2),x([oe()],V.prototype,"hiddenState",2),x([oe()],V.prototype,"zoomState",2),x([oe()],V.prototype,"selectedState",2);var Z=class extends V{constructor(){super(...arguments);this.series=[];this.labels=!1;this.connectNulls=!1;this.stacked=!1;this.brush=!1;this.crosshair=!1}input(){let{series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:c,labels:d,curve:u,connectNulls:h,nulls:b,stacked:v,stackOffset:y,orientation:p,radius:k,barGap:w,barWidth:f,sort:M,transform:I,transforms:S,bins:O,binWidth:F,binDomain:j,binMode:B,sampling:X,brush:J,crosshair:ae}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:a,references:l,annotations:c,labels:d,curve:u,connectNulls:h,nulls:b,stacked:v,stackOffset:y,orientation:p,radius:k,barGap:w,barWidth:f,sort:M,transform:I,transforms:S,bins:O,binWidth:F,binDomain:j,binMode:B,sampling:X,brush:J,crosshair:ae}}};x([A({attribute:!1})],Z.prototype,"series",2),x([A({attribute:!1})],Z.prototype,"categories",2),x([A({attribute:!1})],Z.prototype,"xAxis",2),x([A({attribute:!1})],Z.prototype,"yAxis",2),x([A({attribute:!1})],Z.prototype,"rightAxis",2),x([A({attribute:!1})],Z.prototype,"references",2),x([A({attribute:!1})],Z.prototype,"annotations",2),x([A({type:Boolean,reflect:!0})],Z.prototype,"labels",2),x([A()],Z.prototype,"curve",2),x([A({type:Boolean,attribute:"connect-nulls"})],Z.prototype,"connectNulls",2),x([A()],Z.prototype,"nulls",2),x([A({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],Z.prototype,"stacked",2),x([A({attribute:"stack-offset"})],Z.prototype,"stackOffset",2),x([A()],Z.prototype,"orientation",2),x([A({type:Number})],Z.prototype,"radius",2),x([A({type:Number,attribute:"bar-gap"})],Z.prototype,"barGap",2),x([A({type:Number,attribute:"bar-width"})],Z.prototype,"barWidth",2),x([A()],Z.prototype,"sort",2),x([A()],Z.prototype,"transform",2),x([A({attribute:!1})],Z.prototype,"transforms",2),x([A({type:Number})],Z.prototype,"bins",2),x([A({type:Number,attribute:"bin-width"})],Z.prototype,"binWidth",2),x([A({attribute:!1})],Z.prototype,"binDomain",2),x([A({attribute:"bin-mode"})],Z.prototype,"binMode",2),x([A({attribute:!1})],Z.prototype,"sampling",2),x([A({type:Boolean,reflect:!0})],Z.prototype,"brush",2),x([A({type:Boolean,reflect:!0})],Z.prototype,"crosshair",2);var _i=e=>e.defs&&e.defs.length?re`<defs>${e.defs.map(n=>re`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>re`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${H(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:Y,bt=e=>re`${e.map((n,t)=>{let r=n.title?re`<title>${n.title}</title>`:Y,i=n.item?t:void 0;switch(n.kind){case"path":return re`<path data-skdx-part=${n.part} data-skdx-i=${H(i)} d=${n.d} fill=${n.fill??"none"} stroke=${H(n.stroke)} stroke-width=${H(n.strokeWidth)} stroke-linecap=${H(n.strokeLinecap)} stroke-linejoin=${H(n.strokeLinejoin)} stroke-dasharray=${H(n.dash)} opacity=${H(n.opacity)} fill-opacity=${H(n.fillOpacity)}>${r}</path>`;case"rect":return re`<rect data-skdx-part=${n.part} data-skdx-i=${H(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${H(n.rx)} style=${H(ut(n.part)?`rx:${ut(n.part)}`:void 0)} fill=${n.fill} stroke=${H(n.stroke)} fill-opacity=${H(n.opacity)} pointer-events=${H(n.part==="stage-label-background"||n.part==="label-background"?"none":void 0)}>${r}</rect>`;case"line":return re`<line data-skdx-part=${n.part} data-skdx-i=${H(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${H(n.strokeWidth)} stroke-dasharray=${H(n.dash)} opacity=${H(n.opacity)}>${r}</line>`;case"circle":return re`<circle data-skdx-part=${n.part} data-skdx-i=${H(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${H(n.stroke)} opacity=${H(n.opacity)}>${r}</circle>`;case"text":return re`<text aria-label=${H(n.title)} data-skdx-part=${n.part} data-skdx-i=${H(i)} x=${n.x} y=${n.y} text-anchor=${H(n.anchor)} dominant-baseline=${H(n.baseline)} fill=${H(n.fill)} font-weight=${H(n.weight)} pointer-events=${H(i===void 0?"none":void 0)} transform=${H(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var ee=class extends V{constructor(){super(...arguments);this.data=[];this.labels=!1;this.brush=!1;this.crosshair=!1}render(){let{data:t,threshold:r,cumulativeLabel:i,name:o,labels:a,radius:l,barGap:c,barWidth:d,xAxis:u,yAxis:h,brush:b,crosshair:v}=this;return this.root(Tn({...this.sized(),data:t,threshold:r,cumulativeLabel:i,name:o,labels:a,radius:l,barGap:c,barWidth:d,xAxis:u,yAxis:h,brush:b,crosshair:v}),"pareto",this.label??"Pareto chart")}};x([ie({attribute:!1})],ee.prototype,"data",2),x([ie({type:Number})],ee.prototype,"threshold",2),x([ie({attribute:"cumulative-label"})],ee.prototype,"cumulativeLabel",2),x([ie()],ee.prototype,"name",2),x([ie({type:Boolean,reflect:!0})],ee.prototype,"labels",2),x([ie({type:Number})],ee.prototype,"radius",2),x([ie({type:Number,attribute:"bar-gap"})],ee.prototype,"barGap",2),x([ie({type:Number,attribute:"bar-width"})],ee.prototype,"barWidth",2),x([ie({attribute:!1})],ee.prototype,"xAxis",2),x([ie({attribute:!1})],ee.prototype,"yAxis",2),x([ie({type:Boolean,reflect:!0})],ee.prototype,"brush",2),x([ie({type:Boolean,reflect:!0})],ee.prototype,"crosshair",2),ee=x([ji("skdx-pareto-chart")],ee);export{ee as SkdxParetoChart};
|