Skill Tracer
Skills › Archify › archify › MSKIJHB2.js

MSKIJHB2.js

2 lines · archify/explainer/vendor/pele/chunks/MSKIJHB2.js at a406594

1import{a as ae,b as ce}from"./DKTLEL5E.js";import{a as le,b as fe,c as de,d as pe,e as he,f as me,g as ue,h as ge,i as $e,j as be,k as B,l as we,m as ye,n as Me,o as Pe,p as xe}from"./3DKXF73K.js";import{b as F,c as o,d as G,m as U,n as se,o as Z}from"./IZOKQ2GT.js";import{a as oe,g as re}from"./XTDUIGUI.js";function ke(i,e){let t=new Map;for(let{label:n,value:c}of i.sections){if(c<0)throw new oe(`"${n}" has invalid value: ${c}. Negative values are not allowed in pie charts. All slice values must be >= 0.`,"semantic",{type:"pie"});t.has(n)||t.set(n,c)}return{type:"pie",title:i.title||e,accTitle:i.accTitle?i.accTitle.replace(/^\s+/g,""):void 0,accDescr:i.accDescr?i.accDescr.replace(/\n\s+/g,`
2`):void 0,showData:i.showData,sections:t}}function Ae(i,e){let t=e;for(let n=i.charCodeAt(t);n>=48&&n<=57;n=i.charCodeAt(t))t++;return t}function Re(){let i=0,e=0,t=-1;return(n,c)=>{let s=n.charCodeAt(c)===45?c+1:c;if((s<i||s>=e)&&(i=s,e=Ae(n,s),t=-1,e>s&&n.charCodeAt(e)===46)){let r=Ae(n,e+1),f=r-e-1;f>0&&n.charCodeAt(r)!==46?t=r:f>1&&(t=r-1)}return e===s?-1:t>=0?t:n.charCodeAt(s)===48?n.charCodeAt(s+1)===46?-1:s+1:n.charCodeAt(e)!==46?e:e-1>s?e-1:-1}}var De=[B("showData"),B("pie"),{name:":",pattern:":"},{name:"NUMBER_PIE",pattern:/(?:-?[0-9]+\.[0-9]+(?!\.))|(?:-?(0|[1-9][0-9]*)(?!\.))/y,scanner:Re,first:"-0123456789"},fe,de,pe,he,me,ue,ge,$e,be];function Ce(i){let e=new xe(le(i,De,"pie"),De,"pie"),t={$type:"Pie",showData:!1,sections:[]},n=()=>{if(e.kind!==-1)for(e.kind!==8&&e.fail("a line break or the end of input");e.kind===8;)e.i++};for(;e.kind===8;)e.i++;for(e.expect(1),t.showData=e.accept(0);e.kind!==-1;)switch(e.kind){case 8:e.i++;break;case 4:t.accDescr=Me(e.take()),n();break;case 5:t.accTitle=ye(e.take()),n();break;case 6:t.title=we(e.take()),n();break;case 7:{let c=Pe(e.take());e.expect(2);let s=Number(e.expect(3));t.sections.push({$type:"PieSection",label:c,value:s}),n();break}default:e.fail("a section, a title, or a line break")}return t}var Le=120,E=12,K=26,Y=32,Ee=28;function q(i,e){return i.pie?.[e]}function M(i,e){return`${o(Math.sin(i)*e)},${o(-Math.cos(i)*e)}`}function _e(i,e,t,n){if(e-i>=Math.PI*2-1e-9){let s=(r,f)=>`M0,${o(-r)}A${o(r)},${o(r)} 0 1 ${f} 0,${o(r)}A${o(r)},${o(r)} 0 1 ${f} 0,${o(-r)}Z`;return s(t,1)+(n>0?s(n,0):"")}let c=e-i>Math.PI?1:0;return n<=0?`M0,0L${M(i,t)}A${o(t)},${o(t)} 0 ${c} 1 ${M(e,t)}Z`:`M${M(i,t)}A${o(t)},${o(t)} 0 ${c} 1 ${M(e,t)}L${M(e,n)}A${o(n)},${o(n)} 0 ${c} 0 ${M(i,n)}Z`}function Te(i,e,t){return ae(t,Le*2,140,(n,c)=>Ne(i,e,t,n/2,c))}function Ne(i,e,t,n,c){let s=t.fontSize??16,r=Math.round(s*.875),f=t.measurer??re(t.fontFamily),u=t.padding??8,T=q(e,"textPosition"),J=typeof T=="number"&&T>=0&&T<=1?T:.75,v=q(e,"donutHole"),ve=typeof v=="number"&&v>0&&v<=.9?v*n:0,N=String(q(e,"legendPosition")??"right"),p=c&&(N==="left"||N==="right")?"bottom":N,P=[...i.sections],O=0;for(let[,a]of P)O+=a;let I=P.map(([a,l])=>Z(i.showData?`${a} [${l}]`:a,!1,f,r,4e3)),d=0;for(let a of I)d=Math.max(d,a.width);d+=I.length>0?E+8:0;let g=I.length*K,x=Z(i.title,!1,f,s,ce(t),1),Q=x.height>0?x.height+16:0,X=P.map(([,a])=>{let l=O>0?a/O:0;return l*100>=1&&(l*100).toFixed(0)!=="0"?l:0}),ee=X.map(a=>a===0||a>=.5?!1:2*n*J*Math.sin(a*Math.PI)<f.width((a*100).toFixed(0)+"%",r,0)+6),Ie=ee.includes(!0)?Ee:0,$=p==="left"||p==="right"||p==="center"?p:"",te=p==="top"||p==="bottom",h=(n+Ie)*2,m=h,b=h;$==="left"||$==="right"?(m+=d>0?Y+d:0,b=Math.max(b,g)):te&&(m=Math.max(m,d),b+=g>0?20+g:0),m=Math.max(m,x.width);let k=u+($==="left"?d+Y+h/2:$==="right"?h/2:m/2),A=u+Q,S=A+(p==="top"?g+20+h/2:te?h/2:b/2),R="",W="",j="",L=0;P.forEach(([a],l)=>{let y=X[l];if(y===0)return;let V=L+y*Math.PI*2;R+=`<path class="pele-slice" data-id="${F(a)}" d="${_e(L,V,n,ve)}" fill="${U(l)}"/>`;let _=(L+V)/2,ie=(y*100).toFixed(0)+"%";if(ee[l]){let C=n+Ee/2;j+=`<text x="${o(Math.sin(_)*C)}" y="${o(-Math.cos(_)*C+r*.35)}">${ie}</text>`}else{let C=n*J;W+=`<text x="${o(Math.sin(_)*C)}" y="${o(-Math.cos(_)*C+r*.35)}">${ie}</text>`}L=V}),R===""&&(R=`<circle class="pele-slice" r="${n}" fill="none" stroke="var(--_b)"/>`);let z="",w,D;$==="right"?(w=k+h/2+Y,D=A+(b-g)/2):$==="left"?(w=u,D=A+(b-g)/2):$==="center"?(w=k-d/2,D=S-g/2):(w=u+(m-d)/2,D=p==="top"?A:A+h+20),I.forEach((a,l)=>{let y=D+l*K+K/2;z+=`<g class="pele-legend-item" data-id="${F(P[l][0])}"><rect x="${o(w)}" y="${o(y-E/2)}" width="${E}" height="${E}" rx="2" fill="${U(l)}"/>`+G(a,w+E+8+a.width/2,y,"")+"</g>"});let H=Math.ceil(m+2*u),ne=Math.ceil(b+Q+2*u),Se=G(x,H/2,u+x.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-slices" transform="translate(${o(k)},${o(S)})" stroke="var(--_bg)" stroke-width="1.5" stroke-linejoin="round">${R}</g>`+(W?`<g class="pele-slice-labels" transform="translate(${o(k)},${o(S)})" font-size="${r}" text-anchor="middle" fill="var(--_bg)">${W}</g>`:"")+(j?`<g class="pele-slice-labels" transform="translate(${o(k)},${o(S)})" font-size="${r}" text-anchor="middle">${j}</g>`:"")+(z?`<g class="pele-legend" font-size="${r}">${z}</g>`:"");return{svg:se("pie",H,ne,s,t,i,Se),width:H,height:ne,links:[]}}var Qe={type:"pie",parse:(i,e,t)=>ke(Ce(i),t),render:Te};export{Qe as a};