@bicharts/chart-mcp 0.6.54 → 0.6.55
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/README.md +7 -1
- package/dist/check-chart.mjs +1 -1
- package/dist/index.mjs +91 -86
- package/package.json +1 -1
- package/skills/bic-charts/SKILL.md +31 -10
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ What that buys you: a working, interactive chart that **fits your data on the fi
|
|
|
22
22
|
try** — real source you commit, with no D3, Vega or charting-API expertise in the
|
|
23
23
|
loop, and a solid starting point to adjust rather than a blank page. Because the
|
|
24
24
|
engine knows what ~90 chart types can honestly say, it will sometimes propose a view
|
|
25
|
-
— or a measure — you had not thought to ask for.
|
|
25
|
+
— or a measure — you had not thought to ask for. The main tools:
|
|
26
26
|
|
|
27
27
|
- **`assess_data_shape`** — profiles a CSV **locally** with the same measurement
|
|
28
28
|
engine the Power BI visual uses (`@bicharts/shape-core`). No backend call, no
|
|
@@ -42,6 +42,12 @@ engine knows what ~90 chart types can honestly say, it will sometimes propose a
|
|
|
42
42
|
is not the same as no cost, because eligibility *is* the engine's own answer. Free within
|
|
43
43
|
a generous hourly allowance; beyond it a call may draw usage credits. A live licence
|
|
44
44
|
additionally unlocks *draft* types.
|
|
45
|
+
- **`suggest_charts`** — "which charts suit this model?" in one call, for a semantic model in a
|
|
46
|
+
Microsoft Fabric App on Rayfin's data app template: reads the model's tables, measures and
|
|
47
|
+
relationships through the project's own `fabric-app-data` CLI, finds its natural views (by place,
|
|
48
|
+
flows between places, over time, by category), queries each at its grain and asks the eligibility
|
|
49
|
+
engine what fits each, replying with the real counts. Each view saves its rows for
|
|
50
|
+
`generate_chart`. One `list_eligible_charts`-style metered call per view.
|
|
45
51
|
- **`generate_chart`** — profiles locally, then calls the BIC backend, which picks
|
|
46
52
|
an eligible chart type for the measured shape (or honors `chart_type`) and
|
|
47
53
|
returns code that has passed the backend's gates/QC. Renderer selection is the same
|
package/dist/check-chart.mjs
CHANGED
|
@@ -300,6 +300,6 @@ License: MIT
|
|
|
300
300
|
.${os} .${nS} text {
|
|
301
301
|
font-weight: 700 !important;
|
|
302
302
|
text-decoration: underline !important;
|
|
303
|
-
}`,(t.head||t.documentElement)?.appendChild(j)}catch{}},O=()=>{try{let j=w,ne=!!j&&j.length>0,ue=ne&&!A;r.classList?.[ue?"add":"remove"](Uw);let _e=r.querySelectorAll(`.${nS}`);for(let fe of Array.from(_e))fe.classList?.remove(nS);let Be=!!P&&(typeof r.contains=="function"?r.contains(P):P.isConnected!==!1);ne&&Be&&P.classList?.add(nS);let Ke=new Set(j??[]),ut=r.querySelectorAll(`.${ca}[${Vo}], .${Zy}[${Vo}]`);for(let fe of Array.from(ut)){let ge=bC(fe.getAttribute(Vo)),Ye=ne&&ge.some(be=>Ke.has(be));fe.classList?.[Ye?"add":"remove"](Bw)}}catch{}},T=(j,ne,ue,_e=!1)=>{w=j,M=j.length>0&&_e,P=j.length?ue??null:null,A=j.length>0&&IV(!!ue,LV(r)),O();for(let Be of C)try{Be(j,ne)}catch{}},L=0,N=150,W=j=>{let ne=j?.detail||{};L=Date.now(),ne.clear?T([],ne.source||"chart"):ne.mark&&T(bC(ne.mark.getAttribute?.(Vo)),ne.source||"chart",ne.mark,!0)},B=bH({root:r,doc:t,log:()=>{}}),R=`.${ca}[${Vo}], .${Zy}[${Vo}], .${lS}[${Vo}]`,F=j=>{if(Date.now()-L<N||gH(j?.target,r))return;let ne=B.findMark(j?.target,R,j);if(ne||(ne=B.penetrateOverlayAt(j?.clientX,j?.clientY,R)),ne||(ne=B.resolveByGeometry(j?.clientX,j?.clientY,R)),!ne){if(w&&w.length){let fe=r[U5];if(M&&typeof fe=="function")try{fe()}catch{}w&&w.length&&T([],"user")}return}let ue=bC(ne.getAttribute(Vo));if(!ue.length)return;let _e=ne.classList?.contains?.(lS)?ne:null,Be=!!(j?.ctrlKey||j?.metaKey||j?.shiftKey),Ke=fH(w,ue,{ctrl:!!(j?.ctrlKey||j?.metaKey),shift:!!j?.shiftKey}),ut=!Be&&Ke.length===0;T(Ke,"user",ut?null:_e)};r.addEventListener(AC,W),r.addEventListener("click",F),r.classList?.add(os),D();let V=e.fit??!0,K=e.labelContrast??!0,J=()=>{let j=r[UC];if(typeof j=="function")try{j()}catch{}},z=()=>{if(K!==!1)try{let j=K===!0?{}:{...K};if(!j.pageBg){let ue=l.backgroundColor??l.themeBg;typeof ue=="string"&&ue&&(j.pageBg=ue)}let ne=rz(r,j);e.onLabelContrast?.(ne)}catch{}SH(r,t),O();try{let j=F5(r);if(G5({markCount:j.markCount,rows:i.rows?i.rows.length:0,animated:e.animated,contractUntagged:e.contractUntagged,declaresNoRowMarks:j.declaresNoRowMarks})){if(!m){m=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] this chart rendered without error but painted no data marks, against ${i.rows.length} row(s) \u2014 so the container is empty. The usual cause is that the generated code binds a column BY NAME that is no longer in the data, sending it down its own "no data" branch. Check that the columns in your table still match the ones the chart was generated for.`)}catch{}}e.onBlankRender?.({census:j,rows:i.rows?i.rows.length:0})}}catch{}if(e.onHitBandCensus)try{e.onHitBandCensus(AH(r,t))}catch{}if(e.onColourSpreadCensus)try{e.onColourSpreadCensus(VV(r,t))}catch{}if(e.onValuePlacementCensus)try{e.onValuePlacementCensus(PH(r,i))}catch{}if(V!==!1)try{let j=FH(r,V===!0?{}:V);e.onFit?.(j)}catch{}try{y()}catch{}},q=j=>{let ne=String(j?.message??j??"");return e.onInvalidSentinel&&oz(ne)?(J(),r.innerHTML="",e.onInvalidSentinel({reason:nz(ne),message:ne}),null):sz(j,n)},me={render(){if(c)return;let j=++p;if(J(),r.innerHTML="",!u){if(!e.code)throw new Error("createChartHost: provide code or renderFn");u=uz(e.code,o,t,n)}if(l.geo===void 0&&e.geoKind){let ue=e.geoProvider?.(e.geoKind)??JV(e.geoKind);if(ue)l={...l,geo:ue};else if(!h){h=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] geoKind "${e.geoKind}" was set but no geometry is available, so this chart will draw without a basemap. Either \`await loadGeo("${e.geoKind}")\` before rendering, pass a geoProvider, or import { geoForKind } from "@bicharts/chart-host/geo" and set options.geo.`)}catch{}}}l.geoUnmatched===void 0&&i.geoUnmatched&&(l={...l,geoUnmatched:i.geoUnmatched}),l.geoPoint===void 0&&i.geoPoint&&(l={...l,geoPoint:i.geoPoint}),l.geoPointDest===void 0&&i.geoPointDest&&(l={...l,geoPointDest:i.geoPointDest}),l.dateCellsAreUtcDays===void 0&&i.dateCellsAreUtcDays&&(l={...l,dateCellsAreUtcDays:!0});let ne;try{ne=u(r,{columns:i.columns,rows:i.rows},l)}catch(ue){let _e=q(ue);if(_e)throw b(Promise.reject(_e)),_e;b(Promise.resolve());return}if(!Iie(ne)){z(),b(Promise.resolve());return}b(new Promise((ue,_e)=>{let Be=setTimeout(()=>{_e(new Error(`[@bicharts/chart-host] the chart did not finish drawing within ${Math.round(xV/1e3)}s, so the host stopped waiting for it. Nothing past that point ran: no label-contrast pass, no hit-target heal, no census, no fit. A render() that returns a promise has to settle it.`))},xV),Ke=ut=>{clearTimeout(Be),ut()};Promise.resolve(ne).then(()=>Ke(()=>{if(c||j!==p){ue();return}z(),ue()}),ut=>Ke(()=>{if(c||j!==p){ue();return}let fe=q(ut);fe?_e(fe):ue()}))}))},setOptions(j){a={...a,...j},l=s(a),me.render()},setData(j){i=j,me.render()},get options(){return l},setAnnotations(j){if(g.set(j),!c)try{y()}catch{}},get annotationReport(){return g.report},get rendered(){return f},selection:{onChange(j){return C.add(j),()=>C.delete(j)},clear(){let j=r[U5];if(typeof j=="function")try{j()}catch{}T([],"host")},highlight(j){T(Array.isArray(j)?j.slice():[],"host")},get current(){return w}},animation:{stop:J},initialMark(){return r[MV]??null},destroy(){c||(c=!0,J(),r.removeEventListener(AC,W),r.removeEventListener("click",F),C.clear(),g.destroy(),Cp(r),r.innerHTML="")}};return me}var Rie=Object.freeze({sourceId:null,rows:Object.freeze([])});function H5(r,e){return r?e.map(t=>r[t]).filter(t=>t!==void 0):e.slice()}function _ie(r,e){let t=new Map;return r.forEach((o,n)=>{t.has(o)||t.set(o,n)}),e.map(o=>t.get(o)).filter(o=>o!==void 0)}var Uie=(r,e)=>{if(r.length!==e.length)return!1;let t=r.slice().sort((n,i)=>n-i),o=e.slice().sort((n,i)=>n-i);return t.every((n,i)=>n===o[i])};function cz(r,e,t,o,n,i){if(e.sourceId===t&&e.rows.length>0){if(i){let s=_ie(i,e.rows);Uie(s,r.selection.current??[])||r.selection.highlight(s)}return}if(o&&n&&n.length){r.selection.highlight(n.slice());return}r.selection.current&&r.selection.current.length&&r.selection.clear()}function yk(r,e,t={}){let o=r,n=e,i=t.geo??null,a=t.point??null,s=t.destination??null,l=Rie,u=new Set,c=new Set,h=f=>{for(let b of Array.from(u))b(l,f)},m=(f,b)=>{let w=l,P=w.rows.length&&w.sourceId&&w.sourceId!==f?w.rows.slice():null;return b?w.sourceId===b?P:null:P},p=f=>{let b=f?f.slice():n.map((A,M)=>M),w=b.map(A=>n[A]);return{payload:pH(o,w,i??void 0,a??void 0,s??void 0),rowMap:b}},g=(f,b={})=>p(b.respondsWith==="highlight"?null:m(f,b.filteredBy)),y={get selection(){return l},get columns(){return o},get rows(){return n},incomingFor:m,payloadFor:p,memberPayload:g,publish(f,b){l=b.length?{sourceId:f,rows:b.slice()}:{sourceId:null,rows:[]},h(b.length?"select":"clear")},clear(){l={sourceId:null,rows:[]},h("clear")},setSource(f,b,w={}){o=f,n=b,i=w.geo??null,a=w.point??null,s=w.destination??null,h("source")},onChange(f){return u.add(f),()=>{u.delete(f)}},attach(f,b,w={}){let P=w.respondsWith==="highlight",A=g(f,w).rowMap,M=L=>P||!L?"*":L.join(","),C=M(m(f,w.filteredBy)),D=b.selection.onChange((L,N)=>{if(N==="host")return;let W=H5(A,L);f&&y.publish(f,W),w.onSelect?.(W)}),O=y.onChange((L,N)=>{let W=m(f,w.filteredBy),B=M(W);if(N==="source"||B!==C){let R=p(P?null:W);A=R.rowMap,C=B,b.setData(R.payload)}cz(b,L,f,P,W,A)}),T={get rowMap(){return A},detach(){D(),O(),c.delete(T)}};return c.add(T),T},destroy(){for(let f of Array.from(c))f.detach();u.clear()}};return y}/*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */var Bie=10,Die=1e5,Oie=1e4,bo=r=>Object.freeze({...r,...r.values?{values:Object.freeze([...r.values])}:{}}),fk=Object.freeze({aggregation:bo({timing:"live-and-next-generate",default:"",values:["","sum","average","median","min","max","count","distinct"],wire:"request"}),colorScaleLow:bo({timing:"live-and-next-generate",default:"",wire:"request"}),colorScaleHigh:bo({timing:"live-and-next-generate",default:"",wire:"request"}),palette:bo({timing:"live-and-next-generate",default:"",wire:"request"}),maxMapPoints:bo({timing:"live-and-next-generate",default:qC,min:Bie,max:Die,wire:"clientHints"}),pageSize:bo({timing:"live",default:0,min:0}),valueAxisBaseline:bo({timing:"live",default:KC,values:["fit","zero","auto"]}),seasonalMarkers:bo({timing:"live",default:YC,values:["auto","always","never"]}),animAutoPlay:bo({timing:"live",default:!1}),animPlaySpeedMs:bo({timing:"live",default:BC,min:DC,max:OC}),animLoopDelaySec:bo({timing:"live",default:FC,min:GC}),animStopAtEnd:bo({timing:"live",default:!1}),animMaxIdealFrames:bo({timing:"live",default:VC,min:HC,max:zC}),animTimelineStyle:bo({timing:"live",default:"",values:["","line","boxes"]}),filtersDuringPlay:bo({timing:"live",default:!1}),flipMode:bo({timing:"live",default:jC,values:["both","all","single"]}),flipIntervalMs:bo({timing:"live",default:"",min:0,max:BV}),flipDirection:bo({timing:"live",default:XC,values:["horizontal","vertical"]}),levelOfDetail:bo({timing:"next-generate",default:"",values:["","High","Medium","Low"],wire:"clientHints"}),favorLimitTo:bo({timing:"next-generate",default:"",values:["","latest","top / greatest","bottom / smallest","most common","outliers"],wire:"clientHints"}),favorLimitCount:bo({timing:"next-generate",default:0,min:0,max:Oie,wire:"clientHints"}),favorTitle:bo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),favorDPValues:bo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),legendPlacement:bo({timing:"next-generate",default:"",values:["","outside","inside","none"],wire:"clientHints"}),industryContext:bo({timing:"next-generate",default:"",wire:"clientHints"}),suggestFontFamily:bo({timing:"next-generate",default:"",wire:"clientHints"}),visionReview:bo({timing:"after-render",default:!1}),saveThumbnails:bo({timing:"after-render",default:!1})}),Dft=Object.freeze(Object.keys(fk).filter(r=>fk[r].timing==="live"||fk[r].timing==="live-and-next-generate"));function ns(r,e,t,o){var n,i=arguments.length,a=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(n=r[s])&&(a=(i<3?n(a):i>3?n(e,t,a):n(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a}function Ul(r,e,t){if(t||arguments.length===2)for(var o,n=0,i=e.length;n<i;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}var mz=function(r,e,t){return[r,e,t].map((function(o){return(o/=255)>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92}))},pz=function(r,e,t){return[r,e,t].map((function(o){return 255*(o<=.00304?12.92*o:1.055*Math.pow(o,1/2.4)-.055)}))},an=function(r,e,t){return Math.min(Math.max(r,e),t)},dz=function(r,e){return Math.round((r+Number.EPSILON)*Math.pow(10,e))/Math.pow(10,e)},z5=function(r,e){return Math.floor(Math.random()*(e-r+1)-r)},yz=function(r,e,t,o){for(var n,i=[r,e,t],a="#",s=0;s<i.length;s++)a+=(n=i[s],Math.round(an(n,0,255)).toString(16).padStart(2,"0"));return o!=null&&(a+=Math.round(an(o,0,100)/100*255).toString(16).padStart(2,"0")),a},fz=function(r){var e=r.length,t=(r=(function(i){var a=(i=/^#/.test(i)?i.slice(1):i).length;if(![3,4,6,8].includes(a))return"000000";if(a===6||a===8)return i;if(a===3||a===4){for(var s="",l=0;l<a;l++){var u=i[l];s+=""+u+u}return s}return"000000"})(r).padEnd(8,"ff")).match(/.{2}/g);if(!t)return[0,0,0,1];var o=[0,0,0],n=!1;return t.forEach((function(i,a){a<3?o[a]=parseInt(i,16):n=100*parseInt(i,16)/255})),n===!1||e<8?o:Ul(Ul([],o,!0),[n],!1)},gz=function(r,e,t){var o;o=[r,e,t].map((function(a){return a/255})),r=o[0],e=o[1],t=o[2];var n=1-Math.max(r,e,t),i=n<1?1/(1-n):0;return[(1-r-n)*i*100,(1-e-n)*i*100,(1-t-n)*i*100,100*n]},bz=function(r,e,t,o){return o===100?[0,0,0]:(o/=100,[r,e,t].map((function(n){return(n/=100)>=1?0:255*(1-n)*(1-o)})))};function Pk(r,e,t,o){var n;o===void 0&&(o="l"),n=[r,e,t].map((function(p){return p/255})),r=n[0],e=n[1],t=n[2];var i=Math.max(r,e,t),a=Math.min(r,e,t),s=(function(p,g,y,f){var b;f===void 0&&(f=!1),b=[p,g,y].map((function(C){return C/255})),p=b[0],g=b[1],y=b[2];var w=Math.max(p,g,y),P=Math.min(p,g,y),A=0;if(w!==P)if(f)A=(p-g+(p-y))/2,A/=Math.sqrt((p-g)*(p-g)+(p-y)*(g-y)),A=Math.acos(A),y>g&&(A=2*Math.PI-A),A/=2*Math.PI;else{var M=w-P;A=w===p?(g-y)/M+(g<y?6:0):w===g?(y-p)/M+2:(p-g)/M+4,A/=6}else A=NaN;return 360*A})(r,e,t,o==="i"),l=0,u=(i+a)/2,c=i-a,h=i,m=(r+e+t)/3;return o==="v"&&(l=i===0?0:c/i),i!==a&&o==="l"&&(l=u>.5?c/(2-i-a):c/(i+a)),o==="i"&&(l=m>0?1-a/m:0),l*=100,u*=100,m*=100,o==="l"?[s,l,u]:o==="v"?[s,l,h*=100]:[s,l,m]}var Nk=function(r,e,t){return Pk(r,e,t,"l")},Wp=function(r,e,t){var o,n,i=function(a){return 6*(a=a<0?a+1:a>1?a-1:a)<1?o+(n-o)*a*6:2*a<1?n:3*a<2?o+(n-o)*(.6666666666666666-a)*6:o};return r=r%360/360,e=an(e/100,0,1),t=an(t/100,0,1),o=2*t-(n=t<=.5?t*(e+1):t+e-t*e),[255*i(r+1/3),255*i(r),255*i(r-1/3)]},Sz=function(r,e,t){return Pk(r,e,t,"v")},vk=function(r,e,t){var o,n,i=[t/=100,t*(1-(e/=100)),t*(1-(n=(r=r%360/360*360)/60-(o=Math.floor(r/60%6)))*e),t*(1-(1-n)*e)],a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return[255*i[a[o][0]],255*i[a[o][1]],255*i[a[o][2]]]},Az=function(r,e,t){return Pk(r,e,t,"i")},xk=function(r,e,t){var o,n,i,a;e/=100,t/=100,isNaN(r)&&(r=0),isNaN(e)&&(e=0);var s=function(l){return(1+e*Math.cos(2*Math.PI*l)/Math.cos(Math.PI/3-2*Math.PI*l))/3};return(r=(360+r)%360/360)<1/3?i=1-((a=(1-e)/3)+(n=s(r))):r<2/3?a=1-((n=(1-e)/3)+(i=s(r-=1/3))):n=1-((i=(1-e)/3)+(a=s(r-=2/3))),o=[n,i,a].map((function(l){return 255*an(t*l*3,0,1)})),[n=o[0],i=o[1],a=o[2]]},wz=function(r,e,t){return[Nk(r,e,t)[0],100*(Math.min(r,e,t)/255),100*(1-Math.max(r,e,t)/255)]};function Ek(r,e,t){return e/=100,t/=100,Wp(r,100,50).map((function(o){return 255*(o/255*(1-e-t)+e)}))}var gk={x:[.4124564,.3575761,.1804375],y:[.2126729,.7151522,.072175],z:[.0193339,.119192,.9503041]},bk={r:[3.2404542,-1.5371385,-.4985314],g:[-.969266,1.8760108,.041556],b:[.0556434,-.2040259,1.0572252]},Pz=.95047,Nz=1,vz=1.08883,Fie=.206896552,Gie=.008856452,xz=24389/27,Sk=function(r,e,t){var o=mz(r,e,t);return[100*gk.x.reduce((function(n,i,a){return n+i*o[a]}),0),100*gk.y.reduce((function(n,i,a){return n+i*o[a]}),0),100*gk.z.reduce((function(n,i,a){return n+i*o[a]}),0)]},Yw=function(r,e,t){var o=[r,e,t],n=bk.r.reduce((function(s,l,u){return s+l*o[u]}),0)/100,i=bk.g.reduce((function(s,l,u){return s+l*o[u]}),0)/100,a=bk.b.reduce((function(s,l,u){return s+l*o[u]}),0)/100;return pz(n,i,a)},j5=function(r,e,t){var o;return o=[r=r/Pz/100,e=e/Nz/100,t=t/vz/100].map((function(n){return n>Gie?Math.pow(n,1/3):(xz*n+16)/116})),r=o[0],e=o[1],t=o[2],[Math.max(0,116*e-16),500*(r-e),200*(e-t)]},Ck=function(r,e,t){var o,n=(r+16)/116,i=isNaN(e)?n:n+e/500,a=isNaN(t)?n:n-t/200;return o=[i,n,a].map((function(s){return s>Fie?Math.pow(s,3):(116*s-16)/xz})),i=o[0],n=o[1],a=o[2],[i*Pz*100,n*Nz*100,a*vz*100]},kk=function(r,e,t){return Yw.apply(void 0,Ck(r,e,t))},Ak=function(r,e,t){e=an(e,-100,100),t=an(t,-100,100);var o=Math.sqrt(e*e+t*t),n=(180*Math.atan2(t,e)/Math.PI+360)%360;return Math.round(1e4*o)===0&&(n=Number.NaN),[r,o,n]},Ez=function(r,e,t){return isNaN(t)&&(t=0),t*=Math.PI/180,[r,Math.cos(t)*e,Math.sin(t)*e]},Mk=function(r,e,t){return Ck.apply(void 0,Ez(r,e,t))},Cz=function(r,e,t){var o=r+e+t,n=0,i=0;return o>0&&(n=r/o,i=e/o),[n,i,e]},Vie=Object.freeze({__proto__:null,linear2rgb:pz,rgb2linear:mz,rgb2hex:yz,hex2rgb:fz,rgb2cmyk:gz,cmyk2rgb:bz,rgb2hsl:Nk,hsl2rgb:Wp,rgb2hsv:Sz,hsv2rgb:vk,rgb2hsi:Az,hsi2rgb:xk,rgb2hwb:wz,hwb2rgb:Ek,rgb2xyz:Sk,xyz2rgb:Yw,xyz2lab:j5,lab2xyz:Ck,rgb2lab:function(r,e,t){return j5.apply(void 0,Sk(r,e,t))},lab2rgb:kk,lch2lab:Ez,lab2lch:Ak,xyz2lch:function(r,e,t){return Ak.apply(void 0,j5(r,e,t))},lch2xyz:Mk,xyY2xyz:function(r,e,t){return e===0?[0,0,0]:[r*(t/e),t,t/e*(1-r-e)]},xyz2xyY:Cz});function _l(r,e){return e===void 0&&(e=!1),function(t,o,n){var i=n.value;n.value=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];if(a.length>0&&e){var l=JSON.stringify(a);r+=l}if(this.cache.has(r))return this.cache.get(r);var u=i.call.apply(i,Ul([this],a,!1));return this.cache.set(r,u),u}}}function js(r,e,t,o){return r===void 0&&(r=[0,2,2]),e===void 0&&(e=0),t===void 0&&(t=!0),o===void 0&&(o=0),function(n,i,a){var s=a.value;a.value=function(){for(var l=[],u=0;u<arguments.length;u++)l[u]=arguments[u];var c=l[o]===void 0?t:l[o],h=s.call.apply(s,Ul([this],l,!1));if(c===!1)return h;var m=typeof c=="number"?Math.round(c):0,p=typeof r=="number"?new Array(h.length).fill(r):r,g=p.map((function(y){return e===1?typeof c=="number"?m:y:y+m}));return h.map((function(y,f){return dz(y,g[f])}))}}}var kz=function(r,e,t){var o=r instanceof fn?r:new fn(r),n=e instanceof fn?e:new fn(e),i=an(t,0,100)/100,a=2*i-1,s=o.alpha()-n.alpha(),l=((a*s==-1?a:(a+s)/(1+a*s))+1)/2,u=1-l,c=[Math.round(an(o.red()*l+n.red()*u,0,255)),Math.round(an(o.green()*l+n.green()*u,0,255)),Math.round(an(o.blue()*l+n.blue()*u,0,255))],h=o.alpha()*i+n.alpha()*(1-i);return new fn(c,h)},La=Math.sqrt,Gr=Math.pow,dS=Math.cos,Kw=Math.abs,hz=Math.sin,Hie=Math.exp,zie=Math.atan2,Mz=Math.PI,Tp=function(r){return Mz*r/180},wk=function(r,e,t){t===void 0&&(t=!0);var o=zie(e,r);return t&&(o=(o=(o=180*o/Mz)>0?o:o+360)>360?o-360:o),o},yS=function(r,e){e===void 0&&(e=!0);var t=r.lab(!1),o=t[0],n=t[1],i=t[2];return[o,La(Gr(n,2)+Gr(i,2)),wk(n,i,e),n,i]},jie=["CMC","CIE","CIE2000","CIE1994","CIE1976"],Xie="CMC",Kie="CIE2000",Yie="CIE1994",qie="CIE1976",Tz=function(r,e,t,o){t===void 0&&(t="CIE");var n=(function(c){var h=c.toUpperCase();return jie.includes(h)&&h!=="CIE"?h:Kie})(t);if(o=o||{},n===Xie){var i=Object.assign({},{l:1,c:1},o);return(function(c,h,m,p){m===void 0&&(m=1),p===void 0&&(p=1);var g=yS(c,!0),y=g[0],f=g[1],b=g[2],w=g[3],P=g[4],A=yS(h),M=A[0],C=A[1],D=A[3],O=f-C,T=y-M,L=P-A[4],N=La(Gr(w-D,2)+Gr(L,2)-Gr(O,2)),W=y<16?.511:.040975*y/(1+.01765*y),B=.0638*f/(1+.0131*f)+.638,R=164<=b&&b<=345?.56+Kw(.2*dS(Tp(b+168))):.36+Kw(.4*dS(Tp(b+35))),F=La(Gr(f,4)/(Gr(f,4)+1900)),V=B*(F*R+1-F);return La(Gr(T/(m*W),2)+Gr(O/(p*B),2)+Gr(N/V,2))})(r,e,i.l,i.c)}if(n===Yie){var a={kL:1,kC:1,kH:1,cate:"graphic"},s=Object.assign({},a,o);return(function(c,h,m,p,g,y){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1),y===void 0&&(y="graphic");var f=y==="textiles"?.048:.045,b=y==="textiles"?.014:.015;m=y==="textiles"?2:m;var w=yS(c),P=w[0],A=w[1],M=w[3],C=w[4],D=yS(h),O=D[0],T=D[1],L=D[3],N=P-O,W=A-T,B=C-D[4],R=1+f*A,F=1+b*A,V=La(Gr(M-L,2)+Gr(B,2)-Gr(W,2));return La(Gr(N/(1*m),2)+Gr(W/(p*R),2)+Gr(V/(g*F),2))})(r,e,s.kL,s.kC,s.kH,s.cate)}if(n===qie)return(function(c,h){var m=c.lab(!1),p=m[0],g=m[1],y=m[2],f=h.lab(!1),b=f[0],w=f[1],P=f[2];return La(Gr(p-b,2)+Gr(g-w,2)+Gr(y-P,2))})(r,e);var l={kL:1,kC:1,kH:1},u=Object.assign({},l,o);return(function(c,h,m,p,g){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1);var y=yS(c),f=y[0],b=y[1],w=y[3],P=y[4],A=yS(h),M=A[0],C=A[1],D=A[3],O=A[4],T=(f+M)/2,L=(b+C)/2,N=(1-La(Gr(L,7)/(Gr(L,7)+Gr(25,7))))/2,W=w*(1+N),B=D*(1+N),R=La(Gr(W,2)+Gr(P,2)),F=La(Gr(B,2)+Gr(O,2)),V=wk(W,P,!0),K=wk(B,O,!0),J=(R+F)/2,z=Kw(V-K)>180?(V+K+360)/2:(V+K)/2,q=1-.17*dS(Tp(z-30))+.24*dS(Tp(2*z))+.32*dS(Tp(3*z+6))-.2*dS(Tp(4*z-63)),me=Kw(K-V)<=180?K-V:Kw(K-V)>180&&K<=V?K-V+360:K-V-360,j=M-f,ne=C-b,ue=2*La(R*F)*hz(Tp(me)/2),_e=1+.015*Gr(T-50,2)/La(20+Gr(T-50,2)),Be=1+.045*J,Ke=1+.015*J*q,ut=30*Hie(-Gr((z-275)/25,2)),fe=-2*La(Gr(J,7)/(Gr(J,7)+Gr(25,7)))*hz(2*Tp(ut));return La(Gr(j/(m*_e),2)+Gr(ne/(p*Be),2)+Gr(ue/(g*Ke),2)+fe*(ne/(p*Be))*(ue/(g*Ke)))})(r,e,u.kL,u.kC,u.kH)},Jie=function(r,e,t){var o=Math.abs,n=Math.max,i=Math.min,a=r instanceof fn?r:new fn(r),s=e instanceof fn?e:new fn(e),l=Object.assign({},{b:125,c:500},t);return!(o(255*a.brightness()/100-255*s.brightness()/100)<=l.b)&&!(n(a.red(),s.red())-i(a.red(),s.red())+(n(a.green(),s.green())-i(a.green(),s.green()))+(n(a.blue(),s.blue())-i(a.blue(),s.blue()))<=l.c)},fS=function(r,e,t){var o,n=function(u){return an(u,0,100)},i=function(u){return an(u,0,255)},a={h:[0,function(u){return u%360}],s:[1,n],l:[2,n],r:[0,i],g:[1,i],b:[2,i]},s=a[e][0];if(["h","s","l"].includes(e)){var l=r.hsl();if(t===void 0)return l[s];t=a[e][1](t),l[s]=t,o=Wp.apply(void 0,l)}else{if(o=r.rgb(),t===void 0)return o[s];t=a[e][1](t),o[s]=t}return new fn(o,r.alpha())},K5={},$ie=new Set(["rgb","rgba","cmyk","lab","hsl","hsla","hsv","hsva","hsi","hsia","xyz","lch","hwb","hwba"]),Qie=/^([a-zA-Z]+)\(([\s\S]+)\)$/,X5=function(r){return typeof r=="string"?r.indexOf("%")===-1?X5(Number(r.trim())):(r=r.split("%")[0],(r=Number(r.trim()))||0):Math.abs(r)<1?100*r:r},Wz=function(r,e){e===void 0&&(e=new Set);var t=typeof r=="string"?r:r.join(",");if(e.has(t))throw new Error("Invalid Color");e.add(t);var o="rgb",n=[0,0,0],i=100;if(Array.isArray(r)){if(r.length<3)throw new Error("Invalid Color");for(var a=0;a<r.length;a++)if(a<3)n[a]=r[a];else{if(a!==3||r[3]===void 0)break;i=r[3]}}else{var s=!1,l=r.trim().match(Qie);if(l||(s=!0),l){var u=l[1].toLocaleLowerCase();if(o=u,$ie.has(u)||(s=!0),l[2]&&!s){var c=l[2],h=c.indexOf(",")!==-1?",":" ",m=c.split(h);for(a=0;a<3;a++)m[a]!==void 0&&(["lch","lab"].includes(o)&&a===0||["hsl","hsla","hsv","hsva","hwb","hwba","hsi","hsia"].includes(o)&&a>0?n[a]=X5(m[a]):n[a]=Number(m[a].trim()));["rgba","hsla","hsva","hwba","hsia"].includes(o)?(o=o.slice(0,-1),m[3]!==void 0&&(i=X5(m[3]))):o==="cmyk"&&n.push(m[3]!==void 0?X5(m[3]):0)}}if(s){if(!/^#(([a-fA-F\d]{3}){1,2}|[a-fA-F\d]{8})$/.test(r))try{return r=(function(p,g){if(g===void 0&&(g=!1),p=p.toLowerCase(),K5[p]===void 0){if(g)throw new Error("Unknown color name: ".concat(p,")"));return p}return K5[p]})(r,!0),Wz(r,e)}catch{throw new Error("Invalid Color")}n=fz(r)}}return[o,n,i]},Lz={thowParseError:!1},fn=(function(){function r(e,t,o){this.cache=new Map,this._rgb=[0,0,0],this._alpha=100;var n={thowParseError:Lz.thowParseError},i=Object.assign({},n,o??{});try{var a=(function(u){var c,h={lab2rgb:kk,hsl2rgb:Wp,hsv2rgb:vk,xyz2rgb:Yw,hwb2rgb:Ek,hsi2rgb:xk},m=Wz(u),p=m[0],g=m[1],y=m[2];if(p==="rgb")return[g,y];p==="lch"&&(p=(c=["xyz",Mk(g[0],g[1],g[2])])[0],g=c[1]);var f=g[0],b=g[1],w=g[2],P=g[3];if(p==="cmyk")return[bz(f,b,w,P).map((function(M){return an(M,0,255)})),y];var A="".concat(p,"2rgb");if(typeof h[A]=="function")return[h[A](f,b,w).map((function(M){return an(M,0,255)})),y];throw new Error("Invalid color")})(e),s=a[0],l=a[1];this._alpha=l,this._rgb=s}catch(u){if(i.thowParseError)throw u}t!==void 0&&(this._alpha=an(t,0,100))}return r.prototype.red=function(e){return fS(this,"r",e)},r.prototype.green=function(e){return fS(this,"g",e)},r.prototype.blue=function(e){return fS(this,"b",e)},r.prototype.alpha=function(e){return e===void 0?this._alpha:(e=an(e,0,100),new r(this.rgb(),e))},r.prototype.fadeIn=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),an(this._alpha+e,0,100))},r.prototype.fadeOut=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),an(this._alpha-e,0,100))},r.prototype.opacify=function(e,t){return e===void 0&&(e=10),this.fadeIn(e,t)},r.prototype.transparentize=function(e,t){return e===void 0&&(e=10),this.fadeOut(e,t)},r.prototype.hue=function(e){return fS(this,"h",e)},r.prototype.saturation=function(e){return fS(this,"s",e)},r.prototype.lightness=function(e){return fS(this,"l",e)},r.prototype.rgb=function(e){return Ul([],this._rgb,!0)},r.prototype.rgba=function(e){return Ul(Ul([],this.rgb(!1),!0),[this._alpha],!1)},r.prototype.cmyk=function(e){return gz.apply(void 0,this._rgb)},r.prototype.hsl=function(e){return Nk.apply(void 0,this._rgb)},r.prototype.hsla=function(e){return Ul(Ul([],this.hsl(!1),!0),[this._alpha],!1)},r.prototype.hsv=function(e){return Sz.apply(void 0,this._rgb)},r.prototype.hsi=function(e){return Az.apply(void 0,this._rgb)},r.prototype.hwb=function(e){return wz.apply(void 0,this._rgb)},r.prototype.xyz=function(e){return Sk.apply(void 0,this._rgb)},r.prototype.lab=function(e){return j5.apply(void 0,this.xyz(!1))},r.prototype.lch=function(e){return Ak.apply(void 0,this.lab(!1))},r.prototype.xyY=function(e){return Cz.apply(void 0,this.xyz(!1))},r.prototype.hex=function(e){e===void 0&&(e=2);var t=e===0?void 0:e===1?this._alpha:this._alpha===100?void 0:this._alpha,o="color:hex:param_".concat(e);if(this.cache.has(o))return this.cache.get(o);var n=yz.apply(void 0,Ul(Ul([],this._rgb,!1),[t],!1));return this.cache.set(o,n),n},r.prototype.lighten=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return a=an(a+=t!==void 0&&t==="relative"?a*(e/100):e,0,100),new r(Wp(n,i,a),this._alpha)},r.prototype.darken=function(e,t){return e===void 0&&(e=5),this.lighten(-e,t)},r.prototype.saturate=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return i=an(i+=t!==void 0&&t==="relative"?i*(e/100):e,0,100),new r(Wp(n,i,a),this._alpha)},r.prototype.desaturate=function(e,t){return e===void 0&&(e=5),this.saturate(-e,t)},r.prototype.spin=function(e){var t=this.hsl(!1),o=t[0],n=t[1],i=t[2];return new r(Wp(o=(o+e%360+360)%360,n,i),this._alpha)},r.prototype.adjustHue=function(e){return this.spin(e)},r.prototype.complement=function(){return this.spin(180)},r.prototype.invert=function(){var e=this._rgb.map((function(t){return 255-t}));return new r([e[0],e[1],e[2]],this._alpha)},r.prototype.mix=function(e,t){return t===void 0&&(t=50),kz(this,e,100-an(t,0,100))},r.prototype.luma=function(){var e=this._rgb.map((function(t){return(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return .2126*e[0]+.7152*e[1]+.0722*e[2]},r.prototype.brightness=function(){var e=this._rgb;return(function(t,o,n){return(299*t+587*o+114*n)/1e3/255*100})(e[0],e[1],e[2])},r.prototype.deltaE=function(e,t,o){return t===void 0&&(t="CMC"),Tz(this,e,t,o)},r.prototype.visibility=function(e,t){return Jie(this,e,t)},ns([js(0,1,!0,0),_l("color:rgb")],r.prototype,"rgb",null),ns([js(0,1,!0,0)],r.prototype,"rgba",null),ns([js(0,1,!0,0),_l("color:cmyk")],r.prototype,"cmyk",null),ns([js(0,1,!0,0),_l("color:hsl")],r.prototype,"hsl",null),ns([js(0,1,!0,0)],r.prototype,"hsla",null),ns([js(0,1,!0,0),_l("color:hsv")],r.prototype,"hsv",null),ns([js(0,1,!0,0),_l("color:hsi")],r.prototype,"hsi",null),ns([js(0,1,!0,0),_l("color: hwb")],r.prototype,"hwb",null),ns([js(2,1,!0,0),_l("color:xyz")],r.prototype,"xyz",null),ns([js(2,1,!0,0),_l("color:lab")],r.prototype,"lab",null),ns([js(2,1,!0,0),_l("color:lch")],r.prototype,"lch",null),ns([js(2,1,!0,0),_l("color:xyY")],r.prototype,"xyY",null),ns([_l("color:luma")],r.prototype,"luma",null),r})(),Zie=function(r,e,t,o){return new fn([r,e,t],o)},eae=function(r,e,t,o){return new fn(Wp(r,e,t),o)},tae=function(r,e,t,o){return new fn(vk(r,e,t),o)},rae=function(r,e,t,o){return new fn(xk(r,e,t),o)},oae=function(r,e,t,o){return new fn(Ek(r,e,t),o)},nae=function(r,e,t,o){return new fn(Yw(r,e,t),o)},iae=function(r,e,t,o){return new fn(kk(r,e,t),o)},aae=function(r,e,t,o){return new fn(Yw.apply(void 0,Mk(r,e,t)),o)};function bi(r,e,t){return new fn(r,e,t)}bi.config=function(r){Object.assign(Lz,r)},bi.random=function(){var r=z5(0,255),e=z5(0,255),t=z5(0,255);return new fn([r,e,t])},bi.convertor=Vie,bi.Color=fn,bi.rgb=Zie,bi.hsl=eae,bi.hsv=tae,bi.hsi=rae,bi.hwb=oae,bi.xyz=nae,bi.lab=iae,bi.lch=aae,bi.mix=kz,bi.deltaE=Tz,bi.utils={roundDecimal:dz,randomRange:z5},bi.useNames=function(r,e){return(function(t,o){if(o!==void 0&&typeof o=="function"){var n={};for(var i in t){var a=o(i,t[i]),s=a[0],l=a[1];n[s]=l}Object.assign(K5,n)}else Object.assign(K5,t)})(r,e),bi};var J5=[1,0,0,1,0,0],$5=(r,e)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]],Y5=(r,e,t)=>[r[0]*e+r[2]*t+r[4],r[1]*e+r[3]*t+r[5]];function sae(r){if(!r||!r.trim())return J5;let e=J5,t=/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g,o="";for(let n of r.matchAll(t)){o+=n[0];let i=n[2].split(/[\s,]+/).filter(Boolean).map(Number);if(i.some(s=>!isFinite(s)))return null;let a;switch(n[1]){case"matrix":if(i.length!==6)return null;a=i;break;case"translate":a=[1,0,0,1,i[0]??0,i[1]??0];break;case"scale":a=[i[0]??1,0,0,i[1]??i[0]??1,0,0];break;case"rotate":{let s=(i[0]??0)*Math.PI/180,l=Math.cos(s),u=Math.sin(s),c=[l,u,-u,l,0,0];a=i.length>=3?$5($5([1,0,0,1,i[1],i[2]],c),[1,0,0,1,-i[1],-i[2]]):c;break}case"skewX":a=[1,0,Math.tan((i[0]??0)*Math.PI/180),1,0,0];break;default:a=[1,Math.tan((i[0]??0)*Math.PI/180),0,1,0,0];break}e=$5(e,a)}return r.replace(t,"").replace(/[\s,]/g,"")!==""?null:o?e:J5}var Ch=r=>String(r??"").toLowerCase(),Q5=(r,e)=>{let t=Ch(r.getAttribute("style")).replace(/\s+/g,"");for(let o of t.split(";")){let n=o.indexOf(":");if(n>0&&o.slice(0,n)===e)return o.slice(n+1)}return null},qw=(r,e)=>Q5(r,e)??(r.getAttribute(e)!==null?Ch(r.getAttribute(e)):null);function lae(r){for(let e=r.parentElement;e;e=e.parentElement)if(Ch(e.localName)==="svg")return e;return null}var _z=new Set(["defs","clippath","mask","pattern","marker","symbol","lineargradient","radialgradient","filter","title","desc","metadata","style","script"]);function Iz(r){let e=String(r??"").trim();return/^\+?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i.test(e)?parseFloat(e):NaN}function uae(r){if(qw(r,"overflow")==="visible")return null;let e=Iz(Q5(r,"width")??r.getAttribute("width")),t=Iz(Q5(r,"height")??r.getAttribute("height")),o=r.getAttribute("viewBox");if(o){let n=o.split(/[\s,]+/).filter(Boolean).map(Number);return n.length!==4||!n.every(isFinite)||n[2]<=0||n[3]<=0||!Ch(r.getAttribute("preserveAspectRatio")).includes("none")&&isFinite(e)&&isFinite(t)&&e>0&&t>0&&Math.abs(n[2]/n[3]-e/t)>.01*(e/t)?null:{x0:n[0],y0:n[1],x1:n[0]+n[2],y1:n[1]+n[3]}}return!(e>0)||!(t>0)?null:{x0:0,y0:0,x1:e,y1:t}}function cae(r,e){for(let t=r;t&&t!==e;t=t.parentElement){if(qw(t,"display")==="none")return!0;let o=qw(t,"visibility");if(o==="hidden"||o==="collapse")return!0;let n=qw(t,"opacity");if(n!==null&&n!==""&&parseFloat(n)===0)return!0}return!1}function hae(r,e){for(let t=r;t&&t!==e;t=t.parentElement)if(t.getAttribute("clip-path")||Q5(t,"clip-path")||_z.has(Ch(t.localName)))return!0;return!1}function mae(r,e){let t=J5;for(let o=r;o&&o!==e;o=o.parentElement){let n=sae(o.getAttribute("transform"));if(!n)return null;t=$5(n,t)}return t}var Si=(r,e)=>{let t=parseFloat(r.getAttribute(e)??"");return isFinite(t)?t:0};function Uz(r){let e="";for(let t=r.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue??"":t.nodeType===1&&!_z.has(Ch(t.localName))&&(e+=Uz(t));return e}function q5(r,e,t){for(let o=r;o&&o!==e.parentElement;o=o.parentElement){let n=qw(o,t);if(n!==null&&n!=="")return n}return null}function Tk(r){let e=[],t=r.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=0,n="",i=0,a=0,s=0,l=0,u=()=>parseFloat(t[o++]),c=()=>o<t.length&&!/^[a-zA-Z]$/.test(t[o]);for(;o<t.length;){if(/^[a-zA-Z]$/.test(t[o]))n=t[o++];else if(!n)return[];let h=n===n.toLowerCase(),m=n.toUpperCase();if(m==="Z"){if(i=s,a=l,c())return e;continue}let p={M:2,L:2,T:2,H:1,V:1,C:6,S:4,Q:4,A:7}[m];if(!p)return e;if(!c())continue;let g=[];for(let b=0;b<p;b++)g.push(u());if(g.some(b=>!isFinite(b)))return e;let y=h?i:0,f=h?a:0;if(m==="H")i=y+g[0],e.push([i,a]);else if(m==="V")a=f+g[0],e.push([i,a]);else if(m==="A")i=y+g[5],a=f+g[6],e.push([i,a]);else{for(let b=0;b<p;b+=2)e.push([y+g[b],f+g[b+1]]);i=y+g[p-2],a=f+g[p-1]}m==="M"&&(s=i,l=a,n=h?"l":"L")}return e}function Rz(r){let e=1/0,t=-1/0,o=1/0,n=-1/0;for(let[i,a]of r)e=Math.min(e,i),t=Math.max(t,i),o=Math.min(o,a),n=Math.max(n,a);return{X0:e,X1:t,Y0:o,Y1:n}}var pae=new Set(["rect","image","foreignobject","circle","ellipse","line","text","path","polygon","polyline"]),Xs=.5,dae=5;function Bz(r){let e={frames:0,unmeasured:0,outside:0,crossing:0,textLikely:0,samples:{outside:[],crossing:[],textLikely:[]}},t=(n,i)=>{n.length<dae&&n.push(i)},o=Math.round;for(let n of Array.from(r.querySelectorAll("svg"))){let i=uae(n),a=Array.from(n.querySelectorAll("*")).filter(c=>pae.has(Ch(c.localName))&&lae(c)===n);if(!i){a.length&&e.unmeasured++;continue}e.frames++;let s=(c,h)=>h==="left"||h==="right"?`x ${o(c.X0)}..${o(c.X1)}, frame ${o(i.x0)}..${o(i.x1)}`:`y ${o(c.Y0)}..${o(c.Y1)}, frame ${o(i.y0)}..${o(i.y1)}`,l=c=>c.X0>i.x1+Xs?"right":c.X1<i.x0-Xs?"left":c.Y0>i.y1+Xs?"bottom":c.Y1<i.y0-Xs?"top":"",u=c=>c.X1>i.x1+Xs?"right":c.X0<i.x0-Xs?"left":c.Y1>i.y1+Xs?"bottom":c.Y0<i.y0-Xs?"top":"";for(let c of a){if(cae(c,n)||hae(c,n))continue;let h=mae(c,n);if(!h)continue;let m=Ch(c.localName);if(m==="text"){let b=Uz(c).trim();if(!b)continue;let w=parseFloat(q5(c,n,"font-size")??"")||10,P=Si(c,"x")+Si(c,"dx"),A=Si(c,"y")+(Ch(c.getAttribute("dy")).endsWith("em")?parseFloat(c.getAttribute("dy"))*w:Si(c,"dy")),M=q5(c,n,"dominant-baseline")??q5(c,n,"alignment-baseline")??"";M==="middle"||M==="central"?A+=.35*w:(M==="hanging"||M==="text-before-edge")&&(A+=.8*w);let C=q5(c,n,"text-anchor")??"start",D=b.length*w*.6,O=C==="middle"?P-D/2:C==="end"?P-D:P;if(Math.abs(h[1])>1e-9||Math.abs(h[2])>1e-9)continue;let T=Rz([Y5(h,O,A-.75*w),Y5(h,O+D,A+.2*w)]),L=`text "${b.length>30?b.slice(0,30)+"...":b}"`,N=Y5(h,P,A)[0],W=T.Y0>i.y1+Xs?"bottom":T.Y1<i.y0-Xs?"top":C==="start"&&N>i.x1+Xs?"right":C==="end"&&N<i.x0-Xs?"left":"";if(W){e.outside++,t(e.samples.outside,{what:L,edge:W,where:s(T,W)});continue}let B=u(T);B&&(e.textLikely++,t(e.samples.textLikely,{what:L,edge:B,where:s(T,B)}));continue}let p;if(m==="circle"||m==="ellipse"){let b=m==="circle"?Si(c,"r"):Si(c,"rx"),w=m==="circle"?b:Si(c,"ry");if(!(b>0&&w>0))continue;let P=Si(c,"cx"),A=Si(c,"cy");p=[[P-b,A-w],[P+b,A+w],[P+b,A-w],[P-b,A+w]]}else if(m==="line")p=[[Si(c,"x1"),Si(c,"y1")],[Si(c,"x2"),Si(c,"y2")]];else if(m==="path"||m==="polygon"||m==="polyline"){if(m==="path")p=Tk(c.getAttribute("d")??"");else{let b=(c.getAttribute("points")??"").split(/[\s,]+/).filter(Boolean).map(Number);p=[];for(let w=0;w+1<b.length;w+=2)p.push([b[w],b[w+1]])}if(!p.length||p.some(b=>!isFinite(b[0])||!isFinite(b[1])))continue}else{let b=Si(c,"width"),w=Si(c,"height");if(!(b>0&&w>0))continue;let P=Si(c,"x"),A=Si(c,"y");p=[[P,A],[P+b,A+w],[P+b,A],[P,A+w]]}let g=Rz(p.map(b=>Y5(h,b[0],b[1]))),y=l(g);if(y){e.outside++,t(e.samples.outside,{what:m,edge:y,where:s(g,y)});continue}if(m==="path")continue;let f=u(g);f&&(e.crossing++,t(e.samples.crossing,{what:m,edge:f,where:s(g,f)}))}}return e}var Sae=new Set(["d3-sankey","d3-hexbin","d3-voronoi-treemap"]),Aae=new Set(["title","desc","metadata","style","script"]);function Vz(r){let e="";for(let t=r?.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue||"":t.nodeType===1&&!Aae.has(String(t.localName||"").toLowerCase())&&(e+=Vz(t));return e}function Wk(r){let e=parseFloat(r.getAttribute?.("font-size")||"")||0;if(!e){let t=String(r.getAttribute?.("style")||"").match(/font-size:\s*([\d.]+)/);e=t?parseFloat(t[1]):10}return e}function wae(r){let e=["SVGElement","SVGGraphicsElement","SVGGeometryElement","SVGTextContentElement"].map(u=>r[u]?.prototype).filter(Boolean),t=u=>["text","tspan","textpath"].includes(String(u.tagName||"").toLowerCase()),o=u=>t(u)?Vz(u).trim().length*Wk(u)*.6:0,n=u=>{let c=String(u.tagName||"").toLowerCase();if(c==="path")return Tk(u.getAttribute("d")||"");if(c==="line")return[[+u.getAttribute("x1")||0,+u.getAttribute("y1")||0],[+u.getAttribute("x2")||0,+u.getAttribute("y2")||0]];let h=String(u.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),m=[];for(let p=0;p+1<h.length;p+=2)m.push([h[p],h[p+1]]);return m},i=u=>{let c=0;for(let h=1;h<u.length;h++)c+=Math.hypot(u[h][0]-u[h-1][0],u[h][1]-u[h-1][1]);return c},a=function(){if(t(this)){let m=Wk(this);return{x:0,y:-m*.8,width:Math.max(1,o(this)),height:Math.max(1,m)}}let u=parseFloat(this.getAttribute?.("width")||"")||0,c=parseFloat(this.getAttribute?.("height")||"")||0;if(u>0||c>0)return{x:0,y:0,width:u||1,height:c||1};let h=parseFloat(this.getAttribute?.("r")||"")||0;return h>0?{x:-h,y:-h,width:2*h,height:2*h}:{x:0,y:0,width:1,height:1}},s=(u,c,h)=>Object.defineProperty(u,c,{configurable:!0,writable:!0,value:h});for(let u of e)s(u,"getBBox",a),s(u,"getBoundingClientRect",function(){let c=a.call(this);return{...c,top:c.y,left:c.x,right:c.x+c.width,bottom:c.y+c.height,toJSON(){return c}}}),s(u,"getComputedTextLength",function(){return o(this)}),s(u,"getSubStringLength",function(c,h){return t(this)?Math.max(0,(h||0)*Wk(this)*.6):0}),s(u,"getTotalLength",function(){return i(n(this))}),s(u,"getPointAtLength",function(c){let h=n(this);if(!h.length)return{x:0,y:0};let m=Math.max(0,+c||0);for(let g=1;g<h.length;g++){let y=Math.hypot(h[g][0]-h[g-1][0],h[g][1]-h[g-1][1]);if(m<=y&&y>0){let f=m/y;return{x:h[g-1][0]+f*(h[g][0]-h[g-1][0]),y:h[g-1][1]+f*(h[g][1]-h[g-1][1])}}m-=y}let p=h[h.length-1];return{x:p[0],y:p[1]}});let l=r.HTMLCanvasElement?.prototype;if(l){let u=new WeakMap,c=m=>{let p=String(m||"").match(/([\d.]+)\s*(px|pt|em|rem)\b/i);if(!p)return 10;let g=parseFloat(p[1]);return p[2].toLowerCase()==="pt"?g*4/3:/r?em/i.test(p[2])?g*16:g},h=()=>{};Object.defineProperty(l,"getContext",{configurable:!0,writable:!0,value:function(m){if(String(m||"").toLowerCase()!=="2d")return null;let p=u.get(this);if(!p){let g=this;p=new Proxy({canvas:g,font:"10px sans-serif",measureText(y){let f=c(this.font),b=String(y??"").length*f*.6;return{width:b,actualBoundingBoxLeft:0,actualBoundingBoxRight:b,actualBoundingBoxAscent:f*.8,actualBoundingBoxDescent:f*.2,fontBoundingBoxAscent:f*.8,fontBoundingBoxDescent:f*.2}},getImageData:(y,f,b,w)=>({width:b,height:w,data:new Uint8ClampedArray(Math.max(1,b*w*4))}),createLinearGradient:()=>({addColorStop:h}),createRadialGradient:()=>({addColorStop:h}),getLineDash:()=>[],isPointInPath:()=>!1,isPointInStroke:()=>!1},{get:(y,f)=>f in y?y[f]:typeof f=="string"&&/^[a-z]/.test(f)?h:void 0}),u.set(this,p)}return p}})}}function Pae(r){let e=["window","document","navigator","Event","CustomEvent","MouseEvent","KeyboardEvent","PointerEvent","Element","HTMLElement","SVGElement","Node","getComputedStyle","requestAnimationFrame","cancelAnimationFrame","DOMParser","XMLSerializer","MutationObserver","Image","ResizeObserver"],t=e.map(n=>[n,Object.getOwnPropertyDescriptor(globalThis,n)]),o=n=>n==="window"?r:n==="ResizeObserver"?r.ResizeObserver??class{observe(){}unobserve(){}disconnect(){}}:typeof r[n]=="function"&&/^[a-z]/.test(n)?r[n].bind(r):r[n];for(let n of e){let i=o(n);if(i!==void 0)try{Object.defineProperty(globalThis,n,{configurable:!0,writable:!0,value:i})}catch{}}return()=>{for(let[n,i]of t)try{i?Object.defineProperty(globalThis,n,i):delete globalThis[n]}catch{}}}function Fz(r,e){let t=e.split(/\r?\n/);for(let o of String(r?.stack??"").split(`
|
|
303
|
+
}`,(t.head||t.documentElement)?.appendChild(j)}catch{}},O=()=>{try{let j=w,ne=!!j&&j.length>0,ue=ne&&!A;r.classList?.[ue?"add":"remove"](Uw);let _e=r.querySelectorAll(`.${nS}`);for(let fe of Array.from(_e))fe.classList?.remove(nS);let Be=!!P&&(typeof r.contains=="function"?r.contains(P):P.isConnected!==!1);ne&&Be&&P.classList?.add(nS);let Ke=new Set(j??[]),ut=r.querySelectorAll(`.${ca}[${Vo}], .${Zy}[${Vo}]`);for(let fe of Array.from(ut)){let ge=bC(fe.getAttribute(Vo)),Ye=ne&&ge.some(be=>Ke.has(be));fe.classList?.[Ye?"add":"remove"](Bw)}}catch{}},T=(j,ne,ue,_e=!1)=>{w=j,M=j.length>0&&_e,P=j.length?ue??null:null,A=j.length>0&&IV(!!ue,LV(r)),O();for(let Be of C)try{Be(j,ne)}catch{}},L=0,N=150,W=j=>{let ne=j?.detail||{};L=Date.now(),ne.clear?T([],ne.source||"chart"):ne.mark&&T(bC(ne.mark.getAttribute?.(Vo)),ne.source||"chart",ne.mark,!0)},B=bH({root:r,doc:t,log:()=>{}}),R=`.${ca}[${Vo}], .${Zy}[${Vo}], .${lS}[${Vo}]`,F=j=>{if(Date.now()-L<N||gH(j?.target,r))return;let ne=B.findMark(j?.target,R,j);if(ne||(ne=B.penetrateOverlayAt(j?.clientX,j?.clientY,R)),ne||(ne=B.resolveByGeometry(j?.clientX,j?.clientY,R)),!ne){if(w&&w.length){let fe=r[U5];if(M&&typeof fe=="function")try{fe()}catch{}w&&w.length&&T([],"user")}return}let ue=bC(ne.getAttribute(Vo));if(!ue.length)return;let _e=ne.classList?.contains?.(lS)?ne:null,Be=!!(j?.ctrlKey||j?.metaKey||j?.shiftKey),Ke=fH(w,ue,{ctrl:!!(j?.ctrlKey||j?.metaKey),shift:!!j?.shiftKey}),ut=!Be&&Ke.length===0;T(Ke,"user",ut?null:_e)};r.addEventListener(AC,W),r.addEventListener("click",F),r.classList?.add(os),D();let V=e.fit??!0,K=e.labelContrast??!0,J=()=>{let j=r[UC];if(typeof j=="function")try{j()}catch{}},z=()=>{if(K!==!1)try{let j=K===!0?{}:{...K};if(!j.pageBg){let ue=l.backgroundColor??l.themeBg;typeof ue=="string"&&ue&&(j.pageBg=ue)}let ne=rz(r,j);e.onLabelContrast?.(ne)}catch{}SH(r,t),O();try{let j=F5(r);if(G5({markCount:j.markCount,rows:i.rows?i.rows.length:0,animated:e.animated,contractUntagged:e.contractUntagged,declaresNoRowMarks:j.declaresNoRowMarks})){if(!m){m=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] this chart rendered without error but painted no data marks, against ${i.rows.length} row(s) \u2014 so the container is empty. The usual cause is that the generated code binds a column BY NAME that is no longer in the data, sending it down its own "no data" branch. Check that the columns in your table still match the ones the chart was generated for.`)}catch{}}e.onBlankRender?.({census:j,rows:i.rows?i.rows.length:0})}}catch{}if(e.onHitBandCensus)try{e.onHitBandCensus(AH(r,t))}catch{}if(e.onColourSpreadCensus)try{e.onColourSpreadCensus(VV(r,t))}catch{}if(e.onValuePlacementCensus)try{e.onValuePlacementCensus(PH(r,i))}catch{}if(V!==!1)try{let j=FH(r,V===!0?{}:V);e.onFit?.(j)}catch{}try{y()}catch{}},q=j=>{let ne=String(j?.message??j??"");return e.onInvalidSentinel&&oz(ne)?(J(),r.innerHTML="",e.onInvalidSentinel({reason:nz(ne),message:ne}),null):sz(j,n)},me={render(){if(c)return;let j=++p;if(J(),r.innerHTML="",!u){if(!e.code)throw new Error("createChartHost: provide code or renderFn");u=uz(e.code,o,t,n)}if(l.geo===void 0&&e.geoKind){let ue=e.geoProvider?.(e.geoKind)??JV(e.geoKind);if(ue)l={...l,geo:ue};else if(!h){h=!0;try{(o?.console??console)?.warn(`[@bicharts/chart-host] geoKind "${e.geoKind}" was set but no geometry is available, so this chart will draw without a basemap. Either \`await loadGeo("${e.geoKind}")\` before rendering, pass a geoProvider, or import { geoForKind } from "@bicharts/chart-host/geo" and set options.geo.`)}catch{}}}l.geoUnmatched===void 0&&i.geoUnmatched&&(l={...l,geoUnmatched:i.geoUnmatched}),l.geoPoint===void 0&&i.geoPoint&&(l={...l,geoPoint:i.geoPoint}),l.geoPointDest===void 0&&i.geoPointDest&&(l={...l,geoPointDest:i.geoPointDest}),l.dateCellsAreUtcDays===void 0&&i.dateCellsAreUtcDays&&(l={...l,dateCellsAreUtcDays:!0});let ne;try{ne=u(r,{columns:i.columns,rows:i.rows},l)}catch(ue){let _e=q(ue);if(_e)throw b(Promise.reject(_e)),_e;b(Promise.resolve());return}if(!Iie(ne)){z(),b(Promise.resolve());return}b(new Promise((ue,_e)=>{let Be=setTimeout(()=>{_e(new Error(`[@bicharts/chart-host] the chart did not finish drawing within ${Math.round(xV/1e3)}s, so the host stopped waiting for it. Nothing past that point ran: no label-contrast pass, no hit-target heal, no census, no fit. A render() that returns a promise has to settle it.`))},xV),Ke=ut=>{clearTimeout(Be),ut()};Promise.resolve(ne).then(()=>Ke(()=>{if(c||j!==p){ue();return}z(),ue()}),ut=>Ke(()=>{if(c||j!==p){ue();return}let fe=q(ut);fe?_e(fe):ue()}))}))},setOptions(j){a={...a,...j},l=s(a),me.render()},setData(j){i=j,me.render()},get options(){return l},setAnnotations(j){if(g.set(j),!c)try{y()}catch{}},get annotationReport(){return g.report},get rendered(){return f},selection:{onChange(j){return C.add(j),()=>C.delete(j)},clear(){let j=r[U5];if(typeof j=="function")try{j()}catch{}T([],"host")},highlight(j){T(Array.isArray(j)?j.slice():[],"host")},get current(){return w}},animation:{stop:J},initialMark(){return r[MV]??null},destroy(){c||(c=!0,J(),r.removeEventListener(AC,W),r.removeEventListener("click",F),C.clear(),g.destroy(),Cp(r),r.innerHTML="")}};return me}var Rie=Object.freeze({sourceId:null,rows:Object.freeze([])});function H5(r,e){return r?e.map(t=>r[t]).filter(t=>t!==void 0):e.slice()}function _ie(r,e){let t=new Map;return r.forEach((o,n)=>{t.has(o)||t.set(o,n)}),e.map(o=>t.get(o)).filter(o=>o!==void 0)}var Uie=(r,e)=>{if(r.length!==e.length)return!1;let t=r.slice().sort((n,i)=>n-i),o=e.slice().sort((n,i)=>n-i);return t.every((n,i)=>n===o[i])};function cz(r,e,t,o,n,i){if(e.sourceId===t&&e.rows.length>0){if(i){let s=_ie(i,e.rows);Uie(s,r.selection.current??[])||r.selection.highlight(s)}return}if(o&&n&&n.length){r.selection.highlight(n.slice());return}r.selection.current&&r.selection.current.length&&r.selection.clear()}function yk(r,e,t={}){let o=r,n=e,i=t.geo??null,a=t.point??null,s=t.destination??null,l=Rie,u=new Set,c=new Set,h=f=>{for(let b of Array.from(u))b(l,f)},m=(f,b)=>{let w=l,P=w.rows.length&&w.sourceId&&w.sourceId!==f?w.rows.slice():null;return b?w.sourceId===b?P:null:P},p=f=>{let b=f?f.slice():n.map((A,M)=>M),w=b.map(A=>n[A]);return{payload:pH(o,w,i??void 0,a??void 0,s??void 0),rowMap:b}},g=(f,b={})=>p(b.respondsWith==="highlight"?null:m(f,b.filteredBy)),y={get selection(){return l},get columns(){return o},get rows(){return n},incomingFor:m,payloadFor:p,memberPayload:g,publish(f,b){l=b.length?{sourceId:f,rows:b.slice()}:{sourceId:null,rows:[]},h(b.length?"select":"clear")},clear(){l={sourceId:null,rows:[]},h("clear")},setSource(f,b,w={}){o=f,n=b,i=w.geo??null,a=w.point??null,s=w.destination??null,h("source")},onChange(f){return u.add(f),()=>{u.delete(f)}},attach(f,b,w={}){let P=w.respondsWith==="highlight",A=g(f,w).rowMap,M=L=>P||!L?"*":L.join(","),C=M(m(f,w.filteredBy)),D=b.selection.onChange((L,N)=>{if(N==="host")return;let W=H5(A,L);f&&y.publish(f,W),w.onSelect?.(W)}),O=y.onChange((L,N)=>{let W=m(f,w.filteredBy),B=M(W);if(N==="source"||B!==C){let R=p(P?null:W);A=R.rowMap,C=B,b.setData(R.payload)}cz(b,L,f,P,W,A)}),T={get rowMap(){return A},detach(){D(),O(),c.delete(T)}};return c.add(T),T},destroy(){for(let f of Array.from(c))f.detach();u.clear()}};return y}/*! @bicharts/chart-host — Apache-2.0. Bundled reference data: GeoNames (https://www.geonames.org/) CC BY 4.0; Natural Earth and US Census/TIGER (public domain). Full text: NOTICE in this package. */var Bie=10,Die=1e5,Oie=1e4,bo=r=>Object.freeze({...r,...r.values?{values:Object.freeze([...r.values])}:{}}),fk=Object.freeze({aggregation:bo({timing:"live-and-next-generate",default:"",values:["","sum","average","median","min","max","count","distinct"],wire:"request"}),colorScaleLow:bo({timing:"live-and-next-generate",default:"",wire:"request"}),colorScaleHigh:bo({timing:"live-and-next-generate",default:"",wire:"request"}),palette:bo({timing:"live-and-next-generate",default:"",wire:"request"}),maxMapPoints:bo({timing:"live-and-next-generate",default:qC,min:Bie,max:Die,wire:"clientHints"}),pageSize:bo({timing:"live",default:0,min:0}),valueAxisBaseline:bo({timing:"live",default:KC,values:["fit","zero","auto"]}),seasonalMarkers:bo({timing:"live",default:YC,values:["auto","always","never"]}),animAutoPlay:bo({timing:"live",default:!1}),animPlaySpeedMs:bo({timing:"live",default:BC,min:DC,max:OC}),animLoopDelaySec:bo({timing:"live",default:FC,min:GC}),animStopAtEnd:bo({timing:"live",default:!1}),animMaxIdealFrames:bo({timing:"live",default:VC,min:HC,max:zC}),animTimelineStyle:bo({timing:"live",default:"",values:["","line","boxes"]}),filtersDuringPlay:bo({timing:"live",default:!1}),flipMode:bo({timing:"live",default:jC,values:["both","all","single"]}),flipIntervalMs:bo({timing:"live",default:"",min:0,max:BV}),flipDirection:bo({timing:"live",default:XC,values:["horizontal","vertical"]}),levelOfDetail:bo({timing:"next-generate",default:"",values:["","High","Medium","Low"],wire:"clientHints"}),favorLimitTo:bo({timing:"next-generate",default:"",values:["","latest","top / greatest","bottom / smallest","most common","outliers"],wire:"clientHints"}),favorLimitCount:bo({timing:"next-generate",default:0,min:0,max:Oie,wire:"clientHints"}),favorTitle:bo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),favorDPValues:bo({timing:"next-generate",default:"",values:["","1","0"],wire:"clientHints"}),legendPlacement:bo({timing:"next-generate",default:"",values:["","outside","inside","none"],wire:"clientHints"}),industryContext:bo({timing:"next-generate",default:"",wire:"clientHints"}),suggestFontFamily:bo({timing:"next-generate",default:"",wire:"clientHints"}),visionReview:bo({timing:"after-render",default:!1}),saveThumbnails:bo({timing:"after-render",default:!1})}),Dft=Object.freeze(Object.keys(fk).filter(r=>fk[r].timing==="live"||fk[r].timing==="live-and-next-generate"));function ns(r,e,t,o){var n,i=arguments.length,a=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(n=r[s])&&(a=(i<3?n(a):i>3?n(e,t,a):n(e,t))||a);return i>3&&a&&Object.defineProperty(e,t,a),a}function Ul(r,e,t){if(t||arguments.length===2)for(var o,n=0,i=e.length;n<i;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))}var mz=function(r,e,t){return[r,e,t].map((function(o){return(o/=255)>.04045?Math.pow((o+.055)/1.055,2.4):o/12.92}))},pz=function(r,e,t){return[r,e,t].map((function(o){return 255*(o<=.00304?12.92*o:1.055*Math.pow(o,1/2.4)-.055)}))},an=function(r,e,t){return Math.min(Math.max(r,e),t)},dz=function(r,e){return Math.round((r+Number.EPSILON)*Math.pow(10,e))/Math.pow(10,e)},z5=function(r,e){return Math.floor(Math.random()*(e-r+1)-r)},yz=function(r,e,t,o){for(var n,i=[r,e,t],a="#",s=0;s<i.length;s++)a+=(n=i[s],Math.round(an(n,0,255)).toString(16).padStart(2,"0"));return o!=null&&(a+=Math.round(an(o,0,100)/100*255).toString(16).padStart(2,"0")),a},fz=function(r){var e=r.length,t=(r=(function(i){var a=(i=/^#/.test(i)?i.slice(1):i).length;if(![3,4,6,8].includes(a))return"000000";if(a===6||a===8)return i;if(a===3||a===4){for(var s="",l=0;l<a;l++){var u=i[l];s+=""+u+u}return s}return"000000"})(r).padEnd(8,"ff")).match(/.{2}/g);if(!t)return[0,0,0,1];var o=[0,0,0],n=!1;return t.forEach((function(i,a){a<3?o[a]=parseInt(i,16):n=100*parseInt(i,16)/255})),n===!1||e<8?o:Ul(Ul([],o,!0),[n],!1)},gz=function(r,e,t){var o;o=[r,e,t].map((function(a){return a/255})),r=o[0],e=o[1],t=o[2];var n=1-Math.max(r,e,t),i=n<1?1/(1-n):0;return[(1-r-n)*i*100,(1-e-n)*i*100,(1-t-n)*i*100,100*n]},bz=function(r,e,t,o){return o===100?[0,0,0]:(o/=100,[r,e,t].map((function(n){return(n/=100)>=1?0:255*(1-n)*(1-o)})))};function Pk(r,e,t,o){var n;o===void 0&&(o="l"),n=[r,e,t].map((function(p){return p/255})),r=n[0],e=n[1],t=n[2];var i=Math.max(r,e,t),a=Math.min(r,e,t),s=(function(p,g,y,f){var b;f===void 0&&(f=!1),b=[p,g,y].map((function(C){return C/255})),p=b[0],g=b[1],y=b[2];var w=Math.max(p,g,y),P=Math.min(p,g,y),A=0;if(w!==P)if(f)A=(p-g+(p-y))/2,A/=Math.sqrt((p-g)*(p-g)+(p-y)*(g-y)),A=Math.acos(A),y>g&&(A=2*Math.PI-A),A/=2*Math.PI;else{var M=w-P;A=w===p?(g-y)/M+(g<y?6:0):w===g?(y-p)/M+2:(p-g)/M+4,A/=6}else A=NaN;return 360*A})(r,e,t,o==="i"),l=0,u=(i+a)/2,c=i-a,h=i,m=(r+e+t)/3;return o==="v"&&(l=i===0?0:c/i),i!==a&&o==="l"&&(l=u>.5?c/(2-i-a):c/(i+a)),o==="i"&&(l=m>0?1-a/m:0),l*=100,u*=100,m*=100,o==="l"?[s,l,u]:o==="v"?[s,l,h*=100]:[s,l,m]}var Nk=function(r,e,t){return Pk(r,e,t,"l")},Wp=function(r,e,t){var o,n,i=function(a){return 6*(a=a<0?a+1:a>1?a-1:a)<1?o+(n-o)*a*6:2*a<1?n:3*a<2?o+(n-o)*(.6666666666666666-a)*6:o};return r=r%360/360,e=an(e/100,0,1),t=an(t/100,0,1),o=2*t-(n=t<=.5?t*(e+1):t+e-t*e),[255*i(r+1/3),255*i(r),255*i(r-1/3)]},Sz=function(r,e,t){return Pk(r,e,t,"v")},vk=function(r,e,t){var o,n,i=[t/=100,t*(1-(e/=100)),t*(1-(n=(r=r%360/360*360)/60-(o=Math.floor(r/60%6)))*e),t*(1-(1-n)*e)],a=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return[255*i[a[o][0]],255*i[a[o][1]],255*i[a[o][2]]]},Az=function(r,e,t){return Pk(r,e,t,"i")},xk=function(r,e,t){var o,n,i,a;e/=100,t/=100,isNaN(r)&&(r=0),isNaN(e)&&(e=0);var s=function(l){return(1+e*Math.cos(2*Math.PI*l)/Math.cos(Math.PI/3-2*Math.PI*l))/3};return(r=(360+r)%360/360)<1/3?i=1-((a=(1-e)/3)+(n=s(r))):r<2/3?a=1-((n=(1-e)/3)+(i=s(r-=1/3))):n=1-((i=(1-e)/3)+(a=s(r-=2/3))),o=[n,i,a].map((function(l){return 255*an(t*l*3,0,1)})),[n=o[0],i=o[1],a=o[2]]},wz=function(r,e,t){return[Nk(r,e,t)[0],100*(Math.min(r,e,t)/255),100*(1-Math.max(r,e,t)/255)]};function Ek(r,e,t){return e/=100,t/=100,Wp(r,100,50).map((function(o){return 255*(o/255*(1-e-t)+e)}))}var gk={x:[.4124564,.3575761,.1804375],y:[.2126729,.7151522,.072175],z:[.0193339,.119192,.9503041]},bk={r:[3.2404542,-1.5371385,-.4985314],g:[-.969266,1.8760108,.041556],b:[.0556434,-.2040259,1.0572252]},Pz=.95047,Nz=1,vz=1.08883,Fie=.206896552,Gie=.008856452,xz=24389/27,Sk=function(r,e,t){var o=mz(r,e,t);return[100*gk.x.reduce((function(n,i,a){return n+i*o[a]}),0),100*gk.y.reduce((function(n,i,a){return n+i*o[a]}),0),100*gk.z.reduce((function(n,i,a){return n+i*o[a]}),0)]},Yw=function(r,e,t){var o=[r,e,t],n=bk.r.reduce((function(s,l,u){return s+l*o[u]}),0)/100,i=bk.g.reduce((function(s,l,u){return s+l*o[u]}),0)/100,a=bk.b.reduce((function(s,l,u){return s+l*o[u]}),0)/100;return pz(n,i,a)},j5=function(r,e,t){var o;return o=[r=r/Pz/100,e=e/Nz/100,t=t/vz/100].map((function(n){return n>Gie?Math.pow(n,1/3):(xz*n+16)/116})),r=o[0],e=o[1],t=o[2],[Math.max(0,116*e-16),500*(r-e),200*(e-t)]},Ck=function(r,e,t){var o,n=(r+16)/116,i=isNaN(e)?n:n+e/500,a=isNaN(t)?n:n-t/200;return o=[i,n,a].map((function(s){return s>Fie?Math.pow(s,3):(116*s-16)/xz})),i=o[0],n=o[1],a=o[2],[i*Pz*100,n*Nz*100,a*vz*100]},kk=function(r,e,t){return Yw.apply(void 0,Ck(r,e,t))},Ak=function(r,e,t){e=an(e,-100,100),t=an(t,-100,100);var o=Math.sqrt(e*e+t*t),n=(180*Math.atan2(t,e)/Math.PI+360)%360;return Math.round(1e4*o)===0&&(n=Number.NaN),[r,o,n]},Ez=function(r,e,t){return isNaN(t)&&(t=0),t*=Math.PI/180,[r,Math.cos(t)*e,Math.sin(t)*e]},Mk=function(r,e,t){return Ck.apply(void 0,Ez(r,e,t))},Cz=function(r,e,t){var o=r+e+t,n=0,i=0;return o>0&&(n=r/o,i=e/o),[n,i,e]},Vie=Object.freeze({__proto__:null,linear2rgb:pz,rgb2linear:mz,rgb2hex:yz,hex2rgb:fz,rgb2cmyk:gz,cmyk2rgb:bz,rgb2hsl:Nk,hsl2rgb:Wp,rgb2hsv:Sz,hsv2rgb:vk,rgb2hsi:Az,hsi2rgb:xk,rgb2hwb:wz,hwb2rgb:Ek,rgb2xyz:Sk,xyz2rgb:Yw,xyz2lab:j5,lab2xyz:Ck,rgb2lab:function(r,e,t){return j5.apply(void 0,Sk(r,e,t))},lab2rgb:kk,lch2lab:Ez,lab2lch:Ak,xyz2lch:function(r,e,t){return Ak.apply(void 0,j5(r,e,t))},lch2xyz:Mk,xyY2xyz:function(r,e,t){return e===0?[0,0,0]:[r*(t/e),t,t/e*(1-r-e)]},xyz2xyY:Cz});function _l(r,e){return e===void 0&&(e=!1),function(t,o,n){var i=n.value;n.value=function(){for(var a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];if(a.length>0&&e){var l=JSON.stringify(a);r+=l}if(this.cache.has(r))return this.cache.get(r);var u=i.call.apply(i,Ul([this],a,!1));return this.cache.set(r,u),u}}}function js(r,e,t,o){return r===void 0&&(r=[0,2,2]),e===void 0&&(e=0),t===void 0&&(t=!0),o===void 0&&(o=0),function(n,i,a){var s=a.value;a.value=function(){for(var l=[],u=0;u<arguments.length;u++)l[u]=arguments[u];var c=l[o]===void 0?t:l[o],h=s.call.apply(s,Ul([this],l,!1));if(c===!1)return h;var m=typeof c=="number"?Math.round(c):0,p=typeof r=="number"?new Array(h.length).fill(r):r,g=p.map((function(y){return e===1?typeof c=="number"?m:y:y+m}));return h.map((function(y,f){return dz(y,g[f])}))}}}var kz=function(r,e,t){var o=r instanceof fn?r:new fn(r),n=e instanceof fn?e:new fn(e),i=an(t,0,100)/100,a=2*i-1,s=o.alpha()-n.alpha(),l=((a*s==-1?a:(a+s)/(1+a*s))+1)/2,u=1-l,c=[Math.round(an(o.red()*l+n.red()*u,0,255)),Math.round(an(o.green()*l+n.green()*u,0,255)),Math.round(an(o.blue()*l+n.blue()*u,0,255))],h=o.alpha()*i+n.alpha()*(1-i);return new fn(c,h)},La=Math.sqrt,Gr=Math.pow,dS=Math.cos,Kw=Math.abs,hz=Math.sin,Hie=Math.exp,zie=Math.atan2,Mz=Math.PI,Tp=function(r){return Mz*r/180},wk=function(r,e,t){t===void 0&&(t=!0);var o=zie(e,r);return t&&(o=(o=(o=180*o/Mz)>0?o:o+360)>360?o-360:o),o},yS=function(r,e){e===void 0&&(e=!0);var t=r.lab(!1),o=t[0],n=t[1],i=t[2];return[o,La(Gr(n,2)+Gr(i,2)),wk(n,i,e),n,i]},jie=["CMC","CIE","CIE2000","CIE1994","CIE1976"],Xie="CMC",Kie="CIE2000",Yie="CIE1994",qie="CIE1976",Tz=function(r,e,t,o){t===void 0&&(t="CIE");var n=(function(c){var h=c.toUpperCase();return jie.includes(h)&&h!=="CIE"?h:Kie})(t);if(o=o||{},n===Xie){var i=Object.assign({},{l:1,c:1},o);return(function(c,h,m,p){m===void 0&&(m=1),p===void 0&&(p=1);var g=yS(c,!0),y=g[0],f=g[1],b=g[2],w=g[3],P=g[4],A=yS(h),M=A[0],C=A[1],D=A[3],O=f-C,T=y-M,L=P-A[4],N=La(Gr(w-D,2)+Gr(L,2)-Gr(O,2)),W=y<16?.511:.040975*y/(1+.01765*y),B=.0638*f/(1+.0131*f)+.638,R=164<=b&&b<=345?.56+Kw(.2*dS(Tp(b+168))):.36+Kw(.4*dS(Tp(b+35))),F=La(Gr(f,4)/(Gr(f,4)+1900)),V=B*(F*R+1-F);return La(Gr(T/(m*W),2)+Gr(O/(p*B),2)+Gr(N/V,2))})(r,e,i.l,i.c)}if(n===Yie){var a={kL:1,kC:1,kH:1,cate:"graphic"},s=Object.assign({},a,o);return(function(c,h,m,p,g,y){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1),y===void 0&&(y="graphic");var f=y==="textiles"?.048:.045,b=y==="textiles"?.014:.015;m=y==="textiles"?2:m;var w=yS(c),P=w[0],A=w[1],M=w[3],C=w[4],D=yS(h),O=D[0],T=D[1],L=D[3],N=P-O,W=A-T,B=C-D[4],R=1+f*A,F=1+b*A,V=La(Gr(M-L,2)+Gr(B,2)-Gr(W,2));return La(Gr(N/(1*m),2)+Gr(W/(p*R),2)+Gr(V/(g*F),2))})(r,e,s.kL,s.kC,s.kH,s.cate)}if(n===qie)return(function(c,h){var m=c.lab(!1),p=m[0],g=m[1],y=m[2],f=h.lab(!1),b=f[0],w=f[1],P=f[2];return La(Gr(p-b,2)+Gr(g-w,2)+Gr(y-P,2))})(r,e);var l={kL:1,kC:1,kH:1},u=Object.assign({},l,o);return(function(c,h,m,p,g){m===void 0&&(m=1),p===void 0&&(p=1),g===void 0&&(g=1);var y=yS(c),f=y[0],b=y[1],w=y[3],P=y[4],A=yS(h),M=A[0],C=A[1],D=A[3],O=A[4],T=(f+M)/2,L=(b+C)/2,N=(1-La(Gr(L,7)/(Gr(L,7)+Gr(25,7))))/2,W=w*(1+N),B=D*(1+N),R=La(Gr(W,2)+Gr(P,2)),F=La(Gr(B,2)+Gr(O,2)),V=wk(W,P,!0),K=wk(B,O,!0),J=(R+F)/2,z=Kw(V-K)>180?(V+K+360)/2:(V+K)/2,q=1-.17*dS(Tp(z-30))+.24*dS(Tp(2*z))+.32*dS(Tp(3*z+6))-.2*dS(Tp(4*z-63)),me=Kw(K-V)<=180?K-V:Kw(K-V)>180&&K<=V?K-V+360:K-V-360,j=M-f,ne=C-b,ue=2*La(R*F)*hz(Tp(me)/2),_e=1+.015*Gr(T-50,2)/La(20+Gr(T-50,2)),Be=1+.045*J,Ke=1+.015*J*q,ut=30*Hie(-Gr((z-275)/25,2)),fe=-2*La(Gr(J,7)/(Gr(J,7)+Gr(25,7)))*hz(2*Tp(ut));return La(Gr(j/(m*_e),2)+Gr(ne/(p*Be),2)+Gr(ue/(g*Ke),2)+fe*(ne/(p*Be))*(ue/(g*Ke)))})(r,e,u.kL,u.kC,u.kH)},Jie=function(r,e,t){var o=Math.abs,n=Math.max,i=Math.min,a=r instanceof fn?r:new fn(r),s=e instanceof fn?e:new fn(e),l=Object.assign({},{b:125,c:500},t);return!(o(255*a.brightness()/100-255*s.brightness()/100)<=l.b)&&!(n(a.red(),s.red())-i(a.red(),s.red())+(n(a.green(),s.green())-i(a.green(),s.green()))+(n(a.blue(),s.blue())-i(a.blue(),s.blue()))<=l.c)},fS=function(r,e,t){var o,n=function(u){return an(u,0,100)},i=function(u){return an(u,0,255)},a={h:[0,function(u){return u%360}],s:[1,n],l:[2,n],r:[0,i],g:[1,i],b:[2,i]},s=a[e][0];if(["h","s","l"].includes(e)){var l=r.hsl();if(t===void 0)return l[s];t=a[e][1](t),l[s]=t,o=Wp.apply(void 0,l)}else{if(o=r.rgb(),t===void 0)return o[s];t=a[e][1](t),o[s]=t}return new fn(o,r.alpha())},K5={},$ie=new Set(["rgb","rgba","cmyk","lab","hsl","hsla","hsv","hsva","hsi","hsia","xyz","lch","hwb","hwba"]),Qie=/^([a-zA-Z]+)\(([\s\S]+)\)$/,X5=function(r){return typeof r=="string"?r.indexOf("%")===-1?X5(Number(r.trim())):(r=r.split("%")[0],(r=Number(r.trim()))||0):Math.abs(r)<1?100*r:r},Wz=function(r,e){e===void 0&&(e=new Set);var t=typeof r=="string"?r:r.join(",");if(e.has(t))throw new Error("Invalid Color");e.add(t);var o="rgb",n=[0,0,0],i=100;if(Array.isArray(r)){if(r.length<3)throw new Error("Invalid Color");for(var a=0;a<r.length;a++)if(a<3)n[a]=r[a];else{if(a!==3||r[3]===void 0)break;i=r[3]}}else{var s=!1,l=r.trim().match(Qie);if(l||(s=!0),l){var u=l[1].toLocaleLowerCase();if(o=u,$ie.has(u)||(s=!0),l[2]&&!s){var c=l[2],h=c.indexOf(",")!==-1?",":" ",m=c.split(h);for(a=0;a<3;a++)m[a]!==void 0&&(["lch","lab"].includes(o)&&a===0||["hsl","hsla","hsv","hsva","hwb","hwba","hsi","hsia"].includes(o)&&a>0?n[a]=X5(m[a]):n[a]=Number(m[a].trim()));["rgba","hsla","hsva","hwba","hsia"].includes(o)?(o=o.slice(0,-1),m[3]!==void 0&&(i=X5(m[3]))):o==="cmyk"&&n.push(m[3]!==void 0?X5(m[3]):0)}}if(s){if(!/^#(([a-fA-F\d]{3}){1,2}|[a-fA-F\d]{8})$/.test(r))try{return r=(function(p,g){if(g===void 0&&(g=!1),p=p.toLowerCase(),K5[p]===void 0){if(g)throw new Error("Unknown color name: ".concat(p,")"));return p}return K5[p]})(r,!0),Wz(r,e)}catch{throw new Error("Invalid Color")}n=fz(r)}}return[o,n,i]},Lz={thowParseError:!1},fn=(function(){function r(e,t,o){this.cache=new Map,this._rgb=[0,0,0],this._alpha=100;var n={thowParseError:Lz.thowParseError},i=Object.assign({},n,o??{});try{var a=(function(u){var c,h={lab2rgb:kk,hsl2rgb:Wp,hsv2rgb:vk,xyz2rgb:Yw,hwb2rgb:Ek,hsi2rgb:xk},m=Wz(u),p=m[0],g=m[1],y=m[2];if(p==="rgb")return[g,y];p==="lch"&&(p=(c=["xyz",Mk(g[0],g[1],g[2])])[0],g=c[1]);var f=g[0],b=g[1],w=g[2],P=g[3];if(p==="cmyk")return[bz(f,b,w,P).map((function(M){return an(M,0,255)})),y];var A="".concat(p,"2rgb");if(typeof h[A]=="function")return[h[A](f,b,w).map((function(M){return an(M,0,255)})),y];throw new Error("Invalid color")})(e),s=a[0],l=a[1];this._alpha=l,this._rgb=s}catch(u){if(i.thowParseError)throw u}t!==void 0&&(this._alpha=an(t,0,100))}return r.prototype.red=function(e){return fS(this,"r",e)},r.prototype.green=function(e){return fS(this,"g",e)},r.prototype.blue=function(e){return fS(this,"b",e)},r.prototype.alpha=function(e){return e===void 0?this._alpha:(e=an(e,0,100),new r(this.rgb(),e))},r.prototype.fadeIn=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),an(this._alpha+e,0,100))},r.prototype.fadeOut=function(e,t){return e===void 0&&(e=10),e=t&&t==="relative"?this._alpha*e/100:e,new r(this.rgb(),an(this._alpha-e,0,100))},r.prototype.opacify=function(e,t){return e===void 0&&(e=10),this.fadeIn(e,t)},r.prototype.transparentize=function(e,t){return e===void 0&&(e=10),this.fadeOut(e,t)},r.prototype.hue=function(e){return fS(this,"h",e)},r.prototype.saturation=function(e){return fS(this,"s",e)},r.prototype.lightness=function(e){return fS(this,"l",e)},r.prototype.rgb=function(e){return Ul([],this._rgb,!0)},r.prototype.rgba=function(e){return Ul(Ul([],this.rgb(!1),!0),[this._alpha],!1)},r.prototype.cmyk=function(e){return gz.apply(void 0,this._rgb)},r.prototype.hsl=function(e){return Nk.apply(void 0,this._rgb)},r.prototype.hsla=function(e){return Ul(Ul([],this.hsl(!1),!0),[this._alpha],!1)},r.prototype.hsv=function(e){return Sz.apply(void 0,this._rgb)},r.prototype.hsi=function(e){return Az.apply(void 0,this._rgb)},r.prototype.hwb=function(e){return wz.apply(void 0,this._rgb)},r.prototype.xyz=function(e){return Sk.apply(void 0,this._rgb)},r.prototype.lab=function(e){return j5.apply(void 0,this.xyz(!1))},r.prototype.lch=function(e){return Ak.apply(void 0,this.lab(!1))},r.prototype.xyY=function(e){return Cz.apply(void 0,this.xyz(!1))},r.prototype.hex=function(e){e===void 0&&(e=2);var t=e===0?void 0:e===1?this._alpha:this._alpha===100?void 0:this._alpha,o="color:hex:param_".concat(e);if(this.cache.has(o))return this.cache.get(o);var n=yz.apply(void 0,Ul(Ul([],this._rgb,!1),[t],!1));return this.cache.set(o,n),n},r.prototype.lighten=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return a=an(a+=t!==void 0&&t==="relative"?a*(e/100):e,0,100),new r(Wp(n,i,a),this._alpha)},r.prototype.darken=function(e,t){return e===void 0&&(e=5),this.lighten(-e,t)},r.prototype.saturate=function(e,t){e===void 0&&(e=5);var o=this.hsl(!1),n=o[0],i=o[1],a=o[2];return i=an(i+=t!==void 0&&t==="relative"?i*(e/100):e,0,100),new r(Wp(n,i,a),this._alpha)},r.prototype.desaturate=function(e,t){return e===void 0&&(e=5),this.saturate(-e,t)},r.prototype.spin=function(e){var t=this.hsl(!1),o=t[0],n=t[1],i=t[2];return new r(Wp(o=(o+e%360+360)%360,n,i),this._alpha)},r.prototype.adjustHue=function(e){return this.spin(e)},r.prototype.complement=function(){return this.spin(180)},r.prototype.invert=function(){var e=this._rgb.map((function(t){return 255-t}));return new r([e[0],e[1],e[2]],this._alpha)},r.prototype.mix=function(e,t){return t===void 0&&(t=50),kz(this,e,100-an(t,0,100))},r.prototype.luma=function(){var e=this._rgb.map((function(t){return(t/=255)<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}));return .2126*e[0]+.7152*e[1]+.0722*e[2]},r.prototype.brightness=function(){var e=this._rgb;return(function(t,o,n){return(299*t+587*o+114*n)/1e3/255*100})(e[0],e[1],e[2])},r.prototype.deltaE=function(e,t,o){return t===void 0&&(t="CMC"),Tz(this,e,t,o)},r.prototype.visibility=function(e,t){return Jie(this,e,t)},ns([js(0,1,!0,0),_l("color:rgb")],r.prototype,"rgb",null),ns([js(0,1,!0,0)],r.prototype,"rgba",null),ns([js(0,1,!0,0),_l("color:cmyk")],r.prototype,"cmyk",null),ns([js(0,1,!0,0),_l("color:hsl")],r.prototype,"hsl",null),ns([js(0,1,!0,0)],r.prototype,"hsla",null),ns([js(0,1,!0,0),_l("color:hsv")],r.prototype,"hsv",null),ns([js(0,1,!0,0),_l("color:hsi")],r.prototype,"hsi",null),ns([js(0,1,!0,0),_l("color: hwb")],r.prototype,"hwb",null),ns([js(2,1,!0,0),_l("color:xyz")],r.prototype,"xyz",null),ns([js(2,1,!0,0),_l("color:lab")],r.prototype,"lab",null),ns([js(2,1,!0,0),_l("color:lch")],r.prototype,"lch",null),ns([js(2,1,!0,0),_l("color:xyY")],r.prototype,"xyY",null),ns([_l("color:luma")],r.prototype,"luma",null),r})(),Zie=function(r,e,t,o){return new fn([r,e,t],o)},eae=function(r,e,t,o){return new fn(Wp(r,e,t),o)},tae=function(r,e,t,o){return new fn(vk(r,e,t),o)},rae=function(r,e,t,o){return new fn(xk(r,e,t),o)},oae=function(r,e,t,o){return new fn(Ek(r,e,t),o)},nae=function(r,e,t,o){return new fn(Yw(r,e,t),o)},iae=function(r,e,t,o){return new fn(kk(r,e,t),o)},aae=function(r,e,t,o){return new fn(Yw.apply(void 0,Mk(r,e,t)),o)};function bi(r,e,t){return new fn(r,e,t)}bi.config=function(r){Object.assign(Lz,r)},bi.random=function(){var r=z5(0,255),e=z5(0,255),t=z5(0,255);return new fn([r,e,t])},bi.convertor=Vie,bi.Color=fn,bi.rgb=Zie,bi.hsl=eae,bi.hsv=tae,bi.hsi=rae,bi.hwb=oae,bi.xyz=nae,bi.lab=iae,bi.lch=aae,bi.mix=kz,bi.deltaE=Tz,bi.utils={roundDecimal:dz,randomRange:z5},bi.useNames=function(r,e){return(function(t,o){if(o!==void 0&&typeof o=="function"){var n={};for(var i in t){var a=o(i,t[i]),s=a[0],l=a[1];n[s]=l}Object.assign(K5,n)}else Object.assign(K5,t)})(r,e),bi};var J5=[1,0,0,1,0,0],$5=(r,e)=>[r[0]*e[0]+r[2]*e[1],r[1]*e[0]+r[3]*e[1],r[0]*e[2]+r[2]*e[3],r[1]*e[2]+r[3]*e[3],r[0]*e[4]+r[2]*e[5]+r[4],r[1]*e[4]+r[3]*e[5]+r[5]],Y5=(r,e,t)=>[r[0]*e+r[2]*t+r[4],r[1]*e+r[3]*t+r[5]];function sae(r){if(!r||!r.trim())return J5;let e=J5,t=/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g,o="";for(let n of r.matchAll(t)){o+=n[0];let i=n[2].split(/[\s,]+/).filter(Boolean).map(Number);if(i.some(s=>!isFinite(s)))return null;let a;switch(n[1]){case"matrix":if(i.length!==6)return null;a=i;break;case"translate":a=[1,0,0,1,i[0]??0,i[1]??0];break;case"scale":a=[i[0]??1,0,0,i[1]??i[0]??1,0,0];break;case"rotate":{let s=(i[0]??0)*Math.PI/180,l=Math.cos(s),u=Math.sin(s),c=[l,u,-u,l,0,0];a=i.length>=3?$5($5([1,0,0,1,i[1],i[2]],c),[1,0,0,1,-i[1],-i[2]]):c;break}case"skewX":a=[1,0,Math.tan((i[0]??0)*Math.PI/180),1,0,0];break;default:a=[1,Math.tan((i[0]??0)*Math.PI/180),0,1,0,0];break}e=$5(e,a)}return r.replace(t,"").replace(/[\s,]/g,"")!==""?null:o?e:J5}var Ch=r=>String(r??"").toLowerCase(),Q5=(r,e)=>{let t=Ch(r.getAttribute("style")).replace(/\s+/g,"");for(let o of t.split(";")){let n=o.indexOf(":");if(n>0&&o.slice(0,n)===e)return o.slice(n+1)}return null},qw=(r,e)=>Q5(r,e)??(r.getAttribute(e)!==null?Ch(r.getAttribute(e)):null);function lae(r){for(let e=r.parentElement;e;e=e.parentElement)if(Ch(e.localName)==="svg")return e;return null}var _z=new Set(["defs","clippath","mask","pattern","marker","symbol","lineargradient","radialgradient","filter","title","desc","metadata","style","script"]);function Iz(r){let e=String(r??"").trim();return/^\+?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?$/i.test(e)?parseFloat(e):NaN}function uae(r){if(qw(r,"overflow")==="visible")return null;let e=Iz(Q5(r,"width")??r.getAttribute("width")),t=Iz(Q5(r,"height")??r.getAttribute("height")),o=r.getAttribute("viewBox");if(o){let n=o.split(/[\s,]+/).filter(Boolean).map(Number);return n.length!==4||!n.every(isFinite)||n[2]<=0||n[3]<=0||!Ch(r.getAttribute("preserveAspectRatio")).includes("none")&&isFinite(e)&&isFinite(t)&&e>0&&t>0&&Math.abs(n[2]/n[3]-e/t)>.01*(e/t)?null:{x0:n[0],y0:n[1],x1:n[0]+n[2],y1:n[1]+n[3]}}return!(e>0)||!(t>0)?null:{x0:0,y0:0,x1:e,y1:t}}function cae(r,e){for(let t=r;t&&t!==e;t=t.parentElement){if(qw(t,"display")==="none")return!0;let o=qw(t,"visibility");if(o==="hidden"||o==="collapse")return!0;let n=qw(t,"opacity");if(n!==null&&n!==""&&parseFloat(n)===0)return!0}return!1}function hae(r,e){for(let t=r;t&&t!==e;t=t.parentElement)if(t.getAttribute("clip-path")||Q5(t,"clip-path")||_z.has(Ch(t.localName)))return!0;return!1}function mae(r,e){let t=J5;for(let o=r;o&&o!==e;o=o.parentElement){let n=sae(o.getAttribute("transform"));if(!n)return null;t=$5(n,t)}return t}var Si=(r,e)=>{let t=parseFloat(r.getAttribute(e)??"");return isFinite(t)?t:0};function Uz(r){let e="";for(let t=r.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue??"":t.nodeType===1&&!_z.has(Ch(t.localName))&&(e+=Uz(t));return e}function q5(r,e,t){for(let o=r;o&&o!==e.parentElement;o=o.parentElement){let n=qw(o,t);if(n!==null&&n!=="")return n}return null}function Tk(r){let e=[],t=r.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g)??[],o=0,n="",i=0,a=0,s=0,l=0,u=()=>parseFloat(t[o++]),c=()=>o<t.length&&!/^[a-zA-Z]$/.test(t[o]);for(;o<t.length;){if(/^[a-zA-Z]$/.test(t[o]))n=t[o++];else if(!n)return[];let h=n===n.toLowerCase(),m=n.toUpperCase();if(m==="Z"){if(i=s,a=l,c())return e;continue}let p={M:2,L:2,T:2,H:1,V:1,C:6,S:4,Q:4,A:7}[m];if(!p)return e;if(!c())continue;let g=[];for(let b=0;b<p;b++)g.push(u());if(g.some(b=>!isFinite(b)))return e;let y=h?i:0,f=h?a:0;if(m==="H")i=y+g[0],e.push([i,a]);else if(m==="V")a=f+g[0],e.push([i,a]);else if(m==="A")i=y+g[5],a=f+g[6],e.push([i,a]);else{for(let b=0;b<p;b+=2)e.push([y+g[b],f+g[b+1]]);i=y+g[p-2],a=f+g[p-1]}m==="M"&&(s=i,l=a,n=h?"l":"L")}return e}function Rz(r){let e=1/0,t=-1/0,o=1/0,n=-1/0;for(let[i,a]of r)e=Math.min(e,i),t=Math.max(t,i),o=Math.min(o,a),n=Math.max(n,a);return{X0:e,X1:t,Y0:o,Y1:n}}var pae=new Set(["rect","image","foreignobject","circle","ellipse","line","text","path","polygon","polyline"]),Xs=.5,dae=5;function Bz(r){let e={frames:0,unmeasured:0,outside:0,crossing:0,textLikely:0,textEvenNarrow:0,samples:{outside:[],crossing:[],textLikely:[],textEvenNarrow:[]}},t=(n,i)=>{n.length<dae&&n.push(i)},o=Math.round;for(let n of Array.from(r.querySelectorAll("svg"))){let i=uae(n),a=Array.from(n.querySelectorAll("*")).filter(c=>pae.has(Ch(c.localName))&&lae(c)===n);if(!i){a.length&&e.unmeasured++;continue}e.frames++;let s=(c,h)=>h==="left"||h==="right"?`x ${o(c.X0)}..${o(c.X1)}, frame ${o(i.x0)}..${o(i.x1)}`:`y ${o(c.Y0)}..${o(c.Y1)}, frame ${o(i.y0)}..${o(i.y1)}`,l=c=>c.X0>i.x1+Xs?"right":c.X1<i.x0-Xs?"left":c.Y0>i.y1+Xs?"bottom":c.Y1<i.y0-Xs?"top":"",u=c=>c.X1>i.x1+Xs?"right":c.X0<i.x0-Xs?"left":c.Y1>i.y1+Xs?"bottom":c.Y0<i.y0-Xs?"top":"";for(let c of a){if(cae(c,n)||hae(c,n))continue;let h=mae(c,n);if(!h)continue;let m=Ch(c.localName);if(m==="text"){let b=Uz(c).trim();if(!b)continue;let w=parseFloat(q5(c,n,"font-size")??"")||10,P=Si(c,"x")+Si(c,"dx"),A=Si(c,"y")+(Ch(c.getAttribute("dy")).endsWith("em")?parseFloat(c.getAttribute("dy"))*w:Si(c,"dy")),M=q5(c,n,"dominant-baseline")??q5(c,n,"alignment-baseline")??"";M==="middle"||M==="central"?A+=.35*w:(M==="hanging"||M==="text-before-edge")&&(A+=.8*w);let C=q5(c,n,"text-anchor")??"start";if(Math.abs(h[1])>1e-9||Math.abs(h[2])>1e-9)continue;let D=B=>{let R=b.length*w*B,F=C==="middle"?P-R/2:C==="end"?P-R:P;return Rz([Y5(h,F,A-.75*w),Y5(h,F+R,A+.2*w)])},O=D(.6),T=`text "${b.length>30?b.slice(0,30)+"...":b}"`,L=Y5(h,P,A)[0],N=O.Y0>i.y1+Xs?"bottom":O.Y1<i.y0-Xs?"top":C==="start"&&L>i.x1+Xs?"right":C==="end"&&L<i.x0-Xs?"left":"";if(N){e.outside++,t(e.samples.outside,{what:T,edge:N,where:s(O,N)});continue}let W=u(O);if(W){e.textLikely++,t(e.samples.textLikely,{what:T,edge:W,where:s(O,W)});let B=D(.5),R=u(B);R&&(e.textEvenNarrow++,t(e.samples.textEvenNarrow,{what:T,edge:R,where:s(O,R)}))}continue}let p;if(m==="circle"||m==="ellipse"){let b=m==="circle"?Si(c,"r"):Si(c,"rx"),w=m==="circle"?b:Si(c,"ry");if(!(b>0&&w>0))continue;let P=Si(c,"cx"),A=Si(c,"cy");p=[[P-b,A-w],[P+b,A+w],[P+b,A-w],[P-b,A+w]]}else if(m==="line")p=[[Si(c,"x1"),Si(c,"y1")],[Si(c,"x2"),Si(c,"y2")]];else if(m==="path"||m==="polygon"||m==="polyline"){if(m==="path")p=Tk(c.getAttribute("d")??"");else{let b=(c.getAttribute("points")??"").split(/[\s,]+/).filter(Boolean).map(Number);p=[];for(let w=0;w+1<b.length;w+=2)p.push([b[w],b[w+1]])}if(!p.length||p.some(b=>!isFinite(b[0])||!isFinite(b[1])))continue}else{let b=Si(c,"width"),w=Si(c,"height");if(!(b>0&&w>0))continue;let P=Si(c,"x"),A=Si(c,"y");p=[[P,A],[P+b,A+w],[P+b,A],[P,A+w]]}let g=Rz(p.map(b=>Y5(h,b[0],b[1]))),y=l(g);if(y){e.outside++,t(e.samples.outside,{what:m,edge:y,where:s(g,y)});continue}if(m==="path")continue;let f=u(g);f&&(e.crossing++,t(e.samples.crossing,{what:m,edge:f,where:s(g,f)}))}}return e}var Sae=new Set(["d3-sankey","d3-hexbin","d3-voronoi-treemap"]),Aae=new Set(["title","desc","metadata","style","script"]);function Vz(r){let e="";for(let t=r?.firstChild;t;t=t.nextSibling)t.nodeType===3||t.nodeType===4?e+=t.nodeValue||"":t.nodeType===1&&!Aae.has(String(t.localName||"").toLowerCase())&&(e+=Vz(t));return e}function Wk(r){let e=parseFloat(r.getAttribute?.("font-size")||"")||0;if(!e){let t=String(r.getAttribute?.("style")||"").match(/font-size:\s*([\d.]+)/);e=t?parseFloat(t[1]):10}return e}function wae(r){let e=["SVGElement","SVGGraphicsElement","SVGGeometryElement","SVGTextContentElement"].map(u=>r[u]?.prototype).filter(Boolean),t=u=>["text","tspan","textpath"].includes(String(u.tagName||"").toLowerCase()),o=u=>t(u)?Vz(u).trim().length*Wk(u)*.6:0,n=u=>{let c=String(u.tagName||"").toLowerCase();if(c==="path")return Tk(u.getAttribute("d")||"");if(c==="line")return[[+u.getAttribute("x1")||0,+u.getAttribute("y1")||0],[+u.getAttribute("x2")||0,+u.getAttribute("y2")||0]];let h=String(u.getAttribute("points")||"").split(/[\s,]+/).filter(Boolean).map(Number),m=[];for(let p=0;p+1<h.length;p+=2)m.push([h[p],h[p+1]]);return m},i=u=>{let c=0;for(let h=1;h<u.length;h++)c+=Math.hypot(u[h][0]-u[h-1][0],u[h][1]-u[h-1][1]);return c},a=function(){if(t(this)){let m=Wk(this);return{x:0,y:-m*.8,width:Math.max(1,o(this)),height:Math.max(1,m)}}let u=parseFloat(this.getAttribute?.("width")||"")||0,c=parseFloat(this.getAttribute?.("height")||"")||0;if(u>0||c>0)return{x:0,y:0,width:u||1,height:c||1};let h=parseFloat(this.getAttribute?.("r")||"")||0;return h>0?{x:-h,y:-h,width:2*h,height:2*h}:{x:0,y:0,width:1,height:1}},s=(u,c,h)=>Object.defineProperty(u,c,{configurable:!0,writable:!0,value:h});for(let u of e)s(u,"getBBox",a),s(u,"getBoundingClientRect",function(){let c=a.call(this);return{...c,top:c.y,left:c.x,right:c.x+c.width,bottom:c.y+c.height,toJSON(){return c}}}),s(u,"getComputedTextLength",function(){return o(this)}),s(u,"getSubStringLength",function(c,h){return t(this)?Math.max(0,(h||0)*Wk(this)*.6):0}),s(u,"getTotalLength",function(){return i(n(this))}),s(u,"getPointAtLength",function(c){let h=n(this);if(!h.length)return{x:0,y:0};let m=Math.max(0,+c||0);for(let g=1;g<h.length;g++){let y=Math.hypot(h[g][0]-h[g-1][0],h[g][1]-h[g-1][1]);if(m<=y&&y>0){let f=m/y;return{x:h[g-1][0]+f*(h[g][0]-h[g-1][0]),y:h[g-1][1]+f*(h[g][1]-h[g-1][1])}}m-=y}let p=h[h.length-1];return{x:p[0],y:p[1]}});let l=r.HTMLCanvasElement?.prototype;if(l){let u=new WeakMap,c=m=>{let p=String(m||"").match(/([\d.]+)\s*(px|pt|em|rem)\b/i);if(!p)return 10;let g=parseFloat(p[1]);return p[2].toLowerCase()==="pt"?g*4/3:/r?em/i.test(p[2])?g*16:g},h=()=>{};Object.defineProperty(l,"getContext",{configurable:!0,writable:!0,value:function(m){if(String(m||"").toLowerCase()!=="2d")return null;let p=u.get(this);if(!p){let g=this;p=new Proxy({canvas:g,font:"10px sans-serif",measureText(y){let f=c(this.font),b=String(y??"").length*f*.6;return{width:b,actualBoundingBoxLeft:0,actualBoundingBoxRight:b,actualBoundingBoxAscent:f*.8,actualBoundingBoxDescent:f*.2,fontBoundingBoxAscent:f*.8,fontBoundingBoxDescent:f*.2}},getImageData:(y,f,b,w)=>({width:b,height:w,data:new Uint8ClampedArray(Math.max(1,b*w*4))}),createLinearGradient:()=>({addColorStop:h}),createRadialGradient:()=>({addColorStop:h}),getLineDash:()=>[],isPointInPath:()=>!1,isPointInStroke:()=>!1},{get:(y,f)=>f in y?y[f]:typeof f=="string"&&/^[a-z]/.test(f)?h:void 0}),u.set(this,p)}return p}})}}function Pae(r){let e=["window","document","navigator","Event","CustomEvent","MouseEvent","KeyboardEvent","PointerEvent","Element","HTMLElement","SVGElement","Node","getComputedStyle","requestAnimationFrame","cancelAnimationFrame","DOMParser","XMLSerializer","MutationObserver","Image","ResizeObserver"],t=e.map(n=>[n,Object.getOwnPropertyDescriptor(globalThis,n)]),o=n=>n==="window"?r:n==="ResizeObserver"?r.ResizeObserver??class{observe(){}unobserve(){}disconnect(){}}:typeof r[n]=="function"&&/^[a-z]/.test(n)?r[n].bind(r):r[n];for(let n of e){let i=o(n);if(i!==void 0)try{Object.defineProperty(globalThis,n,{configurable:!0,writable:!0,value:i})}catch{}}return()=>{for(let[n,i]of t)try{i?Object.defineProperty(globalThis,n,i):delete globalThis[n]}catch{}}}function Fz(r,e){let t=e.split(/\r?\n/);for(let o of String(r?.stack??"").split(`
|
|
304
304
|
`)){if(!/eval at|anonymous/.test(o))continue;let n=o.match(/<anonymous>:(\d+):(\d+)\)?\s*$/);if(!n)continue;let i=parseInt(n[1],10)-2;if(i<1||i>t.length||!t[i-1].trim())continue;let a=t[i-1].trim();return{line:i,lineText:a.length>200?a.slice(0,197)+"...":a}}return{}}var kh=r=>String(r?.message??r??"unknown error").split(`
|
|
305
305
|
`)[0].slice(0,400),Hz=r=>new Promise(e=>setTimeout(e,r));async function Gz(r,e){let t=Date.now()+e;for(;Date.now()<t;){let o=!1;for(let n of Array.from(r.querySelectorAll("*"))){let i=n.__transition;if(i&&Object.keys(i).length){o=!0;break}}if(!o)return;await Hz(40)}}async function Nae(r){let e=Date.now(),t={rows:r.rows.length,payloadRows:0,missingPlugins:[],threw:null,invalid:null,timedOut:!1,marks:{byKind:{},total:0,legend:0,containerKind:"empty",declaresNoRowMarks:!1},blank:!1,frame:null,click:{tried:!1,target:"",reached:!1,sourceRowIdxs:[],sourceRows:[],error:null},consoleErrors:[],elapsedMs:0},o=t.consoleErrors,n=y=>{o.length<8&&!/painted no data marks/.test(y)&&o.push(y.slice(0,300))};if(t.missingPlugins=pk(r.code).filter(y=>!Sae.has(y)),t.missingPlugins.length)return t.elapsedMs=Date.now()-e,t;let i=new Proxy({},{get:(y,f)=>f==="error"||f==="warn"?(...b)=>n(b.map(w=>kh(w)).join(" ")):()=>{}}),a=new Jm({url:"http://localhost/",width:r.width,height:r.height,console:i,settings:{disableJavaScriptFileLoading:!0,disableCSSFileLoading:!0,handleDisabledFileLoadingAsSuccess:!0,suppressInsecureJavaScriptEnvironmentWarning:!0}});wae(a);let s=Pae(a),l=console.error,u=console.warn,c=console.log;console.error=(...y)=>n(y.map(f=>kh(f)).join(" ")),console.warn=(...y)=>n(y.map(f=>kh(f)).join(" ")),console.log=()=>{};let h=y=>{n(`uncaught: ${kh(y?.error??y?.message)}`)};a.addEventListener("error",h);let m=hk(KE,fae,gae,bae);a.d3=m;let p=a.document.createElement("div");p.style.width=`${r.width}px`,p.style.height=`${r.height}px`,a.document.body.appendChild(p);let g=null;try{let f=yk(r.columns,r.rows,r.binding).payloadFor(null);t.payloadRows=f.payload.rows.length,g=dk(p,{code:r.code,d3:m,data:f.payload,options:{...r.options??{},width:r.width,height:r.height},geoKind:r.geoKind||void 0,geoProvider:()=>r.geo,fit:!1,onInvalidSentinel:w=>{t.invalid=w.reason||w.message}});let b={rows:[]};g.selection.onChange((w,P)=>{P!=="host"&&(b.rows=H5(f.rowMap,w))});try{g.render();let w=r.renderTimeoutMs??15e3;await Promise.race([g.rendered.then(()=>!1),Hz(w).then(()=>!0)])&&(t.timedOut=!0)}catch(w){let P=/could not be COMPILED|did not define render/.test(kh(w));t.threw={phase:P?"compile":"render",message:kh(w),...Fz(w,r.code)}}if(!t.threw&&!t.invalid&&!t.timedOut){await Gz(p,2e3);let w=F5(p);t.marks.legend=w.legendMarkCount,t.marks.containerKind=w.containerKind,t.marks.declaresNoRowMarks=w.declaresNoRowMarks;for(let A of Array.from(p.querySelectorAll(".d3-mark"))){if(A.closest(".d3-legend-mark"))continue;let M=String(A.localName||"element").toLowerCase();t.marks.byKind[M]=(t.marks.byKind[M]??0)+1}t.marks.total=w.markCount,t.blank=G5({markCount:w.markCount,rows:t.payloadRows,declaresNoRowMarks:w.declaresNoRowMarks});try{t.frame=Bz(p)}catch{t.frame=null}let P=Array.from(p.querySelectorAll(".d3-mark")).find(A=>!A.closest(".d3-legend-mark")&&(A.hasAttribute("data-row-idx")||A.querySelector("[data-row-idx]")));if(P){t.click.tried=!0;let A=P.hasAttribute("data-row-idx")?P:P.querySelector("[data-row-idx]"),M=String(A.getAttribute("data-row-idx")).split(",");t.click.target=`${String(P.localName).toLowerCase()} for ${M.length===1?`row ${M[0]}`:`${M.length} rows`}`;let C=o.length;try{P.dispatchEvent(new a.MouseEvent("click",{bubbles:!0,cancelable:!0,view:a})),await Gz(p,1e3)}catch(D){t.click.error=kh(D)}!t.click.error&&o.length>C&&(t.click.error=o[C]),b.rows.length&&(t.click.reached=!0,t.click.sourceRowIdxs=b.rows,t.click.sourceRows=b.rows.slice(0,3).map(D=>r.rows[D]).filter(Boolean))}}}catch(y){t.threw=t.threw??{phase:"render",message:kh(y),...Fz(y,r.code)}}finally{try{g?.animation.stop()}catch{}try{g?.destroy()}catch{}a.removeEventListener("error",h),console.error=l,console.warn=u,console.log=c,s();try{await a.happyDOM.abort(),await a.happyDOM.close()}catch{}}return t.elapsedMs=Date.now()-e,t}if(!yae&&Dz&&Oz?.bicCheckChart){let r=Dz;Nae(Oz.job).then(e=>r.postMessage({ok:!0,facts:e}),e=>r.postMessage({ok:!1,error:kh(e)}))}export{Nae as renderChartCheck};
|