react-semaphor 0.1.149 → 0.1.151
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/chunks/{dashboard-controls-DE_wHkIK.js → dashboard-controls-C9vPPAA5.js} +295 -303
- package/dist/chunks/dashboard-controls-R0Ll84Gl.js +26 -0
- package/dist/chunks/{dashboard-export-dialog-CrxAp9yB.js → dashboard-export-dialog-CzMFzBse.js} +3 -3
- package/dist/chunks/{dashboard-export-dialog-DvMsFXpk.js → dashboard-export-dialog-DYniVga5.js} +1 -1
- package/dist/chunks/{dashboard-json-B1RDTwhR.js → dashboard-json-3GJosjZ1.js} +1 -1
- package/dist/chunks/{dashboard-json-xnqDLMfc.js → dashboard-json-D_Ew5v58.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-B9NwuwjE.js → edit-dashboard-visual-DVgTTLJA.js} +305 -305
- package/dist/chunks/{edit-dashboard-visual-DEgGCKtt.js → edit-dashboard-visual-DxpnXWrq.js} +2 -2
- package/dist/chunks/{editor-action-buttons-Be2gqSdc.js → editor-action-buttons-BGRGrvil.js} +1 -1
- package/dist/chunks/{editor-action-buttons-DiV0FffF.js → editor-action-buttons-nOqTm8Zx.js} +2 -2
- package/dist/chunks/index-C39yXWHP.js +1354 -0
- package/dist/chunks/index-CClisLGZ.js +146833 -0
- package/dist/chunks/{resource-management-panel-B8oEtLaB.js → resource-management-panel-CpxLsJ42.js} +2 -2
- package/dist/chunks/{resource-management-panel-CBrnB1xs.js → resource-management-panel-XGVGu9yZ.js} +1 -1
- package/dist/chunks/{use-visual-utils-DgOik-Ul.js → use-visual-utils-BgJnVTRi.js} +1 -1
- package/dist/chunks/{use-visual-utils-DF-sQ-ZN.js → use-visual-utils-D4_F3SrQ.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/dashboard.d.ts +4 -3
- package/dist/types/main.d.ts +33 -42
- package/dist/types/surfboard.d.ts +4 -3
- package/dist/types/types.d.ts +1 -0
- package/package.json +10 -6
- package/dist/chunks/dashboard-controls-BTd2GP5a.js +0 -26
- package/dist/chunks/index-BISErscW.js +0 -116989
- package/dist/chunks/index-Cz1fGuVl.js +0 -1086
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-C39yXWHP.js"),D=require("react"),qe=require("./editor-action-buttons-BGRGrvil.js"),nt=require("react-dom");function at(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const Ke=at(D);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -174,7 +174,7 @@ ${T.joinType} JOIN ${M.name}
|
|
|
174
174
|
ON ${b}`}),y},isValidConfiguration:()=>!(!n.baseEntity.name||n.joins.some(T=>!T.source.name||!T.target.name)||n.joins.some(T=>T.joinKeyGroups.some(M=>M.keys.length===0))||n.joins.some(T=>T.joinKeyGroups.some(M=>M.keys.some(N=>!N.source.name||!N.target.name||!N.operator))))}}function Dt({joinPlan:t,availableDataSources:a,onSave:n,onRemove:r,onCancel:l}){const{setCardConfig:d}=s.useEditorActions();s.useEditorStore(N=>N.card.config);const{columnGroups:i}=s.useColumns(),{joinPlan:c,expandedJoins:o,setJoinPlan:u,addJoin:x,removeJoin:h,updateJoin:p,moveJoinUp:k,moveJoinDown:m,toggleJoinExpansion:f,getAvailableSourceEntities:j,getAvailableTargetEntities:C,addJoinKeyGroup:I,updateGroupOperator:O,removeJoinKeyGroup:R,addJoinKey:v,updateJoinKey:w,removeJoinKey:g,generateSQLPreview:y,isValidConfiguration:T}=It({initialJoinPlan:t,availableDataSources:a}),M=N=>{const b=i.find(A=>A.entityName===N);return(b==null?void 0:b.columns)||[]};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Base Entity (FROM clause)"}),e.jsxs(s.Select,{value:c.baseEntity.name,onValueChange:N=>{const b=a.find(A=>A.name===N);u({...c,baseEntity:{connectionId:(b==null?void 0:b.connectionId)||"",connectionType:(b==null?void 0:b.connectionType)||"none",type:(b==null?void 0:b.type)||"table",name:N,database:b==null?void 0:b.database,schema:b==null?void 0:b.schema}})},children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Select base entity..."})}),e.jsx(s.SelectContent,{children:a.map(N=>e.jsx(s.SelectItem,{className:"hover:bg-muted",value:N.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:N.type}),N.name,e.jsx(s.Badge,{variant:"outline",className:"text-xs text-green-600",children:"BASE"})]})},N.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This entity will be used as the base table in the FROM clause of the SQL query."})]}),e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx("div",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Join SQL Preview"}),e.jsx("code",{className:"block whitespace-pre-wrap break-all text-xs",children:y()})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(s.Label,{children:["Joins Configuration (",c.joins.length,")"]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(s.Button,{variant:"outline",size:"sm",onClick:x,children:[e.jsx(s.Plus,{className:"mr-1 h-4 w-4"}),"Add Join"]})})]}),c.joins.length===0?e.jsx("div",{className:"rounded-lg border border-dashed py-8 text-center text-muted-foreground",children:e.jsx("p",{children:"No joins configured. Add a join to connect multiple data sources."})}):e.jsx("div",{className:"max-h-[300px] space-y-4 overflow-y-auto",children:c.joins.map(N=>{const b=a.find(E=>E.name===N.source.name),A=a.find(E=>E.name===N.target.name),F=o.has(N.id);return e.jsxs(s.Card,{className:"border",children:[e.jsx(s.CardHeader,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Badge,{children:N.sequence}),e.jsxs(s.CardTitle,{className:"text-sm",children:["Join ",N.sequence,b&&A&&e.jsxs("span",{className:"ml-2 font-normal text-gray-600",children:["(",b.name," → ",A.name,")"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>k(N.id),disabled:N.sequence===1,children:e.jsx(s.ArrowUp,{className:"h-4 w-4"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>m(N.id),disabled:N.sequence===c.joins.length,children:e.jsx(s.ArrowDown,{className:"h-4 w-4"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>f(N.id),children:F?e.jsx(s.ChevronUp,{className:"h-4 w-4"}):e.jsx(s.ChevronDown,{className:"h-4 w-4"})}),e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>h(N.id),children:e.jsx(s.X,{className:"h-4 w-4"})})]})]})}),F&&e.jsxs(s.CardContent,{className:"space-y-4 pb-6",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Source"}),e.jsxs(s.Select,{value:N.source.name,onValueChange:E=>{const L=a.find(S=>S.name===E);p(N.id,{source:{connectionId:(L==null?void 0:L.connectionId)||"",connectionType:(L==null?void 0:L.connectionType)||"none",type:(L==null?void 0:L.type)||"table",name:E,database:L==null?void 0:L.database,schema:L==null?void 0:L.schema}})},children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Select source..."})}),e.jsx(s.SelectContent,{children:j(N.id).map(E=>e.jsx(s.SelectItem,{className:"hover:bg-muted",value:E.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:E.type}),E.name]})},E.name))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Join Type"}),e.jsxs(s.Select,{value:N.joinType,onValueChange:E=>p(N.id,{joinType:E}),children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"INNER",children:"INNER JOIN"}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"LEFT",children:"LEFT JOIN"}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"RIGHT",children:"RIGHT JOIN"}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"FULL",children:"FULL JOIN"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Target"}),e.jsxs(s.Select,{value:N.target.name,onValueChange:E=>{const L=a.find(S=>S.name===E);p(N.id,{target:{connectionId:(L==null?void 0:L.connectionId)||"",connectionType:(L==null?void 0:L.connectionType)||"none",type:(L==null?void 0:L.type)||"table",name:E,database:L==null?void 0:L.database,schema:L==null?void 0:L.schema}})},disabled:!N.source.name,children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Select target..."})}),e.jsx(s.SelectContent,{children:N.source.name?C(N.source.name).map(E=>e.jsx(s.SelectItem,{className:"hover:bg-muted",value:E.name,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:E.type}),E.name,E.name===N.source.name&&e.jsx(s.Badge,{variant:"outline",className:"text-xs text-yellow-600",children:"(Self-join)"})]})},E.name)):[]})]})]})]}),N.source.name&&N.target.name&&b&&A&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{children:"Join Conditions"}),e.jsxs(s.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>I(N.id),children:[e.jsx(s.Plus,{className:"mr-1 h-3 w-3"})," Add Condition Group"]})]}),N.joinKeyGroups.length===0?e.jsx("div",{className:"rounded-md border p-3 text-center text-sm text-gray-500",children:"No join conditions defined. Add condition groups to specify how data sources should be joined."}):e.jsx("div",{className:"space-y-4",children:N.joinKeyGroups.map((E,L)=>e.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Label,{children:["Group ",L+1]}),L>0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-gray-100 px-2 py-1",children:[e.jsx(s.Label,{className:"text-xs font-normal",children:"Join with:"}),e.jsx("span",{className:"text-sm font-medium",children:"OR"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Select,{value:E.operator,onValueChange:S=>O(N.id,L,S),children:[e.jsx(s.SelectTrigger,{className:"w-[100px]",children:e.jsx(s.SelectValue,{})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"AND",children:"AND"}),e.jsx(s.SelectItem,{value:"OR",children:"OR"})]})]}),e.jsx(s.Button,{type:"button",variant:"ghost",size:"sm",onClick:()=>R(N.id,L),children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[E.keys.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-center text-sm text-gray-500",children:"No conditions in this group. Add conditions to specify join criteria."}):e.jsx("div",{className:"space-y-2",children:E.keys.map((S,P)=>e.jsxs("div",{className:"flex flex-col items-start gap-2 rounded-md border p-2 sm:flex-row sm:items-center",children:[P>0&&e.jsx("div",{className:"self-center rounded-md bg-gray-100 px-2 py-1 text-xs font-medium",children:E.operator}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:flex-1",children:e.jsxs(s.Select,{value:S.source.name,onValueChange:$=>w(N.id,L,P,"sourceColumnName",$),children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Source column"})}),e.jsx(s.SelectContent,{children:M(N.source.name).map($=>e.jsx(s.SelectItem,{className:"hover:bg-muted",value:$.name,children:e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("span",{children:$.name}),e.jsx(s.Badge,{variant:"outline",className:"ml-2 text-xs",children:$.dataType})]})},$.name))})]})}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:w-20",children:e.jsxs(s.Select,{value:S.operator,onValueChange:$=>w(N.id,L,P,"operator",$),children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"=",children:"="}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"<",children:"<"}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:">",children:">"}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:"<=",children:"<="}),e.jsx(s.SelectItem,{className:"hover:bg-muted",value:">=",children:">="})]})]})}),e.jsx("div",{className:"mb-2 w-full sm:mb-0 sm:flex-1",children:e.jsxs(s.Select,{value:S.target.name,onValueChange:$=>w(N.id,L,P,"targetColumnName",$),children:[e.jsx(s.SelectTrigger,{children:e.jsx(s.SelectValue,{placeholder:"Target column"})}),e.jsx(s.SelectContent,{children:M(N.target.name).map($=>e.jsx(s.SelectItem,{className:"hover:bg-muted",value:$.name,children:e.jsxs("div",{className:"flex w-full items-center justify-between hover:bg-muted",children:[e.jsx("span",{children:$.name}),e.jsx(s.Badge,{variant:"outline",className:"ml-2 text-xs",children:$.dataType})]})},$.name))})]})}),e.jsx(s.Button,{type:"button",variant:"ghost",size:"sm",className:"self-center",onClick:()=>g(N.id,L,P),children:e.jsx(s.X,{className:"size-3.5"})})]},S.id||P))}),e.jsxs(s.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2",onClick:()=>v(N.id,L),children:[e.jsx(s.Plus,{className:"mr-1 h-3 w-3"})," Add Condition"]})]})]},E.id))})]})]})]},N.id)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t pt-4",children:[e.jsx(s.Button,{variant:"outline",onClick:()=>{r(),l()},children:"Remove All"}),e.jsx(s.Button,{variant:"outline",onClick:l,children:"Cancel"}),e.jsx(s.Button,{onClick:()=>n(c),disabled:!T(),children:"Save"})]})]})}function ws({children:t,open:a,onOpenChange:n,joinPlan:r,availableDataSources:l,onRemove:d,onSave:i,onCancel:c}){return e.jsxs(s.Dialog,{open:a,onOpenChange:n,children:[e.jsxs(s.DialogContent,{className:"max-w-4xl",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Join Configuration"}),e.jsx(s.DialogDescription,{children:"Configure the join between the two entities to combine the fields."})]}),e.jsx(Dt,{joinPlan:r,availableDataSources:l,onSave:i,onCancel:c,onRemove:d})]}),t]})}function Mt({joins:t,baseEntityId:a,availableDataSources:n,generateSQLPreview:r}){return e.jsxs("div",{className:"max-h-[400px] divide-y divide-border overflow-y-auto",children:[t.length>0&&e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"mb-3 text-left font-semibold",children:"Join Chain"}),e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:(()=>{const l=[...t].sort((i,c)=>i.sequence-c.sequence),d=n.find(i=>i.name===a);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(s.Badge,{variant:"secondary",className:"text-xs",children:d==null?void 0:d.type}),e.jsx("span",{className:"text-xs font-medium",children:d==null?void 0:d.name}),e.jsx(s.Badge,{variant:"outline",className:"text-xs text-green-600",children:"BASE"})]}),l.map(i=>{const c=n.find(o=>o.name===i.target.name);return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"mx-1 flex items-center gap-1",children:[e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:i.joinType}),e.jsx("span",{className:"text-muted-foreground",children:"→"})]}),e.jsxs("div",{className:"flex items-center gap-1 rounded-md border bg-muted px-2 py-1",children:[e.jsx(s.Badge,{variant:"secondary",className:"text-xs",children:c==null?void 0:c.type}),e.jsx("span",{className:"text-xs font-medium",children:c==null?void 0:c.name})]})]},i.id)})]})})()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"mb-3 text-left text-sm font-medium",children:["Configured Joins (",t.length,")"]}),e.jsx("div",{className:"space-y-2",children:[...t].sort((l,d)=>l.sequence-d.sequence).map((l,d)=>{const i=n.find(u=>u.name===l.source.name),c=n.find(u=>u.name===l.target.name),o=l.joinKeyGroups.reduce((u,x)=>u+x.keys.length,0);return e.jsxs("div",{className:"rounded-md bg-muted p-2 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Badge,{variant:"secondary",className:"shrink-0 text-xs",children:d+1}),e.jsx(s.Badge,{variant:"outline",className:"shrink-0 text-xs",children:l.joinType}),e.jsxs(s.Badge,{variant:"outline",className:"ml-auto shrink-0 text-xs",children:[o," condition",o>1?"s":""]})]}),e.jsxs("div",{className:"mt-1 truncate pl-1 text-xs text-muted-foreground",children:[i==null?void 0:i.name," → ",c==null?void 0:c.name]})]},l.id)})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"mb-3 text-left text-sm font-medium",children:"SQL Query"}),e.jsx("div",{className:"overflow-x-auto rounded-md border bg-muted p-3",children:e.jsx("pre",{className:"whitespace-pre-wrap break-all text-left font-mono text-xs text-muted-foreground",children:r()})})]})]})}function ns({open:t,onOpenChange:a,variant:n="button"}={}){var I,O;const r=s.useEditorStore(R=>R.card),{autoJoinMetadata:l}=s.useDashboardCardQuery(r),d=s.useEditorStore(R=>R.actions.updateCardConfig),i=((I=r==null?void 0:r.config)==null?void 0:I.joinPlan)||{baseEntity:{type:"table",name:"",database:"",schema:"",connectionId:"",connectionType:"none",dialect:"none"},joins:[]},[c,o]=D.useState(!1),u=t!==void 0,x=u?t:c,h=u?a:o,p=((O=r==null?void 0:r.dataSource)==null?void 0:O.selectedEntities)||[],k=R=>{d(r.id,{...r==null?void 0:r.config,joinPlan:R}),h(!1)},m=()=>{d(r.id,{...r==null?void 0:r.config,joinPlan:void 0})},f=()=>{h(!1)},j=()=>{const R=[...i.joins].sort((g,y)=>g.sequence-y.sequence),v=i.baseEntity;if(!v.name)return"SELECT * FROM table -- Please select a base entity";let w=`SELECT *
|
|
175
175
|
FROM ${v.name}`;return R.forEach(g=>{const y=p.find(N=>N.name===g.target.name);if(!y)return;const T=g.joinKeyGroups.filter(N=>N.keys&&N.keys.length>0).map(N=>{const b=N.keys.filter(A=>{var F,E,L,S;return((F=A.source)==null?void 0:F.name)&&((E=A.target)==null?void 0:E.name)&&((L=A.source)==null?void 0:L.entityName)&&((S=A.target)==null?void 0:S.entityName)}).map(A=>`${A.source.entityName}.${A.source.name} ${A.operator} ${A.target.entityName}.${A.target.name}`);return b.length>1?`(${b.join(` ${N.operator} `)})`:b[0]}).filter(Boolean),M=T.length>1?T.join(" OR "):T[0]||"condition_here";w+=`
|
|
176
176
|
${g.joinType} JOIN ${y.name}
|
|
177
|
-
ON ${M}`}),w};if(p.length<2)return null;const C=i.joins.length>0&&e.jsx(s.TooltipContent,{side:"bottom",className:"ml-4 max-w-md overflow-hidden p-0",children:e.jsx(Mt,{joins:i.joins,baseEntityId:i.baseEntity.name,availableDataSources:p,generateSQLPreview:j})});return e.jsxs(e.Fragment,{children:[e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:n==="badge"?e.jsxs(s.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:R=>{R.stopPropagation(),h(!0)},children:[e.jsx(s.Link,{className:"h-3 w-3"}),i.joins.length]}):e.jsxs(s.Button,{onClick:()=>h(!0),variant:"outline",className:"w-full bg-muted/50",children:[e.jsx(s.Link,{className:"mr-2 h-3.5 w-3.5"}),i.joins.length===0?"Configure Joins":i.joins.length===1?"Join":"Joins",i.joins.length>0&&e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:i.joins.length}),(l==null?void 0:l.autoResolved)&&e.jsxs(s.Badge,{variant:"secondary",className:"ml-2 h-5 gap-1 bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:[e.jsx(s.Sparkles,{className:"h-3 w-3"}),"Auto"]})]})}),C]})}),e.jsx(ws,{open:x,onOpenChange:h,joinPlan:i,availableDataSources:p,onSave:k,onCancel:f,onRemove:m,children:e.jsx("div",{})})]})}function Lt({open:t,onOpenChange:a}){const[n,r]=D.useState([]),{updateDataSource:l}=s.useEditorActions(),d=s.useDashboardStore(m=>m.dashboard.aiContext),i=(d==null?void 0:d.selectedEntities)||[];D.useEffect(()=>{t&&r([])},[t]);const c=m=>{r(f=>f.some(C=>C.name===m.name&&C.type===m.type)?f.filter(C=>!(C.name===m.name&&C.type===m.type)):[...f,m])},o=()=>{r([...i])},u=()=>{r([])},x=()=>{if(n.length===0)return;const m=n[0],f=m.connectionId||"",j=m.connectionType||"",I=n.some(R=>R.type==="dataset")?"semanticDomain":"database";l({connectionId:f,connectionType:j,mode:I,selectedEntities:n}),a(!1)},h=m=>"label"in m&&m.label?m.label:m.name,p=m=>{if("description"in m&&m.description)return m.description;const f=[];return m.database&&f.push(m.database),m.schema&&f.push(m.schema),m.name&&f.push(m.name),f.join(".")},k=m=>n.some(f=>f.name===m.name&&f.type===m.type);return i.length===0?e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"max-w-md",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"No Data Available"}),e.jsx(s.DialogDescription,{children:"No entities are currently available in the AI context. Please add some data sources to the dashboard first."})]}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{onClick:()=>a(!1),children:"Close"})})]})}):e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-w-2xl flex-col",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Select Data to Analyze"}),e.jsx(s.DialogDescription,{children:"Choose entities from the dashboard's context"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:o,disabled:n.length===i.length,children:"Select All"}),e.jsx(s.Button,{variant:"outline",size:"sm",onClick:u,disabled:n.length===0,children:"Clear All"})]}),e.jsxs(s.Badge,{variant:"secondary",children:[n.length," of ",i.length," selected"]})]}),e.jsx(s.Separator,{}),e.jsx(s.ScrollArea,{className:"h-64",children:e.jsx("div",{className:"space-y-2",children:i.map((m,f)=>e.jsxs("div",{className:s.cn("flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-muted/50",k(m)&&"border-primary bg-primary/5"),children:[e.jsx(s.Checkbox,{checked:k(m),onCheckedChange:()=>c(m)}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:s.getEntityIcon(m.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:h(m)}),e.jsx("div",{className:"truncate text-sm text-muted-foreground",children:p(m)})]}),e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:m.type})]},`${m.type}-${m.name}-${f}`))})})]}),e.jsx(s.DialogFooter,{children:e.jsx("div",{className:"flex w-full justify-between",children:e.jsxs("div",{className:"flex grow justify-end gap-2",children:[e.jsx(s.Button,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(s.Button,{onClick:x,disabled:n.length===0,children:["Select"," ",n.length>0?`(${n.length})`:""]})]})})})]})})}function as({entities:t,title:a}){const{isConsoleMode:n}=s.useDashboardPreferences();return e.jsx(s.TooltipContent,{side:"top",className:"ml-5 max-w-xs",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:a??`${t.length} more entities`}),e.jsx("div",{className:"space-y-1",children:t.map((r,l)=>{const d=s.getEntityDetails(r),i=d.find(o=>o.label==="Description"&&o.value),c=d.filter(o=>o.label==="Description"?!1:n?!0:!["Connection","Database","Schema"].includes(o.label)).slice(0,3);return e.jsxs("div",{className:"border-b border-border pb-1 last:border-b-0",children:[e.jsx("div",{className:"text-xs font-medium",children:s.getDisplayName(r)}),i&&e.jsxs("div",{className:"mb-1 mt-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description:"}),e.jsx("div",{className:"text-xs leading-relaxed",children:i.value})]}),c.length>0&&e.jsx("div",{className:"mt-1 space-y-0.5",children:c.map((o,u)=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[o.label,":"]}),e.jsx("span",{className:"font-mono",children:o.value})]},u))})]},`remaining-${r.type}-${r.name}-${l}`)})})]})})}function ks(t,a){const[n,r]=D.useState(()=>{const l=localStorage.getItem(t);return l?JSON.parse(l):a});return D.useEffect(()=>{localStorage.setItem(t,JSON.stringify(n))},[n,t]),[n,r]}function Ts({isVisible:t}){var f,j;const a=s.useEditorStore(C=>C.isDevMode);s.useSyncLegacyEditorState();const[n,r]=D.useState(!1),[l,d]=D.useState(!1),[i,c]=ks("semaphor:data-source-collapsed",!1),o=s.useEditorStore(C=>C.card.dataSource),u=s.useEditorStore(C=>{var I,O;return(O=(I=C.card)==null?void 0:I.config)==null?void 0:O.joinPlan}),{updateDataSource:x}=s.useEditorActions(),h=((f=o==null?void 0:o.selectedEntities)==null?void 0:f.length)||0,p=((j=u==null?void 0:u.joins)==null?void 0:j.length)||0,m={...{connectionId:"",connectionType:"",mode:"database",selectedEntities:[]},...o,selectedEntities:(o==null?void 0:o.selectedEntities)||[]};return e.jsxs("div",{className:s.cn("flex flex-col overflow-hidden bg-background transition-all duration-300 ease-in-out",{"w-[325px]":t,"w-0":!t}),children:[h===0&&p===0?e.jsx("div",{className:"p-4 px-6",children:e.jsxs(s.Button,{className:"w-full bg-muted/50",variant:"outline",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"mr-2 h-3.5 w-3.5"}),"Choose Dataset"]})}):e.jsxs("div",{children:[e.jsxs("div",{className:s.cn("flex cursor-pointer items-center justify-between px-6 pt-3",!i&&"pb-3"),onClick:()=>c(!i),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Data Source"}),i&&e.jsxs("div",{className:"flex items-center gap-1.5",onClick:C=>C.stopPropagation(),children:[h>0&&e.jsx(s.TooltipProvider,{delayDuration:100,children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(s.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"h-3 w-3"}),h]})}),e.jsx(as,{entities:m.selectedEntities,title:`${h} selected ${h===1?"entity":"entities"}`})]})}),p>0&&!a&&e.jsx(ns,{variant:"badge"})]})]}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:C=>{C.stopPropagation(),c(!i)},children:i?e.jsx(s.ChevronDown,{className:"h-4 w-4"}):e.jsx(s.ChevronUp,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:s.cn("overflow-hidden transition-all duration-200 ease-in-out",i?"max-h-0 opacity-0":"max-h-96 opacity-100"),children:[e.jsx("div",{className:"px-6 pb-2",children:e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"w-full bg-muted/50",variant:"outline",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"mr-2 h-3.5 w-3.5"}),h===1?"Dataset":"Datasets",e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:h})]})}),e.jsx(as,{entities:m.selectedEntities,title:`${h} selected ${h===1?"entity":"entities"}`})]})})}),!a&&e.jsx("div",{className:"px-6 pb-2",children:e.jsx(ns,{})})]})]}),e.jsx(s.FieldsSection,{}),e.jsx(s.DataSourceDialog,{incomingSelectedEntities:(o==null?void 0:o.selectedEntities)||[],dialogMode:"dataSource",open:n,onOpenChange:r,dataSource:m}),e.jsx(Lt,{open:l,onOpenChange:d})]})}function He({error:t,errorSql:a,onSendFeedback:n,onOpenInEditor:r,className:l,showFeedbackButton:d=!0,errorTitle:i="Query Error"}){const[c,o]=D.useState(!1);return e.jsx("div",{className:s.cn("rounded-lg border border-destructive/30 bg-destructive/5 p-4",l),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(s.CircleAlert,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-destructive"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:i}),e.jsxs("div",{className:"relative rounded-md bg-background/60 p-3",children:[e.jsx(s.CopyButton,{text:t,className:"absolute right-2 top-2 h-6 w-6 z-10"}),e.jsx("div",{className:"max-h-40 overflow-auto pr-10",children:e.jsx("p",{className:"font-mono text-xs text-foreground/80 break-all",children:t})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(s.Collapsible,{open:c,onOpenChange:o,children:e.jsx(s.CollapsibleTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:"h-8",children:c?e.jsxs(e.Fragment,{children:[e.jsx(s.ChevronUp,{className:"mr-1.5 h-3.5 w-3.5"}),"Hide Details"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.ChevronDown,{className:"mr-1.5 h-3.5 w-3.5"}),"Show Details"]})})})}),r&&a&&e.jsxs(s.Button,{variant:"outline",size:"sm",className:"h-8",onClick:r,children:[e.jsx(Cs,{className:"mr-1.5 h-3.5 w-3.5"}),"Open in Editor"]}),d&&n&&e.jsxs(s.Button,{variant:"outline",size:"sm",className:"h-8",onClick:n,children:[e.jsx(s.MessageSquareWarning,{className:"mr-1.5 h-3.5 w-3.5"}),"Send Feedback"]})]}),a&&e.jsx(s.Collapsible,{open:c,onOpenChange:o,children:e.jsx(s.CollapsibleContent,{className:"space-y-2",children:e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Error SQL Query"}),e.jsx(s.CopyButton,{text:a,className:"h-6 w-6"})]}),e.jsx("div",{className:"rounded-md bg-background/60 p-2 max-h-80 overflow-auto",children:e.jsx(s.CodeHighlighter,{code:a,language:"sql"})})]})})})]})]})})}function Es({sql:t,error:a,errorSql:n,onDebugWithAssistant:r}){const l=s.useEditorStore(f=>f.isDevMode),{setIsDevMode:d,setCardSql:i,setRunSql:c}=s.useEditorActions(),[o,u]=D.useState(!1),x=s.useEditorStore(f=>f.card),h=s.useEditorStore(f=>f.frame),p=s.useDashboardStore(f=>f.selectedSheetId),k=s.useDashboardStore(f=>{var j;return(j=f.dashboard)==null?void 0:j.id});function m(f){d(!0),i(f||t),setTimeout(()=>{c(!0)},100)}return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col pt-4",children:[!l&&t&&!a&&e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs(s.Button,{onClick:()=>m(),variant:"secondary",size:"sm",children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),e.jsxs(s.Button,{onClick:()=>u(!o),variant:"outline",size:"sm",children:[e.jsx(s.Info,{className:"mr-2 h-4 w-4"}),"Card Details"]})]}),o&&e.jsx("div",{className:"mb-3 rounded-lg border border-border bg-muted/30 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Card Information"}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!1),children:e.jsx(ys,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Card ID"}),e.jsx("code",{className:"text-xs font-mono",children:x.id||"N/A"})]}),e.jsx(s.CopyButton,{text:x.id||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Frame ID"}),e.jsx("code",{className:"text-xs font-mono",children:h.id||"N/A"})]}),e.jsx(s.CopyButton,{text:h.id||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Sheet ID"}),e.jsx("code",{className:"text-xs font-mono",children:p||"N/A"})]}),e.jsx(s.CopyButton,{text:p||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Dashboard ID"}),e.jsx("code",{className:"text-xs font-mono",children:k||"N/A"})]}),e.jsx(s.CopyButton,{text:k||"",className:"h-6 w-6"})]})]})]})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto text-xs leading-relaxed text-foreground/80",children:[a&&e.jsx(He,{error:a,errorSql:n,showFeedbackButton:!1,onOpenInEditor:()=>m(n)}),!a&&t&&e.jsx("div",{className:"flex flex-col space-y-1.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(s.CopyButton,{text:t,className:"h-6 w-6"})}),e.jsx(s.CodeHighlighter,{code:t,language:"sql"})]})})]}),a&&r&&e.jsx("div",{className:"mt-3",children:e.jsxs(s.Button,{onClick:r,size:"sm",variant:"outline",children:[e.jsx(ht,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})})]})}function Ft({sql:t,error:a,errorSql:n,onDebugWithAssistant:r}){return e.jsxs(s.HoverCard,{openDelay:a?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:a?e.jsx(ys,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"flex w-[700px]",children:e.jsx(Es,{errorSql:n,sql:t,error:a,onDebugWithAssistant:r})})]})}function Ot(t){return s.GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(t)}function As(t){const{theme:a}=s.useTheme(),n=s.useDashboardStore(f=>f.theme),r=s.useEditorStore(f=>f.frame),l=s.useEditorStore(f=>f.card),d=s.useEditorStore(f=>f.activeTabCardId),i=s.Le(),{refetch:c}=s.useDashboardCardQuery(l),{updateCardTab:o,setRunSql:u}=s.useEditorActions(),x=D.useRef(),h=D.useRef({}),p=r.cards.find(f=>f.id===d),k=D.useCallback(()=>{let f="";return t==="python"&&(f=(p==null?void 0:p.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(f=(p==null?void 0:p.sql)||""),f},[t,p]);D.useEffect(()=>{if(d&&l.id&&l.id!==d){if(x.current&&i){const f=x.current.getModel();f&&(h.current[l.id]=f);let j=h.current[d];if(!j){const C=k();j=i.editor.createModel(C,t),h.current[d]=j}x.current.setModel(j)}o(d,l),u(!0)}},[d,l,o,i,u,t,k]),D.useEffect(()=>{if(!i)return;const f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",j=n==="system"?f:n;i.editor.defineTheme("default",{base:j==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":j==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),D.useEffect(()=>{const f=x.current;f&&i&&l&&f.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return c(),!1})},[i,c,l]);function m(f,j){if(x.current=f,!h.current[l.id]){const C=f.getModel(),I=k();h.current[l.id]=C||(j==null?void 0:j.editor.createModel(I,t))||f.getModel()}f.setModel(h.current[l.id])}return{handleEditorDidMount:m}}function Rt(){const t=s.useEditorStore(i=>i.card.sql),a=s.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:l}=As("sql");function d(i){n(i),s.isObjectEmpty(a)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!t&&e.jsx("div",{className:"pointer-events-none absolute left-[65px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:d,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:l})]})}function Bt(){const t=s.useEditorStore(l=>l.card.python),{setCardPython:a}=s.useEditorActions(),{handleEditorDidMount:n}=As("python");function r(l){a(l)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:n})}function Vt(){const t=s.useQueryClient(),{isConsoleMode:a}=s.useDashboardPreferences(),[n,r]=D.useState(!1);s.useEditorStore(B=>B.frame);const l=s.useEditorStore(B=>B.card);s.useEditorStore(B=>B.isShowingVisual),s.useEditorStore(B=>B.selectedConnectionId),s.useEditorStore(B=>B.tempQueryData),s.useEditorStore(B=>B.selectedDatabaseName),s.useEditorStore(B=>B.selectedDatamodelId),s.useEditorStore(B=>B.selectedSchemaName);const d=s.useEditorStore(B=>B.showAIDialog);s.useEditorStore(B=>B.selectedTableName);const i=s.useEditorStore(B=>{var U;return(U=B==null?void 0:B.card)==null?void 0:U.sql}),c=s.useEditorStore(B=>{var U;return(U=B==null?void 0:B.card)==null?void 0:U.python}),{cardFilterValues:o}=s.useCardFilterValues((l==null?void 0:l.id)??""),u=s.useDashboardStore(B=>B.inlineFilterValuesMap[(l==null?void 0:l.id)??""]),x=D.useRef(!0),{setCardCustomCfg:h,setQueryResultColumns:p,setCardSql:k,setTempQueryData:m,setPythonStdOut:f,setCardPreferences:j,setCardType:C,setCardPython:I,runAssistant:O,setShowAIDialog:R,setCard:v,updateCardInFrame:w}=s.useEditorActions();s.useEditorStore(B=>B.onSave),s.useEditorStore(B=>B.onClose),s.useEditorStore(B=>B.actions.setSqlGen);const g=s.useEditorStore(B=>B.runSql),y=s.useEditorStore(B=>B.actions.setRunSql),T=s.useEditorStore(B=>B.actions.setIsSqlRunning),{data:M,isLoading:N,isFetching:b,isSuccess:A,isError:F,error:E,errorSql:L,queryKey:S,refetch:P,errorMessage:$}=s.useDashboardCardQuery(l);D.useEffect(()=>{if(M&&(M.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),f((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:B}=s.getKeys(M.records);p(B)}},[M,p,f]),D.useEffect(()=>{(N||b)&&T(!0),(F||A)&&T(!1),F&&(p([]),f(""))},[N,b,M,f,F,A,T,p,E]),D.useEffect(()=>{g&&(t.getQueryData(S)||P(),y(!1))},[g,P,y,S,t]);const J=D.useRef(P);J.current=P,D.useEffect(()=>{if(x.current){x.current=!1;return}J.current()},[u]);async function K(){const B=`Can you help me debug this query?
|
|
177
|
+
ON ${M}`}),w};if(p.length<2)return null;const C=i.joins.length>0&&e.jsx(s.TooltipContent,{side:"bottom",className:"ml-4 max-w-md overflow-hidden p-0",children:e.jsx(Mt,{joins:i.joins,baseEntityId:i.baseEntity.name,availableDataSources:p,generateSQLPreview:j})});return e.jsxs(e.Fragment,{children:[e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:n==="badge"?e.jsxs(s.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:R=>{R.stopPropagation(),h(!0)},children:[e.jsx(s.Link,{className:"h-3 w-3"}),i.joins.length]}):e.jsxs(s.Button,{onClick:()=>h(!0),variant:"outline",className:"w-full bg-muted/50",children:[e.jsx(s.Link,{className:"mr-2 h-3.5 w-3.5"}),i.joins.length===0?"Configure Joins":i.joins.length===1?"Join":"Joins",i.joins.length>0&&e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:i.joins.length}),(l==null?void 0:l.autoResolved)&&e.jsxs(s.Badge,{variant:"secondary",className:"ml-2 h-5 gap-1 bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",children:[e.jsx(s.Sparkles,{className:"h-3 w-3"}),"Auto"]})]})}),C]})}),e.jsx(ws,{open:x,onOpenChange:h,joinPlan:i,availableDataSources:p,onSave:k,onCancel:f,onRemove:m,children:e.jsx("div",{})})]})}function Lt({open:t,onOpenChange:a}){const[n,r]=D.useState([]),{updateDataSource:l}=s.useEditorActions(),d=s.useDashboardStore(m=>m.dashboard.aiContext),i=(d==null?void 0:d.selectedEntities)||[];D.useEffect(()=>{t&&r([])},[t]);const c=m=>{r(f=>f.some(C=>C.name===m.name&&C.type===m.type)?f.filter(C=>!(C.name===m.name&&C.type===m.type)):[...f,m])},o=()=>{r([...i])},u=()=>{r([])},x=()=>{if(n.length===0)return;const m=n[0],f=m.connectionId||"",j=m.connectionType||"",I=n.some(R=>R.type==="dataset")?"semanticDomain":"database";l({connectionId:f,connectionType:j,mode:I,selectedEntities:n}),a(!1)},h=m=>"label"in m&&m.label?m.label:m.name,p=m=>{if("description"in m&&m.description)return m.description;const f=[];return m.database&&f.push(m.database),m.schema&&f.push(m.schema),m.name&&f.push(m.name),f.join(".")},k=m=>n.some(f=>f.name===m.name&&f.type===m.type);return i.length===0?e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"max-w-md",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"No Data Available"}),e.jsx(s.DialogDescription,{children:"No entities are currently available in the AI context. Please add some data sources to the dashboard first."})]}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{onClick:()=>a(!1),children:"Close"})})]})}):e.jsx(s.Dialog,{open:t,onOpenChange:a,children:e.jsxs(s.DialogContent,{className:"flex max-w-2xl flex-col",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Select Data to Analyze"}),e.jsx(s.DialogDescription,{children:"Choose entities from the dashboard's context"})]}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:o,disabled:n.length===i.length,children:"Select All"}),e.jsx(s.Button,{variant:"outline",size:"sm",onClick:u,disabled:n.length===0,children:"Clear All"})]}),e.jsxs(s.Badge,{variant:"secondary",children:[n.length," of ",i.length," selected"]})]}),e.jsx(s.Separator,{}),e.jsx(s.ScrollArea,{className:"h-64",children:e.jsx("div",{className:"space-y-2",children:i.map((m,f)=>e.jsxs("div",{className:s.cn("flex items-center gap-3 rounded-lg border p-3 transition-colors hover:bg-muted/50",k(m)&&"border-primary bg-primary/5"),children:[e.jsx(s.Checkbox,{checked:k(m),onCheckedChange:()=>c(m)}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:s.getEntityIcon(m.type)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:h(m)}),e.jsx("div",{className:"truncate text-sm text-muted-foreground",children:p(m)})]}),e.jsx(s.Badge,{variant:"outline",className:"text-xs",children:m.type})]},`${m.type}-${m.name}-${f}`))})})]}),e.jsx(s.DialogFooter,{children:e.jsx("div",{className:"flex w-full justify-between",children:e.jsxs("div",{className:"flex grow justify-end gap-2",children:[e.jsx(s.Button,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(s.Button,{onClick:x,disabled:n.length===0,children:["Select"," ",n.length>0?`(${n.length})`:""]})]})})})]})})}function as({entities:t,title:a}){const{isConsoleMode:n}=s.useDashboardPreferences();return e.jsx(s.TooltipContent,{side:"top",className:"ml-5 max-w-xs",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:a??`${t.length} more entities`}),e.jsx("div",{className:"space-y-1",children:t.map((r,l)=>{const d=s.getEntityDetails(r),i=d.find(o=>o.label==="Description"&&o.value),c=d.filter(o=>o.label==="Description"?!1:n?!0:!["Connection","Database","Schema"].includes(o.label)).slice(0,3);return e.jsxs("div",{className:"border-b border-border pb-1 last:border-b-0",children:[e.jsx("div",{className:"text-xs font-medium",children:s.getDisplayName(r)}),i&&e.jsxs("div",{className:"mb-1 mt-1",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:"Description:"}),e.jsx("div",{className:"text-xs leading-relaxed",children:i.value})]}),c.length>0&&e.jsx("div",{className:"mt-1 space-y-0.5",children:c.map((o,u)=>e.jsxs("div",{className:"flex justify-between text-xs",children:[e.jsxs("span",{className:"mr-2 text-muted-foreground",children:[o.label,":"]}),e.jsx("span",{className:"font-mono",children:o.value})]},u))})]},`remaining-${r.type}-${r.name}-${l}`)})})]})})}function ks(t,a){const[n,r]=D.useState(()=>{const l=localStorage.getItem(t);return l?JSON.parse(l):a});return D.useEffect(()=>{localStorage.setItem(t,JSON.stringify(n))},[n,t]),[n,r]}function Ts({isVisible:t}){var f,j;const a=s.useEditorStore(C=>C.isDevMode);s.useSyncLegacyEditorState();const[n,r]=D.useState(!1),[l,d]=D.useState(!1),[i,c]=ks("semaphor:data-source-collapsed",!1),o=s.useEditorStore(C=>C.card.dataSource),u=s.useEditorStore(C=>{var I,O;return(O=(I=C.card)==null?void 0:I.config)==null?void 0:O.joinPlan}),{updateDataSource:x}=s.useEditorActions(),h=((f=o==null?void 0:o.selectedEntities)==null?void 0:f.length)||0,p=((j=u==null?void 0:u.joins)==null?void 0:j.length)||0,m={...{connectionId:"",connectionType:"",mode:"database",selectedEntities:[]},...o,selectedEntities:(o==null?void 0:o.selectedEntities)||[]};return e.jsxs("div",{className:s.cn("flex flex-col overflow-hidden bg-background transition-all duration-300 ease-in-out",{"w-[325px]":t,"w-0":!t}),children:[h===0&&p===0?e.jsx("div",{className:"p-4 px-6",children:e.jsxs(s.Button,{className:"w-full bg-muted/50",variant:"outline",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"mr-2 h-3.5 w-3.5"}),"Choose Dataset"]})}):e.jsxs("div",{children:[e.jsxs("div",{className:s.cn("flex cursor-pointer items-center justify-between px-6 pt-3",!i&&"pb-3"),onClick:()=>c(!i),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:"Data Source"}),i&&e.jsxs("div",{className:"flex items-center gap-1.5",onClick:C=>C.stopPropagation(),children:[h>0&&e.jsx(s.TooltipProvider,{delayDuration:100,children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(s.Badge,{variant:"secondary",className:"h-5 cursor-pointer gap-1 px-1.5 text-xs transition-colors hover:bg-secondary/80",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"h-3 w-3"}),h]})}),e.jsx(as,{entities:m.selectedEntities,title:`${h} selected ${h===1?"entity":"entities"}`})]})}),p>0&&!a&&e.jsx(ns,{variant:"badge"})]})]}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:C=>{C.stopPropagation(),c(!i)},children:i?e.jsx(s.ChevronDown,{className:"h-4 w-4"}):e.jsx(s.ChevronUp,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:s.cn("overflow-hidden transition-all duration-200 ease-in-out",i?"max-h-0 opacity-0":"max-h-96 opacity-100"),children:[e.jsx("div",{className:"px-6 pb-2",children:e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"w-full bg-muted/50",variant:"outline",onClick:()=>r(!0),children:[e.jsx(s.Database,{className:"mr-2 h-3.5 w-3.5"}),h===1?"Dataset":"Datasets",e.jsx("span",{className:"ml-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-medium text-primary-foreground",children:h})]})}),e.jsx(as,{entities:m.selectedEntities,title:`${h} selected ${h===1?"entity":"entities"}`})]})})}),!a&&e.jsx("div",{className:"px-6 pb-2",children:e.jsx(ns,{})})]})]}),e.jsx(s.FieldsSection,{}),e.jsx(s.DataSourceDialog,{incomingSelectedEntities:(o==null?void 0:o.selectedEntities)||[],dialogMode:"dataSource",open:n,onOpenChange:r,dataSource:m}),e.jsx(Lt,{open:l,onOpenChange:d})]})}function He({error:t,errorSql:a,onSendFeedback:n,onOpenInEditor:r,className:l,showFeedbackButton:d=!0,errorTitle:i="Query Error"}){const[c,o]=D.useState(!1);return e.jsx("div",{className:s.cn("rounded-lg border border-destructive/30 bg-destructive/5 p-4",l),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(s.CircleAlert,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-destructive"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-destructive",children:i}),e.jsxs("div",{className:"relative rounded-md bg-background/60 p-3",children:[e.jsx(s.CopyButton,{text:t,className:"absolute right-2 top-2 h-6 w-6 z-10"}),e.jsx("div",{className:"max-h-40 overflow-auto pr-10",children:e.jsx("p",{className:"font-mono text-xs text-foreground/80 break-all",children:t})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&e.jsx(s.Collapsible,{open:c,onOpenChange:o,children:e.jsx(s.CollapsibleTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:"h-8",children:c?e.jsxs(e.Fragment,{children:[e.jsx(s.ChevronUp,{className:"mr-1.5 h-3.5 w-3.5"}),"Hide Details"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.ChevronDown,{className:"mr-1.5 h-3.5 w-3.5"}),"Show Details"]})})})}),r&&a&&e.jsxs(s.Button,{variant:"outline",size:"sm",className:"h-8",onClick:r,children:[e.jsx(Cs,{className:"mr-1.5 h-3.5 w-3.5"}),"Open in Editor"]}),d&&n&&e.jsxs(s.Button,{variant:"outline",size:"sm",className:"h-8",onClick:n,children:[e.jsx(s.MessageSquareWarning,{className:"mr-1.5 h-3.5 w-3.5"}),"Send Feedback"]})]}),a&&e.jsx(s.Collapsible,{open:c,onOpenChange:o,children:e.jsx(s.CollapsibleContent,{className:"space-y-2",children:e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Error SQL Query"}),e.jsx(s.CopyButton,{text:a,className:"h-6 w-6"})]}),e.jsx("div",{className:"rounded-md bg-background/60 p-2 max-h-80 overflow-auto",children:e.jsx(s.CodeHighlighter,{code:a,language:"sql"})})]})})})]})]})})}function Es({sql:t,error:a,errorSql:n,onDebugWithAssistant:r}){const l=s.useEditorStore(f=>f.isDevMode),{setIsDevMode:d,setCardSql:i,setRunSql:c}=s.useEditorActions(),[o,u]=D.useState(!1),x=s.useEditorStore(f=>f.card),h=s.useEditorStore(f=>f.frame),p=s.useDashboardStore(f=>f.selectedSheetId),k=s.useDashboardStore(f=>{var j;return(j=f.dashboard)==null?void 0:j.id});function m(f){d(!0),i(f||t),setTimeout(()=>{c(!0)},100)}return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col pt-4",children:[!l&&t&&!a&&e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxs(s.Button,{onClick:()=>m(),variant:"secondary",size:"sm",children:[e.jsx(Cs,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),e.jsxs(s.Button,{onClick:()=>u(!o),variant:"outline",size:"sm",children:[e.jsx(s.Info,{className:"mr-2 h-4 w-4"}),"Card Details"]})]}),o&&e.jsx("div",{className:"mb-3 rounded-lg border border-border bg-muted/30 p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Card Information"}),e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!1),children:e.jsx(ys,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Card ID"}),e.jsx("code",{className:"text-xs font-mono",children:x.id||"N/A"})]}),e.jsx(s.CopyButton,{text:x.id||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Frame ID"}),e.jsx("code",{className:"text-xs font-mono",children:h.id||"N/A"})]}),e.jsx(s.CopyButton,{text:h.id||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Sheet ID"}),e.jsx("code",{className:"text-xs font-mono",children:p||"N/A"})]}),e.jsx(s.CopyButton,{text:p||"",className:"h-6 w-6"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-background/60 px-3 py-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Dashboard ID"}),e.jsx("code",{className:"text-xs font-mono",children:k||"N/A"})]}),e.jsx(s.CopyButton,{text:k||"",className:"h-6 w-6"})]})]})]})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto text-xs leading-relaxed text-foreground/80",children:[a&&e.jsx(He,{error:a,errorSql:n,showFeedbackButton:!1,onOpenInEditor:()=>m(n)}),!a&&t&&e.jsx("div",{className:"flex flex-col space-y-1.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(s.CopyButton,{text:t,className:"h-6 w-6"})}),e.jsx(s.CodeHighlighter,{code:t,language:"sql"})]})})]}),a&&r&&e.jsx("div",{className:"mt-3",children:e.jsxs(s.Button,{onClick:r,size:"sm",variant:"outline",children:[e.jsx(ht,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})})]})}function Ft({sql:t,error:a,errorSql:n,onDebugWithAssistant:r}){return e.jsxs(s.HoverCard,{openDelay:a?0:500,children:[e.jsx(s.HoverCardTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"link",className:"h-5 p-0",children:a?e.jsx(ys,{className:"h-4 w-4 text-red-500"}):e.jsx(s.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(s.HoverCardContent,{align:"start",className:"flex w-[700px]",children:e.jsx(Es,{errorSql:n,sql:t,error:a,onDebugWithAssistant:r})})]})}function Ot(t){return s.GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"},child:[]}]})(t)}function As(t){const{theme:a}=s.useTheme(),n=s.useDashboardStore(f=>f.theme),r=s.useEditorStore(f=>f.frame),l=s.useEditorStore(f=>f.card),d=s.useEditorStore(f=>f.activeTabCardId),i=s.Le(),{refetch:c}=s.useDashboardCardQuery(l),{updateCardTab:o,setRunSql:u}=s.useEditorActions(),x=D.useRef(void 0),h=D.useRef({}),p=r.cards.find(f=>f.id===d),k=D.useCallback(()=>{let f="";return t==="python"&&(f=(p==null?void 0:p.python)||s.PYTHON_DEFAULT_CODE),t==="sql"&&(f=(p==null?void 0:p.sql)||""),f},[t,p]);D.useEffect(()=>{if(d&&l.id&&l.id!==d){if(x.current&&i){const f=x.current.getModel();f&&(h.current[l.id]=f);let j=h.current[d];if(!j){const C=k();j=i.editor.createModel(C,t),h.current[d]=j}x.current.setModel(j)}o(d,l),u(!0)}},[d,l,o,i,u,t,k]),D.useEffect(()=>{if(!i)return;const f=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",j=n==="system"?f:n;i.editor.defineTheme("default",{base:j==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":j==="light"?"#ffffff":s.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),D.useEffect(()=>{const f=x.current;f&&i&&l&&f.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return c(),!1})},[i,c,l]);function m(f,j){if(x.current=f,!h.current[l.id]){const C=f.getModel(),I=k();h.current[l.id]=C||(j==null?void 0:j.editor.createModel(I,t))||f.getModel()}f.setModel(h.current[l.id])}return{handleEditorDidMount:m}}function Rt(){const t=s.useEditorStore(i=>i.card.sql),a=s.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=s.useEditorActions(),{handleEditorDidMount:l}=As("sql");function d(i){n(i),s.isObjectEmpty(a)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!t&&e.jsx("div",{className:"pointer-events-none absolute left-[65px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),e.jsx(s.Ft,{theme:"default",className:"pt-3",onChange:d,value:t||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:l})]})}function Bt(){const t=s.useEditorStore(l=>l.card.python),{setCardPython:a}=s.useEditorActions(),{handleEditorDidMount:n}=As("python");function r(l){a(l)}return e.jsx(s.Ft,{className:"pt-3",theme:"default",onChange:r,value:t||s.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:n})}function Vt(){const t=s.useQueryClient(),{isConsoleMode:a}=s.useDashboardPreferences(),[n,r]=D.useState(!1);s.useEditorStore(B=>B.frame);const l=s.useEditorStore(B=>B.card);s.useEditorStore(B=>B.isShowingVisual),s.useEditorStore(B=>B.selectedConnectionId),s.useEditorStore(B=>B.tempQueryData),s.useEditorStore(B=>B.selectedDatabaseName),s.useEditorStore(B=>B.selectedDatamodelId),s.useEditorStore(B=>B.selectedSchemaName);const d=s.useEditorStore(B=>B.showAIDialog);s.useEditorStore(B=>B.selectedTableName);const i=s.useEditorStore(B=>{var U;return(U=B==null?void 0:B.card)==null?void 0:U.sql}),c=s.useEditorStore(B=>{var U;return(U=B==null?void 0:B.card)==null?void 0:U.python}),{cardFilterValues:o}=s.useCardFilterValues((l==null?void 0:l.id)??""),u=s.useDashboardStore(B=>B.inlineFilterValuesMap[(l==null?void 0:l.id)??""]),x=D.useRef(!0),{setCardCustomCfg:h,setQueryResultColumns:p,setCardSql:k,setTempQueryData:m,setPythonStdOut:f,setCardPreferences:j,setCardType:C,setCardPython:I,runAssistant:O,setShowAIDialog:R,setCard:v,updateCardInFrame:w}=s.useEditorActions();s.useEditorStore(B=>B.onSave),s.useEditorStore(B=>B.onClose),s.useEditorStore(B=>B.actions.setSqlGen);const g=s.useEditorStore(B=>B.runSql),y=s.useEditorStore(B=>B.actions.setRunSql),T=s.useEditorStore(B=>B.actions.setIsSqlRunning),{data:M,isLoading:N,isFetching:b,isSuccess:A,isError:F,error:E,errorSql:L,queryKey:S,refetch:P,errorMessage:$}=s.useDashboardCardQuery(l);D.useEffect(()=>{if(M&&(M.rowLimitExceeded&&s.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),f((M==null?void 0:M.output)||""),M.records.length>0)){const{dimensionKeys:B}=s.getKeys(M.records);p(B)}},[M,p,f]),D.useEffect(()=>{(N||b)&&T(!0),(F||A)&&T(!1),F&&(p([]),f(""))},[N,b,M,f,F,A,T,p,E]),D.useEffect(()=>{g&&(t.getQueryData(S)||P(),y(!1))},[g,P,y,S,t]);const J=D.useRef(P);J.current=P,D.useEffect(()=>{if(x.current){x.current=!1;return}J.current()},[u]);async function K(){const B=`Can you help me debug this query?
|
|
178
178
|
|
|
179
179
|
Error:
|
|
180
180
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),e=require("./index-
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),e=require("./index-C39yXWHP.js"),v=require("./use-visual-utils-D4_F3SrQ.js"),C=require("react");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as u, jsx as y, Fragment as C } from "react/jsx-runtime";
|
|
2
|
-
import { b as K, e as b, f as t, B as S, c as g, C as Q, u as D, g as F, L as z, h as I, i as k, j as E, k as B, X as L, l as h } from "./index-
|
|
3
|
-
import { u as M, a as N } from "./use-visual-utils-
|
|
2
|
+
import { b as K, e as b, f as t, B as S, c as g, C as Q, u as D, g as F, L as z, h as I, i as k, j as E, k as B, X as L, l as h } from "./index-CClisLGZ.js";
|
|
3
|
+
import { u as M, a as N } from "./use-visual-utils-BgJnVTRi.js";
|
|
4
4
|
import { useState as V } from "react";
|
|
5
5
|
/**
|
|
6
6
|
* @license lucide-react v0.453.0 - ISC
|