@skdx/web-components-charts 0.38.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 +40 -37
- 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 +38 -35
- package/dist/candlestick.d.cts +1 -1
- package/dist/candlestick.d.ts +1 -1
- package/dist/candlestick.js +40 -37
- package/dist/chord.cjs +40 -37
- package/dist/chord.d.cts +1 -1
- package/dist/chord.d.ts +1 -1
- package/dist/chord.js +38 -35
- package/dist/circle-packing.cjs +31 -28
- package/dist/circle-packing.d.cts +1 -1
- package/dist/circle-packing.d.ts +1 -1
- package/dist/circle-packing.js +30 -27
- 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 +37 -34
- 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 +35 -32
- package/dist/gauge.d.cts +1 -1
- package/dist/gauge.d.ts +1 -1
- package/dist/gauge.js +39 -36
- package/dist/heatmap.cjs +38 -35
- package/dist/heatmap.d.cts +1 -1
- package/dist/heatmap.d.ts +1 -1
- package/dist/heatmap.js +30 -27
- package/dist/histogram.cjs +40 -37
- package/dist/histogram.d.cts +1 -1
- package/dist/histogram.d.ts +1 -1
- package/dist/histogram.js +30 -27
- package/dist/icicle.cjs +40 -37
- package/dist/icicle.d.cts +1 -1
- package/dist/icicle.d.ts +1 -1
- package/dist/icicle.js +40 -37
- 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 +40 -37
- 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 +32 -29
- package/dist/marimekko.d.cts +1 -1
- package/dist/marimekko.d.ts +1 -1
- package/dist/marimekko.js +33 -30
- 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 +40 -37
- package/dist/pareto.d.cts +1 -1
- package/dist/pareto.d.ts +1 -1
- package/dist/pareto.js +26 -23
- 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 +40 -37
- package/dist/range.d.cts +1 -1
- package/dist/range.d.ts +1 -1
- package/dist/range.js +30 -27
- package/dist/sankey.cjs +29 -26
- package/dist/sankey.d.cts +1 -1
- package/dist/sankey.d.ts +1 -1
- package/dist/sankey.js +40 -37
- package/dist/scatter.cjs +38 -35
- package/dist/scatter.d.cts +1 -1
- package/dist/scatter.d.ts +1 -1
- package/dist/scatter.js +31 -28
- 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 +24 -21
- package/dist/tree.d.cts +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +38 -35
- 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 +21 -18
- package/dist/waffle.d.cts +1 -1
- package/dist/waffle.d.ts +1 -1
- package/dist/waffle.js +37 -34
- package/dist/waterfall.cjs +33 -30
- 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/waffle.js
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
|
-
var zt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var l=(e,n,t,r)=>{for(var i=r>1?void 0:r?Ot(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&&zt(n,t,i),i};import{customElement as Xt,property as F}from"lit/decorators.js";var at=e=>Number(e.toPrecision(12)),At,Lt=e=>(At??(At=new Intl.NumberFormat)).format(at(e)),Bt=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 ct(e){if(e===void 0)return Lt;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=d=>i?h=>d(h)+i:d,a=d=>r===void 0?d===void 0?{}:{maximumFractionDigits:d}:{minimumFractionDigits:r,maximumFractionDigits:r},c=d=>{let h=new Intl.NumberFormat(t,d);return s(g=>h.format(at(g)))},u=d=>{let h=new Intl.DateTimeFormat(t,o?{...d,timeZone:o}:d);return g=>h.format(g)};switch(n){case"integer":return c({maximumFractionDigits:0});case"decimal":return c(a(2));case"percent":return c({style:"percent",...a(0)});case"currency":return c({style:"currency",currency:e.currency??"USD",...a()});case"compact":return c({notation:"compact",...a(1)});case"scientific":return c({notation:"scientific",...a(2)});case"date":return u({dateStyle:"medium"});case"time":return u({timeStyle:"short"});case"datetime":return u({dateStyle:"medium",timeStyle:"short"});case"duration":return s(Bt)}}var y=e=>Number(e.toFixed(2)),oe=e=>typeof e=="number"&&Number.isFinite(e);var U=1e3,K=60*U,Y=60*K,ie=24*Y,en=[U,5*U,15*U,30*U,K,5*K,15*K,30*K,Y,3*Y,6*Y,12*Y,ie,2*ie,7*ie,14*ie];var Pt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Rt=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Nt={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Dt(e,n,t){return e.replace(Rt,(r,i,o)=>{let s=Nt[i];if(s===void 0)return i+o;let c=(o.match(Pt)??[]).map((u,d)=>{let h=Number(u);if(s===-1)return String(h+n);if(s===-2)return String(h+t);let g=d%s;return s===7?g===5?String(h+n):g===6?String(h+t):u:String(g%2===0?h+n:h+t)});return i+c.join(" ")})}var lt=(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:Dt(r.d,n,t)}}});var ye=["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)"};var ut=(e,n)=>n??ye[e%ye.length];function j(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function dt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var se=20,Gt=120,ht=e=>{let n=j(e);return n&&(n.position==="left"||n.position==="right")?n.width??Gt:0},we=(e,n=600,t=300)=>({width:(e.width??n)-ht(e),height:(e.height??t)-(j(e)?.position==="bottom"?se:0)}),pt=e=>{let n=j(e);return n&&(n.position===void 0||n.position==="top")?se:0},q=6.5,Me=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:ut(n)),$e=(e,n)=>e.hiddenSeries?.includes(n)??!1;function ve(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],c=r.maxItems,u=c!==void 0&&c>=0&&e.length>c?e.slice(0,c):e,d=e.length-u.length,h=r.interactive??!0,g=o,$=i,C=(M,w,I,O)=>{let P=(w?18:4)+M.length*q;g>o&&(s||g+P>n-8)&&(g=o,$+=se),w&&a.push({kind:"rect",part:"legend-swatch",x:g,y:$-5,width:10,height:10,fill:w,opacity:O?.3:void 0,item:I}),a.push({kind:"text",part:"legend-label",x:g+(w?14:0),y:$,text:M,baseline:"middle",fill:O?v.grid:v.label,item:I}),g+=P+12};for(let M of u){let w=t.includes(M.name),I=h?{label:M.name,series:M.name,legend:!0}:void 0;C(r.formatter?.(M.name)??M.name,M.color,I,w)}return d>0&&C(`+${d} more`,void 0,void 0,!1),r.align==="end"?Ft(a,n):a}function Ft(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(a=>a.kind==="rect"?a.x+a.width:a.x+a.text.length*q)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var jt=(e,n,t={})=>new Set(ve(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Ce(e,n,t,r=[]){let i=j(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=dt(e),a=o?.position==="bottom",c=ht(e),u=e.hiddenSeries??[],d=o?c?ve(r,1/0,u,o,10,(o.position==="right"?n:0)+8,!0):ve(r,n,u,o,a?t+10:10):[],h=a?jt(r,n,o):0;return{width:n+c,height:a?t+Math.max(1,h)*se: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:d}}function Se(e){let n=e.legendOffset;if(!n)return e;let t=[...lt(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,a=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:s,map:a,legendOffset:void 0}}function ae(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(g=>g.length))*q+12,c=6+s.length*16,u=o==="top"?{x:e-a/2,y:n-c-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-c/2}:o==="right"?{x:e+8,y:n-c/2}:{x:e+12,y:n-c-6},d=Math.max(0,Math.min(r-a,u.x)),h=Math.max(0,Math.min(i-c,u.y));return[{kind:"rect",part:"tooltip",x:y(d),y:y(h),width:y(a),height:c,fill:"var(--skdx-color-surface-raised)",stroke:v.axis,rx:3},...s.map((g,$)=>({kind:"text",part:"tooltip-label",x:y(d+6),y:y(h+11+$*16),text:g,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&$===0?"bold":void 0}))]}function ft(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}=we(e,t,r),a=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:y(o/2),y:y(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":v.label}),{...Ce(e,o,s),shapes:c,tooltip:!1}}function ce(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Ie=e=>e.id??e.name??e.series,mt=e=>e.seriesId??e.series;function L(e,n){let t=!1;return n.id!==void 0&&(t=!0,Ie(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,mt(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 N(e){let n={},t=Ie(e);t!==void 0&&(n.id=t);let r=mt(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var ke=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Te(e,n,t){let r=ce(e),i=N(n),o=r.some(s=>L(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!L(n,s)):[...r,i]}var Ht=.2;function Zt(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 Vt=(e,n)=>e.kind==="text"?{...e,fill:v.grid}:{...e,opacity:(e.opacity??1)*n};function ze(e,n){let t=ce(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:ce(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=[],a=d=>!i||r.some(h=>L(d,h))?!0:o.highlighted==="series"?r.some(h=>h.series!==void 0&&L(d,{series:h.series})):!1,c=d=>{if(!i||o.faded==="none"||a(d))return!1;if(o.faded==="series"){let h=i.series;return h!==void 0&&L(d,{series:h})}return!0},u=e.shapes.map(d=>{let h=d.item;if(!h||h.legend)return d;if(t.some(g=>L(h,g))){let g=Zt(d);g&&s.push(g)}return c(h)?Vt(d,Ht):d});return s.length?{...e,shapes:[...u,...s]}:{...e,shapes:u}}function V(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 Oe=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function gt(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 X(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=gt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Ae(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[gt(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 Le(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Oe(r.plot,n,t))return[];let i=Ae(e,n),{rows:o}=X(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...ae(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Be(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 Le(e,i,t.plot.y+8)}function Pe(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:c,y:u}=V(t,r,i,e.width,e.height);if(Oe(e.hit.plot,c,u)){let d=X(e,c),h=Ae(e,c);if(d&&h)return{lines:d.rows,shapes:[h]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?D(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(c=>c.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function bt(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),c=s&&s.tooltipFormatter?D(s,e)?.item:void 0,u=c&&s?.tooltipFormatter?.(c)||a&&Array.from(a.children).find(C=>C.tagName.toLowerCase()==="title")?.textContent;if(!u)return[];let d=s?.tooltipAnchored?D(s,e):void 0,h=d?s?.shapes[d.index]:void 0,{x:g,y:$}=h?Q(h):V(n,t,r,i,o);return ae(g,$,u,i,o,s?.tooltipPlacement)}function Re(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=V(t,r,i,e.width,e.height),a=Le(e,o,s);if(a.length>0)return a}return bt(n,t,r,i,e.width,e.height,e)}function Ne(e,n){let t=D(e,n);return t&&!t.item.legend?N(t.item):null}var _t=(e,n)=>{let{x:t,y:r}=Q(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 De(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!_t(i,n))continue;let o=N(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var Ge=e=>({kind:"rect",part:"selection-box",x:y(e.x),y:y(e.y),width:y(e.width),height:y(e.height),fill:v.focus,opacity:.12,stroke:v.focus}),ue=(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 xt(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let s=e[i],a=e[o];s.y>t!=a.y>t&&n<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function Fe(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}=Q(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!xt(n,o,a))continue;let c=N(i.item),u=JSON.stringify(c);t.has(u)||(t.add(u),r.push(c))}return r}var je=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${y(n.x)} ${y(n.y)}`).join("L")}`:"",fill:v.focus,fillOpacity:.12,stroke:v.focus,dash:"4 3"}),le=6;function He(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-le||n>i.x1+le))return Math.abs(n-i.x0)<=le?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=le?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ze(e,n,t){let r=e.edit;return yt(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function Ve(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",a=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return yt(r,{bar:o,mode:s},i*a)}function yt(e,{bar:n,mode:t},r){let i=a=>e.snap?Math.round(a/e.snap)*e.snap:a,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 _e(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:y(Math.min(i,o)),y:y(n.bar.y),width:y(Math.max(1,Math.abs(o-i))),height:y(n.bar.height),fill:v.focus,opacity:.25,stroke:v.focus,rx:2}}var Et=64,Wt=e=>Math.max(1,Math.min(Et,e));function Ee(e,n,t,r){let i=n>0?.8:1.25,o=Wt(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[c,u]=e.view.center,d=(t-(s.x+s.width/2))/a,h=(r-(s.y+s.height/2))/a,g=e.view.zoom/o;return{center:[c+d*(1-g),e.fromY(e.toY(u)-h*(1-g))],zoom:o}}function We(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 D(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 de=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function Q(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 Ue(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*q+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}=Q(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?ae(y(o),y(s),a,e.width,e.height):[]]}function Ke(e,n,t){let r=de(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 H=2,Z=(e,n,t)=>{let r=Math.max(H,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},vt=(e,n)=>!e||e.start<=0&&e.end>=n;function Ye(e,n,t){if(e.count<=H||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(H,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!vt(e.zoom,e.count)?Z(r,a,e.count):void 0;let c=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),u=r+c*o;return Z(u-c*a,a,e.count)}function qe(e,n,t,r){let i=n.end-n.start,o=Math.max(H,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 Z(n.start+s*i-s*o,o,e.count)}function Xe(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return Z(n.start-t/i,r,e.count)}function Qe(e,n,t){let r=e.brush;if(!r||!Oe(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:Z(s-o/2,o,e.count)}}function Je(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 Z(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-H,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+H,Math.round(t.end+o)));return{start:t.start,end:s}}function tt(e,n){switch(n.type){case"svg":return Promise.resolve(et(e,n.label,n.resolve));case"csv":return Promise.resolve(Ct(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=et(e,n.label,n.resolve);return $t(t,e.width,e.height,n.scale,n.background)}}}var B=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),J=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${B(String(t))}"`).join("");function wt(e){let n=e.title?`<title>${B(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${J([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${J([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${J([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${J([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${J([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]])}>${B(e.text)}</text>`}}function Mt(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${B(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="${B(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function et(e,n,t){let r=Mt(e)+e.shapes.map(wt).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="${B(n)}" font-family="${B(v.fontFamily)}" font-size="${B(v.fontSize)}"><title>${B(n)}</title>${r}</svg>`}function $t(e,n,t,r=2,i){return new Promise((o,s)=>{let a=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(a);let u=document.createElement("canvas");u.width=Math.round(n*r),u.height=Math.round(t*r);let d=u.getContext("2d");if(!d)return s(new Error("canvas 2d context unavailable"));i&&(d.fillStyle=i,d.fillRect(0,0,u.width,u.height)),d.drawImage(c,0,0,u.width,u.height),u.toBlob(h=>h?o(h):s(new Error("toBlob failed")),"image/png")},c.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},c.src=a})}function Ct(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 nt(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let a=r.rows[0];if(r.rows.length>t)return;let c=["",...a.slice(1).map(d=>d.replace(/:\s[^:]*$/,""))],u=r.rows.map(d=>[d[0],...d.slice(1).map(h=>h.slice(h.lastIndexOf(": ")+2))]);return[c,...u]}let i=e.shapes.flatMap(a=>a.item&&!a.item.legend&&!(a.part==="anchor"&&!a.title)?[a.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(a=>i.some(c=>c[a]!==void 0)),s=(a,c)=>a[c]===void 0?"":String(a[c]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(c=>s(a,c)))]}var rt=new Map;function he(e){let n=rt.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&&rt.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return rt.set(e,{group:i,listeners:t}),i}var St='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',it=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${St}{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){${St}{animation:none;transition:none}}`;function ot(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}var It=8;function kt(e){let n=e.map(i=>Math.floor(i)),t=Math.round(e.reduce((i,o)=>i+o,0))-n.reduce((i,o)=>i+o,0),r=e.map((i,o)=>({i:o,frac:i-Math.floor(i)})).sort((i,o)=>o.frac-i.frac||i.i-o.i);for(let{i}of r){if(t<=0)break;n[i]++,t--}return n}function st(e){let n=[],t=e.data.map(m=>{let k=oe(m.value)&&m.value>=0;return k||n.push({code:oe(m.value)?"negative-value":"invalid-value",severity:"warning",message:`"${m.name}" has no valid non-negative value and is drawn as zero.`,itemId:m.id??m.name}),{...m,value:k?m.value:0}}),r=t.reduce((m,k)=>m+($e(e,k.name)?0:k.value),0),i=ft(e,r<=0,300,300);if(i)return{...i,issues:n};let o=ct(e.format),s=oe(e.total)&&e.total>0?e.total:r,a=Math.max(1,Math.round(e.rows??10)),c=Math.max(1,Math.round(e.columns??10)),u=a*c,d=m=>s>0?m/s:0,h=kt(t.map(m=>$e(e,m.name)?0:Math.min(1,d(m.value))*u)),{width:g,height:$}=we(e,300,300),C=pt(e),M=Math.max(0,e.cellGap??2),w=Math.max(1,Math.min((g-2*It)/c,($-C-2*It)/a)),I=(g-w*c)/2,O=C+($-C-w*a)/2,P=e.orientation==="horizontal",fe=m=>P?{x:I+m%c*w,y:O+Math.floor(m/c)*w}:{x:I+Math.floor(m/a)*w,y:O+(a-1-m%a)*w},ee=(m,k,be,ne,xe)=>{let{x:re,y:Tt}=fe(m);return{kind:"rect",part:"cell",x:y(re+M/2),y:y(Tt+M/2),width:y(Math.max(.5,w-M)),height:y(Math.max(.5,w-M)),fill:k,opacity:xe,rx:e.cellRadius??2,title:be,item:ne}},_=[],R=0;t.forEach((m,k)=>{let be=h[k],ne=`${m.name}: ${o(m.value)} (${Math.round(d(m.value)*100)}%)`,xe={label:ne,id:m.id??m.name,name:m.name,index:k,value:m.value};for(let re=0;re<be&&R<u;re++,R++)_.push(ee(R,Me(e,k,m.color),ne,xe))});let E=s-r,me=E>0?`Other: ${o(E)} (${Math.round(d(E)*100)}%)`:"Empty";for(;R<u;R++)_.push(ee(R,v.grid,me,void 0,.6));let ge=new Map(t.map(m=>[m.name,`${Math.round(d(m.value)*100)}%`])),W=j(e),te=Ce(e.labels&&W?{...e,legend:{...W,formatter:m=>`${W.formatter?.(m)??m} ${ge.get(m)??""}`}}:e,g,$,e.data.map((m,k)=>({name:m.name,color:Me(e,k,m.color)})));return{...te,shapes:[..._,...te.shapes],issues:n}}import{css as Ut,html as G,LitElement as Kt,nothing as S,svg as T}from"lit";import{property as p,state as A}from"lit/decorators.js";import{ifDefined as x}from"lit/directives/if-defined.js";var Yt={fromAttribute:()=>!1},f=class extends Kt{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=[Ge(ue(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=[je(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ze(r,i.gantt,o-i.x),this.overlay=[_e(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(We(r.map,i.view,o-i.x,s-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[s,a]=[...this.pointers.values()];if(s===void 0||a===void 0||!i.distance)return;this.setZoom(qe(r.hit,i.zoom,Math.abs(s-a)/i.distance,(s+a)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?Xe(r.hit,i.zoom,o-i.x):Je(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Pe(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=Re(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(Ne(r,t.target)),this.syncId&&r.hit?.crosshair){let o=X(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=D(r,t.target)?.item.legend,a=this.canEdit(r)?He(r,i,o):void 0;if(a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:a},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 u=r.map.plot;if(i<u.x||i>u.x+u.width||o<u.y||o>u.y+u.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[u,d]=[...this.pointers.values()];this.drag={x:(u+d)/2,y:o,zoom:c.zoom,grab:"pinch",distance:Math.abs(u-d)||1}}else{let u=Qe(c,i,o);if(u)this.drag={x:i,y:o,zoom:u.zoom,grab:u.grab},u.zoom!==c.zoom&&this.setZoom(u.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:a}=this.viewBox(t,o);if(Math.abs(s-i.x)>2||Math.abs(a-i.y)>2){i.grab==="select"?this.setSelected(De(o,ue(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Fe(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(Ee(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 a=Ye(s,t.deltaY,i);a&&(t.preventDefault(),this.setZoom(a))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=D(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 a=r.shapes[this.focused]?.item;a&&(t.preventDefault(),this.select(a),this.emit("skdx-item-click",a));return}let i=this.canEdit(r)?Ve(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Ke(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?N(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:a,loading:c,error:u,emptyMessage:d,description:h,decorative:g,animated:$,responsive:C,highlighted:M,highlightScope:w,accessibleTable:I}=this;return{...typeof C=="object"&&this.measured!==void 0&&this.measured<(C.breakpoint??480)?C.compact:void 0,width:C&&this.measured?this.measured:t,height:r,animate:$,responsive:C,legend:i,tooltip:o,format:s,palette:a,loading:c,error:u,emptyMessage:d,description:h,decorative:g,highlighted:M===void 0?this.highlightState:M,highlightScope:w,accessibleTable:I,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&&he(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=he(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&&ke(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(Te(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 V(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&&L(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?tt(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=ze(Se(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let I of o.issues??[])this.emit("skdx-data-issue",I)}let s=this.canZoom(o),a=this.canPan(o),c=this.canEdit(o),u=this.brushing(),d=s||a||c||u,h=!o.decorative&&de(o).length>0,g=o.description?`${r}-desc`:void 0,$=ot(o),C=nt(o,this.accessibleTable),M=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,w=this.portal;return G`<svg
|
|
1
|
+
var Pt=Object.defineProperty;var Nt=Object.getOwnPropertyDescriptor;var l=(e,n,t,r)=>{for(var i=r>1?void 0:r?Nt(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&&Pt(n,t,i),i};import{customElement as rn,property as j}from"lit/decorators.js";var lt=e=>Number(e.toPrecision(12)),Dt,Gt=e=>(Dt??(Dt=new Intl.NumberFormat)).format(lt(e)),Ft=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 ut(e){if(e===void 0)return Gt;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=d=>i?h=>d(h)+i:d,a=d=>r===void 0?d===void 0?{}:{maximumFractionDigits:d}:{minimumFractionDigits:r,maximumFractionDigits:r},c=d=>{let h=new Intl.NumberFormat(t,d);return s(f=>h.format(lt(f)))},u=d=>{let h=new Intl.DateTimeFormat(t,o?{...d,timeZone:o}:d);return f=>h.format(f)};switch(n){case"integer":return c({maximumFractionDigits:0});case"decimal":return c(a(2));case"percent":return c({style:"percent",...a(0)});case"currency":return c({style:"currency",currency:e.currency??"USD",...a()});case"compact":return c({notation:"compact",...a(1)});case"scientific":return c({notation:"scientific",...a(2)});case"date":return u({dateStyle:"medium"});case"time":return u({timeStyle:"short"});case"datetime":return u({dateStyle:"medium",timeStyle:"short"});case"duration":return s(Ft)}}var M=e=>Number(e.toFixed(2)),se=e=>typeof e=="number"&&Number.isFinite(e);var K=1e3,Y=60*K,q=60*Y,oe=24*q,an=[K,5*K,15*K,30*K,Y,5*Y,15*Y,30*Y,q,3*q,6*q,12*q,oe,2*oe,7*oe,14*oe];var jt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Ht=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,_t={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Zt(e,n,t){return e.replace(Ht,(r,i,o)=>{let s=_t[i];if(s===void 0)return i+o;let c=(o.match(jt)??[]).map((u,d)=>{let h=Number(u);if(s===-1)return String(h+n);if(s===-2)return String(h+t);let f=d%s;return s===7?f===5?String(h+n):f===6?String(h+t):u:String(f%2===0?h+n:h+t)});return i+c.join(" ")})}var dt=(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:Zt(r.d,n,t)}}});var we=["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)"};var ht=(e,n)=>n??we[e%we.length];function _(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 ae=20,Et=120,ft=e=>{let n=_(e);return n&&(n.position==="left"||n.position==="right")?n.width??Et:0},ce=(e,n=600,t=300)=>({width:(e.width??n)-ft(e),height:(e.height??t)-(_(e)?.position==="bottom"?ae:0)}),mt=(e,n,t)=>{let r=_(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,gt(n,t??ce(e).width,r)):1)*ae},H=6.5;function Vt(e,n){let t=Array.from(e),r=Math.max(0,Math.floor(n/H));return t.length<=r?e:r===0?"":`${t.slice(0,r-1).join("")}\u2026`}var $e=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:ht(n)),Ce=(e,n)=>e.hiddenSeries?.includes(n)??!1;function Me(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],c=r.maxItems,u=c!==void 0&&c>=0&&e.length>c?e.slice(0,c):e,d=e.length-u.length,h=r.interactive??!0,f=o,C=i,k=(w,y,$,S)=>{let T=(y?18:4)+w.length*H;f>o&&(s||f+T>n-8)&&(f=o,C+=ae),y&&a.push({kind:"rect",part:"legend-swatch",x:f,y:C-5,width:10,height:10,fill:y,opacity:S?.3:void 0,item:$}),a.push({kind:"text",part:"legend-label",x:f+(y?14:0),y:C,text:w,baseline:"middle",fill:S?v.grid:v.label,item:$}),f+=T+12};for(let w of u){let y=t.includes(w.name),$=h?{label:w.name,series:w.name,legend:!0}:void 0;k(r.formatter?.(w.name)??w.name,w.color,$,y)}return d>0&&k(`+${d} more`,void 0,void 0,!1),r.align==="end"?Wt(a,n):a}function Wt(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(a=>a.kind==="rect"?a.x+a.width:a.x+a.text.length*H)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var gt=(e,n,t={})=>new Set(Me(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Se(e,n,t,r=[]){let i=_(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=pt(e),a=o?.position==="bottom",c=ft(e),u=e.hiddenSeries??[],d=o?c?Me(r,1/0,u,o,10,(o.position==="right"?n:0)+8,!0):Me(r,n,u,o,a?t+10:10):[],h=a?gt(r,n,o):0;return{width:n+c,height:a?t+Math.max(1,h)*ae: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:d}}function Ie(e){let n=e.legendOffset;if(!n)return e;let t=[...dt(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,a=e.map?{...e.map,plot:r(e.map.plot)}:void 0;return{...e,shapes:t,hit:i,edit:s,map:a,legendOffset:void 0}}function le(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(1,Math.floor((r-12)/H)),c=s.flatMap(y=>{let $=[],S=Array.from(y);for(;S.length>a;){let T=S.slice(0,a+1).lastIndexOf(" ");T<1&&(T=a),$.push(S.slice(0,T).join("")),S=S.slice(T),S[0]===" "&&S.shift()}return $.push(S.join("")),$}),u=Math.max(1,Math.floor((i-6)/16)),d=c.slice(0,u);c.length>u&&(d[u-1]=Vt(`${d[u-1]}\u2026`,r-12));let h=Math.min(r,Math.max(0,...d.map(y=>Array.from(y).length))*H+12),f=Math.min(i,6+d.length*16),C=o==="top"?{x:e-h/2,y:n-f-8}:o==="bottom"?{x:e-h/2,y:n+8}:o==="left"?{x:e-h-8,y:n-f/2}:o==="right"?{x:e+8,y:n-f/2}:{x:e+12,y:n-f-6},k=Math.max(0,Math.min(r-h,C.x)),w=Math.max(0,Math.min(i-f,C.y));return[{kind:"rect",part:"tooltip",title:s.join(`
|
|
2
|
+
`),x:M(k),y:M(w),width:M(h),height:f,fill:"var(--skdx-color-surface-raised)",stroke:v.axis,rx:8},...d.map((y,$)=>({kind:"text",part:"tooltip-label",x:M(k+6),y:M(w+11+$*16),text:y,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:d.length>1&&$===0?"bold":void 0}))]}function bt(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}=ce(e,t,r),a=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:8}),c.push({kind:"text",part:`state-${i}`,x:M(o/2),y:M(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":v.label}),{...Se(e,o,s),shapes:c,tooltip:!1}}function ue(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var ke=e=>e.id??e.name??e.series,xt=e=>e.seriesId??e.series;function B(e,n){let t=!1;return n.id!==void 0&&(t=!0,ke(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,xt(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 D(e){let n={},t=ke(e);t!==void 0&&(n.id=t);let r=xt(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Te=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Oe(e,n,t){let r=ue(e),i=D(n),o=r.some(s=>B(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!B(n,s)):[...r,i]}var Ut=.2;function Kt(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 Yt=(e,n)=>e.kind==="text"?{...e,fill:v.grid}:{...e,opacity:(e.opacity??1)*n};function ze(e,n){let t=ue(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:ue(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=[],a=d=>!i||r.some(h=>B(d,h))?!0:o.highlighted==="series"?r.some(h=>h.series!==void 0&&B(d,{series:h.series})):!1,c=d=>{if(!i||o.faded==="none"||a(d))return!1;if(o.faded==="series"){let h=i.series;return h!==void 0&&B(d,{series:h})}return!0},u=e.shapes.map(d=>{let h=d.item;if(!h||h.legend)return d;if(t.some(f=>B(h,f))){let f=Kt(d);f&&s.push(f)}return c(h)?Yt(d,Ut):d});return s.length?{...e,shapes:[...u,...s]}:{...e,shapes:u}}var yt="var(--skdx-radius-default, var(--skdx-radius-md, 0.5rem))";function de(e){return["tooltip","skeleton","label-background","stage-label-background","brush-handle"].includes(e)?yt:void 0}function V(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 Ae=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function vt(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 X(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=vt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Le(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[vt(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 Re(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Ae(r.plot,n,t))return[];let i=Le(e,n),{rows:o}=X(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...le(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Be(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 Re(e,i,t.plot.y+8)}function Pe(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:c,y:u}=V(t,r,i,e.width,e.height);if(Ae(e.hit.plot,c,u)){let d=X(e,c),h=Le(e,c);if(d&&h)return{lines:d.rows,shapes:[h]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?G(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(c=>c.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function wt(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),c=s&&s.tooltipFormatter?G(s,e)?.item:void 0,u=c&&s?.tooltipFormatter?.(c)||a&&Array.from(a.children).find(k=>k.tagName.toLowerCase()==="title")?.textContent;if(!u)return[];let d=s?.tooltipAnchored?G(s,e):void 0,h=d?s?.shapes[d.index]:void 0,{x:f,y:C}=h?Q(h):V(n,t,r,i,o);return le(f,C,u,i,o,s?.tooltipPlacement)}function Ne(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=V(t,r,i,e.width,e.height),a=Re(e,o,s);if(a.length>0)return a}return wt(n,t,r,i,e.width,e.height,e)}function De(e,n){let t=G(e,n);return t&&!t.item.legend?D(t.item):null}var qt=(e,n)=>{let{x:t,y:r}=Q(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 Ge(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!qt(i,n))continue;let o=D(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var Fe=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}),pe=(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 Mt(e,n,t){let r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let s=e[i],a=e[o];s.y>t!=a.y>t&&n<(a.x-s.x)*(t-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}function je(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}=Q(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Mt(n,o,a))continue;let c=D(i.item),u=JSON.stringify(c);t.has(u)||(t.add(u),r.push(c))}return r}var He=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"}),he=6;function _e(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-he||n>i.x1+he))return Math.abs(n-i.x0)<=he?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=he?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ze(e,n,t){let r=e.edit;return $t(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function Ee(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",a=r.snap??r.invert(o.x0+10)-r.invert(o.x0);return $t(r,{bar:o,mode:s},i*a)}function $t(e,{bar:n,mode:t},r){let i=a=>e.snap?Math.round(a/e.snap)*e.snap:a,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 Ve(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 Xt=64,Qt=e=>Math.max(1,Math.min(Xt,e));function We(e,n,t,r){let i=n>0?.8:1.25,o=Qt(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[c,u]=e.view.center,d=(t-(s.x+s.width/2))/a,h=(r-(s.y+s.height/2))/a,f=e.view.zoom/o;return{center:[c+d*(1-f),e.fromY(e.toY(u)-h*(1-f))],zoom:o}}function Ue(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 G(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 fe=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function Q(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 Ke(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*H+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}=Q(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?le(M(o),M(s),a,e.width,e.height):[]]}function Ye(e,n,t){let r=fe(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 Z=2,E=(e,n,t)=>{let r=Math.max(Z,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Ct=(e,n)=>!e||e.start<=0&&e.end>=n;function qe(e,n,t){if(e.count<=Z||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(Z,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!Ct(e.zoom,e.count)?E(r,a,e.count):void 0;let c=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),u=r+c*o;return E(u-c*a,a,e.count)}function Xe(e,n,t,r){let i=n.end-n.start,o=Math.max(Z,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 E(n.start+s*i-s*o,o,e.count)}function Qe(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return E(n.start-t/i,r,e.count)}function Je(e,n,t){let r=e.brush;if(!r||!Ae(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:E(s-o/2,o,e.count)}}function et(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 E(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-Z,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+Z,Math.round(t.end+o)));return{start:t.start,end:s}}function nt(e,n){switch(n.type){case"svg":return Promise.resolve(tt(e,n.label,n.resolve));case"csv":return Promise.resolve(Tt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=tt(e,n.label,n.resolve);return kt(t,e.width,e.height,n.scale,n.background)}}}var P=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),J=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${P(String(t))}"`).join("");function St(e){let n=e.title?`<title>${P(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${J([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${J([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${J([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${J([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${J([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]])}>${P(e.text)}</text>`}}function It(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${P(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="${P(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function tt(e,n,t){let r=It(e)+e.shapes.map(St).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="${P(n)}" font-family="${P(v.fontFamily)}" font-size="${P(v.fontSize)}"><title>${P(n)}</title>${r}</svg>`}function kt(e,n,t,r=2,i){return new Promise((o,s)=>{let a=URL.createObjectURL(new Blob([e],{type:"image/svg+xml;charset=utf-8"})),c=new Image;c.onload=()=>{URL.revokeObjectURL(a);let u=document.createElement("canvas");u.width=Math.round(n*r),u.height=Math.round(t*r);let d=u.getContext("2d");if(!d)return s(new Error("canvas 2d context unavailable"));i&&(d.fillStyle=i,d.fillRect(0,0,u.width,u.height)),d.drawImage(c,0,0,u.width,u.height),u.toBlob(h=>h?o(h):s(new Error("toBlob failed")),"image/png")},c.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},c.src=a})}function Tt(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 rt(e,n){if(!n)return;let t=typeof n=="object"?n.maxRows??500:500,r=e.hit;if(r&&r.rows.length>0){let a=r.rows[0];if(r.rows.length>t)return;let c=["",...a.slice(1).map(d=>d.replace(/:\s[^:]*$/,""))],u=r.rows.map(d=>[d[0],...d.slice(1).map(h=>h.slice(h.lastIndexOf(": ")+2))]);return[c,...u]}let i=e.shapes.flatMap(a=>a.item&&!a.item.legend&&!(a.part==="anchor"&&!a.title)?[a.item]:[]);if(i.length===0||i.length>t)return;let o=["series","name","category","value"].filter(a=>i.some(c=>c[a]!==void 0)),s=(a,c)=>a[c]===void 0?"":String(a[c]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(c=>s(a,c)))]}var it=new Map;function me(e){let n=it.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&&it.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return it.set(e,{group:i,listeners:t}),i}var Ot='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',ot=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Ot}{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){${Ot}{animation:none;transition:none}}`;function st(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}var zt=8;function At(e){let n=e.map(i=>Math.floor(i)),t=Math.round(e.reduce((i,o)=>i+o,0))-n.reduce((i,o)=>i+o,0),r=e.map((i,o)=>({i:o,frac:i-Math.floor(i)})).sort((i,o)=>o.frac-i.frac||i.i-o.i);for(let{i}of r){if(t<=0)break;n[i]++,t--}return n}function at(e){let n=[],t=e.data.map(g=>{let O=se(g.value)&&g.value>=0;return O||n.push({code:se(g.value)?"negative-value":"invalid-value",severity:"warning",message:`"${g.name}" has no valid non-negative value and is drawn as zero.`,itemId:g.id??g.name}),{...g,value:O?g.value:0}}),r=t.reduce((g,O)=>g+(Ce(e,O.name)?0:O.value),0),i=bt(e,r<=0,300,300);if(i)return{...i,issues:n};let o=ut(e.format),s=se(e.total)&&e.total>0?e.total:r,a=Math.max(1,Math.round(e.rows??10)),c=Math.max(1,Math.round(e.columns??10)),u=a*c,d=g=>s>0?g/s:0,h=At(t.map(g=>Ce(e,g.name)?0:Math.min(1,d(g.value))*u)),{width:f,height:C}=ce(e,300,300),k=new Map(t.map(g=>[g.name,`${Math.round(d(g.value)*100)}%`])),w=_(e),y=e.data.map((g,O)=>({name:g.name,color:$e(e,O,g.color)})),$=e.labels&&w?{...e,legend:{...w,formatter:g=>`${w.formatter?.(g)??g} ${k.get(g)??""}`}}:e,S=mt($,y,f),T=Math.max(0,e.cellGap??2),R=Math.max(1,Math.min((f-2*zt)/c,(C-S-2*zt)/a)),ee=(f-R*c)/2,te=S+(C-S-R*a)/2,be=e.orientation==="horizontal",xe=g=>be?{x:ee+g%c*R,y:te+Math.floor(g/c)*R}:{x:ee+Math.floor(g/a)*R,y:te+(a-1-g%a)*R},ne=(g,O,ye,re,ve,ie)=>{let{x:Rt,y:Bt}=xe(g);return{kind:"rect",part:"cell",x:M(Rt+T/2),y:M(Bt+T/2),width:M(Math.max(.5,R-T)),height:M(Math.max(.5,R-T)),fill:O,stroke:ie,opacity:ve,rx:e.cellRadius??2,title:ye,item:re}},W=[],N=0;t.forEach((g,O)=>{let ye=h[O],re=`${g.name}: ${o(g.value)} (${Math.round(d(g.value)*100)}%)`,ve={label:re,id:g.id??g.name,name:g.name,index:O,value:g.value};for(let ie=0;ie<ye&&N<u;ie++,N++)W.push(ne(N,$e(e,O,g.color),re,ve))});let U=s-r,Lt=U>0?`Other: ${o(U)} (${Math.round(d(U)*100)}%)`:"Empty";for(;N<u;N++)W.push(ne(N,v.grid,Lt,void 0,.6,v.axis));let ct=Se($,f,C,y);return{...ct,shapes:[...W,...ct.shapes],issues:n}}import{css as Jt,html as F,LitElement as en,nothing as I,svg as z}from"lit";import{property as p,state as L}from"lit/decorators.js";import{ifDefined as b}from"lit/directives/if-defined.js";var tn={fromAttribute:()=>!1},m=class extends en{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=[Fe(pe(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=[He(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ze(r,i.gantt,o-i.x),this.overlay=[Ve(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(Ue(r.map,i.view,o-i.x,s-i.y));return}if(i&&r.hit){if(i.grab==="pinch"){let[s,a]=[...this.pointers.values()];if(s===void 0||a===void 0||!i.distance)return;this.setZoom(Xe(r.hit,i.zoom,Math.abs(s-a)/i.distance,(s+a)/2));return}let{x:o}=this.viewBox(t,r);this.setZoom(i.grab==="pan"?Qe(r.hit,i.zoom,o-i.x):et(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Pe(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=Ne(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(De(r,t.target)),this.syncId&&r.hit?.crosshair){let o=X(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=G(r,t.target)?.item.legend,a=this.canEdit(r)?_e(r,i,o):void 0;if(a){this.drag={x:i,y:o,zoom:{start:0,end:0},grab:"edit",gantt:a},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 u=r.map.plot;if(i<u.x||i>u.x+u.width||o<u.y||o>u.y+u.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[u,d]=[...this.pointers.values()];this.drag={x:(u+d)/2,y:o,zoom:c.zoom,grab:"pinch",distance:Math.abs(u-d)||1}}else{let u=Je(c,i,o);if(u)this.drag={x:i,y:o,zoom:u.zoom,grab:u.grab},u.zoom!==c.zoom&&this.setZoom(u.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:a}=this.viewBox(t,o);if(Math.abs(s-i.x)>2||Math.abs(a-i.y)>2){i.grab==="select"?this.setSelected(Ge(o,pe(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(je(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(We(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 a=qe(s,t.deltaY,i);a&&(t.preventDefault(),this.setZoom(a))};this.onClick=t=>{if(!this.layout)return;if(this.drag?.distance===-1){this.drag=null;return}let r=G(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 a=r.shapes[this.focused]?.item;a&&(t.preventDefault(),this.select(a),this.emit("skdx-item-click",a));return}let i=this.canEdit(r)?Ee(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Ye(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?D(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:a,loading:c,error:u,emptyMessage:d,description:h,decorative:f,animated:C,responsive:k,highlighted:w,highlightScope:y,accessibleTable:$}=this;return{...typeof k=="object"&&this.measured!==void 0&&this.measured<(k.breakpoint??480)?k.compact:void 0,width:k&&this.measured?this.measured:t,height:r,animate:C,responsive:k,legend:i,tooltip:o,format:s,palette:a,loading:c,error:u,emptyMessage:d,description:h,decorative:f,highlighted:w===void 0?this.highlightState:w,highlightScope:y,accessibleTable:$,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&&me(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=me(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&&Te(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(Oe(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 V(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&&B(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?nt(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=ze(Ie(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let y of o.issues??[])this.emit("skdx-data-issue",y)}let s=this.canZoom(o),a=this.canPan(o),c=this.canEdit(o),u=this.brushing(),d=s||a||c||u,h=!o.decorative&&fe(o).length>0,f=st(o),C=rt(o,this.accessibleTable),k=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,w=this.portal;return F`<svg
|
|
3
4
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
5
|
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
6
|
width=${o.width}
|
|
6
7
|
height=${o.height}
|
|
7
8
|
role=${o.decorative?"presentation":"img"}
|
|
8
|
-
aria-hidden=${o.decorative?"true":
|
|
9
|
-
aria-label=${o.decorative?
|
|
10
|
-
aria-
|
|
11
|
-
tabindex=${h?0:
|
|
9
|
+
aria-hidden=${o.decorative?"true":I}
|
|
10
|
+
aria-label=${o.decorative?I:i}
|
|
11
|
+
aria-description=${b(o.description)}
|
|
12
|
+
tabindex=${h?0:I}
|
|
12
13
|
data-skdx-chart=${r}
|
|
13
|
-
data-zoomable=${s||a?"":
|
|
14
|
-
data-brushing=${u&&!(s||a)?"":
|
|
15
|
-
data-editable=${c?"":
|
|
16
|
-
style=${
|
|
14
|
+
data-zoomable=${s||a?"":I}
|
|
15
|
+
data-brushing=${u&&!(s||a)?"":I}
|
|
16
|
+
data-editable=${c?"":I}
|
|
17
|
+
style=${f?`--skdx-chart-duration:${f}`:I}
|
|
17
18
|
font-family=${v.fontFamily}
|
|
18
19
|
font-size=${v.fontSize}
|
|
19
|
-
@pointermove=${o.tooltip||d?this.onPointerMove:
|
|
20
|
+
@pointermove=${o.tooltip||d?this.onPointerMove:I}
|
|
20
21
|
@pointerleave=${()=>{this.clearTip(),this.highlight(null)}}
|
|
21
|
-
@pointerdown=${d?this.onPointerDown:
|
|
22
|
-
@pointerup=${d?this.onPointerUp:
|
|
23
|
-
@pointercancel=${d?this.onPointerUp:
|
|
24
|
-
@wheel=${s||a?this.onWheel:
|
|
25
|
-
@dblclick=${s||a?()=>a?this.setView(void 0):this.setZoom(void 0):
|
|
22
|
+
@pointerdown=${d?this.onPointerDown:I}
|
|
23
|
+
@pointerup=${d?this.onPointerUp:I}
|
|
24
|
+
@pointercancel=${d?this.onPointerUp:I}
|
|
25
|
+
@wheel=${s||a?this.onWheel:I}
|
|
26
|
+
@dblclick=${s||a?()=>a?this.setView(void 0):this.setZoom(void 0):I}
|
|
26
27
|
@click=${this.onClick}
|
|
27
|
-
@keydown=${h?this.onKeyDown:
|
|
28
|
+
@keydown=${h?this.onKeyDown:I}
|
|
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?z`<desc>${o.description}</desc>`:I}
|
|
33
|
+
${f?z`<style>${ot}</style>`:I} ${nn(o)}
|
|
34
|
+
${ge(o.shapes)}
|
|
35
|
+
${ge(this.tip.length||!this.crossState?this.tip:Be(o,this.crossState))}
|
|
36
|
+
${ge(Ke(o,this.focused))} ${ge(this.overlay)}
|
|
36
37
|
</svg>
|
|
37
|
-
${w?
|
|
38
|
+
${w?F`<div
|
|
38
39
|
role="tooltip"
|
|
39
40
|
data-skdx-tooltip=${r}
|
|
40
41
|
style="left:${w.x+12}px;top:${w.y+12}px"
|
|
41
42
|
>
|
|
42
|
-
${w.lines.map(
|
|
43
|
-
</div>`:
|
|
44
|
-
${C?
|
|
43
|
+
${w.lines.map(y=>F`<div>${y}</div>`)}
|
|
44
|
+
</div>`:I}
|
|
45
|
+
${C?F`<table data-skdx-table=${r}>
|
|
45
46
|
<caption>
|
|
46
|
-
${
|
|
47
|
+
${k}
|
|
47
48
|
</caption>
|
|
48
49
|
<thead>
|
|
49
50
|
<tr>
|
|
50
|
-
${(C[0]??[]).map(
|
|
51
|
+
${(C[0]??[]).map(y=>F`<th scope="col">${y}</th>`)}
|
|
51
52
|
</tr>
|
|
52
53
|
</thead>
|
|
53
54
|
<tbody>
|
|
54
|
-
${C.slice(1).map(
|
|
55
|
-
${
|
|
55
|
+
${C.slice(1).map(y=>F`<tr>
|
|
56
|
+
${y.map(($,S)=>S===0?F`<th scope="row">${$}</th>`:F`<td>${$}</td>`)}
|
|
56
57
|
</tr>`)}
|
|
57
58
|
</tbody>
|
|
58
|
-
</table>`:
|
|
59
|
+
</table>`:I}`}};m.styles=Jt`
|
|
59
60
|
:host {
|
|
60
61
|
display: inline-block;
|
|
61
62
|
}
|
|
@@ -63,7 +64,6 @@ var zt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var l=(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 zt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var l=(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 zt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var l=(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 zt=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var l=(e,n,t
|
|
|
106
109
|
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
110
|
font-weight: bold;
|
|
108
111
|
}
|
|
109
|
-
`,l([p({type:Number})],
|
|
112
|
+
`,l([p({type:Number})],m.prototype,"width",2),l([p({type:Number})],m.prototype,"height",2),l([p()],m.prototype,"label",2),l([p({type:Boolean,reflect:!0})],m.prototype,"legend",2),l([p({type:Boolean,attribute:"no-tooltip",converter:tn})],m.prototype,"tooltip",2),l([p({attribute:!1})],m.prototype,"format",2),l([p({attribute:!1})],m.prototype,"palette",2),l([p({attribute:!1})],m.prototype,"hiddenSeries",2),l([p({attribute:!1})],m.prototype,"selected",2),l([p({attribute:"selection-mode"})],m.prototype,"selectionMode",2),l([p({attribute:!1})],m.prototype,"highlighted",2),l([p({attribute:!1})],m.prototype,"highlightScope",2),l([p({type:Boolean,reflect:!0})],m.prototype,"loading",2),l([p()],m.prototype,"error",2),l([p({attribute:"empty-message"})],m.prototype,"emptyMessage",2),l([p()],m.prototype,"description",2),l([p({type:Boolean,reflect:!0})],m.prototype,"decorative",2),l([p({type:Boolean,attribute:"accessible-table"})],m.prototype,"accessibleTable",2),l([p({attribute:!1})],m.prototype,"zoom",2),l([p({attribute:!1})],m.prototype,"view",2),l([p({type:Boolean,reflect:!0})],m.prototype,"zoomable",2),l([p({type:Boolean,reflect:!0})],m.prototype,"editable",2),l([p({attribute:"sync-id"})],m.prototype,"syncId",2),l([p({type:Boolean,attribute:"cross-filter"})],m.prototype,"crossFilter",2),l([p({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],m.prototype,"animated",2),l([p({type:Boolean,reflect:!0})],m.prototype,"responsive",2),l([L()],m.prototype,"tip",2),l([L()],m.prototype,"overlay",2),l([L()],m.prototype,"portal",2),l([L()],m.prototype,"measured",2),l([L()],m.prototype,"viewState",2),l([L()],m.prototype,"highlightState",2),l([L()],m.prototype,"crossState",2),l([L()],m.prototype,"focused",2),l([L()],m.prototype,"hiddenState",2),l([L()],m.prototype,"zoomState",2),l([L()],m.prototype,"selectedState",2);var x=class extends m{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:s,references:a,annotations:c,labels:u,curve:d,connectNulls:h,nulls:f,stacked:C,stackOffset:k,orientation:w,radius:y,barGap:$,barWidth:S,sort:T,transform:R,transforms:ee,bins:te,binWidth:be,binDomain:xe,binMode:ne,sampling:W,brush:N,crosshair:U}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:c,labels:u,curve:d,connectNulls:h,nulls:f,stacked:C,stackOffset:k,orientation:w,radius:y,barGap:$,barWidth:S,sort:T,transform:R,transforms:ee,bins:te,binWidth:be,binDomain:xe,binMode:ne,sampling:W,brush:N,crosshair:U}}};l([p({attribute:!1})],x.prototype,"series",2),l([p({attribute:!1})],x.prototype,"categories",2),l([p({attribute:!1})],x.prototype,"xAxis",2),l([p({attribute:!1})],x.prototype,"yAxis",2),l([p({attribute:!1})],x.prototype,"rightAxis",2),l([p({attribute:!1})],x.prototype,"references",2),l([p({attribute:!1})],x.prototype,"annotations",2),l([p({type:Boolean,reflect:!0})],x.prototype,"labels",2),l([p()],x.prototype,"curve",2),l([p({type:Boolean,attribute:"connect-nulls"})],x.prototype,"connectNulls",2),l([p()],x.prototype,"nulls",2),l([p({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],x.prototype,"stacked",2),l([p({attribute:"stack-offset"})],x.prototype,"stackOffset",2),l([p()],x.prototype,"orientation",2),l([p({type:Number})],x.prototype,"radius",2),l([p({type:Number,attribute:"bar-gap"})],x.prototype,"barGap",2),l([p({type:Number,attribute:"bar-width"})],x.prototype,"barWidth",2),l([p()],x.prototype,"sort",2),l([p()],x.prototype,"transform",2),l([p({attribute:!1})],x.prototype,"transforms",2),l([p({type:Number})],x.prototype,"bins",2),l([p({type:Number,attribute:"bin-width"})],x.prototype,"binWidth",2),l([p({attribute:!1})],x.prototype,"binDomain",2),l([p({attribute:"bin-mode"})],x.prototype,"binMode",2),l([p({attribute:!1})],x.prototype,"sampling",2),l([p({type:Boolean,reflect:!0})],x.prototype,"brush",2),l([p({type:Boolean,reflect:!0})],x.prototype,"crosshair",2);var nn=e=>e.defs&&e.defs.length?z`<defs>${e.defs.map(n=>z`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>z`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${b(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:I,ge=e=>z`${e.map((n,t)=>{let r=n.title?z`<title>${n.title}</title>`:I,i=n.item?t:void 0;switch(n.kind){case"path":return z`<path data-skdx-part=${n.part} data-skdx-i=${b(i)} d=${n.d} fill=${n.fill??"none"} stroke=${b(n.stroke)} stroke-width=${b(n.strokeWidth)} stroke-linecap=${b(n.strokeLinecap)} stroke-linejoin=${b(n.strokeLinejoin)} stroke-dasharray=${b(n.dash)} opacity=${b(n.opacity)} fill-opacity=${b(n.fillOpacity)}>${r}</path>`;case"rect":return z`<rect data-skdx-part=${n.part} data-skdx-i=${b(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${b(n.rx)} style=${b(de(n.part)?`rx:${de(n.part)}`:void 0)} fill=${n.fill} stroke=${b(n.stroke)} fill-opacity=${b(n.opacity)} pointer-events=${b(n.part==="stage-label-background"||n.part==="label-background"?"none":void 0)}>${r}</rect>`;case"line":return z`<line data-skdx-part=${n.part} data-skdx-i=${b(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${b(n.strokeWidth)} stroke-dasharray=${b(n.dash)} opacity=${b(n.opacity)}>${r}</line>`;case"circle":return z`<circle data-skdx-part=${n.part} data-skdx-i=${b(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${b(n.stroke)} opacity=${b(n.opacity)}>${r}</circle>`;case"text":return z`<text aria-label=${b(n.title)} data-skdx-part=${n.part} data-skdx-i=${b(i)} x=${n.x} y=${n.y} text-anchor=${b(n.anchor)} dominant-baseline=${b(n.baseline)} fill=${b(n.fill)} font-weight=${b(n.weight)} pointer-events=${b(i===void 0?"none":void 0)} transform=${b(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var A=class extends m{constructor(){super(...arguments);this.data=[];this.labels=!1}render(){let{data:t,total:r,rows:i,columns:o,orientation:s,cellGap:a,cellRadius:c,labels:u}=this;return this.root(at({...this.sized(),data:t,total:r,rows:i,columns:o,orientation:s,cellGap:a,cellRadius:c,labels:u}),"waffle",this.label??"Waffle chart")}};l([j({attribute:!1})],A.prototype,"data",2),l([j({type:Number})],A.prototype,"total",2),l([j({type:Number})],A.prototype,"rows",2),l([j({type:Number})],A.prototype,"columns",2),l([j()],A.prototype,"orientation",2),l([j({type:Number,attribute:"cell-gap"})],A.prototype,"cellGap",2),l([j({type:Number,attribute:"cell-radius"})],A.prototype,"cellRadius",2),l([j({type:Boolean,reflect:!0})],A.prototype,"labels",2),A=l([rn("skdx-waffle-chart")],A);export{A as SkdxWaffleChart};
|