mayacharts 0.2.0 → 0.3.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! mayacharts v0.2.0 | MIT | https://github.com/BbekShr/mayacharts */
2
- var e={noData:`No data`,other:`Other`,back:`Back`,reset:`Reset zoom`,showing:`Showing {0}`,drilledInto:`Drilled into {0}`,zoomedTo:`Zoomed to {0} – {1}`,selected:`{0} selected`,selectionCleared:`Selection cleared`,chartOf:`{0} chart of {1} by {2}`,chartOfAll:`{0} chart of {1}`,firstOf:`First {0} of {1} rows`,measures:`Measure`,crumbs:`Drill path`,positive:`positive`,negative:`negative`,above:`above target`,below:`below target`,vs:`{0} vs {1}`,sortedBy:`Sorted by {0}, {1}`,ascending:`ascending`,descending:`descending`,ofTarget:`{0} of target {1}`};function t(t,n,...r){return((t.text&&Object.hasOwn(t.text,n)?t.text[n]:void 0)??e[n]).replace(/\{(\d)\}/g,(e,t)=>String(r[+t]??``))}var n={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function r(e){return String(e).replace(/[&<>"']/g,e=>n[e])}function i(e){return Math.round(e*100)/100}function a(e,t,n){let i=``;for(let e in t){let n=t[e];n!=null&&n!==!1&&(i+=n===!0?` ${e}=""`:` ${e}="${r(n)}"`)}return n===void 0?`<${e}${i}/>`:`<${e}${i}>${n}</${e}>`}var o=`\0other`,s=(...e)=>e.map(e=>encodeURIComponent(String(e).replace(/\p{Cs}/gu,`�`)).replace(/~/g,`%7E`)).join(`~`);function c(e,t,n,r,o){let[s,c]=[Math.max(r,24),Math.max(o,24)];return r<24||o<24?a(`rect`,Object.assign({"data-maya":`hit`},e,{"data-maya":`hit`,x:i(t-(s-r)/2),y:i(n-(c-o)/2),width:i(s),height:i(c),fill:`transparent`})):``}var l=e=>e.title??`${e.titles.get(e.y)??e.y}`+(e.x||e.path.length?` by ${e.titles.get(e.x)??(e.x||e.path.join(` / `))}`:``),u=[`scatter`,`treemap`,`sunburst`,`sankey`,`hexmap`],d=1e3;function f(e,n,r,i){if(e.description!==null)return e.description;let a=t=>e.titles.get(t)??t,o=e.x||e.path.length?t(e,`chartOf`,i,a(e.y),e.x?a(e.x):e.path.join(` / `)):t(e,`chartOfAll`,i,a(e.y));if(e.series!==null&&n.series.length&&(o+=`, ${e.stack?`stacked`:`grouped`} by ${a(e.series)} (${n.series.join(`, `)})`),u.includes(e.type))return`${o}. ${e.data.length} rows.`;let s=0,c=1/0,l=-1/0;for(let e of n.cells)e.value!==null&&(s++,c=Math.min(c,e.value),l=Math.max(l,e.value));let d=t=>r(e.y,t);return s?s===1?`${o}. 1 value: ${d(c)}.`:`${o}. ${s} values from ${d(c)} to ${d(l)}.`:o+`. No data.`}function p(e,n,i,a){let o=t=>e.titles.get(t)??t,s=(t,n)=>{if(n==null)return``;let o=t===e.y&&typeof n==`number`?a(n):null;return r(i(t,n))+(o?` (${r(o)})`:``)},c=n=>n>d?t(e,`firstOf`,d,n):l(e),f,p,m;if(u.includes(e.type)){let t=[...new Set([e.x,...e.path,e.series,e.name,e.size,e.y,typeof e.colorBy==`string`&&e.colorBy!==`sign`?e.colorBy:null].filter(e=>!!e))];m=e.data.length,f=t.map(e=>`<th>${r(o(e))}</th>`).join(``),p=e.data.slice(0,d).map(e=>`<tr>${t.map(t=>`<td>${s(t,e[t])}</td>`).join(``)}</tr>`).join(``)}else{let t=e.series===null?[o(e.y)]:n.visible.map(e=>n.series[e]);m=n.categories.length,f=`<th>${r(o(e.x))}</th>`+t.map(e=>`<th>${r(e)}</th>`).join(``);let i=new Map(n.cells.map(e=>[e.ci+`,`+e.si,e.value]));p=``;for(let t=0;t<Math.min(m,d);t++){p+=`<tr><th scope="row">${r(n.categories[t])}</th>`;for(let r of n.visible)p+=`<td>${s(e.y,i.get(t+`,`+r))}</td>`;p+=`</tr>`}}return`<table class="maya-sr"><caption>${r(c(m))}</caption><thead><tr>${f}</tr></thead><tbody>${p}</tbody></table>`}var m=e=>{for(let t=0;t<8;t++)if(Math.abs(e*10**t-Math.round(e*10**t))<1e-9)return t;return 8},h=`year month day hour minute second weekday era timeZone dateStyle timeStyle fractionalSecondDigits hour12 dayPeriod timeZoneName`.split(` `),g={date:{dateStyle:`medium`},month:{month:`short`,year:`numeric`},year:{year:`numeric`},time:{timeStyle:`short`},datetime:{dateStyle:`medium`,timeStyle:`short`}};function _(e,t=e.y,n){typeof t==`number`&&([t,n]=[e.y,t]);let r=e.format.get(t),i=Intl.NumberFormat.supportedLocalesOf(e.locale).length?e.locale:`en-US`,a=n===void 0?2:m(n),o=``,s=``,c=null,l=null,u=typeof r==`string`?r:`auto`;if(typeof r==`string`&&Object.hasOwn(g,r))c=new Intl.DateTimeFormat(i,{timeZone:`UTC`,...g[r]});else if(typeof r==`object`&&r){let{prefix:e=``,suffix:t=``,...n}=r;[o,s]=[String(e),String(t)],h.some(e=>Object.hasOwn(n,e))?c=new Intl.DateTimeFormat(i,{timeZone:`UTC`,...n}):l=new Intl.NumberFormat(i,n)}if(!c&&!l){let t=u===`integer`?{maximumFractionDigits:0}:u===`decimal`?{minimumFractionDigits:2,maximumFractionDigits:2}:u===`compact`?{notation:`compact`,maximumFractionDigits:1}:u===`percent`?{style:`percent`,minimumFractionDigits:Math.max(0,a-2),maximumFractionDigits:Math.max(1,a-2)}:u===`currency`?{style:`currency`,currency:e.currency,minimumFractionDigits:n!==void 0&&n>=1?0:a,maximumFractionDigits:n!==void 0&&n>=1?0:Math.max(a,2)}:{maximumFractionDigits:Math.max(a,2)};l=new Intl.NumberFormat(i,t)}return e=>{if(e==null)return``;let t;if(c){let n=typeof e==`string`&&/^-?\d+$/.test(e)?/* @__PURE__ */ new Date(+e):typeof e==`number`||typeof e==`string`||e instanceof Date?new Date(e):NaN;t=Number.isNaN(+n)?String(e):c.format(n)}else t=typeof e==`number`?l.format(e):String(e);return o+t+s}}function v(e,t,n=.2,r=.1){let i=e.length,a=t[1]-t[0],o=a/(i-n+r*2)||1,s=t[0]+(a-o*(i-n))/2;return{domain:e,step:o,bandwidth:o*(1-n),at:e=>s+o*e}}function y(e,t){let[n,r]=e,[i,a]=t,o=r===n?0:(a-i)/(r-n);return{domain:e,range:t,of:e=>r===n?(i+a)/2:i+(e-n)*o}}var b=e=>parseFloat(e.toPrecision(12));function x(e,t,n=5){t===e&&([e,t]=e===0?[0,1]:[e-1,t+1]);let r=10**Math.floor(Math.log10((t-e)/n)),i=r,a=1/0,o=e<0&&t>0;for(let s of[1,2,2.5,5,10]){let c=r*s,l=Math.floor(e/c+1e-9),u=Math.ceil(t/c-1e-9)-l+1,d=o?u>n+3?1/0:(u-1+Math.abs(u-n)/1e3)*c:Math.abs(u-n);d<a-1e-9*Math.abs(d)&&(a=d,i=c)}let s=Math.floor(e/i+1e-9),c=Math.ceil(t/i-1e-9),l=[];for(let e=s;e<=c;e++)l.push(b(e*i));return{domain:[b(s*i),b(c*i)],values:l,step:b(i)}}var S=e=>e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510,C=e=>{let t=0,n=0;for(let r of e)S(r.codePointAt(0))?n++:t++;return t*7.2+n*12},w=e=>C(e)+8,T=e=>e.reduce((e,t)=>Math.max(e,w(t)),0);function E(e,t){if(C(e)<=t)return e;let n=``,r=0;for(let i of e){if(r+=C(i),r+7.2>t)break;n+=i}return n+`…`}function D(e,t,n){let r=(t.field===e.y?e.yDomain:e.xDomain)??null,[i,a]=r??t.domain,[o,s]=i>a?[a,i]:[i,a],c=x(o,s),l=r?c.values.filter(e=>e>=o&&e<=s):c.values;return{domain:r??c.domain,values:l,labels:l.map(e=>n(t.field,e,c.step))}}function O(e,[t,n,o],s,c){let{width:l,height:u}=s,d=t&&t.kind===`linear`?D(e,t,c):null,f=n&&n.kind===`linear`?D(e,n,c):null,p=t&&!d?t.domain.map(e=>c(t.field,e)):[],m=n&&!f?n.domain.map(e=>c(n.field,e)):[],h=f?f.labels:m.map(e=>E(e,l*.4-8)),g=o&&o.kind===`linear`?D(e,o,c):null,_=g&&o&&e.titles.get(o.field),b=n&&e.titles.get(n.field),x=t&&e.titles.get(t.field),S=Math.max((e.yAxis&&n?T(h)+10:8)+(b?18:0),d?C(d.labels[0]??``)/2+2:0),w=(e.xAxis&&t?24:8)+(x?18:0),O={x:S,y:10,w:Math.max(1,l-S-(g?(e.yAxis?T(g.labels)+4:8)+(_?18:0):Math.max(12,d?C(d.labels.at(-1)??``)/2+2:0))),h:Math.max(1,u-10-w)},k=t?t.kind===`band`?v(t.domain,[O.x,O.x+O.w]):y(d.domain,[O.x,O.x+O.w]):null,A=n?n.kind===`band`?v(n.domain,[O.y,O.y+O.h]):y(f.domain,[O.y+O.h,O.y]):null,j=g?y(g.domain,[O.y+O.h,O.y]):null,M=``;if(e.grid){let e=i(O.x+O.w);if(f)for(let t of f.values){let n=i(A.of(t));M+=a(`line`,{x1:i(O.x),x2:e,y1:n,y2:n})}if(d)for(let e of d.values){let t=i(k.of(e));M+=a(`line`,{x1:t,x2:t,y1:i(O.y),y2:i(O.y+O.h)})}}let N=``;if(e.yAxis&&n){if(f)f.values.forEach((e,t)=>{N+=a(`text`,{x:i(O.x-6),y:i(A.of(e)),"text-anchor":`end`,"dominant-baseline":`middle`},r(f.labels[t]))});else{let e=A,t=Math.max(1,Math.ceil(14/(O.h/Math.max(1,n.domain.length))));m.forEach((n,o)=>{if(o%t)return;let s=h[o];N+=a(`text`,{x:i(O.x-6),y:i(e.at(o)+e.bandwidth/2),"text-anchor":`end`,"dominant-baseline":`middle`},r(s)+(s===n?``:a(`title`,{},r(n))))})}}if(b){let e=i(O.y+O.h/2);N+=a(`text`,{x:9,y:e,"text-anchor":`middle`,transform:`rotate(-90 9 ${e})`},r(b))}if(g&&j&&(e.yAxis&&g.values.forEach((e,t)=>{N+=a(`text`,{x:i(O.x+O.w+6),y:i(j.of(e)),"text-anchor":`start`,"dominant-baseline":`middle`},r(g.labels[t]))}),_)){let[e,t]=[l-9,i(O.y+O.h/2)];N+=a(`text`,{x:e,y:t,"text-anchor":`middle`,transform:`rotate(90 ${e} ${t})`},r(_))}let P=``;if(e.xAxis&&t){let e=i(O.y+O.h+16);if(d){let t=Math.max(1,Math.ceil(T(d.labels)/(O.w/Math.max(1,d.values.length-1))));d.values.forEach((n,o)=>{o%t||(P+=a(`text`,{x:i(k.of(n)),y:e,"text-anchor":`middle`},r(d.labels[o])))})}else{let t=k,n=Math.max(1,Math.ceil(T(p)/(O.w/Math.max(1,p.length))));p.forEach((o,s)=>{s%n===0&&(P+=a(`text`,{x:i(t.at(s)+t.bandwidth/2),y:e,"text-anchor":`middle`},r(o)))})}}x&&(P+=a(`text`,{x:i(O.x+O.w/2),y:u-4,"text-anchor":`middle`},r(x)));let F=d&&f,I=t?.kind===`band`?t:n?.kind===`band`?n:null;return{plot:O,x:k,y:A,y2:j,grid:M,ay:N,ax:P,attrs:{"data-plot":`${i(O.x)} ${i(O.y)} ${i(O.w)} ${i(O.h)}`,"data-n":F||!I?null:I.domain.length,"data-xd":F?d.domain.join(` `):null,"data-yd":F?f.domain.join(` `):null}}}function k(e){let t=0,n=0;return{add(r){n=t===0||e===`sum`||e===`mean`?n+r:e===`min`?Math.min(n,r):e===`max`?Math.max(n,r):n,t++},value:()=>e===`count`?t:t===0?null:e===`mean`?n/t:n}}function A(e,t={}){let{hidden:n=[],window:r}=Array.isArray(t)?{hidden:t}:t,i=[],a=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let t of e.data){let n=String(t[e.x]),r=e.series===null?``:String(t[e.series]),o=a.get(r);o===void 0&&a.set(r,o=i.push(r)-1);let c=s.get(n);c||s.set(n,c={label:n,rows:[],vals:[]}),c.rows.push([o,t[e.y],e.y2===null?void 0:t[e.y2]])}let c=t=>{let n=/* @__PURE__ */ new Map;for(let[r,i]of t){let t=n.get(r);t||n.set(r,t=k(e.aggregate)),typeof i==`number`&&t.add(i)}return i.map((e,t)=>n.get(t)?.value()??null)},l=t=>{let n=k(e.aggregate);for(let[,,e]of t.rows)typeof e==`number`&&n.add(e);t.y2=n.value()},u=[...s.values()];for(let e of u)e.vals=c(e.rows),l(e);let d=e=>e.vals.reduce((e,t)=>e+(t??0),0);if(e.sort){let t=e.sort===`asc`?1:-1;u=u.map(e=>[e,d(e)]).sort((e,n)=>t*(e[1]-n[1])).map(e=>e[0])}if(e.limit!==null&&u.length>e.limit){let t=new Set(u.map(e=>[e,d(e)]).sort((e,t)=>t[1]-e[1]).slice(0,e.limit).map(e=>e[0])),n={label:o,rows:u.filter(e=>!t.has(e)).flatMap(e=>e.rows),vals:[]};n.vals=c(n.rows),l(n),u=[...u.filter(e=>t.has(e)),n]}let f=e.type===`waterfall`,p=/* @__PURE__ */ new Map;if(f){let t=0;for(let n of u)e.totals.includes(n.label)?p.set(n,[0,t]):p.set(n,[t,t+=d(n)])}if(r?.length===2&&u.length){let e=Math.min(u.length-1,Math.max(0,Math.trunc(r[1]))),t=Math.min(e,Math.max(0,Math.trunc(r[0])));u=u.slice(t,e+1)}let m=[];i.forEach((e,t)=>n.includes(e)||m.push(t));let h=[],g=0,_=0;return u.forEach((t,n)=>{let r=0,i=0;for(let a of m){let o=t.vals[a]??null,s=o??0,[c,l]=f?p.get(t):[0,s];e.stack&&(s<0?[c,l]=[i,i+=s]:[c,l]=[r,r+=s]),g=Math.min(g,c,l),_=Math.max(_,c,l),h.push({ci:n,si:a,value:o,y0:c,y1:l})}}),{categories:u.map(e=>e.label),totals:u.map(t=>e.totals.includes(t.label)),series:i,visible:m,cells:h,extent:[g,_],y2:e.y2===null?[]:u.map(e=>e.y2??null)}}function j(e){let t=typeof e.colorBy==`string`&&e.colorBy!==`sign`?e.colorBy:null,n=/* @__PURE__ */ new Map;if(t)for(let r of e.data){let i=r[t];if(typeof i!=`number`)continue;let a=String(r[e.x])+`\0`+(e.series===null?``:String(r[e.series]));(n.get(a)??n.set(a,k(e.aggregate)).get(a)).add(i)}return(e,t)=>n.get(e+`\0`+t)?.value()??null}function M(e){let t=[];for(let n of e.cells)t[n.ci]=n;let n=e.visible[0]??0,r=0,i=[];return e.categories.forEach((a,o)=>{let s=t[o];if(s){if(e.totals[o])return void i.push({ci:o,si:n,y0:0,y1:r,v:r,s:2});s.value!==null&&i.push({ci:o,si:n,y0:r,y1:r+=s.value,v:s.value,s:+(s.value<0)})}}),i}var N=(e,t)=>e.type===`waterfall`?M(t):t.cells.flatMap(e=>e.value===null?[]:[{ci:e.ci,si:e.si,y0:e.y0,y1:e.y1,v:e.value,s:e.si%8}]),P={noun:`Bar`,axes(e,t){let n=t.extent[0],r=t.extent[1];if(e.type===`waterfall`){n=r=0;for(let e of M(t))n=Math.min(n,e.y0,e.y1),r=Math.max(r,e.y0,e.y1)}let i={kind:`band`,field:e.x,domain:t.categories},a={kind:`linear`,field:e.y,domain:[n,r]};if(e.y2!==null){let n=t.y2.filter(e=>e!==null);return[i,a,{kind:`linear`,field:e.y2,domain:[Math.min(0,...n),Math.max(0,...n)]}]}return e.horizontal?[a,i]:[i,a]},draw(e){let{spec:t,shaped:n}=e,r=t.horizontal,l=r?e.y:e.x,u=r?e.x:e.y,d=v(n.visible.map(e=>n.series[e]),[0,l.bandwidth],.1,0),f=j(t),p=``,m=``;for(let h of N(t,n)){let g=n.visible.indexOf(h.si),_=l.at(h.ci)+(t.stack||t.type===`waterfall`?0:d.at(g)),v=t.stack||t.type===`waterfall`?l.bandwidth:d.bandwidth,[y,b]=[u.of(h.y0),u.of(h.y1)],x=Math.min(y,b),S=Math.abs(y-b),[C,w,T,E]=r?[x,_,S,v]:[_,x,v,S],D=n.categories[h.ci],O=n.series[h.si],k=f(D,O),A={"data-key":s(O,D),"data-c":h.ci,"data-s":h.s,"data-x":e.fmt(t.x,D),"data-series":O,"data-f":e.fmt(t.y,h.v),"data-y":h.v,"data-neg":h.v<0,"data-tone":e.tone(h.v),"data-q":k===null?null:e.q(k),"data-other":D===o,"data-total":n.totals[h.ci]};if(p+=a(`rect`,{"data-maya":`mark`,...A,x:i(C),y:i(w),width:i(T),height:i(E)}),m+=c(A,C,w,T,E),t.labels){let n=e.fmt(t.y,h.v),i=n.length*7.2+4,[a,o]=[C+T/2,w+E/2],s=h.v<0;r?i<=T&&E>=14?e.label(a,o,n,`center`):e.label(s?C-4:C+T+4,o,n,s?`end`:`start`):i<=T&&E>=16?e.label(a,o,n,`center`):e.label(a,s?w+E:w,n,s?`below`:`above`)}}if(e.y2&&t.y2!==null&&n.y2.length){let r=t.y2,o=n.series.length%8,u=t.titles.get(r)??r,d=``,f=!0,h=``;n.y2.forEach((p,g)=>{if(p===null){f=!0;return}let _=i(l.at(g)+l.bandwidth/2),v=i(e.y2.of(p));d+=`${f?`M`:`L`}${_} ${v}`,f=!1;let y=n.categories[g],b={"data-key":s(`\0y2`,y),"data-c":g,"data-s":o,"data-x":e.fmt(t.x,y),"data-series":u,"data-f":e.fmt(r,p),"data-y":p,"data-neg":p<0};h+=a(`circle`,{"data-maya":`mark`,...b,r:3,cx:_,cy:v}),m+=c(b,_-3,v-3,6,6),t.labels&&e.label(+_,+v,e.fmt(r,p),`above`)}),p+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,`\0y2`),"data-s":o,pathLength:1,d:d||null})+h}return{marks:p,hits:m}}};function F(e,t){let n=[],r=new Map(t.categories.map((e,t)=>[e,t])),i=e.yDomain;return e.data.forEach((a,o)=>{let s=a[e.y];if(typeof s!=`number`||!Number.isFinite(s)||i&&(s<i[0]||s>i[1]))return;let c=e.x===``?0:r.get(String(a[e.x]));if(c===void 0)return;let l=t.series.indexOf(e.series===null?``:String(a[e.series]));if(!t.visible.includes(l))return;let u=e.name===null?null:a[e.name];n.push({i:o,v:s,ci:c,si:l,name:u==null?null:String(u),row:a})}),n}function I(e,t,n){let r=e.map((e,t)=>t).sort((t,n)=>e[t]-e[n]||t-n),i=(2*t)**2,a=Array(e.length).fill(0),o=[],s=0;for(let c of r){let r=e[c];for(;s<o.length&&r-e[o[s]]>=2*t;)s++;let l=o.slice(s),u=[0];for(let t of l){let n=Math.sqrt(Math.max(0,i-(r-e[t])**2));u.push(a[t]+n,a[t]-n)}u.sort((e,t)=>Math.abs(e)-Math.abs(t)||t-e);let d=u.find(t=>l.every(n=>(r-e[n])**2+(t-a[n])**2>=i-1e-6))??0;d=Math.max(-n,Math.min(n,d)),a[c]=d,o.push(c)}return a}var ee={noun:`Beeswarm`,axes(e,t){let n=1/0,r=-1/0;for(let i of F(e,t))n=Math.min(n,i.v),r=Math.max(r,i.v);n>r&&(n=r=0);let i=e.x===``?null:{kind:`band`,field:e.x,domain:t.categories};return[{kind:`linear`,field:e.y,domain:e.yDomain??[n,r]},i]},draw(e){let{spec:t,shaped:n,plot:r}=e,o=e.x,l=e.y,u=F(t,n),d=l?l.bandwidth:r.h,f=/* @__PURE__ */ new Map;for(let e of u)(f.get(e.ci)??f.set(e.ci,[]).get(e.ci)).push(e);let p=1;for(let e of f.values())p=Math.max(p,e.length);let m=Math.max(3,Math.min(6,Math.sqrt(r.w*d/p)/4)),h=typeof t.colorBy==`string`&&t.colorBy!==`sign`?t.colorBy:null,g=/* @__PURE__ */ new Map,_=``,v=``;for(let[u,p]of[...f].sort((e,t)=>e[0]-t[0])){let f=l?l.at(u)+l.bandwidth/2:r.y+r.h/2,y=p.map(e=>o.of(e.v)),b=I(y,m+.5,Math.max(0,d/2-m));p.forEach((r,o)=>{let d=r.i;if(r.name!==null){let e=(g.get(r.name)??0)+1;g.set(r.name,e),d=e>1?`${r.name}#${e}`:r.name}let p=n.series[r.si],x=e.fmt(t.y,r.v),S=h?r.row[h]:null,C={"data-key":s(p,d),"data-c":r.i,"data-s":r.si%8,"data-x":r.name??(l?e.fmt(t.x,n.categories[u]):``),"data-series":p,"data-y":r.v,"data-f":x,"data-neg":r.v<0,"data-tone":e.tone(r.v),"data-q":typeof S==`number`?e.q(S):null},w=y[o],T=f+b[o];_+=a(`circle`,{"data-maya":`mark`,...C,r:i(m),cx:i(w),cy:i(T)}),v+=c(C,w-m,T-m,m*2,m*2),t.labels&&e.label(w,T-m,x,`above`)})}return{marks:_,hits:v}}},L={noun:`Dumbbell`,axes(e,t){let n={kind:`band`,field:e.x,domain:t.categories},r={kind:`linear`,field:e.y,domain:t.extent};return e.horizontal?[r,n]:[n,r]},draw(e){let{spec:t,shaped:n}=e,r=t.horizontal,l=r?e.y:e.x,u=r?e.x:e.y,d=Math.max(3,Math.min(5,l.bandwidth/2-1)),f=/* @__PURE__ */ new Map;for(let e of n.cells)e.value!==null&&e.si<2&&((f.get(e.ci)??f.set(e.ci,[]).get(e.ci))[e.si]=e.value);let p=``,m=``,h=``;for(let[g,_]of[...f].sort((e,t)=>e[0]-t[0])){let f=n.categories[g],v=l.at(g)+l.bandwidth/2,y=e=>r?[u.of(e),v]:[v,u.of(e)],[b,x]=_;if(b!==void 0&&x!==void 0){let[t,n]=y(b),[r,o]=y(x);p+=a(`line`,{"data-maya":`link`,"data-key":s(`k`,f),"data-c":g,"data-tone":e.tone(x-b),"stroke-width":2,x1:i(t),y1:i(n),x2:i(r),y2:i(o)})}for(let l of[0,1]){let u=_[l];if(u===void 0)continue;let[p,v]=y(u),b=n.series[l],x={"data-key":s(b,f),"data-c":g,"data-s":l%8,"data-x":e.fmt(t.x,f),"data-series":b,"data-f":e.fmt(t.y,u),"data-y":u,"data-neg":u<0,"data-other":f===o};if(m+=a(`circle`,{"data-maya":`mark`,...x,cx:i(p),cy:i(v),r:d}),h+=c(x,p-d,v-d,d*2,d*2),t.labels){let n=_[1-l],[i,a]=y(n??u),o=e.fmt(t.y,u),s=r?p>=i:v>=a,c=n===void 0?r:l===1?s:!s;r?e.label(p+(c?d+4:-d-4),v,o,c?`start`:`end`):e.label(p,v+(c?d:-d),o,c?`below`:`above`)}}}return{marks:p+m,hits:h}}},te={noun:`Heatmap`,axes:(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`band`,field:e.series??``,domain:t.series}],draw(e){let{spec:t,shaped:n}=e,o=e.x,l=e.y,u=n.cells.filter(e=>e.value!==null),d=1/0,f=-1/0;for(let e of u)d=Math.min(d,e.value),f=Math.max(f,e.value);let p=e=>f>d?Math.min(9,Math.max(0,Math.floor((e-d)/(f-d)*10))):9,m=``,h=``;for(let[r,d]of u.entries()){let u=d.value,f=n.visible.indexOf(d.si),g=o.at(d.ci)+1,_=l.at(f)+1,v=Math.max(0,o.bandwidth-2),y=Math.max(0,l.bandwidth-2),b=n.categories[d.ci],x=n.series[d.si],S={"data-key":s(x,b),"data-c":r,"data-x":e.fmt(t.x,b),"data-series":x,"data-y":u,"data-f":e.fmt(t.y,u),"data-q":p(u)};m+=a(`rect`,{"data-maya":`mark`,...S,x:i(g),y:i(_),width:i(v),height:i(y)}),h+=c(S,g,_,v,y),t.labels!==!1&&v>=24&&y>=24&&e.label(g+v/2,_+y/2,e.fmt(t.y,u),`center`)}let g=u.length>0?`<div class="maya-legend" data-maya="ramp"><span>${r(e.fmt(t.y,d))}</span><i></i><span>${r(e.fmt(t.y,f))}</span></div>`:``;return{marks:m,hits:h,grid:``,legend:g}}},R=12,ne=e=>typeof e==`number`?e:null;function re(e){let{spec:t,shaped:n,width:o,height:c}=e,l=t.x?n.categories:[],u=t.x?n.cells.filter(e=>e.si===0).sort((e,t)=>e.ci-t.ci):[],d=u.filter(e=>e.value!==null),f=d[d.length-1],p=t.x?f?.value??null:e.agg(t.aggregate)(t.data.map(e=>ne(e[t.y]))),m=o/2;if(p===null)return{marks:``,hits:``,labels:a(`text`,{"data-maya":`empty`,x:i(m),y:i(c/2),"text-anchor":`middle`},r(e.t(`noData`)))};let h=f?.ci??0,g=t.x?e.fmt(t.x,l[h]):``,_=e.fmt(t.y,p),v=i(Math.max(16,Math.min(c*.32,72,(o-24)/(_.length*.62)))),y={"data-c":h,"data-s":0,"data-x":g,"data-series":``,"data-y":p,"data-f":_},b=(e,t)=>a(`text`,{"dominant-baseline":`hanging`,x:R,...e},r(t)),x=a(`text`,{"data-maya":`mark`,"data-key":`v`,...y,"font-size":v,x:R,y:R,"dominant-baseline":`hanging`},r(_)),S=``,C=``,w=R+v+4,T=d[d.length-2];if(f&&T&&T.value){let n=(p-T.value)/Math.abs(T.value),r=new Intl.NumberFormat(t.locale,{style:`percent`,maximumFractionDigits:1,signDisplay:`exceptZero`}).format(n);S+=b({"data-kpi":`delta`,"data-tone":n>0?`good`:n<0?`bad`:null,y:i(w),"font-size":12},e.t(`vs`,r,e.fmt(t.x,l[T.ci]))),w+=16}g&&(S+=b({"data-kpi":`period`,y:i(w),"font-size":11},g)),w+=18;let E=``,D=typeof t.colorBy==`object`&&t.colorBy?t.colorBy.target:null,O=c-R;if(D){let n=o-24,r=Math.min(Math.max(p/D,0),1.2)/1.2,s=new Intl.NumberFormat(t.locale,{style:`percent`,maximumFractionDigits:1});O-=8,E=a(`rect`,{"data-kpi":`track`,x:R,y:O,width:i(n),height:8,rx:4}),x+=a(`rect`,{"data-maya":`mark`,"data-key":`b`,...y,"data-kpi":`fill`,"data-tone":e.tone(p),x:R,y:O,width:i(n*r),height:8,rx:4}),S+=a(`line`,{"data-kpi":`target`,"stroke-width":2,x1:i(R+n/1.2),x2:i(R+n/1.2),y1:O-3,y2:O+11}),S+=b({"data-kpi":`of`,y:O-16,"font-size":11},e.t(`ofTarget`,s.format(p/D),e.fmt(t.y,D))),O-=24}if(l.length>=3&&O-w>=28){let n=d.map(e=>e.value),r=Math.min(...n),p=Math.max(...n)-r||1,m=l.length-1,h=(o-24)/m,g=e=>i(R+e*h),_=e=>i(O-(e-r)/p*(O-w-4)-2),v=``,y=!0;u.forEach(n=>{if(n.value===null)return void(y=!0);v+=`${y?`M`:`L`}${g(n.ci)} ${_(n.value)}`,y=!1,x+=a(`circle`,{"data-maya":`mark`,"data-key":s(``,l[n.ci]),"data-c":n.ci,"data-s":0,"data-x":e.fmt(t.x,l[n.ci]),"data-series":``,"data-y":n.value,"data-f":e.fmt(t.y,n.value),"data-neg":n.value<0,"data-last":n===f,r:3,cx:g(n.ci),cy:_(n.value)})}),x=a(`path`,{"data-maya":`line`,"data-key":s(`l`,``),"data-s":0,pathLength:1,d:v||null})+x,l.forEach((e,t)=>{C+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(Math.max(0,R+t*h-h/2)),y:0,width:i(h),height:c,fill:`transparent`})})}return{marks:x,hits:C,labels:S,grid:E}}var ie={noun:`KPI`,draw:re},ae=26,oe=12,se=48,ce=14,le={noun:`Parallel coordinates`,draw(e){let{spec:t,shaped:n,width:o,height:c}=e,l=t.measures,u=/* @__PURE__ */ new Map;for(let e of t.data){let n=String(e[t.x]);(u.get(n)??u.set(n,[]).get(n)).push(e)}let d=e.agg(t.aggregate),f=n.categories.flatMap((e,r)=>{let i=u.get(e);if(!i||e===`\0other`)return[];let a=l.map(e=>d(i.map(t=>t[e]))),o=t.series===null?0:Math.max(0,n.series.indexOf(String(i[0][t.series])));return n.visible.includes(o)?[{cat:e,ci:r,vals:a,si:o}]:[]}),p=se,m=Math.max(49,o-ce),[h,g]=[ae,Math.max(27,c-oe)],_=e=>i(l.length<2?p:p+(m-p)*e/(l.length-1)),v=``,y=``,b=l.map((n,o)=>{let s=f.map(e=>e.vals[o]).filter(e=>e!==null),c=x(Math.min(0,...s),Math.max(0,...s),4),[u,d]=c.domain,p=e=>i(g-(e-u)/(d-u||1)*(g-h)),m=_(o);v+=a(`line`,{x1:m,x2:m,y1:i(h),y2:i(g)});for(let t of c.values){let i=p(t);v+=a(`line`,{x1:m-3,x2:m,y1:i,y2:i}),y+=a(`text`,{x:m-6,y:i,"text-anchor":`end`,"dominant-baseline":`middle`,"data-in":!0},r(e.fmt(n,t,c.step)))}return y+=a(`text`,{x:m,y:12,"text-anchor":o===0?`start`:o===l.length-1?`end`:`middle`,"font-weight":600,"data-in":!0},r(t.titles.get(n)??n)),p}),S=``,C=``,w=``;for(let{cat:n,ci:r,vals:i,si:o}of f){let c=e.fmt(t.x,n),u=``,d=!0;i.forEach((i,f)=>{if(i===null){d=!0;return}let[p,m]=[_(f),b[f](i)];u+=`${d?`M`:`L`}${p} ${m}`,d=!1,S+=a(`circle`,{"data-maya":`mark`,"data-key":s(n,l[f]),"data-c":r,"data-s":o%8,"data-x":c,"data-series":t.titles.get(l[f])??l[f],"data-y":i,"data-f":e.fmt(l[f],i),"data-neg":i<0,r:3.5,cx:p,cy:m})}),u&&(C+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,n),"data-c":r,"data-s":o%8,pathLength:1,d:u}),w+=a(`path`,{"data-maya":`hit`,"data-c":r,d:u,fill:`none`,stroke:`transparent`,"stroke-width":16,"stroke-linejoin":`round`}))}return{marks:S+C,hits:w,grid:v,labels:y}}},ue={noun:`Ridgeline`,axes:(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`band`,field:e.series??``,domain:t.visible.map(e=>t.series[e])}],draw(e){let{spec:t,shaped:n,plot:r}=e,c=e.x,l=e.y,u=j(t),d=e=>i(c.at(e)+c.bandwidth/2),f=0;for(let e of n.cells)e.value!==null&&e.value>f&&(f=e.value);f<=0&&(f=1);let p=e=>l.at(e)+l.bandwidth/2+l.step/2,m=Math.min(1.4*l.step,p(0)-r.y),h=``,g=``;n.visible.forEach((r,c)=>{let l=n.series[r],_=p(c),v=e=>i(_-e/f*m),y=n.cells.filter(e=>e.si===r).sort((e,t)=>e.ci-t.ci),b=[[]];for(let i of y){if(i.value===null){b.push([]);continue}b[b.length-1].push(i);let c=n.categories[i.ci],f=u(c,l);g+=a(`circle`,{"data-maya":`mark`,"data-key":s(l,c),"data-c":i.ci,"data-s":r%8,"data-x":e.fmt(t.x,c),"data-series":l,"data-y":i.value,"data-f":e.fmt(t.y,i.value),"data-neg":i.value<0,"data-tone":e.tone(i.value),"data-q":f===null?null:e.q(f),"data-other":c===o,r:3,cx:d(i.ci),cy:v(i.value)})}let x=e=>e.map((e,t)=>`${t?`L`:`M`}${d(e.ci)} ${v(e.value)}`),S=b.filter(e=>e.length>0),C=S.map(e=>`${x(e).join(``)}L${d(e.at(-1).ci)} ${i(_)}L${d(e[0].ci)} ${i(_)}Z`).join(``);C&&(h+=a(`path`,{"data-maya":`area`,"data-ridge":!0,"data-key":s(`a`,l),"data-s":r%8,d:C})),h+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,l),"data-s":r%8,pathLength:1,d:S.map(e=>x(e).join(``)).join(``)||null})});let _=``;return n.categories.forEach((e,t)=>{_+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(c.at(t)),y:i(r.y),width:i(c.bandwidth),height:i(r.h),fill:`transparent`})}),{marks:h+g,hits:_,cross:a(`line`,{x1:0,x2:0,y1:i(r.y),y2:i(r.y+r.h)})}}},de=(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`linear`,field:e.y,domain:t.extent}];function fe(e,t){let{spec:n,shaped:r,plot:c}=e,l=e.x,u=e.y,d=j(n),f=e=>i(l.at(e)+l.bandwidth/2),p=``,m=``,h=``;for(let c of r.visible){let l=r.series[c],g=r.cells.filter(e=>e.si===c).sort((e,t)=>e.ci-t.ci),_=``,v=!0,y=[[]];for(let t of g){if(t.value===null&&!n.stack?y.push([]):y[y.length-1].push(t),t.value===null){v=!0;continue}_+=`${v?`M`:`L`}${f(t.ci)} ${i(u.of(t.y1))}`,v=!1;let p=r.categories[t.ci],m=d(p,l),g=p===o,b=e.fmt(n.x,p);h+=a(`circle`,{"data-maya":`mark`,"data-key":s(l,p),"data-c":t.ci,"data-s":c%8,"data-x":b,"data-series":l,"data-y":t.value,"data-f":e.fmt(n.y,t.value),"data-neg":t.value<0,"data-tone":e.tone(t.value),"data-q":m===null?null:e.q(m),"data-other":g,r:3,cx:f(t.ci),cy:i(u.of(t.y1))}),n.labels&&e.label(f(t.ci),u.of(t.y1),e.fmt(n.y,t.value),`above`)}if(t){let e=y.filter(e=>e.length>0).map(e=>e.map((e,t)=>`${t?`L`:`M`}${f(e.ci)} ${i(u.of(e.y1))}`).join(``)+[...e].reverse().map(e=>`L${f(e.ci)} ${i(u.of(e.y0))}`).join(``)+`Z`).join(``);e&&(p+=a(`path`,{"data-maya":`area`,"data-key":s(`a`,l),"data-s":c%8,d:e}))}m+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,l),"data-s":c%8,pathLength:1,d:_||null})}let g=``;return r.categories.forEach((e,t)=>{g+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(l.at(t)),y:i(c.y),width:i(l.bandwidth),height:i(c.h),fill:`transparent`})}),{marks:p+m+h,hits:g,cross:a(`line`,{x1:0,x2:0,y1:i(c.y),y2:i(c.y+c.h)})}}var pe={noun:`Line`,axes:de,draw:e=>fe(e,!1)},me={noun:`Area`,axes:de,draw:e=>fe(e,!0)},he=24;function ge(e,t){let n=[],r=e.xDomain,i=e.yDomain,a=e.window;return e.data.forEach((o,s)=>{let c=o[e.x],l=o[e.y];if(typeof c!=`number`||typeof l!=`number`||r&&(c<r[0]||c>r[1])||i&&(l<i[0]||l>i[1])||a&&(c<a[0]||c>a[1]||l<a[2]||l>a[3]))return;let u=t.series.indexOf(e.series===null?``:String(o[e.series]));if(!t.visible.includes(u))return;let d=e.size===null?null:o[e.size],f=e.name===null?null:o[e.name];n.push({i:s,x:c,y:l,sz:typeof d==`number`?d:null,si:u,name:f==null?null:String(f),row:o})}),n}var _e={noun:`Scatter`,axes(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(let o of ge(e,t))n=Math.min(n,o.x),r=Math.max(r,o.x),i=Math.min(i,o.y),a=Math.max(a,o.y);n>r&&(n=r=0,i=a=0);let o=e.size===null?0:(r-n)*.06,s=e.size===null?0:(a-i)*.06,c=(e,t)=>e>=0?Math.max(0,e-t):e-t;return[n,r,i,a]=[c(n,o),r+o,c(i,s),a+s],[{kind:`linear`,field:e.x,domain:e.xDomain??[n,r]},{kind:`linear`,field:e.y,domain:e.yDomain??[i,a]}]},draw(e){let{spec:t,shaped:n,plot:r}=e,o=e.x,c=e.y,l=ge(t,n),u=0;for(let e of l)e.sz!==null&&(u=Math.max(u,Math.abs(e.sz)));let d=Math.min(r.w,r.h)/16,f=typeof t.colorBy==`string`&&t.colorBy!==`sign`?t.colorBy:null,p=/* @__PURE__ */ new Map,m=l.map(r=>{let i=r.sz!==null&&u>0?2+Math.sqrt(Math.abs(r.sz)/u)*d:4,a=r.i;if(r.name!==null){let e=(p.get(r.name)??0)+1;p.set(r.name,e),a=e>1?`${r.name}#${e}`:r.name}let l=n.series[r.si],m=e.fmt(t.x,r.x),h=e.fmt(t.y,r.y),g=f?r.row[f]:null;return{p:r,rad:i,d:{"data-key":s(l,a),"data-c":r.i,"data-s":r.si%8,"data-x":r.name??m,"data-series":l,"data-y":r.y,"data-f":r.name===null&&r.sz===null?h:[m,h,r.sz===null?null:e.fmt(t.size,r.sz)].filter(e=>e!==null).join(` · `),"data-neg":r.y<0,"data-tone":e.tone(r.y),"data-q":typeof g==`number`?e.q(g):null},cx:o.of(r.x),cy:c.of(r.y)}});m.sort((e,t)=>t.rad-e.rad);let h=``,g=``;for(let{p:n,rad:r,d:o,cx:s,cy:c}of m)h+=a(`circle`,{"data-maya":`mark`,...o,r:i(r),cx:i(s),cy:i(c)}),r*2<he&&(g+=a(`circle`,{"data-maya":`hit`,...o,r:i(Math.max(r,12)),cx:i(s),cy:i(c),fill:`transparent`})),t.labels&&e.label(s,c-r,e.fmt(t.y,n.y),`above`);return{marks:h,hits:g}}},z=30,B=26,V=8,ve=e=>typeof e==`number`?e:null,ye={noun:`Table`,draw(e){let{spec:t,width:n,height:o}=e,l=t.measures,u=e=>t.titles.get(e)??e,d=e.agg(t.aggregate),f=/* @__PURE__ */ new Map;for(let e of t.data){let n=String(e[t.x]),r=f.get(n)??f.set(n,l.map(()=>[])).get(n);l.forEach((t,n)=>r[n].push(ve(e[t])))}let p=[...f].map(([e,t])=>({name:e,vals:t.map(e=>d(e))})),m=(e,t)=>e===null?1/0:e*t,h=(e,t)=>(n,r)=>m(n.vals[e],t)-m(r.vals[e],t)||0;t.limit!==null&&p.length>t.limit&&(p=p.sort(h(0,-1)).slice(0,t.limit));let g=t.sortBy&&(t.sortBy[0]===t.x||l.includes(t.sortBy[0]))?t.sortBy:null;if(g){let e=g[1]===`asc`?1:-1,n=l.indexOf(g[0]);if(n<0){let n=new Intl.Collator(t.locale,{numeric:!0});p.sort((t,r)=>e*n.compare(t.name,r.name))}else p.sort((t,r)=>{let[i,a]=[t.vals[n],r.vals[n]];return i===null||a===null?(i===null)-+(a===null):e*(i-a)})}else t.sort&&p.sort(h(0,t.sort===`asc`?1:-1));let _=Math.max(80,Math.min(n*.34,180)),v=(n-_)/l.length,y=e=>_+e*v,b=l.map((e,t)=>Math.max(0,...p.map(e=>Math.abs(e.vals[t]??0)))),x=(e,t)=>{let n=Math.max(1,Math.floor((t-V)/7));return e.length>n?e.slice(0,n-1)+`…`:e},S=``,C=``;[t.x,...l].forEach((t,n)=>{let o=n?y(n-1):0,s=n?v:_,c=g?.[0]===t?g[1]:null,l=x(u(t),s-(c?14:0))+(c?c===`asc`?` ▲`:` ▼`:``);C+=a(`g`,{"data-maya":`sort`,"data-field":t,"data-sort":c,role:`button`,tabindex:0,"aria-label":c?e.t(`sortedBy`,u(t),e.t(c===`asc`?`ascending`:`descending`)):u(t)},a(`rect`,{x:i(o),y:0,width:i(s),height:z,fill:`transparent`})+a(`text`,{"data-th":!0,x:i(n?o+s-V:V),y:z/2,"text-anchor":n?`end`:`start`,"dominant-baseline":`middle`},r(l)))}),S+=a(`line`,{x1:0,x2:n,y1:z,y2:z});let w=Math.max(0,Math.floor((o-z)/B)),T=``;return p.slice(0,w).forEach((n,o)=>{let d=z+o*B,f=e.fmt(t.x,n.name);T+=a(`text`,{"data-key":s(`t`,n.name),x:V,y:d+B/2-2,"dominant-baseline":`middle`,"data-td":`label`},r(x(f,_))),l.forEach((t,p)=>{let m=n.vals[p],h=y(p)+v-V,g=m===null?`–`:e.fmt(t,m);if(T+=a(`text`,{"data-key":s(`v`,t,n.name),x:i(h),y:d+B/2-2,"text-anchor":`end`,"dominant-baseline":`middle`},r(g)),m===null)return;let _=b[p]?(v-16)*Math.abs(m)/b[p]:0,x={"data-key":s(t,n.name),"data-c":o,"data-s":l.length>1?p%8:0,"data-x":f,"data-series":u(t),"data-f":g,"data-y":m,"data-neg":m<0},S=d+B-7;T+=a(`rect`,{"data-maya":`mark`,...x,x:i(y(p)+V),y:S,width:i(_),height:4}),C+=c(x,y(p)+V,S,_,4)})}),{marks:T,hits:C,labels:``,grid:S}}},be=`0.2.0`,xe=Symbol.for(`mayacharts.marks@0`);Object.hasOwn(globalThis,xe)||Object.defineProperty(globalThis,xe,{value:/* @__PURE__ */ new Map});var Se=globalThis[xe],Ce=[`bar`,`line`,`area`,`scatter`,`heatmap`,`waterfall`,`kpi`,`dumbbell`,`ridgeline`,`beeswarm`,`parallel`,`table`],we={treemap:`hierarchy`,sunburst:`hierarchy`,marimekko:`hierarchy`,waffle:`hierarchy`,sankey:`flow`,chord:`flow`,radial:`radial`,hexmap:`geo`},Te=()=>[...Se.keys()],Ee=`--maya-fg:#1f2328;--maya-fg-muted:#656d76;--maya-bg:#fff`,De=`--maya-fg:#e6edf3;--maya-fg-muted:#9198a1;--maya-bg:#0d1117`,H=(e,t=0)=>Array.from({length:e},(e,n)=>n+t),Oe=H(8).map(e=>`[data-s="${e}"]{--c:var(--maya-series-${e+1})}`).join(``),ke=H(10).map(e=>`[data-q="${e}"]{--q:${Math.round(20+e*80/9)}%}`).join(``),Ae=H(8).map(e=>`.maya:has([data-s="${e}"]:hover) [data-maya=mark]:not([data-s="${e}"]){opacity:.3}`).join(``),je=H(3,2).map(e=>`.maya-ctl[data-n="${e}"]::before{width:calc((100% - 4px)/${e})}`).join(``)+H(3,1).map(e=>`.maya-ctl[data-i="${e}"]::before{transform:translateX(${e*100}%)}`).join(``),Me=`border:0;background:none;padding:0;font:inherit;color:var(--maya-fg-muted);cursor:pointer`,Ne=`:host,.maya-root{--maya-font:system-ui,sans-serif;--maya-font-size:12px;--maya-fg:light-dark(#1f2328,#e6edf3);--maya-fg-muted:light-dark(#656d76,#9198a1);--maya-grid:color-mix(in oklab,var(--maya-fg) 12%,transparent);--maya-bg:light-dark(#fff,#0d1117);--maya-accent:oklch(.6 .17 255);--maya-radius:2px;--maya-tooltip-bg:var(--maya-fg);--maya-tooltip-fg:var(--maya-bg);--maya-focus:var(--maya-accent);--maya-good:light-dark(#1a7f37,#3fb950);--maya-bad:light-dark(#cf222e,#f85149);--maya-series-1:var(--maya-accent);--maya-series-2:oklch(.66 .16 50);--maya-series-3:oklch(.62 .15 160);--maya-series-4:oklch(.66 .17 330);--maya-series-5:oklch(.62 .14 90);--maya-series-6:oklch(.62 .12 205);--maya-series-7:oklch(.64 .19 22);--maya-series-8:oklch(.62 .16 295);color-scheme:light dark}@supports not (color:light-dark(#000,#fff)){:host,.maya-root{${Ee}}@media (prefers-color-scheme:dark){:host,.maya-root{${De}}}}:host{display:block;position:relative;container-type:inline-size;min-height:200px}.maya{display:flex;flex-direction:column;height:100%;font:var(--maya-font-size) var(--maya-font);font-variant-numeric:tabular-nums;color:var(--maya-fg)}.maya-title{font-weight:600;font-size:14px}.maya-legend,.maya-crumbs{color:var(--maya-fg-muted);display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;margin:0 0 8px}.maya-crumbs{min-height:1.25em;line-height:1.25}.maya-legend button,.maya-crumbs button,.maya-reset{display:inline-flex;align-items:center;gap:6px;${Me};border-radius:4px}.maya-legend [aria-pressed=false]{opacity:.4}:is(.maya-legend,.maya-crumbs) button:focus-visible,.maya-reset:focus-visible,.maya-ctl :focus-visible{outline:2px solid var(--maya-focus);outline-offset:2px}i{width:10px;height:10px;border-radius:3px;background:var(--c)}[data-maya=ramp]{display:flex;align-items:center;gap:6px}[data-maya=ramp] i{width:80px;height:8px;background:linear-gradient(90deg,color-mix(in oklab,var(--maya-accent) 20%,var(--b)),var(--maya-accent))}[data-q],[data-maya=ramp] i{--b:light-dark(var(--maya-bg),color-mix(in oklab,var(--maya-accent) 15%,var(--maya-bg)))}.maya-legend span{display:inline-flex;align-items:center;gap:6px}.maya-reset{position:absolute;top:4px;right:4px;border:1px solid var(--maya-grid);border-radius:99px;padding:2px 10px;background:var(--maya-bg)}.maya-ctl{position:relative;display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;align-self:flex-start;margin:0 0 8px;padding:2px;border-radius:8px;background:var(--maya-grid)}.maya-ctl::before{content:'';position:absolute;inset:2px auto 2px 2px;width:calc(100% - 4px);border-radius:6px;background:var(--maya-bg);transition:transform .2s}`+je+`.maya-ctl [role=radio]{${Me};position:relative;padding:4px 12px;border-radius:6px}.maya-ctl [aria-checked=true]{color:var(--maya-fg);font-weight:600}.maya-err{margin:0;padding:8px;color:var(--maya-bad);white-space:pre-wrap;font:12px monospace}.maya-box{flex:1;min-height:0;position:relative}.maya-box svg{display:block;width:100%;height:100%;overflow:visible}.maya-svg{direction:ltr;font:var(--maya-font-size) var(--maya-font);font-variant-numeric:tabular-nums}.maya-svg text{fill:var(--maya-fg-muted);unicode-bidi:plaintext}[data-maya=grid] *{stroke:var(--maya-grid);shape-rendering:crispEdges}`+Oe+`[data-other],[data-total]{--c:var(--maya-fg-muted)}[data-tone=good]{--c:var(--maya-good)}[data-tone=bad]{--c:var(--maya-bad)}[data-q]{--c:color-mix(in oklab,var(--maya-accent) var(--q),var(--b))}`+ke+`[data-maya=mark]{fill:var(--c,var(--maya-series-1));rx:var(--maya-radius);transform-box:fill-box;transform-origin:0 0}[data-dir=h] [data-neg]{transform-origin:100% 0}[data-maya=mark],[data-maya=link]{transition:opacity .2s}[data-maya=mark][data-active]{fill:color-mix(in oklab,var(--c,var(--maya-series-1)),var(--maya-fg) 18%)}:where([data-xd] circle[data-maya=mark]){stroke:var(--maya-bg);stroke-width:1}[data-maya=line]~circle[data-maya=mark]:not([data-active],[data-selected],[data-last]){fill-opacity:0}[data-maya=line]{fill:none;stroke:var(--c);stroke-width:2;stroke-linejoin:round}[data-maya=area]{fill:color-mix(in oklab,var(--c) 18%,transparent);stroke:none}[data-maya=link]{fill:var(--c);opacity:.3}[data-maya=link][data-active]{opacity:.6}line[data-maya=link]{stroke:var(--c,var(--maya-fg-muted));opacity:1}text[data-maya=mark]{fill:var(--maya-fg);font-weight:600}[data-kpi=track]{fill:var(--maya-grid)}[data-kpi=target]{stroke:var(--maya-fg)}[data-maya=labels] [data-tone]{fill:var(--c)}[data-maya=labels] :is([data-kpi=period],[data-kpi=of]){fill:var(--maya-fg-muted)}[data-line] i{height:2px;border-radius:1px}[data-ridge]{fill:color-mix(in oklab,var(--c) 40%,var(--maya-bg))}[data-maya=grid] circle{fill:none;shape-rendering:auto}[data-maya=labels] [data-ring]{fill:var(--maya-fg-muted)}[data-maya=marks] text{fill:var(--maya-fg)}[data-maya=sort]{cursor:pointer}[data-maya=sort] rect{fill:transparent}[data-maya=sort] text{font-weight:600}[data-maya=sort]:focus-visible{outline:2px solid var(--maya-focus)}[data-maya=line]{transition:opacity .2s}[data-maya=marks]:has(path[data-active]) path[data-maya=line]:not([data-active]){opacity:.25}[data-depth]{stroke:var(--maya-bg);stroke-width:1}[data-maya=marks]:has([data-active]) [data-maya=mark]:not([data-active],text){opacity:.55}[data-maya=marks]:has([data-selected]) [data-maya=mark]:not([data-selected]){opacity:.35}[data-selected]{stroke:var(--maya-fg);stroke-width:2}`+Ae+`[data-maya=labels],[data-maya=cross]{pointer-events:none}[data-maya=cross]{opacity:0}[data-maya=labels] text{fill:var(--maya-fg);paint-order:stroke;stroke:var(--maya-bg);stroke-width:3;stroke-linejoin:round}[data-maya=labels] [data-in]{stroke:none}[data-maya=cross] line{stroke:var(--maya-fg-muted);stroke-dasharray:3 3}[data-maya=brush]{fill:var(--maya-accent);fill-opacity:.12;stroke:var(--maya-accent);vector-effect:non-scaling-stroke;pointer-events:none}.maya-svg:focus-visible{outline:2px solid var(--maya-focus)}.maya-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.maya-probe{position:absolute;width:0;height:0;pointer-events:none;anchor-name:--maya-probe}.maya-tip{margin:0;inset:auto;border:0;padding:6px 8px;background:var(--maya-tooltip-bg);color:var(--maya-tooltip-fg);border-radius:6px;box-shadow:0 2px 8px #0003;font:var(--maya-font-size) var(--maya-font);pointer-events:none}@supports (anchor-name:--x){.maya-tip{position-anchor:--maya-probe;position-area:block-start;position-try-fallbacks:flip-block,block-start span-inline-start,block-start span-inline-end;margin:8px}}.maya-tip{opacity:0;transition:opacity .12s}.maya-tip.maya-open{opacity:1}.maya-tip b{display:block}.maya-tip div{display:flex;align-items:center;gap:6px}.maya-tip i{outline:1px solid}.maya-tip [data-on]{font-weight:600}@media (pointer:coarse){:is(.maya-legend,.maya-crumbs) button,.maya-ctl [role=radio],.maya-reset,.maya-crumbs{min-height:24px}}@container (max-width:320px){.maya-legend{display:none}.maya-title{font-size:12px}}@media (prefers-contrast:more){:host,.maya-root{--maya-fg-muted:var(--maya-fg);--maya-grid:color-mix(in oklab,var(--maya-fg) 40%,transparent)}}@media (forced-colors:active){.maya-svg,i{forced-color-adjust:none}[data-maya=mark]{stroke:CanvasText;stroke-width:1}[data-tone=bad]{stroke-dasharray:4 2}}@media (prefers-reduced-motion:reduce){*{transition:none!important}}`,Pe=class extends Error{code;path;constructor(e,t,n){super(n),this.name=`MayaSpecError`,this.code=e,this.path=t}},U=e=>e.split(` `),W=Object.fromEntries([...U(`$schema x y2 series size name title description locale currency`).map(e=>[e,`string`]),...U(`stack horizontal labels legend tooltip drill zoom grid xAxis yAxis table animate`).map(e=>[e,`boolean`])]),Fe=[...U(`type data y path totals aggregate sort limit format titles text yDomain xDomain select`),...U(`colors colorBy theme`),...Object.keys(W)],Ie=[`bar`,`line`,`area`,`dumbbell`],Le=[`treemap`,`sunburst`,`sankey`,`chord`],Re=[`parallel`,`table`],G=`bar,line,area`,ze=`treemap,sunburst,sankey,chord`,Be=Object.fromEntries(U(`horizontal:bar,dumbbell y2:bar size:scatter name:scatter,beeswarm path:${G},dumbbell,${ze} totals:waterfall series:${G},scatter,heatmap,dumbbell,ridgeline,beeswarm,parallel,marimekko,radial sort:${G},heatmap,dumbbell,table,radial,waffle limit:${G},heatmap,dumbbell,table,waffle,radial stack:bar,area colorBy:${G},waterfall,scatter,dumbbell,kpi,treemap,sunburst,hexmap xDomain:scatter drill:${G},dumbbell,${ze} select:${G},waterfall,scatter,heatmap,dumbbell,beeswarm,parallel,table,marimekko,waffle,radial,treemap,sunburst,hexmap zoom:line,area,scatter`).map(e=>e.split(`:`)).map(([e,t])=>[e,t.split(`,`)])),Ve=U(`sum mean count min max`),He=U(`auto integer decimal compact percent currency date month year time datetime`),Ue=U(`dateStyle timeStyle weekday era year month day dayPeriod hour minute second fractionalSecondDigits timeZoneName timeZone hour12 hourCycle calendar`),We=e=>Ue.some(t=>Object.hasOwn(e,t)),Ge=[...U(`font fontSize fg fgMuted grid bg accent radius tooltipBg tooltipFg focus good bad`),...[1,2,3,4,5,6,7,8].map(e=>`series`+e)],Ke={x:`the category axis`,y:`the plotted numbers`,y2:`the right-axis line`,series:`splitting rows into series`,size:`bubble area`,name:`point identity`,path:`the hierarchy levels`,colorBy:`colouring marks by value`,format:`formatting that field`,titles:`naming that field`},qe=`Use horizontal: true to put categories on the left axis.`,Je=`Size comes from the element's CSS box, or render(spec, { width, height }).`,Ye=`Pie and donut charts are not supported: use "bar" or "treemap" to compare parts.`,Xe=`Use type: "hexmap" (import "mayacharts/geo").`,Ze=`Example: { type: "bar", data: [{ month: "Jan", revenue: 10 }], x: "month", y: "revenue" }`,Qe={label:`Use titles: { <field>: "Name" } for display names, or labels: true for values on marks.`,xLabel:`Use titles: { <x field>: "Name" }. titles is keyed by field and also names tooltips and table headers.`,yLabel:`Use titles: { <y field>: "Name" }. titles is keyed by field and also names tooltips, legend and table headers.`,yFormat:`Use format: "compact" (applies to every y), or format: { <field>: "currency" }.`,dataKey:`Use y: "<field>" for values and x: "<field>" for categories.`,indexAxis:qe,orientation:qe,width:Je,height:Je,color:`Use colors: [...] for the palette, or colorBy: "sign" | { target: n } | "<field>".`,groupBy:`Use series: "<field>".`,formatter:`Functions are not supported (the spec is JSON). Use format presets or Intl options.`,"size:number":`spec.size names a field for bubble area. For chart size use CSS, or render(spec, { width, height }).`,"select:boolean":`Use select: true or "multi"; omit it to disable selection.`},$e={column:`Use type: "bar".`,barh:`Use type: "bar" with horizontal: true.`,bubble:`Use type: "scatter" with size: "<field>".`,choropleth:Xe,map:Xe,pie:Ye,donut:Ye},et=U(`rgb rgba hsl hsla oklch oklab lab lch color color-mix light-dark var calc`),tt=String.raw`\s*(?:"[\w\s.\-]*"|'[\w\s.\-]*'|[\w\-]+(?:\s+[\w\-]+)*)\s*`,nt=RegExp(`^${tt}(?:,${tt})*$`),rt=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,K=e=>typeof e==`object`&&!!e&&!Array.isArray(e),q=(e,t=0)=>Array.isArray(e)&&e.length>=t&&e.every(e=>typeof e==`string`),J=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,Y=e=>{let t=typeof e==`string`||K(e)||Array.isArray(e)?JSON.stringify(e):String(e);return t.length>60?t.slice(0,59)+`…`:t},X=(e,t)=>{let n=e.toLowerCase(),r=``,i=40;for(let e of t){let t=e.toLowerCase(),a=Math.abs(n.length-t.length)+[...t].filter(e=>!n.includes(e)).length,o=0;for(;o<9&&n[o]!==void 0&&n[o]===t[o];)o++;a<4&&a*10-o<i&&([i,r]=[a*10-o,e])}return r&&`Did you mean "${r}"?`},Z=(e,t,n,...r)=>{throw new Pe(e,t,`mayacharts: ${n}\n${[...r,`-> https://bbekshr.github.io/mayacharts/errors.html#${e}`].filter(Boolean).map(e=>` `+e).join(`
3
- `)}`)},Q=(e,t,n)=>Z(`invalid-option`,e,`spec.${e} must be ${n}, received ${Y(t)}.`,rt(Qe,`${e}:${J(t)}`)??``),it=(e,t,n)=>{let r=n?nt.test(t):/^[#\w\s.,%()+\-\/]*$/.test(t)&&[...t.matchAll(/([\w-]*)\s*\(/g)].every(e=>et.includes(e[1].toLowerCase()));(!t||!r)&&Z(`unsafe-css-value`,e,`spec.${e} = ${Y(t)} is not a safe CSS value.`,`Allowed: colours, lengths, numbers and ${et.join(`() `)}(); fonts are family names.`,`Not allowed: url(), image-set(), other functions, ; { } < > \\ and (outside fonts) quotes.`)},$=(e,t,...n)=>Z(`invalid-format`,e,t,...n),at=(e,t,n)=>{if(typeof t==`string`){He.includes(t)||$(e,`spec.${e} = ${Y(t)} is not a format preset.`,`Presets: ${He.join(`, `)}. Or per field: { <field>: preset or Intl options }.`,X(t,He));return}K(t)||$(e,`spec.${e} must be a preset or Intl options, received ${Y(t)}.`);let{prefix:r,suffix:i,...a}=t;for(let[t,n]of[[`prefix`,r],[`suffix`,i]])n!==void 0&&typeof n!=`string`&&$(`${e}.${t}`,`spec.${e}.${t} must be a string, received ${Y(n)}.`);let o=We(a);try{o?new Intl.DateTimeFormat(n,a):new Intl.NumberFormat(n,a)}catch(n){$(e,`spec.${e} = ${Y(t)} is not valid ${o?`Intl.DateTimeFormat`:`Intl.NumberFormat`} options.`,n instanceof Error?n.message:String(n))}},ot=[[`y`,`a field name or a non-empty array of field names`,e=>typeof e==`string`||q(e,1)],[`path`,`a non-empty array of field names`,e=>q(e,1)],[`totals`,`an array of x values (strings)`,e=>q(e)],[`aggregate`,`one of ${Ve.join(`, `)}`,e=>Ve.includes(e)],[`sort`,`"asc" or "desc"`,e=>e===`asc`||e===`desc`],[`limit`,`a positive integer`,e=>Number.isInteger(e)&&e>0],[`select`,`true or "multi"`,e=>e===!0||e===`multi`],[`colorBy`,`"sign", { target: number } or a numeric field name`,e=>typeof e==`string`&&!!e||K(e)&&Object.keys(e).join()===`target`&&Number.isFinite(e.target)],[`titles`,`an object of strings keyed by field`,e=>K(e)&&Object.values(e).every(e=>typeof e==`string`)]];function st(t){K(t)||Z(`spec-not-object`,`spec`,`spec must be a plain object, received ${J(t)}.`,`Received: ${Y(t)}`);let n=t;for(let e of Object.keys(n))Fe.includes(e)||Z(`unknown-option`,e,`spec.${e} is not a known option.`,rt(Qe,e)??X(e,Fe),`Known options: ${Fe.join(`, `)}.`);let r=n.type;r===void 0&&Z(`missing-field`,`type`,`spec.type is required but missing.`,`Required fields: type, data, x, y.`,Ze);let i=[...Ce,...Te()],a=typeof r==`string`?r:void 0;if(a===void 0||!i.includes(a)){let e=a===void 0?void 0:rt(we,a);e&&Z(`unknown-type`,`type`,`spec.type = "${r}" needs the "${e}" module, which is not loaded.`,`Add: import "mayacharts/${e}"`),Z(`unknown-type`,`type`,`spec.type = ${Y(r)} is not a chart type.`,`Valid types: ${i.join(`, `)}.`,a===void 0?``:rt($e,a)??X(a,[...i,...Object.keys(we)]))}let o=r,s=Le.includes(o),c=s?`path`:`x`,l=t.path;o===`sankey`&&Array.isArray(l)&&l.length<2&&Z(`invalid-option`,`path`,`spec.path needs at least two levels for a sankey.`,`Example: path: ["region", "family"]`),o===`chord`&&Array.isArray(l)&&l.length!==2&&Z(`invalid-option`,`path`,`spec.path needs exactly two levels for a chord: from and to.`,`Example: path: ["region", "family"]`);let u=e=>Z(`missing-field`,e,`spec.${e} is required but missing.`,`Required fields: type, data, ${c}, y.`,s?`Example: { type: "${o}", data: [{ region: "N", state: "NY", sales: 10 }], path: ["region", "state"], y: "sales" }`:Ze);n.data===void 0&&u(`data`),Array.isArray(n.data)||Z(`data-not-array`,`data`,`spec.data must be an array of rows, received ${J(n.data)}.`);let d=n.data;d.forEach((e,t)=>{K(e)||Z(`row-not-object`,`data[${t}]`,`spec.data[${t}] must be an object, received ${J(e)}.`,`Received: ${Y(e)}`)}),n[c]===void 0&&o!==`kpi`&&o!==`beeswarm`&&!(c===`x`&&Ie.includes(o)&&n.path!==void 0)&&u(c),n.y===void 0&&u(`y`),(o===`dumbbell`||o===`ridgeline`||o===`marimekko`)&&n.series===void 0&&u(`series`),o===`parallel`&&!(Array.isArray(n.y)&&n.y.length>=2)&&Z(`invalid-option`,`y`,`spec.y on "parallel" needs an array of at least 2 measures, one axis each.`,`Example: y: ["sales", "units", "price"]`);for(let e in W)n[e]!==void 0&&typeof n[e]!==W[e]&&Q(e,n[e],`a ${W[e]}`);for(let[e,t,r]of ot)n[e]!==void 0&&!r(n[e])&&Q(e,n[e],t);let{y:f,path:p,select:m,colors:h,colorBy:g,theme:_,text:v}=n;if(v!==void 0){K(v)||Q(`text`,v,`an object of strings`);for(let[t,n]of Object.entries(v))Object.hasOwn(e,t)||Z(`invalid-option`,`text.${t}`,`spec.text.${t} is not a text key.`,X(t,Object.keys(e)),`Text keys: ${Object.keys(e).join(`, `)}.`),typeof n!=`string`&&Q(`text.${t}`,n,`a string`)}for(let e of[`yDomain`,`xDomain`]){let t=n[e];t!==void 0&&!(Array.isArray(t)&&t.length===2&&Number.isFinite(t[0])&&Number.isFinite(t[1])&&(e===`yDomain`?t[0]!==t[1]:t[0]<t[1]))&&Z(`invalid-domain`,e,`spec.${e} = ${Y(t)} is not a valid domain.`,e===`yDomain`?`Expected [min, max] (or [max, min] to reverse) with two different finite numbers.`:`Expected [min, max] with finite numbers and min < max, e.g. [0, 100].`)}let y=`en-US`;if(typeof n.locale==`string`){let e=!1;try{e=Intl.NumberFormat.supportedLocalesOf(n.locale).length>0}catch{}e||$(`locale`,`spec.locale = ${Y(n.locale)} is not a locale this runtime supports.`,`Use a BCP 47 tag such as "de-DE". Node built with small ICU supports English only.`),y=n.locale}if(typeof n.currency==`string`)try{new Intl.NumberFormat(y,{style:`currency`,currency:n.currency})}catch{$(`currency`,`spec.currency = ${Y(n.currency)} is not an ISO 4217 currency code.`,`Use a three-letter code such as "USD" or "EUR".`)}if(typeof n.format==`string`)at(`format`,n.format,y);else if(n.format!==void 0){K(n.format)||Q(`format`,n.format,`a preset or an object keyed by field`);for(let[e,t]of Object.entries(n.format))at(`format.${e}`,t,y)}if(h!==void 0){let e=Array.isArray(h)?h.map((e,t)=>[`[${t}]`,e]):K(h)?Object.entries(h).map(([e,t])=>[`.${e}`,t]):null;(!e||!e.every(([,e])=>typeof e==`string`))&&Q(`colors`,h,`an array of colours, or an object of colours by series value`),e.length>8&&Z(`invalid-option`,`colors`,`spec.colors has ${e.length} colours; the palette has 8 slots.`,`Pass at most 8. Series 9 and later reuse slots in order.`);for(let[t,n]of e)it(`colors${t}`,n,!1)}if(_!==void 0){K(_)&&Object.values(_).every(e=>typeof e==`string`)||Q(`theme`,_,`an object of string values`);for(let e of Object.keys(_))Ge.includes(e)||Z(`invalid-theme`,`theme.${e}`,`spec.theme.${e} is not a theme token.`,`Valid tokens: ${Ge.join(`, `)}.`,X(e,Ge));for(let[e,t]of Object.entries(_))it(`theme.${e}`,t,e===`font`)}n.stack===!0&&o===`line`&&Z(`stack-unsupported`,`stack`,`spec.stack is not supported with spec.type = "line".`,`Use type "area" (or "bar") to stack series.`);for(let e in Be)n[e]!==void 0&&n[e]!==!1&&!Be[e].includes(o)&&Z(`option-unsupported`,e,`spec.${e} is not supported with spec.type = "${o}".`,`spec.${e} works with: ${Be[e].join(`, `)}.`);let b=Ie.includes(o),x=[[g!==void 0&&n.series!==void 0&&o!==`dumbbell`,`colorBy`,`spec.colorBy cannot be combined with spec.series.`,`Series already set the colours; remove one of them.`],[n.yDomain!==void 0&&Array.isArray(f),`yDomain`,`spec.yDomain cannot be combined with a y array.`,`Each measure needs its own domain; use a single y or remove yDomain.`],[n.drill===!0&&m!==void 0,`select`,`spec.select cannot be combined with spec.drill.`,`A click either drills or selects; choose one.`],[b&&p!==void 0&&n.x!==void 0,`x`,`spec.x cannot be combined with spec.path.`,`With path, the current drill level is the category; remove x.`],[n.y2!==void 0&&n.horizontal===!0,`y2`,`spec.y2 cannot be combined with spec.horizontal.`,`The y2 line needs a right value axis; draw vertical bars.`],[o===`kpi`&&g!==void 0&&!K(g),`colorBy`,`spec.colorBy on "kpi" must be { target: number }.`,`A kpi compares its headline with one target, drawn as a bullet bar.`],[b&&n.drill===!0&&p===void 0,`drill`,`spec.drill on "${o}" needs spec.path.`,`Replace x with path: ["region", "state"] (outer to inner).`]];for(let[e,t,n,r]of x)e&&Z(`option-unsupported`,t,n,r);if(d.length){let e=[...new Set(d.flatMap(e=>Object.keys(e)))],t=(t,n,r,i)=>Z(`unknown-field`,t,n,`Fields found: ${e.slice(0,20).join(`, `)}.`,X(r,e),i),r=typeof f==`string`?[f]:f,i=(e,t)=>t.map((t,n)=>[`${e}[${n}]`,t]),a=[[`x`,n.x],...typeof f==`string`?[[`y`,f]]:i(`y`,r),[`series`,n.series],[`y2`,n.y2],[`size`,n.size],[`name`,n.name],...i(`path`,p??[]),[`colorBy`,g===`sign`?void 0:g]];for(let[n,r]of a){if(typeof r!=`string`||e.includes(r))continue;let i=n.replace(/\[.*/,``);t(n,`spec.${n} = ${Y(r)} is not a field in spec.data.`,r,`spec.${i} names the field used for ${Ke[i]}.`)}for(let r of[`format`,`titles`])if(K(n[r]))for(let i of Object.keys(n[r]))e.includes(i)||t(`${r}.${i}`,`spec.${r} key "${i}" is not a field in spec.data.`,i,`spec.${r} keys name fields, for ${Ke[r]}.`);g===`sign`&&e.includes(`sign`)&&Z(`invalid-option`,`colorBy`,`spec.colorBy = "sign" colours by the sign of y, but spec.data also has a field named "sign".`,`Rename that field (e.g. data.map(({ sign, ...r }) => ({ ...r, signValue: sign }))) to colour by it.`);let c=(e,t)=>d.forEach((n,r)=>t(n[e],`data[${r}].${e}`)),l=(e,t,n)=>c(e,(r,i)=>{r==null||typeof r==`number`&&Number.isFinite(r)||Z(t,i,`spec.${i} is ${Y(r)} (a ${J(r)}), but spec.${n} requires numbers.`,typeof r==`string`&&r.trim()&&Number.isFinite(Number(r))?`Convert first: data.map(r => ({ ...r, ${e}: Number(r.${e}) }))`:`Use null for a gap in the data.`)});for(let e of r)l(e,`non-numeric-y`,`y`);if(typeof n.size==`string`&&l(n.size,`non-numeric-field`,`size`),typeof n.y2==`string`&&l(n.y2,`non-numeric-field`,`y2`),o===`dumbbell`&&typeof n.series==`string`){let e=new Set(d.map(e=>String(e[n.series]))).size;e!==2&&Z(`invalid-option`,`series`,`spec.series on "dumbbell" needs exactly 2 values, found ${e}.`,`The first value seen is the start of each bar, the second the end, e.g. last year and this year.`)}if(o===`scatter`&&typeof n.x==`string`&&l(n.x,`non-numeric-field`,`x`),typeof g==`string`&&g!==`sign`&&l(g,`non-numeric-field`,`colorBy`),s)for(let e of r)c(e,(t,n)=>{typeof t==`number`&&t<=0&&Z(`non-positive-value`,n,`spec.${n} is ${t}, but ${o} sizes must be positive.`,`Filter first: data.filter(r => r.${e} > 0), or chart the signed values with "bar".`)})}Se.get(o)?.check?.(t,Z)}function ct(e){if(e===void 0)return;K(e)||Z(`invalid-option`,`options`,`options must be a plain object, received ${J(e)}.`);let t=e,n=(e,t,n)=>Z(`unknown-option`,`${e}.${t}`,`${e}.${t} is not a known render option.`,X(t,n),`Known options: ${n.join(`, `)}.`),r=U(`width height view selected nonce`);for(let e of Object.keys(t))r.includes(e)||n(`options`,e,r);let i=(e,t,n)=>Z(`invalid-option`,`options.${e}`,`options.${e} must be ${n}, received ${Y(t)}.`);for(let e of[`width`,`height`]){let n=t[e];n!==void 0&&!(typeof n==`number`&&Number.isFinite(n)&&n>0)&&Z(`invalid-size`,`options.${e}`,`options.${e} = ${Y(n)} is not a valid size.`,`Size must be a finite number greater than 0.`)}let{view:a,selected:o,nonce:s}=t;if(a!==void 0){K(a)||i(`view`,a,`an object`);let e=U(`measure drill window hidden sortBy`);for(let t of Object.keys(a))e.includes(t)||n(`options.view`,t,e);let{measure:t,drill:r,window:o,hidden:s,sortBy:c}=a;c!==void 0&&(!Array.isArray(c)||c.length!==2||typeof c[0]!=`string`||c[1]!==`asc`&&c[1]!==`desc`)&&i(`view.sortBy`,c,`[field, "asc" | "desc"]`),t!==void 0&&!(Number.isInteger(t)&&t>=0)&&i(`view.measure`,t,`an index (integer >= 0)`),r!==void 0&&!q(r)&&i(`view.drill`,r,`an array of strings`),s!==void 0&&!q(s)&&i(`view.hidden`,s,`an array of strings`),o!==void 0&&(!Array.isArray(o)||o.length!==2&&o.length!==4||!o.every(Number.isFinite))&&i(`view.window`,o,`[i0, i1] or [x0, x1, y0, y1] of finite numbers`)}o!==void 0&&!(Array.isArray(o)&&o.every(e=>K(e)&&Object.keys(e).every(e=>[`x`,`series`,`name`].includes(e))))&&i(`selected`,o,`an array of { x?, series?, name? }`),s!==void 0&&!(typeof s==`string`&&/^[\w+/=-]+$/.test(s))&&i(`nonce`,s,`a base64 nonce string`)}function lt(e,t={}){let n=typeof e.y==`string`?[e.y]:[...e.y],r=Math.min(t.measure??0,n.length-1),i=[...e.path??[]],a=e.drill?(t.drill??[]).slice(0,Math.max(0,i.length-1)):[],o=i.slice(a.length),s=e.format,c=e=>Object.entries(e??{}).filter(e=>e[1]!==void 0);return{type:e.type,data:a.length?e.data.filter(e=>a.every((t,n)=>String(e[i[n]])===t)):e.data,x:e.x??(Ie.includes(e.type)?o[0]??``:``),y:n[r],measures:n,measure:r,series:e.series??null,y2:e.y2??null,path:o,drilled:a,window:t.window&&t.window.length===4?t.window:null,size:e.size??null,name:e.name??null,totals:[...e.totals??[]],stack:e.stack??!1,horizontal:e.horizontal??!1,aggregate:e.aggregate??`sum`,sort:e.sort??null,sortBy:t.sortBy??null,limit:e.limit??null,format:new Map(typeof s==`string`?n.map(e=>[e,s]):c(s)),titles:new Map(c(e.titles)),labels:e.labels??null,text:{...e.text},title:e.title??null,description:e.description??null,legend:e.legend??(e.series!==void 0||e.y2!==void 0||e.type===`waffle`),tooltip:e.tooltip??!0,drill:e.drill??!1,select:e.select??!1,zoom:e.zoom??!1,grid:e.grid??!0,xAxis:e.xAxis??!0,yAxis:e.yAxis??!0,locale:e.locale??`en-US`,currency:e.currency??`USD`,yDomain:e.yDomain??null,xDomain:e.xDomain??null,table:e.table??!0,animate:e.animate??!0,colors:Array.isArray(e.colors)?e.colors:e.colors?new Map(Object.entries(e.colors)):null,colorBy:e.colorBy??null,theme:e.theme??{}}}var ut={bar:P,waterfall:P,line:pe,area:me,scatter:_e,heatmap:te,kpi:ie,dumbbell:L,ridgeline:ue,beeswarm:ee,parallel:le,table:ye},dt=e=>e.replace(/[A-Z]|\d+/g,e=>`-`+e.toLowerCase());function ft(e,n,o){st(e),n!==void 0&&ct(n);let s=Object.hasOwn(ut,e.type)?ut[e.type]:Se.get(e.type),c=lt(e,n?.view),u=n?.width??640,d=n?.height??320,m=A(c,n?.view??{}),h=e=>e>5e3&&Z(`too-many-marks`,`data`,`${e} marks exceed the limit of 5000.`,`Use spec.limit to keep the top N categories, or aggregate the rows first.`);h(m.cells.length);let g=/* @__PURE__ */ new Map,v=(e,n,r)=>{if(n===`\0other`)return t(c,`other`);let i=e+`\0`+r,a=g.get(i);return a||g.set(i,a=_(c,e,r)),a(n)},y=c.colorBy,b=1/0,x=-1/0;if(typeof y==`string`&&y!==`sign`)for(let e of c.data){let t=e[y];typeof t==`number`&&(b=Math.min(b,t),x=Math.max(x,t))}let S=e=>y===`sign`?e<0?`bad`:`good`:y&&typeof y==`object`?e>=y.target?`good`:`bad`:null,C=e=>{let n=S(e);return n===null?null:t(c,y===`sign`?n===`good`?`positive`:`negative`:n===`good`?`above`:`below`)},w=[],T=``,E=(e,t,n,o)=>{let s=n.length*7.2+4,c=o===`start`?e:o===`end`?e-s:e-s/2,l=o===`above`?t-16:o===`below`?t+2:t-7;return c<0||l<0||c+s>u||l+14>d||w.some(e=>c<e[2]&&c+s>e[0]&&l<e[3]&&l+14>e[1])?!1:(w.push([c,l,c+s,l+14]),T+=a(`text`,{x:i(e),y:i(o===`above`?t-4:o===`below`?t+13:t),"text-anchor":o===`start`||o===`end`?o:`middle`,"dominant-baseline":o===`above`||o===`below`?null:`middle`,"data-in":o===`center`},r(n)),!0)},D=s.axes?O(c,s.axes(c,m),{width:u,height:d},v):null,j=D?.plot??{x:0,y:0,w:u,h:d},M={spec:c,shaped:m,width:u,height:d,plot:j,x:D?.x??null,y:D?.y??null,y2:D?.y2??null,fmt:v,label:E,tone:S,q:e=>x>b?Math.min(9,Math.max(0,Math.floor((e-b)/(x-b)*10))):9,agg:e=>t=>{let n=k(e);for(let e of t)typeof e==`number`&&n.add(e);return n.value()},fail:Z,t:(e,...n)=>t(c,e,...n)};s.check?.(e,Z);let N=null,P=``;if(c.data.length===0)P=a(`text`,{"data-maya":`empty`,x:u/2,y:d/2,"text-anchor":`middle`,"dominant-baseline":`middle`},r(t(c,`noData`)));else{let e=(e,t)=>a(`g`,{"data-maya":e},t),t=s.draw(M);h(t.marks.split(` data-maya="mark"`).length-1),N=t.legend??null,P=e(`grid`,t.grid??D?.grid??``)+e(`axis-y`,D?.ay??``)+e(`axis-x`,D?.ax??``)+e(`marks`,t.marks)+e(`labels`,(t.labels??``)+T)+e(`cross`,t.cross??``)+e(`hits`,t.hits)}let F=[];if(Array.isArray(c.colors))c.colors.forEach((e,t)=>F.push([`--maya-series-${t+1}`,e]));else if(c.colors)for(let[e,t]of c.colors){let n=m.series.indexOf(e);n>=0&&F.push([`--maya-series-${n%8+1}`,t])}for(let e in c.theme)F.push([`--maya-${dt(e)}`,c.theme[e]]);let I=F.map(([e,t])=>`${e}:${t};`).join(``),ee=a(`svg`,{class:o===null?`maya-svg`:`maya-root maya-svg`,viewBox:`0 0 ${u} ${d}`,width:u,height:d,role:`img`,"aria-label":o===null?null:l(c),"aria-labelledby":o===null?`maya-t`:null,"aria-describedby":o===null?`maya-d`:null,tabindex:o===null?`0`:null,style:o===null?null:I||null,"data-plot":`${i(j.x)} ${i(j.y)} ${i(j.w)} ${i(j.h)}`,...D?.attrs,"data-dir":c.horizontal?`h`:null},(o?`<style>${o}</style>`:``)+a(`title`,{id:o===null?`maya-t`:null},r(l(c)))+a(`desc`,{id:o===null?`maya-d`:null},r(f(c,m,v,s.noun)))+P),L=``;return N!==null&&c.legend?L=N:(c.series!==null||c.y2!==null)&&c.legend?L=`<div class="maya-legend" data-maya="legend">`+(c.series===null&&c.y2!==null?`<span data-s="0"><i></i>${r(c.titles.get(c.y)??c.y)}</span>`:``)+(c.series===null?[]:m.series).map((e,t)=>a(`button`,{type:`button`,"data-si":t,"data-s":t%8,"data-key":e,"aria-pressed":String(m.visible.includes(t))},`<i></i>${r(e)}`)).join(``)+(c.y2===null?``:`<span data-s="${m.series.length%8}" data-line><i></i>${r(c.titles.get(c.y2)??c.y2)}</span>`)+`</div>`:e.legend!==!1&&y!==null&&c.series===null&&c.type!==`kpi`&&(L=y===`sign`||typeof y==`object`?`<div class="maya-legend" data-maya="tone">`+[`good`,`bad`].map(e=>`<span data-tone="${e}"><i></i>${r(t(c,y===`sign`?e===`good`?`positive`:`negative`:e===`good`?`above`:`below`))}</span>`).join(``)+`</div>`:x>b?`<div class="maya-legend" data-maya="ramp"><span>${r(v(y,b))}</span><i></i><span>${r(v(y,x))}</span></div>`:``),{svg:ee,legend:L,controls:c.measures.length>1&&!Re.includes(c.type)?`<div class="maya-ctl" role="radiogroup" aria-label="${r(t(c,`measures`))}" data-n="${c.measures.length}" data-i="${c.measure}">`+c.measures.map((e,t)=>`<button type="button" role="radio" aria-checked="${t===c.measure}" data-i="${t}" tabindex="${t===c.measure?0:-1}">${r(c.titles.get(e)??e)}</button>`).join(``)+`</div>`:``,crumbs:c.drilled.length>0?`<nav class="maya-crumbs" aria-label="${r(t(c,`crumbs`))}"><button type="button" data-depth="0">${r(t(c,`back`))}</button>`+c.drilled.map((e,t)=>`<span aria-hidden="true">›</span><button type="button" data-depth="${t+1}"${t===c.drilled.length-1?` aria-current="page"`:``}>${r(String(e))}</button>`).join(``)+`</nav>`:c.drill?`<div class="maya-crumbs" aria-hidden="true"></div>`:``,table:c.table?p(c,m,v,C):``,title:c.title===null?``:`<div class="maya-title">${r(c.title)}</div>`,style:I,vars:F,warnings:[]}}function pt(e,t){return ft(e,t,null)}function mt(e,t){return ft(e,t,Ne).svg}function ht(e,t,n){let i=e.style?` style="${r(e.style)}"`:``,a=n?` nonce="${r(n)}"`:``;return`${t?`<style${a}>${t}</style>`:``}<div class="maya"${i}>${e.title}${e.controls}${e.legend}${e.crumbs}<div class="maya-box">${e.svg}</div>${e.table}<div class="maya-sr" data-maya="live" aria-live="polite"></div><div class="maya-probe" data-maya="probe"></div><div class="maya-tip" popover="manual" role="tooltip"></div></div>`}function gt(e){let t=e=>typeof e==`object`?Object.keys(e):[],n=/* @__PURE__ */ new Set([e.x,...typeof e.y==`string`?[e.y]:e.y,e.series,e.y2,e.size,e.name,...e.path??[],typeof e.colorBy==`string`?e.colorBy:void 0,...t(e.format),...t(e.titles)]);return{...e,data:e.data.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e))))}}function _t(e,t){let n=pt(e,t),r=JSON.stringify(gt(e)).replace(/</g,`\\u003c`);return`<maya-chart><template shadowrootmode="open">${ht(n,Ne,t?.nonce)}</template><script type="application/json">${r}<\/script></maya-chart>`}export{Pe as MayaSpecError,mt as render,pt as renderParts,_t as renderShell,st as validateSpec,be as version};
1
+ /*! mayacharts v0.3.0 | MIT | https://github.com/BbekShr/mayacharts */
2
+ var e={noData:`No data`,other:`Other`,back:`Back`,reset:`Reset zoom`,showing:`Showing {0}`,drilledInto:`Drilled into {0}`,zoomedTo:`Zoomed to {0} – {1}`,selected:`{0} selected`,selectionCleared:`Selection cleared`,chartOf:`{0} chart of {1} by {2}`,chartOfAll:`{0} chart of {1}`,firstOf:`First {0} of {1} rows`,measures:`Measure`,crumbs:`Drill path`,positive:`positive`,negative:`negative`,above:`above target`,below:`below target`,vs:`{0} vs {1}`,sortedBy:`Sorted by {0}, {1}`,ascending:`ascending`,descending:`descending`,ofTarget:`{0} of target {1}`};function t(t,n,...r){return((t.text&&Object.hasOwn(t.text,n)?t.text[n]:void 0)??e[n]).replace(/\{(\d)\}/g,(e,t)=>String(r[+t]??``))}var n={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function r(e){return String(e).replace(/[&<>"']/g,e=>n[e])}function i(e){return Math.round(e*100)/100}function a(e,t,n){let i=``;for(let e in t){let n=t[e];n!=null&&n!==!1&&(i+=n===!0?` ${e}=""`:` ${e}="${r(n)}"`)}return n===void 0?`<${e}${i}/>`:`<${e}${i}>${n}</${e}>`}var o=`\0other`,s=(...e)=>e.map(e=>encodeURIComponent(String(e).replace(/\p{Cs}/gu,`�`)).replace(/~/g,`%7E`)).join(`~`);function c(e,t,n,r,o){let[s,c]=[Math.max(r,24),Math.max(o,24)];return r<24||o<24?a(`rect`,Object.assign({"data-maya":`hit`},e,{"data-maya":`hit`,x:i(t-(s-r)/2),y:i(n-(c-o)/2),width:i(s),height:i(c),fill:`transparent`})):``}var l=e=>e.title??`${e.titles.get(e.y)??e.y}`+(e.x||e.path.length?` by ${e.titles.get(e.x)??(e.x||e.path.join(` / `))}`:``),u=[`scatter`,`treemap`,`sunburst`,`sankey`,`hexmap`],d=1e3;function f(e,n,r,i){if(e.description!==null)return e.description;let a=t=>e.titles.get(t)??t,o=e.x||e.path.length?t(e,`chartOf`,i,a(e.y),e.x?a(e.x):e.path.join(` / `)):t(e,`chartOfAll`,i,a(e.y));if(e.series!==null&&n.series.length&&(o+=`, ${e.stack?`stacked`:`grouped`} by ${a(e.series)} (${n.series.join(`, `)})`),u.includes(e.type))return`${o}. ${e.data.length} rows.`;let s=0,c=1/0,l=-1/0;for(let e of n.cells)e.value!==null&&(s++,c=Math.min(c,e.value),l=Math.max(l,e.value));let d=t=>r(e.y,t);return s?s===1?`${o}. 1 value: ${d(c)}.`:`${o}. ${s} values from ${d(c)} to ${d(l)}.`:o+`. No data.`}function p(e,n,i,a){let o=t=>e.titles.get(t)??t,s=(t,n)=>{if(n==null)return``;let o=t===e.y&&typeof n==`number`?a(n):null;return r(i(t,n))+(o?` (${r(o)})`:``)},c=n=>n>d?t(e,`firstOf`,d,n):l(e),f,p,m;if(u.includes(e.type)){let t=[...new Set([e.x,...e.path,e.series,e.name,e.size,e.y,typeof e.colorBy==`string`&&e.colorBy!==`sign`?e.colorBy:null].filter(e=>!!e))];m=e.data.length,f=t.map(e=>`<th>${r(o(e))}</th>`).join(``),p=e.data.slice(0,d).map(e=>`<tr>${t.map(t=>`<td>${s(t,e[t])}</td>`).join(``)}</tr>`).join(``)}else{let t=e.series===null?[o(e.y)]:n.visible.map(e=>n.series[e]);m=n.categories.length,f=`<th>${r(o(e.x))}</th>`+t.map(e=>`<th>${r(e)}</th>`).join(``);let i=new Map(n.cells.map(e=>[e.ci+`,`+e.si,e.value]));p=``;for(let t=0;t<Math.min(m,d);t++){p+=`<tr><th scope="row">${r(n.categories[t])}</th>`;for(let r of n.visible)p+=`<td>${s(e.y,i.get(t+`,`+r))}</td>`;p+=`</tr>`}}return`<table class="maya-sr"><caption>${r(c(m))}</caption><thead><tr>${f}</tr></thead><tbody>${p}</tbody></table>`}var m=e=>{for(let t=0;t<8;t++)if(Math.abs(e*10**t-Math.round(e*10**t))<1e-9)return t;return 8},h=`year month day hour minute second weekday era timeZone dateStyle timeStyle fractionalSecondDigits hour12 dayPeriod timeZoneName`.split(` `),g={date:{dateStyle:`medium`},month:{month:`short`,year:`numeric`},year:{year:`numeric`},time:{timeStyle:`short`},datetime:{dateStyle:`medium`,timeStyle:`short`}};function _(e,t=e.y,n){typeof t==`number`&&([t,n]=[e.y,t]);let r=e.format.get(t),i=Intl.NumberFormat.supportedLocalesOf(e.locale).length?e.locale:`en-US`,a=n===void 0?2:m(n),o=``,s=``,c=null,l=null,u=null,d=typeof r==`string`?r:`auto`;if(typeof r==`string`&&Object.hasOwn(g,r))c=new Intl.DateTimeFormat(i,{timeZone:`UTC`,...g[r]});else if(typeof r==`object`&&r){let{prefix:e=``,suffix:t=``,...n}=r;[o,s]=[String(e),String(t)],h.some(e=>Object.hasOwn(n,e))?c=new Intl.DateTimeFormat(i,{timeZone:`UTC`,...n}):l=new Intl.NumberFormat(i,n)}if(!c&&!l){let t=d===`integer`?{maximumFractionDigits:0}:d===`decimal`?{minimumFractionDigits:2,maximumFractionDigits:2}:d===`compact`?{notation:`compact`,maximumFractionDigits:1}:d===`percent`?{style:`percent`,minimumFractionDigits:n===void 0?0:m(n*100),maximumFractionDigits:n===void 0?1:Math.max(1,m(n*100))}:d===`currency`?{style:`currency`,currency:e.currency,minimumFractionDigits:n!==void 0&&n>=1?0:a,maximumFractionDigits:n!==void 0&&n>=1?0:Math.max(a,2)}:{maximumFractionDigits:Math.max(a,2)};l=new Intl.NumberFormat(i,t),d===`percent`&&n===void 0&&(u=new Intl.NumberFormat(i,{...t,maximumFractionDigits:2}))}return e=>{if(e==null)return``;let t;if(c){let n=typeof e==`string`&&/^-?\d+$/.test(e)?/* @__PURE__ */ new Date(+e):typeof e==`number`||typeof e==`string`||e instanceof Date?new Date(e):NaN;t=Number.isNaN(+n)?String(e):c.format(n)}else t=typeof e==`number`?(u&&e&&Math.abs(e)<.01?u:l).format(e):String(e);return o+t+s}}function v(e,t,n=.2,r=.1){let i=e.length,a=t[1]-t[0],o=a/(i-n+r*2)||1,s=t[0]+(a-o*(i-n))/2;return{domain:e,step:o,bandwidth:o*(1-n),at:e=>s+o*e}}function y(e,t){let[n,r]=e,[i,a]=t,o=r===n?0:(a-i)/(r-n);return{domain:e,range:t,of:e=>r===n?(i+a)/2:i+(e-n)*o}}var b=e=>parseFloat(e.toPrecision(12));function x(e,t,n=5){t===e&&([e,t]=e===0?[0,1]:[e-1,t+1]);let r=10**Math.floor(Math.log10((t-e)/n)),i=r,a=1/0,o=e<0&&t>0;for(let s of[1,2,2.5,5,10]){let c=r*s,l=Math.floor(e/c+1e-9),u=Math.ceil(t/c-1e-9)-l+1,d=o?u>n+3?1/0:(u-1+Math.abs(u-n)/1e3)*c:Math.abs(u-n);d<a-1e-9*Math.abs(d)&&(a=d,i=c)}let s=Math.floor(e/i+1e-9),c=Math.ceil(t/i-1e-9),l=[];for(let e=s;e<=c;e++)l.push(b(e*i));return{domain:[b(s*i),b(c*i)],values:l,step:b(i)}}var S=e=>e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65103||e>=65280&&e<=65376||e>=65504&&e<=65510,C=e=>{let t=0,n=0;for(let r of e)S(r.codePointAt(0))?n++:t++;return t*7.2+n*12},w=e=>C(e)+8,T=e=>e.reduce((e,t)=>Math.max(e,w(t)),0);function E(e,t){if(C(e)<=t)return e;let n=``,r=0;for(let i of e){if(r+=C(i),r+7.2>t)break;n+=i}return n+`…`}function D(e,t,n){let r=(t.field===e.y?e.yDomain:e.xDomain)??null,[i,a]=r??t.domain,[o,s]=i>a?[a,i]:[i,a],c=x(o,s),l=r?c.values.filter(e=>e>=o&&e<=s):c.values;return r&&!l.some(e=>Math.abs(e-a)<c.step/2)&&(l.push(a),l.sort((e,t)=>e-t)),{domain:r??c.domain,values:l,labels:l.map(e=>n(t.field,e,c.step))}}function O(e,[t,n,o],s,c){let{width:l,height:u}=s,d=t&&t.kind===`linear`?D(e,t,c):null,f=n&&n.kind===`linear`?D(e,n,c):null,p=t&&!d?t.domain.map(e=>c(t.field,e)):[],m=n&&!f?n.domain.map(e=>c(n.field,e)):[],h=f?f.labels:m.map(e=>E(e,l*.4-8)),g=o&&o.kind===`linear`?D(e,o,c):null,_=g&&o&&e.titles.get(o.field),b=n&&e.titles.get(n.field),x=t&&e.titles.get(t.field),S=Math.max((e.yAxis&&n?T(h)+10:8)+(b?18:0),d?C(d.labels[0]??``)/2+2:0),w=(e.xAxis&&t?24:8)+(x?18:0),O={x:S,y:10,w:Math.max(1,l-S-(g?(e.yAxis?T(g.labels)+4:8)+(_?18:0):Math.max(12,d?C(d.labels.at(-1)??``)/2+2:0))),h:Math.max(1,u-10-w)},k=t?t.kind===`band`?v(t.domain,[O.x,O.x+O.w]):y(d.domain,[O.x,O.x+O.w]):null,A=n?n.kind===`band`?v(n.domain,[O.y,O.y+O.h]):y(f.domain,[O.y+O.h,O.y]):null,j=g?y(g.domain,[O.y+O.h,O.y]):null,M=``;if(e.grid){let e=i(O.x+O.w);if(f)for(let t of f.values){let n=i(A.of(t));M+=a(`line`,{x1:i(O.x),x2:e,y1:n,y2:n})}if(d)for(let e of d.values){let t=i(k.of(e));M+=a(`line`,{x1:t,x2:t,y1:i(O.y),y2:i(O.y+O.h)})}}let N=``;if(e.yAxis&&n){if(f)f.values.forEach((e,t)=>{N+=a(`text`,{x:i(O.x-6),y:i(A.of(e)),"text-anchor":`end`,"dominant-baseline":`middle`},r(f.labels[t]))});else{let e=A,t=Math.max(1,Math.ceil(14/(O.h/Math.max(1,n.domain.length))));m.forEach((n,o)=>{if(o%t)return;let s=h[o];N+=a(`text`,{x:i(O.x-6),y:i(e.at(o)+e.bandwidth/2),"text-anchor":`end`,"dominant-baseline":`middle`},r(s)+(s===n?``:a(`title`,{},r(n))))})}}if(b){let e=i(O.y+O.h/2);N+=a(`text`,{x:9,y:e,"text-anchor":`middle`,transform:`rotate(-90 9 ${e})`},r(b))}if(g&&j&&(e.yAxis&&g.values.forEach((e,t)=>{N+=a(`text`,{x:i(O.x+O.w+6),y:i(j.of(e)),"text-anchor":`start`,"dominant-baseline":`middle`},r(g.labels[t]))}),_)){let[e,t]=[l-9,i(O.y+O.h/2)];N+=a(`text`,{x:e,y:t,"text-anchor":`middle`,transform:`rotate(90 ${e} ${t})`},r(_))}let P=``;if(e.xAxis&&t){let e=i(O.y+O.h+16);if(d){let t=Math.max(1,Math.ceil(T(d.labels)/(O.w/Math.max(1,d.values.length-1))));d.values.forEach((n,o)=>{o%t||(P+=a(`text`,{x:i(k.of(n)),y:e,"text-anchor":`middle`},r(d.labels[o])))})}else{let t=k,n=Math.max(1,Math.ceil(T(p)/(O.w/Math.max(1,p.length))));p.forEach((o,s)=>{s%n===0&&(P+=a(`text`,{x:i(t.at(s)+t.bandwidth/2),y:e,"text-anchor":`middle`},r(o)))})}}x&&(P+=a(`text`,{x:i(O.x+O.w/2),y:u-4,"text-anchor":`middle`},r(x)));let F=d&&f,I=t?.kind===`band`?t:n?.kind===`band`?n:null;return{plot:O,x:k,y:A,y2:j,grid:M,ay:N,ax:P,attrs:{"data-plot":`${i(O.x)} ${i(O.y)} ${i(O.w)} ${i(O.h)}`,"data-n":F||!I?null:I.domain.length,"data-xd":F?d.domain.join(` `):null,"data-yd":F?f.domain.join(` `):null}}}function k(e){let t=0,n=0;return{add(r){n=t===0||e===`sum`||e===`mean`?n+r:e===`min`?Math.min(n,r):e===`max`?Math.max(n,r):n,t++},value:()=>e===`count`?t:t===0?null:e===`mean`?n/t:n}}function A(e,t={}){let{hidden:n=[],window:r}=Array.isArray(t)?{hidden:t}:t,i=[],a=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let t of e.data){let n=String(t[e.x]),r=e.series===null?``:String(t[e.series]),o=a.get(r);o===void 0&&a.set(r,o=i.push(r)-1);let c=s.get(n);c||s.set(n,c={label:n,rows:[],vals:[]}),c.rows.push([o,t[e.y],e.y2===null?void 0:t[e.y2]])}let c=t=>{let n=/* @__PURE__ */ new Map;for(let[r,i]of t){let t=n.get(r);t||n.set(r,t=k(e.aggregate)),typeof i==`number`&&t.add(i)}return i.map((e,t)=>n.get(t)?.value()??null)},l=t=>{let n=k(e.aggregate);for(let[,,e]of t.rows)typeof e==`number`&&n.add(e);t.y2=n.value()},u=[...s.values()];for(let e of u)e.vals=c(e.rows),l(e);let d=e=>e.vals.reduce((e,t)=>e+(t??0),0);if(e.sort){let t=e.sort===`asc`?1:-1;u=u.map(e=>[e,d(e)]).sort((e,n)=>t*(e[1]-n[1])).map(e=>e[0])}if(e.limit!==null&&u.length>e.limit){let t=new Set(u.map(e=>[e,d(e)]).sort((e,t)=>t[1]-e[1]).slice(0,e.limit).map(e=>e[0])),n={label:o,rows:u.filter(e=>!t.has(e)).flatMap(e=>e.rows),vals:[]};n.vals=c(n.rows),l(n),u=[...u.filter(e=>t.has(e)),n]}let f=e.type===`waterfall`,p=/* @__PURE__ */ new Map;if(f){let t=0;for(let n of u)e.totals.includes(n.label)?p.set(n,[0,t]):p.set(n,[t,t+=d(n)])}if(r?.length===2&&u.length){let e=Math.min(u.length-1,Math.max(0,Math.trunc(r[1]))),t=Math.min(e,Math.max(0,Math.trunc(r[0])));u=u.slice(t,e+1)}let m=[];i.forEach((e,t)=>n.includes(e)||m.push(t));let h=[],g=0,_=0;return u.forEach((t,n)=>{let r=0,i=0;for(let a of m){let o=t.vals[a]??null,s=o??0,[c,l]=f?p.get(t):[0,s];e.stack&&(s<0?[c,l]=[i,i+=s]:[c,l]=[r,r+=s]),g=Math.min(g,c,l),_=Math.max(_,c,l),h.push({ci:n,si:a,value:o,y0:c,y1:l})}}),{categories:u.map(e=>e.label),totals:u.map(t=>e.totals.includes(t.label)),series:i,visible:m,cells:h,extent:[g,_],y2:e.y2===null?[]:u.map(e=>e.y2??null)}}function j(e){let t=typeof e.colorBy==`string`&&e.colorBy!==`sign`?e.colorBy:null,n=/* @__PURE__ */ new Map;if(t)for(let r of e.data){let i=r[t];if(typeof i!=`number`)continue;let a=String(r[e.x])+`\0`+(e.series===null?``:String(r[e.series]));(n.get(a)??n.set(a,k(e.aggregate)).get(a)).add(i)}return(e,t)=>n.get(e+`\0`+t)?.value()??null}var M=72;function N(e){let t=[];for(let n of e.cells)t[n.ci]=n;let n=e.visible[0]??0,r=0,i=[];return e.categories.forEach((a,o)=>{let s=t[o];if(s){if(e.totals[o])return void i.push({ci:o,si:n,y0:0,y1:r,v:r,s:2});s.value!==null&&i.push({ci:o,si:n,y0:r,y1:r+=s.value,v:s.value,s:+(s.value<0)})}}),i}var P=(e,t)=>e.type===`waterfall`?N(t):t.cells.flatMap(e=>e.value===null?[]:[{ci:e.ci,si:e.si,y0:e.y0,y1:e.y1,v:e.value,s:e.si%8}]),F={noun:`Bar`,axes(e,t){let n=t.extent[0],r=t.extent[1];if(e.type===`waterfall`){n=r=0;for(let e of N(t))n=Math.min(n,e.y0,e.y1),r=Math.max(r,e.y0,e.y1)}let i={kind:`band`,field:e.x,domain:t.categories},a={kind:`linear`,field:e.y,domain:[n,r]};if(e.y2!==null){let n=t.y2.filter(e=>e!==null);return[i,a,{kind:`linear`,field:e.y2,domain:[Math.min(0,...n),Math.max(0,...n)]}]}return e.horizontal?[a,i]:[i,a]},draw(e){let{spec:t,shaped:n}=e,r=t.horizontal,l=r?e.y:e.x,u=r?e.x:e.y,d=v(n.visible.map(e=>n.series[e]),[0,l.bandwidth],.1,0),f=j(t),p=``,m=``;for(let h of P(t,n)){let g=n.visible.indexOf(h.si),_=t.stack||t.type===`waterfall`?l.bandwidth:d.bandwidth,v=Math.min(_,M),y=l.at(h.ci)+(t.stack||t.type===`waterfall`?0:d.at(g))+(_-v)/2,[b,x]=[u.of(h.y0),u.of(h.y1)],S=Math.min(b,x),C=Math.abs(b-x),[w,T,E,D]=r?[S,y,C,v]:[y,S,v,C],O=n.categories[h.ci],k=n.series[h.si],A=f(O,k),j={"data-key":s(k,O),"data-c":h.ci,"data-s":h.s,"data-x":e.fmt(t.x,O),"data-series":k,"data-f":e.fmt(t.y,h.v),"data-y":h.v,"data-neg":h.v<0,"data-tone":e.tone(h.v),"data-q":A===null?null:e.q(A),"data-other":O===o,"data-total":n.totals[h.ci]};if(p+=a(`rect`,{"data-maya":`mark`,...j,x:i(w),y:i(T),width:i(E),height:i(D)}),m+=c(j,w,T,E,D),t.labels){let n=e.fmt(t.y,h.v),i=n.length*7.2+4,[a,o]=[w+E/2,T+D/2],s=h.v<0;r?i<=E&&D>=14?e.label(a,o,n,`center`):e.label(s?w-4:w+E+4,o,n,s?`end`:`start`):i<=E&&D>=16?e.label(a,o,n,`center`):e.label(a,s?T+D:T,n,s?`below`:`above`)}}if(e.y2&&t.y2!==null&&n.y2.length){let r=t.y2,o=n.series.length%8,u=t.titles.get(r)??r,d=``,f=!0,h=``;n.y2.forEach((p,g)=>{if(p===null){f=!0;return}let _=i(l.at(g)+l.bandwidth/2),v=i(e.y2.of(p));d+=`${f?`M`:`L`}${_} ${v}`,f=!1;let y=n.categories[g],b={"data-key":s(`\0y2`,y),"data-c":g,"data-s":o,"data-x":e.fmt(t.x,y),"data-series":u,"data-f":e.fmt(r,p),"data-y":p,"data-neg":p<0};h+=a(`circle`,{"data-maya":`mark`,...b,r:3,cx:_,cy:v}),m+=c(b,_-3,v-3,6,6),t.labels&&e.label(+_,+v,e.fmt(r,p),`above`)}),p+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,`\0y2`),"data-s":o,pathLength:1,d:d||null})+h}return{marks:p,hits:m}}};function I(e,t){let n=[],r=new Map(t.categories.map((e,t)=>[e,t])),i=e.yDomain;return e.data.forEach((a,o)=>{let s=a[e.y];if(typeof s!=`number`||!Number.isFinite(s)||i&&(s<i[0]||s>i[1]))return;let c=e.x===``?0:r.get(String(a[e.x]));if(c===void 0)return;let l=t.series.indexOf(e.series===null?``:String(a[e.series]));if(!t.visible.includes(l))return;let u=e.name===null?null:a[e.name];n.push({i:o,v:s,ci:c,si:l,name:u==null?null:String(u),row:a})}),n}function ee(e,t,n){let r=e.map((e,t)=>t).sort((t,n)=>e[t]-e[n]||t-n),i=(2*t)**2,a=Array(e.length).fill(0),o=[],s=0;for(let c of r){let r=e[c];for(;s<o.length&&r-e[o[s]]>=2*t;)s++;let l=o.slice(s),u=[0];for(let t of l){let n=Math.sqrt(Math.max(0,i-(r-e[t])**2));u.push(a[t]+n,a[t]-n)}u.sort((e,t)=>Math.abs(e)-Math.abs(t)||t-e);let d=u.find(t=>l.every(n=>(r-e[n])**2+(t-a[n])**2>=i-1e-6))??0;d=Math.max(-n,Math.min(n,d)),a[c]=d,o.push(c)}return a}var L={noun:`Beeswarm`,axes(e,t){let n=1/0,r=-1/0;for(let i of I(e,t))n=Math.min(n,i.v),r=Math.max(r,i.v);n>r&&(n=r=0);let i=e.x===``?null:{kind:`band`,field:e.x,domain:t.categories};return[{kind:`linear`,field:e.y,domain:e.yDomain??[n,r]},i]},draw(e){let{spec:t,shaped:n,plot:r}=e,o=e.x,l=e.y,u=I(t,n),d=l?l.bandwidth:r.h,f=/* @__PURE__ */ new Map;for(let e of u)(f.get(e.ci)??f.set(e.ci,[]).get(e.ci)).push(e);let p=1;for(let e of f.values())p=Math.max(p,e.length);let m=Math.max(3,Math.min(6,Math.sqrt(r.w*d/p)/4)),h=typeof t.colorBy==`string`&&t.colorBy!==`sign`?t.colorBy:null,g=/* @__PURE__ */ new Map,_=``,v=``;for(let[u,p]of[...f].sort((e,t)=>e[0]-t[0])){let f=l?l.at(u)+l.bandwidth/2:r.y+r.h/2,y=p.map(e=>o.of(e.v)),b=ee(y,m+.5,Math.max(0,d/2-m));p.forEach((r,o)=>{let d=r.i;if(r.name!==null){let e=(g.get(r.name)??0)+1;g.set(r.name,e),d=e>1?`${r.name}#${e}`:r.name}let p=n.series[r.si],x=e.fmt(t.y,r.v),S=h?r.row[h]:null,C={"data-key":s(p,d),"data-c":r.i,"data-s":r.si%8,"data-x":r.name??(l?e.fmt(t.x,n.categories[u]):``),"data-series":p,"data-y":r.v,"data-f":x,"data-neg":r.v<0,"data-tone":e.tone(r.v),"data-q":typeof S==`number`?e.q(S):null},w=y[o],T=f+b[o];_+=a(`circle`,{"data-maya":`mark`,...C,r:i(m),cx:i(w),cy:i(T)}),v+=c(C,w-m,T-m,m*2,m*2),t.labels&&e.label(w,T-m,x,`above`)})}return{marks:_,hits:v}}},te={noun:`Dumbbell`,axes(e,t){let n={kind:`band`,field:e.x,domain:t.categories},r={kind:`linear`,field:e.y,domain:t.extent};return e.horizontal?[r,n]:[n,r]},draw(e){let{spec:t,shaped:n}=e,r=t.horizontal,l=r?e.y:e.x,u=r?e.x:e.y,d=Math.max(3,Math.min(5,l.bandwidth/2-1)),f=/* @__PURE__ */ new Map;for(let e of n.cells)e.value!==null&&e.si<2&&((f.get(e.ci)??f.set(e.ci,[]).get(e.ci))[e.si]=e.value);let p=``,m=``,h=``;for(let[g,_]of[...f].sort((e,t)=>e[0]-t[0])){let f=n.categories[g],v=l.at(g)+l.bandwidth/2,y=e=>r?[u.of(e),v]:[v,u.of(e)],[b,x]=_;if(b!==void 0&&x!==void 0){let[t,n]=y(b),[r,o]=y(x);p+=a(`line`,{"data-maya":`link`,"data-key":s(`k`,f),"data-c":g,"data-tone":e.tone(x-b),"stroke-width":2,x1:i(t),y1:i(n),x2:i(r),y2:i(o)})}for(let l of[0,1]){let u=_[l];if(u===void 0)continue;let[p,v]=y(u),b=n.series[l],x={"data-key":s(b,f),"data-c":g,"data-s":l%8,"data-x":e.fmt(t.x,f),"data-series":b,"data-f":e.fmt(t.y,u),"data-y":u,"data-neg":u<0,"data-other":f===o};if(m+=a(`circle`,{"data-maya":`mark`,...x,cx:i(p),cy:i(v),r:d}),h+=c(x,p-d,v-d,d*2,d*2),t.labels){let n=_[1-l],[i,a]=y(n??u),o=e.fmt(t.y,u),s=r?p>=i:v>=a,c=n===void 0?r:l===1?s:!s;r?e.label(p+(c?d+4:-d-4),v,o,c?`start`:`end`):e.label(p,v+(c?d:-d),o,c?`below`:`above`)}}}return{marks:p+m,hits:h}}},ne={noun:`Heatmap`,axes:(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`band`,field:e.series??``,domain:t.series}],draw(e){let{spec:t,shaped:n}=e,o=e.x,l=e.y,u=n.cells.filter(e=>e.value!==null),d=1/0,f=-1/0;for(let e of u)d=Math.min(d,e.value),f=Math.max(f,e.value);let p=e=>f>d?Math.min(9,Math.max(0,Math.floor((e-d)/(f-d)*10))):9,m=``,h=``,g=``;for(let[d,f]of u.entries()){let u=f.value,_=n.visible.indexOf(f.si),v=o.at(f.ci)+1,y=l.at(_)+1,b=Math.max(0,o.bandwidth-2),x=Math.max(0,l.bandwidth-2),S=n.categories[f.ci],C=n.series[f.si],w={"data-key":s(C,S),"data-c":d,"data-x":e.fmt(t.x,S),"data-series":C,"data-y":u,"data-f":e.fmt(t.y,u),"data-q":p(u)};m+=a(`rect`,{"data-maya":`mark`,...w,x:i(v),y:i(y),width:i(b),height:i(x)}),h+=c(w,v,y,b,x);let T=e.fmt(t.y,u);t.labels!==!1&&b>=24&&x>=24&&T.length*7.2+4<=b&&(g+=a(`text`,{x:i(v+b/2),y:i(y+x/2),"text-anchor":`middle`,"dominant-baseline":`middle`,"data-in":!0,"data-dark":w[`data-q`]>=6},r(T)))}let _=u.length>0?`<div class="maya-legend" data-maya="ramp"><span>${r(e.fmt(t.y,d))}</span><i></i><span>${r(e.fmt(t.y,f))}</span></div>`:``;return{marks:m,hits:h,labels:g,grid:``,legend:_}}},R=12,re=e=>typeof e==`number`?e:null;function ie(e){let{spec:t,shaped:n,width:o,height:c}=e,l=t.x?n.categories:[],u=t.x?n.cells.filter(e=>e.si===0).sort((e,t)=>e.ci-t.ci):[],d=u.filter(e=>e.value!==null),f=d[d.length-1],p=t.x?f?.value??null:e.agg(t.aggregate)(t.data.map(e=>re(e[t.y]))),m=o/2;if(p===null)return{marks:``,hits:``,labels:a(`text`,{"data-maya":`empty`,x:i(m),y:i(c/2),"text-anchor":`middle`},r(e.t(`noData`)))};let h=f?.ci??0,g=t.x?e.fmt(t.x,l[h]):``,_=e.fmt(t.y,p),v=i(Math.max(16,Math.min(c*.32,72,(o-24)/(_.length*.62)))),y={"data-c":h,"data-s":0,"data-x":g,"data-series":``,"data-y":p,"data-f":_},b=(e,t)=>a(`text`,{"dominant-baseline":`hanging`,x:R,...e},r(t)),x=a(`text`,{"data-maya":`mark`,"data-key":`v`,...y,"font-size":v,x:R,y:R,"dominant-baseline":`hanging`},r(_)),S=``,C=``,w=R+v+4,T=d[d.length-2];if(f&&T&&T.value){let n=(p-T.value)/Math.abs(T.value),r=new Intl.NumberFormat(t.locale,{style:`percent`,maximumFractionDigits:1,signDisplay:`exceptZero`}).format(n);S+=b({"data-kpi":`delta`,"data-tone":n>0?`good`:n<0?`bad`:null,y:i(w),"font-size":12},e.t(`vs`,r,e.fmt(t.x,l[T.ci]))),w+=16}g&&(S+=b({"data-kpi":`period`,y:i(w),"font-size":11},g)),w+=18;let E=``,D=typeof t.colorBy==`object`&&t.colorBy?t.colorBy.target:null,O=c-R;if(D){let n=o-24,r=Math.min(Math.max(p/D,0),1.2)/1.2,s=new Intl.NumberFormat(t.locale,{style:`percent`,maximumFractionDigits:1});O-=8,E=a(`rect`,{"data-kpi":`track`,x:R,y:O,width:i(n),height:8,rx:4}),x+=a(`rect`,{"data-maya":`mark`,"data-key":`b`,...y,"data-kpi":`fill`,"data-tone":e.tone(p),x:R,y:O,width:i(n*r),height:8,rx:4}),S+=a(`line`,{"data-kpi":`target`,"stroke-width":2,x1:i(R+n/1.2),x2:i(R+n/1.2),y1:O-3,y2:O+11}),S+=b({"data-kpi":`of`,y:O-16,"font-size":11},e.t(`ofTarget`,s.format(p/D),e.fmt(t.y,D))),O-=24}if(l.length>=3&&O-w>=28){let n=d.map(e=>e.value),r=Math.min(...n),p=Math.max(...n)-r||1,m=l.length-1,h=(o-24)/m,g=e=>i(R+e*h),_=e=>i(O-(e-r)/p*(O-w-4)-2),v=``,y=!0;u.forEach(n=>{if(n.value===null)return void(y=!0);v+=`${y?`M`:`L`}${g(n.ci)} ${_(n.value)}`,y=!1,x+=a(`circle`,{"data-maya":`mark`,"data-key":s(``,l[n.ci]),"data-c":n.ci,"data-s":0,"data-x":e.fmt(t.x,l[n.ci]),"data-series":``,"data-y":n.value,"data-f":e.fmt(t.y,n.value),"data-neg":n.value<0,"data-last":n===f,r:3,cx:g(n.ci),cy:_(n.value)})});let b=d[0],S=d[d.length-1];x=(b&&S&&d.length===u.length?a(`path`,{"data-maya":`area`,"data-key":s(`a`,``),"data-s":0,d:`${v}L${g(S.ci)} ${i(O)}L${g(b.ci)} ${i(O)}Z`}):``)+a(`path`,{"data-maya":`line`,"data-key":s(`l`,``),"data-s":0,pathLength:1,d:v||null})+x,l.forEach((e,t)=>{C+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(Math.max(0,R+t*h-h/2)),y:0,width:i(h),height:c,fill:`transparent`})})}return{marks:x,hits:C,labels:S,grid:E}}var ae={noun:`KPI`,draw:ie},oe=26,se=12,ce=48,le=14,ue={noun:`Parallel coordinates`,draw(e){let{spec:t,shaped:n,width:o,height:c}=e,l=t.measures,u=/* @__PURE__ */ new Map;for(let e of t.data){let n=String(e[t.x]);(u.get(n)??u.set(n,[]).get(n)).push(e)}let d=e.agg(t.aggregate),f=n.categories.flatMap((e,r)=>{let i=u.get(e);if(!i||e===`\0other`)return[];let a=l.map(e=>d(i.map(t=>t[e]))),o=t.series===null?0:Math.max(0,n.series.indexOf(String(i[0][t.series])));return n.visible.includes(o)?[{cat:e,ci:r,vals:a,si:o}]:[]}),p=ce,m=Math.max(49,o-le),[h,g]=[oe,Math.max(27,c-se)],_=e=>i(l.length<2?p:p+(m-p)*e/(l.length-1)),v=``,y=``,b=l.map((n,o)=>{let s=f.map(e=>e.vals[o]).filter(e=>e!==null),c=x(Math.min(0,...s),Math.max(0,...s),4),[u,d]=c.domain,p=e=>i(g-(e-u)/(d-u||1)*(g-h)),m=_(o);v+=a(`line`,{x1:m,x2:m,y1:i(h),y2:i(g)});for(let t of c.values){let i=p(t);v+=a(`line`,{x1:m-3,x2:m,y1:i,y2:i}),y+=a(`text`,{x:m-6,y:i,"text-anchor":`end`,"dominant-baseline":`middle`,"data-in":!0},r(e.fmt(n,t,c.step)))}return y+=a(`text`,{x:m,y:12,"text-anchor":o===0?`start`:o===l.length-1?`end`:`middle`,"font-weight":600,"data-in":!0},r(t.titles.get(n)??n)),p}),S=``,C=``,w=``;for(let{cat:n,ci:r,vals:i,si:o}of f){let c=e.fmt(t.x,n),u=``,d=!0;i.forEach((i,f)=>{if(i===null){d=!0;return}let[p,m]=[_(f),b[f](i)];u+=`${d?`M`:`L`}${p} ${m}`,d=!1,S+=a(`circle`,{"data-maya":`mark`,"data-key":s(n,l[f]),"data-c":r,"data-s":o%8,"data-x":c,"data-series":t.titles.get(l[f])??l[f],"data-y":i,"data-f":e.fmt(l[f],i),"data-neg":i<0,r:3.5,cx:p,cy:m})}),u&&(C+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,n),"data-c":r,"data-s":o%8,pathLength:1,d:u}),w+=a(`path`,{"data-maya":`hit`,"data-c":r,d:u,fill:`none`,stroke:`transparent`,"stroke-width":16,"stroke-linejoin":`round`}))}return{marks:S+C,hits:w,grid:v,labels:y}}},de={noun:`Ridgeline`,axes:(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`band`,field:e.series??``,domain:t.visible.map(e=>t.series[e])}],draw(e){let{spec:t,shaped:n,plot:r}=e,c=e.x,l=e.y,u=j(t),d=e=>i(c.at(e)+c.bandwidth/2),f=0;for(let e of n.cells)e.value!==null&&e.value>f&&(f=e.value);f<=0&&(f=1);let p=e=>l.at(e)+l.bandwidth/2+l.step/2,m=Math.min(1.4*l.step,p(0)-r.y),h=``,g=``;n.visible.forEach((r,c)=>{let l=n.series[r],_=p(c),v=e=>i(_-e/f*m),y=n.cells.filter(e=>e.si===r).sort((e,t)=>e.ci-t.ci),b=[[]];for(let i of y){if(i.value===null){b.push([]);continue}b[b.length-1].push(i);let c=n.categories[i.ci],f=u(c,l);g+=a(`circle`,{"data-maya":`mark`,"data-key":s(l,c),"data-c":i.ci,"data-s":r%8,"data-x":e.fmt(t.x,c),"data-series":l,"data-y":i.value,"data-f":e.fmt(t.y,i.value),"data-neg":i.value<0,"data-tone":e.tone(i.value),"data-q":f===null?null:e.q(f),"data-other":c===o,r:3,cx:d(i.ci),cy:v(i.value)})}let x=e=>e.map((e,t)=>`${t?`L`:`M`}${d(e.ci)} ${v(e.value)}`),S=b.filter(e=>e.length>0),C=S.map(e=>`${x(e).join(``)}L${d(e.at(-1).ci)} ${i(_)}L${d(e[0].ci)} ${i(_)}Z`).join(``);C&&(h+=a(`path`,{"data-maya":`area`,"data-ridge":!0,"data-key":s(`a`,l),"data-s":r%8,d:C})),h+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,l),"data-s":r%8,pathLength:1,d:S.map(e=>x(e).join(``)).join(``)||null})});let _=``;return n.categories.forEach((e,t)=>{_+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(c.at(t)),y:i(r.y),width:i(c.bandwidth),height:i(r.h),fill:`transparent`})}),{marks:h+g,hits:_,cross:a(`line`,{x1:0,x2:0,y1:i(r.y),y2:i(r.y+r.h)})}}},fe=(e,t)=>[{kind:`band`,field:e.x,domain:t.categories},{kind:`linear`,field:e.y,domain:t.extent}];function pe(e,t){let{spec:n,shaped:r,plot:c}=e,l=e.x,u=e.y,d=j(n),f=e=>i(l.at(e)+l.bandwidth/2),p=``,m=``,h=``;for(let c of r.visible){let l=r.series[c],g=r.cells.filter(e=>e.si===c).sort((e,t)=>e.ci-t.ci),_=``,v=!0,y=[[]];for(let t of g){if(t.value===null&&!n.stack?y.push([]):y[y.length-1].push(t),t.value===null){v=!0;continue}_+=`${v?`M`:`L`}${f(t.ci)} ${i(u.of(t.y1))}`,v=!1;let p=r.categories[t.ci],m=d(p,l),g=p===o,b=e.fmt(n.x,p);h+=a(`circle`,{"data-maya":`mark`,"data-key":s(l,p),"data-c":t.ci,"data-s":c%8,"data-x":b,"data-series":l,"data-y":t.value,"data-f":e.fmt(n.y,t.value),"data-neg":t.value<0,"data-tone":e.tone(t.value),"data-q":m===null?null:e.q(m),"data-other":g,r:3,cx:f(t.ci),cy:i(u.of(t.y1))}),n.labels&&e.label(f(t.ci),u.of(t.y1),e.fmt(n.y,t.value),`above`)}if(t){let e=y.filter(e=>e.length>0).map(e=>e.map((e,t)=>`${t?`L`:`M`}${f(e.ci)} ${i(u.of(e.y1))}`).join(``)+[...e].reverse().map(e=>`L${f(e.ci)} ${i(u.of(e.y0))}`).join(``)+`Z`).join(``);e&&(p+=a(`path`,{"data-maya":`area`,"data-key":s(`a`,l),"data-s":c%8,d:e}))}m+=a(`path`,{"data-maya":`line`,"data-key":s(`l`,l),"data-s":c%8,pathLength:1,d:_||null})}let g=``;return r.categories.forEach((e,t)=>{g+=a(`rect`,{"data-maya":`hit`,"data-c":t,x:i(l.at(t)),y:i(c.y),width:i(l.bandwidth),height:i(c.h),fill:`transparent`})}),{marks:p+m+h,hits:g,cross:a(`line`,{x1:0,x2:0,y1:i(c.y),y2:i(c.y+c.h)})}}var me={noun:`Line`,axes:fe,draw:e=>pe(e,!1)},he={noun:`Area`,axes:fe,draw:e=>pe(e,!0)},ge=24;function _e(e,t){let n=[],r=e.xDomain,i=e.yDomain,a=e.window;return e.data.forEach((o,s)=>{let c=o[e.x],l=o[e.y];if(typeof c!=`number`||typeof l!=`number`||r&&(c<r[0]||c>r[1])||i&&(l<i[0]||l>i[1])||a&&(c<a[0]||c>a[1]||l<a[2]||l>a[3]))return;let u=t.series.indexOf(e.series===null?``:String(o[e.series]));if(!t.visible.includes(u))return;let d=e.size===null?null:o[e.size],f=e.name===null?null:o[e.name];n.push({i:s,x:c,y:l,sz:typeof d==`number`?d:null,si:u,name:f==null?null:String(f),row:o})}),n}var ve={noun:`Scatter`,axes(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(let o of _e(e,t))n=Math.min(n,o.x),r=Math.max(r,o.x),i=Math.min(i,o.y),a=Math.max(a,o.y);n>r&&(n=r=0,i=a=0);let o=e.size===null?0:(r-n)*.06,s=e.size===null?0:(a-i)*.06,c=(e,t)=>e>=0?Math.max(0,e-t):e-t;return[n,r,i,a]=[c(n,o),r+o,c(i,s),a+s],[{kind:`linear`,field:e.x,domain:e.xDomain??[n,r]},{kind:`linear`,field:e.y,domain:e.yDomain??[i,a]}]},draw(e){let{spec:t,shaped:n,plot:r}=e,o=e.x,c=e.y,l=_e(t,n),u=0;for(let e of l)e.sz!==null&&(u=Math.max(u,Math.abs(e.sz)));let d=Math.min(r.w,r.h)/16,f=typeof t.colorBy==`string`&&t.colorBy!==`sign`?t.colorBy:null,p=/* @__PURE__ */ new Map,m=l.map(r=>{let i=r.sz!==null&&u>0?2+Math.sqrt(Math.abs(r.sz)/u)*d:4,a=r.i;if(r.name!==null){let e=(p.get(r.name)??0)+1;p.set(r.name,e),a=e>1?`${r.name}#${e}`:r.name}let l=n.series[r.si],m=e.fmt(t.x,r.x),h=e.fmt(t.y,r.y),g=f?r.row[f]:null;return{p:r,rad:i,d:{"data-key":s(l,a),"data-c":r.i,"data-s":r.si%8,"data-x":r.name??m,"data-series":l,"data-y":r.y,"data-f":r.name===null&&r.sz===null?h:[m,h,r.sz===null?null:e.fmt(t.size,r.sz)].filter(e=>e!==null).join(` · `),"data-neg":r.y<0,"data-tone":e.tone(r.y),"data-q":typeof g==`number`?e.q(g):null},cx:o.of(r.x),cy:c.of(r.y)}});m.sort((e,t)=>t.rad-e.rad);let h=``,g=``;for(let{p:n,rad:r,d:o,cx:s,cy:c}of m)h+=a(`circle`,{"data-maya":`mark`,...o,r:i(r),cx:i(s),cy:i(c)}),r*2<ge&&(g+=a(`circle`,{"data-maya":`hit`,...o,r:i(Math.max(r,12)),cx:i(s),cy:i(c),fill:`transparent`})),t.labels&&e.label(s,c-r,e.fmt(t.y,n.y),`above`);return{marks:h,hits:g}}},z=30,B=26,V=8,ye=e=>typeof e==`number`?e:null,be={noun:`Table`,draw(e){let{spec:t,width:n,height:o}=e,l=t.measures,u=e=>t.titles.get(e)??e,d=e.agg(t.aggregate),f=/* @__PURE__ */ new Map;for(let e of t.data){let n=String(e[t.x]),r=f.get(n)??f.set(n,l.map(()=>[])).get(n);l.forEach((t,n)=>r[n].push(ye(e[t])))}let p=[...f].map(([e,t])=>({name:e,vals:t.map(e=>d(e))})),m=(e,t)=>e===null?1/0:e*t,h=(e,t)=>(n,r)=>m(n.vals[e],t)-m(r.vals[e],t)||0;t.limit!==null&&p.length>t.limit&&(p=p.sort(h(0,-1)).slice(0,t.limit));let g=t.sortBy&&(t.sortBy[0]===t.x||l.includes(t.sortBy[0]))?t.sortBy:null;if(g){let e=g[1]===`asc`?1:-1,n=l.indexOf(g[0]);if(n<0){let n=new Intl.Collator(t.locale,{numeric:!0});p.sort((t,r)=>e*n.compare(t.name,r.name))}else p.sort((t,r)=>{let[i,a]=[t.vals[n],r.vals[n]];return i===null||a===null?(i===null)-+(a===null):e*(i-a)})}else t.sort&&p.sort(h(0,t.sort===`asc`?1:-1));let _=Math.max(80,Math.min(n*.34,180)),v=(n-_)/l.length,y=e=>_+e*v,b=l.map((e,t)=>Math.max(0,...p.map(e=>Math.abs(e.vals[t]??0)))),x=(e,t)=>{let n=Math.max(1,Math.floor((t-V)/7));return e.length>n?e.slice(0,n-1)+`…`:e},S=``,C=``;[t.x,...l].forEach((t,n)=>{let o=n?y(n-1):0,s=n?v:_,c=g?.[0]===t?g[1]:null,l=x(u(t),s-(c?14:0))+(c?c===`asc`?` ▲`:` ▼`:``);C+=a(`g`,{"data-maya":`sort`,"data-field":t,"data-sort":c,role:`button`,tabindex:0,"aria-label":c?e.t(`sortedBy`,u(t),e.t(c===`asc`?`ascending`:`descending`)):u(t)},a(`rect`,{x:i(o),y:0,width:i(s),height:z,fill:`transparent`})+a(`text`,{"data-th":!0,x:i(n?o+s-V:V),y:z/2,"text-anchor":n?`end`:`start`,"dominant-baseline":`middle`},r(l)))}),S+=a(`line`,{x1:0,x2:n,y1:z,y2:z});let w=Math.max(0,Math.floor((o-z)/B)),T=``;return p.slice(0,w).forEach((n,o)=>{let d=z+o*B,f=e.fmt(t.x,n.name);T+=a(`text`,{"data-key":s(`t`,n.name),x:V,y:d+B/2-2,"dominant-baseline":`middle`,"data-td":`label`},r(x(f,_))),l.forEach((t,p)=>{let m=n.vals[p],h=y(p)+v-V,g=m===null?`–`:e.fmt(t,m);if(T+=a(`text`,{"data-key":s(`v`,t,n.name),x:i(h),y:d+B/2-2,"text-anchor":`end`,"dominant-baseline":`middle`},r(g)),m===null)return;let _=b[p]?(v-16)*Math.abs(m)/b[p]:0,x={"data-key":s(t,n.name),"data-c":o,"data-s":l.length>1?p%8:0,"data-x":f,"data-series":u(t),"data-f":g,"data-y":m,"data-neg":m<0},S=d+B-7;T+=a(`rect`,{"data-maya":`mark`,...x,x:i(y(p)+V),y:S,width:i(_),height:4}),C+=c(x,y(p)+V,S,_,4)})}),{marks:T,hits:C,labels:``,grid:S}}},xe=`0.3.0`,Se=Symbol.for(`mayacharts.marks@0`);Object.hasOwn(globalThis,Se)||Object.defineProperty(globalThis,Se,{value:/* @__PURE__ */ new Map});var Ce=globalThis[Se],we=[`bar`,`line`,`area`,`scatter`,`heatmap`,`waterfall`,`kpi`,`dumbbell`,`ridgeline`,`beeswarm`,`parallel`,`table`],Te={treemap:`hierarchy`,sunburst:`hierarchy`,marimekko:`hierarchy`,waffle:`hierarchy`,sankey:`flow`,chord:`flow`,radial:`radial`,hexmap:`geo`},Ee=()=>[...Ce.keys()],De=`--maya-fg:#1f2328;--maya-fg-muted:#656d76;--maya-bg:#fff`,Oe=`--maya-fg:#e6edf3;--maya-fg-muted:#9198a1;--maya-bg:#0d1117`,H=(e,t=0)=>Array.from({length:e},(e,n)=>n+t),ke=H(8).map(e=>`[data-s="${e}"]{--c:var(--maya-series-${e+1})}`).join(``),Ae=H(8).map(e=>`svg:not([data-stack]) [data-maya=area][data-s="${e}"]{fill:url(#maya-a${e}) color-mix(in oklab,var(--c) 18%,transparent)}`).join(``),je=H(10).map(e=>`[data-q="${e}"]{--q:${Math.round(20+e*80/9)}%}`).join(``),Me=H(8).map(e=>`.maya:has(.maya-legend [data-s="${e}"]:hover) :is([data-maya=mark],[data-maya=line],[data-maya=area]):not([data-s="${e}"]){opacity:.25}`).join(``),Ne=H(3,2).map(e=>`.maya-ctl[data-n="${e}"]::before{width:calc((100% - 4px)/${e})}`).join(``)+H(3,1).map(e=>`.maya-ctl[data-i="${e}"]::before{transform:translateX(${e*100}%)}`).join(``),Pe=`border:0;background:none;padding:0;font:inherit;color:var(--maya-fg-muted);cursor:pointer`,Fe=`:host,.maya-root{--maya-font:ui-sans-serif,system-ui,sans-serif;--maya-font-size:12px;--maya-fg:light-dark(#1f2328,#e6edf3);--maya-fg-muted:light-dark(#656d76,#9198a1);--maya-grid:color-mix(in oklab,var(--maya-fg) 10%,transparent);--maya-bg:light-dark(#fff,#0d1117);--maya-accent:oklch(.6 .17 255);--maya-radius:3px;--maya-ease:cubic-bezier(.22,1,.36,1);--maya-tooltip-bg:color-mix(in oklab,var(--maya-bg) 92%,transparent);--maya-tooltip-fg:var(--maya-fg);--maya-focus:var(--maya-accent);--maya-good:light-dark(#1a7f37,#3fb950);--maya-bad:light-dark(#cf222e,#f85149);--maya-series-1:var(--maya-accent);--maya-series-2:oklch(.66 .16 50);--maya-series-3:oklch(.62 .15 160);--maya-series-4:oklch(.66 .17 330);--maya-series-5:oklch(.62 .14 90);--maya-series-6:oklch(.62 .12 205);--maya-series-7:oklch(.64 .19 22);--maya-series-8:oklch(.62 .16 295);color-scheme:light dark}@supports not (color:light-dark(#000,#fff)){:host,.maya-root{${De}}@media (prefers-color-scheme:dark){:host,.maya-root{${Oe}}}}:host{display:block;position:relative;container-type:inline-size;min-height:200px}.maya{display:flex;flex-direction:column;height:100%;font:var(--maya-font-size) var(--maya-font);font-variant-numeric:tabular-nums;color:var(--maya-fg)}.maya-title{font-weight:600;font-size:15px;letter-spacing:-.01em;margin:0 0 6px}.maya-legend,.maya-crumbs{color:var(--maya-fg-muted);display:flex;flex-wrap:wrap;align-items:center;gap:2px 6px;margin:0 0 8px}.maya-crumbs{min-height:1.25em;line-height:1.25}.maya-legend :is(button,span),.maya-crumbs button,.maya-reset{display:inline-flex;align-items:center;gap:6px;${Pe};border-radius:6px;padding:2px 6px;transition:background .15s,opacity .2s,color .15s}:is(.maya-legend,.maya-crumbs) button:hover{background:var(--maya-grid);color:var(--maya-fg)}.maya-legend [aria-pressed=false]{opacity:.5}.maya-legend [aria-pressed=false] i{background:none;box-shadow:inset 0 0 0 1.5px var(--c)}:is(.maya-legend,.maya-crumbs) button:focus-visible,.maya-reset:focus-visible,.maya-ctl :focus-visible{outline:2px solid var(--maya-focus);outline-offset:2px}i{width:10px;height:10px;border-radius:3px;background:var(--c)}[data-maya=ramp]{display:flex;align-items:center;gap:6px}[data-maya=ramp] i{width:80px;height:8px;background:linear-gradient(90deg,color-mix(in oklab,var(--maya-accent) 20%,var(--b)),var(--maya-accent))}[data-q],[data-maya=ramp] i{--b:light-dark(var(--maya-bg),color-mix(in oklab,var(--maya-accent) 15%,var(--maya-bg)))}.maya-reset{position:absolute;top:4px;right:4px;border:1px solid var(--maya-grid);border-radius:99px;padding:3px 12px;background:var(--maya-bg);box-shadow:0 1px 3px #0000001a}.maya-ctl{position:relative;display:inline-grid;grid-auto-flow:column;grid-auto-columns:1fr;align-self:flex-start;margin:0 0 8px;padding:2px;border-radius:8px;background:var(--maya-grid)}.maya-ctl::before{content:'';position:absolute;inset:2px auto 2px 2px;width:calc(100% - 4px);border-radius:6px;background:var(--maya-bg);box-shadow:0 1px 3px #00000024;transition:transform .3s var(--maya-ease)}`+Ne+`.maya-ctl [role=radio]{${Pe};position:relative;padding:4px 12px;border-radius:6px;transition:color .2s}.maya-ctl [aria-checked=true]{color:var(--maya-fg);font-weight:600}.maya-err{margin:0;padding:8px;color:var(--maya-bad);white-space:pre-wrap;font:12px monospace}.maya-box{flex:1;min-height:0;position:relative}.maya-box svg{display:block;width:100%;height:100%;overflow:visible}.maya-svg{direction:ltr;font:var(--maya-font-size) var(--maya-font);font-variant-numeric:tabular-nums}.maya-svg text{fill:var(--maya-fg-muted);unicode-bidi:plaintext}[data-maya^=axis] text{font-size:11px}[data-maya=grid] *{stroke:var(--maya-grid);shape-rendering:crispEdges}`+ke+`[data-other],[data-total]{--c:var(--maya-fg-muted)}[data-tone=good]{--c:var(--maya-good)}[data-tone=bad]{--c:var(--maya-bad)}[data-q]{--c:color-mix(in oklab,var(--maya-accent) var(--q),var(--b))}`+je+`[data-maya=mark]{fill:var(--c,var(--maya-series-1));rx:var(--maya-radius);transform-box:fill-box;transform-origin:0 0}[data-dir=h] [data-neg]{transform-origin:100% 0}[data-maya=mark],[data-maya=link]{transition:opacity .25s var(--maya-ease),fill .2s}[data-ghost]{pointer-events:none}[data-maya=mark][data-active]{fill:color-mix(in oklab,var(--c,var(--maya-series-1)),var(--maya-fg) 12%)}[data-stack] rect[data-maya=mark]{stroke:var(--maya-bg);stroke-width:1}:where([data-xd] circle[data-maya=mark]){stroke:var(--maya-bg);stroke-width:1}[data-maya=line]~circle[data-maya=mark]:not([data-active],[data-lit],[data-selected],[data-last]){fill-opacity:0;stroke-opacity:0}[data-maya=line]~circle[data-maya=mark]{stroke:var(--maya-bg);stroke-width:2;transition:fill-opacity .15s,stroke-opacity .15s}[data-maya=line]~circle[data-lit]{r:4px}circle[data-maya=mark][data-active]{filter:drop-shadow(0 0 4px color-mix(in oklab,var(--c) 70%,transparent))}[data-maya=line]{fill:none;stroke:var(--c);stroke-width:2.25;stroke-linejoin:round;stroke-linecap:round}[data-maya=area]{fill:color-mix(in oklab,var(--c) 18%,transparent);stroke:none}[data-stack] [data-maya=area]{fill:color-mix(in oklab,var(--c) 45%,var(--maya-bg))}`+Ae+`stop{stop-color:var(--c)}[data-maya=link]{fill:var(--c);opacity:.3}[data-maya=link][data-active]{opacity:.6}line[data-maya=link]{stroke:var(--c,var(--maya-fg-muted));opacity:1}text[data-maya=mark]{fill:var(--maya-fg);font-weight:600}[data-kpi=track]{fill:var(--maya-grid)}[data-kpi=target]{stroke:var(--maya-fg)}[data-maya=labels] [data-tone]{fill:var(--c)}[data-maya=labels] :is([data-kpi=period],[data-kpi=of]){fill:var(--maya-fg-muted)}[data-line] i{height:2px;border-radius:1px}[data-ridge]{fill:color-mix(in oklab,var(--c) 40%,var(--maya-bg))}[data-maya=grid] circle{fill:none;shape-rendering:auto}[data-maya=labels] [data-ring]{fill:var(--maya-fg-muted)}[data-maya=marks] text{fill:var(--maya-fg)}[data-maya=sort]{cursor:pointer}[data-maya=sort] rect{fill:transparent}[data-maya=sort] text{font-weight:600}[data-maya=sort]:focus-visible{outline:2px solid var(--maya-focus)}:is([data-maya=line],[data-maya=area]){transition:opacity .25s}[data-maya=marks]:has(path[data-active]) path[data-maya=line]:not([data-active]){opacity:.25}[data-depth]{stroke:var(--maya-bg);stroke-width:1}[data-maya=marks]:has([data-active]) [data-maya=mark]:not([data-active],[data-lit],text){opacity:.4}[data-maya=marks]:has([data-selected]) [data-maya=mark]:not([data-selected]){opacity:.35}[data-selected]{stroke:var(--maya-fg);stroke-width:2}`+Me+`[data-maya=labels],[data-maya=cross],[data-maya=band]{pointer-events:none}[data-maya=cross],[data-maya=band]{opacity:0;transition:opacity .2s}[data-on]:is([data-maya=cross],[data-maya=band]){opacity:1;transition:opacity .2s,transform .25s var(--maya-ease)}[data-maya=band]{fill:var(--maya-fg);fill-opacity:.05;rx:6px}[data-maya=labels] text{fill:var(--maya-fg);paint-order:stroke;stroke:var(--maya-bg);stroke-width:3;stroke-linejoin:round}[data-maya=labels] [data-in]{stroke:none}[data-maya=labels] [data-dark]{fill:var(--maya-bg)}[data-maya=hit]{stroke:none}[data-maya=cross] line{stroke:var(--maya-fg-muted);stroke-opacity:.55}[data-maya=brush]{fill:var(--maya-accent);fill-opacity:.12;stroke:var(--maya-accent);vector-effect:non-scaling-stroke;pointer-events:none}.maya-svg:focus-visible{outline:2px solid var(--maya-focus)}.maya-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.maya-probe{position:absolute;width:0;height:0;pointer-events:none;anchor-name:--maya-probe}.maya-tip{margin:0;inset:auto;border:1px solid var(--maya-grid);padding:8px 10px;min-width:96px;background:var(--maya-tooltip-bg);color:var(--maya-tooltip-fg);border-radius:8px;box-shadow:0 1px 2px #0000000f,0 10px 28px -8px #0000004d;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);font:var(--maya-font-size)/1.4 var(--maya-font);font-variant-numeric:tabular-nums;pointer-events:none}@supports (anchor-name:--x){.maya-tip{position-anchor:--maya-probe;position-area:block-start;position-try-fallbacks:flip-block,block-start span-inline-start,block-start span-inline-end;margin:8px}.maya-tip[data-side]{position-area:inline-end span-block-end;position-try-fallbacks:flip-inline;margin:0 12px}}.maya-tip{opacity:0;translate:0 4px;transition:opacity .15s,translate .2s var(--maya-ease)}.maya-tip.maya-open{opacity:1;translate:none}.maya-tip b{display:block;margin:0 0 4px;font-weight:600}.maya-tip div{display:flex;align-items:center;gap:8px;color:color-mix(in oklab,var(--maya-tooltip-fg) 72%,transparent)}.maya-tip i{width:8px;height:8px;border-radius:50%}.maya-tip [data-v]{margin-inline-start:auto;padding-inline-start:12px;font-weight:600;color:var(--maya-tooltip-fg)}.maya-tip [data-on]{color:var(--maya-tooltip-fg)}@media (pointer:coarse){:is(.maya-legend,.maya-crumbs) button,.maya-ctl [role=radio],.maya-reset,.maya-crumbs{min-height:24px}}@container (max-width:320px){.maya-legend:has(button){display:none}.maya-title{font-size:12px}}@media (prefers-contrast:more){:host,.maya-root{--maya-fg-muted:var(--maya-fg);--maya-grid:color-mix(in oklab,var(--maya-fg) 40%,transparent)}}@media (forced-colors:active){.maya-svg,i{forced-color-adjust:none}[data-maya=mark]{stroke:CanvasText;stroke-width:1}[data-tone=bad]{stroke-dasharray:4 2}}[data-still] *{transition:none!important}@media (prefers-reduced-motion:reduce){*{transition:none!important}}`,Ie=class extends Error{code;path;constructor(e,t,n){super(n),this.name=`MayaSpecError`,this.code=e,this.path=t}},U=e=>e.split(` `),W=Object.fromEntries([...U(`$schema x y2 series size name title description locale currency`).map(e=>[e,`string`]),...U(`stack horizontal labels legend tooltip drill zoom grid xAxis yAxis table animate`).map(e=>[e,`boolean`])]),Le=[...U(`type data y path totals aggregate sort limit format titles text yDomain xDomain select`),...U(`colors colorBy theme`),...Object.keys(W)],Re=[`bar`,`line`,`area`,`dumbbell`],ze=[`treemap`,`sunburst`,`sankey`,`chord`],Be=[`parallel`,`table`],G=`bar,line,area`,Ve=`treemap,sunburst,sankey,chord`,He=Object.fromEntries(U(`horizontal:bar,dumbbell y2:bar size:scatter name:scatter,beeswarm path:${G},dumbbell,${Ve} totals:waterfall series:${G},scatter,heatmap,dumbbell,ridgeline,beeswarm,parallel,marimekko,radial sort:${G},heatmap,dumbbell,table,radial,waffle limit:${G},heatmap,dumbbell,table,waffle,radial stack:bar,area colorBy:${G},waterfall,scatter,dumbbell,kpi,treemap,sunburst,hexmap xDomain:scatter drill:${G},dumbbell,${Ve} select:${G},waterfall,scatter,heatmap,dumbbell,beeswarm,parallel,table,marimekko,waffle,radial,treemap,sunburst,hexmap zoom:line,area,scatter`).map(e=>e.split(`:`)).map(([e,t])=>[e,t.split(`,`)])),Ue=U(`sum mean count min max`),We=U(`auto integer decimal compact percent currency date month year time datetime`),Ge=U(`dateStyle timeStyle weekday era year month day dayPeriod hour minute second fractionalSecondDigits timeZoneName timeZone hour12 hourCycle calendar`),Ke=e=>Ge.some(t=>Object.hasOwn(e,t)),qe=[...U(`font fontSize fg fgMuted grid bg accent radius tooltipBg tooltipFg focus good bad`),...[1,2,3,4,5,6,7,8].map(e=>`series`+e)],Je={x:`the category axis`,y:`the plotted numbers`,y2:`the right-axis line`,series:`splitting rows into series`,size:`bubble area`,name:`point identity`,path:`the hierarchy levels`,colorBy:`colouring marks by value`,format:`formatting that field`,titles:`naming that field`},Ye=`Use horizontal: true to put categories on the left axis.`,Xe=`Size comes from the element's CSS box, or render(spec, { width, height }).`,Ze=`Pie and donut charts are not supported: use "bar" or "treemap" to compare parts.`,Qe=`Use type: "hexmap" (import "mayacharts/geo").`,$e=`Example: { type: "bar", data: [{ month: "Jan", revenue: 10 }], x: "month", y: "revenue" }`,et={label:`Use titles: { <field>: "Name" } for display names, or labels: true for values on marks.`,xLabel:`Use titles: { <x field>: "Name" }. titles is keyed by field and also names tooltips and table headers.`,yLabel:`Use titles: { <y field>: "Name" }. titles is keyed by field and also names tooltips, legend and table headers.`,yFormat:`Use format: "compact" (applies to every y), or format: { <field>: "currency" }.`,dataKey:`Use y: "<field>" for values and x: "<field>" for categories.`,indexAxis:Ye,orientation:Ye,width:Xe,height:Xe,color:`Use colors: [...] for the palette, or colorBy: "sign" | { target: n } | "<field>".`,groupBy:`Use series: "<field>".`,formatter:`Functions are not supported (the spec is JSON). Use format presets or Intl options.`,"size:number":`spec.size names a field for bubble area. For chart size use CSS, or render(spec, { width, height }).`,"select:boolean":`Use select: true or "multi"; omit it to disable selection.`},tt={column:`Use type: "bar".`,barh:`Use type: "bar" with horizontal: true.`,bubble:`Use type: "scatter" with size: "<field>".`,choropleth:Qe,map:Qe,pie:Ze,donut:Ze},nt=U(`rgb rgba hsl hsla oklch oklab lab lch color color-mix light-dark var calc`),rt=String.raw`\s*(?:"[\w\s.\-]*"|'[\w\s.\-]*'|[\w\-]+(?:\s+[\w\-]+)*)\s*`,it=RegExp(`^${rt}(?:,${rt})*$`),at=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,K=e=>typeof e==`object`&&!!e&&!Array.isArray(e),q=(e,t=0)=>Array.isArray(e)&&e.length>=t&&e.every(e=>typeof e==`string`),J=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,Y=e=>{let t=typeof e==`string`||K(e)||Array.isArray(e)?JSON.stringify(e):String(e);return t.length>60?t.slice(0,59)+`…`:t},X=(e,t)=>{let n=e.toLowerCase(),r=``,i=40;for(let e of t){let t=e.toLowerCase(),a=Math.abs(n.length-t.length)+[...t].filter(e=>!n.includes(e)).length,o=0;for(;o<9&&n[o]!==void 0&&n[o]===t[o];)o++;a<4&&a*10-o<i&&([i,r]=[a*10-o,e])}return r&&`Did you mean "${r}"?`},Z=(e,t,n,...r)=>{throw new Ie(e,t,`mayacharts: ${n}\n${[...r,`-> https://bbekshr.github.io/mayacharts/errors.html#${e}`].filter(Boolean).map(e=>` `+e).join(`
3
+ `)}`)},Q=(e,t,n)=>Z(`invalid-option`,e,`spec.${e} must be ${n}, received ${Y(t)}.`,at(et,`${e}:${J(t)}`)??``),ot=(e,t,n)=>{let r=n?it.test(t):/^[#\w\s.,%()+\-\/]*$/.test(t)&&[...t.matchAll(/([\w-]*)\s*\(/g)].every(e=>nt.includes(e[1].toLowerCase()));(!t||!r)&&Z(`unsafe-css-value`,e,`spec.${e} = ${Y(t)} is not a safe CSS value.`,`Allowed: colours, lengths, numbers and ${nt.join(`() `)}(); fonts are family names.`,`Not allowed: url(), image-set(), other functions, ; { } < > \\ and (outside fonts) quotes.`)},$=(e,t,...n)=>Z(`invalid-format`,e,t,...n),st=(e,t,n)=>{if(typeof t==`string`){We.includes(t)||$(e,`spec.${e} = ${Y(t)} is not a format preset.`,`Presets: ${We.join(`, `)}. Or per field: { <field>: preset or Intl options }.`,X(t,We));return}K(t)||$(e,`spec.${e} must be a preset or Intl options, received ${Y(t)}.`);let{prefix:r,suffix:i,...a}=t;for(let[t,n]of[[`prefix`,r],[`suffix`,i]])n!==void 0&&typeof n!=`string`&&$(`${e}.${t}`,`spec.${e}.${t} must be a string, received ${Y(n)}.`);let o=Ke(a);try{o?new Intl.DateTimeFormat(n,a):new Intl.NumberFormat(n,a)}catch(n){$(e,`spec.${e} = ${Y(t)} is not valid ${o?`Intl.DateTimeFormat`:`Intl.NumberFormat`} options.`,n instanceof Error?n.message:String(n))}},ct=[[`y`,`a field name or a non-empty array of field names`,e=>typeof e==`string`||q(e,1)],[`path`,`a non-empty array of field names`,e=>q(e,1)],[`totals`,`an array of x values (strings)`,e=>q(e)],[`aggregate`,`one of ${Ue.join(`, `)}`,e=>Ue.includes(e)],[`sort`,`"asc" or "desc"`,e=>e===`asc`||e===`desc`],[`limit`,`a positive integer`,e=>Number.isInteger(e)&&e>0],[`select`,`true or "multi"`,e=>e===!0||e===`multi`],[`colorBy`,`"sign", { target: number } or a numeric field name`,e=>typeof e==`string`&&!!e||K(e)&&Object.keys(e).join()===`target`&&Number.isFinite(e.target)],[`titles`,`an object of strings keyed by field`,e=>K(e)&&Object.values(e).every(e=>typeof e==`string`)]];function lt(t){K(t)||Z(`spec-not-object`,`spec`,`spec must be a plain object, received ${J(t)}.`,`Received: ${Y(t)}`);let n=t;for(let e of Object.keys(n))Le.includes(e)||Z(`unknown-option`,e,`spec.${e} is not a known option.`,at(et,e)??X(e,Le),`Known options: ${Le.join(`, `)}.`);let r=n.type;r===void 0&&Z(`missing-field`,`type`,`spec.type is required but missing.`,`Required fields: type, data, x, y.`,$e);let i=[...we,...Ee()],a=typeof r==`string`?r:void 0;if(a===void 0||!i.includes(a)){let e=a===void 0?void 0:at(Te,a);e&&Z(`unknown-type`,`type`,`spec.type = "${r}" needs the "${e}" module, which is not loaded.`,`Add: import "mayacharts/${e}"`),Z(`unknown-type`,`type`,`spec.type = ${Y(r)} is not a chart type.`,`Valid types: ${i.join(`, `)}.`,a===void 0?``:at(tt,a)??X(a,[...i,...Object.keys(Te)]))}let o=r,s=ze.includes(o),c=s?`path`:`x`,l=t.path;o===`sankey`&&Array.isArray(l)&&l.length<2&&Z(`invalid-option`,`path`,`spec.path needs at least two levels for a sankey.`,`Example: path: ["region", "family"]`),o===`chord`&&Array.isArray(l)&&l.length!==2&&Z(`invalid-option`,`path`,`spec.path needs exactly two levels for a chord: from and to.`,`Example: path: ["region", "family"]`);let u=e=>Z(`missing-field`,e,`spec.${e} is required but missing.`,`Required fields: type, data, ${c}, y.`,s?`Example: { type: "${o}", data: [{ region: "N", state: "NY", sales: 10 }], path: ["region", "state"], y: "sales" }`:$e);n.data===void 0&&u(`data`),Array.isArray(n.data)||Z(`data-not-array`,`data`,`spec.data must be an array of rows, received ${J(n.data)}.`);let d=n.data;d.forEach((e,t)=>{K(e)||Z(`row-not-object`,`data[${t}]`,`spec.data[${t}] must be an object, received ${J(e)}.`,`Received: ${Y(e)}`)}),n[c]===void 0&&o!==`kpi`&&o!==`beeswarm`&&!(c===`x`&&Re.includes(o)&&n.path!==void 0)&&u(c),n.y===void 0&&u(`y`),(o===`dumbbell`||o===`ridgeline`||o===`marimekko`)&&n.series===void 0&&u(`series`),o===`parallel`&&!(Array.isArray(n.y)&&n.y.length>=2)&&Z(`invalid-option`,`y`,`spec.y on "parallel" needs an array of at least 2 measures, one axis each.`,`Example: y: ["sales", "units", "price"]`);for(let e in W)n[e]!==void 0&&typeof n[e]!==W[e]&&Q(e,n[e],`a ${W[e]}`);for(let[e,t,r]of ct)n[e]!==void 0&&!r(n[e])&&Q(e,n[e],t);let{y:f,path:p,select:m,colors:h,colorBy:g,theme:_,text:v}=n;if(v!==void 0){K(v)||Q(`text`,v,`an object of strings`);for(let[t,n]of Object.entries(v))Object.hasOwn(e,t)||Z(`invalid-option`,`text.${t}`,`spec.text.${t} is not a text key.`,X(t,Object.keys(e)),`Text keys: ${Object.keys(e).join(`, `)}.`),typeof n!=`string`&&Q(`text.${t}`,n,`a string`)}for(let e of[`yDomain`,`xDomain`]){let t=n[e];t!==void 0&&!(Array.isArray(t)&&t.length===2&&Number.isFinite(t[0])&&Number.isFinite(t[1])&&(e===`yDomain`?t[0]!==t[1]:t[0]<t[1]))&&Z(`invalid-domain`,e,`spec.${e} = ${Y(t)} is not a valid domain.`,e===`yDomain`?`Expected [min, max] (or [max, min] to reverse) with two different finite numbers.`:`Expected [min, max] with finite numbers and min < max, e.g. [0, 100].`)}let y=`en-US`;if(typeof n.locale==`string`){let e=!1;try{e=Intl.NumberFormat.supportedLocalesOf(n.locale).length>0}catch{}e||$(`locale`,`spec.locale = ${Y(n.locale)} is not a locale this runtime supports.`,`Use a BCP 47 tag such as "de-DE". Node built with small ICU supports English only.`),y=n.locale}if(typeof n.currency==`string`)try{new Intl.NumberFormat(y,{style:`currency`,currency:n.currency})}catch{$(`currency`,`spec.currency = ${Y(n.currency)} is not an ISO 4217 currency code.`,`Use a three-letter code such as "USD" or "EUR".`)}if(typeof n.format==`string`)st(`format`,n.format,y);else if(n.format!==void 0){K(n.format)||Q(`format`,n.format,`a preset or an object keyed by field`);for(let[e,t]of Object.entries(n.format))st(`format.${e}`,t,y)}if(h!==void 0){let e=Array.isArray(h)?h.map((e,t)=>[`[${t}]`,e]):K(h)?Object.entries(h).map(([e,t])=>[`.${e}`,t]):null;(!e||!e.every(([,e])=>typeof e==`string`))&&Q(`colors`,h,`an array of colours, or an object of colours by series value`),e.length>8&&Z(`invalid-option`,`colors`,`spec.colors has ${e.length} colours; the palette has 8 slots.`,`Pass at most 8. Series 9 and later reuse slots in order.`);for(let[t,n]of e)ot(`colors${t}`,n,!1)}if(_!==void 0){K(_)&&Object.values(_).every(e=>typeof e==`string`)||Q(`theme`,_,`an object of string values`);for(let e of Object.keys(_))qe.includes(e)||Z(`invalid-theme`,`theme.${e}`,`spec.theme.${e} is not a theme token.`,`Valid tokens: ${qe.join(`, `)}.`,X(e,qe));for(let[e,t]of Object.entries(_))ot(`theme.${e}`,t,e===`font`)}n.stack===!0&&o===`line`&&Z(`stack-unsupported`,`stack`,`spec.stack is not supported with spec.type = "line".`,`Use type "area" (or "bar") to stack series.`);for(let e in He)n[e]!==void 0&&n[e]!==!1&&!He[e].includes(o)&&Z(`option-unsupported`,e,`spec.${e} is not supported with spec.type = "${o}".`,`spec.${e} works with: ${He[e].join(`, `)}.`);let b=Re.includes(o),x=[[g!==void 0&&n.series!==void 0&&o!==`dumbbell`,`colorBy`,`spec.colorBy cannot be combined with spec.series.`,`Series already set the colours; remove one of them.`],[n.yDomain!==void 0&&Array.isArray(f),`yDomain`,`spec.yDomain cannot be combined with a y array.`,`Each measure needs its own domain; use a single y or remove yDomain.`],[n.drill===!0&&m!==void 0,`select`,`spec.select cannot be combined with spec.drill.`,`A click either drills or selects; choose one.`],[b&&p!==void 0&&n.x!==void 0,`x`,`spec.x cannot be combined with spec.path.`,`With path, the current drill level is the category; remove x.`],[n.y2!==void 0&&n.horizontal===!0,`y2`,`spec.y2 cannot be combined with spec.horizontal.`,`The y2 line needs a right value axis; draw vertical bars.`],[o===`kpi`&&g!==void 0&&!K(g),`colorBy`,`spec.colorBy on "kpi" must be { target: number }.`,`A kpi compares its headline with one target, drawn as a bullet bar.`],[b&&n.drill===!0&&p===void 0,`drill`,`spec.drill on "${o}" needs spec.path.`,`Replace x with path: ["region", "state"] (outer to inner).`]];for(let[e,t,n,r]of x)e&&Z(`option-unsupported`,t,n,r);if(d.length){let e=[...new Set(d.flatMap(e=>Object.keys(e)))],t=(t,n,r,i)=>Z(`unknown-field`,t,n,`Fields found: ${e.slice(0,20).join(`, `)}.`,X(r,e),i),r=typeof f==`string`?[f]:f,i=(e,t)=>t.map((t,n)=>[`${e}[${n}]`,t]),a=[[`x`,n.x],...typeof f==`string`?[[`y`,f]]:i(`y`,r),[`series`,n.series],[`y2`,n.y2],[`size`,n.size],[`name`,n.name],...i(`path`,p??[]),[`colorBy`,g===`sign`?void 0:g]];for(let[n,r]of a){if(typeof r!=`string`||e.includes(r))continue;let i=n.replace(/\[.*/,``);t(n,`spec.${n} = ${Y(r)} is not a field in spec.data.`,r,`spec.${i} names the field used for ${Je[i]}.`)}for(let r of[`format`,`titles`])if(K(n[r]))for(let i of Object.keys(n[r]))e.includes(i)||t(`${r}.${i}`,`spec.${r} key "${i}" is not a field in spec.data.`,i,`spec.${r} keys name fields, for ${Je[r]}.`);g===`sign`&&e.includes(`sign`)&&Z(`invalid-option`,`colorBy`,`spec.colorBy = "sign" colours by the sign of y, but spec.data also has a field named "sign".`,`Rename that field (e.g. data.map(({ sign, ...r }) => ({ ...r, signValue: sign }))) to colour by it.`);let c=(e,t)=>d.forEach((n,r)=>t(n[e],`data[${r}].${e}`)),l=(e,t,n)=>c(e,(r,i)=>{r==null||typeof r==`number`&&Number.isFinite(r)||Z(t,i,`spec.${i} is ${Y(r)} (a ${J(r)}), but spec.${n} requires numbers.`,typeof r==`string`&&r.trim()&&Number.isFinite(Number(r))?`Convert first: data.map(r => ({ ...r, ${e}: Number(r.${e}) }))`:`Use null for a gap in the data.`)});for(let e of r)l(e,`non-numeric-y`,`y`);if(typeof n.size==`string`&&l(n.size,`non-numeric-field`,`size`),typeof n.y2==`string`&&l(n.y2,`non-numeric-field`,`y2`),o===`dumbbell`&&typeof n.series==`string`){let e=new Set(d.map(e=>String(e[n.series]))).size;e!==2&&Z(`invalid-option`,`series`,`spec.series on "dumbbell" needs exactly 2 values, found ${e}.`,`The first value seen is the start of each bar, the second the end, e.g. last year and this year.`)}if(o===`scatter`&&typeof n.x==`string`&&l(n.x,`non-numeric-field`,`x`),typeof g==`string`&&g!==`sign`&&l(g,`non-numeric-field`,`colorBy`),s)for(let e of r)c(e,(t,n)=>{typeof t==`number`&&t<=0&&Z(`non-positive-value`,n,`spec.${n} is ${t}, but ${o} sizes must be positive.`,`Filter first: data.filter(r => r.${e} > 0), or chart the signed values with "bar".`)})}Ce.get(o)?.check?.(t,Z)}function ut(e){if(e===void 0)return;K(e)||Z(`invalid-option`,`options`,`options must be a plain object, received ${J(e)}.`);let t=e,n=(e,t,n)=>Z(`unknown-option`,`${e}.${t}`,`${e}.${t} is not a known render option.`,X(t,n),`Known options: ${n.join(`, `)}.`),r=U(`width height view selected nonce`);for(let e of Object.keys(t))r.includes(e)||n(`options`,e,r);let i=(e,t,n)=>Z(`invalid-option`,`options.${e}`,`options.${e} must be ${n}, received ${Y(t)}.`);for(let e of[`width`,`height`]){let n=t[e];n!==void 0&&!(typeof n==`number`&&Number.isFinite(n)&&n>0)&&Z(`invalid-size`,`options.${e}`,`options.${e} = ${Y(n)} is not a valid size.`,`Size must be a finite number greater than 0.`)}let{view:a,selected:o,nonce:s}=t;if(a!==void 0){K(a)||i(`view`,a,`an object`);let e=U(`measure drill window hidden sortBy`);for(let t of Object.keys(a))e.includes(t)||n(`options.view`,t,e);let{measure:t,drill:r,window:o,hidden:s,sortBy:c}=a;c!==void 0&&(!Array.isArray(c)||c.length!==2||typeof c[0]!=`string`||c[1]!==`asc`&&c[1]!==`desc`)&&i(`view.sortBy`,c,`[field, "asc" | "desc"]`),t!==void 0&&!(Number.isInteger(t)&&t>=0)&&i(`view.measure`,t,`an index (integer >= 0)`),r!==void 0&&!q(r)&&i(`view.drill`,r,`an array of strings`),s!==void 0&&!q(s)&&i(`view.hidden`,s,`an array of strings`),o!==void 0&&(!Array.isArray(o)||o.length!==2&&o.length!==4||!o.every(Number.isFinite))&&i(`view.window`,o,`[i0, i1] or [x0, x1, y0, y1] of finite numbers`)}o!==void 0&&!(Array.isArray(o)&&o.every(e=>K(e)&&Object.keys(e).every(e=>[`x`,`series`,`name`].includes(e))))&&i(`selected`,o,`an array of { x?, series?, name? }`),s!==void 0&&!(typeof s==`string`&&/^[\w+/=-]+$/.test(s))&&i(`nonce`,s,`a base64 nonce string`)}function dt(e,t={}){let n=typeof e.y==`string`?[e.y]:[...e.y],r=Math.min(t.measure??0,n.length-1),i=[...e.path??[]],a=e.drill?(t.drill??[]).slice(0,Math.max(0,i.length-1)):[],o=i.slice(a.length),s=e.format,c=e=>Object.entries(e??{}).filter(e=>e[1]!==void 0);return{type:e.type,data:a.length?e.data.filter(e=>a.every((t,n)=>String(e[i[n]])===t)):e.data,x:e.x??(Re.includes(e.type)?o[0]??``:``),y:n[r],measures:n,measure:r,series:e.series??null,y2:e.y2??null,path:o,drilled:a,window:t.window&&t.window.length===4?t.window:null,size:e.size??null,name:e.name??null,totals:[...e.totals??[]],stack:e.stack??!1,horizontal:e.horizontal??!1,aggregate:e.aggregate??`sum`,sort:e.sort??null,sortBy:t.sortBy??null,limit:e.limit??null,format:new Map(typeof s==`string`?n.map(e=>[e,s]):c(s)),titles:new Map(c(e.titles)),labels:e.labels??null,text:{...e.text},title:e.title??null,description:e.description??null,legend:e.legend??(e.series!==void 0||e.y2!==void 0||e.type===`waffle`),tooltip:e.tooltip??!0,drill:e.drill??!1,select:e.select??!1,zoom:e.zoom??!1,grid:e.grid??!0,xAxis:e.xAxis??!0,yAxis:e.yAxis??!0,locale:e.locale??`en-US`,currency:e.currency??`USD`,yDomain:e.yDomain??null,xDomain:e.xDomain??null,table:e.table??!0,animate:e.animate??!0,colors:Array.isArray(e.colors)?e.colors:e.colors?new Map(Object.entries(e.colors)):null,colorBy:e.colorBy??null,theme:e.theme??{}}}var ft={bar:F,waterfall:F,line:me,area:he,scatter:ve,heatmap:ne,kpi:ae,dumbbell:te,ridgeline:de,beeswarm:L,parallel:ue,table:be},pt=e=>e.replace(/[A-Z]|\d+/g,e=>`-`+e.toLowerCase());function mt(e,n,o){lt(e),n!==void 0&&ut(n);let s=Object.hasOwn(ft,e.type)?ft[e.type]:Ce.get(e.type),c=dt(e,n?.view),u=n?.width??640,d=n?.height??320,m=A(c,n?.view??{}),h=e=>e>5e3&&Z(`too-many-marks`,`data`,`${e} marks exceed the limit of 5000.`,`Use spec.limit to keep the top N categories, or aggregate the rows first.`);h(m.cells.length);let g=/* @__PURE__ */ new Map,v=(e,n,r)=>{if(n===`\0other`)return t(c,`other`);let i=e+`\0`+r,a=g.get(i);return a||g.set(i,a=_(c,e,r)),a(n)},y=c.colorBy,b=1/0,x=-1/0;if(typeof y==`string`&&y!==`sign`)for(let e of c.data){let t=e[y];typeof t==`number`&&(b=Math.min(b,t),x=Math.max(x,t))}let S=e=>y===`sign`?e<0?`bad`:`good`:y&&typeof y==`object`?e>=y.target?`good`:`bad`:null,C=e=>{let n=S(e);return n===null?null:t(c,y===`sign`?n===`good`?`positive`:`negative`:n===`good`?`above`:`below`)},w=[],T=``,E=(e,t,n,o)=>{let s=n.length*7.2+4,c=o===`start`?e:o===`end`?e-s:e-s/2,l=o===`above`?t-16:o===`below`?t+2:t-7;return c<0||l<0||c+s>u||l+14>d||w.some(e=>c<e[2]&&c+s>e[0]&&l<e[3]&&l+14>e[1])?!1:(w.push([c,l,c+s,l+14]),T+=a(`text`,{x:i(e),y:i(o===`above`?t-4:o===`below`?t+13:t),"text-anchor":o===`start`||o===`end`?o:`middle`,"dominant-baseline":o===`above`||o===`below`?null:`middle`,"data-in":o===`center`},r(n)),!0)},D=s.axes?O(c,s.axes(c,m),{width:u,height:d},v):null,j=D?.plot??{x:0,y:0,w:u,h:d},M={spec:c,shaped:m,width:u,height:d,plot:j,x:D?.x??null,y:D?.y??null,y2:D?.y2??null,fmt:v,label:E,tone:S,q:e=>x>b?Math.min(9,Math.max(0,Math.floor((e-b)/(x-b)*10))):9,agg:e=>t=>{let n=k(e);for(let e of t)typeof e==`number`&&n.add(e);return n.value()},fail:Z,t:(e,...n)=>t(c,e,...n)};s.check?.(e,Z);let N=null,P=``;if(c.data.length===0)P=a(`text`,{"data-maya":`empty`,x:u/2,y:d/2,"text-anchor":`middle`,"dominant-baseline":`middle`},r(t(c,`noData`)));else{let e=(e,t)=>a(`g`,{"data-maya":e},t),t=s.draw(M);h(t.marks.split(` data-maya="mark"`).length-1),N=t.legend??null,P=e(`grid`,(c.type===`area`&&!c.stack||c.type===`kpi`?a(`defs`,{},[...new Set(m.visible.map(e=>e%8))].map(e=>a(`linearGradient`,{id:`maya-a${e}`,"data-s":e,x1:0,y1:0,x2:0,y2:1},`<stop offset="0" stop-opacity=".34"/><stop offset="1" stop-opacity=".02"/>`)).join(``)):``)+(t.grid??D?.grid??``))+e(`axis-y`,D?.ay??``)+e(`axis-x`,D?.ax??``)+e(`marks`,t.marks)+e(`labels`,(t.labels??``)+T)+e(`cross`,t.cross??``)+e(`hits`,t.hits)}let F=[];if(Array.isArray(c.colors))c.colors.forEach((e,t)=>F.push([`--maya-series-${t+1}`,e]));else if(c.colors)for(let[e,t]of c.colors){let n=(c.type===`waffle`?m.categories:m.series).indexOf(e);n>=0&&F.push([`--maya-series-${n%8+1}`,t])}for(let e in c.theme)F.push([`--maya-${pt(e)}`,c.theme[e]]);let I=F.map(([e,t])=>`${e}:${t};`).join(``),ee=a(`svg`,{class:o===null?`maya-svg`:`maya-root maya-svg`,viewBox:`0 0 ${u} ${d}`,width:u,height:d,role:c.type===`table`?`figure`:`img`,"aria-label":o===null?null:l(c),"aria-labelledby":o===null?`maya-t`:null,"aria-describedby":o===null?`maya-d`:null,tabindex:o===null?`0`:null,style:o===null?null:I||null,"data-plot":`${i(j.x)} ${i(j.y)} ${i(j.w)} ${i(j.h)}`,...D?.attrs,"data-dir":c.horizontal?`h`:null,"data-stack":c.stack||null},(o?`<style>${o}</style>`:``)+a(`title`,{id:o===null?`maya-t`:null},r(l(c)))+a(`desc`,{id:o===null?`maya-d`:null},r(f(c,m,v,s.noun)))+P),L=``;return N!==null&&c.legend?L=N:(c.series!==null||c.y2!==null)&&c.legend?L=`<div class="maya-legend" data-maya="legend">`+(c.series===null&&c.y2!==null?`<span data-s="0"><i></i>${r(c.titles.get(c.y)??c.y)}</span>`:``)+(c.series===null?[]:m.series).map((e,t)=>a(`button`,{type:`button`,"data-si":t,"data-s":t%8,"data-key":e,"aria-pressed":String(m.visible.includes(t))},`<i></i>${r(e)}`)).join(``)+(c.y2===null?``:`<span data-s="${m.series.length%8}" data-line><i></i>${r(c.titles.get(c.y2)??c.y2)}</span>`)+`</div>`:e.legend!==!1&&y!==null&&c.series===null&&c.type!==`kpi`&&(L=y===`sign`||typeof y==`object`?`<div class="maya-legend" data-maya="tone">`+[`good`,`bad`].map(e=>`<span data-tone="${e}"><i></i>${r(t(c,y===`sign`?e===`good`?`positive`:`negative`:e===`good`?`above`:`below`))}</span>`).join(``)+`</div>`:x>b?`<div class="maya-legend" data-maya="ramp"><span>${r(v(y,b))}</span><i></i><span>${r(v(y,x))}</span></div>`:``),{svg:ee,legend:L,controls:c.measures.length>1&&!Be.includes(c.type)?`<div class="maya-ctl" role="radiogroup" aria-label="${r(t(c,`measures`))}" data-n="${c.measures.length}" data-i="${c.measure}">`+c.measures.map((e,t)=>`<button type="button" role="radio" aria-checked="${t===c.measure}" data-i="${t}" tabindex="${t===c.measure?0:-1}">${r(c.titles.get(e)??e)}</button>`).join(``)+`</div>`:``,crumbs:c.drilled.length>0?`<nav class="maya-crumbs" aria-label="${r(t(c,`crumbs`))}"><button type="button" data-depth="0">${r(t(c,`back`))}</button>`+c.drilled.map((e,t)=>`<span aria-hidden="true">›</span><button type="button" data-depth="${t+1}"${t===c.drilled.length-1?` aria-current="page"`:``}>${r(String(e))}</button>`).join(``)+`</nav>`:c.drill?`<div class="maya-crumbs" aria-hidden="true"></div>`:``,table:c.table?p(c,m,v,C):``,title:c.title===null?``:`<div class="maya-title">${r(c.title)}</div>`,style:I,vars:F,warnings:[]}}function ht(e,t){return mt(e,t,null)}function gt(e,t){return mt(e,t,Fe).svg}function _t(e,t,n){let i=e.style?` style="${r(e.style)}"`:``,a=n?` nonce="${r(n)}"`:``;return`${t?`<style${a}>${t}</style>`:``}<div class="maya"${i}>${e.title}${e.controls}${e.legend}${e.crumbs}<div class="maya-box">${e.svg}</div>${e.table}<div class="maya-sr" data-maya="live" aria-live="polite"></div><div class="maya-probe" data-maya="probe"></div><div class="maya-tip" popover="manual" role="tooltip"></div></div>`}function vt(e){let t=e=>typeof e==`object`?Object.keys(e):[],n=/* @__PURE__ */ new Set([e.x,...typeof e.y==`string`?[e.y]:e.y,e.series,e.y2,e.size,e.name,...e.path??[],typeof e.colorBy==`string`?e.colorBy:void 0,...t(e.format),...t(e.titles)]);return{...e,data:e.data.map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>n.has(e))))}}function yt(e,t){let n=ht(e,t),r=JSON.stringify(vt(e)).replace(/</g,`\\u003c`);return`<maya-chart><template shadowrootmode="open">${_t(n,Fe,t?.nonce)}</template><script type="application/json">${r}<\/script></maya-chart>`}export{Ie as MayaSpecError,gt as render,ht as renderParts,yt as renderShell,lt as validateSpec,xe as version};
4
4
  //# sourceMappingURL=index.js.map