@duckcodeailabs/dql-cli 1.12.3 → 1.12.4
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/assets/dql-notebook/assets/AgentAnswerCard-BJAnjaLA.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-CsSC2tOR.js → AgentLogPage-J72WR6hk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-CjJ-9bQW.js → AiBuildDialog-CHJZfDmp.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-BvTcW9oE.js → AiBuildResult-Da7_Cn12.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiSidePanel-CxFrOfCE.js → AiSidePanel-BY6W_5aC.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AnalyticsHome-BtXEdJNR.js → AnalyticsHome-u-buXgdv.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AppsView-HjQkbbE6.js → AppsView-3k7ftDpd.js} +3 -3
- package/dist/assets/dql-notebook/assets/{BlockStudio-oQHTJsXC.js → BlockStudio-CLX4EUyO.js} +14 -14
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-Dpsftjs7.js → BusinessArtifactView-3THMNeyO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-c6ZteaI6.js → DbtFirstModelingPage-BwBPwtdA.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GitPage-Cj6mc-Yv.js → GitPage-CvEki0pe.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GlobalAiRail-8G_rEyhK.js → GlobalAiRail-NXdk9kNy.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GovernedContextPage-BTtzt0Za.js → GovernedContextPage-DILbw-Vr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-e2CesE73.js → HelpDocsPage-DgCu4bvY.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-U3ryMLEF.js → HomePage-CK3fXTQo.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDAG-CEmgJzm3.js → LineageDAG-DW_NO3P2.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDetailView-CeV5QMXS.js → LineageDetailView-VT7DLJOB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-B1oAn-N_.js → LineageDrawer-DSTm8aXw.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-fP6RTXut.js → LineagePathBreadcrumb-DRlAYasJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-CBYSTmRC.js → MiniLineageGraph-CR_nhwhZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-ksEwimjl.js → NewBlockModal-CJvjYiBF.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-CUx0WmXb.js → NewNotebookModal-BEpPH93n.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NotebookEditor-BdxJL3LX.js → NotebookEditor-C7GDFwhF.js} +1 -1
- package/dist/assets/dql-notebook/assets/{ReadinessPage-DZ9wDW76.js → ReadinessPage-rZiOp2xr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bt0AAe0h.js → SetupOnboarding-BWjhTjPB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{TrustBadge-DNVJK_mP.js → TrustBadge-RvZ9s6OQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{UnifiedAgentRunPanel-BNqE169i.js → UnifiedAgentRunPanel-CGPcpY1B.js} +18 -18
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-B_gE6rsY.js → answer-to-notebook-Di227Cd4.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-DnKGhzOR.js → arrow-left-BZHDcWHR.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-CQ73DG7_.js → arrow-right-DlM1pC3_.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-CyBV5Nhw.js → book-open-text-DBcXFQAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-UOPtBzCj.js → bot-BAywbvPm.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-CDHDU3N3.js → chevron-up-B_GfKE_F.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-DC5nkL_u.js → circle-x-BcxtZ-ym.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-C7ujXipB.js → dagre.esm-Bqs0lsEz.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-BiJ_dtTM.js → external-link-B24Dk9_t.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-eXvkUerq.js → grip-vertical-D9g31N3j.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-DU7j3Sqk.js +644 -0
- package/dist/assets/dql-notebook/assets/{link-2-DkHVJTuH.js → link-2-B36oR5Bj.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-8lYW2Itb.js → list-tree-B9ZzGc4U.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-DjSovOdP.js → maximize-2-BrvQLPoj.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-DGlmQLES.js → minimize-2-BrpFmsxS.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-DPc4gShM.js → panel-right-open-B1g1qhh5.js} +1 -1
- package/dist/assets/dql-notebook/assets/{pencil-nwaGtOdL.js → pencil-DwywbTqQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-ByjLhAu7.js → rotate-ccw-Db_KVs3J.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-eEhwnQhG.js → semantic-fields-BIVuvP2l.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-zws0cKhp.js → triangle-alert-Cne6C2aG.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-D6mtrJ-_.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-CM8xNakq.js → user-round-DkzxN1xD.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-CIKc8r-4.js → wand-sparkles-CJUvFtur.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-6C0ZLbTi.js → workflow-BOvVTg7R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-CeU7hF12.js → wrench-YeSpzZRt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-DLWEzvri.js → x-C6tsHUR7.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/block-invocation.js +4 -0
- package/dist/block-invocation.js.map +1 -1
- package/dist/llm/answer-loop-tools.d.ts +8 -2
- package/dist/llm/answer-loop-tools.d.ts.map +1 -1
- package/dist/llm/answer-loop-tools.js +29 -2
- package/dist/llm/answer-loop-tools.js.map +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +27 -1
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +79 -15
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/llm/types.d.ts +8 -1
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/local-runtime.d.ts +46 -0
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +606 -66
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/sql-result-filter.d.ts +39 -0
- package/dist/sql-result-filter.d.ts.map +1 -0
- package/dist/sql-result-filter.js +256 -0
- package/dist/sql-result-filter.js.map +1 -0
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-BEIwKGm4.js +0 -5
- package/dist/assets/dql-notebook/assets/index-BMVfPaXr.js +0 -644
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-hxi1RZDm.js +0 -18
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{g as C,r as T,j as n,t as H,aJ as he,L as be,e as ve,h as je,S as ne,b as ge,d as Se}from"./index-BMVfPaXr.js";/**
|
|
2
|
-
* @license lucide-react v0.563.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Me=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],we=C("code-xml",Me);/**
|
|
7
|
-
* @license lucide-react v0.563.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const $e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],ke=C("file-search",$e);/**
|
|
12
|
-
* @license lucide-react v0.563.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ae=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],vt=C("send",Ae),ze=/date|time|_at$|_on$|timestamp/i;function _e(t){return typeof t=="number"||typeof t=="string"&&t!==""&&!isNaN(Number(t))}function Fe(t,s){if(ze.test(t))return"date";const e=s.slice(0,40).map(l=>l[t]).filter(l=>l!=null);return e.length===0?"string":e.every(l=>typeof l=="boolean")?"bool":e.every(l=>typeof l=="object")?"json":e.filter(_e).length/e.length>.8?"numeric":"string"}function jt(t){return t==="numeric"?"measure":t==="date"?"temporal":"dimension"}const oe=/(?:^|_)(?:revenue|sales|spend|amount|price|cost|profit|income|expense|balance|budget|bookings|arr|mrr|gmv|fee|fees|charge|charges|tax|value)(?:_|$)/i,Ie=/(?:^|_)(?:percent|percentage|pct|ratio|share|conversion|churn|retention|utilization)(?:_|$)|(?:^|_)margin(?:_|$)/i,We=/(?:^|_)(?:count|orders?|customers?|accounts?|users?|products?|items?|units?|quantity|rank|position|days?|months?|years?|distinct)(?:_|$)/i,se=/(?:^|_)(?:average|avg|mean)(?:_|$)/i,Le=/(?:^|_)(?:date|day|month|quarter|year|time|timestamp)(?:_|$)|_(?:at|on)$/i,Te=/^(\d{4}-\d{2}-\d{2})T00:00:00(?:\.0+)?(?:Z|\+00:00)$/,Be=/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;function de(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()!==""&&Number.isFinite(Number(t)))return Number(t)}function Pe(t){if(t==="currency"||t==="percent"||t==="number")return t;if(t==="duration")return"number"}function Ne(t,s=[],e){const o=Pe(e);if(o)return o;if(Le.test(t))return"date";if(se.test(t)&&oe.test(t))return"currency";if(Ie.test(t))return"percent";if(se.test(t))return"number";if(We.test(t))return"integer";if(oe.test(t))return"currency";const l=s.filter(r=>r!=null&&r!=="");return l.length===0?"text":l.every(r=>typeof r=="boolean")?"boolean":l.every(r=>de(r)!==void 0)?"number":l.every(r=>typeof r=="object")?"json":"text"}function Ee(t,s=!1){return t?{notation:"compact",maximumFractionDigits:1}:s?{maximumFractionDigits:0}:{maximumFractionDigits:2}}function ee(t,s,e=[],o={}){if(s==null)return"";const l=Ne(t,e,o.format),r=de(s);if(l==="date"&&typeof s=="string"){const i=Te.exec(s);if(i)return i[1];const w=Be.exec(s);if(w)return`${w[1]} ${w[2]}`}if(r!==void 0){if(l==="currency")return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",...o.compact?{notation:"compact",maximumFractionDigits:1}:{minimumFractionDigits:2,maximumFractionDigits:2}}).format(r);if(l==="percent"){const i=Math.abs(r)<=1?r:r/100;return new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:2}).format(i)}return new Intl.NumberFormat("en-US",Ee(!!o.compact,l==="integer")).format(r)}return l==="boolean"?s?"Yes":"No":l==="json"||typeof s=="object"?JSON.stringify(s):String(s)}function He(t,s,e){return ee(t,s,[s],{compact:!0,format:e})}const Re=[25,50,100,500];function K(t){return typeof t=="number"?!0:typeof t=="string"?!isNaN(Number(t))&&t.trim()!=="":!1}function De(t){switch(t){case"numeric":return{icon:"#",color:"#79c0ff"};case"date":return{icon:"D",color:"#e3b341"};case"bool":return{icon:"B",color:"#a371f7"};case"json":return{icon:"{}",color:"#ff7b72"};case"string":default:return{icon:"A",color:"#56d364"}}}function Oe(t){return t==null?"":typeof t=="object"?JSON.stringify(t):String(t)}function Ve(t,s){return t==null?1:s==null?-1:K(t)&&K(s)?Number(t)-Number(s):String(t).localeCompare(String(s))}function Ye(t,s){const e=i=>i.includes(",")||i.includes('"')||i.includes(`
|
|
17
|
-
`)?`"${i.replace(/"/g,'""')}"`:i,o=t.columns.map(e).join(","),l=t.rows.map(i=>t.columns.map(w=>e(Oe(i[w]))).join(",")),r=[o,...l].join(`
|
|
18
|
-
`);xe(r,"export.csv","text/csv")}function Ge(t,s){const e=JSON.stringify(t.rows,null,2);xe(e,"export.json","application/json")}function xe(t,s,e){const o=new Blob([t],{type:e}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download=s,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(l)}function qe({dir:t,color:s}){return t?n.jsx("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,style:{marginLeft:3,flexShrink:0},children:t==="asc"?n.jsx("path",{d:"M4 0L7 4H1L4 0Z"}):n.jsx("path",{d:"M4 10L1 6H7L4 10Z"})}):n.jsxs("svg",{width:"8",height:"10",viewBox:"0 0 8 10",fill:s,opacity:.3,style:{marginLeft:3,flexShrink:0},children:[n.jsx("path",{d:"M4 0L7 3.5H1L4 0Z"}),n.jsx("path",{d:"M4 10L1 6.5H7L4 10Z"})]})}function J({result:t,themeMode:s}){const e=H[s],[o,l]=T.useState(null),[r,i]=T.useState(null),[w,A]=T.useState(null),[y,j]=T.useState(""),[b,v]=T.useState(50),[M,p]=T.useState(0),u=T.useCallback(a=>{r===a?w==="asc"?A("desc"):w==="desc"?(i(null),A(null)):A("asc"):(i(a),A("asc")),p(0)},[r,w]),S=T.useMemo(()=>{if(!y.trim())return t.rows;const a=y.toLowerCase();return t.rows.filter(x=>t.columns.some(k=>{const f=x[k];return f==null?!1:String(f).toLowerCase().includes(a)}))},[t.rows,t.columns,y]),m=T.useMemo(()=>{if(!r||!w)return S;const a=[...S];return a.sort((x,k)=>{const f=Ve(x[r],k[r]);return w==="desc"?-f:f}),a},[S,r,w]),d=T.useMemo(()=>{const a=new Map;for(const x of t.columns)a.set(x,Fe(x,t.rows));return a},[t.columns,t.rows]),c=T.useMemo(()=>new Map(t.columns.map(a=>[a,t.rows.map(x=>x[a])])),[t.columns,t.rows]),[z,I]=T.useState(!1),F=Math.max(1,Math.ceil(m.length/b)),g=Math.min(M,F-1),_=m.slice(g*b,(g+1)*b);return t.columns.length===0?n.jsx("div",{style:{padding:"12px 16px",color:e.textMuted,fontSize:12,fontFamily:e.font,fontStyle:"italic"},children:"Query executed successfully. No columns to display."}):n.jsxs("div",{children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 8px",borderBottom:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,flexWrap:"wrap"},children:[n.jsxs("div",{style:{position:"relative",flex:"0 1 200px",minWidth:120},children:[n.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:e.textMuted,style:{position:"absolute",left:6,top:6},children:n.jsx("path",{d:"M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982 7.922l3.04 3.04a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215ZM11.5 7a4.499 4.499 0 1 0-8.997 0A4.499 4.499 0 0 0 11.5 7Z"})}),n.jsx("input",{value:y,onChange:a=>{j(a.target.value),p(0)},placeholder:"Filter rows...",style:{width:"100%",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:4,color:e.textPrimary,fontSize:11,fontFamily:e.font,padding:"3px 8px 3px 22px",outline:"none"}}),y&&n.jsx("button",{onClick:()=>j(""),style:{position:"absolute",right:4,top:3,background:"none",border:"none",color:e.textMuted,cursor:"pointer",fontSize:12,padding:"0 2px"},children:"×"})]}),n.jsxs("span",{style:{fontSize:10,color:e.textMuted,fontFamily:e.font},children:[y?`${m.length} of ${t.rows.length}`:`${t.rows.length}`," ",t.rows.length===1?"row":"rows"]}),n.jsx("div",{style:{flex:1}}),n.jsx(le,{label:"CSV",onClick:()=>Ye(t),t:e}),n.jsx(le,{label:"JSON",onClick:()=>Ge(t),t:e}),n.jsx("select",{value:b,onChange:a=>{v(Number(a.target.value)),p(0)},style:{background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:3,color:e.textSecondary,fontSize:10,fontFamily:e.font,padding:"2px 4px",outline:"none"},children:Re.map(a=>n.jsxs("option",{value:a,children:[a," / page"]},a))}),F>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(G,{disabled:g===0,onClick:()=>p(0),t:e,children:"«"}),n.jsx(G,{disabled:g===0,onClick:()=>p(g-1),t:e,children:"‹"}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,padding:"0 4px"},children:[g+1,"/",F]}),n.jsx(G,{disabled:g>=F-1,onClick:()=>p(g+1),t:e,children:"›"}),n.jsx(G,{disabled:g>=F-1,onClick:()=>p(F-1),t:e,children:"»"})]})]}),n.jsx("div",{style:{maxHeight:440,overflow:"auto",position:"relative"},onScroll:a=>I(a.target.scrollTop>0),children:n.jsxs("table",{style:{width:"100%",borderCollapse:"separate",borderSpacing:0,tableLayout:"auto",fontSize:12.5,fontFamily:e.fontMono},children:[n.jsx("thead",{children:n.jsx("tr",{children:t.columns.map(a=>{const x=d.get(a)??"string",k=x==="numeric";return n.jsx("th",{onClick:()=>u(a),style:{background:e.tableHeaderBg,color:e.textSecondary,fontWeight:600,fontSize:11,textAlign:k?"right":"left",padding:"8px 14px",borderBottom:`1px solid ${e.tableBorder}`,minWidth:80,maxWidth:320,whiteSpace:"nowrap",position:"sticky",top:0,zIndex:1,fontFamily:e.font,letterSpacing:"0.03em",overflow:"hidden",textOverflow:"ellipsis",cursor:"pointer",userSelect:"none",boxShadow:z?"0 2px 4px -2px rgba(0,0,0,0.18)":"none",transition:"background 0.1s, box-shadow 0.18s"},children:n.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,justifyContent:k?"flex-end":"flex-start"},children:[(()=>{const f=De(x);return n.jsx("span",{title:x,style:{fontSize:9,fontFamily:e.fontMono,fontWeight:700,color:f.color,background:`${f.color}15`,border:`1px solid ${f.color}40`,borderRadius:3,padding:"0 4px",minWidth:14,textAlign:"center",lineHeight:"14px",flexShrink:0},children:f.icon})})(),n.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:a}),n.jsx(qe,{dir:r===a?w:null,color:r===a?e.accent:e.textMuted})]})},a)})})}),n.jsx("tbody",{children:_.map((a,x)=>{const k=o===x,W=x%2===1?e.tableHeaderBg:"transparent";return n.jsx("tr",{onMouseEnter:()=>l(x),onMouseLeave:()=>l(null),style:{transition:"background 0.1s"},children:t.columns.map(B=>{const P=a[B],h=P==null,$=K(P);return n.jsx("td",{style:{padding:"7px 14px",borderBottom:`1px solid ${e.tableBorder}`,background:k?e.tableRowHover:W,color:h?e.textMuted:e.textPrimary,fontStyle:h?"italic":"normal",fontVariantNumeric:$?"tabular-nums":"normal",textAlign:$?"right":"left",whiteSpace:"nowrap",maxWidth:320,overflow:"hidden",textOverflow:"ellipsis",transition:"background 0.1s"},children:h?"—":ee(B,P,c.get(B)??[])},B)})},x)})})]})}),n.jsxs("div",{style:{padding:"5px 10px",color:e.textMuted,fontSize:10,fontFamily:e.font,borderTop:`1px solid ${e.tableBorder}`,background:`${e.tableHeaderBg}60`,display:"flex",alignItems:"center",gap:4},children:[F>1&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[n.jsx(G,{disabled:g===0,onClick:()=>p(g-1),t:e,children:"‹"}),Ue(F,g).map((a,x)=>a==="…"?n.jsx("span",{style:{color:e.textMuted,fontSize:10,padding:"0 2px"},children:"…"},`gap-${x}`):n.jsx("button",{onClick:()=>p(a-1),style:{background:a-1===g?`${e.accent}20`:"transparent",border:"none",color:a-1===g?e.accent:e.textSecondary,fontSize:10,fontFamily:e.font,fontWeight:a-1===g?700:400,padding:"1px 6px",borderRadius:3,cursor:"pointer",minWidth:20},children:a},a)),n.jsx(G,{disabled:g>=F-1,onClick:()=>p(g+1),t:e,children:"›"})]}),n.jsx("div",{style:{flex:1}}),n.jsxs("span",{style:{fontSize:10,color:e.textSecondary,fontFamily:e.font,marginLeft:6,whiteSpace:"nowrap"},children:[m.length.toLocaleString()," ",m.length===1?"row":"rows",y&&t.rows.length!==m.length&&` of ${t.rows.length.toLocaleString()}`]})]})]})}function Ue(t,s){if(t<=7)return Array.from({length:t},(l,r)=>r+1);const e=s+1,o=[1];e>3&&o.push("…");for(let l=Math.max(2,e-1);l<=Math.min(t-1,e+1);l++)o.push(l);return e<t-2&&o.push("…"),o.push(t),o}function le({label:t,onClick:s,t:e}){const[o,l]=T.useState(!1);return n.jsxs("button",{onClick:s,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:o?e.btnHover:"transparent",border:`1px solid ${o?e.btnBorder:"transparent"}`,borderRadius:3,cursor:"pointer",color:o?e.textSecondary:e.textMuted,fontSize:10,fontFamily:e.font,fontWeight:600,padding:"2px 6px",transition:"all 0.15s",display:"flex",alignItems:"center",gap:3},children:[n.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 16 16",fill:"currentColor",children:[n.jsx("path",{d:"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z"}),n.jsx("path",{d:"M7.25 7.689V2a.75.75 0 0 1 1.5 0v5.689l1.97-1.97a.749.749 0 1 1 1.06 1.06l-3.25 3.25a.749.749 0 0 1-1.06 0L4.22 6.779a.749.749 0 1 1 1.06-1.06l1.97 1.97Z"})]}),t]})}function G({disabled:t,onClick:s,children:e,t:o}){return n.jsx("button",{disabled:t,onClick:s,style:{background:"transparent",border:"none",cursor:t?"default":"pointer",color:t?o.textMuted:o.textSecondary,fontSize:12,fontFamily:o.font,padding:"0 3px",opacity:t?.4:1,transition:"opacity 0.1s"},children:e})}const gt=[{value:"bar",label:"Bar"},{value:"grouped-bar",label:"Grouped Bar"},{value:"stacked-bar",label:"Stacked Bar"},{value:"line",label:"Line"},{value:"area",label:"Area"},{value:"scatter",label:"Scatter"},{value:"pie",label:"Pie"},{value:"donut",label:"Donut"},{value:"heatmap",label:"Heatmap"},{value:"histogram",label:"Histogram"},{value:"funnel",label:"Funnel"},{value:"sankey",label:"Sankey"},{value:"waterfall",label:"Waterfall"},{value:"gauge",label:"Gauge"},{value:"kpi",label:"KPI"}],Ze=/date|time|at|day|month|year/i,ue=/^(label|name|category|status|type|group)$/i,pe=/^(value|count|total|revenue|amount|sum|avg|price|quantity|sales)$/i;function V(t){return typeof t=="number"?!0:typeof t=="string"?t.trim()!==""&&!isNaN(Number(t)):!1}function Xe(t){return typeof t=="string"||typeof t=="number"}const Ke=new Set(["bar","line","area","pie","donut","scatter","heatmap","funnel","waterfall","histogram","gauge","stacked-bar","grouped-bar","sankey","kpi","table"]);function Je(t,s){if(s!=null&&s.chart){const e=s.chart.toLowerCase().replace(/_/g,"-");if(Ke.has(e))return e}return Qe(t)}function Qe(t){const{columns:s,rows:e}=t;if(s.length<2||e.length===0)return"table";const o=s[0],l=s[1],r=e.slice(0,5),i=r.every(b=>V(b[l])),w=r.every(b=>Xe(b[o]));if(Ze.test(o)&&i&&w)return"line";const A=s.find(b=>ue.test(b)),y=s.find(b=>pe.test(b));return A&&y&&r.every(v=>V(v[y]))?"bar":r.every(b=>V(b[o]))&&i&&s.length>=2?"scatter":s.length===2&&w&&i?"bar":"table"}const Q={default:["#388bfd","#56d364","#e3b341","#f78166","#a371f7","#39c5cf","#ffa657","#ff7b72","#89d185","#d2a8ff","#58a6ff","#3fb950"],warm:["#f85149","#f78166","#ffa657","#e3b341","#d29922","#db6d28","#ff7b72","#ffa198","#ffdfb6","#e6c174","#c4a35a","#b08c3e"],cool:["#388bfd","#58a6ff","#79c0ff","#39c5cf","#56d364","#3fb950","#a371f7","#d2a8ff","#bc8cff","#6cb6ff","#2ea043","#1f6feb"],mono:["#c9d1d9","#b1bac4","#8b949e","#6e7681","#484f58","#30363d","#21262d","#161b22","#a0a8b2","#9e9e9e","#757575","#616161"],pastel:["#b8d8f8","#b4e6c8","#f4e6a0","#f8c4a4","#d2b8f0","#a8e0e0","#f8d8a0","#f4b8b4","#c0e8c0","#e0d0f8","#a8d8f8","#b0e8b0"],corporate:["#2563eb","#16a34a","#7c3aed","#0891b2","#f59e0b","#dc2626","#475569","#0f766e","#9333ea","#0284c7","#65a30d","#ea580c"]};function D(t){return Q[t??"default"]??Q.default}function N(t,s="value",e){return He(s,t,e)}function re(t,s=8){if(/^\d{4}-\d{2}(-\d{2})?/.test(t)){const e=/^\d{4}-\d{2}$/.test(t),o=new Date(e?`${t}-01T00:00:00Z`:t);if(!isNaN(o.getTime()))return o.toLocaleDateString("en-US",e?{year:"numeric",month:"short",timeZone:"UTC"}:{month:"short",day:"numeric",timeZone:"UTC"})}return String(t).length>s?String(t).slice(0,s):String(t)}function q(t,s){const e=(s!=null&&s.x&&t.columns.includes(s.x)?s.x:void 0)??t.columns.find(l=>ue.test(l))??t.columns[0],o=(s!=null&&s.y&&t.columns.includes(s.y)?s.y:void 0)??t.columns.find(l=>pe.test(l))??t.columns[1];return{labelCol:e,valueCol:o}}const Y=20;function te({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),{labelCol:i,valueCol:w}=q(t,e),A=(e==null?void 0:e.maxItems)??Y,y=D(e==null?void 0:e.colorPalette),j=t.rows.slice(0,A).map(d=>({label:String(d[i]??""),value:Number(d[w]??0)})),b=t.rows.length>A,v=Math.max(...j.map(d=>d.value),1),M=28,p=120,u=6,S=12,m=j.length*(M+u)+S*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:j.map((d,c)=>{const z=S+c*(M+u),I=600-p-84,F=Math.max(d.value/v*I,2),g=l===c,_=y[c%y.length];return n.jsxs("g",{onMouseEnter:()=>r(c),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("text",{x:p-8,y:z+M/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.label.length>16?d.label.slice(0,15)+"…":d.label}),n.jsx("rect",{x:p,y:z,width:F,height:M,rx:3,fill:_,opacity:g?1:.88,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:p+F+6,y:z+M/2+4,textAnchor:"start",fontSize:11,fontFamily:o.fontMono,fill:o.textMuted,children:N(d.value,w,e==null?void 0:e.format)})]},c)})}),b&&n.jsxs("div",{style:{fontSize:11,color:o.textMuted,fontFamily:o.font,fontStyle:"italic",padding:"4px 12px"},children:["Showing ",Y," of ",t.rows.length," rows"]})]})}function Ce({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),i=D(e==null?void 0:e.colorPalette),w=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==w&&A.some(c=>V(c[d])));if(y.length===0)return n.jsx(te,{result:t,themeMode:s,chartConfig:e});const j=t.rows.slice(0,Y).map(d=>String(d[w]??"")),b=Math.max(...t.rows.slice(0,Y).flatMap(d=>y.map(c=>Math.abs(Number(d[c]??0)))),1),v=24,M=v/y.length,p=120,u=12,S=8,m=j.length*(v+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:j.map((d,c)=>{const z=u+c*(v+S),I=t.rows[c];return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+v/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((F,g)=>{const _=Number(I[F]??0),a=600-p-60,x=Math.max(Math.abs(_)/b*a,1),k=z+g*M,f=`${c}-${g}`;return n.jsxs("g",{onMouseEnter:()=>r(f),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:p,y:k,width:x,height:M-1,rx:2,fill:i[g%i.length],opacity:l===f?1:.85,style:{transition:"opacity 0.15s"}}),l===f&&n.jsx("text",{x:p+x+4,y:k+M/2+3,fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:N(_,F,e==null?void 0:e.format)})]},g)})]},c)})})]})}function et({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),i=D(e==null?void 0:e.colorPalette),w=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=t.rows.slice(0,5),y=t.columns.filter(d=>d!==w&&A.some(c=>V(c[d])));if(y.length===0)return n.jsx(te,{result:t,themeMode:s,chartConfig:e});const j=t.rows.slice(0,Y),b=j.map(d=>String(d[w]??"")),v=Math.max(...j.map(d=>y.reduce((c,z)=>c+Math.abs(Number(d[z]??0)),0)),1),M=28,p=120,u=12,S=6,m=b.length*(M+S)+u*2;return n.jsxs("div",{style:{padding:"8px 0"},children:[n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:y.map((d,c)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:i[c%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:d})]},d))}),n.jsx("svg",{width:"100%",height:m,viewBox:`0 0 600 ${m}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:b.map((d,c)=>{const z=u+c*(M+S),I=j[c],F=600-p-60;let g=p;return n.jsxs("g",{children:[n.jsx("text",{x:p-8,y:z+M/2+4,textAnchor:"end",fontSize:11,fontFamily:o.font,fill:o.textSecondary,children:d.length>16?d.slice(0,15)+"…":d}),y.map((_,a)=>{const x=Math.abs(Number(I[_]??0)),k=Math.max(x/v*F,0),f=g;g+=k;const W=`${c}-${a}`;return n.jsxs("g",{onMouseEnter:()=>r(W),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:f,y:z,width:k,height:M,rx:a===0?3:0,fill:i[a%i.length],opacity:l===W?1:.85,style:{transition:"opacity 0.15s"}}),l===W&&k>30&&n.jsx("text",{x:f+k/2,y:z+M/2+4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:"#fff",fontWeight:600,children:N(x,_,e==null?void 0:e.format)})]},a)})]},c)})})]})}function ie({result:t,themeMode:s,showArea:e,chartConfig:o}){const l=H[s],[r,i]=T.useState(null),A=D(o==null?void 0:o.colorPalette)[0]??l.accent,{labelCol:y,valueCol:j}=q(t,o),b=t.rows.map($=>({label:String($[y]??""),value:Number($[j]??0)}));if(b.length<2)return null;const v=560,M=212,p=56,u=16,S=16,m=48,d=v-p-u,c=M-S-m,z=Math.min(...b.map($=>$.value)),F=Math.max(...b.map($=>$.value))-z||1,g=d/(b.length-1),_=$=>p+$*g,a=$=>S+c-($-z)/F*c,x=b.map(($,L)=>({x:_(L),y:a($.value)})),k=x.reduce(($,L,E)=>{if(E===0)return`M ${L.x},${L.y}`;const R=x[E-1],O=R.x+(L.x-R.x)/2;return`${$} C ${O},${R.y} ${O},${L.y} ${L.x},${L.y}`},""),f=`${k} L ${x[x.length-1].x},${S+c} L ${p},${S+c} Z`,W=5,B=Array.from({length:W+1},($,L)=>{const E=z+F*L/W;return{val:E,y:a(E)}}),P=Math.ceil(b.length/8),h=b.filter(($,L)=>L%P===0||L===b.length-1);return n.jsx("div",{style:{position:"relative",padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:M,viewBox:`0 0 ${v} ${M}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},onMouseLeave:()=>i(null),children:[B.map(($,L)=>n.jsxs("g",{children:[n.jsx("line",{x1:p,y1:$.y,x2:p+d,y2:$.y,stroke:l.tableBorder,strokeWidth:.5}),n.jsx("text",{x:p-6,y:$.y+4,textAnchor:"end",fontSize:10,fontFamily:l.fontMono,fill:l.textMuted,children:N($.val,j,o==null?void 0:o.format)})]},L)),n.jsx("path",{d:f,fill:A,opacity:e?.3:.15}),n.jsx("path",{d:k,fill:"none",stroke:A,strokeWidth:2,strokeLinejoin:"round"}),x.map(($,L)=>n.jsx("circle",{cx:$.x,cy:$.y,r:3,fill:A,style:{cursor:"crosshair"},onMouseEnter:()=>i({x:$.x,y:$.y,label:b[L].label,value:b[L].value})},L)),h.map(($,L)=>{const E=b.indexOf($);return n.jsx("text",{x:_(E),y:S+c+16,textAnchor:"middle",fontSize:10,fontFamily:l.font,fill:l.textMuted,children:re($.label)},L)}),n.jsx("line",{x1:p,y1:S,x2:p,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("line",{x1:p,y1:S+c,x2:p+d,y2:S+c,stroke:l.tableBorder,strokeWidth:1}),n.jsx("text",{x:p+d/2,y:M-4,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",children:y}),n.jsx("text",{x:12,y:S+c/2,textAnchor:"middle",fontSize:10,fontWeight:600,fontFamily:l.font,fill:l.textMuted,letterSpacing:"0.04em",transform:`rotate(-90, 12, ${S+c/2})`,children:j}),r&&n.jsxs("g",{children:[n.jsx("rect",{x:r.x+8,y:r.y-20,width:90,height:32,rx:4,fill:l.cellBg,stroke:l.cellBorder,strokeWidth:1}),n.jsx("text",{x:r.x+13,y:r.y-8,fontSize:10,fontFamily:l.font,fill:l.textSecondary,children:re(r.label,12)}),n.jsx("text",{x:r.x+13,y:r.y+6,fontSize:11,fontFamily:l.fontMono,fill:l.textPrimary,fontWeight:600,children:N(r.value,j,o==null?void 0:o.format)})]})]})})}function tt({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),i=D(e==null?void 0:e.colorPalette),w=e!=null&&e.x&&t.columns.includes(e.x)?e.x:t.columns[0],A=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns[1],y=e!=null&&e.color&&t.columns.includes(e.color)?e.color:void 0,j=t.rows.slice(0,200).map(f=>({x:Number(f[w]??0),y:Number(f[A]??0),color:y?String(f[y]??""):void 0})),b=560,v=300,M=52,p=16,u=16,S=36,m=b-M-p,d=v-u-S,c=Math.min(...j.map(f=>f.x)),z=Math.max(...j.map(f=>f.x)),I=Math.min(...j.map(f=>f.y)),F=Math.max(...j.map(f=>f.y)),g=z-c||1,_=F-I||1,a=f=>M+(f-c)/g*m,x=f=>u+d-(f-I)/_*d,k=y?[...new Set(j.map(f=>f.color))]:[];return n.jsxs("div",{style:{padding:"8px 0"},children:[y&&k.length>0&&n.jsx("div",{style:{display:"flex",gap:12,padding:"0 12px 6px",flexWrap:"wrap"},children:k.slice(0,12).map((f,W)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[n.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:i[W%i.length]}}),n.jsx("span",{style:{fontSize:10,fontFamily:o.font,color:o.textSecondary},children:f})]},f))}),n.jsxs("svg",{width:"100%",height:v,viewBox:`0 0 ${b} ${v}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(f,W)=>{const B=I+_*W/5,P=x(B);return n.jsxs("g",{children:[n.jsx("line",{x1:M,y1:P,x2:M+m,y2:P,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:M-6,y:P+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:N(B,A,e==null?void 0:e.format)})]},W)}),Array.from({length:6},(f,W)=>{const B=c+g*W/5,P=a(B);return n.jsx("text",{x:P,y:u+d+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:N(B,w)},W)}),n.jsx("line",{x1:M,y1:u,x2:M,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:M,y1:u+d,x2:M+m,y2:u+d,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:M+m/2,y:v-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:w}),n.jsx("text",{x:10,y:u+d/2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-90, 10, ${u+d/2})`,children:A}),j.map((f,W)=>{const B=y?k.indexOf(f.color):0;return n.jsx("circle",{cx:a(f.x),cy:x(f.y),r:l===W?5:3.5,fill:i[B%i.length],opacity:l===W?1:.7,style:{cursor:"crosshair",transition:"r 0.1s, opacity 0.1s"},onMouseEnter:()=>r(W),onMouseLeave:()=>r(null)},W)}),l!==null&&n.jsxs("g",{children:[n.jsx("rect",{x:a(j[l].x)+8,y:x(j[l].y)-24,width:100,height:28,rx:4,fill:o.cellBg,stroke:o.cellBorder,strokeWidth:1}),n.jsxs("text",{x:a(j[l].x)+13,y:x(j[l].y)-8,fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:["(",N(j[l].x,w),", ",N(j[l].y,A,e==null?void 0:e.format),")"]})]})]})]})}const nt=12;function ae({result:t,themeMode:s,chartConfig:e,isDonut:o}){const l=H[s],[r,i]=T.useState(null),{labelCol:w,valueCol:A}=q(t,e),y=D(e==null?void 0:e.colorPalette),j=t.rows.slice(0,nt).map(c=>({label:String(c[w]??""),value:Math.abs(Number(c[A]??0))})),b=j.reduce((c,z)=>c+z.value,0)||1,v=90,M=90,p=70,u=o?40:0,S=[];let m=-Math.PI/2;j.forEach((c,z)=>{const I=c.value/b*2*Math.PI,F=m,g=m+I,_=v+p*Math.cos(F),a=M+p*Math.sin(F),x=v+p*Math.cos(g),k=M+p*Math.sin(g),f=I>Math.PI?1:0;let W;if(u>0){const B=v+u*Math.cos(F),P=M+u*Math.sin(F),h=v+u*Math.cos(g),$=M+u*Math.sin(g);W=`M ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${k} L ${h} ${$} A ${u} ${u} 0 ${f} 0 ${B} ${P} Z`}else W=`M ${v} ${M} L ${_} ${a} A ${p} ${p} 0 ${f} 1 ${x} ${k} Z`;S.push({path:W,color:y[z%y.length],label:c.label,value:c.value,pct:c.value/b*100}),m=g});const d=r!==null?S[r]:null;return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"8px 12px",flexWrap:"wrap"},children:[n.jsxs("svg",{width:180,height:180,style:{flexShrink:0},onMouseLeave:()=>i(null),children:[S.map((c,z)=>n.jsx("path",{d:c.path,fill:c.color,opacity:r===null||r===z?1:.55,style:{cursor:"pointer",transition:"opacity 0.15s"},onMouseEnter:()=>i(z)},z)),o&&n.jsxs(n.Fragment,{children:[n.jsx("text",{x:v,y:M-5,textAnchor:"middle",fontSize:11,fontFamily:l.fontMono,fill:l.textSecondary,children:N(d?d.value:b,A,e==null?void 0:e.format)}),n.jsx("text",{x:v,y:M+9,textAnchor:"middle",fontSize:9,fontFamily:l.font,fill:l.textMuted,children:d?`${d.pct.toFixed(1)}%`:"total"})]})]}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,maxHeight:180,overflowY:"auto",flex:1},children:S.map((c,z)=>n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,cursor:"default",opacity:r===null||r===z?1:.5},onMouseEnter:()=>i(z),onMouseLeave:()=>i(null),children:[n.jsx("div",{style:{width:10,height:10,borderRadius:2,background:c.color,flexShrink:0}}),n.jsx("span",{style:{fontSize:11,fontFamily:l.font,color:l.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c.label}),n.jsxs("span",{style:{fontSize:11,fontFamily:l.fontMono,color:l.textMuted,marginLeft:"auto",flexShrink:0},children:[c.pct.toFixed(1),"%"]})]},z))})]})}function ot({result:t,themeMode:s}){const e=H[s],[o,l]=T.useState(null),r=t.columns[0],i=t.columns.slice(1),w=t.rows.slice(0,30),A=w.flatMap(S=>i.map(m=>Number(S[m]??0))),y=Math.min(...A),b=Math.max(...A)-y||1,v=Math.min(50,480/i.length),M=24,p=100;function u(S){const m=(S-y)/b,d=Math.round(56+m*192),c=Math.round(139+m*-58),z=Math.round(253+m*-180);return`rgb(${d},${c},${z})`}return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{width:p+i.length*v+20,height:w.length*M+M+16,style:{display:"block",overflow:"visible"},children:[i.map((S,m)=>n.jsx("text",{x:p+m*v+v/2,y:14,textAnchor:"middle",fontSize:9,fontFamily:e.font,fill:e.textMuted,transform:`rotate(-30, ${p+m*v+v/2}, 14)`,children:S.length>8?S.slice(0,7)+"…":S},m)),w.map((S,m)=>{const d=String(S[r]??""),c=M+m*M;return n.jsxs("g",{children:[n.jsx("text",{x:p-6,y:c+M/2+4,textAnchor:"end",fontSize:10,fontFamily:e.font,fill:e.textSecondary,children:d.length>14?d.slice(0,13)+"…":d}),i.map((z,I)=>{const F=Number(S[z]??0),g=(o==null?void 0:o.r)===m&&(o==null?void 0:o.c)===I;return n.jsxs("g",{onMouseEnter:()=>l({r:m,c:I}),onMouseLeave:()=>l(null),children:[n.jsx("rect",{x:p+I*v,y:c,width:v-1,height:M-1,rx:2,fill:u(F),opacity:g?1:.85,stroke:g?e.accent:"none",strokeWidth:g?1.5:0}),g&&n.jsx("text",{x:p+I*v+v/2,y:c+M/2+4,textAnchor:"middle",fontSize:10,fontFamily:e.fontMono,fill:"#fff",fontWeight:600,children:N(F,z)})]},I)})]},m)})]})})}function st({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),w=D(e==null?void 0:e.colorPalette)[0]??o.accent,A=(e!=null&&e.x&&t.columns.includes(e.x)?e.x:void 0)??t.columns.find(x=>t.rows.slice(0,5).some(k=>V(k[x])))??t.columns[0],y=t.rows.map(x=>Number(x[A]??0)).filter(x=>!isNaN(x));if(y.length===0)return null;const j=Math.min(20,Math.max(5,Math.ceil(Math.sqrt(y.length)))),b=Math.min(...y),p=(Math.max(...y)-b||1)/j,u=Array.from({length:j},(x,k)=>({low:b+k*p,high:b+(k+1)*p,count:0}));y.forEach(x=>{const k=Math.min(Math.floor((x-b)/p),j-1);u[k].count++});const S=Math.max(...u.map(x=>x.count),1),m=560,d=200,c=52,z=16,I=16,F=36,g=m-c-z,_=d-I-F,a=g/j;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:d,viewBox:`0 0 ${m} ${d}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:5},(x,k)=>{const f=S*(k+1)/5,W=I+_-f/S*_;return n.jsxs("g",{children:[n.jsx("line",{x1:c,y1:W,x2:c+g,y2:W,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:c-6,y:W+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:Math.round(f)})]},k)}),u.map((x,k)=>{const f=x.count/S*_,W=c+k*a,B=I+_-f,P=l===k;return n.jsxs("g",{onMouseEnter:()=>r(k),onMouseLeave:()=>r(null),children:[n.jsx("rect",{x:W+1,y:B,width:a-2,height:f,rx:1,fill:w,opacity:P?1:.85,style:{transition:"opacity 0.1s"}}),P&&n.jsx("text",{x:W+a/2,y:B-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:x.count})]},k)}),u.filter((x,k)=>k%Math.ceil(j/6)===0).map((x,k)=>{const f=u.indexOf(x);return n.jsx("text",{x:c+f*a+a/2,y:I+_+16,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:N(x.low,A,e==null?void 0:e.format)},k)}),n.jsx("line",{x1:c,y1:I,x2:c,y2:I+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:c,y1:I+_,x2:c+g,y2:I+_,stroke:o.tableBorder,strokeWidth:1}),n.jsx("text",{x:c+g/2,y:d-2,textAnchor:"middle",fontSize:10,fontFamily:o.font,fill:o.textMuted,children:A})]})})}function lt({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),{labelCol:i,valueCol:w}=q(t,e),A=D(e==null?void 0:e.colorPalette),y=t.rows.slice(0,10).map(m=>({label:String(m[i]??""),value:Math.abs(Number(m[w]??0))}));if(y.length===0)return null;const j=y[0].value||1,b=400,v=36,M=4,p=16,u=y.length*(v+M)+p*2,S=b/2;return n.jsx("div",{style:{padding:"8px 0",display:"flex",justifyContent:"center"},children:n.jsx("svg",{width:b,height:u,style:{display:"block"},children:y.map((m,d)=>{const c=p+d*(v+M),z=m.value/j,I=Math.max(z*(b-80),40),F=l===d,g=d<y.length-1?y[d+1].value/j:z*.8,_=Math.max(g*(b-80),40),a=S-I/2,x=S+I/2,k=S+_/2,f=S-_/2,W=`M ${a} ${c} L ${x} ${c} L ${k} ${c+v} L ${f} ${c+v} Z`;return n.jsxs("g",{onMouseEnter:()=>r(d),onMouseLeave:()=>r(null),style:{cursor:"default"},children:[n.jsx("path",{d:W,fill:A[d%A.length],opacity:F?1:.85,style:{transition:"opacity 0.15s"}}),n.jsx("text",{x:S,y:c+v/2+1,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:"#fff",fontWeight:500,children:m.label}),n.jsxs("text",{x:S,y:c+v/2+13,textAnchor:"middle",fontSize:9,fontFamily:o.fontMono,fill:"rgba(255,255,255,0.7)",children:[N(m.value,w,e==null?void 0:e.format)," (",(z*100).toFixed(0),"%)"]})]},d)})})})}function rt({result:t,themeMode:s,chartConfig:e}){const o=H[s],l=D(e==null?void 0:e.colorPalette),[r,i]=T.useState(null),w=t.rows.slice(0,20),A=t.columns.filter(h=>w.some($=>V($[h]))),y=t.columns.filter(h=>!A.includes(h)),j=e!=null&&e.x&&y.includes(e.x)?e.x:y.find(h=>/(?:^|_)(?:source|from|origin|upstream|supplier|producer|category)(?:_|$)/i.test(h))??y[0],b=e!=null&&e.color&&y.includes(e.color)&&e.color!==j?e.color:y.find(h=>h!==j&&/(?:^|_)(?:target|to|destination|downstream|consumer|customer|product)(?:_|$)/i.test(h))??y.find(h=>h!==j),v=e!=null&&e.y&&A.includes(e.y)?e.y:A[0];if(!j||!b||!v)return n.jsx(J,{result:t,themeMode:s});const M=new Map;for(const h of t.rows){const $=String(h[j]??"").trim(),L=String(h[b]??"").trim(),E=Math.abs(Number(h[v]??0));if(!$||!L||!Number.isFinite(E)||E<=0)continue;const R=`${$}\0${L}`,O=M.get(R);M.set(R,{source:$,target:L,value:((O==null?void 0:O.value)??0)+E})}const p=[...M.values()].sort((h,$)=>$.value-h.value);if(p.length===0)return n.jsx(J,{result:t,themeMode:s});const u=new Map,S=new Map;p.forEach(h=>{u.set(h.source,(u.get(h.source)??0)+h.value),S.set(h.target,(S.get(h.target)??0)+h.value)});const m=[...u].sort((h,$)=>$[1]-h[1]).slice(0,12).map(([h])=>h),d=[...S].sort((h,$)=>$[1]-h[1]).slice(0,12).map(([h])=>h),c=new Set(m),z=new Set(d),I=p.filter(h=>c.has(h.source)&&z.has(h.target)).slice(0,40),F=Math.max(...I.map(h=>h.value),1),g=640,_=Math.max(250,Math.max(m.length,d.length)*34+40),a=132,x=g-144,k=12,f=28,W=(h,$)=>$<=1?_/2:f+h*((_-f*2)/($-1)),B=new Map(m.map((h,$)=>[h,$])),P=new Map(d.map((h,$)=>[h,$]));return n.jsx("div",{style:{padding:"8px 0",overflowX:"auto"},children:n.jsxs("svg",{role:"img","aria-label":`${j} to ${b} flow by ${v}`,width:"100%",height:_,viewBox:`0 0 ${g} ${_}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",minWidth:520},children:[n.jsx("text",{x:a,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:j}),n.jsx("text",{x,y:14,textAnchor:"middle",fontSize:10,fontWeight:700,fontFamily:o.font,fill:o.textMuted,children:b}),I.map((h,$)=>{const L=W(B.get(h.source)??0,m.length),E=W(P.get(h.target)??0,d.length),R=`${h.source}\0${h.target}`,O=r===R,fe=`M ${a+k},${L} C ${a+150},${L} ${x-150},${E} ${x},${E}`,U=g/2,Z=(L+E)/2;return n.jsxs("g",{onMouseEnter:()=>i(R),onMouseLeave:()=>i(null),children:[n.jsx("path",{d:fe,fill:"none",stroke:l[$%l.length],strokeWidth:Math.max(2,h.value/F*18),opacity:r===null||O?.7:.14,strokeLinecap:"round",style:{transition:"opacity 0.15s",cursor:"default"}}),O?n.jsxs("g",{pointerEvents:"none",children:[n.jsx("rect",{x:U-72,y:Z-18,width:144,height:36,rx:5,fill:o.cellBg,stroke:o.cellBorder}),n.jsxs("text",{x:U,y:Z-3,textAnchor:"middle",fontSize:9.5,fontFamily:o.font,fill:o.textSecondary,children:[h.source," → ",h.target]}),n.jsx("text",{x:U,y:Z+11,textAnchor:"middle",fontSize:11,fontWeight:700,fontFamily:o.fontMono,fill:o.textPrimary,children:N(h.value,v,e==null?void 0:e.format)})]}):null]},R)}),m.map((h,$)=>{const L=W($,m.length);return n.jsxs("g",{children:[n.jsx("rect",{x:a,y:L-9,width:k,height:18,rx:3,fill:l[$%l.length]}),n.jsx("text",{x:a-7,y:L+3,textAnchor:"end",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`source-${h}`)}),d.map((h,$)=>{const L=W($,d.length);return n.jsxs("g",{children:[n.jsx("rect",{x,y:L-9,width:k,height:18,rx:3,fill:l[($+m.length)%l.length]}),n.jsx("text",{x:x+k+7,y:L+3,textAnchor:"start",fontSize:10.5,fontFamily:o.font,fill:o.textSecondary,children:h.length>18?`${h.slice(0,17)}…`:h})]},`target-${h}`)})]})})}function it({result:t,themeMode:s,chartConfig:e}){const o=H[s],[l,r]=T.useState(null),{labelCol:i,valueCol:w}=q(t,e),A=t.rows.slice(0,15).map(a=>({label:String(a[i]??""),value:Number(a[w]??0)}));if(A.length===0)return null;let y=0;const j=A.map(a=>{const x=y;return y+=a.value,{...a,start:x,end:y}}),b=j.flatMap(a=>[a.start,a.end]),v=Math.min(0,...b),p=Math.max(0,...b)-v||1,u=560,S=240,m=52,d=16,c=16,z=44,I=u-m-d,F=S-c-z,g=I/j.length,_=a=>c+F-(a-v)/p*F;return n.jsx("div",{style:{padding:"8px 0"},children:n.jsxs("svg",{width:"100%",height:S,viewBox:`0 0 ${u} ${S}`,preserveAspectRatio:"xMidYMid meet",style:{display:"block",overflow:"visible"},children:[Array.from({length:6},(a,x)=>{const k=v+p*x/5,f=_(k);return n.jsxs("g",{children:[n.jsx("line",{x1:m,y1:f,x2:m+I,y2:f,stroke:o.tableBorder,strokeWidth:.5}),n.jsx("text",{x:m-6,y:f+4,textAnchor:"end",fontSize:10,fontFamily:o.fontMono,fill:o.textMuted,children:N(k,w,e==null?void 0:e.format)})]},x)}),n.jsx("line",{x1:m,y1:_(0),x2:m+I,y2:_(0),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"3,3"}),j.map((a,x)=>{const k=m+x*g,f=_(Math.max(a.start,a.end)),B=_(Math.min(a.start,a.end))-f,P=a.value>=0,h=l===x;return n.jsxs("g",{onMouseEnter:()=>r(x),onMouseLeave:()=>r(null),children:[x<j.length-1&&n.jsx("line",{x1:k+g-2,y1:_(a.end),x2:k+g+2,y2:_(a.end),stroke:o.textMuted,strokeWidth:1,strokeDasharray:"2,2"}),n.jsx("rect",{x:k+4,y:f,width:g-8,height:Math.max(B,1),rx:2,fill:P?o.success:o.error,opacity:h?1:.8,style:{transition:"opacity 0.1s"}}),h&&n.jsxs("text",{x:k+g/2,y:f-4,textAnchor:"middle",fontSize:10,fontFamily:o.fontMono,fill:o.textPrimary,children:[a.value>=0?"+":"",N(a.value,w,e==null?void 0:e.format)]})]},x)}),j.map((a,x)=>n.jsx("text",{x:m+x*g+g/2,y:S-6,textAnchor:"middle",fontSize:9,fontFamily:o.font,fill:o.textMuted,transform:`rotate(-20, ${m+x*g+g/2}, ${S-6})`,children:a.label.length>8?a.label.slice(0,7)+"…":a.label},x)),n.jsx("line",{x1:m,y1:c,x2:m,y2:c+F,stroke:o.tableBorder,strokeWidth:1}),n.jsx("line",{x1:m,y1:c+F,x2:m+I,y2:c+F,stroke:o.tableBorder,strokeWidth:1})]})})}function at({result:t,themeMode:s,chartConfig:e}){const o=H[s],l=t.rows[0];if(!l)return null;const r=(e!=null&&e.y&&t.columns.includes(e.y)?e.y:void 0)??t.columns.find(_=>V(l[_]))??t.columns[0],i=Number(l[r]??0),w=(e==null?void 0:e.title)??r,A=i>100?i*1.2:100,y=Math.min(Math.max(i/A,0),1),j=120,b=110,v=80,M=Math.PI,p=0,u=M-(M-p)*y,S=j+v*Math.cos(M),m=b+v*Math.sin(M),d=j+v*Math.cos(u),c=b+v*Math.sin(u),z=y>.5?1:0,I=j+v*Math.cos(p),F=b+v*Math.sin(p),g=y<.33?o.error:y<.66?o.warning:o.success;return n.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"16px 24px"},children:n.jsxs("svg",{width:240,height:140,style:{display:"block",overflow:"visible"},children:[n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 1 1 ${I} ${F}`,fill:"none",stroke:o.tableBorder,strokeWidth:12,strokeLinecap:"round"}),y>0&&n.jsx("path",{d:`M ${S} ${m} A ${v} ${v} 0 ${z} 1 ${d} ${c}`,fill:"none",stroke:g,strokeWidth:12,strokeLinecap:"round"}),n.jsx("text",{x:j,y:b-4,textAnchor:"middle",fontSize:28,fontFamily:o.fontMono,fill:g,fontWeight:700,children:N(i,r,e==null?void 0:e.format)}),n.jsx("text",{x:j,y:b+16,textAnchor:"middle",fontSize:11,fontFamily:o.font,fill:o.textMuted,children:w})]})})}function ct(t,s,e,o){const l=Number(s);return s==null||typeof s!="number"&&isNaN(l)?s==null?"—":String(s):ee(t,s,e,{compact:Math.abs(l)>=1e5,format:o})}function me({result:t,themeMode:s,chartConfig:e}){const o=H[s],l=D(e==null?void 0:e.colorPalette),r=t.rows[0];if(!r)return null;const i=e!=null&&e.y&&t.columns.includes(e.y)?e.y:t.columns.find(A=>V(r[A]))??t.columns[0],w=ct(i,r[i],t.rows.map(A=>A[i]),e==null?void 0:e.format);return n.jsx("div",{style:{containerType:"inline-size",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:"8px 4px",boxSizing:"border-box",minWidth:0},children:n.jsx("span",{title:String(r[i]),style:{fontSize:"clamp(14px, 13cqw, 40px)",fontWeight:750,fontFamily:o.fontMono,color:l[0]??o.accent,lineHeight:1.1,maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w})})}function dt({config:t,columns:s,onChange:e,onClose:o,t:l}){const r={background:l.inputBg,border:`1px solid ${l.inputBorder}`,borderRadius:4,color:l.textPrimary,fontSize:11,fontFamily:l.font,padding:"4px 8px",outline:"none",width:"100%",boxSizing:"border-box"};return n.jsxs("div",{style:{position:"absolute",top:4,right:4,zIndex:100,background:l.cellBg,border:`1px solid ${l.headerBorder}`,borderRadius:8,padding:12,width:240,boxShadow:"0 4px 16px rgba(0,0,0,0.3)",display:"grid",gap:8},onClick:i=>i.stopPropagation(),children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[n.jsx("span",{style:{fontSize:11,fontWeight:600,color:l.textPrimary,fontFamily:l.font},children:"Chart Settings"}),n.jsx("button",{onClick:o,style:{background:"none",border:"none",color:l.textMuted,cursor:"pointer",fontSize:14},children:"×"})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Title",n.jsx("input",{value:t.title??"",onChange:i=>e({title:i.target.value||void 0}),placeholder:"Chart title",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["X-axis label",n.jsx("input",{value:t.xLabel??"",onChange:i=>e({xLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Y-axis label",n.jsx("input",{value:t.yLabel??"",onChange:i=>e({yLabel:i.target.value||void 0}),placeholder:"Auto",style:{...r,marginTop:2}})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Legend",n.jsxs("select",{value:t.legendPosition??"top",onChange:i=>e({legendPosition:i.target.value}),style:{...r,marginTop:2},children:[n.jsx("option",{value:"top",children:"Top"}),n.jsx("option",{value:"bottom",children:"Bottom"}),n.jsx("option",{value:"left",children:"Left"}),n.jsx("option",{value:"right",children:"Right"}),n.jsx("option",{value:"none",children:"Hidden"})]})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Color palette",n.jsx("select",{value:t.colorPalette??"default",onChange:i=>e({colorPalette:i.target.value}),style:{...r,marginTop:2},children:Object.keys(Q).map(i=>n.jsx("option",{value:i,children:i.charAt(0).toUpperCase()+i.slice(1)},i))})]}),n.jsxs("label",{style:{fontSize:10,color:l.textMuted,fontFamily:l.font},children:["Max items",n.jsx("input",{type:"number",value:t.maxItems??Y,min:5,max:200,onChange:i=>e({maxItems:parseInt(i.target.value)||Y}),style:{...r,marginTop:2}})]})]})}function St({result:t,themeMode:s,chartConfig:e,onConfigChange:o}){const l=H[s],r=Je(t,e),[i,w]=T.useState(!1);return r==="kpi"?n.jsx(me,{result:t,themeMode:s,chartConfig:e}):n.jsxs("div",{style:{position:"relative"},children:[(e==null?void 0:e.title)&&n.jsx("div",{style:{padding:"8px 12px 0",fontSize:13,fontWeight:600,color:l.textPrimary,fontFamily:l.font,textAlign:"center"},children:e.title}),o&&n.jsx("button",{onClick:()=>w(!i),title:"Chart settings",style:{position:"absolute",top:4,right:4,zIndex:50,background:i?`${l.accent}18`:"transparent",border:`1px solid ${i?l.accent:"transparent"}`,borderRadius:4,color:i?l.accent:l.textMuted,cursor:"pointer",fontSize:14,padding:"2px 6px",lineHeight:1},children:"⚙"}),i&&o&&n.jsx(dt,{config:e??{},columns:t.columns,onChange:A=>o(A),onClose:()=>w(!1),t:l}),xt(r,t,s,e)]})}function xt(t,s,e,o){const l=o!=null&&o.x&&s.columns.includes(o.x)?o.x:void 0,r=o!=null&&o.y&&s.columns.includes(o.y)?o.y:void 0,i=l||r?ut(s,l,r):s;switch(t){case"line":return n.jsx(ie,{result:i,themeMode:e,chartConfig:o});case"area":return n.jsx(ie,{result:i,themeMode:e,chartConfig:o,showArea:!0});case"bar":return n.jsx(te,{result:i,themeMode:e,chartConfig:o});case"grouped-bar":return n.jsx(Ce,{result:i,themeMode:e,chartConfig:o});case"stacked-bar":return n.jsx(et,{result:i,themeMode:e,chartConfig:o});case"scatter":return n.jsx(tt,{result:s,themeMode:e,chartConfig:o});case"pie":return n.jsx(ae,{result:s,themeMode:e,chartConfig:o,isDonut:!1});case"donut":return n.jsx(ae,{result:s,themeMode:e,chartConfig:o,isDonut:!0});case"heatmap":return n.jsx(ot,{result:s,themeMode:e});case"histogram":return n.jsx(st,{result:s,themeMode:e,chartConfig:o});case"funnel":return n.jsx(lt,{result:s,themeMode:e,chartConfig:o});case"sankey":return n.jsx(rt,{result:s,themeMode:e,chartConfig:o});case"waterfall":return n.jsx(it,{result:s,themeMode:e,chartConfig:o});case"gauge":return n.jsx(at,{result:s,themeMode:e,chartConfig:o});case"kpi":return n.jsx(me,{result:s,themeMode:e,chartConfig:o});default:return n.jsx(J,{result:s,themeMode:e})}}function ut(t,s,e){const o=t.columns,l=[];s&&o.includes(s)&&l.push(s),e&&o.includes(e)&&l.push(e);for(const r of o)l.includes(r)||l.push(r);return l.join(",")===o.join(",")?t:{...t,columns:l,rows:t.rows.map(r=>{const i={};for(const w of l)i[w]=r[w];return i})}}function Mt(t){return new Set(t.tiles.filter(s=>!s.error&&s.selectedByDefault).map(s=>s.id))}function wt({proposal:t,t:s,selected:e,onToggle:o,onCreate:l,busy:r,error:i,compact:w}){const A=t.tiles.filter(u=>!u.error),y=t.tiles.filter(u=>u.error),j=A.filter(u=>e.has(u.id)).length,b=A.filter(u=>e.has(u.id)&&u.certification==="ai_generated").length,v=A.filter(u=>e.has(u.id)&&u.certification==="reviewed_semantic").length,p=A.filter(u=>e.has(u.id)&&u.certification==="certified").length+v>0;return n.jsxs("div",{style:{display:"grid",gap:10},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:800,color:s.textPrimary},children:"Proposed app content"}),n.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[t.coverage.certifiedTiles," certified",t.coverage.semanticTiles>0?` · ${t.coverage.semanticTiles} reviewed semantic`:"",t.coverage.generatedTiles>0?` · ${t.coverage.generatedTiles} AI-generated`:"",t.coverage.gaps>0?` · ${t.coverage.gaps} uncovered`:""]})]}),n.jsxs("div",{style:{display:"grid",gap:6},children:[A.map(u=>n.jsx(pt,{tile:u,t:s,checked:e.has(u.id),onToggle:()=>o(u.id),compact:w},u.id)),y.map(u=>n.jsxs("div",{style:{...ye(s),opacity:.75},children:[n.jsx(he,{size:13,color:s.warning,style:{flexShrink:0,marginTop:2}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsx("div",{style:{fontSize:12,fontWeight:700,color:s.textSecondary},children:u.title}),n.jsx("div",{style:{fontSize:11,color:s.textMuted,marginTop:1},children:u.error})]})]},u.id))]}),t.gaps.length>0?n.jsxs("div",{style:{display:"grid",gap:4},children:[n.jsx("div",{style:{fontSize:11,fontWeight:800,color:s.textMuted,textTransform:"uppercase",letterSpacing:"0.04em"},children:"Not covered yet"}),t.gaps.map(u=>n.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:s.textMuted},children:[n.jsx(ke,{size:12,style:{flexShrink:0,marginTop:2}}),n.jsx("span",{style:{lineHeight:1.4},children:u.question})]},u.id))]}):null,i?n.jsx("div",{style:{fontSize:12,color:s.error},children:i}):null,n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,flexWrap:"wrap"},children:[n.jsxs("button",{type:"button",className:"dql-hover",onClick:l,disabled:r||!p,style:ht(s,p&&!r),children:[r?n.jsx(be,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):n.jsx(ve,{size:13}),n.jsx("span",{children:r?"Creating app…":`Create app (${j} tile${j===1?"":"s"})`})]}),n.jsx("span",{style:{fontSize:11,color:s.textMuted},children:p?v>0?`${v} semantic tile${v===1?"":"s"} will compile against the governed semantic layer at run time.`:b>0?`${b} AI-generated tile${b===1?"":"s"} will stay review-required until certified.`:"Nothing is created until you confirm.":"Select at least one certified block or reviewed semantic tile."})]})]})}function pt({tile:t,t:s,checked:e,onToggle:o,compact:l}){const[r,i]=T.useState(!1),w=t.certification==="certified",A=t.certification==="reviewed_semantic",y=!!(t.sql||t.answer||t.preview&&t.preview.rows.length>0);return n.jsxs("div",{style:ye(s),children:[n.jsx("input",{type:"checkbox",checked:e,onChange:o,"aria-label":`Include ${t.title}`,style:{marginTop:2,accentColor:s.accent,cursor:"pointer",flexShrink:0}}),n.jsxs("div",{style:{minWidth:0,flex:1},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:12.5,fontWeight:750,color:s.textPrimary},children:t.title}),w?n.jsxs("span",{style:X(s.success),children:[n.jsx(je,{size:10})," certified"]}):A?n.jsxs("span",{style:X(s.accent),children:[n.jsx(ne,{size:10})," reviewed semantic"]}):n.jsxs("span",{style:X(s.warning),children:[n.jsx(ne,{size:10})," AI-generated · needs review"]}),n.jsx("span",{style:{fontSize:10,color:s.textMuted},children:t.viz})]}),t.description&&!l?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:2,lineHeight:1.4},children:t.description}):null,t.question&&t.question!==t.title?n.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:2},children:["Answers: ",t.question]}):null,y?n.jsxs("button",{type:"button",onClick:()=>i(j=>!j),style:{border:"none",background:"transparent",color:s.accent,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:3,fontSize:10.5,fontWeight:700,padding:0,marginTop:4,fontFamily:s.font},children:[r?n.jsx(ge,{size:11}):n.jsx(Se,{size:11}),n.jsx(we,{size:11})," ",r?"Hide details":"Show SQL & preview"]}):null,r&&t.answer?n.jsx("div",{style:{fontSize:11.5,color:s.textSecondary,marginTop:5,lineHeight:1.4},children:t.answer}):null,r&&t.sql?n.jsx("pre",{style:ft(s),children:t.sql}):null,r&&t.preview&&t.preview.rows.length>0?n.jsx(mt,{preview:t.preview,t:s}):null]})]})}function mt({preview:t,t:s}){const e=t.columns.slice(0,5),o=t.rows.slice(0,5);return n.jsxs("div",{style:{marginTop:5,overflow:"auto",border:`1px solid ${s.headerBorder}`,borderRadius:6},children:[n.jsxs("table",{style:{borderCollapse:"collapse",fontSize:10.5,fontFamily:s.fontMono,width:"100%"},children:[n.jsx("thead",{children:n.jsx("tr",{children:e.map(l=>n.jsx("th",{style:{textAlign:"left",padding:"3px 8px",color:s.textMuted,borderBottom:`1px solid ${s.headerBorder}`,fontWeight:700,whiteSpace:"nowrap"},children:l},l))})}),n.jsx("tbody",{children:o.map((l,r)=>n.jsx("tr",{children:e.map(i=>n.jsx("td",{style:{padding:"3px 8px",color:s.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:160},children:yt(l[i])},i))},r))})]}),typeof t.rowCount=="number"&&t.rowCount>o.length?n.jsxs("div",{style:{fontSize:10,color:s.textMuted,padding:"3px 8px"},children:[t.rowCount," rows total"]}):null]})}function yt(t){return t==null?"":typeof t=="number"?Number.isInteger(t)?String(t):t.toFixed(2):String(t)}function ye(t){return{display:"flex",gap:9,alignItems:"flex-start",border:`1px solid ${t.cellBorder}`,background:t.cellBg,borderRadius:8,padding:"9px 11px"}}function X(t){return{display:"inline-flex",alignItems:"center",gap:3,border:`1px solid ${t}55`,color:t,background:`${t}12`,borderRadius:999,padding:"1px 7px",fontSize:9.5,fontWeight:800}}function ft(t){return{margin:"5px 0 0",maxHeight:140,overflow:"auto",border:`1px solid ${t.headerBorder}`,background:t.editorBg,borderRadius:6,padding:8,fontSize:10.5,fontFamily:t.fontMono,color:t.textSecondary,lineHeight:1.45,whiteSpace:"pre-wrap"}}function ht(t,s){return{display:"inline-flex",alignItems:"center",gap:6,border:"none",borderRadius:8,padding:"8px 14px",fontSize:12.5,fontWeight:800,fontFamily:t.font,cursor:s?"pointer":"default",background:s?t.accent:`${t.accent}55`,color:"#fff"}}function $t(t){const s=`dql.agent.threadId.${t}`,[e,o]=T.useState(()=>ce(s));T.useEffect(()=>{o(ce(s))},[s]);const l=T.useCallback(i=>{o(i);try{window.localStorage.setItem(s,i)}catch{}},[s]),r=T.useCallback(()=>{o(void 0);try{window.localStorage.removeItem(s)}catch{}},[s]);return{threadId:e,onThreadIdChange:l,resetThreadId:r}}function ce(t){try{return window.localStorage.getItem(t)??void 0}catch{return}}export{wt as A,gt as C,ke as F,vt as S,J as T,Je as a,St as b,jt as c,we as d,Mt as e,Fe as i,xt as r,$t as u};
|