@flesler/cursor-canvas-web 1.5.0 → 1.5.2
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/cursor-canvas.cjs +1 -1
- package/dist/cursor-canvas.js +419 -404
- package/package.json +1 -1
- package/src/shim/__tests__/chartLegendOrder.test.tsx +34 -0
- package/src/shim/__tests__/useCanvasState.test.tsx +32 -0
- package/src/shim/bar-chart.tsx +2 -1
- package/src/shim/canvas-hooks.tsx +16 -4
- package/src/shim/chart-shared.tsx +8 -1
- package/src/shim/line-chart.tsx +5 -2
package/dist/cursor-canvas.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),r=require("react/jsx-runtime"),I=require("@mantine/charts"),h=require("@mantine/core"),k=require("./host-tokens-Lz69pkRj.cjs");function ge(t,e){const n=`canvas:${t}`,[o,s]=x.useState(()=>{if(typeof localStorage>"u")return e;try{const c=localStorage.getItem(n);return c===null?e:JSON.parse(c)}catch{return e}}),a=x.useCallback(c=>{s(f=>{const u=typeof c=="function"?c(f):c;try{localStorage==null||localStorage.setItem(n,JSON.stringify(u))}catch{}return u})},[n]);return[o,a]}function ye(){return x.useCallback(t=>{},[])}function xe(t,e){return{...t,...e}}const T={success:"#1F8A65",danger:"#CF2D56",warning:"#E8A33D",info:"#2E79B5",neutral:"#8888A8",added:"#1F8A65",deleted:"#CF2D56",renamed:"#5A6CC0"},te={success:"green",danger:"red",warning:"orange",info:"blue",neutral:"gray",added:"green",deleted:"red",renamed:"indigo"};function y(){const e=h.useComputedColorScheme("light")==="dark"?"dark":"light";return k.resolveThemeForColorScheme(e)}const ne={verticalAlign:"bottom",align:"center"},re={legend:{justifyContent:"center"}};function G(){const e=y().chart.sequence;return(n,o)=>n?T[n]:e[o%e.length]}function oe(){const e=y().text.primary;return{textColor:e,barLabelColor:e}}function se(t,e){return t.map((n,o)=>{const s={category:n};for(const a of e)s[a.name]=a.data[o]??0;return s})}function ae(t,e){return t.map((n,o)=>({name:n.name,color:e(n.tone,o)}))}function ie(t,e){return n=>`${e??""}${n}${t??""}`}function me(t,e){if(t!=null&&t.length)return t.map(n=>({...e?{x:n.value}:{y:n.value},label:n.label,color:n.tone?T[n.tone]:T.neutral}))}const be=new Set(["log","symlog","pow","sqrt"]);function ve(t){const{scale:e}=t;return typeof e!="string"||!be.has(e)?t:{...t,type:t.type??"number",allowDataOverflow:t.allowDataOverflow??!0,allowDecimals:t.allowDecimals??!0,domain:t.domain??[1,"dataMax"]}}function le(t){const e=me(t.referenceLines,!!t.horizontal);let n;if(!t.stacked&&!t.normalized){const a=t.beginAtZero!==!1;n=[t.yMin??(a?0:"auto"),t.yMax??"auto"]}const o=t.valueAxis?ve(t.valueAxis):void 0;if(!n&&!o)return{referenceLines:e};const s={...n&&{domain:n},...o};return t.horizontal?{xAxisProps:s,referenceLines:e}:{yAxisProps:s,referenceLines:e}}function je(t,e,n){return t!==void 0?t:e.length===1&&n.length<=8}function Se(t,e,n){return e.length!==1||e[0].tone?t:t.map((o,s)=>({...o,color:n(void 0,s)}))}const Ce=96,ke=6.5;function Te(t,e){return t.length<=e?t:`${t.slice(0,Math.max(0,e-1))}…`}function we(t,e){var c;const n=typeof e.x=="number"?e.x:Number(e.x)||0,o=typeof e.y=="number"?e.y:Number(e.y)||0,s=String(((c=e.payload)==null?void 0:c.value)??""),a=Te(s,t);return r.jsx("g",{transform:`translate(${n},${o})`,children:r.jsxs("text",{x:-10,y:0,dy:4,textAnchor:"end",fill:"currentColor",fontSize:12,children:[r.jsx("title",{children:s}),a]})})}function ce(t){return{fontWeight:700,fill:t}}function Le(t){return{...ce(t),position:"right"}}function Pe(t=Ce,e=!1){const n=Math.floor(t/ke);return{yAxisProps:{tick:o=>we(n,o),width:t},barChartProps:{margin:{right:e?48:32}},gridAxis:"y"}}function Ae(){return{barChartProps:{margin:{top:22}}}}function Me({categories:t,series:e,height:n=240,stacked:o,horizontal:s,normalized:a,valueSuffix:c,valuePrefix:f,showValues:u,beginAtZero:l,yMin:d,yMax:m,referenceLines:v,style:p,extra:j}){var A;const w=G(),L=oe(),P=Se(se(t,e),e,w),B=a?"percent":o?"stacked":"default",E=le({beginAtZero:l,yMin:d,yMax:m,referenceLines:v,horizontal:s,stacked:o,normalized:a,valueAxis:j==null?void 0:j.valueAxis}),S=!o&&!a&&je(u,e,t);return r.jsx(I.BarChart,{h:n,data:P,dataKey:"category",series:ae(e,w),type:B,orientation:s?"vertical":"horizontal",withLegend:e.length>1,legendProps:ne,valueFormatter:ie(c,f),withBarValueLabel:S,...S?{valueLabelProps:s?Le(L.barLabelColor):ce(L.barLabelColor)}:{},...s?Pe((A=j==null?void 0:j.categoryAxis)==null?void 0:A.width,S):S?Ae():{},styles:{...re,legendItemName:{color:L.textColor}},...E,style:p})}function Be({categories:t,series:e,height:n=240,fill:o,valueSuffix:s,valuePrefix:a,showValues:c,showHoverGuide:f=!0,beginAtZero:u,yMin:l,yMax:d,referenceLines:m,style:v,extra:p,smooth:j}){const w=(p==null?void 0:p.smooth)??j,L=G(),P=oe(),B=se(t,e),E=ae(e,L),S=!!(o&&(p!=null&&p.stacked)),A=le({beginAtZero:u,yMin:l,yMax:d,referenceLines:m,horizontal:!1,stacked:S,valueAxis:p==null?void 0:p.valueAxis}),M={h:n,data:B,dataKey:"category",series:E,curveType:w?"monotone":"linear",withLegend:e.length>1,legendProps:ne,valueFormatter:ie(s,a),withPointLabels:c??t.length<=20,tooltipProps:f?void 0:{cursor:!1},styles:{...re,legendItemName:{color:P.textColor}},...A,style:v};return o?r.jsx(I.AreaChart,{...M,type:S?"stacked":"default"}):r.jsx(I.LineChart,{...M})}const De=x.lazy(()=>Promise.resolve().then(()=>require("./pie-donut-DNbA0GeH.cjs")).then(t=>({default:t.PieDonutChart}))),Ee=180,Ie=540;function He(t,e){if(e<=0)return"0%";const n=t/e*100;return n<10&&Math.abs(n-Math.round(n))>.05?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function Re(t){return t.map(e=>({dataKey:e.name,value:e.name,color:e.color,type:"circle"}))}function Fe(t,e){return t.map(n=>({name:n.name,color:n.color,label:`${n.name} ${He(n.value,e)}`}))}function Ne({data:t,size:e=200,donut:n,style:o}){const[s,a]=x.useState(null),c=y(),f=G(),u=t.map((p,j)=>({name:p.label,value:p.value,color:f(p.tone,j)})),l=u.reduce((p,j)=>p+j.value,0),d={startAngle:Ee,endAngle:Ie},m=p=>({opacity:s===null||s===p?1:.35}),v=n?r.jsx(x.Suspense,{fallback:null,children:r.jsx(De,{data:u,size:e,highlighted:s})}):r.jsx(I.PieChart,{data:u,size:e,withTooltip:!0,withLabelsLine:!1,cellProps:p=>m(p.name),...d});return r.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",...o},children:[r.jsx("div",{style:{width:"100%",height:e,minHeight:e,display:"flex",alignItems:"center",justifyContent:"center"},children:v}),r.jsx(I.ChartLegend,{payload:Re(u),series:Fe(u,l),legendPosition:"bottom",centered:!0,onHighlight:a,mt:"sm",w:"100%",styles:{legend:{justifyContent:"center",gap:12,color:c.text.primary},legendItemName:{color:c.text.primary}}})]})}function _e(t){const{nodes:e,edges:n,direction:o="vertical",nodeWidth:s=160,nodeHeight:a=40,rankGap:c=64,nodeGap:f=48,padding:u=24}=t,l=e.map(i=>i.id),d=new Set(l),m=new Map;for(const i of l)m.set(i,[]);for(const i of n)d.has(i.from)&&d.has(i.to)&&m.get(i.from).push(i.to);const v=0,p=1,j=2,w=new Map(l.map(i=>[i,v])),L=new Set,P=(i,g)=>`${i}\0${g}`,B=i=>{w.set(i,p);for(const g of m.get(i)??[]){const b=w.get(g);b===p?L.add(P(i,g)):b===v&&B(g)}w.set(i,j)};for(const i of l)w.get(i)===v&&B(i);const E=n.filter(i=>d.has(i.from)&&d.has(i.to)&&!L.has(P(i.from,i.to))),S=new Map(l.map(i=>[i,0])),A=new Map(l.map(i=>[i,[]]));for(const i of E)A.get(i.from).push(i.to),S.set(i.to,(S.get(i.to)??0)+1);const M=new Map(l.map(i=>[i,0])),N=l.filter(i=>(S.get(i)??0)===0);for(;N.length>0;){const i=N.shift(),g=M.get(i);for(const b of A.get(i))M.set(b,Math.max(M.get(b),g+1)),S.set(b,S.get(b)-1),S.get(b)===0&&N.push(b)}const D=new Map;for(const i of l){const g=M.get(i);D.has(g)||D.set(g,[]),D.get(g).push(i)}const H=[...D.keys()].sort((i,g)=>i-g),C=o==="vertical",$=i=>i*(C?s:a)+Math.max(0,i-1)*f,q=Math.max(0,...H.map(i=>$(D.get(i).length))),R=new Map,V=[];H.forEach((i,g)=>{const b=D.get(i),_=$(b.length),z=u+(q-_)/2,F=u+g*((C?a:s)+c);b.forEach((U,Z)=>{const J=z+Z*((C?s:a)+f),he=C?J:F,pe=C?F:J;R.set(U,{id:U,x:he,y:pe,rank:i,order:Z})}),V.push({rank:i,x:C?z:F,y:C?F:z,width:C?_:s,height:C?a:_,nodeIds:b})});const K=(i,g)=>i?C?{x:i.x+s/2,y:g==="source"?i.y+a:i.y}:{x:g==="source"?i.x+s:i.x,y:i.y+a/2}:{x:0,y:0},fe=n.filter(i=>d.has(i.from)&&d.has(i.to)).map(i=>{const g=K(R.get(i.from),"source"),b=K(R.get(i.to),"target");return{from:i.from,to:i.to,sourceX:g.x,sourceY:g.y,targetX:b.x,targetY:b.y,isBackEdge:L.has(P(i.from,i.to))}}),X=u*2+H.length*(C?a:s)+Math.max(0,H.length-1)*c,Y=u*2+q;return{nodes:[...R.values()],edges:fe,ranks:V,direction:o,width:C?Y:X,height:C?X:Y}}function ze({additions:t=0,deletions:e=0,style:n}){return t===0&&e===0?null:r.jsxs("span",{style:{display:"inline-flex",gap:8,fontVariantNumeric:"tabular-nums",fontSize:12,fontWeight:600,...n},children:[t>0&&r.jsxs("span",{style:{color:T.added},children:["+",t]}),e>0&&r.jsxs("span",{style:{color:T.deleted},children:["-",e]})]})}const Ge={added:"+",removed:"-",unchanged:" "};function Oe({lines:t,showLineNumbers:e=!0,coloredLineNumbers:n=!0,showAccentStrip:o=!0,style:s}){const a=y(),c=l=>l==="added"?a.diff.insertedLine:l==="removed"?a.diff.removedLine:"transparent",f=l=>l==="added"?a.diff.stripAdded:l==="removed"?a.diff.stripRemoved:"transparent",u=l=>n&&l==="added"?T.added:n&&l==="removed"?T.deleted:a.text.tertiary;return r.jsx("div",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:12.5,lineHeight:"18px",color:a.text.primary,overflowX:"auto",...s},children:t.map((l,d)=>r.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:c(l.type),borderLeft:o?`3px solid ${f(l.type)}`:void 0},children:[e&&r.jsx("span",{style:{flex:"0 0 auto",width:40,textAlign:"right",paddingRight:10,userSelect:"none",color:u(l.type)},children:l.lineNumber??""}),r.jsx("span",{style:{flex:"0 0 auto",width:14,textAlign:"center",userSelect:"none",color:u(l.type)},children:Ge[l.type]}),r.jsx("pre",{style:{margin:0,padding:"0 8px",whiteSpace:"pre",fontFamily:"inherit"},children:l.content})]},d))})}function We({status:t}){const e=y(),n=t==="completed"?T.success:t==="in_progress"?e.accent.primary:t==="cancelled"?T.danger:e.text.tertiary;return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",style:{flex:"0 0 auto",marginTop:3},"aria-hidden":!0,children:[r.jsx("circle",{cx:7,cy:7,r:6,stroke:n,strokeWidth:1.4}),t==="completed"&&r.jsx("path",{d:"M4 7.2l2 2 4-4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}),t==="in_progress"&&r.jsx("circle",{cx:7,cy:7,r:3,fill:n}),t==="cancelled"&&r.jsx("path",{d:"M4.8 4.8l4.4 4.4M9.2 4.8l-4.4 4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round"})]})}function ue({todos:t,dimmedTodoIds:e,onTodoClick:n,style:o}){const s=y();return t.length===0?null:r.jsx("div",{style:{display:"flex",flexDirection:"column",...o},children:t.map(a=>{const c=e==null?void 0:e.has(a.id);return r.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(a),style:{display:"flex",gap:8,alignItems:"flex-start",width:"100%",textAlign:"left",padding:"4px 6px",background:"transparent",border:"none",cursor:n?"pointer":"default",color:s.text.primary,fontSize:14,lineHeight:"20px",opacity:c?.45:1},children:[r.jsx(We,{status:a.status}),r.jsx("span",{style:{textDecoration:a.status==="cancelled"?"line-through":void 0,color:a.status==="cancelled"?s.text.tertiary:void 0},children:a.content})]},a.id)})})}function $e({todos:t,dimmedTodoIds:e,defaultExpanded:n=!1,onTodoClick:o,style:s}){const a=y(),[c,f]=x.useState(n);if(t.length===0)return null;const u=t.filter(l=>l.status==="completed").length;return r.jsxs("div",{style:{border:`1px solid ${a.stroke.primary}`,borderRadius:6,overflow:"hidden",...s},children:[r.jsxs("button",{type:"button",onClick:()=>f(l=>!l),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:a.fill.secondary,border:"none",cursor:"pointer",color:a.text.secondary,fontSize:12,fontWeight:600},children:[r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:c?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{children:"Todos"}),r.jsx("span",{style:{flex:1}}),r.jsxs("span",{children:[u," of ",t.length," Done"]})]}),c&&r.jsx("div",{style:{padding:6},children:r.jsx(ue,{todos:t,dimmedTodoIds:e,onTodoClick:o})})]})}const qe={primary:"filled",secondary:"default",ghost:"subtle"};function Ve({children:t,variant:e="secondary",disabled:n,type:o="button",style:s,onClick:a}){return r.jsx(h.Button,{variant:qe[e],color:e==="primary"?"accent":void 0,size:"xs",disabled:n,type:o,onClick:a,style:s,children:t})}function Ke({children:t,onClick:e,disabled:n,title:o,variant:s="default",size:a="md",style:c}){return r.jsx(h.ActionIcon,{variant:s==="circle"?"light":"subtle",radius:s==="circle"?"xl":"sm",size:a==="sm"?"sm":"md",color:"gray",disabled:n,title:o,"aria-label":o,onClick:e,style:c,children:t})}const O=x.createContext({collapsible:!1,open:!0,toggle:()=>{}});function de({expanded:t}){return r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:t?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})})}function Xe({children:t,variant:e="default",collapsible:n=!1,defaultOpen:o=!0,open:s,onOpenChange:a,style:c}){const f=y(),[u,l]=x.useState(o),d=s??u,m=x.useCallback(()=>{const v=!d;s===void 0&&l(v),a==null||a(v)},[d,s,a]);return r.jsx(h.Card,{withBorder:e!=="borderless",radius:f.radius.md,padding:0,style:{background:f.bg.elevated,borderColor:f.stroke.secondary,...c},children:r.jsx(O.Provider,{value:{collapsible:n,open:d,toggle:m},children:t})})}function Ye({children:t,trailing:e,style:n}){const o=y(),{collapsible:s,open:a,toggle:c}=x.useContext(O);return r.jsxs("div",{onClick:s?c:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 14px",borderBottom:`1px solid ${o.stroke.secondary}`,fontSize:o.typography.small.fontSize,fontWeight:o.typography.h3.fontWeight,color:o.text.primary,fontFamily:o.typography.fontFamily,cursor:s?"pointer":void 0,userSelect:s?"none":void 0,...n},children:[r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[s&&r.jsx(de,{expanded:a}),t]}),e!=null&&r.jsx("span",{children:e})]})}function Ue({children:t,style:e}){const{collapsible:n,open:o}=x.useContext(O);return n&&!o?null:r.jsx("div",{style:{padding:14,...e},children:t})}function Ze({value:t,label:e,tone:n,style:o}){const s=y();return r.jsxs("div",{style:o,children:[r.jsx(h.Text,{fz:22,fw:700,lh:1.2,style:{color:n?T[n]:s.text.primary,fontFamily:s.typography.fontFamily},children:t}),r.jsx(h.Text,{fz:12,style:{color:s.text.tertiary,fontFamily:s.typography.fontFamily},children:e})]})}function Je({children:t,active:e,tone:n="neutral",size:o="md",leadingContent:s,keyboardHint:a,title:c,style:f,onClick:u}){return r.jsx(h.Badge,{color:te[n],variant:e?"filled":"light",size:o==="sm"?"sm":"md",leftSection:s,rightSection:a,title:c,onClick:u,style:{cursor:u?"pointer":void 0,textTransform:"none",...f},children:t})}function Qe({children:t,tone:e="neutral",title:n,icon:o,style:s}){return r.jsx(h.Alert,{color:te[e],title:n,icon:o,variant:"light",style:s,children:t})}function et({value:t,onChange:e,options:n,placeholder:o,disabled:s,style:a}){return r.jsx(h.Select,{value:t,data:n,placeholder:o,disabled:s,allowDeselect:!1,onChange:c=>{c!==null&&(e==null||e(c))},style:a})}function tt({checked:t,onChange:e,disabled:n,label:o,style:s}){return r.jsx(h.Checkbox,{checked:t,disabled:n,label:o,onChange:a=>e==null?void 0:e(a.currentTarget.checked),style:s})}function nt({checked:t,onChange:e,disabled:n,size:o="sm",style:s}){return r.jsx(h.Switch,{checked:t,disabled:n,size:o==="sm"?"sm":"md",onChange:a=>e==null?void 0:e(a.currentTarget.checked),style:s})}function rt({value:t,onChange:e,placeholder:n,disabled:o,type:s,style:a}){return r.jsx(h.TextInput,{value:t,placeholder:n,disabled:o,type:s,onChange:c=>e==null?void 0:e(c.currentTarget.value),style:a})}function ot({value:t,onChange:e,placeholder:n,disabled:o,rows:s=3,style:a}){return r.jsx(h.Textarea,{value:t,placeholder:n,disabled:o,autosize:!0,minRows:s,onChange:c=>e==null?void 0:e(c.currentTarget.value),style:a})}function st({children:t,gap:e,style:n}){return r.jsx(h.Stack,{gap:e,style:n,children:t})}const Q={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch","space-between":"space-between"};function at({children:t,gap:e,align:n="center",justify:o="start",wrap:s=!1,style:a}){return r.jsx(h.Group,{gap:e,align:Q[n],justify:Q[o],wrap:s?"wrap":"nowrap",style:a,children:t})}function it(){return r.jsx("div",{style:{flex:1}})}function lt({children:t,columns:e,gap:n=16,align:o,style:s}){const a=typeof e=="number"?`repeat(${e}, minmax(0, 1fr))`:e;return r.jsx("div",{style:{display:"grid",gridTemplateColumns:a,gap:n,alignItems:o,...s},children:t})}function ct({style:t}){return r.jsx(h.Divider,{style:t})}function ut({color:t,style:e}){const n=y();return r.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:4,background:n.category[t],flex:"0 0 auto",...e}})}function dt({segments:t,total:e,topLeftLabel:n,topRightLabel:o,style:s}){const a=y(),c=e>0?e:1,f=t.reduce((l,d)=>l+(Number.isFinite(d.value)&&d.value>0?d.value:0),0),u=Math.max(0,c-f);return r.jsxs("div",{style:s,children:[(n!=null||o!=null)&&r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:a.text.secondary,marginBottom:6},children:[r.jsx("span",{children:n}),r.jsx("span",{children:o})]}),r.jsxs("div",{style:{display:"flex",gap:2,height:8},children:[t.map((l,d)=>{const m=Number.isFinite(l.value)&&l.value>0?l.value:0,v=a.category[l.color??k.usageColorSequence[d%k.usageColorSequence.length]];return r.jsx("div",{style:{width:`${m/c*100}%`,background:v,borderRadius:3}},l.id)}),u>0&&r.jsx("div",{style:{width:`${u/c*100}%`,background:a.fill.tertiary,borderRadius:3}})]})]})}function ft({title:t,leading:e,count:n,trailing:o,children:s,defaultOpen:a=!1,style:c}){const f=y(),[u,l]=x.useState(a);return r.jsxs("div",{style:c,children:[r.jsxs("div",{onClick:()=>l(d=>!d),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",cursor:"pointer",userSelect:"none",color:f.text.primary,fontSize:14},children:[r.jsx(de,{expanded:u}),e,r.jsx("span",{style:{fontWeight:500},children:t}),n!=null&&r.jsx("span",{style:{color:f.text.tertiary,fontSize:12},children:n}),r.jsx("span",{style:{flex:1}}),o!=null&&r.jsx("span",{style:{color:f.text.tertiary},children:o})]}),u&&r.jsx("div",{style:{paddingLeft:18,paddingBottom:4},children:s})]})}const ht={success:"rgba(31,138,101,0.12)",danger:"rgba(207,45,86,0.12)",warning:"rgba(232,163,61,0.14)",info:"rgba(46,121,181,0.12)",neutral:"rgba(136,136,168,0.12)"};function pt({headers:t,rows:e,columnAlign:n,rowTone:o,framed:s=!0,striped:a,stickyHeader:c,style:f,emptyMessage:u}){return r.jsxs(h.Table,{withTableBorder:s,withColumnBorders:!1,striped:a,stickyHeader:c,highlightOnHover:!0,style:f,children:[r.jsx(h.Table.Thead,{children:r.jsx(h.Table.Tr,{children:t.map((l,d)=>r.jsx(h.Table.Th,{ta:(n==null?void 0:n[d])??"left",children:l},d))})}),r.jsx(h.Table.Tbody,{children:e.length===0?r.jsx(h.Table.Tr,{children:r.jsx(h.Table.Td,{colSpan:t.length,ta:"center",c:"dimmed",children:u??"No data"})}):e.map((l,d)=>{const m=o==null?void 0:o[d];return r.jsx(h.Table.Tr,{style:m?{background:ht[m]}:void 0,children:t.map((v,p)=>r.jsx(h.Table.Td,{ta:(n==null?void 0:n[p])??"left",children:l[p]},p))},d)})})]})}function W(t,e,n){const o=t.typography[e];return{fontFamily:t.typography.fontFamily,fontSize:o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,color:t.text.primary,margin:0,...n}}function gt({children:t,style:e}){const n=y();return r.jsx(h.Title,{order:1,style:W(n,"h1",e),children:t})}function yt({children:t,style:e}){const n=y();return r.jsx(h.Title,{order:2,style:W(n,"h2",e),children:t})}function xt({children:t,style:e}){const n=y();return r.jsx(h.Title,{order:3,style:W(n,"h3",e),children:t})}const mt={normal:400,medium:500,semibold:600,bold:700},ee=x.createContext(!1);function bt({children:t,tone:e="primary",size:n="body",as:o="p",weight:s="normal",italic:a,truncate:c,style:f}){const u=y(),d=x.useContext(ee)&&o==="p"?"span":o,m=o==="p";return r.jsx(ee.Provider,{value:!0,children:r.jsx(h.Text,{component:d,size:n==="small"?"xs":"sm",fw:mt[s],c:e==="primary"?void 0:u.text[e],truncate:c,style:{fontStyle:a?"italic":void 0,...e==="primary"?{color:u.text.primary}:void 0,...m&&d==="span"?{display:"block"}:void 0,fontFamily:u.typography.fontFamily,...f},children:t})})}function vt({children:t,style:e}){const n=y();return r.jsx("code",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:"0.92em",color:n.text.primary,background:n.fill.secondary,borderRadius:n.radius.sm,padding:"1px 4px",...e},children:t})}function jt({children:t,href:e,style:n}){const o=y();return r.jsx("a",{href:e,target:"_blank",rel:"noreferrer",style:{color:o.text.link,...n},children:t})}Object.defineProperty(exports,"useEffect",{enumerable:!0,get:()=>x.useEffect});Object.defineProperty(exports,"useMemo",{enumerable:!0,get:()=>x.useMemo});Object.defineProperty(exports,"useRef",{enumerable:!0,get:()=>x.useRef});Object.defineProperty(exports,"useState",{enumerable:!0,get:()=>x.useState});exports.canvasPaletteDark=k.canvasPaletteDark;exports.canvasPaletteGrokDark=k.canvasPaletteGrokDark;exports.canvasPaletteGrokLight=k.canvasPaletteGrokLight;exports.canvasPaletteLight=k.canvasPaletteLight;exports.canvasTokens=k.canvasTokens;exports.canvasTokensLight=k.canvasTokensLight;exports.categoryPaletteDark=k.categoryPaletteDark;exports.categoryPaletteLight=k.categoryPaletteLight;exports.colorPalette=k.colorPalette;exports.usageColorSequence=k.usageColorSequence;exports.BarChart=Me;exports.Button=Ve;exports.Callout=Qe;exports.Card=Xe;exports.CardBody=Ue;exports.CardHeader=Ye;exports.Checkbox=tt;exports.Code=vt;exports.CollapsibleSection=ft;exports.DiffStats=ze;exports.DiffView=Oe;exports.Divider=ct;exports.Grid=lt;exports.H1=gt;exports.H2=yt;exports.H3=xt;exports.IconButton=Ke;exports.LineChart=Be;exports.Link=jt;exports.PieChart=Ne;exports.Pill=Je;exports.Row=at;exports.Select=et;exports.Spacer=it;exports.Stack=st;exports.Stat=Ze;exports.Swatch=ut;exports.Table=pt;exports.Text=bt;exports.TextArea=ot;exports.TextInput=rt;exports.TodoList=ue;exports.TodoListCard=$e;exports.Toggle=nt;exports.UsageBar=dt;exports.computeDAGLayout=_e;exports.mergeStyle=xe;exports.useCanvasAction=ye;exports.useCanvasState=ge;exports.useHostTheme=y;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react"),r=require("react/jsx-runtime"),E=require("@mantine/charts"),h=require("@mantine/core"),k=require("./host-tokens-Lz69pkRj.cjs");function ye(e,t){const n=`canvas:${e}`,[o,s]=x.useState(()=>{try{const f=localStorage.getItem(n);if(f!==null)return JSON.parse(f)}catch{}const c=be(e);return c!==void 0?c:t}),a=x.useCallback(c=>{s(f=>{const u=typeof c=="function"?c(f):c;try{localStorage.setItem(n,JSON.stringify(u))}catch{}return u})},[n]);return[o,a]}function xe(){return x.useCallback(e=>{},[])}function me(e,t){return{...e,...t}}function be(e){try{const t=globalThis.__canvasJsonState;return!t||!Object.hasOwn(t,e)?void 0:t[e]}catch{return}}const T={success:"#1F8A65",danger:"#CF2D56",warning:"#E8A33D",info:"#2E79B5",neutral:"#8888A8",added:"#1F8A65",deleted:"#CF2D56",renamed:"#5A6CC0"},te={success:"green",danger:"red",warning:"orange",info:"blue",neutral:"gray",added:"green",deleted:"red",renamed:"indigo"};function y(){const t=h.useComputedColorScheme("light")==="dark"?"dark":"light";return k.resolveThemeForColorScheme(t)}const ne={verticalAlign:"bottom",align:"center",itemSorter:null},re={itemSorter:null},oe={legend:{justifyContent:"center"}};function z(){const t=y().chart.sequence;return(n,o)=>n?T[n]:t[o%t.length]}function se(){const t=y().text.primary;return{textColor:t,barLabelColor:t}}function ae(e,t){return e.map((n,o)=>{const s={category:n};for(const a of t)s[a.name]=a.data[o]??0;return s})}function ie(e,t){return e.map((n,o)=>({name:n.name,color:t(n.tone,o)}))}function le(e,t){return n=>`${t??""}${n}${e??""}`}function ve(e,t){if(e!=null&&e.length)return e.map(n=>({...t?{x:n.value}:{y:n.value},label:n.label,color:n.tone?T[n.tone]:T.neutral}))}const je=new Set(["log","symlog","pow","sqrt"]);function Se(e){const{scale:t}=e;return typeof t!="string"||!je.has(t)?e:{...e,type:e.type??"number",allowDataOverflow:e.allowDataOverflow??!0,allowDecimals:e.allowDecimals??!0,domain:e.domain??[1,"dataMax"]}}function ce(e){const t=ve(e.referenceLines,!!e.horizontal);let n;if(!e.stacked&&!e.normalized){const a=e.beginAtZero!==!1;n=[e.yMin??(a?0:"auto"),e.yMax??"auto"]}const o=e.valueAxis?Se(e.valueAxis):void 0;if(!n&&!o)return{referenceLines:t};const s={...n&&{domain:n},...o};return e.horizontal?{xAxisProps:s,referenceLines:t}:{yAxisProps:s,referenceLines:t}}function Ce(e,t,n){return e!==void 0?e:t.length===1&&n.length<=8}function ke(e,t,n){return t.length!==1||t[0].tone?e:e.map((o,s)=>({...o,color:n(void 0,s)}))}const Te=96,we=6.5;function Le(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Pe(e,t){var c;const n=typeof t.x=="number"?t.x:Number(t.x)||0,o=typeof t.y=="number"?t.y:Number(t.y)||0,s=String(((c=t.payload)==null?void 0:c.value)??""),a=Le(s,e);return r.jsx("g",{transform:`translate(${n},${o})`,children:r.jsxs("text",{x:-10,y:0,dy:4,textAnchor:"end",fill:"currentColor",fontSize:12,children:[r.jsx("title",{children:s}),a]})})}function ue(e){return{fontWeight:700,fill:e}}function Ae(e){return{...ue(e),position:"right"}}function Me(e=Te,t=!1){const n=Math.floor(e/we);return{yAxisProps:{tick:o=>Pe(n,o),width:e},barChartProps:{margin:{right:t?48:32}},gridAxis:"y"}}function Be(){return{barChartProps:{margin:{top:22}}}}function De({categories:e,series:t,height:n=240,stacked:o,horizontal:s,normalized:a,valueSuffix:c,valuePrefix:f,showValues:u,beginAtZero:l,yMin:d,yMax:m,referenceLines:v,style:p,extra:j}){var A;const w=z(),L=se(),P=ke(ae(e,t),t,w),B=a?"percent":o?"stacked":"default",I=ce({beginAtZero:l,yMin:d,yMax:m,referenceLines:v,horizontal:s,stacked:o,normalized:a,valueAxis:j==null?void 0:j.valueAxis}),S=!o&&!a&&Ce(u,t,e);return r.jsx(E.BarChart,{h:n,data:P,dataKey:"category",series:ie(t,w),type:B,orientation:s?"vertical":"horizontal",withLegend:t.length>1,legendProps:ne,tooltipProps:re,valueFormatter:le(c,f),withBarValueLabel:S,...S?{valueLabelProps:s?Ae(L.barLabelColor):ue(L.barLabelColor)}:{},...s?Me((A=j==null?void 0:j.categoryAxis)==null?void 0:A.width,S):S?Be():{},styles:{...oe,legendItemName:{color:L.textColor}},...I,style:p})}function Ie({categories:e,series:t,height:n=240,fill:o,valueSuffix:s,valuePrefix:a,showValues:c,showHoverGuide:f=!0,beginAtZero:u,yMin:l,yMax:d,referenceLines:m,style:v,extra:p,smooth:j}){const w=(p==null?void 0:p.smooth)??j,L=z(),P=se(),B=ae(e,t),I=ie(t,L),S=!!(o&&(p!=null&&p.stacked)),A=ce({beginAtZero:u,yMin:l,yMax:d,referenceLines:m,horizontal:!1,stacked:S,valueAxis:p==null?void 0:p.valueAxis}),M={h:n,data:B,dataKey:"category",series:I,curveType:w?"monotone":"linear",withLegend:t.length>1,legendProps:ne,valueFormatter:le(s,a),withPointLabels:c??e.length<=20,tooltipProps:{...re,...!f&&{cursor:!1}},styles:{...oe,legendItemName:{color:P.textColor}},...A,style:v};return o?r.jsx(E.AreaChart,{...M,type:S?"stacked":"default"}):r.jsx(E.LineChart,{...M})}const Ee=x.lazy(()=>Promise.resolve().then(()=>require("./pie-donut-DNbA0GeH.cjs")).then(e=>({default:e.PieDonutChart}))),Re=180,He=540;function _e(e,t){if(t<=0)return"0%";const n=e/t*100;return n<10&&Math.abs(n-Math.round(n))>.05?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function Fe(e){return e.map(t=>({dataKey:t.name,value:t.name,color:t.color,type:"circle"}))}function Oe(e,t){return e.map(n=>({name:n.name,color:n.color,label:`${n.name} ${_e(n.value,t)}`}))}function Ne({data:e,size:t=200,donut:n,style:o}){const[s,a]=x.useState(null),c=y(),f=z(),u=e.map((p,j)=>({name:p.label,value:p.value,color:f(p.tone,j)})),l=u.reduce((p,j)=>p+j.value,0),d={startAngle:Re,endAngle:He},m=p=>({opacity:s===null||s===p?1:.35}),v=n?r.jsx(x.Suspense,{fallback:null,children:r.jsx(Ee,{data:u,size:t,highlighted:s})}):r.jsx(E.PieChart,{data:u,size:t,withTooltip:!0,withLabelsLine:!1,cellProps:p=>m(p.name),...d});return r.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center",...o},children:[r.jsx("div",{style:{width:"100%",height:t,minHeight:t,display:"flex",alignItems:"center",justifyContent:"center"},children:v}),r.jsx(E.ChartLegend,{payload:Fe(u),series:Oe(u,l),legendPosition:"bottom",centered:!0,onHighlight:a,mt:"sm",w:"100%",styles:{legend:{justifyContent:"center",gap:12,color:c.text.primary},legendItemName:{color:c.text.primary}}})]})}function ze(e){const{nodes:t,edges:n,direction:o="vertical",nodeWidth:s=160,nodeHeight:a=40,rankGap:c=64,nodeGap:f=48,padding:u=24}=e,l=t.map(i=>i.id),d=new Set(l),m=new Map;for(const i of l)m.set(i,[]);for(const i of n)d.has(i.from)&&d.has(i.to)&&m.get(i.from).push(i.to);const v=0,p=1,j=2,w=new Map(l.map(i=>[i,v])),L=new Set,P=(i,g)=>`${i}\0${g}`,B=i=>{w.set(i,p);for(const g of m.get(i)??[]){const b=w.get(g);b===p?L.add(P(i,g)):b===v&&B(g)}w.set(i,j)};for(const i of l)w.get(i)===v&&B(i);const I=n.filter(i=>d.has(i.from)&&d.has(i.to)&&!L.has(P(i.from,i.to))),S=new Map(l.map(i=>[i,0])),A=new Map(l.map(i=>[i,[]]));for(const i of I)A.get(i.from).push(i.to),S.set(i.to,(S.get(i.to)??0)+1);const M=new Map(l.map(i=>[i,0])),F=l.filter(i=>(S.get(i)??0)===0);for(;F.length>0;){const i=F.shift(),g=M.get(i);for(const b of A.get(i))M.set(b,Math.max(M.get(b),g+1)),S.set(b,S.get(b)-1),S.get(b)===0&&F.push(b)}const D=new Map;for(const i of l){const g=M.get(i);D.has(g)||D.set(g,[]),D.get(g).push(i)}const R=[...D.keys()].sort((i,g)=>i-g),C=o==="vertical",$=i=>i*(C?s:a)+Math.max(0,i-1)*f,q=Math.max(0,...R.map(i=>$(D.get(i).length))),H=new Map,V=[];R.forEach((i,g)=>{const b=D.get(i),O=$(b.length),N=u+(q-O)/2,_=u+g*((C?a:s)+c);b.forEach((J,U)=>{const Z=N+U*((C?s:a)+f),pe=C?Z:_,ge=C?_:Z;H.set(J,{id:J,x:pe,y:ge,rank:i,order:U})}),V.push({rank:i,x:C?N:_,y:C?_:N,width:C?O:s,height:C?a:O,nodeIds:b})});const K=(i,g)=>i?C?{x:i.x+s/2,y:g==="source"?i.y+a:i.y}:{x:g==="source"?i.x+s:i.x,y:i.y+a/2}:{x:0,y:0},he=n.filter(i=>d.has(i.from)&&d.has(i.to)).map(i=>{const g=K(H.get(i.from),"source"),b=K(H.get(i.to),"target");return{from:i.from,to:i.to,sourceX:g.x,sourceY:g.y,targetX:b.x,targetY:b.y,isBackEdge:L.has(P(i.from,i.to))}}),X=u*2+R.length*(C?a:s)+Math.max(0,R.length-1)*c,Y=u*2+q;return{nodes:[...H.values()],edges:he,ranks:V,direction:o,width:C?Y:X,height:C?X:Y}}function Ge({additions:e=0,deletions:t=0,style:n}){return e===0&&t===0?null:r.jsxs("span",{style:{display:"inline-flex",gap:8,fontVariantNumeric:"tabular-nums",fontSize:12,fontWeight:600,...n},children:[e>0&&r.jsxs("span",{style:{color:T.added},children:["+",e]}),t>0&&r.jsxs("span",{style:{color:T.deleted},children:["-",t]})]})}const We={added:"+",removed:"-",unchanged:" "};function $e({lines:e,showLineNumbers:t=!0,coloredLineNumbers:n=!0,showAccentStrip:o=!0,style:s}){const a=y(),c=l=>l==="added"?a.diff.insertedLine:l==="removed"?a.diff.removedLine:"transparent",f=l=>l==="added"?a.diff.stripAdded:l==="removed"?a.diff.stripRemoved:"transparent",u=l=>n&&l==="added"?T.added:n&&l==="removed"?T.deleted:a.text.tertiary;return r.jsx("div",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:12.5,lineHeight:"18px",color:a.text.primary,overflowX:"auto",...s},children:e.map((l,d)=>r.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:c(l.type),borderLeft:o?`3px solid ${f(l.type)}`:void 0},children:[t&&r.jsx("span",{style:{flex:"0 0 auto",width:40,textAlign:"right",paddingRight:10,userSelect:"none",color:u(l.type)},children:l.lineNumber??""}),r.jsx("span",{style:{flex:"0 0 auto",width:14,textAlign:"center",userSelect:"none",color:u(l.type)},children:We[l.type]}),r.jsx("pre",{style:{margin:0,padding:"0 8px",whiteSpace:"pre",fontFamily:"inherit"},children:l.content})]},d))})}function qe({status:e}){const t=y(),n=e==="completed"?T.success:e==="in_progress"?t.accent.primary:e==="cancelled"?T.danger:t.text.tertiary;return r.jsxs("svg",{width:14,height:14,viewBox:"0 0 14 14",fill:"none",style:{flex:"0 0 auto",marginTop:3},"aria-hidden":!0,children:[r.jsx("circle",{cx:7,cy:7,r:6,stroke:n,strokeWidth:1.4}),e==="completed"&&r.jsx("path",{d:"M4 7.2l2 2 4-4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"}),e==="in_progress"&&r.jsx("circle",{cx:7,cy:7,r:3,fill:n}),e==="cancelled"&&r.jsx("path",{d:"M4.8 4.8l4.4 4.4M9.2 4.8l-4.4 4.4",stroke:n,strokeWidth:1.4,strokeLinecap:"round"})]})}function de({todos:e,dimmedTodoIds:t,onTodoClick:n,style:o}){const s=y();return e.length===0?null:r.jsx("div",{style:{display:"flex",flexDirection:"column",...o},children:e.map(a=>{const c=t==null?void 0:t.has(a.id);return r.jsxs("button",{type:"button",onClick:()=>n==null?void 0:n(a),style:{display:"flex",gap:8,alignItems:"flex-start",width:"100%",textAlign:"left",padding:"4px 6px",background:"transparent",border:"none",cursor:n?"pointer":"default",color:s.text.primary,fontSize:14,lineHeight:"20px",opacity:c?.45:1},children:[r.jsx(qe,{status:a.status}),r.jsx("span",{style:{textDecoration:a.status==="cancelled"?"line-through":void 0,color:a.status==="cancelled"?s.text.tertiary:void 0},children:a.content})]},a.id)})})}function Ve({todos:e,dimmedTodoIds:t,defaultExpanded:n=!1,onTodoClick:o,style:s}){const a=y(),[c,f]=x.useState(n);if(e.length===0)return null;const u=e.filter(l=>l.status==="completed").length;return r.jsxs("div",{style:{border:`1px solid ${a.stroke.primary}`,borderRadius:6,overflow:"hidden",...s},children:[r.jsxs("button",{type:"button",onClick:()=>f(l=>!l),style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:a.fill.secondary,border:"none",cursor:"pointer",color:a.text.secondary,fontSize:12,fontWeight:600},children:[r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:c?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsx("span",{children:"Todos"}),r.jsx("span",{style:{flex:1}}),r.jsxs("span",{children:[u," of ",e.length," Done"]})]}),c&&r.jsx("div",{style:{padding:6},children:r.jsx(de,{todos:e,dimmedTodoIds:t,onTodoClick:o})})]})}const Ke={primary:"filled",secondary:"default",ghost:"subtle"};function Xe({children:e,variant:t="secondary",disabled:n,type:o="button",style:s,onClick:a}){return r.jsx(h.Button,{variant:Ke[t],color:t==="primary"?"accent":void 0,size:"xs",disabled:n,type:o,onClick:a,style:s,children:e})}function Ye({children:e,onClick:t,disabled:n,title:o,variant:s="default",size:a="md",style:c}){return r.jsx(h.ActionIcon,{variant:s==="circle"?"light":"subtle",radius:s==="circle"?"xl":"sm",size:a==="sm"?"sm":"md",color:"gray",disabled:n,title:o,"aria-label":o,onClick:t,style:c,children:e})}const G=x.createContext({collapsible:!1,open:!0,toggle:()=>{}});function fe({expanded:e}){return r.jsx("svg",{width:12,height:12,viewBox:"0 0 12 12",fill:"none",style:{transform:e?"rotate(90deg)":"none",transition:"transform 120ms"},"aria-hidden":!0,children:r.jsx("path",{d:"M4 2.5L8 6l-4 3.5",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round"})})}function Je({children:e,variant:t="default",collapsible:n=!1,defaultOpen:o=!0,open:s,onOpenChange:a,style:c}){const f=y(),[u,l]=x.useState(o),d=s??u,m=x.useCallback(()=>{const v=!d;s===void 0&&l(v),a==null||a(v)},[d,s,a]);return r.jsx(h.Card,{withBorder:t!=="borderless",radius:f.radius.md,padding:0,style:{background:f.bg.elevated,borderColor:f.stroke.secondary,...c},children:r.jsx(G.Provider,{value:{collapsible:n,open:d,toggle:m},children:e})})}function Ue({children:e,trailing:t,style:n}){const o=y(),{collapsible:s,open:a,toggle:c}=x.useContext(G);return r.jsxs("div",{onClick:s?c:void 0,style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,padding:"8px 14px",borderBottom:`1px solid ${o.stroke.secondary}`,fontSize:o.typography.small.fontSize,fontWeight:o.typography.h3.fontWeight,color:o.text.primary,fontFamily:o.typography.fontFamily,cursor:s?"pointer":void 0,userSelect:s?"none":void 0,...n},children:[r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[s&&r.jsx(fe,{expanded:a}),e]}),t!=null&&r.jsx("span",{children:t})]})}function Ze({children:e,style:t}){const{collapsible:n,open:o}=x.useContext(G);return n&&!o?null:r.jsx("div",{style:{padding:14,...t},children:e})}function Qe({value:e,label:t,tone:n,style:o}){const s=y();return r.jsxs("div",{style:o,children:[r.jsx(h.Text,{fz:22,fw:700,lh:1.2,style:{color:n?T[n]:s.text.primary,fontFamily:s.typography.fontFamily},children:e}),r.jsx(h.Text,{fz:12,style:{color:s.text.tertiary,fontFamily:s.typography.fontFamily},children:t})]})}function et({children:e,active:t,tone:n="neutral",size:o="md",leadingContent:s,keyboardHint:a,title:c,style:f,onClick:u}){return r.jsx(h.Badge,{color:te[n],variant:t?"filled":"light",size:o==="sm"?"sm":"md",leftSection:s,rightSection:a,title:c,onClick:u,style:{cursor:u?"pointer":void 0,textTransform:"none",...f},children:e})}function tt({children:e,tone:t="neutral",title:n,icon:o,style:s}){return r.jsx(h.Alert,{color:te[t],title:n,icon:o,variant:"light",style:s,children:e})}function nt({value:e,onChange:t,options:n,placeholder:o,disabled:s,style:a}){return r.jsx(h.Select,{value:e,data:n,placeholder:o,disabled:s,allowDeselect:!1,onChange:c=>{c!==null&&(t==null||t(c))},style:a})}function rt({checked:e,onChange:t,disabled:n,label:o,style:s}){return r.jsx(h.Checkbox,{checked:e,disabled:n,label:o,onChange:a=>t==null?void 0:t(a.currentTarget.checked),style:s})}function ot({checked:e,onChange:t,disabled:n,size:o="sm",style:s}){return r.jsx(h.Switch,{checked:e,disabled:n,size:o==="sm"?"sm":"md",onChange:a=>t==null?void 0:t(a.currentTarget.checked),style:s})}function st({value:e,onChange:t,placeholder:n,disabled:o,type:s,style:a}){return r.jsx(h.TextInput,{value:e,placeholder:n,disabled:o,type:s,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:a})}function at({value:e,onChange:t,placeholder:n,disabled:o,rows:s=3,style:a}){return r.jsx(h.Textarea,{value:e,placeholder:n,disabled:o,autosize:!0,minRows:s,onChange:c=>t==null?void 0:t(c.currentTarget.value),style:a})}function it({children:e,gap:t,style:n}){return r.jsx(h.Stack,{gap:t,style:n,children:e})}const Q={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch","space-between":"space-between"};function lt({children:e,gap:t,align:n="center",justify:o="start",wrap:s=!1,style:a}){return r.jsx(h.Group,{gap:t,align:Q[n],justify:Q[o],wrap:s?"wrap":"nowrap",style:a,children:e})}function ct(){return r.jsx("div",{style:{flex:1}})}function ut({children:e,columns:t,gap:n=16,align:o,style:s}){const a=typeof t=="number"?`repeat(${t}, minmax(0, 1fr))`:t;return r.jsx("div",{style:{display:"grid",gridTemplateColumns:a,gap:n,alignItems:o,...s},children:e})}function dt({style:e}){return r.jsx(h.Divider,{style:e})}function ft({color:e,style:t}){const n=y();return r.jsx("span",{style:{display:"inline-block",width:14,height:14,borderRadius:4,background:n.category[e],flex:"0 0 auto",...t}})}function ht({segments:e,total:t,topLeftLabel:n,topRightLabel:o,style:s}){const a=y(),c=t>0?t:1,f=e.reduce((l,d)=>l+(Number.isFinite(d.value)&&d.value>0?d.value:0),0),u=Math.max(0,c-f);return r.jsxs("div",{style:s,children:[(n!=null||o!=null)&&r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,color:a.text.secondary,marginBottom:6},children:[r.jsx("span",{children:n}),r.jsx("span",{children:o})]}),r.jsxs("div",{style:{display:"flex",gap:2,height:8},children:[e.map((l,d)=>{const m=Number.isFinite(l.value)&&l.value>0?l.value:0,v=a.category[l.color??k.usageColorSequence[d%k.usageColorSequence.length]];return r.jsx("div",{style:{width:`${m/c*100}%`,background:v,borderRadius:3}},l.id)}),u>0&&r.jsx("div",{style:{width:`${u/c*100}%`,background:a.fill.tertiary,borderRadius:3}})]})]})}function pt({title:e,leading:t,count:n,trailing:o,children:s,defaultOpen:a=!1,style:c}){const f=y(),[u,l]=x.useState(a);return r.jsxs("div",{style:c,children:[r.jsxs("div",{onClick:()=>l(d=>!d),style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",cursor:"pointer",userSelect:"none",color:f.text.primary,fontSize:14},children:[r.jsx(fe,{expanded:u}),t,r.jsx("span",{style:{fontWeight:500},children:e}),n!=null&&r.jsx("span",{style:{color:f.text.tertiary,fontSize:12},children:n}),r.jsx("span",{style:{flex:1}}),o!=null&&r.jsx("span",{style:{color:f.text.tertiary},children:o})]}),u&&r.jsx("div",{style:{paddingLeft:18,paddingBottom:4},children:s})]})}const gt={success:"rgba(31,138,101,0.12)",danger:"rgba(207,45,86,0.12)",warning:"rgba(232,163,61,0.14)",info:"rgba(46,121,181,0.12)",neutral:"rgba(136,136,168,0.12)"};function yt({headers:e,rows:t,columnAlign:n,rowTone:o,framed:s=!0,striped:a,stickyHeader:c,style:f,emptyMessage:u}){return r.jsxs(h.Table,{withTableBorder:s,withColumnBorders:!1,striped:a,stickyHeader:c,highlightOnHover:!0,style:f,children:[r.jsx(h.Table.Thead,{children:r.jsx(h.Table.Tr,{children:e.map((l,d)=>r.jsx(h.Table.Th,{ta:(n==null?void 0:n[d])??"left",children:l},d))})}),r.jsx(h.Table.Tbody,{children:t.length===0?r.jsx(h.Table.Tr,{children:r.jsx(h.Table.Td,{colSpan:e.length,ta:"center",c:"dimmed",children:u??"No data"})}):t.map((l,d)=>{const m=o==null?void 0:o[d];return r.jsx(h.Table.Tr,{style:m?{background:gt[m]}:void 0,children:e.map((v,p)=>r.jsx(h.Table.Td,{ta:(n==null?void 0:n[p])??"left",children:l[p]},p))},d)})})]})}function W(e,t,n){const o=e.typography[t];return{fontFamily:e.typography.fontFamily,fontSize:o.fontSize,lineHeight:o.lineHeight,fontWeight:o.fontWeight,color:e.text.primary,margin:0,...n}}function xt({children:e,style:t}){const n=y();return r.jsx(h.Title,{order:1,style:W(n,"h1",t),children:e})}function mt({children:e,style:t}){const n=y();return r.jsx(h.Title,{order:2,style:W(n,"h2",t),children:e})}function bt({children:e,style:t}){const n=y();return r.jsx(h.Title,{order:3,style:W(n,"h3",t),children:e})}const vt={normal:400,medium:500,semibold:600,bold:700},ee=x.createContext(!1);function jt({children:e,tone:t="primary",size:n="body",as:o="p",weight:s="normal",italic:a,truncate:c,style:f}){const u=y(),d=x.useContext(ee)&&o==="p"?"span":o,m=o==="p";return r.jsx(ee.Provider,{value:!0,children:r.jsx(h.Text,{component:d,size:n==="small"?"xs":"sm",fw:vt[s],c:t==="primary"?void 0:u.text[t],truncate:c,style:{fontStyle:a?"italic":void 0,...t==="primary"?{color:u.text.primary}:void 0,...m&&d==="span"?{display:"block"}:void 0,fontFamily:u.typography.fontFamily,...f},children:e})})}function St({children:e,style:t}){const n=y();return r.jsx("code",{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, "Cascadia Code", monospace',fontSize:"0.92em",color:n.text.primary,background:n.fill.secondary,borderRadius:n.radius.sm,padding:"1px 4px",...t},children:e})}function Ct({children:e,href:t,style:n}){const o=y();return r.jsx("a",{href:t,target:"_blank",rel:"noreferrer",style:{color:o.text.link,...n},children:e})}Object.defineProperty(exports,"useEffect",{enumerable:!0,get:()=>x.useEffect});Object.defineProperty(exports,"useMemo",{enumerable:!0,get:()=>x.useMemo});Object.defineProperty(exports,"useRef",{enumerable:!0,get:()=>x.useRef});Object.defineProperty(exports,"useState",{enumerable:!0,get:()=>x.useState});exports.canvasPaletteDark=k.canvasPaletteDark;exports.canvasPaletteGrokDark=k.canvasPaletteGrokDark;exports.canvasPaletteGrokLight=k.canvasPaletteGrokLight;exports.canvasPaletteLight=k.canvasPaletteLight;exports.canvasTokens=k.canvasTokens;exports.canvasTokensLight=k.canvasTokensLight;exports.categoryPaletteDark=k.categoryPaletteDark;exports.categoryPaletteLight=k.categoryPaletteLight;exports.colorPalette=k.colorPalette;exports.usageColorSequence=k.usageColorSequence;exports.BarChart=De;exports.Button=Xe;exports.Callout=tt;exports.Card=Je;exports.CardBody=Ze;exports.CardHeader=Ue;exports.Checkbox=rt;exports.Code=St;exports.CollapsibleSection=pt;exports.DiffStats=Ge;exports.DiffView=$e;exports.Divider=dt;exports.Grid=ut;exports.H1=xt;exports.H2=mt;exports.H3=bt;exports.IconButton=Ye;exports.LineChart=Ie;exports.Link=Ct;exports.PieChart=Ne;exports.Pill=et;exports.Row=lt;exports.Select=nt;exports.Spacer=ct;exports.Stack=it;exports.Stat=Qe;exports.Swatch=ft;exports.Table=yt;exports.Text=jt;exports.TextArea=at;exports.TextInput=st;exports.TodoList=de;exports.TodoListCard=Ve;exports.Toggle=ot;exports.UsageBar=ht;exports.computeDAGLayout=ze;exports.mergeStyle=me;exports.useCanvasAction=xe;exports.useCanvasState=ye;exports.useHostTheme=y;
|