@skdx/web-components-charts 0.38.0 → 0.39.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 +31 -31
- package/dist/area.js +11 -11
- package/dist/bar.cjs +31 -31
- package/dist/bar.js +11 -11
- package/dist/boxplot.cjs +8 -8
- package/dist/boxplot.js +9 -9
- package/dist/bubble.cjs +9 -9
- package/dist/bubble.js +10 -10
- package/dist/bullet.cjs +12 -12
- package/dist/bullet.js +13 -13
- package/dist/bump.cjs +7 -7
- package/dist/bump.js +8 -8
- package/dist/candlestick.cjs +34 -34
- package/dist/candlestick.js +34 -34
- package/dist/chord.cjs +35 -35
- package/dist/chord.js +21 -21
- package/dist/circle-packing.cjs +16 -16
- package/dist/circle-packing.js +30 -30
- package/dist/combo.cjs +31 -31
- package/dist/combo.js +11 -11
- package/dist/dumbbell.cjs +21 -21
- package/dist/dumbbell.js +24 -24
- package/dist/funnel.cjs +7 -7
- package/dist/funnel.js +7 -7
- package/dist/gantt.cjs +7 -7
- package/dist/gantt.js +8 -8
- package/dist/gauge.cjs +6 -6
- package/dist/gauge.js +6 -6
- package/dist/heatmap.cjs +9 -9
- package/dist/heatmap.js +10 -10
- package/dist/histogram.cjs +30 -30
- package/dist/histogram.js +11 -11
- package/dist/icicle.cjs +16 -16
- package/dist/icicle.js +16 -16
- package/dist/index.cjs +33 -33
- package/dist/index.js +17 -17
- package/dist/line.cjs +31 -31
- package/dist/line.js +11 -11
- package/dist/linear-gauge.cjs +12 -12
- package/dist/linear-gauge.js +13 -13
- package/dist/map.cjs +6 -6
- package/dist/map.js +6 -6
- package/dist/marimekko.cjs +17 -17
- package/dist/marimekko.js +20 -20
- package/dist/network.cjs +14 -14
- package/dist/network.js +13 -13
- package/dist/organization.cjs +10 -10
- package/dist/organization.js +14 -14
- package/dist/parallel.cjs +6 -6
- package/dist/parallel.js +6 -6
- package/dist/pareto.cjs +30 -30
- package/dist/pareto.js +12 -12
- package/dist/pie.cjs +6 -6
- package/dist/pie.js +6 -6
- package/dist/polar-area.cjs +7 -7
- package/dist/polar-area.js +7 -7
- package/dist/radar.cjs +7 -7
- package/dist/radar.js +6 -6
- package/dist/radial.cjs +6 -6
- package/dist/radial.js +6 -6
- package/dist/range.cjs +31 -31
- package/dist/range.js +15 -15
- package/dist/sankey.cjs +10 -10
- package/dist/sankey.js +15 -15
- package/dist/scatter.cjs +31 -31
- package/dist/scatter.js +12 -12
- package/dist/sunburst.cjs +28 -28
- package/dist/sunburst.js +8 -8
- package/dist/swarm.cjs +16 -16
- package/dist/swarm.js +17 -17
- package/dist/timeline.cjs +6 -6
- package/dist/timeline.js +6 -6
- package/dist/tree.cjs +10 -10
- package/dist/tree.js +13 -13
- package/dist/treemap.cjs +7 -7
- package/dist/treemap.js +7 -7
- package/dist/waffle.cjs +31 -31
- package/dist/waffle.js +31 -31
- package/dist/waterfall.cjs +14 -14
- package/dist/waterfall.js +18 -18
- package/package.json +3 -3
package/dist/map.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var nn=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var h=(e,n,t,r)=>{for(var i=r>1?void 0:r?rn(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&&nn(n,t,i),i};import{customElement as Tn,property as V}from"lit/decorators.js";var vt=e=>Number(e.toPrecision(12)),on,sn=e=>(on??(on=new Intl.NumberFormat)).format(vt(e)),an=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 wt(e){if(e===void 0)return sn;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=u=>i?p=>u(p)+i:u,a=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},l=u=>{let p=new Intl.NumberFormat(t,u);return s(g=>p.format(vt(g)))},d=u=>{let p=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return g=>p.format(g)};switch(n){case"integer":return l({maximumFractionDigits:0});case"decimal":return l(a(2));case"percent":return l({style:"percent",...a(0)});case"currency":return l({style:"currency",currency:e.currency??"USD",...a()});case"compact":return l({notation:"compact",...a(1)});case"scientific":return l({notation:"scientific",...a(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(an)}}var b=e=>Number(e.toFixed(2)),X=e=>typeof e=="number"&&Number.isFinite(e);function D(e){let n=1/0,t=-1/0;for(let r of e)X(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}var oe=1e3,se=60*oe,ae=60*se,fe=24*ae,zn=[oe,5*oe,15*oe,30*oe,se,5*se,15*se,30*se,ae,3*ae,6*ae,12*ae,fe,2*fe,7*fe,14*fe];var ln=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,cn=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,un={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function dn(e,n,t){return e.replace(cn,(r,i,o)=>{let s=un[i];if(s===void 0)return i+o;let l=(o.match(ln)??[]).map((d,u)=>{let p=Number(d);if(s===-1)return String(p+n);if(s===-2)return String(p+t);let g=u%s;return s===7?g===5?String(p+n):g===6?String(p+t):d:String(g%2===0?p+n:p+t)});return i+l.join(" ")})}var Mt=(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:dn(r.d,n,t)}}});var Ce=["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 kt=(e,n)=>n??Ce[e%Ce.length];function le(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function St(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var ge=20,hn=120,$t=e=>{let n=le(e);return n&&(n.position==="left"||n.position==="right")?n.width??hn:0},Te=(e,n=600,t=300)=>({width:(e.width??n)-$t(e),height:(e.height??t)-(le(e)?.position==="bottom"?ge:0)}),Ct=e=>{let n=le(e);return n&&(n.position===void 0||n.position==="top")?ge:0},Q=6.5,be=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:kt(n));function Ie(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],l=r.maxItems,d=l!==void 0&&l>=0&&e.length>l?e.slice(0,l):e,u=e.length-d.length,p=r.interactive??!0,g=o,$=i,C=(S,m,y,w)=>{let O=(m?18:4)+S.length*Q;g>o&&(s||g+O>n-8)&&(g=o,$+=ge),m&&a.push({kind:"rect",part:"legend-swatch",x:g,y:$-5,width:10,height:10,fill:m,opacity:w?.3:void 0,item:y}),a.push({kind:"text",part:"legend-label",x:g+(m?14:0),y:$,text:S,baseline:"middle",fill:w?v.grid:v.label,item:y}),g+=O+12};for(let S of d){let m=t.includes(S.name),y=p?{label:S.name,series:S.name,legend:!0}:void 0;C(r.formatter?.(S.name)??S.name,S.color,y,m)}return u>0&&C(`+${u} more`,void 0,void 0,!1),r.align==="end"?pn(a,n):a}function pn(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 mn=(e,n,t={})=>new Set(Ie(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Le(e,n,t,r=[]){let i=le(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=St(e),a=o?.position==="bottom",l=$t(e),d=e.hiddenSeries??[],u=o?l?Ie(r,1/0,d,o,10,(o.position==="right"?n:0)+8,!0):Ie(r,n,d,o,a?t+10:10):[],p=a?mn(r,n,o):0;return{width:n+l,height:a?t+Math.max(1,p)*ge:t,legendOffset:o?.position==="left"?l: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 Oe(e){let n=e.legendOffset;if(!n)return e;let t=[...Mt(e.shapes.filter(l=>!l.part.startsWith("legend-")),n,0),...e.shapes.filter(l=>l.part.startsWith("legend-"))],r=l=>({...l,x:l.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(l=>l+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:l=>o.scale(l)+n,invert:l=>o.invert(l-n),bars:o.bars.map(l=>({...l,x0:l.x0+n,x1:l.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 xe(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(g=>g.length))*Q+12,l=6+s.length*16,d=o==="top"?{x:e-a/2,y:n-l-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-l/2}:o==="right"?{x:e+8,y:n-l/2}:{x:e+12,y:n-l-6},u=Math.max(0,Math.min(r-a,d.x)),p=Math.max(0,Math.min(i-l,d.y));return[{kind:"rect",part:"tooltip",x:b(u),y:b(p),width:b(a),height:l,fill:"var(--skdx-color-surface-raised)",stroke:v.axis,rx:3},...s.map((g,$)=>({kind:"text",part:"tooltip-label",x:b(u+6),y:b(p+11+$*16),text:g,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&$===0?"bold":void 0}))]}function It(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}=Te(e,t,r),a=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",l=[];return i==="loading"&&l.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),l.push({kind:"text",part:`state-${i}`,x:b(o/2),y:b(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":v.label}),{...Le(e,o,s),shapes:l,tooltip:!1}}var Tt=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:v.label,...r});var ce=e=>Math.max(0,Math.min(1,e));function Lt(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function Ot(e,n){if(e.length===0)return v.axis;if(e.length===1)return e[0];let t=ce(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=Lt(e[r]),s=Lt(e[r+1]);if(!o||!s)return e[Math.round(t)];let a=l=>Math.round(o[l]+(s[l]-o[l])*i);return`rgb(${a(0)}, ${a(1)}, ${a(2)})`}var zt=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(ce(e)*n))/(n-1):ce(e);function At(e,n,t,r=v.negative,i=String){let[o,s]=D(n),a=e??{type:"sequential"},l=m=>b(.15+.85*m);if(a.type==="threshold"){let{thresholds:m,colors:y,labels:w}=a,O=A=>{if(typeof A!="number"||!Number.isFinite(A))return;let T=0;for(;T<m.length&&A>=m[T];)T++;return{fill:y[Math.min(T,y.length-1)]??t,opacity:1}},P=y.map((A,T)=>({fill:A,opacity:1,label:w?.[T]??(T===0?`< ${i(m[0]??0)}`:T===m.length?`\u2265 ${i(m[T-1])}`:`${i(m[T-1])} \u2013 ${i(m[T])}`)}));return{color:O,domain:[o,s],swatches:P,kind:"threshold"}}if(a.type==="ordinal"){let m=a.colors?.length?a.colors:[t];return{color:w=>typeof w=="number"&&Number.isFinite(w)?{fill:m[Math.abs(Math.round(w))%m.length],opacity:1}:void 0,domain:[o,s],swatches:m.map((w,O)=>({fill:w,opacity:1,label:String(O)})),kind:"ordinal"}}if(a.type==="diverging"){let[m,y,w]=a.domain??[-Math.max(Math.abs(o),Math.abs(s)),0,Math.max(Math.abs(o),Math.abs(s))],O=a.colors,P=z=>z<y?.5*(z-m)/Math.max(1e-12,y-m):.5+.5*(z-y)/Math.max(1e-12,w-y),A=z=>{let G=zt(a.reversed?1-ce(z):z,a.steps);if(O&&O.length>=2)return{fill:Ot(O,G),opacity:1};let R=G<.5?r:t,E=Math.abs(G-.5)*2;return{fill:R,opacity:l(E)}},T=z=>typeof z=="number"&&Number.isFinite(z)?A(P(z)):void 0,Z=a.steps??5,J=Array.from({length:Z},(z,G)=>{let R=Z===1?.5:G/(Z-1),E=R<.5?m+(y-m)*(R*2):y+(w-y)*((R-.5)*2);return{...A(R),label:i(E)}});return{color:T,domain:[m,w],swatches:J,kind:"diverging"}}let[d,u]=a.domain??[o,s],p=a.colors,g=m=>{let y=zt(a.reversed?1-ce(m):m,a.steps);return p&&p.length>=2?{fill:Ot(p,y),opacity:1}:{fill:p?.[0]??t,opacity:l(y)}},$=m=>typeof m!="number"||!Number.isFinite(m)?void 0:g(u===d?1:(m-d)/(u-d)),C=a.steps??5,S=Array.from({length:C},(m,y)=>{let w=C===1?1:y/(C-1);return{...g(w),label:i(d+(u-d)*w)}});return{color:$,domain:[d,u],swatches:S,kind:"sequential"}}var fn=34,gn=72;function ye(e){if(!e)return{bottom:0,right:0,options:{}};let n=e===!0?{}:e;return n.orientation==="vertical"?{bottom:0,right:gn,options:n}:{bottom:fn,right:0,options:n}}function Pt(e,n,t){let r=typeof t=="string"?{title:t}:t??{},i=r.title,o=e.swatches;if(o.length===0||n.width<=0)return[];if(r.orientation==="vertical"){let u=Math.max(0,n.height-(i?16:0)),p=Math.min(16,u/o.length),g=n.y+(i?16:0),$=o.map((S,m)=>({kind:"rect",part:"color-legend-swatch",x:b(n.x),y:b(g+m*p),width:10,height:b(p),fill:S.fill,opacity:S.opacity,title:S.label})),C=p>=12?1:2;return o.forEach((S,m)=>{m%C!==0&&m!==o.length-1||$.push({kind:"text",part:"color-legend-label",x:b(n.x+14),y:b(g+(m+.5)*p),text:S.label,baseline:"middle",fill:v.label})}),i&&$.push({kind:"text",part:"color-legend-title",x:b(n.x),y:b(n.y+6),text:i,baseline:"middle",fill:v.label}),$}let s=Math.min(n.width/o.length,96),a=n.x+(n.width-s*o.length)/2,l=o.map((u,p)=>({kind:"rect",part:"color-legend-swatch",x:b(a+p*s),y:b(n.y),width:b(s),height:10,fill:u.fill,opacity:u.opacity,title:u.label})),d=e.kind==="threshold"?1:Math.max(1,Math.ceil(o.length*7*Q/Math.max(1,s*o.length)));return o.forEach((u,p)=>{p%d!==0&&p!==o.length-1||l.push({kind:"text",part:"color-legend-label",x:b(a+(p+.5)*s),y:b(n.y+22),text:u.label,anchor:"middle",fill:v.label})}),i&&l.push({kind:"text",part:"color-legend-title",x:b(a-6),y:b(n.y+5),text:i,anchor:"end",baseline:"middle",fill:v.label}),l}function ve(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var ze=e=>e.id??e.name??e.series,Rt=e=>e.seriesId??e.series;function H(e,n){let t=!1;return n.id!==void 0&&(t=!0,ze(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,Rt(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 U(e){let n={},t=ze(e);t!==void 0&&(n.id=t);let r=Rt(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ae=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Pe(e,n,t){let r=ve(e),i=U(n),o=r.some(s=>H(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!H(n,s)):[...r,i]}var bn=.2;function xn(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 yn=(e,n)=>e.kind==="text"?{...e,fill:v.grid}:{...e,opacity:(e.opacity??1)*n};function Re(e,n){let t=ve(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:ve(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=u=>!i||r.some(p=>H(u,p))?!0:o.highlighted==="series"?r.some(p=>p.series!==void 0&&H(u,{series:p.series})):!1,l=u=>{if(!i||o.faded==="none"||a(u))return!1;if(o.faded==="series"){let p=i.series;return p!==void 0&&H(u,{series:p})}return!0},d=e.shapes.map(u=>{let p=u.item;if(!p||p.legend)return u;if(t.some(g=>H(p,g))){let g=xn(u);g&&s.push(g)}return l(p)?yn(u,bn):u});return s.length?{...e,shapes:[...d,...s]}:{...e,shapes:d}}function re(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 Be=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Bt(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 ue(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Bt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Ne(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[Bt(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 Fe(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Be(r.plot,n,t))return[];let i=Ne(e,n),{rows:o}=ue(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...xe(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function De(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 Fe(e,i,t.plot.y+8)}function Ge(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:l,y:d}=re(t,r,i,e.width,e.height);if(Be(e.hit.plot,l,d)){let u=ue(e,l),p=Ne(e,l);if(u&&p)return{lines:u.rows,shapes:[p]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?q(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(l=>l.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function Nt(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),l=s&&s.tooltipFormatter?q(s,e)?.item:void 0,d=l&&s?.tooltipFormatter?.(l)||a&&Array.from(a.children).find(C=>C.tagName.toLowerCase()==="title")?.textContent;if(!d)return[];let u=s?.tooltipAnchored?q(s,e):void 0,p=u?s?.shapes[u.index]:void 0,{x:g,y:$}=p?de(p):re(n,t,r,i,o);return xe(g,$,d,i,o,s?.tooltipPlacement)}function je(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=re(t,r,i,e.width,e.height),a=Fe(e,o,s);if(a.length>0)return a}return Nt(n,t,r,i,e.width,e.height,e)}function He(e,n){let t=q(e,n);return t&&!t.item.legend?U(t.item):null}var vn=(e,n)=>{let{x:t,y:r}=de(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 _e(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!vn(i,n))continue;let o=U(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var Ve=e=>({kind:"rect",part:"selection-box",x:b(e.x),y:b(e.y),width:b(e.width),height:b(e.height),fill:v.focus,opacity:.12,stroke:v.focus}),Me=(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 Ft(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 Ze(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}=de(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Ft(n,o,a))continue;let l=U(i.item),d=JSON.stringify(l);t.has(d)||(t.add(d),r.push(l))}return r}var Ee=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${b(n.x)} ${b(n.y)}`).join("L")}`:"",fill:v.focus,fillOpacity:.12,stroke:v.focus,dash:"4 3"}),we=6;function We(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-we||n>i.x1+we))return Math.abs(n-i.x0)<=we?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=we?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ue(e,n,t){let r=e.edit;return Dt(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function qe(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(l=>l.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 Dt(r,{bar:o,mode:s},i*a)}function Dt(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 Ke(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:b(Math.min(i,o)),y:b(n.bar.y),width:b(Math.max(1,Math.abs(o-i))),height:b(n.bar.height),fill:v.focus,opacity:.25,stroke:v.focus,rx:2}}var wn=64,Mn=e=>Math.max(1,Math.min(wn,e));function Ye(e,n,t,r){let i=n>0?.8:1.25,o=Mn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[l,d]=e.view.center,u=(t-(s.x+s.width/2))/a,p=(r-(s.y+s.height/2))/a,g=e.view.zoom/o;return{center:[l+u*(1-g),e.fromY(e.toY(d)-p*(1-g))],zoom:o}}function Xe(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 q(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 ke=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function de(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 Qe(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}=de(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?xe(b(o),b(s),a,e.width,e.height):[]]}function Je(e,n,t){let r=ke(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,ne=(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}},Gt=(e,n)=>!e||e.start<=0&&e.end>=n;function et(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,a=Math.max(te,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!Gt(e.zoom,e.count)?ne(r,a,e.count):void 0;let l=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),d=r+l*o;return ne(d-l*a,a,e.count)}function tt(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 ne(n.start+s*i-s*o,o,e.count)}function nt(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return ne(n.start-t/i,r,e.count)}function rt(e,n,t){let r=e.brush;if(!r||!Be(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:ne(s-o/2,o,e.count)}}function it(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 ne(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 st(e,n){switch(n.type){case"svg":return Promise.resolve(ot(e,n.label,n.resolve));case"csv":return Promise.resolve(Vt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=ot(e,n.label,n.resolve);return _t(t,e.width,e.height,n.scale,n.background)}}}var _=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),he=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${_(String(t))}"`).join("");function jt(e){let n=e.title?`<title>${_(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${he([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${he([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${he([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${he([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${he([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]])}>${_(e.text)}</text>`}}function Ht(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${_(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="${_(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function ot(e,n,t){let r=Ht(e)+e.shapes.map(jt).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="${_(n)}" font-family="${_(v.fontFamily)}" font-size="${_(v.fontSize)}"><title>${_(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"})),l=new Image;l.onload=()=>{URL.revokeObjectURL(a);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(l,0,0,d.width,d.height),d.toBlob(p=>p?o(p):s(new Error("toBlob failed")),"image/png")},l.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},l.src=a})}function Vt(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 at(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 l=["",...a.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],d=r.rows.map(u=>[u[0],...u.slice(1).map(p=>p.slice(p.lastIndexOf(": ")+2))]);return[l,...d]}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(l=>l[a]!==void 0)),s=(a,l)=>a[l]===void 0?"":String(a[l]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(l=>s(a,l)))]}var lt=new Map;function Se(e){let n=lt.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&<.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return lt.set(e,{group:i,listeners:t}),i}var Zt='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',ct=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Zt}{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){${Zt}{animation:none;transition:none}}`;function ut(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}var K=8,dt=e=>e.geometry.type==="Polygon"?e.geometry.coordinates:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.flat():[],Wt=e=>e.geometry.type==="Point"?[e.geometry.coordinates]:e.geometry.type==="MultiPoint"?e.geometry.coordinates:[],Ut=e=>e.geometry.type==="LineString"?[e.geometry.coordinates]:e.geometry.type==="MultiLineString"?e.geometry.coordinates:[],Et=e=>[...dt(e).flat(),...Wt(e),...Ut(e).flat()],kn=e=>Math.log(Math.tan(Math.PI/4+Math.max(-85,Math.min(85,e))*Math.PI/360)),ie=e=>e!==void 0&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function ht(e){let n=[],t=e.features.filter(c=>{let L=Et(c).some(ie);return L||n.push({code:"invalid-geometry",severity:"warning",message:`Feature "${c.name}" has no valid coordinates and was dropped.`,itemId:c.id??c.name}),L}),r=It(e,t.length===0);if(r)return{...r,issues:n};let i=wt(e.format),{width:o,height:s}=Te(e),a=Ct(e),l=ye(e.colorLegend).bottom,d=ye(e.colorLegend).right,u=e.projection==="mercator"?kn:c=>c,p=t.filter(c=>dt(c).length>0),g=(p.length?p:t).flatMap(c=>Et(c).filter(ie)),[$,C]=g.length?D(g.map(c=>c[0])):[0,1],[S,m]=g.length?D(g.map(c=>u(c[1]))):[0,1],y=Math.min((o-d-2*K)/Math.max(1e-9,C-$),(s-a-l-2*K)/Math.max(1e-9,m-S)),w={x:K,y:a+K,width:o-d-2*K,height:s-a-l-2*K},O=Math.max(1,Math.min(64,e.view?.zoom??1)),P=y*O,A=e.view?.center?[e.view.center[0],u(e.view.center[1])]:[($+C)/2,(S+m)/2],T=w.x+w.width/2-A[0]*P,Z=w.y+w.height/2+A[1]*P,J=([c,L])=>({x:b(T+c*P),y:b(Z-u(L)*P)}),z=c=>{let{x:L,y:j}=J(c);return`${L} ${j}`},G=be(e,0,e.color),R=At(e.colorScale,t.map(c=>c.value),G,void 0,i),E=[],qt=p.map(c=>{let L=dt(c);if(e.labels&&L.length){let W=L.reduce((ee,yt)=>yt.length>ee.length?yt:ee),[me,Jt]=D(W.map(ee=>ee[0])),[en,tn]=D(W.map(ee=>u(ee[1])));E.push(Tt(b(T+((me+Jt)/2-$)*P),b(Z+(m-(en+tn)/2)*P),c.name,{part:"region-label",anchor:"middle",baseline:"middle",fill:"var(--skdx-color-text-default)"}))}let j=c.color!==void 0?{fill:c.color,opacity:1}:R.color(c.value),pe=`${c.name}${X(c.value)?`: ${i(c.value)}`:""}`;return{kind:"path",part:"region",d:L.map(W=>`M${W.filter(ie).map(z).join("L")}Z`).join(""),fill:j?.fill??v.grid,opacity:j?.opacity??.6,stroke:"var(--skdx-color-surface-default)",title:pe,item:{label:pe,id:c.id??c.name,name:c.name,value:c.value}}}),pt=[...e.lines??[],...t.flatMap(c=>Ut(c).map(L=>({id:c.id,name:c.name,coordinates:L,value:c.value,color:c.color??(X(c.value)?R.color(c.value)?.fill:void 0),dash:void 0})))].filter(c=>c.coordinates.filter(ie).length>=2),[,mt]=D(pt.map(c=>c.value)),Kt=pt.map((c,L)=>{let j=`${c.name}${X(c.value)?`: ${i(c.value)}`:""}`;return{kind:"path",part:"route",d:`M${c.coordinates.filter(ie).map(z).join("L")}`,stroke:c.color??be(e,2),strokeWidth:X(c.value)&&mt>0?1+3*Math.sqrt(Math.max(0,c.value)/mt):1.5,strokeLinecap:"round",strokeLinejoin:"round",dash:c.dash,opacity:.85,title:j,item:{label:j,id:c.id??c.name,name:c.name,index:L,value:c.value}}}),ft=[...e.points??[],...t.flatMap(c=>Wt(c).map(L=>({id:c.id,name:c.name,coordinates:L,value:c.value,color:c.color??(X(c.value)?R.color(c.value)?.fill:void 0)})))].filter(c=>ie(c.coordinates)),[gt,Yt]=e.sizeRange??[3,14],[,bt]=D(ft.map(c=>c.value)),Xt=ft.map((c,L)=>{let{x:j,y:pe}=J(c.coordinates),W=Number.isFinite(c.value)&&bt>0,me=`${c.name}${W?`: ${i(c.value)}`:""}`;return{kind:"circle",part:W?"bubble":"point",cx:j,cy:pe,r:b(W?Math.max(gt,Math.sqrt(Math.max(0,c.value)/bt)*Yt):gt),fill:c.color??be(e,1),stroke:"var(--skdx-color-surface-default)",opacity:.85,title:me,item:{label:me,id:c.id??c.name,name:c.name,index:L,value:c.value}}}),Qt=e.colorLegend?Pt(R,d?{x:w.x+w.width+12,y:w.y,width:d,height:w.height}:{x:K,y:s-l+8,width:o-2*K,height:l},ye(e.colorLegend).options):[],xt=e.projection==="mercator"?c=>Math.atan(Math.exp(c))*360/Math.PI-90:c=>c;return{...Le(e,o,s),shapes:[...qt,...Kt,...E,...Xt,...Qt],issues:n,map:{view:{center:[A[0],xt(A[1])],zoom:O},bounds:{minLon:$,maxLon:C,minLat:S,maxLat:m},plot:w,scale:P,toY:u,fromY:xt}}}import{css as Sn,html as Y,LitElement as $n,nothing as I,svg as N}from"lit";import{property as f,state as F}from"lit/decorators.js";import{ifDefined as k}from"lit/directives/if-defined.js";var Cn={fromAttribute:()=>!1},x=class extends $n{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=[Ve(Me(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=[Ee(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ue(r,i.gantt,o-i.x),this.overlay=[Ke(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(Xe(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(tt(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"?nt(r.hit,i.zoom,o-i.x):it(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Ge(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=je(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(He(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ue(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=q(r,t.target)?.item.legend,a=this.canEdit(r)?We(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 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 l=r.hit;if(!(!l||!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:l.zoom,grab:"pinch",distance:Math.abs(d-u)||1}}else{let d=rt(l,i,o);if(d)this.drag={x:i,y:o,zoom:d.zoom,grab:d.grab},d.zoom!==l.zoom&&this.setZoom(d.zoom);else if(this.zoomable&&i>=l.plot.x&&i<=l.plot.x+l.plot.width&&o>=l.plot.y&&o<=l.plot.y+l.plot.height)this.drag={x:i,y:o,zoom:l.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(_e(o,Me(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ze(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 l=r.map.plot;if(i<l.x||i>l.x+l.width||o<l.y||o>l.y+l.height)return;t.preventDefault(),this.setView(Ye(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=et(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=q(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)?qe(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Je(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?U(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:l,error:d,emptyMessage:u,description:p,decorative:g,animated:$,responsive:C,highlighted:S,highlightScope:m,accessibleTable:y}=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:l,error:d,emptyMessage:u,description:p,decorative:g,highlighted:S===void 0?this.highlightState:S,highlightScope:m,accessibleTable:y,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&&Se(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=Se(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&&Ae(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(Pe(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 re(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&&H(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?st(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Re(Oe(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),l=this.canEdit(o),d=this.brushing(),u=s||a||l||d,p=!o.decorative&&ke(o).length>0,g=o.description?`${r}-desc`:void 0,$=ut(o),C=at(o,this.accessibleTable),S=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,m=this.portal;return Y`<svg
|
|
1
|
+
var rn=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var h=(e,n,t,r)=>{for(var i=r>1?void 0:r?on(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&&rn(n,t,i),i};import{customElement as Tn,property as V}from"lit/decorators.js";var vt=e=>Number(e.toPrecision(12)),sn,an=e=>(sn??(sn=new Intl.NumberFormat)).format(vt(e)),ln=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 wt(e){if(e===void 0)return an;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=u=>i?p=>u(p)+i:u,a=u=>r===void 0?u===void 0?{}:{maximumFractionDigits:u}:{minimumFractionDigits:r,maximumFractionDigits:r},l=u=>{let p=new Intl.NumberFormat(t,u);return s(g=>p.format(vt(g)))},d=u=>{let p=new Intl.DateTimeFormat(t,o?{...u,timeZone:o}:u);return g=>p.format(g)};switch(n){case"integer":return l({maximumFractionDigits:0});case"decimal":return l(a(2));case"percent":return l({style:"percent",...a(0)});case"currency":return l({style:"currency",currency:e.currency??"USD",...a()});case"compact":return l({notation:"compact",...a(1)});case"scientific":return l({notation:"scientific",...a(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(ln)}}var b=e=>Number(e.toFixed(2)),X=e=>typeof e=="number"&&Number.isFinite(e);function D(e){let n=1/0,t=-1/0;for(let r of e)X(r)&&(r<n&&(n=r),r>t&&(t=r));return n===1/0?[0,0]:[n,t]}var oe=1e3,se=60*oe,ae=60*se,fe=24*ae,zn=[oe,5*oe,15*oe,30*oe,se,5*se,15*se,30*se,ae,3*ae,6*ae,12*ae,fe,2*fe,7*fe,14*fe];var cn=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,un=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,dn={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function hn(e,n,t){return e.replace(un,(r,i,o)=>{let s=dn[i];if(s===void 0)return i+o;let l=(o.match(cn)??[]).map((d,u)=>{let p=Number(d);if(s===-1)return String(p+n);if(s===-2)return String(p+t);let g=u%s;return s===7?g===5?String(p+n):g===6?String(p+t):d:String(g%2===0?p+n:p+t)});return i+l.join(" ")})}var Mt=(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:hn(r.d,n,t)}}});var Ie=["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 kt=(e,n)=>n??Ie[e%Ie.length];function le(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function St(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var ge=20,pn=120,$t=e=>{let n=le(e);return n&&(n.position==="left"||n.position==="right")?n.width??pn:0},be=(e,n=600,t=300)=>({width:(e.width??n)-$t(e),height:(e.height??t)-(le(e)?.position==="bottom"?ge:0)}),Ct=(e,n,t)=>{let r=le(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,It(n,t??be(e).width,r)):1)*ge},Q=6.5,xe=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:kt(n));function Te(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],l=r.maxItems,d=l!==void 0&&l>=0&&e.length>l?e.slice(0,l):e,u=e.length-d.length,p=r.interactive??!0,g=o,$=i,C=(S,m,y,w)=>{let O=(m?18:4)+S.length*Q;g>o&&(s||g+O>n-8)&&(g=o,$+=ge),m&&a.push({kind:"rect",part:"legend-swatch",x:g,y:$-5,width:10,height:10,fill:m,opacity:w?.3:void 0,item:y}),a.push({kind:"text",part:"legend-label",x:g+(m?14:0),y:$,text:S,baseline:"middle",fill:w?v.grid:v.label,item:y}),g+=O+12};for(let S of d){let m=t.includes(S.name),y=p?{label:S.name,series:S.name,legend:!0}:void 0;C(r.formatter?.(S.name)??S.name,S.color,y,m)}return u>0&&C(`+${u} more`,void 0,void 0,!1),r.align==="end"?mn(a,n):a}function mn(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 It=(e,n,t={})=>new Set(Te(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Le(e,n,t,r=[]){let i=le(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=St(e),a=o?.position==="bottom",l=$t(e),d=e.hiddenSeries??[],u=o?l?Te(r,1/0,d,o,10,(o.position==="right"?n:0)+8,!0):Te(r,n,d,o,a?t+10:10):[],p=a?It(r,n,o):0;return{width:n+l,height:a?t+Math.max(1,p)*ge:t,legendOffset:o?.position==="left"?l: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 Oe(e){let n=e.legendOffset;if(!n)return e;let t=[...Mt(e.shapes.filter(l=>!l.part.startsWith("legend-")),n,0),...e.shapes.filter(l=>l.part.startsWith("legend-"))],r=l=>({...l,x:l.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(l=>l+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:l=>o.scale(l)+n,invert:l=>o.invert(l-n),bars:o.bars.map(l=>({...l,x0:l.x0+n,x1:l.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 ye(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(g=>g.length))*Q+12,l=6+s.length*16,d=o==="top"?{x:e-a/2,y:n-l-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-l/2}:o==="right"?{x:e+8,y:n-l/2}:{x:e+12,y:n-l-6},u=Math.max(0,Math.min(r-a,d.x)),p=Math.max(0,Math.min(i-l,d.y));return[{kind:"rect",part:"tooltip",x:b(u),y:b(p),width:b(a),height:l,fill:"var(--skdx-color-surface-raised)",stroke:v.axis,rx:3},...s.map((g,$)=>({kind:"text",part:"tooltip-label",x:b(u+6),y:b(p+11+$*16),text:g,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&$===0?"bold":void 0}))]}function Tt(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}=be(e,t,r),a=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",l=[];return i==="loading"&&l.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),l.push({kind:"text",part:`state-${i}`,x:b(o/2),y:b(s/2),text:a,anchor:"middle",baseline:"middle",fill:i==="error"?"var(--skdx-color-text-danger)":v.label}),{...Le(e,o,s),shapes:l,tooltip:!1}}var Lt=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:v.label,...r});var ce=e=>Math.max(0,Math.min(1,e));function Ot(e){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(n){let r=n[1],i=r.length===3?r.split("").map(o=>o+o).join(""):r;return[0,2,4].map(o=>parseInt(i.slice(o,o+2),16))}let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:void 0}function zt(e,n){if(e.length===0)return v.axis;if(e.length===1)return e[0];let t=ce(n)*(e.length-1),r=Math.min(e.length-2,Math.floor(t)),i=t-r,o=Ot(e[r]),s=Ot(e[r+1]);if(!o||!s)return e[Math.round(t)];let a=l=>Math.round(o[l]+(s[l]-o[l])*i);return`rgb(${a(0)}, ${a(1)}, ${a(2)})`}var At=(e,n)=>n!==void 0&&n>=2?Math.min(n-1,Math.floor(ce(e)*n))/(n-1):ce(e);function Pt(e,n,t,r=v.negative,i=String){let[o,s]=D(n),a=e??{type:"sequential"},l=m=>b(.15+.85*m);if(a.type==="threshold"){let{thresholds:m,colors:y,labels:w}=a,O=A=>{if(typeof A!="number"||!Number.isFinite(A))return;let T=0;for(;T<m.length&&A>=m[T];)T++;return{fill:y[Math.min(T,y.length-1)]??t,opacity:1}},P=y.map((A,T)=>({fill:A,opacity:1,label:w?.[T]??(T===0?`< ${i(m[0]??0)}`:T===m.length?`\u2265 ${i(m[T-1])}`:`${i(m[T-1])} \u2013 ${i(m[T])}`)}));return{color:O,domain:[o,s],swatches:P,kind:"threshold"}}if(a.type==="ordinal"){let m=a.colors?.length?a.colors:[t];return{color:w=>typeof w=="number"&&Number.isFinite(w)?{fill:m[Math.abs(Math.round(w))%m.length],opacity:1}:void 0,domain:[o,s],swatches:m.map((w,O)=>({fill:w,opacity:1,label:String(O)})),kind:"ordinal"}}if(a.type==="diverging"){let[m,y,w]=a.domain??[-Math.max(Math.abs(o),Math.abs(s)),0,Math.max(Math.abs(o),Math.abs(s))],O=a.colors,P=z=>z<y?.5*(z-m)/Math.max(1e-12,y-m):.5+.5*(z-y)/Math.max(1e-12,w-y),A=z=>{let G=At(a.reversed?1-ce(z):z,a.steps);if(O&&O.length>=2)return{fill:zt(O,G),opacity:1};let R=G<.5?r:t,E=Math.abs(G-.5)*2;return{fill:R,opacity:l(E)}},T=z=>typeof z=="number"&&Number.isFinite(z)?A(P(z)):void 0,Z=a.steps??5,J=Array.from({length:Z},(z,G)=>{let R=Z===1?.5:G/(Z-1),E=R<.5?m+(y-m)*(R*2):y+(w-y)*((R-.5)*2);return{...A(R),label:i(E)}});return{color:T,domain:[m,w],swatches:J,kind:"diverging"}}let[d,u]=a.domain??[o,s],p=a.colors,g=m=>{let y=At(a.reversed?1-ce(m):m,a.steps);return p&&p.length>=2?{fill:zt(p,y),opacity:1}:{fill:p?.[0]??t,opacity:l(y)}},$=m=>typeof m!="number"||!Number.isFinite(m)?void 0:g(u===d?1:(m-d)/(u-d)),C=a.steps??5,S=Array.from({length:C},(m,y)=>{let w=C===1?1:y/(C-1);return{...g(w),label:i(d+(u-d)*w)}});return{color:$,domain:[d,u],swatches:S,kind:"sequential"}}var fn=34,gn=72;function ve(e){if(!e)return{bottom:0,right:0,options:{}};let n=e===!0?{}:e;return n.orientation==="vertical"?{bottom:0,right:gn,options:n}:{bottom:fn,right:0,options:n}}function Rt(e,n,t){let r=typeof t=="string"?{title:t}:t??{},i=r.title,o=e.swatches;if(o.length===0||n.width<=0)return[];if(r.orientation==="vertical"){let u=Math.max(0,n.height-(i?16:0)),p=Math.min(16,u/o.length),g=n.y+(i?16:0),$=o.map((S,m)=>({kind:"rect",part:"color-legend-swatch",x:b(n.x),y:b(g+m*p),width:10,height:b(p),fill:S.fill,opacity:S.opacity,title:S.label})),C=p>=12?1:2;return o.forEach((S,m)=>{m%C!==0&&m!==o.length-1||$.push({kind:"text",part:"color-legend-label",x:b(n.x+14),y:b(g+(m+.5)*p),text:S.label,baseline:"middle",fill:v.label})}),i&&$.push({kind:"text",part:"color-legend-title",x:b(n.x),y:b(n.y+6),text:i,baseline:"middle",fill:v.label}),$}let s=Math.min(n.width/o.length,96),a=n.x+(n.width-s*o.length)/2,l=o.map((u,p)=>({kind:"rect",part:"color-legend-swatch",x:b(a+p*s),y:b(n.y),width:b(s),height:10,fill:u.fill,opacity:u.opacity,title:u.label})),d=e.kind==="threshold"?1:Math.max(1,Math.ceil(o.length*7*Q/Math.max(1,s*o.length)));return o.forEach((u,p)=>{p%d!==0&&p!==o.length-1||l.push({kind:"text",part:"color-legend-label",x:b(a+(p+.5)*s),y:b(n.y+22),text:u.label,anchor:"middle",fill:v.label})}),i&&l.push({kind:"text",part:"color-legend-title",x:b(a-6),y:b(n.y+5),text:i,anchor:"end",baseline:"middle",fill:v.label}),l}function we(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var ze=e=>e.id??e.name??e.series,Bt=e=>e.seriesId??e.series;function H(e,n){let t=!1;return n.id!==void 0&&(t=!0,ze(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,Bt(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 U(e){let n={},t=ze(e);t!==void 0&&(n.id=t);let r=Bt(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ae=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Pe(e,n,t){let r=we(e),i=U(n),o=r.some(s=>H(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!H(n,s)):[...r,i]}var bn=.2;function xn(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 yn=(e,n)=>e.kind==="text"?{...e,fill:v.grid}:{...e,opacity:(e.opacity??1)*n};function Re(e,n){let t=we(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:we(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=u=>!i||r.some(p=>H(u,p))?!0:o.highlighted==="series"?r.some(p=>p.series!==void 0&&H(u,{series:p.series})):!1,l=u=>{if(!i||o.faded==="none"||a(u))return!1;if(o.faded==="series"){let p=i.series;return p!==void 0&&H(u,{series:p})}return!0},d=e.shapes.map(u=>{let p=u.item;if(!p||p.legend)return u;if(t.some(g=>H(p,g))){let g=xn(u);g&&s.push(g)}return l(p)?yn(u,bn):u});return s.length?{...e,shapes:[...d,...s]}:{...e,shapes:d}}function re(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 Be=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Nt(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 ue(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Nt(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Ne(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[Nt(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 Fe(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!Be(r.plot,n,t))return[];let i=Ne(e,n),{rows:o}=ue(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...ye(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function De(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 Fe(e,i,t.plot.y+8)}function Ge(e,n,t,r,i){if(!e.tooltip)return{lines:[],shapes:[]};if(e.hit?.crosshair){let{x:l,y:d}=re(t,r,i,e.width,e.height);if(Be(e.hit.plot,l,d)){let u=ue(e,l),p=Ne(e,l);if(u&&p)return{lines:u.rows,shapes:[p]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?q(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(l=>l.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function Ft(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),l=s&&s.tooltipFormatter?q(s,e)?.item:void 0,d=l&&s?.tooltipFormatter?.(l)||a&&Array.from(a.children).find(C=>C.tagName.toLowerCase()==="title")?.textContent;if(!d)return[];let u=s?.tooltipAnchored?q(s,e):void 0,p=u?s?.shapes[u.index]:void 0,{x:g,y:$}=p?de(p):re(n,t,r,i,o);return ye(g,$,d,i,o,s?.tooltipPlacement)}function je(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=re(t,r,i,e.width,e.height),a=Fe(e,o,s);if(a.length>0)return a}return Ft(n,t,r,i,e.width,e.height,e)}function He(e,n){let t=q(e,n);return t&&!t.item.legend?U(t.item):null}var vn=(e,n)=>{let{x:t,y:r}=de(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 _e(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!vn(i,n))continue;let o=U(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var Ve=e=>({kind:"rect",part:"selection-box",x:b(e.x),y:b(e.y),width:b(e.width),height:b(e.height),fill:v.focus,opacity:.12,stroke:v.focus}),ke=(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 Dt(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 Ze(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}=de(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Dt(n,o,a))continue;let l=U(i.item),d=JSON.stringify(l);t.has(d)||(t.add(d),r.push(l))}return r}var Ee=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${b(n.x)} ${b(n.y)}`).join("L")}`:"",fill:v.focus,fillOpacity:.12,stroke:v.focus,dash:"4 3"}),Me=6;function We(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-Me||n>i.x1+Me))return Math.abs(n-i.x0)<=Me?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=Me?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ue(e,n,t){let r=e.edit;return Gt(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function qe(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(l=>l.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 Gt(r,{bar:o,mode:s},i*a)}function Gt(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 Ke(e,n,t){let r=e.edit,i=r.scale(t.start),o=r.scale(t.end);return{kind:"rect",part:"edit-ghost",x:b(Math.min(i,o)),y:b(n.bar.y),width:b(Math.max(1,Math.abs(o-i))),height:b(n.bar.height),fill:v.focus,opacity:.25,stroke:v.focus,rx:2}}var wn=64,Mn=e=>Math.max(1,Math.min(wn,e));function Ye(e,n,t,r){let i=n>0?.8:1.25,o=Mn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[l,d]=e.view.center,u=(t-(s.x+s.width/2))/a,p=(r-(s.y+s.height/2))/a,g=e.view.zoom/o;return{center:[l+u*(1-g),e.fromY(e.toY(d)-p*(1-g))],zoom:o}}function Xe(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 q(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 Se=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function de(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 Qe(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}=de(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?ye(b(o),b(s),a,e.width,e.height):[]]}function Je(e,n,t){let r=Se(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,ne=(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}},jt=(e,n)=>!e||e.start<=0&&e.end>=n;function et(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,a=Math.max(te,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!jt(e.zoom,e.count)?ne(r,a,e.count):void 0;let l=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),d=r+l*o;return ne(d-l*a,a,e.count)}function tt(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 ne(n.start+s*i-s*o,o,e.count)}function nt(e,n,t){let r=n.end-n.start,i=e.plot.width/Math.max(1,r);return ne(n.start-t/i,r,e.count)}function rt(e,n,t){let r=e.brush;if(!r||!Be(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:ne(s-o/2,o,e.count)}}function it(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 ne(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 st(e,n){switch(n.type){case"svg":return Promise.resolve(ot(e,n.label,n.resolve));case"csv":return Promise.resolve(Zt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=ot(e,n.label,n.resolve);return Vt(t,e.width,e.height,n.scale,n.background)}}}var _=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),he=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${_(String(t))}"`).join("");function Ht(e){let n=e.title?`<title>${_(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${he([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${he([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${he([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${he([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${he([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]])}>${_(e.text)}</text>`}}function _t(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${_(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="${_(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function ot(e,n,t){let r=_t(e)+e.shapes.map(Ht).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="${_(n)}" font-family="${_(v.fontFamily)}" font-size="${_(v.fontSize)}"><title>${_(n)}</title>${r}</svg>`}function Vt(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"})),l=new Image;l.onload=()=>{URL.revokeObjectURL(a);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(l,0,0,d.width,d.height),d.toBlob(p=>p?o(p):s(new Error("toBlob failed")),"image/png")},l.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},l.src=a})}function Zt(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 at(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 l=["",...a.slice(1).map(u=>u.replace(/:\s[^:]*$/,""))],d=r.rows.map(u=>[u[0],...u.slice(1).map(p=>p.slice(p.lastIndexOf(": ")+2))]);return[l,...d]}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(l=>l[a]!==void 0)),s=(a,l)=>a[l]===void 0?"":String(a[l]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(l=>s(a,l)))]}var lt=new Map;function $e(e){let n=lt.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&<.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return lt.set(e,{group:i,listeners:t}),i}var Et='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',ct=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Et}{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){${Et}{animation:none;transition:none}}`;function ut(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}var K=8,dt=e=>e.geometry.type==="Polygon"?e.geometry.coordinates:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.flat():[],Ut=e=>e.geometry.type==="Point"?[e.geometry.coordinates]:e.geometry.type==="MultiPoint"?e.geometry.coordinates:[],qt=e=>e.geometry.type==="LineString"?[e.geometry.coordinates]:e.geometry.type==="MultiLineString"?e.geometry.coordinates:[],Wt=e=>[...dt(e).flat(),...Ut(e),...qt(e).flat()],kn=e=>Math.log(Math.tan(Math.PI/4+Math.max(-85,Math.min(85,e))*Math.PI/360)),ie=e=>e!==void 0&&Number.isFinite(e[0])&&Number.isFinite(e[1]);function ht(e){let n=[],t=e.features.filter(c=>{let L=Wt(c).some(ie);return L||n.push({code:"invalid-geometry",severity:"warning",message:`Feature "${c.name}" has no valid coordinates and was dropped.`,itemId:c.id??c.name}),L}),r=Tt(e,t.length===0);if(r)return{...r,issues:n};let i=wt(e.format),{width:o,height:s}=be(e),a=Ct(e),l=ve(e.colorLegend).bottom,d=ve(e.colorLegend).right,u=e.projection==="mercator"?kn:c=>c,p=t.filter(c=>dt(c).length>0),g=(p.length?p:t).flatMap(c=>Wt(c).filter(ie)),[$,C]=g.length?D(g.map(c=>c[0])):[0,1],[S,m]=g.length?D(g.map(c=>u(c[1]))):[0,1],y=Math.min((o-d-2*K)/Math.max(1e-9,C-$),(s-a-l-2*K)/Math.max(1e-9,m-S)),w={x:K,y:a+K,width:o-d-2*K,height:s-a-l-2*K},O=Math.max(1,Math.min(64,e.view?.zoom??1)),P=y*O,A=e.view?.center?[e.view.center[0],u(e.view.center[1])]:[($+C)/2,(S+m)/2],T=w.x+w.width/2-A[0]*P,Z=w.y+w.height/2+A[1]*P,J=([c,L])=>({x:b(T+c*P),y:b(Z-u(L)*P)}),z=c=>{let{x:L,y:j}=J(c);return`${L} ${j}`},G=xe(e,0,e.color),R=Pt(e.colorScale,t.map(c=>c.value),G,void 0,i),E=[],Kt=p.map(c=>{let L=dt(c);if(e.labels&&L.length){let W=L.reduce((ee,yt)=>yt.length>ee.length?yt:ee),[me,en]=D(W.map(ee=>ee[0])),[tn,nn]=D(W.map(ee=>u(ee[1])));E.push(Lt(b(T+((me+en)/2-$)*P),b(Z+(m-(tn+nn)/2)*P),c.name,{part:"region-label",anchor:"middle",baseline:"middle",fill:"var(--skdx-color-text-default)"}))}let j=c.color!==void 0?{fill:c.color,opacity:1}:R.color(c.value),pe=`${c.name}${X(c.value)?`: ${i(c.value)}`:""}`;return{kind:"path",part:"region",d:L.map(W=>`M${W.filter(ie).map(z).join("L")}Z`).join(""),fill:j?.fill??v.grid,opacity:j?.opacity??.6,stroke:"var(--skdx-color-surface-default)",title:pe,item:{label:pe,id:c.id??c.name,name:c.name,value:c.value}}}),pt=[...e.lines??[],...t.flatMap(c=>qt(c).map(L=>({id:c.id,name:c.name,coordinates:L,value:c.value,color:c.color??(X(c.value)?R.color(c.value)?.fill:void 0),dash:void 0})))].filter(c=>c.coordinates.filter(ie).length>=2),[,mt]=D(pt.map(c=>c.value)),Yt=pt.map((c,L)=>{let j=`${c.name}${X(c.value)?`: ${i(c.value)}`:""}`;return{kind:"path",part:"route",d:`M${c.coordinates.filter(ie).map(z).join("L")}`,stroke:c.color??xe(e,2),strokeWidth:X(c.value)&&mt>0?1+3*Math.sqrt(Math.max(0,c.value)/mt):1.5,strokeLinecap:"round",strokeLinejoin:"round",dash:c.dash,opacity:.85,title:j,item:{label:j,id:c.id??c.name,name:c.name,index:L,value:c.value}}}),ft=[...e.points??[],...t.flatMap(c=>Ut(c).map(L=>({id:c.id,name:c.name,coordinates:L,value:c.value,color:c.color??(X(c.value)?R.color(c.value)?.fill:void 0)})))].filter(c=>ie(c.coordinates)),[gt,Xt]=e.sizeRange??[3,14],[,bt]=D(ft.map(c=>c.value)),Qt=ft.map((c,L)=>{let{x:j,y:pe}=J(c.coordinates),W=Number.isFinite(c.value)&&bt>0,me=`${c.name}${W?`: ${i(c.value)}`:""}`;return{kind:"circle",part:W?"bubble":"point",cx:j,cy:pe,r:b(W?Math.max(gt,Math.sqrt(Math.max(0,c.value)/bt)*Xt):gt),fill:c.color??xe(e,1),stroke:"var(--skdx-color-surface-default)",opacity:.85,title:me,item:{label:me,id:c.id??c.name,name:c.name,index:L,value:c.value}}}),Jt=e.colorLegend?Rt(R,d?{x:w.x+w.width+12,y:w.y,width:d,height:w.height}:{x:K,y:s-l+8,width:o-2*K,height:l},ve(e.colorLegend).options):[],xt=e.projection==="mercator"?c=>Math.atan(Math.exp(c))*360/Math.PI-90:c=>c;return{...Le(e,o,s),shapes:[...Kt,...Yt,...E,...Qt,...Jt],issues:n,map:{view:{center:[A[0],xt(A[1])],zoom:O},bounds:{minLon:$,maxLon:C,minLat:S,maxLat:m},plot:w,scale:P,toY:u,fromY:xt}}}import{css as Sn,html as Y,LitElement as $n,nothing as I,svg as N}from"lit";import{property as f,state as F}from"lit/decorators.js";import{ifDefined as k}from"lit/directives/if-defined.js";var Cn={fromAttribute:()=>!1},x=class extends $n{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=[Ve(ke(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=[Ee(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ue(r,i.gantt,o-i.x),this.overlay=[Ke(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(Xe(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(tt(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"?nt(r.hit,i.zoom,o-i.x):it(r.hit,i.grab,i.zoom,o-i.x));return}if(r.tooltipPortal){let{lines:o,shapes:s}=Ge(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=je(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(He(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ue(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=q(r,t.target)?.item.legend,a=this.canEdit(r)?We(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 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 l=r.hit;if(!(!l||!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:l.zoom,grab:"pinch",distance:Math.abs(d-u)||1}}else{let d=rt(l,i,o);if(d)this.drag={x:i,y:o,zoom:d.zoom,grab:d.grab},d.zoom!==l.zoom&&this.setZoom(d.zoom);else if(this.zoomable&&i>=l.plot.x&&i<=l.plot.x+l.plot.width&&o>=l.plot.y&&o<=l.plot.y+l.plot.height)this.drag={x:i,y:o,zoom:l.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(_e(o,ke(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ze(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 l=r.map.plot;if(i<l.x||i>l.x+l.width||o<l.y||o>l.y+l.height)return;t.preventDefault(),this.setView(Ye(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=et(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=q(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)?qe(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Je(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?U(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:l,error:d,emptyMessage:u,description:p,decorative:g,animated:$,responsive:C,highlighted:S,highlightScope:m,accessibleTable:y}=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:l,error:d,emptyMessage:u,description:p,decorative:g,highlighted:S===void 0?this.highlightState:S,highlightScope:m,accessibleTable:y,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&&$e(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=$e(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&&Ae(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(Pe(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 re(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&&H(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?st(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Re(Oe(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),l=this.canEdit(o),d=this.brushing(),u=s||a||l||d,p=!o.decorative&&Se(o).length>0,g=o.description?`${r}-desc`:void 0,$=ut(o),C=at(o,this.accessibleTable),S=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,m=this.portal;return Y`<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
4
|
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
5
|
width=${o.width}
|
|
@@ -30,9 +30,9 @@ var nn=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var h=(e,n,t
|
|
|
30
30
|
<title>${i}</title>
|
|
31
31
|
${o.description?N`<desc id=${k(g)}>${o.description}</desc>`:I}
|
|
32
32
|
${$?N`<style>${ct}</style>`:I} ${In(o)}
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
33
|
+
${Ce(o.shapes)}
|
|
34
|
+
${Ce(this.tip.length||!this.crossState?this.tip:De(o,this.crossState))}
|
|
35
|
+
${Ce(Qe(o,this.focused))} ${Ce(this.overlay)}
|
|
36
36
|
</svg>
|
|
37
37
|
${m?Y`<div
|
|
38
38
|
role="tooltip"
|
|
@@ -106,4 +106,4 @@ var nn=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var h=(e,n,t
|
|
|
106
106
|
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
107
|
font-weight: bold;
|
|
108
108
|
}
|
|
109
|
-
`,h([f({type:Number})],x.prototype,"width",2),h([f({type:Number})],x.prototype,"height",2),h([f()],x.prototype,"label",2),h([f({type:Boolean,reflect:!0})],x.prototype,"legend",2),h([f({type:Boolean,attribute:"no-tooltip",converter:Cn})],x.prototype,"tooltip",2),h([f({attribute:!1})],x.prototype,"format",2),h([f({attribute:!1})],x.prototype,"palette",2),h([f({attribute:!1})],x.prototype,"hiddenSeries",2),h([f({attribute:!1})],x.prototype,"selected",2),h([f({attribute:"selection-mode"})],x.prototype,"selectionMode",2),h([f({attribute:!1})],x.prototype,"highlighted",2),h([f({attribute:!1})],x.prototype,"highlightScope",2),h([f({type:Boolean,reflect:!0})],x.prototype,"loading",2),h([f()],x.prototype,"error",2),h([f({attribute:"empty-message"})],x.prototype,"emptyMessage",2),h([f()],x.prototype,"description",2),h([f({type:Boolean,reflect:!0})],x.prototype,"decorative",2),h([f({type:Boolean,attribute:"accessible-table"})],x.prototype,"accessibleTable",2),h([f({attribute:!1})],x.prototype,"zoom",2),h([f({attribute:!1})],x.prototype,"view",2),h([f({type:Boolean,reflect:!0})],x.prototype,"zoomable",2),h([f({type:Boolean,reflect:!0})],x.prototype,"editable",2),h([f({attribute:"sync-id"})],x.prototype,"syncId",2),h([f({type:Boolean,attribute:"cross-filter"})],x.prototype,"crossFilter",2),h([f({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],x.prototype,"animated",2),h([f({type:Boolean,reflect:!0})],x.prototype,"responsive",2),h([F()],x.prototype,"tip",2),h([F()],x.prototype,"overlay",2),h([F()],x.prototype,"portal",2),h([F()],x.prototype,"measured",2),h([F()],x.prototype,"viewState",2),h([F()],x.prototype,"highlightState",2),h([F()],x.prototype,"crossState",2),h([F()],x.prototype,"focused",2),h([F()],x.prototype,"hiddenState",2),h([F()],x.prototype,"zoomState",2),h([F()],x.prototype,"selectedState",2);var M=class extends x{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:l,labels:d,curve:u,connectNulls:p,nulls:g,stacked:$,stackOffset:C,orientation:S,radius:m,barGap:y,barWidth:w,sort:O,transform:P,transforms:A,bins:T,binWidth:Z,binDomain:J,binMode:z,sampling:G,brush:R,crosshair:E}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:d,curve:u,connectNulls:p,nulls:g,stacked:$,stackOffset:C,orientation:S,radius:m,barGap:y,barWidth:w,sort:O,transform:P,transforms:A,bins:T,binWidth:Z,binDomain:J,binMode:z,sampling:G,brush:R,crosshair:E}}};h([f({attribute:!1})],M.prototype,"series",2),h([f({attribute:!1})],M.prototype,"categories",2),h([f({attribute:!1})],M.prototype,"xAxis",2),h([f({attribute:!1})],M.prototype,"yAxis",2),h([f({attribute:!1})],M.prototype,"rightAxis",2),h([f({attribute:!1})],M.prototype,"references",2),h([f({attribute:!1})],M.prototype,"annotations",2),h([f({type:Boolean,reflect:!0})],M.prototype,"labels",2),h([f()],M.prototype,"curve",2),h([f({type:Boolean,attribute:"connect-nulls"})],M.prototype,"connectNulls",2),h([f()],M.prototype,"nulls",2),h([f({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],M.prototype,"stacked",2),h([f({attribute:"stack-offset"})],M.prototype,"stackOffset",2),h([f()],M.prototype,"orientation",2),h([f({type:Number})],M.prototype,"radius",2),h([f({type:Number,attribute:"bar-gap"})],M.prototype,"barGap",2),h([f({type:Number,attribute:"bar-width"})],M.prototype,"barWidth",2),h([f()],M.prototype,"sort",2),h([f()],M.prototype,"transform",2),h([f({attribute:!1})],M.prototype,"transforms",2),h([f({type:Number})],M.prototype,"bins",2),h([f({type:Number,attribute:"bin-width"})],M.prototype,"binWidth",2),h([f({attribute:!1})],M.prototype,"binDomain",2),h([f({attribute:"bin-mode"})],M.prototype,"binMode",2),h([f({attribute:!1})],M.prototype,"sampling",2),h([f({type:Boolean,reflect:!0})],M.prototype,"brush",2),h([f({type:Boolean,reflect:!0})],M.prototype,"crosshair",2);var In=e=>e.defs&&e.defs.length?N`<defs>${e.defs.map(n=>N`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>N`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${k(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:I
|
|
109
|
+
`,h([f({type:Number})],x.prototype,"width",2),h([f({type:Number})],x.prototype,"height",2),h([f()],x.prototype,"label",2),h([f({type:Boolean,reflect:!0})],x.prototype,"legend",2),h([f({type:Boolean,attribute:"no-tooltip",converter:Cn})],x.prototype,"tooltip",2),h([f({attribute:!1})],x.prototype,"format",2),h([f({attribute:!1})],x.prototype,"palette",2),h([f({attribute:!1})],x.prototype,"hiddenSeries",2),h([f({attribute:!1})],x.prototype,"selected",2),h([f({attribute:"selection-mode"})],x.prototype,"selectionMode",2),h([f({attribute:!1})],x.prototype,"highlighted",2),h([f({attribute:!1})],x.prototype,"highlightScope",2),h([f({type:Boolean,reflect:!0})],x.prototype,"loading",2),h([f()],x.prototype,"error",2),h([f({attribute:"empty-message"})],x.prototype,"emptyMessage",2),h([f()],x.prototype,"description",2),h([f({type:Boolean,reflect:!0})],x.prototype,"decorative",2),h([f({type:Boolean,attribute:"accessible-table"})],x.prototype,"accessibleTable",2),h([f({attribute:!1})],x.prototype,"zoom",2),h([f({attribute:!1})],x.prototype,"view",2),h([f({type:Boolean,reflect:!0})],x.prototype,"zoomable",2),h([f({type:Boolean,reflect:!0})],x.prototype,"editable",2),h([f({attribute:"sync-id"})],x.prototype,"syncId",2),h([f({type:Boolean,attribute:"cross-filter"})],x.prototype,"crossFilter",2),h([f({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],x.prototype,"animated",2),h([f({type:Boolean,reflect:!0})],x.prototype,"responsive",2),h([F()],x.prototype,"tip",2),h([F()],x.prototype,"overlay",2),h([F()],x.prototype,"portal",2),h([F()],x.prototype,"measured",2),h([F()],x.prototype,"viewState",2),h([F()],x.prototype,"highlightState",2),h([F()],x.prototype,"crossState",2),h([F()],x.prototype,"focused",2),h([F()],x.prototype,"hiddenState",2),h([F()],x.prototype,"zoomState",2),h([F()],x.prototype,"selectedState",2);var M=class extends x{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:l,labels:d,curve:u,connectNulls:p,nulls:g,stacked:$,stackOffset:C,orientation:S,radius:m,barGap:y,barWidth:w,sort:O,transform:P,transforms:A,bins:T,binWidth:Z,binDomain:J,binMode:z,sampling:G,brush:R,crosshair:E}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:d,curve:u,connectNulls:p,nulls:g,stacked:$,stackOffset:C,orientation:S,radius:m,barGap:y,barWidth:w,sort:O,transform:P,transforms:A,bins:T,binWidth:Z,binDomain:J,binMode:z,sampling:G,brush:R,crosshair:E}}};h([f({attribute:!1})],M.prototype,"series",2),h([f({attribute:!1})],M.prototype,"categories",2),h([f({attribute:!1})],M.prototype,"xAxis",2),h([f({attribute:!1})],M.prototype,"yAxis",2),h([f({attribute:!1})],M.prototype,"rightAxis",2),h([f({attribute:!1})],M.prototype,"references",2),h([f({attribute:!1})],M.prototype,"annotations",2),h([f({type:Boolean,reflect:!0})],M.prototype,"labels",2),h([f()],M.prototype,"curve",2),h([f({type:Boolean,attribute:"connect-nulls"})],M.prototype,"connectNulls",2),h([f()],M.prototype,"nulls",2),h([f({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],M.prototype,"stacked",2),h([f({attribute:"stack-offset"})],M.prototype,"stackOffset",2),h([f()],M.prototype,"orientation",2),h([f({type:Number})],M.prototype,"radius",2),h([f({type:Number,attribute:"bar-gap"})],M.prototype,"barGap",2),h([f({type:Number,attribute:"bar-width"})],M.prototype,"barWidth",2),h([f()],M.prototype,"sort",2),h([f()],M.prototype,"transform",2),h([f({attribute:!1})],M.prototype,"transforms",2),h([f({type:Number})],M.prototype,"bins",2),h([f({type:Number,attribute:"bin-width"})],M.prototype,"binWidth",2),h([f({attribute:!1})],M.prototype,"binDomain",2),h([f({attribute:"bin-mode"})],M.prototype,"binMode",2),h([f({attribute:!1})],M.prototype,"sampling",2),h([f({type:Boolean,reflect:!0})],M.prototype,"brush",2),h([f({type:Boolean,reflect:!0})],M.prototype,"crosshair",2);var In=e=>e.defs&&e.defs.length?N`<defs>${e.defs.map(n=>N`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>N`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${k(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:I,Ce=e=>N`${e.map((n,t)=>{let r=n.title?N`<title>${n.title}</title>`:I,i=n.item?t:void 0;switch(n.kind){case"path":return N`<path data-skdx-part=${n.part} data-skdx-i=${k(i)} d=${n.d} fill=${n.fill??"none"} stroke=${k(n.stroke)} stroke-width=${k(n.strokeWidth)} stroke-linecap=${k(n.strokeLinecap)} stroke-linejoin=${k(n.strokeLinejoin)} stroke-dasharray=${k(n.dash)} opacity=${k(n.opacity)} fill-opacity=${k(n.fillOpacity)}>${r}</path>`;case"rect":return N`<rect data-skdx-part=${n.part} data-skdx-i=${k(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${k(n.rx)} fill=${n.fill} stroke=${k(n.stroke)} fill-opacity=${k(n.opacity)}>${r}</rect>`;case"line":return N`<line data-skdx-part=${n.part} data-skdx-i=${k(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${k(n.strokeWidth)} stroke-dasharray=${k(n.dash)} opacity=${k(n.opacity)}>${r}</line>`;case"circle":return N`<circle data-skdx-part=${n.part} data-skdx-i=${k(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${k(n.stroke)} opacity=${k(n.opacity)}>${r}</circle>`;case"text":return N`<text data-skdx-part=${n.part} data-skdx-i=${k(i)} x=${n.x} y=${n.y} text-anchor=${k(n.anchor)} dominant-baseline=${k(n.baseline)} fill=${k(n.fill)} font-weight=${k(n.weight)} pointer-events=${k(i===void 0?"none":void 0)} transform=${k(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var B=class extends x{constructor(){super(...arguments);this.features=[];this.labels=!1}render(){let{features:t,color:r,colorScale:i,colorLegend:o,projection:s,points:a,lines:l,sizeRange:d,labels:u}=this;return this.root(ht({...this.sized(),features:t,color:r,colorScale:i,colorLegend:o,projection:s,points:a,lines:l,sizeRange:d,labels:u}),"map",this.label??"Map")}};h([V({attribute:!1})],B.prototype,"features",2),h([V()],B.prototype,"color",2),h([V({attribute:!1})],B.prototype,"colorScale",2),h([V({attribute:!1})],B.prototype,"colorLegend",2),h([V()],B.prototype,"projection",2),h([V({attribute:!1})],B.prototype,"points",2),h([V({attribute:!1})],B.prototype,"lines",2),h([V({attribute:!1})],B.prototype,"sizeRange",2),h([V({type:Boolean,reflect:!0})],B.prototype,"labels",2),B=h([Tn("skdx-map-chart")],B);export{B as SkdxMapChart};
|
package/dist/marimekko.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var se=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Nt=Object.prototype.hasOwnProperty;var Dt=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},Gt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Rt(n))!Nt.call(e,i)&&i!==t&&se(e,i,{get:()=>n[i],enumerable:!(r=ct(n,i))||r.enumerable});return e};var Ft=e=>Gt(se({},"__esModule",{value:!0}),e),h=(e,n,t,r)=>{for(var i=r>1?void 0:r?ct(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&&se(n,t,i),i};var on={};Dt(on,{SkdxMarimekkoChart:()=>R});module.exports=Ft(on);var H=require("lit/decorators.js");var lt=e=>Number(e.toPrecision(12)),jt,Vt=e=>(jt??(jt=new Intl.NumberFormat)).format(lt(e)),Ht=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 Y(e){if(e===void 0)return Vt;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=l=>i?p=>l(p)+i:l,a=l=>r===void 0?l===void 0?{}:{maximumFractionDigits:l}:{minimumFractionDigits:r,maximumFractionDigits:r},c=l=>{let p=new Intl.NumberFormat(t,l);return s(g=>p.format(lt(g)))},u=l=>{let p=new Intl.DateTimeFormat(t,o?{...l,timeZone:o}:l);return g=>p.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(Ht)}}function ce([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function le(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,a=Math.floor(e/s)*s,c=Math.ceil(n/s)*s,u=[];for(let l=a;l<=c+s/2;l+=s)u.push(dt(l));return u}var dt=e=>Number(e.toPrecision(12)),y=e=>Number(e.toFixed(2)),J=e=>typeof e=="number"&&Number.isFinite(e);var q=1e3,X=60*q,Q=60*X,ae=24*Q,cn=[q,5*q,15*q,30*q,X,5*X,15*X,30*X,Q,3*Q,6*Q,12*Q,ae,2*ae,7*ae,14*ae];function ut(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 a of i)o.push(dt(a*10**s));return o.filter(s=>s>=e/1.0001&&s<=n*1.0001)}var Zt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,_t=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Wt={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Et(e,n,t){return e.replace(_t,(r,i,o)=>{let s=Wt[i];if(s===void 0)return i+o;let c=(o.match(Zt)??[]).map((u,l)=>{let p=Number(u);if(s===-1)return String(p+n);if(s===-2)return String(p+t);let g=l%s;return s===7?g===5?String(p+n):g===6?String(p+t):u:String(g%2===0?p+n:p+t)});return i+c.join(" ")})}var ht=(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:Et(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)"))),M={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 pt=(e,n)=>n??ye[e%ye.length];var ee={top:16,right:16,bottom:32,left:48};function ft(e,n,t=ee){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 te(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function mt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var de=20,Ut=120,gt=e=>{let n=te(e);return n&&(n.position==="left"||n.position==="right")?n.width??Ut:0},we=(e,n=600,t=300)=>({width:(e.width??n)-gt(e),height:(e.height??t)-(te(e)?.position==="bottom"?de:0)}),bt=e=>{let n=te(e);return n&&(n.position===void 0||n.position==="top")?de:0},W=6.5,ke=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:pt(n)),xt=(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,l=e.length-u.length,p=r.interactive??!0,g=o,I=i,k=(d,b,x,S)=>{let T=(b?18:4)+d.length*W;g>o&&(s||g+T>n-8)&&(g=o,I+=de),b&&a.push({kind:"rect",part:"legend-swatch",x:g,y:I-5,width:10,height:10,fill:b,opacity:S?.3:void 0,item:x}),a.push({kind:"text",part:"legend-label",x:g+(b?14:0),y:I,text:d,baseline:"middle",fill:S?M.grid:M.label,item:x}),g+=T+12};for(let d of u){let b=t.includes(d.name),x=p?{label:d.name,series:d.name,legend:!0}:void 0;k(r.formatter?.(d.name)??d.name,d.color,x,b)}return l>0&&k(`+${l} more`,void 0,void 0,!1),r.align==="end"?Kt(a,n):a}function Kt(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*W)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var Yt=(e,n,t={})=>new Set(ve(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Me(e,n,t,r=[]){let i=te(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=mt(e),a=o?.position==="bottom",c=gt(e),u=e.hiddenSeries??[],l=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):[],p=a?Yt(r,n,o):0;return{width:n+c,height:a?t+Math.max(1,p)*de: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:l}}function $e(e){let n=e.legendOffset;if(!n)return e;let t=[...ht(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 ue(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(g=>g.length))*W+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},l=Math.max(0,Math.min(r-a,u.x)),p=Math.max(0,Math.min(i-c,u.y));return[{kind:"rect",part:"tooltip",x:y(l),y:y(p),width:y(a),height:c,fill:"var(--skdx-color-surface-raised)",stroke:M.axis,rx:3},...s.map((g,I)=>({kind:"text",part:"tooltip-label",x:y(l+6),y:y(p+11+I*16),text:g,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&I===0?"bold":void 0}))]}function yt([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,s=Y(o.format??i),a=o.min??e,c=o.max??n;o.reversed&&(t=[t[1],t[0]]);let u={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let d=L=>Math.sign(L)*Math.sqrt(Math.abs(L)),b=o.nice===!1?[a,c]:le(a,c,o.ticks),x=o.min??b[0],S=o.max??b[b.length-1],T=ce([d(x),d(S)],t),A=L=>T(d(L)),B=le(x,S,o.ticks).filter(L=>L>=x-1e-9&&L<=S+1e-9);return{...u,scale:A,domain:[x,S],format:s,ticks:(B.length>=2?B:[x,S]).map(L=>({pos:y(A(L)),label:s(L)})),zero:y(A(Math.min(Math.max(0,x),S)))}}if(o.scale==="log"){let d=Math.max(a,Number.EPSILON),b=Math.max(c,d),x=ut(d,b),S=[Math.log10(d),Math.log10(b)],T=ce(S,t),A=B=>T(Math.log10(Math.max(B,Number.EPSILON)));return{...u,scale:A,domain:S,format:s,ticks:x.map(B=>({pos:y(A(B)),label:s(B)})),zero:y(t[0])}}let l=le(a,c,o.ticks),p=[o.min??(o.nice===!1?a:l[0]),o.max??(o.nice===!1?c:l[l.length-1])],g=ce(p,t),I=l.filter(d=>d>=p[0]-1e-9&&d<=p[1]+1e-9),k=(I.length>=2?I:[p[0],p[1]]).map(d=>({pos:y(g(d)),label:s(d)}));return{...u,scale:g,domain:p,format:s,ticks:k,zero:y(g(Math.min(Math.max(0,p[0]),p[1])))}}function vt(e,n){if(e.length<2)return e;let t=e.reduce((i,o)=>Math.max(i,o.label.length),0)*W+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)}function wt(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)":M.label}),{...Me(e,o,s),shapes:c,tooltip:!1}}function kt(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,s=t.x+t.width,a=t.y+t.height,c=[],u=n.grid??!0,l=(k,d)=>d?{kind:"line",part:"grid",x1:k.pos,x2:k.pos,y1:t.y,y2:a,stroke:M.grid}:{kind:"line",part:"grid",x1:t.x,x2:s,y1:k.pos,y2:k.pos,stroke:M.grid},p=n.x?.tickRotation??0,g=(k,d,b,x)=>p?P(k,d,b,{part:x,anchor:p<0?"end":"start",baseline:"middle",rotate:p}):P(k,d,b,{part:x,anchor:"middle"}),I=(k,d,b,x,S)=>{for(let T of k)c.push(d==="x"?{kind:"line",part:"tick",x1:T.pos,x2:T.pos,y1:b,y2:y(b+x*S),stroke:M.axis}:{kind:"line",part:"tick",x1:b,x2:y(b+x*S),y1:T.pos,y2:T.pos,stroke:M.axis})};if(n.categoryGrid)for(let k of r)c.push(l(k,!n.horizontal));if(n.horizontal){let k=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(u)for(let d of i)c.push(l(d,!0));k[0]?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:a,stroke:M.axis});for(let d of k){let b=d.position==="top"||d.position==="right",x=y(b?t.y-d.offset:a+d.offset),S=b||d.offset>0;d.showLine&&S&&c.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:x,y2:x,stroke:M.axis}),d.showTicks&&I(d.ticks,"x",x,b?-1:1,d.tickSize??4);let T=y(b?x-8:x+20);for(let A of d.ticks)c.push(b?P(A.pos,T,A.label,{part:"x-label-top",anchor:"middle"}):g(A.pos,T,A.label,"x-label"));d.label&&c.push(S?P(4,T,d.label,{part:"axis-title",anchor:"start",baseline:b?void 0:"middle"}):P(4,t.y-6,d.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:a,stroke:M.axis}),n.x?.showTicks&&I(r,"y",n.rtl?s:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let d of r)c.push(n.rtl?P(s+8,d.pos,d.label,{part:"y-label",anchor:"start",baseline:"middle"}):P(t.x-8,d.pos,d.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(u)for(let d of i)c.push(l(d,!1));n.y?.showLine!==!1&&c.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:o,y2:o,stroke:M.axis});let k=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 d of k){let b=d.position==="left",x=b?t.x-d.offset:s+d.offset,S=b?"y-label":"y-label-right";d.showLine&&c.push({kind:"line",part:"axis",x1:y(x),x2:y(x),y1:t.y,y2:a,stroke:M.axis}),d.showTicks&&I(d.ticks,"y",y(x),b?-1:1,d.tickSize??4);for(let T of d.ticks)c.push(P(y(b?x-8:x+8),T.pos,T.label,{part:S,anchor:b?"end":"start",baseline:"middle"}));d.label&&c.push(P(y(b?d.offset===0?4:Math.max(4,x-40):d.offset===0?e.width-4:Math.min(e.width-4,x+40)),t.y-6,d.label,{part:"axis-title",anchor:b?"start":"end"}))}n.x?.showTicks&&I(r,"x",a,1,n.x.tickSize??4);for(let d of r)c.push(g(d.pos,a+(p?12:20),d.label,"x-label"))}return n.xLabel&&c.push(P(y(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&c.push(P(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),c}var P=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:M.label,...r});function he(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Se=e=>e.id??e.name??e.series,Mt=e=>e.seriesId??e.series;function D(e,n){let t=!1;return n.id!==void 0&&(t=!0,Se(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 j(e){let n={},t=Se(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 Ce=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Ie(e,n,t){let r=he(e),i=j(n),o=r.some(s=>D(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!D(n,s)):[...r,i]}var qt=.2;function Xt(e){let n=M.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 Qt=(e,n)=>e.kind==="text"?{...e,fill:M.grid}:{...e,opacity:(e.opacity??1)*n};function Te(e,n){let t=he(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:he(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=l=>!i||r.some(p=>D(l,p))?!0:o.highlighted==="series"?r.some(p=>p.series!==void 0&&D(l,{series:p.series})):!1,c=l=>{if(!i||o.faded==="none"||a(l))return!1;if(o.faded==="series"){let p=i.series;return p!==void 0&&D(l,{series:p})}return!0},u=e.shapes.map(l=>{let p=l.item;if(!p||p.legend)return l;if(t.some(g=>D(p,g))){let g=Xt(l);g&&s.push(g)}return c(p)?Qt(l,qt):l});return s.length?{...e,shapes:[...u,...s]}:{...e,shapes:u}}function K(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 ze=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function $t(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 ne(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=$t(t,n),i=t.rows[r]??[];return{index:r,rows:e.axisTooltipFormatter?.(i,r)??i}}function Oe(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=t.xs[$t(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:M.axis,dash:"3 3"}}function Ae(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!ze(r.plot,n,t))return[];let i=Oe(e,n),{rows:o}=ne(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...ue(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Le(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 Ae(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}=K(t,r,i,e.width,e.height);if(ze(e.hit.plot,c,u)){let l=ne(e,c),p=Oe(e,c);if(l&&p)return{lines:l.rows,shapes:[p]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?V(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 St(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),c=s&&s.tooltipFormatter?V(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 l=s?.tooltipAnchored?V(s,e):void 0,p=l?s?.shapes[l.index]:void 0,{x:g,y:I}=p?re(p):K(n,t,r,i,o);return ue(g,I,u,i,o,s?.tooltipPlacement)}function Be(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=K(t,r,i,e.width,e.height),a=Ae(e,o,s);if(a.length>0)return a}return St(n,t,r,i,e.width,e.height,e)}function Re(e,n){let t=V(e,n);return t&&!t.item.legend?j(t.item):null}var Jt=(e,n)=>{let{x:t,y:r}=re(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 Ne(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!Jt(i,n))continue;let o=j(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var De=e=>({kind:"rect",part:"selection-box",x:y(e.x),y:y(e.y),width:y(e.width),height:y(e.height),fill:M.focus,opacity:.12,stroke:M.focus}),fe=(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 Ct(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 Ge(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}=re(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Ct(n,o,a))continue;let c=j(i.item),u=JSON.stringify(c);t.has(u)||(t.add(u),r.push(c))}return r}var Fe=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${y(n.x)} ${y(n.y)}`).join("L")}`:"",fill:M.focus,fillOpacity:.12,stroke:M.focus,dash:"4 3"}),pe=6;function je(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-pe||n>i.x1+pe))return Math.abs(n-i.x0)<=pe?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=pe?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function Ve(e,n,t){let r=e.edit;return It(r,n,r.invert(n.bar.x0+t)-r.invert(n.bar.x0))}function He(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 It(r,{bar:o,mode:s},i*a)}function It(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 Ze(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:M.focus,opacity:.25,stroke:M.focus,rx:2}}var en=64,tn=e=>Math.max(1,Math.min(en,e));function _e(e,n,t,r){let i=n>0?.8:1.25,o=tn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[c,u]=e.view.center,l=(t-(s.x+s.width/2))/a,p=(r-(s.y+s.height/2))/a,g=e.view.zoom/o;return{center:[c+l*(1-g),e.fromY(e.toY(u)-p*(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 V(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 me=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function re(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 Ee(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=M.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*W+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}=re(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?ue(y(o),y(s),a,e.width,e.height):[]]}function Ue(e,n,t){let r=me(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 E=2,U=(e,n,t)=>{let r=Math.max(E,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},Tt=(e,n)=>!e||e.start<=0&&e.end>=n;function Ke(e,n,t){if(e.count<=E||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(E,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!Tt(e.zoom,e.count)?U(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 U(u-c*a,a,e.count)}function Ye(e,n,t,r){let i=n.end-n.start,o=Math.max(E,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 U(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 U(n.start-t/i,r,e.count)}function Xe(e,n,t){let r=e.brush;if(!r||!ze(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:U(s-o/2,o,e.count)}}function Qe(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 U(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-E,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+E,Math.round(t.end+o)));return{start:t.start,end:s}}function et(e,n){switch(n.type){case"svg":return Promise.resolve(Je(e,n.label,n.resolve));case"csv":return Promise.resolve(Lt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=Je(e,n.label,n.resolve);return At(t,e.width,e.height,n.scale,n.background)}}}var G=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),ie=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${G(String(t))}"`).join("");function zt(e){let n=e.title?`<title>${G(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${ie([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${ie([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${ie([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${ie([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${ie([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]])}>${G(e.text)}</text>`}}function Ot(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${G(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="${G(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function Je(e,n,t){let r=Ot(e)+e.shapes.map(zt).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="${G(n)}" font-family="${G(M.fontFamily)}" font-size="${G(M.fontSize)}"><title>${G(n)}</title>${r}</svg>`}function At(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 l=u.getContext("2d");if(!l)return s(new Error("canvas 2d context unavailable"));i&&(l.fillStyle=i,l.fillRect(0,0,u.width,u.height)),l.drawImage(c,0,0,u.width,u.height),u.toBlob(p=>p?o(p):s(new Error("toBlob failed")),"image/png")},c.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},c.src=a})}function Lt(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 tt(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(l=>l.replace(/:\s[^:]*$/,""))],u=r.rows.map(l=>[l[0],...l.slice(1).map(p=>p.slice(p.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 nt=new Map;function ge(e){let n=nt.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&&nt.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return nt.set(e,{group:i,listeners:t}),i}var Pt='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',rt=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Pt}{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){${Pt}{animation:none;transition:none}}`;function it(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function ot(e){let n=[],t=e.segments.map((m,O)=>typeof m=="string"?{name:m,id:m,color:ke(e,O)}:{name:m.name,id:m.id??m.name,color:ke(e,O,m.color)}),r=t.map(m=>!xt(e,m.name)),i=(m,O)=>{let z=m.values[O];return z==null?0:!J(z)||z<0?(n.push({code:J(z)?"negative-value":"invalid-value",severity:"warning",message:`"${t[O]?.name}" in "${m.name}" is ${J(z)?"negative":"not a number"}; drawn as zero.`,itemId:m.id??m.name}),0):z},o=e.data.map((m,O)=>{let z=t.map((_,F)=>r[F]?i(m,F):0),Z=z.reduce((_,F)=>_+F,0),N=J(m.total)&&m.total>=0?m.total:Z;return{c:m,ci:O,values:z,sum:Z,total:N}}),s=o.reduce((m,O)=>m+O.total,0),a=wt(e,s<=0);if(a)return{...a,issues:n};let c=Y(e.format),u=Y(e.xAxis?.format??e.format),{width:l,height:p}=we(e),g=ft(l,p,{...ee,top:ee.top+bt(e),bottom:ee.bottom+(e.xAxis?.label?14:0)+(e.xAxis?.format?14:0)}),I=Math.max(0,Math.min(.2,e.gap??.01))*g.width,k=Math.max(0,o.length-1),d=Math.max(0,g.width-I*k),b=yt([0,1],[g.y+g.height,g.y],{format:{style:"percent"}}),x=Me(e,l,p,t.map(m=>({name:m.name,color:m.color}))),S=g.x,T=o.map(m=>{let O=m.total/s*d,z={x:S,w:O};return S+=O+I,{...m,...z}}),A=T.map(m=>({pos:y(m.x+m.w/2),label:m.c.name})),B=kt({...x,plot:g,xTicks:vt(A,g.width),yTicks:b.ticks,baseline:b.zero},{xLabel:e.xAxis?.label,yLabel:void 0});if(e.xAxis?.format)for(let m of T)m.w>24&&B.push(P(y(m.x+m.w/2),g.y+g.height+34,u(m.total),{part:"x-total",anchor:"middle"}));let L=[],oe=[];for(let m of T){let O=0;m.values.forEach((z,Z)=>{let N=t[Z];if(z<=0||m.sum<=0)return;let _=z/m.sum,F=b.scale(O+_),Bt=b.scale(O);O+=_;let st=`${Math.round(_*100)}%`,at=`${N.name}, ${m.c.name}: ${c(z)} (${st}) \xB7 column ${u(m.total)}`,xe=Math.max(0,Bt-F);L.push({kind:"rect",part:"cell",x:y(m.x),y:y(F),width:y(m.w),height:y(xe),fill:N.color,stroke:"var(--skdx-color-surface-default)",title:at,item:{label:at,id:`${m.c.id??m.c.name}:${N.name}`,series:N.name,seriesId:N.id,category:m.c.name,index:m.ci,value:z}}),e.labels&&xe>14&&m.w>24&&oe.push(P(y(m.x+m.w/2),y(F+xe/2),st,{part:"cell-label",anchor:"middle",baseline:"middle",fill:"var(--skdx-color-text-on-accent)"}))})}return{...x,shapes:[...B,...L,...oe,...x.shapes],issues:n}}var v=require("lit"),f=require("lit/decorators.js"),$=require("lit/directives/if-defined.js");var nn={fromAttribute:()=>!1},w=class extends v.LitElement{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=[De(fe(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=[Fe(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=Ve(r,i.gantt,o-i.x),this.overlay=[Ze(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(Ye(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):Qe(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=Be(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(Re(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ne(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=V(r,t.target)?.item.legend,a=this.canEdit(r)?je(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,l]=[...this.pointers.values()];this.drag={x:(u+l)/2,y:o,zoom:c.zoom,grab:"pinch",distance:Math.abs(u-l)||1}}else{let u=Xe(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(Ne(o,fe(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ge(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(_e(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=Ke(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=V(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)?He(r,this.focused,t):void 0;if(i){t.preventDefault(),this.emit("skdx-task-change",i);return}let o=Ue(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?j(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:l,description:p,decorative:g,animated:I,responsive:k,highlighted:d,highlightScope:b,accessibleTable:x}=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:I,responsive:k,legend:i,tooltip:o,format:s,palette:a,loading:c,error:u,emptyMessage:l,description:p,decorative:g,highlighted:d===void 0?this.highlightState:d,highlightScope:b,accessibleTable:x,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&&ge(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=ge(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&&Ce(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(Ie(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 K(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&&D(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?et(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Te($e(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let x of o.issues??[])this.emit("skdx-data-issue",x)}let s=this.canZoom(o),a=this.canPan(o),c=this.canEdit(o),u=this.brushing(),l=s||a||c||u,p=!o.decorative&&me(o).length>0,g=o.description?`${r}-desc`:void 0,I=it(o),k=tt(o,this.accessibleTable),d=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,b=this.portal;return v.html`<svg
|
|
1
|
+
"use strict";var se=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Gt=Object.prototype.hasOwnProperty;var Ft=(e,n)=>{for(var t in n)se(e,t,{get:n[t],enumerable:!0})},jt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Dt(n))!Gt.call(e,i)&&i!==t&&se(e,i,{get:()=>n[i],enumerable:!(r=lt(n,i))||r.enumerable});return e};var Ht=e=>jt(se({},"__esModule",{value:!0}),e),h=(e,n,t,r)=>{for(var i=r>1?void 0:r?lt(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&&se(n,t,i),i};var sn={};Ft(sn,{SkdxMarimekkoChart:()=>R});module.exports=Ht(sn);var Z=require("lit/decorators.js");var ct=e=>Number(e.toPrecision(12)),Vt,Zt=e=>(Vt??(Vt=new Intl.NumberFormat)).format(ct(e)),_t=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 Y(e){if(e===void 0)return Zt;if(typeof e=="function")return e;let{style:n,locale:t,digits:r,unit:i="",timeZone:o}=e,s=c=>i?p=>c(p)+i:c,a=c=>r===void 0?c===void 0?{}:{maximumFractionDigits:c}:{minimumFractionDigits:r,maximumFractionDigits:r},l=c=>{let p=new Intl.NumberFormat(t,c);return s(b=>p.format(ct(b)))},u=c=>{let p=new Intl.DateTimeFormat(t,o?{...c,timeZone:o}:c);return b=>p.format(b)};switch(n){case"integer":return l({maximumFractionDigits:0});case"decimal":return l(a(2));case"percent":return l({style:"percent",...a(0)});case"currency":return l({style:"currency",currency:e.currency??"USD",...a()});case"compact":return l({notation:"compact",...a(1)});case"scientific":return l({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(_t)}}function le([e,n],[t,r]){let i=n-e;return o=>i===0?t:t+(o-e)/i*(r-t)}function ce(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,a=Math.floor(e/s)*s,l=Math.ceil(n/s)*s,u=[];for(let c=a;c<=l+s/2;c+=s)u.push(dt(c));return u}var dt=e=>Number(e.toPrecision(12)),y=e=>Number(e.toFixed(2)),J=e=>typeof e=="number"&&Number.isFinite(e);var q=1e3,X=60*q,Q=60*X,ae=24*Q,cn=[q,5*q,15*q,30*q,X,5*X,15*X,30*X,Q,3*Q,6*Q,12*Q,ae,2*ae,7*ae,14*ae];function ut(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 a of i)o.push(dt(a*10**s));return o.filter(s=>s>=e/1.0001&&s<=n*1.0001)}var Wt=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,Et=/([MLTHVCSQAZmlthvcsqaz])([^MLTHVCSQAZmlthvcsqaz]*)/g,Ut={M:2,L:2,T:2,C:6,S:4,Q:4,A:7,H:-1,V:-2};function Kt(e,n,t){return e.replace(Et,(r,i,o)=>{let s=Ut[i];if(s===void 0)return i+o;let l=(o.match(Wt)??[]).map((u,c)=>{let p=Number(u);if(s===-1)return String(p+n);if(s===-2)return String(p+t);let b=c%s;return s===7?b===5?String(p+n):b===6?String(p+t):u:String(b%2===0?p+n:p+t)});return i+l.join(" ")})}var ht=(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:Kt(r.d,n,t)}}});var ve=["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)"))),M={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 pt=(e,n)=>n??ve[e%ve.length];var ee={top:16,right:16,bottom:32,left:48};function ft(e,n,t=ee){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 te(e){let n=e.legend;if(n)return n===!0?{}:n.enabled===!1?void 0:n}function mt(e){let n=e.tooltip;return n===void 0||n===!0?{enabled:!0}:n===!1?{enabled:!1}:{...n,enabled:n.enabled??!0}}var de=20,Yt=120,bt=e=>{let n=te(e);return n&&(n.position==="left"||n.position==="right")?n.width??Yt:0},ue=(e,n=600,t=300)=>({width:(e.width??n)-bt(e),height:(e.height??t)-(te(e)?.position==="bottom"?de:0)}),gt=(e,n,t)=>{let r=te(e);return!r||!(r.position===void 0||r.position==="top")?0:(n?Math.max(1,yt(n,t??ue(e).width,r)):1)*de},j=6.5,ke=(e,n,t)=>t??(e.palette&&e.palette.length>0?e.palette[n%e.palette.length]:pt(n)),xt=(e,n)=>e.hiddenSeries?.includes(n)??!1;function we(e,n,t=[],r={},i=10,o=8,s=!1){let a=[],l=r.maxItems,u=l!==void 0&&l>=0&&e.length>l?e.slice(0,l):e,c=e.length-u.length,p=r.interactive??!0,b=o,I=i,k=(d,g,x,S)=>{let T=(g?18:4)+d.length*j;b>o&&(s||b+T>n-8)&&(b=o,I+=de),g&&a.push({kind:"rect",part:"legend-swatch",x:b,y:I-5,width:10,height:10,fill:g,opacity:S?.3:void 0,item:x}),a.push({kind:"text",part:"legend-label",x:b+(g?14:0),y:I,text:d,baseline:"middle",fill:S?M.grid:M.label,item:x}),b+=T+12};for(let d of u){let g=t.includes(d.name),x=p?{label:d.name,series:d.name,legend:!0}:void 0;k(r.formatter?.(d.name)??d.name,d.color,x,g)}return c>0&&k(`+${c} more`,void 0,void 0,!1),r.align==="end"?qt(a,n):a}function qt(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*j)),s=n-8-o;for(let a of i)r.push({...a,x:a.x+s})}return r}var yt=(e,n,t={})=>new Set(we(e,n,[],t).flatMap(r=>r.kind==="text"?[r.y]:[])).size;function Me(e,n,t,r=[]){let i=te(e),o=i&&e.direction==="rtl"&&i.align===void 0?{...i,align:"end"}:i,s=mt(e),a=o?.position==="bottom",l=bt(e),u=e.hiddenSeries??[],c=o?l?we(r,1/0,u,o,10,(o.position==="right"?n:0)+8,!0):we(r,n,u,o,a?t+10:10):[],p=a?yt(r,n,o):0;return{width:n+l,height:a?t+Math.max(1,p)*de:t,legendOffset:o?.position==="left"?l: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:c}}function $e(e){let n=e.legendOffset;if(!n)return e;let t=[...ht(e.shapes.filter(l=>!l.part.startsWith("legend-")),n,0),...e.shapes.filter(l=>l.part.startsWith("legend-"))],r=l=>({...l,x:l.x+n}),i=e.hit?{...e.hit,plot:r(e.hit.plot),xs:e.hit.xs.map(l=>l+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:l=>o.scale(l)+n,invert:l=>o.invert(l-n),bars:o.bars.map(l=>({...l,x0:l.x0+n,x1:l.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 he(e,n,t,r,i,o="auto"){let s=Array.isArray(t)?t:[t],a=Math.max(...s.map(b=>b.length))*j+12,l=6+s.length*16,u=o==="top"?{x:e-a/2,y:n-l-8}:o==="bottom"?{x:e-a/2,y:n+8}:o==="left"?{x:e-a-8,y:n-l/2}:o==="right"?{x:e+8,y:n-l/2}:{x:e+12,y:n-l-6},c=Math.max(0,Math.min(r-a,u.x)),p=Math.max(0,Math.min(i-l,u.y));return[{kind:"rect",part:"tooltip",x:y(c),y:y(p),width:y(a),height:l,fill:"var(--skdx-color-surface-raised)",stroke:M.axis,rx:3},...s.map((b,I)=>({kind:"text",part:"tooltip-label",x:y(c+6),y:y(p+11+I*16),text:b,baseline:"middle",fill:"var(--skdx-color-text-default)",weight:s.length>1&&I===0?"bold":void 0}))]}function vt([e,n],t,r=!1,i){let o=typeof r=="boolean"?{scale:r?"log":"linear"}:r,s=Y(o.format??i),a=o.min??e,l=o.max??n;o.reversed&&(t=[t[1],t[0]]);let u={id:o.id,position:o.position,options:o};if(o.scale==="sqrt"){let d=L=>Math.sign(L)*Math.sqrt(Math.abs(L)),g=o.nice===!1?[a,l]:ce(a,l,o.ticks),x=o.min??g[0],S=o.max??g[g.length-1],T=le([d(x),d(S)],t),O=L=>T(d(L)),B=ce(x,S,o.ticks).filter(L=>L>=x-1e-9&&L<=S+1e-9);return{...u,scale:O,domain:[x,S],format:s,ticks:(B.length>=2?B:[x,S]).map(L=>({pos:y(O(L)),label:s(L)})),zero:y(O(Math.min(Math.max(0,x),S)))}}if(o.scale==="log"){let d=Math.max(a,Number.EPSILON),g=Math.max(l,d),x=ut(d,g),S=[Math.log10(d),Math.log10(g)],T=le(S,t),O=B=>T(Math.log10(Math.max(B,Number.EPSILON)));return{...u,scale:O,domain:S,format:s,ticks:x.map(B=>({pos:y(O(B)),label:s(B)})),zero:y(t[0])}}let c=ce(a,l,o.ticks),p=[o.min??(o.nice===!1?a:c[0]),o.max??(o.nice===!1?l:c[c.length-1])],b=le(p,t),I=c.filter(d=>d>=p[0]-1e-9&&d<=p[1]+1e-9),k=(I.length>=2?I:[p[0],p[1]]).map(d=>({pos:y(b(d)),label:s(d)}));return{...u,scale:b,domain:p,format:s,ticks:k,zero:y(b(Math.min(Math.max(0,p[0]),p[1])))}}function wt(e,n){if(e.length<2)return e;let t=e.reduce((i,o)=>Math.max(i,o.label.length),0)*j+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)}function kt(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}=ue(e,t,r),a=i==="error"?e.error:i==="loading"?"Loading\u2026":e.emptyMessage??"No data available",l=[];return i==="loading"&&l.push({kind:"rect",part:"skeleton",x:0,y:0,width:o,height:s,fill:"var(--skdx-color-surface-sunken)",rx:4}),l.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)":M.label}),{...Me(e,o,s),shapes:l,tooltip:!1}}var Mt=(e,n,t)=>{let r=n.length*j/2;return e+r>t?"end":e-r<0?"start":"middle"};function $t(e,n={}){let{plot:t,xTicks:r,yTicks:i,baseline:o}=e,s=t.x+t.width,a=t.y+t.height,l=[],u=n.grid??!0,c=(k,d)=>d?{kind:"line",part:"grid",x1:k.pos,x2:k.pos,y1:t.y,y2:a,stroke:M.grid}:{kind:"line",part:"grid",x1:t.x,x2:s,y1:k.pos,y2:k.pos,stroke:M.grid},p=n.x?.tickRotation??0,b=(k,d,g,x)=>p?P(k,d,g,{part:x,anchor:p<0?"end":"start",baseline:"middle",rotate:p}):P(k,d,g,{part:x,anchor:Mt(k,g,e.width)}),I=(k,d,g,x,S)=>{for(let T of k)l.push(d==="x"?{kind:"line",part:"tick",x1:T.pos,x2:T.pos,y1:g,y2:y(g+x*S),stroke:M.axis}:{kind:"line",part:"tick",x1:g,x2:y(g+x*S),y1:T.pos,y2:T.pos,stroke:M.axis})};if(n.categoryGrid)for(let k of r)l.push(c(k,!n.horizontal));if(n.horizontal){let k=n.axes??[{ticks:i,position:"bottom",offset:0,label:n.yLabel,...n.y}];if(u)for(let d of i)l.push(c(d,!0));k[0]?.showLine!==!1&&l.push({kind:"line",part:"axis",x1:o,x2:o,y1:t.y,y2:a,stroke:M.axis});for(let d of k){let g=d.position==="top"||d.position==="right",x=y(g?t.y-d.offset:a+d.offset),S=g||d.offset>0;d.showLine&&S&&l.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:x,y2:x,stroke:M.axis}),d.showTicks&&I(d.ticks,"x",x,g?-1:1,d.tickSize??4);let T=y(g?x-8:x+20);for(let O of d.ticks)l.push(g?P(O.pos,T,O.label,{part:"x-label-top",anchor:Mt(O.pos,O.label,e.width)}):b(O.pos,T,O.label,"x-label"));d.label&&l.push(S?P(4,T,d.label,{part:"axis-title",anchor:"start",baseline:g?void 0:"middle"}):P(4,t.y-6,d.label,{part:"axis-title",anchor:"start"}))}n.x?.showLine&&l.push({kind:"line",part:"axis",x1:n.rtl?s:t.x,x2:n.rtl?s:t.x,y1:t.y,y2:a,stroke:M.axis}),n.x?.showTicks&&I(r,"y",n.rtl?s:t.x,n.rtl?1:-1,n.x.tickSize??4);for(let d of r)l.push(n.rtl?P(s+8,d.pos,d.label,{part:"y-label",anchor:"start",baseline:"middle"}):P(t.x-8,d.pos,d.label,{part:"y-label",anchor:"end",baseline:"middle"}))}else{if(u)for(let d of i)l.push(c(d,!1));n.y?.showLine!==!1&&l.push({kind:"line",part:"axis",x1:t.x,x2:s,y1:o,y2:o,stroke:M.axis});let k=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 d of k){let g=d.position==="left",x=g?t.x-d.offset:s+d.offset,S=g?"y-label":"y-label-right";d.showLine&&l.push({kind:"line",part:"axis",x1:y(x),x2:y(x),y1:t.y,y2:a,stroke:M.axis}),d.showTicks&&I(d.ticks,"y",y(x),g?-1:1,d.tickSize??4);for(let T of d.ticks)l.push(P(y(g?x-8:x+8),T.pos,T.label,{part:S,anchor:g?"end":"start",baseline:"middle"}));d.label&&l.push(P(y(g?d.offset===0?4:Math.max(4,x-40):d.offset===0?e.width-4:Math.min(e.width-4,x+40)),t.y-6,d.label,{part:"axis-title",anchor:g?"start":"end"}))}n.x?.showTicks&&I(r,"x",a,1,n.x.tickSize??4);for(let d of r)l.push(b(d.pos,a+(p?12:20),d.label,"x-label"))}return n.xLabel&&l.push(P(y(t.x+t.width/2),e.height-4,n.xLabel,{part:"axis-title",anchor:"middle"})),n.horizontal&&n.rightLabel&&l.push(P(e.width-4,t.y-6,n.rightLabel,{part:"axis-title",anchor:"end"})),l}var P=(e,n,t,r={})=>({kind:"text",part:"label",x:e,y:n,text:t,fill:M.label,...r});function pe(e){return e==null?[]:(Array.isArray(e)?e:[e]).map(t=>typeof t=="object"?t:{id:t})}var Se=e=>e.id??e.name??e.series,St=e=>e.seriesId??e.series;function D(e,n){let t=!1;return n.id!==void 0&&(t=!0,Se(e)!==n.id&&e.id!==n.id&&e.name!==n.id)||n.series!==void 0&&(t=!0,St(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 H(e){let n={},t=Se(e);t!==void 0&&(n.id=t);let r=St(e);return r!==void 0&&e.series!==void 0&&(n.series=r),e.index!==void 0&&(n.index=e.index),n}var Ce=(e,n)=>e.id===n.id&&e.series===n.series&&e.index===n.index&&e.category===n.category;function Ie(e,n,t){let r=pe(e),i=H(n),o=r.some(s=>D(n,s));return t==="single"?o?[]:[i]:o?r.filter(s=>!D(n,s)):[...r,i]}var Xt=.2;function Qt(e){let n=M.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 Jt=(e,n)=>e.kind==="text"?{...e,fill:M.grid}:{...e,opacity:(e.opacity??1)*n};function Te(e,n){let t=pe(n.selected),r=n.highlighted===void 0||n.highlighted===null?[]:pe(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=c=>!i||r.some(p=>D(c,p))?!0:o.highlighted==="series"?r.some(p=>p.series!==void 0&&D(c,{series:p.series})):!1,l=c=>{if(!i||o.faded==="none"||a(c))return!1;if(o.faded==="series"){let p=i.series;return p!==void 0&&D(c,{series:p})}return!0},u=e.shapes.map(c=>{let p=c.item;if(!p||p.legend)return c;if(t.some(b=>D(p,b))){let b=Qt(c);b&&s.push(b)}return l(p)?Jt(c,Xt):c});return s.length?{...e,shapes:[...u,...s]}:{...e,shapes:u}}function K(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 ze=(e,n,t)=>n>=e.x&&n<=e.x+e.width&&t>=e.y&&t<=e.y+e.height;function Ct(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 ne(e,n){let t=e.hit;if(!t||t.xs.length===0)return;let r=Ct(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[Ct(t,n)];return{kind:"line",part:"crosshair",x1:r,x2:r,y1:t.plot.y,y2:t.plot.y+t.plot.height,stroke:M.axis,dash:"3 3"}}function Oe(e,n,t){let r=e.hit;if(!r||!r.crosshair||r.xs.length===0||!ze(r.plot,n,t))return[];let i=Ae(e,n),{rows:o}=ne(e,n),s=e.tooltipAnchored?r.plot.y+8:t;return[i,...he(i.x1,s,o,e.width,e.height,e.tooltipPlacement)]}function Le(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 Oe(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:l,y:u}=K(t,r,i,e.width,e.height);if(ze(e.hit.plot,l,u)){let c=ne(e,l),p=Ae(e,l);if(c&&p)return{lines:c.rows,shapes:[p]}}}let o=n?.closest?.("[data-skdx-part]"),s=e.tooltipFormatter?V(e,n)?.item:void 0,a=s&&e.tooltipFormatter?.(s)||o&&Array.from(o.children).find(l=>l.tagName.toLowerCase()==="title")?.textContent;return a?{lines:Array.isArray(a)?a:[a],shapes:[]}:{lines:[],shapes:[]}}function It(e,n,t,r,i,o,s){let a=e?.closest?.("[data-skdx-part]"),l=s&&s.tooltipFormatter?V(s,e)?.item:void 0,u=l&&s?.tooltipFormatter?.(l)||a&&Array.from(a.children).find(k=>k.tagName.toLowerCase()==="title")?.textContent;if(!u)return[];let c=s?.tooltipAnchored?V(s,e):void 0,p=c?s?.shapes[c.index]:void 0,{x:b,y:I}=p?re(p):K(n,t,r,i,o);return he(b,I,u,i,o,s?.tooltipPlacement)}function Be(e,n,t,r,i){if(!e.tooltip)return[];if(e.hit?.crosshair){let{x:o,y:s}=K(t,r,i,e.width,e.height),a=Oe(e,o,s);if(a.length>0)return a}return It(n,t,r,i,e.width,e.height,e)}function Re(e,n){let t=V(e,n);return t&&!t.item.legend?H(t.item):null}var en=(e,n)=>{let{x:t,y:r}=re(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 Ne(e,n){let t=new Set,r=[];for(let i of e.shapes){if(!i.item||i.item.legend||i.part==="anchor"||!en(i,n))continue;let o=H(i.item),s=JSON.stringify(o);t.has(s)||(t.add(s),r.push(o))}return r}var De=e=>({kind:"rect",part:"selection-box",x:y(e.x),y:y(e.y),width:y(e.width),height:y(e.height),fill:M.focus,opacity:.12,stroke:M.focus}),me=(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 Tt(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 Ge(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}=re(i),a=i.kind==="circle"?i.cy:i.kind==="rect"?i.y+i.height/2:s;if(!Tt(n,o,a))continue;let l=H(i.item),u=JSON.stringify(l);t.has(u)||(t.add(u),r.push(l))}return r}var Fe=e=>({kind:"path",part:"selection-lasso",d:e.length?`M${e.map(n=>`${y(n.x)} ${y(n.y)}`).join("L")}`:"",fill:M.focus,fillOpacity:.12,stroke:M.focus,dash:"4 3"}),fe=6;function je(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-fe||n>i.x1+fe))return Math.abs(n-i.x0)<=fe?{bar:i,mode:"start"}:Math.abs(n-i.x1)<=fe?{bar:i,mode:"end"}:{bar:i,mode:"move"}}}function He(e,n,t){let r=e.edit;return zt(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(l=>l.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 zt(r,{bar:o,mode:s},i*a)}function zt(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 Ze(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:M.focus,opacity:.25,stroke:M.focus,rx:2}}var tn=64,nn=e=>Math.max(1,Math.min(tn,e));function _e(e,n,t,r){let i=n>0?.8:1.25,o=nn(e.view.zoom*i);if(o===e.view.zoom)return e.view;let{plot:s,scale:a}=e,[l,u]=e.view.center,c=(t-(s.x+s.width/2))/a,p=(r-(s.y+s.height/2))/a,b=e.view.zoom/o;return{center:[l+c*(1-b),e.fromY(e.toY(u)-p*(1-b))],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 V(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 be=e=>e.shapes.flatMap((n,t)=>n.item&&!n.item.legend?[t]:[]);function re(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 Ee(e,n){let t=n===null?void 0:e.shapes[n];if(!t)return[];let r=M.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*j+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}=re(t),a=t.item&&e.tooltipFormatter?.(t.item)||(t.item?.label??t.title??"");return[i,...a?he(y(o),y(s),a,e.width,e.height):[]]}function Ue(e,n,t){let r=be(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 E=2,U=(e,n,t)=>{let r=Math.max(E,Math.min(t,Math.round(n))),i=Math.max(0,Math.min(t-r,Math.round(e)));return{start:i,end:i+r}},At=(e,n)=>!e||e.start<=0&&e.end>=n;function Ke(e,n,t){if(e.count<=E||!e.plot.width)return;let{start:r,end:i}=e.zoom,o=i-r,s=n>0?1.25:.8,a=Math.max(E,Math.min(e.count,Math.round(o*s)));if(a===o)return n>0&&!At(e.zoom,e.count)?U(r,a,e.count):void 0;let l=Math.max(0,Math.min(1,(t-e.plot.x)/e.plot.width)),u=r+l*o;return U(u-l*a,a,e.count)}function Ye(e,n,t,r){let i=n.end-n.start,o=Math.max(E,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 U(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 U(n.start-t/i,r,e.count)}function Xe(e,n,t){let r=e.brush;if(!r||!ze(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:U(s-o/2,o,e.count)}}function Qe(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 U(t.start+o,t.end-t.start,e.count);if(n==="left")return{start:Math.max(0,Math.min(t.end-E,Math.round(t.start+o))),end:t.end};let s=Math.min(e.count,Math.max(t.start+E,Math.round(t.end+o)));return{start:t.start,end:s}}function et(e,n){switch(n.type){case"svg":return Promise.resolve(Je(e,n.label,n.resolve));case"csv":return Promise.resolve(Bt(n.rows));case"png":{if(typeof document>"u"||typeof Image>"u")return Promise.reject(new Error("PNG export needs a browser"));let t=Je(e,n.label,n.resolve);return Pt(t,e.width,e.height,n.scale,n.background)}}}var G=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,"""),ie=e=>e.filter(([,n])=>n!==void 0&&n!=="").map(([n,t])=>` ${n}="${G(String(t))}"`).join("");function Ot(e){let n=e.title?`<title>${G(e.title)}</title>`:"",t=["data-skdx-part",e.part];switch(e.kind){case"path":return`<path${ie([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${ie([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${ie([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${ie([t,["cx",e.cx],["cy",e.cy],["r",e.r],["fill",e.fill],["stroke",e.stroke]])}>${n}</circle>`;case"text":return`<text${ie([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]])}>${G(e.text)}</text>`}}function Lt(e){let n=e.defs??[];return n.length===0?"":`<defs>${n.map(t=>`<linearGradient id="${G(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="${G(r.color)}"${r.opacity===void 0?"":` stop-opacity="${r.opacity}"`}/>`).join("")}</linearGradient>`).join("")}</defs>`}function Je(e,n,t){let r=Lt(e)+e.shapes.map(Ot).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="${G(n)}" font-family="${G(M.fontFamily)}" font-size="${G(M.fontSize)}"><title>${G(n)}</title>${r}</svg>`}function Pt(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"})),l=new Image;l.onload=()=>{URL.revokeObjectURL(a);let u=document.createElement("canvas");u.width=Math.round(n*r),u.height=Math.round(t*r);let c=u.getContext("2d");if(!c)return s(new Error("canvas 2d context unavailable"));i&&(c.fillStyle=i,c.fillRect(0,0,u.width,u.height)),c.drawImage(l,0,0,u.width,u.height),u.toBlob(p=>p?o(p):s(new Error("toBlob failed")),"image/png")},l.onerror=()=>{URL.revokeObjectURL(a),s(new Error("svg could not be decoded"))},l.src=a})}function Bt(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 tt(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 l=["",...a.slice(1).map(c=>c.replace(/:\s[^:]*$/,""))],u=r.rows.map(c=>[c[0],...c.slice(1).map(p=>p.slice(p.lastIndexOf(": ")+2))]);return[l,...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(l=>l[a]!==void 0)),s=(a,l)=>a[l]===void 0?"":String(a[l]);return[o.map(a=>a[0]?.toUpperCase()+a.slice(1)),...i.map(a=>o.map(l=>s(a,l)))]}var nt=new Map;function ge(e){let n=nt.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&&nt.delete(e)}},publish(o,s){Object.assign(r,o);for(let a of t)a(o,s)}};return nt.set(e,{group:i,listeners:t}),i}var Rt='[data-skdx-part]:not([data-skdx-part^="tooltip"]):not([data-skdx-part="focus"]):not([data-skdx-part="crosshair"])',rt=`@keyframes skdx-in{from{opacity:0}to{opacity:1}}${Rt}{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){${Rt}{animation:none;transition:none}}`;function it(e){let n=e.animate;return n&&e.shapes.length<=1500?`${n}ms`:void 0}function ot(e){let n=[],t=e.segments.map((m,A)=>typeof m=="string"?{name:m,id:m,color:ke(e,A)}:{name:m.name,id:m.id??m.name,color:ke(e,A,m.color)}),r=t.map(m=>!xt(e,m.name)),i=(m,A)=>{let z=m.values[A];return z==null?0:!J(z)||z<0?(n.push({code:J(z)?"negative-value":"invalid-value",severity:"warning",message:`"${t[A]?.name}" in "${m.name}" is ${J(z)?"negative":"not a number"}; drawn as zero.`,itemId:m.id??m.name}),0):z},o=e.data.map((m,A)=>{let z=t.map((W,F)=>r[F]?i(m,F):0),_=z.reduce((W,F)=>W+F,0),N=J(m.total)&&m.total>=0?m.total:_;return{c:m,ci:A,values:z,sum:_,total:N}}),s=o.reduce((m,A)=>m+A.total,0),a=kt(e,s<=0);if(a)return{...a,issues:n};let l=Y(e.format),u=Y(e.xAxis?.format??e.format),{width:c,height:p}=ue(e),b=ft(c,p,{...ee,top:ee.top+gt(e),bottom:ee.bottom+(e.xAxis?.label?14:0)+(e.xAxis?.format?14:0)}),I=Math.max(0,Math.min(.2,e.gap??.01))*b.width,k=Math.max(0,o.length-1),d=Math.max(0,b.width-I*k),g=vt([0,1],[b.y+b.height,b.y],{format:{style:"percent"}}),x=Me(e,c,p,t.map(m=>({name:m.name,color:m.color}))),S=b.x,T=o.map(m=>{let A=m.total/s*d,z={x:S,w:A};return S+=A+I,{...m,...z}}),O=T.map(m=>({pos:y(m.x+m.w/2),label:m.c.name})),B=$t({...x,plot:b,xTicks:wt(O,b.width),yTicks:g.ticks,baseline:g.zero},{xLabel:e.xAxis?.label,yLabel:void 0});if(e.xAxis?.format)for(let m of T)m.w>24&&B.push(P(y(m.x+m.w/2),b.y+b.height+34,u(m.total),{part:"x-total",anchor:"middle"}));let L=[],oe=[];for(let m of T){let A=0;m.values.forEach((z,_)=>{let N=t[_];if(z<=0||m.sum<=0)return;let W=z/m.sum,F=g.scale(A+W),Nt=g.scale(A);A+=W;let st=`${Math.round(W*100)}%`,at=`${N.name}, ${m.c.name}: ${l(z)} (${st}) \xB7 column ${u(m.total)}`,ye=Math.max(0,Nt-F);L.push({kind:"rect",part:"cell",x:y(m.x),y:y(F),width:y(m.w),height:y(ye),fill:N.color,stroke:"var(--skdx-color-surface-default)",title:at,item:{label:at,id:`${m.c.id??m.c.name}:${N.name}`,series:N.name,seriesId:N.id,category:m.c.name,index:m.ci,value:z}}),e.labels&&ye>14&&m.w>24&&oe.push(P(y(m.x+m.w/2),y(F+ye/2),st,{part:"cell-label",anchor:"middle",baseline:"middle",fill:"var(--skdx-color-text-on-accent)"}))})}return{...x,shapes:[...B,...L,...oe,...x.shapes],issues:n}}var v=require("lit"),f=require("lit/decorators.js"),$=require("lit/directives/if-defined.js");var rn={fromAttribute:()=>!1},w=class extends v.LitElement{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=[De(me(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=[Fe(i.points)];return}if(i?.grab==="edit"){if(!i.gantt)return;let{x:o}=this.viewBox(t,r);i.change=He(r,i.gantt,o-i.x),this.overlay=[Ze(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(Ye(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):Qe(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=Be(r,t.target,t.currentTarget,t.clientX,t.clientY);(o.length>0||this.tip.length>0)&&(this.tip=o)}if(this.highlight(Re(r,t.target)),this.syncId&&r.hit?.crosshair){let o=ne(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=V(r,t.target)?.item.legend,a=this.canEdit(r)?je(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 l=r.hit;if(!(!l||!this.canZoom(r))){if(this.pointers.set(t.pointerId,i),this.pointers.size===2){let[u,c]=[...this.pointers.values()];this.drag={x:(u+c)/2,y:o,zoom:l.zoom,grab:"pinch",distance:Math.abs(u-c)||1}}else{let u=Xe(l,i,o);if(u)this.drag={x:i,y:o,zoom:u.zoom,grab:u.grab},u.zoom!==l.zoom&&this.setZoom(u.zoom);else if(this.zoomable&&i>=l.plot.x&&i<=l.plot.x+l.plot.width&&o>=l.plot.y&&o<=l.plot.y+l.plot.height)this.drag={x:i,y:o,zoom:l.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(Ne(o,me(i.x,i.y,s,a))):i.grab==="lasso"?this.setSelected(Ge(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 l=r.map.plot;if(i<l.x||i>l.x+l.width||o<l.y||o>l.y+l.height)return;t.preventDefault(),this.setView(_e(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=Ke(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=V(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=Ue(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?H(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:l,error:u,emptyMessage:c,description:p,decorative:b,animated:I,responsive:k,highlighted:d,highlightScope:g,accessibleTable:x}=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:I,responsive:k,legend:i,tooltip:o,format:s,palette:a,loading:l,error:u,emptyMessage:c,description:p,decorative:b,highlighted:d===void 0?this.highlightState:d,highlightScope:g,accessibleTable:x,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&&ge(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=ge(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&&Ce(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(Ie(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 K(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&&D(o.item,t));return i<0?!1:(this.getSvgElement()?.focus(),this.focused=i,!0)}export(t){let r=this.layout;return r?et(r,{...t,label:t.label??this.label??this.localName}):Promise.reject(new Error("not rendered yet"))}root(t,r,i){this.join();let o=Te($e(t),this.sized());if(this.layout=o,o.issues!==this.reported){this.reported=o.issues;for(let x of o.issues??[])this.emit("skdx-data-issue",x)}let s=this.canZoom(o),a=this.canPan(o),l=this.canEdit(o),u=this.brushing(),c=s||a||l||u,p=!o.decorative&&be(o).length>0,b=o.description?`${r}-desc`:void 0,I=it(o),k=tt(o,this.accessibleTable),d=typeof this.accessibleTable=="object"&&this.accessibleTable.caption||i,g=this.portal;return v.html`<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
4
|
viewBox="0 0 ${o.width} ${o.height}"
|
|
5
5
|
width=${o.width}
|
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
role=${o.decorative?"presentation":"img"}
|
|
8
8
|
aria-hidden=${o.decorative?"true":v.nothing}
|
|
9
9
|
aria-label=${o.decorative?v.nothing:i}
|
|
10
|
-
aria-describedby=${(0,$.ifDefined)(
|
|
10
|
+
aria-describedby=${(0,$.ifDefined)(b)}
|
|
11
11
|
tabindex=${p?0:v.nothing}
|
|
12
12
|
data-skdx-chart=${r}
|
|
13
13
|
data-zoomable=${s||a?"":v.nothing}
|
|
14
14
|
data-brushing=${u&&!(s||a)?"":v.nothing}
|
|
15
|
-
data-editable=${
|
|
15
|
+
data-editable=${l?"":v.nothing}
|
|
16
16
|
style=${I?`--skdx-chart-duration:${I}`:v.nothing}
|
|
17
17
|
font-family=${M.fontFamily}
|
|
18
18
|
font-size=${M.fontSize}
|
|
19
|
-
@pointermove=${o.tooltip||
|
|
19
|
+
@pointermove=${o.tooltip||c?this.onPointerMove:v.nothing}
|
|
20
20
|
@pointerleave=${()=>{this.clearTip(),this.highlight(null)}}
|
|
21
|
-
@pointerdown=${
|
|
22
|
-
@pointerup=${
|
|
23
|
-
@pointercancel=${
|
|
21
|
+
@pointerdown=${c?this.onPointerDown:v.nothing}
|
|
22
|
+
@pointerup=${c?this.onPointerUp:v.nothing}
|
|
23
|
+
@pointercancel=${c?this.onPointerUp:v.nothing}
|
|
24
24
|
@wheel=${s||a?this.onWheel:v.nothing}
|
|
25
25
|
@dblclick=${s||a?()=>a?this.setView(void 0):this.setZoom(void 0):v.nothing}
|
|
26
26
|
@click=${this.onClick}
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
@blur=${()=>{this.focused=null,this.highlight(null)}}
|
|
29
29
|
>
|
|
30
30
|
<title>${i}</title>
|
|
31
|
-
${o.description?v.svg`<desc id=${(0,$.ifDefined)(
|
|
32
|
-
${I?v.svg`<style>${rt}</style>`:v.nothing} ${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
31
|
+
${o.description?v.svg`<desc id=${(0,$.ifDefined)(b)}>${o.description}</desc>`:v.nothing}
|
|
32
|
+
${I?v.svg`<style>${rt}</style>`:v.nothing} ${on(o)}
|
|
33
|
+
${xe(o.shapes)}
|
|
34
|
+
${xe(this.tip.length||!this.crossState?this.tip:Le(o,this.crossState))}
|
|
35
|
+
${xe(Ee(o,this.focused))} ${xe(this.overlay)}
|
|
36
36
|
</svg>
|
|
37
|
-
${
|
|
37
|
+
${g?v.html`<div
|
|
38
38
|
role="tooltip"
|
|
39
39
|
data-skdx-tooltip=${r}
|
|
40
|
-
style="left:${
|
|
40
|
+
style="left:${g.x+12}px;top:${g.y+12}px"
|
|
41
41
|
>
|
|
42
|
-
${
|
|
42
|
+
${g.lines.map(x=>v.html`<div>${x}</div>`)}
|
|
43
43
|
</div>`:v.nothing}
|
|
44
44
|
${k?v.html`<table data-skdx-table=${r}>
|
|
45
45
|
<caption>
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
[role='tooltip'] > :first-child:not(:only-child) {
|
|
107
107
|
font-weight: bold;
|
|
108
108
|
}
|
|
109
|
-
`,h([(0,f.property)({type:Number})],w.prototype,"width",2),h([(0,f.property)({type:Number})],w.prototype,"height",2),h([(0,f.property)()],w.prototype,"label",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"legend",2),h([(0,f.property)({type:Boolean,attribute:"no-tooltip",converter:
|
|
109
|
+
`,h([(0,f.property)({type:Number})],w.prototype,"width",2),h([(0,f.property)({type:Number})],w.prototype,"height",2),h([(0,f.property)()],w.prototype,"label",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"legend",2),h([(0,f.property)({type:Boolean,attribute:"no-tooltip",converter:rn})],w.prototype,"tooltip",2),h([(0,f.property)({attribute:!1})],w.prototype,"format",2),h([(0,f.property)({attribute:!1})],w.prototype,"palette",2),h([(0,f.property)({attribute:!1})],w.prototype,"hiddenSeries",2),h([(0,f.property)({attribute:!1})],w.prototype,"selected",2),h([(0,f.property)({attribute:"selection-mode"})],w.prototype,"selectionMode",2),h([(0,f.property)({attribute:!1})],w.prototype,"highlighted",2),h([(0,f.property)({attribute:!1})],w.prototype,"highlightScope",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"loading",2),h([(0,f.property)()],w.prototype,"error",2),h([(0,f.property)({attribute:"empty-message"})],w.prototype,"emptyMessage",2),h([(0,f.property)()],w.prototype,"description",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"decorative",2),h([(0,f.property)({type:Boolean,attribute:"accessible-table"})],w.prototype,"accessibleTable",2),h([(0,f.property)({attribute:!1})],w.prototype,"zoom",2),h([(0,f.property)({attribute:!1})],w.prototype,"view",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"zoomable",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"editable",2),h([(0,f.property)({attribute:"sync-id"})],w.prototype,"syncId",2),h([(0,f.property)({type:Boolean,attribute:"cross-filter"})],w.prototype,"crossFilter",2),h([(0,f.property)({converter:{fromAttribute:t=>t===null?!1:t===""?!0:Number(t)}})],w.prototype,"animated",2),h([(0,f.property)({type:Boolean,reflect:!0})],w.prototype,"responsive",2),h([(0,f.state)()],w.prototype,"tip",2),h([(0,f.state)()],w.prototype,"overlay",2),h([(0,f.state)()],w.prototype,"portal",2),h([(0,f.state)()],w.prototype,"measured",2),h([(0,f.state)()],w.prototype,"viewState",2),h([(0,f.state)()],w.prototype,"highlightState",2),h([(0,f.state)()],w.prototype,"crossState",2),h([(0,f.state)()],w.prototype,"focused",2),h([(0,f.state)()],w.prototype,"hiddenState",2),h([(0,f.state)()],w.prototype,"zoomState",2),h([(0,f.state)()],w.prototype,"selectedState",2);var C=class extends w{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:l,labels:u,curve:c,connectNulls:p,nulls:b,stacked:I,stackOffset:k,orientation:d,radius:g,barGap:x,barWidth:S,sort:T,transform:O,transforms:B,bins:L,binWidth:oe,binDomain:m,binMode:A,sampling:z,brush:_,crosshair:N}=this;return{...this.sized(),series:t,categories:r,xAxis:i,yAxis:o,rightAxis:s,references:a,annotations:l,labels:u,curve:c,connectNulls:p,nulls:b,stacked:I,stackOffset:k,orientation:d,radius:g,barGap:x,barWidth:S,sort:T,transform:O,transforms:B,bins:L,binWidth:oe,binDomain:m,binMode:A,sampling:z,brush:_,crosshair:N}}};h([(0,f.property)({attribute:!1})],C.prototype,"series",2),h([(0,f.property)({attribute:!1})],C.prototype,"categories",2),h([(0,f.property)({attribute:!1})],C.prototype,"xAxis",2),h([(0,f.property)({attribute:!1})],C.prototype,"yAxis",2),h([(0,f.property)({attribute:!1})],C.prototype,"rightAxis",2),h([(0,f.property)({attribute:!1})],C.prototype,"references",2),h([(0,f.property)({attribute:!1})],C.prototype,"annotations",2),h([(0,f.property)({type:Boolean,reflect:!0})],C.prototype,"labels",2),h([(0,f.property)()],C.prototype,"curve",2),h([(0,f.property)({type:Boolean,attribute:"connect-nulls"})],C.prototype,"connectNulls",2),h([(0,f.property)()],C.prototype,"nulls",2),h([(0,f.property)({reflect:!0,converter:{fromAttribute:t=>t==="percent"?"percent":t!==null}})],C.prototype,"stacked",2),h([(0,f.property)({attribute:"stack-offset"})],C.prototype,"stackOffset",2),h([(0,f.property)()],C.prototype,"orientation",2),h([(0,f.property)({type:Number})],C.prototype,"radius",2),h([(0,f.property)({type:Number,attribute:"bar-gap"})],C.prototype,"barGap",2),h([(0,f.property)({type:Number,attribute:"bar-width"})],C.prototype,"barWidth",2),h([(0,f.property)()],C.prototype,"sort",2),h([(0,f.property)()],C.prototype,"transform",2),h([(0,f.property)({attribute:!1})],C.prototype,"transforms",2),h([(0,f.property)({type:Number})],C.prototype,"bins",2),h([(0,f.property)({type:Number,attribute:"bin-width"})],C.prototype,"binWidth",2),h([(0,f.property)({attribute:!1})],C.prototype,"binDomain",2),h([(0,f.property)({attribute:"bin-mode"})],C.prototype,"binMode",2),h([(0,f.property)({attribute:!1})],C.prototype,"sampling",2),h([(0,f.property)({type:Boolean,reflect:!0})],C.prototype,"brush",2),h([(0,f.property)({type:Boolean,reflect:!0})],C.prototype,"crosshair",2);var on=e=>e.defs&&e.defs.length?v.svg`<defs>${e.defs.map(n=>v.svg`<linearGradient id=${n.id} x1="0" y1="0" x2=${n.vertical===!1?1:0} y2=${n.vertical===!1?0:1}>${n.stops.map(t=>v.svg`<stop offset=${t.offset} stop-color=${t.color} stop-opacity=${(0,$.ifDefined)(t.opacity)}></stop>`)}</linearGradient>`)}</defs>`:v.nothing,xe=e=>v.svg`${e.map((n,t)=>{let r=n.title?v.svg`<title>${n.title}</title>`:v.nothing,i=n.item?t:void 0;switch(n.kind){case"path":return v.svg`<path data-skdx-part=${n.part} data-skdx-i=${(0,$.ifDefined)(i)} d=${n.d} fill=${n.fill??"none"} stroke=${(0,$.ifDefined)(n.stroke)} stroke-width=${(0,$.ifDefined)(n.strokeWidth)} stroke-linecap=${(0,$.ifDefined)(n.strokeLinecap)} stroke-linejoin=${(0,$.ifDefined)(n.strokeLinejoin)} stroke-dasharray=${(0,$.ifDefined)(n.dash)} opacity=${(0,$.ifDefined)(n.opacity)} fill-opacity=${(0,$.ifDefined)(n.fillOpacity)}>${r}</path>`;case"rect":return v.svg`<rect data-skdx-part=${n.part} data-skdx-i=${(0,$.ifDefined)(i)} x=${n.x} y=${n.y} width=${n.width} height=${n.height} rx=${(0,$.ifDefined)(n.rx)} fill=${n.fill} stroke=${(0,$.ifDefined)(n.stroke)} fill-opacity=${(0,$.ifDefined)(n.opacity)}>${r}</rect>`;case"line":return v.svg`<line data-skdx-part=${n.part} data-skdx-i=${(0,$.ifDefined)(i)} x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2} stroke=${n.stroke} stroke-width=${(0,$.ifDefined)(n.strokeWidth)} stroke-dasharray=${(0,$.ifDefined)(n.dash)} opacity=${(0,$.ifDefined)(n.opacity)}>${r}</line>`;case"circle":return v.svg`<circle data-skdx-part=${n.part} data-skdx-i=${(0,$.ifDefined)(i)} cx=${n.cx} cy=${n.cy} r=${n.r} fill=${n.fill} stroke=${(0,$.ifDefined)(n.stroke)} opacity=${(0,$.ifDefined)(n.opacity)}>${r}</circle>`;case"text":return v.svg`<text data-skdx-part=${n.part} data-skdx-i=${(0,$.ifDefined)(i)} x=${n.x} y=${n.y} text-anchor=${(0,$.ifDefined)(n.anchor)} dominant-baseline=${(0,$.ifDefined)(n.baseline)} fill=${(0,$.ifDefined)(n.fill)} font-weight=${(0,$.ifDefined)(n.weight)} pointer-events=${(0,$.ifDefined)(i===void 0?"none":void 0)} transform=${(0,$.ifDefined)(n.rotate?`rotate(${n.rotate} ${n.x} ${n.y})`:void 0)}>${n.text}</text>`}})}`;var R=class extends w{constructor(){super(...arguments);this.segments=[];this.data=[];this.labels=!1}render(){let{segments:t,data:r,labels:i,gap:o,xAxis:s}=this;return this.root(ot({...this.sized(),segments:t,data:r,labels:i,gap:o,xAxis:s}),"marimekko",this.label??"Marimekko chart")}};h([(0,Z.property)({attribute:!1})],R.prototype,"segments",2),h([(0,Z.property)({attribute:!1})],R.prototype,"data",2),h([(0,Z.property)({type:Boolean,reflect:!0})],R.prototype,"labels",2),h([(0,Z.property)({type:Number})],R.prototype,"gap",2),h([(0,Z.property)({attribute:!1})],R.prototype,"xAxis",2),R=h([(0,Z.customElement)("skdx-marimekko-chart")],R);0&&(module.exports={SkdxMarimekkoChart});
|