@askdb/studio 0.2.0-beta.26 → 0.2.0-beta.28
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/client/assets/{index-DYBXDl3K.js → index-DyBQErXG.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/execute-registry.d.ts +0 -4
- package/dist/execute-registry.d.ts.map +1 -1
- package/dist/execute-registry.js +29 -62
- package/dist/execute-registry.js.map +1 -1
- package/package.json +8 -5
|
@@ -66,4 +66,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
66
66
|
|
|
67
67
|
## Sensitive Interactions
|
|
68
68
|
|
|
69
|
-
`})}function C(){f&&a(f,p||void 0)}let w=h&&g&&_.trim();return u===`choose`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),`Enable Multi-Tenancy`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Configure tenant isolation for your schema`})]})}),d&&(0,L.jsx)(Dm,{status:d}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsx)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,L.jsxs)(`div`,{className:`grid-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},disabled:!n||d?.kind===`loading`,onClick:()=>void b(),children:(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[d?.kind===`loading`?(0,L.jsx)(Di,{size:20,className:`animate-spin`,style:{color:`var(--red-600)`}}):(0,L.jsx)(zi,{size:20,style:{color:`var(--red-600)`}}),(0,L.jsx)(`h3`,{style:{fontWeight:600},children:`Draft with AI`})]}),(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:d?.kind===`loading`?`Analyzing your schema...`:`Let AI analyze your schema and propose a complete tenant policy. You will review before saving.`}),!n&&(0,L.jsx)(`p`,{style:{marginTop:8,fontSize:12,color:`var(--red-600)`},children:`Configure an AI provider to use this option.`})]})}),(0,L.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},onClick:()=>l({type:`set_mode`,payload:`manual`}),children:(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,L.jsx)(Li,{size:20,style:{color:`var(--ink-400)`}}),(0,L.jsx)(`h3`,{style:{fontWeight:600},children:`Configure manually`})]}),(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`Pick the tenant root table and column yourself, then review before saving.`})]})})]})})})]}):u===`manual`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),`Manual Configuration`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Configure the basics, then review before saving`})]}),(0,L.jsx)(`div`,{className:`main-actions`,children:(0,L.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>l({type:`set_mode`,payload:`choose`}),children:`Back`})})]}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Tenant Root`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,L.jsx)($,{label:`Root table`,description:`The table whose rows represent tenants.`,children:(0,L.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:t=>{let n=t.target.value;l({type:`select_root_table`,tableId:n,label:e.find(e=>e.physical.id===n)?.physical.name??``})},children:[(0,L.jsx)(`option`,{value:``,children:`Select a table...`}),e.map(e=>(0,L.jsxs)(`option`,{value:e.physical.id,children:[e.physical.schema,`.`,e.physical.name]},e.physical.id))]})}),h&&(0,L.jsx)($,{label:`Tenant ID column`,description:`The column that uniquely identifies a tenant.`,children:(0,L.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:g,onChange:e=>l({type:`set_rootTenantIdColumn`,payload:e.target.value}),children:[(0,L.jsx)(`option`,{value:``,children:`Select a column...`}),y.map(e=>(0,L.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.type,e.primaryKey?`, PK`:``,`)`]},e.id))]})}),(0,L.jsx)($,{label:`Label`,description:`e.g. "Organization" or "Company"`,children:(0,L.jsx)(Np,{value:_,placeholder:`e.g. Organization`,onChange:e=>l({type:`set_rootLabel`,payload:e.target.value})})})]})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,L.jsx)(`button`,{type:`button`,className:m===`strict`?`active`:``,onClick:()=>l({type:`set_enforcement`,payload:`strict`}),children:`Strict`}),(0,L.jsx)(`button`,{type:`button`,className:m===`warn`?`active`:``,onClick:()=>l({type:`set_enforcement`,payload:`warn`}),children:`Warn`})]}),(0,L.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:m===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Global Tables (optional)`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>e.physical.id===h?null:(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:v.includes(e.physical.id),onChange:t=>l({type:`toggle_global_table`,tableId:e.physical.id,checked:t.target.checked})}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,L.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:x,disabled:!w,children:[(0,L.jsx)(gi,{size:14}),` Review & Confirm`]})})]})})]}):(0,L.jsx)(nh,{tables:e,frontmatter:f,body:p,busy:r,saveStatus:s,onFrontmatterChange:e=>l({type:`set_draftFrontmatter`,payload:e}),onBodyChange:e=>l({type:`set_draftBody`,payload:e}),onConfirm:C,onBack:()=>l({type:`set_mode`,payload:`choose`})})}function nh({tables:e,frontmatter:t,body:n,busy:r,saveStatus:a,onFrontmatterChange:o,onBodyChange:s,onConfirm:c,onBack:l,title:u=`Review Tenant Policy`,backLabel:d=`Start Over`,confirmLabel:f=`Confirm & Save`,badgeLabel:p=`Draft`}){function m(e){o({...t,enforcement:e})}function h(e,n){let r=[...t.roots];r[e]={...r[e],label:n},o({...t,roots:r})}function g(e){let n=t.roots.filter((t,n)=>n!==e);n.length!==0&&o({...t,roots:n})}function _(e){let n=(t.hierarchy??[]).filter((t,n)=>n!==e);o({...t,hierarchy:n.length>0?n:void 0})}function v(e){let n=(t.scopedTables??[]).filter((t,n)=>n!==e);o({...t,scopedTables:n.length>0?n:void 0})}function y(e){let n=(t.polymorphicTables??[]).filter((t,n)=>n!==e);o({...t,polymorphicTables:n.length>0?n:void 0})}function b(e){let n=t.globalTables??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];o({...t,globalTables:r.length>0?r:void 0})}let x=new Set(t.roots.map(e=>e.id)),S=new Set((t.scopedTables??[]).map(e=>e.id)),C=new Set((t.polymorphicTables??[]).map(e=>e.id)),w=new Set(t.globalTables??[]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),u]}),(0,L.jsx)(`div`,{className:`main-sub`,children:(0,L.jsx)(jm,{variant:`warning`,children:p})})]}),(0,L.jsxs)(`div`,{className:`main-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`btn`,onClick:l,children:[(0,L.jsx)(Fi,{size:14}),` `,d]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:c,disabled:r.has(`save-tenant-policy`)||t.roots.length===0,children:[r.has(`save-tenant-policy`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(z,{size:14}),f]})]})]}),a&&(0,L.jsx)(Dm,{status:a}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,L.jsx)(`button`,{type:`button`,className:t.enforcement===`strict`?`active`:``,onClick:()=>m(`strict`),children:`Strict`}),(0,L.jsx)(`button`,{type:`button`,className:t.enforcement===`warn`?`active`:``,onClick:()=>m(`warn`),children:`Warn`})]}),(0,L.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:t.enforcement===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Tenant Roots (`,t.roots.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:12},children:t.roots.map((e,n)=>(0,L.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsxs)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:[(0,L.jsxs)(jm,{variant:`outline`,children:[`col: `,e.tenantIdColumn]}),e.parent&&(0,L.jsxs)(jm,{variant:`outline`,children:[`parent: `,e.parent.root,` via `,e.parent.foreignKey]})]})]}),t.roots.length>1&&(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>g(n),title:`Remove root`,children:`×`})]}),(0,L.jsx)(`div`,{style:{marginTop:8},children:(0,L.jsx)($,{label:`Label`,description:`Human-readable name for this tenant root.`,children:(0,L.jsx)(Np,{value:e.label,onChange:e=>h(n,e.target.value)})})})]},e.id))})})]}),(t.hierarchy??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Hierarchy Edges (`,t.hierarchy.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.hierarchy.map(e=>(0,L.jsxs)(`div`,{className:`policy-edge-card`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`code`,{children:e.parent}),(0,L.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,L.jsx)(`code`,{children:e.child}),(0,L.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>_(i),title:`Remove`,children:`×`})]},`${e.parent}-${e.child}`))})})]}),(t.scopedTables??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Scoped Tables (`,t.scopedTables.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.scopedTables.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,L.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,L.jsx)(jm,{variant:`outline`,children:e.root}),` `,`column`in e?(0,L.jsxs)(`span`,{children:[`column `,(0,L.jsx)(`code`,{children:e.column})]}):(0,L.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>v(t),title:`Remove`,children:`×`})]},e.id))})})]}),(t.polymorphicTables??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Polymorphic Tables (`,t.polymorphicTables.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.polymorphicTables.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,L.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,L.jsx)(`code`,{children:e.idColumn})]}),(0,L.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,L.jsxs)(jm,{variant:`outline`,children:[e,` → `,t]},e))})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>y(t),title:`Remove`,children:`×`})]},e.id))})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Global Tables`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>x.has(e.physical.id)||S.has(e.physical.id)||C.has(e.physical.id)?null:(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:w.has(e.physical.id),onChange:()=>b(e.physical.id)}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Documentation (body)`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Optional markdown body explaining the tenant policy.`}),(0,L.jsx)(Pm,{className:`min-h-48 font-mono text-xs`,value:n,onChange:e=>s(e.target.value)})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Frontmatter Preview`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`pre`,{className:`plain-block`,style:{fontSize:12},children:JSON.stringify(t,null,2)})})]})]})})]})}function rh({title:e,count:t,children:n,defaultOpen:r=!0}){let[a,o]=(0,S.useState)(r);return(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`collapsible-btn`,onClick:()=>o(!a),children:[a?(0,L.jsx)(hi,{size:14}):(0,L.jsx)(gi,{size:14}),e,t==null?``:` (${t})`]}),a&&n]})}function ih({label:e,count:t,variant:n}){return(0,L.jsxs)(`div`,{className:`card`,style:{textAlign:`center`,padding:12,background:n===`primary`?`var(--red-50)`:n===`secondary`?`var(--surface-2)`:`#fef3c7`},children:[(0,L.jsx)(`div`,{style:{fontSize:24,fontWeight:700},children:t}),(0,L.jsx)(`div`,{className:`muted tiny`,children:e})]})}function ah(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function oh(e){return{schemaId:e.schemaId,enforcement:e.enforcement,roots:sh(e.roots),...e.hierarchy.length>0?{hierarchy:sh(e.hierarchy)}:{},...e.scopedTables.length>0?{scopedTables:sh(e.scopedTables)}:{},...e.polymorphicTables.length>0?{polymorphicTables:sh(e.polymorphicTables)}:{},...e.globalTables.length>0?{globalTables:[...e.globalTables]}:{}}}function sh(e){return JSON.parse(JSON.stringify(e))}function ch({text:e}){return(0,L.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:e})}function lh(){let{workspace:e}=wr(),{ragStatus:t,ragMessage:n,ragQuestion:r,setRagQuestion:a,ragK:o,setRagK:s,ragTypes:c,setRagTypes:l,ragResults:u,ragIndexUsage:d,busy:f,allChunkTypes:p,refreshRagStatus:m,handleBuildRag:h,handleQueryRag:g}=Lr();if(!e)return null;let _=!t?.hasIndex||t.stale||f.has(`rag-query`);return(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(zi,{size:18,style:{display:`inline`,marginRight:8}}),`RAG Index`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Retrieval-augmented generation index and query debugger`})]}),(0,L.jsxs)(`div`,{className:`main-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>void m(),children:[(0,L.jsx)(Pi,{size:14}),` Refresh`]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void h(),disabled:f.has(`rag-build`),children:[f.has(`rag-build`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(pi,{size:14}),`Build Index`]})]})]}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[n&&(0,L.jsx)(Om,{status:n}),t?(0,L.jsxs)(`div`,{className:`grid-4`,children:[(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Chunks`}),(0,L.jsx)(`div`,{className:`stat-num`,children:xr(t.chunksTotal)})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Indexed`}),(0,L.jsx)(`div`,{className:`stat-num`,children:xr(t.chunksIndexed)})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Sensitive excluded`}),(0,L.jsx)(`div`,{className:`stat-num`,children:t.sensitiveExcluded})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Sensitive included`}),(0,L.jsx)(`div`,{className:`stat-num`,children:t.sensitiveIncluded})]})]}):(0,L.jsx)(ch,{text:`RAG status is unavailable.`}),t&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Index Details`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginBottom:12},children:[(0,L.jsx)(jm,{variant:t.hasIndex?`secondary`:`warning`,children:t.hasIndex?`Index present`:`No index`}),(0,L.jsx)(jm,{variant:t.stale?`warning`:`secondary`,children:t.stale?`Stale`:`Fresh`}),(0,L.jsx)(jm,{variant:t.embedder.configured?`secondary`:`warning`,children:t.embedder.label})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:4,fontSize:12,color:`var(--ink-400)`},children:[(0,L.jsxs)(`span`,{children:[`Expected: `,t.expectedEmbedderId]}),(0,L.jsxs)(`span`,{children:[`Indexed: `,t.embedder.indexedId??`none`]}),(0,L.jsxs)(`span`,{children:[`Dimensions: `,t.dimensions,` / expected `,t.expectedDimensions]}),(0,L.jsxs)(`span`,{children:[`Updated: `,t.updatedAt??`never`]}),(0,L.jsxs)(`span`,{children:[`Store: `,t.store.kind]})]}),(0,L.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,L.jsx)(`i`,{style:{width:t.chunksTotal>0?`${Math.round(t.chunksIndexed/t.chunksTotal*100)}%`:`0%`}})})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Query Debugger`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,L.jsx)($,{label:`Question`,children:(0,L.jsx)(Pm,{value:r,onChange:e=>a(e.target.value),placeholder:`Which customers placed orders last month?`})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`120px 1fr`},children:[(0,L.jsx)($,{label:`Top K`,children:(0,L.jsx)(Np,{min:1,max:25,type:`number`,value:o,onChange:e=>s(Number(e.target.value))})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Chunk types`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:p.map(e=>(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{checked:c.includes(e),type:`checkbox`,onChange:t=>{t.target.checked?l([...c,e]):l(c.filter(t=>t!==e))}}),e]},e))})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:_,onClick:()=>void g(),children:[f.has(`rag-query`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(Ii,{size:14}),`Query RAG`]}),(0,L.jsx)(dh,{title:`Last Index Usage`,usage:d}),(0,L.jsx)(dh,{title:`Last Query Usage`,usage:u?.usage??null})]})})]}),(0,L.jsx)(uh,{chunks:u?.results??[],emptyText:`No chunks retrieved yet.`})]})})]})}function uh({chunks:e,emptyText:t}){return(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Retrieved Chunks`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:e.length>0?(0,L.jsx)(`div`,{style:{display:`grid`,gap:12},children:e.map(e=>(0,L.jsxs)(`article`,{className:`chunk-card`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,L.jsx)(`h4`,{style:{fontSize:13,fontWeight:600,wordBreak:`break-all`},children:e.id}),(0,L.jsx)(jm,{variant:`outline`,children:e.type}),e.sensitive&&(0,L.jsx)(jm,{variant:`danger`,children:`sensitive`})]}),(0,L.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:[`refs: `,e.refs.length>0?e.refs.join(`, `):`none`]})]}),(0,L.jsx)(jm,{variant:`secondary`,children:e.score.toFixed(3)})]}),(0,L.jsx)(`pre`,{className:`chunk-text`,children:e.text})]},e.id))}):(0,L.jsx)(ch,{text:t})})]})}function dh({title:e,usage:t}){if(!t)return null;let n=t.promptTokens??t.embeddingTokens;return(0,L.jsxs)(`section`,{className:`usage-summary`,"aria-label":e,children:[(0,L.jsx)(`h3`,{children:e}),(0,L.jsxs)(`dl`,{className:`usage-grid`,children:[n!==null&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:t.embeddingTokens===null?`Prompt`:`Embeddings`}),(0,L.jsx)(`dd`,{children:xr(n)})]}),t.completionTokens!==null&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Completion`}),(0,L.jsx)(`dd`,{children:xr(t.completionTokens)})]}),(0,L.jsxs)(`div`,{className:`usage-total`,children:[(0,L.jsx)(`dt`,{children:`Total`}),(0,L.jsx)(`dd`,{children:xr(t.totalTokens)})]})]})]})}function fh({value:e}){let[t,n]=(0,S.useState)(!1);return(0,L.jsxs)(Mp,{variant:`ghost`,size:`sm`,onClick:(0,S.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]),children:[t?(0,L.jsx)(mi,{className:`h-3.5 w-3.5 text-green-500`}):(0,L.jsx)(bi,{className:`h-3.5 w-3.5`}),t?`Copied`:`Copy`]})}var ph=`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,mh={border:0,padding:0,margin:0};function hh(e){return`${e}-${globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}function gh(){let{workspace:e}=wr(),{ragAvailable:t}=Lr(),{askQuestion:n,setAskQuestion:r,askMode:a,setAskMode:o,askMessage:s,askResult:c,askTenantEnabled:l,setAskTenantEnabled:u,askTenantAccessKind:d,setAskTenantAccessKind:f,askTenantRoot:p,setAskTenantRoot:m,askTenantIdsText:h,setAskTenantIdsText:g,askTenantMultiRootRows:_,setAskTenantMultiRootRows:v,askTenantGlobalReason:y,setAskTenantGlobalReason:b,askTenantContext:x,setAskTenantContext:C,askTenantContextAttributes:w,setAskTenantContextAttributes:T,askTenantFilterRows:E,setAskTenantFilterRows:D,generatedTenantScopeJson:ee,tenantScopeValidationError:O,askTenantSqlMode:te,setAskTenantSqlMode:k,executeResult:A,executeMessage:ne,executeStatus:j,historyEntries:re,busy:ie,handleAsk:M,handleExecute:N,loadHistoryEntry:ae,handleDeleteHistory:oe,handleInstallExecuteDriver:se}=Wr(),P=(0,S.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!ie.has(`ask`)&&(e.preventDefault(),M())},[ie,M]);if((0,S.useEffect)(()=>(document.addEventListener(`keydown`,P),()=>document.removeEventListener(`keydown`,P)),[P]),!e)return null;let F=!!e.tenantPolicy,I=e.tenantPolicy?.roots??[],ce=e.tenantPolicy?.polymorphicTables??[],le=I[0]?.id??``,ue=ce[0];return(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Mi,{size:18,style:{display:`inline`,marginRight:8}}),`Query Playground`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Generate SQL from natural language and execute it against your database`})]})}),(0,L.jsx)(`div`,{className:`main-body`,style:{overflow:`auto`},children:(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`2fr 3fr`,minHeight:`100%`},children:[(0,L.jsxs)(`div`,{style:{borderRight:`1px solid var(--border)`,display:`flex`,flexDirection:`column`},children:[(0,L.jsx)(`div`,{style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,L.jsx)($,{label:`Natural language question`,children:(0,L.jsx)(Pm,{value:n,onChange:e=>r(e.target.value),placeholder:`How many users placed orders last month?`,rows:4})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Retrieval mode`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Retrieval mode`}),(0,L.jsx)(`button`,{className:a===`full`?`active`:``,onClick:()=>o(`full`),children:`Full schema`}),(0,L.jsxs)(`button`,{className:a===`rag`?`active`:``,disabled:!t,title:t?void 0:`Build the RAG index first to query with retrieval.`,onClick:()=>o(`rag`),children:[!t&&(0,L.jsx)(Oi,{size:12,style:{display:`inline`,marginRight:4}}),`RAG`]})]})]}),F&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,L.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,L.jsxs)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600},children:[(0,L.jsx)(Ri,{size:12,style:{display:`inline`,marginRight:4}}),`Tenant scope`]})]}),l&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Access kind`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Tenant scope access kind`}),(0,L.jsx)(`button`,{className:d===`ids`?`active`:``,onClick:()=>f(`ids`),children:`IDs`}),(0,L.jsx)(`button`,{className:d===`subtree`?`active`:``,onClick:()=>f(`subtree`),children:`Subtree`}),(0,L.jsx)(`button`,{className:d===`multi_root`?`active`:``,onClick:()=>f(`multi_root`),children:`Multi-root`}),(0,L.jsx)(`button`,{className:d===`global`?`active`:``,onClick:()=>f(`global`),children:`Super / global`})]})]}),(d===`ids`||d===`subtree`)&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,L.jsx)($,{label:`Tenant root`,children:(0,L.jsx)(`select`,{className:ph,value:p,onChange:e=>m(e.target.value),children:I.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id))})}),(0,L.jsx)($,{label:d===`ids`?`Tenant IDs`:`Subtree root IDs`,description:`Comma-separated IDs from your app's auth context.`,children:(0,L.jsx)(Np,{value:h,onChange:e=>g(e.target.value),placeholder:d===`ids`?`org-1, org-2`:`region-1`})})]}),d===`multi_root`&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[_.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Tenant root`,className:`min-w-0`,children:(0,L.jsx)(`select`,{className:ph,value:e.tenantRoot,onChange:n=>{let r=[..._];r[t]={...e,tenantRoot:n.target.value},v(r)},children:I.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id))})}),(0,L.jsx)($,{label:`IDs`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.idsText,onChange:n=>{let r=[..._];r[t]={...e,idsText:n.target.value},v(r)},placeholder:`org-1, org-2`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,disabled:_.length===1,onClick:()=>v(_.filter((e,n)=>n!==t)),title:`Remove scope row`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>v([..._,{id:hh(`multi-root`),tenantRoot:le,idsText:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add root`]})})]}),d===`global`&&(0,L.jsx)($,{label:`Super / global reason`,description:`Required for audit context.`,children:(0,L.jsx)(Np,{value:y,onChange:e=>b(e.target.value),placeholder:`superuser access for support investigation`})}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{className:`muted`,style:{cursor:`pointer`,fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Advisory context`}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8,marginTop:8},children:[(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:8},children:[(0,L.jsx)($,{label:`Role`,children:(0,L.jsx)(Np,{value:x.role,onChange:e=>C({...x,role:e.target.value}),placeholder:`regional_manager`})}),(0,L.jsx)($,{label:`Label`,children:(0,L.jsx)(Np,{value:x.label,onChange:e=>C({...x,label:e.target.value}),placeholder:`Jane Smith, Northeast`})}),(0,L.jsx)($,{label:`Department`,children:(0,L.jsx)(Np,{value:x.department,onChange:e=>C({...x,department:e.target.value}),placeholder:`operations`})}),(0,L.jsx)($,{label:`Region`,children:(0,L.jsx)(Np,{value:x.region,onChange:e=>C({...x,region:e.target.value}),placeholder:`northeast`})})]}),(0,L.jsx)($,{label:`Description`,children:(0,L.jsx)(Pm,{value:x.description,onChange:e=>C({...x,description:e.target.value}),placeholder:`Business context for this user's scope.`,rows:2})}),w.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Attribute key`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.key,onChange:n=>{let r=[...w];r[t]={...e,key:n.target.value},T(r)},placeholder:`team`})}),(0,L.jsx)($,{label:`Attribute value`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.value,onChange:n=>{let r=[...w];r[t]={...e,value:n.target.value},T(r)},placeholder:`field-sales`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>T(w.filter((e,n)=>n!==t)),title:`Remove attribute`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>T([...w,{id:hh(`context-attribute`),key:``,value:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add attribute`]})})]})]}),ce.length>0&&(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{className:`muted`,style:{cursor:`pointer`,fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Tenant filters`}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8,marginTop:8},children:[E.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1.2fr) minmax(0, 1fr) 88px minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Table`,className:`min-w-0`,children:(0,L.jsx)(`select`,{className:ph,value:e.tableId,onChange:n=>{let r=ce.find(e=>e.id===n.target.value),a=[...E];a[t]={...e,tableId:n.target.value,column:e.column||r?.typeColumn||``},D(a)},children:ce.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.id},e.id))})}),(0,L.jsx)($,{label:`Column`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.column,onChange:n=>{let r=[...E];r[t]={...e,column:n.target.value},D(r)},placeholder:`owner_type`})}),(0,L.jsx)($,{label:`Operator`,className:`min-w-0`,children:(0,L.jsxs)(`select`,{className:ph,value:e.operator,onChange:n=>{let r=[...E];r[t]={...e,operator:n.target.value},D(r)},children:[(0,L.jsx)(`option`,{value:`=`,children:`=`}),(0,L.jsx)(`option`,{value:`IN`,children:`IN`}),(0,L.jsx)(`option`,{value:`!=`,children:`!=`}),(0,L.jsx)(`option`,{value:`NOT IN`,children:`NOT IN`})]})}),(0,L.jsx)($,{label:`Value`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.valueText,onChange:n=>{let r=[...E];r[t]={...e,valueText:n.target.value},D(r)},placeholder:e.operator===`IN`||e.operator===`NOT IN`?`client, agency`:`client`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>D(E.filter((e,n)=>n!==t)),title:`Remove condition`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>D([...E,{id:hh(`tenant-filter`),tableId:ue.id,column:ue.typeColumn,operator:`=`,valueText:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add condition`]})})]})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`tenantScope JSON preview`}),ee&&(0,L.jsx)(fh,{value:ee})]}),(0,L.jsx)(`pre`,{className:`mono`,style:{minHeight:116,margin:0,overflow:`auto`,whiteSpace:`pre-wrap`,border:`1px solid var(--border)`,borderRadius:6,padding:10,fontSize:11,background:`var(--surface-2)`},children:ee||O||`Complete the tenant scope fields to preview the JSON passed to ask().`}),O&&(0,L.jsx)(`span`,{style:{color:`var(--red-600)`,fontSize:12},children:O})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`SQL output mode`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`SQL output mode`}),(0,L.jsx)(`button`,{className:te===`sql-only`?`active`:``,onClick:()=>k(`sql-only`),children:`Inline literals`}),(0,L.jsx)(`button`,{className:te===`sql-params`?`active`:``,onClick:()=>k(`sql-params`),children:`$N parameters`})]})]})]})]}),(0,L.jsxs)(`button`,{className:`btn primary`,disabled:ie.has(`ask`),onClick:()=>void M(),title:`Generate SQL (⌘↵)`,children:[ie.has(`ask`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(zi,{size:14}),`Generate SQL`,(0,L.jsx)(`kbd`,{className:`kbd`,style:{marginLeft:4,opacity:.7},children:`⌘↵`})]}),s&&(0,L.jsx)(Om,{status:s})]})}),re.length>0&&(0,L.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,flex:1,overflow:`auto`},children:[(0,L.jsx)(`div`,{style:{padding:`8px var(--pad-x)`},children:(0,L.jsxs)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`History (`,re.length,`)`]})}),(0,L.jsx)(`div`,{children:re.slice(0,20).map(e=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`6px var(--pad-x)`,cursor:`pointer`,fontSize:12,borderBottom:`1px solid var(--border)`},onClick:()=>ae(e),children:[(0,L.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:e.question}),(0,L.jsx)(`span`,{className:`chip ${e.mode===`rag`?`red`:``}`,style:{flexShrink:0},children:e.mode}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:t=>{t.stopPropagation(),oe(e.id)},title:`Delete`,style:{flexShrink:0,padding:2},children:`×`})]},e.id))})]})]}),(0,L.jsx)(`div`,{style:{overflow:`auto`},children:c?(0,L.jsxs)(`div`,{style:{display:`grid`,gap:0},children:[(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600},children:`Generated SQL`}),c.sql&&(0,L.jsx)(fh,{value:c.sql})]}),c.sql?(0,L.jsx)(`pre`,{className:`sql-block`,children:c.sql}):(0,L.jsx)(ch,{text:`No SQL generated.`})]}),c.explain!==null&&c.explain!==void 0&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600,marginBottom:8},children:`Explain`}),(0,L.jsx)(`pre`,{className:`plain-block`,children:_h(c.explain)})]}),c.tenant?.enabled&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600,marginBottom:8},children:`Tenant Params`}),c.tenant.params.length>0?(0,L.jsxs)(`div`,{style:{padding:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,fontSize:12},children:[(0,L.jsx)(`span`,{style:{fontWeight:600},children:`Positional params:`}),` `,(0,L.jsx)(`code`,{children:JSON.stringify(c.tenant.params)})]}):(0,L.jsx)(ch,{text:`No tenant params.`})]}),(0,L.jsxs)(`div`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:8},children:[j&&(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600},children:j.label}),j.configured?(0,L.jsx)(`span`,{className:`chip`,style:{fontSize:11},children:j.connectionKind===`file`?`file configured`:`URL configured`}):(0,L.jsx)(`span`,{className:`chip red`,style:{fontSize:11},children:j.connectionKind===`file`?`no file`:`no URL`}),j.installed?(0,L.jsxs)(`span`,{className:`chip`,style:{fontSize:11},children:[j.packageName,` ready`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`chip red`,style:{fontSize:11},children:[j.packageName,` missing`]}),j.canInstallFromStudio&&(0,L.jsxs)(`button`,{className:`btn ghost sm`,disabled:ie.has(`install-driver`),onClick:()=>void se(),style:{fontSize:11},children:[ie.has(`install-driver`)?(0,L.jsx)(Di,{size:12,className:`animate-spin`}):null,`Install `,j.packageName]}),!j.canInstallFromStudio&&j.manualInstallReason&&(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11},children:j.installCommand})]})]}),(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[(0,L.jsxs)(`button`,{className:`btn primary`,disabled:ie.has(`execute`)||!c.sql||j!==null&&(!j.configured||!j.installed),onClick:()=>void N(),children:[ie.has(`execute`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(Mi,{size:14}),`Execute Query`]}),ne&&(0,L.jsx)(Om,{status:ne})]})]}),A?.ok===!0&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600},children:`Results`}),A.truncated&&(0,L.jsx)(`span`,{className:`chip amber`,children:`Showing first 500 rows`})]}),A.columns&&A.rows?(0,L.jsx)(`div`,{style:{overflowX:`auto`},children:(0,L.jsxs)(`table`,{className:`tbl`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:A.columns.map(e=>(0,L.jsx)(`th`,{children:e},e))})}),(0,L.jsx)(`tbody`,{children:A.rows.map((e,t)=>(0,L.jsx)(`tr`,{children:e.map((e,t)=>(0,L.jsx)(`td`,{className:`mono`,style:{fontSize:11},children:e==null?(0,L.jsx)(`span`,{className:`muted`,children:`NULL`}):String(e)},t))},t))})]})}):(0,L.jsx)(ch,{text:`No results.`})]})]}):(0,L.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,padding:32},children:(0,L.jsx)(ch,{text:`Ask a question to generate SQL`})})})]})})]})}function _h(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function vh(){let{workspace:e}=wr(),{ragStatus:t}=Lr();return e?(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Li,{size:18,style:{display:`inline`,marginRight:8}}),`Settings`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Workspace configuration and diagnostics`})]})}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Workspace`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`dl`,{className:`definition-list`,children:[(0,L.jsx)(`dt`,{children:`Schema ID`}),(0,L.jsx)(`dd`,{children:e.schemaId}),(0,L.jsx)(`dt`,{children:`Schema path`}),(0,L.jsx)(`dd`,{children:e.schemaDir}),(0,L.jsx)(`dt`,{children:`AI provider`}),(0,L.jsx)(`dd`,{children:e.aiProvider}),(0,L.jsx)(`dt`,{children:`Model`}),(0,L.jsx)(`dd`,{children:e.model}),(0,L.jsx)(`dt`,{children:`AI suggestions`}),(0,L.jsx)(`dd`,{children:e.aiConfigured?`Configured`:`Not configured`})]})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`RAG Store`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:t?(0,L.jsxs)(`dl`,{className:`definition-list`,children:[(0,L.jsx)(`dt`,{children:`Store`}),(0,L.jsx)(`dd`,{children:t.store.kind}),(0,L.jsx)(`dt`,{children:`Lock file`}),(0,L.jsx)(`dd`,{children:t.files.lock?`present`:`missing`}),t.store.kind===`file`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Base path`}),(0,L.jsx)(`dd`,{children:t.store.basePath??`n/a`}),(0,L.jsx)(`dt`,{children:`Embeddings JSON`}),(0,L.jsx)(`dd`,{children:t.files.embeddingsJson?`present`:`missing`}),(0,L.jsx)(`dt`,{children:`Embeddings binary`}),(0,L.jsx)(`dd`,{children:t.files.embeddingsBin?`present`:`missing`})]}),t.store.kind===`pgvector`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Table`}),(0,L.jsx)(`dd`,{children:t.store.table??`askdb_rag_chunks`}),(0,L.jsx)(`dt`,{children:`Index strategy`}),(0,L.jsx)(`dd`,{children:t.store.indexStrategy??`default`})]}),t.store.kind===`memory`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Persistence`}),(0,L.jsx)(`dd`,{children:`In-process only`})]})]}):(0,L.jsx)(ch,{text:`RAG status is unavailable.`})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Schema Warnings`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:e.warnings.length>0?(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.warnings.map((e,t)=>(0,L.jsx)(`pre`,{className:`warning-block`,children:typeof e==`string`?e:JSON.stringify(e,null,2)},t))}):(0,L.jsx)(ch,{text:`No schema warnings.`})})]})]})})]}):null}function yh(){return(0,L.jsx)($n,{children:(0,L.jsx)(Dr,{children:(0,L.jsx)(Br,{children:(0,L.jsx)(bh,{})})})})}function bh(){let{load:e,loadState:t,suggestionDialog:n,setSuggestionDialog:r,applySuggestion:a}=wr(),{refreshRagStatus:o,ragAvailable:s}=Lr();return(0,S.useEffect)(()=>{e().then(()=>void o())},[e,o]),t.kind===`loading`?(0,L.jsx)(`div`,{className:`app-shell`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,L.jsx)(`p`,{style:{color:`var(--ink-400)`,fontSize:13},children:`Loading workspace…`})}):t.kind===`error`?(0,L.jsx)(`div`,{className:`app-shell`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,L.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,L.jsx)(`p`,{style:{color:`var(--red-600)`,fontWeight:600,marginBottom:8},children:`Failed to load workspace`}),(0,L.jsx)(`p`,{style:{color:`var(--ink-400)`,fontSize:13},children:t.message})]})}):(0,L.jsxs)(Gr,{ragAvailable:s,children:[(0,L.jsxs)(em,{defaultOpen:!0,className:`!min-h-0 h-svh`,style:{"--sidebar-width":`var(--nav-w)`},children:[(0,L.jsx)(ym,{}),(0,L.jsxs)(rm,{className:`min-h-0 overflow-hidden`,children:[(0,L.jsxs)(`header`,{className:`topbar`,children:[(0,L.jsx)(nm,{className:`-ml-1`}),(0,L.jsx)(Pp,{orientation:`vertical`,className:`mr-2 !h-4`}),(0,L.jsx)(hm,{})]}),(0,L.jsx)(`div`,{className:`app-content`,children:(0,L.jsxs)(Rt,{children:[(0,L.jsx)(It,{path:`/`,element:(0,L.jsx)(Pt,{to:`/overview`,replace:!0})}),(0,L.jsx)(It,{path:`/overview`,element:(0,L.jsx)(xm,{})}),(0,L.jsx)(It,{path:`/tables`,element:(0,L.jsx)(Em,{}),children:(0,L.jsxs)(It,{path:`:schema/:name`,element:(0,L.jsx)(km,{}),children:[(0,L.jsx)(It,{index:!0,element:(0,L.jsx)(Pt,{to:`enrichment`,replace:!0})}),(0,L.jsx)(It,{path:`enrichment`,element:(0,L.jsx)(Fm,{})}),(0,L.jsx)(It,{path:`schema`,element:(0,L.jsx)(Rm,{})}),(0,L.jsx)(It,{path:`sensitivity`,element:(0,L.jsx)(zm,{})})]})}),(0,L.jsx)(It,{path:`/concepts`,element:(0,L.jsx)(Wm,{})}),(0,L.jsx)(It,{path:`/tenancy`,element:(0,L.jsx)(Xm,{})}),(0,L.jsx)(It,{path:`/rag-index`,element:(0,L.jsx)(lh,{})}),(0,L.jsx)(It,{path:`/playground`,element:(0,L.jsx)(gh,{})}),(0,L.jsx)(It,{path:`/settings`,element:(0,L.jsx)(vh,{})})]})})]})]}),n&&(0,L.jsx)(bm,{dialog:n,onApply:a,onClose:()=>r(null)})]})}var xh=document.getElementById(`root`);if(!xh)throw Error(`Missing #root element.`);(0,Yn.createRoot)(xh).render((0,L.jsx)(S.StrictMode,{children:(0,L.jsx)(En,{children:(0,L.jsx)(yh,{})})}));
|
|
69
|
+
`})}function C(){f&&a(f,p||void 0)}let w=h&&g&&_.trim();return u===`choose`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),`Enable Multi-Tenancy`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Configure tenant isolation for your schema`})]})}),d&&(0,L.jsx)(Dm,{status:d}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsx)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,L.jsxs)(`div`,{className:`grid-2`,children:[(0,L.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},disabled:!n||d?.kind===`loading`,onClick:()=>void b(),children:(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[d?.kind===`loading`?(0,L.jsx)(Di,{size:20,className:`animate-spin`,style:{color:`var(--red-600)`}}):(0,L.jsx)(zi,{size:20,style:{color:`var(--red-600)`}}),(0,L.jsx)(`h3`,{style:{fontWeight:600},children:`Draft with AI`})]}),(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:d?.kind===`loading`?`Analyzing your schema...`:`Let AI analyze your schema and propose a complete tenant policy. You will review before saving.`}),!n&&(0,L.jsx)(`p`,{style:{marginTop:8,fontSize:12,color:`var(--red-600)`},children:`Configure an AI provider to use this option.`})]})}),(0,L.jsx)(`button`,{type:`button`,className:`card`,style:{cursor:`pointer`,textAlign:`left`,border:`2px dashed var(--border)`},onClick:()=>l({type:`set_mode`,payload:`manual`}),children:(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,marginBottom:12},children:[(0,L.jsx)(Li,{size:20,style:{color:`var(--ink-400)`}}),(0,L.jsx)(`h3`,{style:{fontWeight:600},children:`Configure manually`})]}),(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13},children:`Pick the tenant root table and column yourself, then review before saving.`})]})})]})})})]}):u===`manual`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),`Manual Configuration`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Configure the basics, then review before saving`})]}),(0,L.jsx)(`div`,{className:`main-actions`,children:(0,L.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>l({type:`set_mode`,payload:`choose`}),children:`Back`})})]}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Tenant Root`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:16},children:[(0,L.jsx)($,{label:`Root table`,description:`The table whose rows represent tenants.`,children:(0,L.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:t=>{let n=t.target.value;l({type:`select_root_table`,tableId:n,label:e.find(e=>e.physical.id===n)?.physical.name??``})},children:[(0,L.jsx)(`option`,{value:``,children:`Select a table...`}),e.map(e=>(0,L.jsxs)(`option`,{value:e.physical.id,children:[e.physical.schema,`.`,e.physical.name]},e.physical.id))]})}),h&&(0,L.jsx)($,{label:`Tenant ID column`,description:`The column that uniquely identifies a tenant.`,children:(0,L.jsxs)(`select`,{className:`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:g,onChange:e=>l({type:`set_rootTenantIdColumn`,payload:e.target.value}),children:[(0,L.jsx)(`option`,{value:``,children:`Select a column...`}),y.map(e=>(0,L.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.type,e.primaryKey?`, PK`:``,`)`]},e.id))]})}),(0,L.jsx)($,{label:`Label`,description:`e.g. "Organization" or "Company"`,children:(0,L.jsx)(Np,{value:_,placeholder:`e.g. Organization`,onChange:e=>l({type:`set_rootLabel`,payload:e.target.value})})})]})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,L.jsx)(`button`,{type:`button`,className:m===`strict`?`active`:``,onClick:()=>l({type:`set_enforcement`,payload:`strict`}),children:`Strict`}),(0,L.jsx)(`button`,{type:`button`,className:m===`warn`?`active`:``,onClick:()=>l({type:`set_enforcement`,payload:`warn`}),children:`Warn`})]}),(0,L.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:m===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Global Tables (optional)`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>e.physical.id===h?null:(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:v.includes(e.physical.id),onChange:t=>l({type:`toggle_global_table`,tableId:e.physical.id,checked:t.target.checked})}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,L.jsx)(`div`,{style:{display:`flex`,justifyContent:`flex-end`},children:(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:x,disabled:!w,children:[(0,L.jsx)(gi,{size:14}),` Review & Confirm`]})})]})})]}):(0,L.jsx)(nh,{tables:e,frontmatter:f,body:p,busy:r,saveStatus:s,onFrontmatterChange:e=>l({type:`set_draftFrontmatter`,payload:e}),onBodyChange:e=>l({type:`set_draftBody`,payload:e}),onConfirm:C,onBack:()=>l({type:`set_mode`,payload:`choose`})})}function nh({tables:e,frontmatter:t,body:n,busy:r,saveStatus:a,onFrontmatterChange:o,onBodyChange:s,onConfirm:c,onBack:l,title:u=`Review Tenant Policy`,backLabel:d=`Start Over`,confirmLabel:f=`Confirm & Save`,badgeLabel:p=`Draft`}){function m(e){o({...t,enforcement:e})}function h(e,n){let r=[...t.roots];r[e]={...r[e],label:n},o({...t,roots:r})}function g(e){let n=t.roots.filter((t,n)=>n!==e);n.length!==0&&o({...t,roots:n})}function _(e){let n=(t.hierarchy??[]).filter((t,n)=>n!==e);o({...t,hierarchy:n.length>0?n:void 0})}function v(e){let n=(t.scopedTables??[]).filter((t,n)=>n!==e);o({...t,scopedTables:n.length>0?n:void 0})}function y(e){let n=(t.polymorphicTables??[]).filter((t,n)=>n!==e);o({...t,polymorphicTables:n.length>0?n:void 0})}function b(e){let n=t.globalTables??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];o({...t,globalTables:r.length>0?r:void 0})}let x=new Set(t.roots.map(e=>e.id)),S=new Set((t.scopedTables??[]).map(e=>e.id)),C=new Set((t.polymorphicTables??[]).map(e=>e.id)),w=new Set(t.globalTables??[]);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Ri,{size:18,style:{display:`inline`,marginRight:8}}),u]}),(0,L.jsx)(`div`,{className:`main-sub`,children:(0,L.jsx)(jm,{variant:`warning`,children:p})})]}),(0,L.jsxs)(`div`,{className:`main-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`btn`,onClick:l,children:[(0,L.jsx)(Fi,{size:14}),` `,d]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:c,disabled:r.has(`save-tenant-policy`)||t.roots.length===0,children:[r.has(`save-tenant-policy`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(z,{size:14}),f]})]})]}),a&&(0,L.jsx)(Dm,{status:a}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Enforcement Mode`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,children:[(0,L.jsx)(`button`,{type:`button`,className:t.enforcement===`strict`?`active`:``,onClick:()=>m(`strict`),children:`Strict`}),(0,L.jsx)(`button`,{type:`button`,className:t.enforcement===`warn`?`active`:``,onClick:()=>m(`warn`),children:`Warn`})]}),(0,L.jsx)(`p`,{className:`muted tiny`,style:{marginTop:8},children:t.enforcement===`strict`?`Queries touching unknown (unscoped) tables will be rejected.`:`Queries touching unknown tables will succeed but emit warnings.`})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Tenant Roots (`,t.roots.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:12},children:t.roots.map((e,n)=>(0,L.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsxs)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:[(0,L.jsxs)(jm,{variant:`outline`,children:[`col: `,e.tenantIdColumn]}),e.parent&&(0,L.jsxs)(jm,{variant:`outline`,children:[`parent: `,e.parent.root,` via `,e.parent.foreignKey]})]})]}),t.roots.length>1&&(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>g(n),title:`Remove root`,children:`×`})]}),(0,L.jsx)(`div`,{style:{marginTop:8},children:(0,L.jsx)($,{label:`Label`,description:`Human-readable name for this tenant root.`,children:(0,L.jsx)(Np,{value:e.label,onChange:e=>h(n,e.target.value)})})})]},e.id))})})]}),(t.hierarchy??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Hierarchy Edges (`,t.hierarchy.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.hierarchy.map(e=>(0,L.jsxs)(`div`,{className:`policy-edge-card`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`code`,{children:e.parent}),(0,L.jsx)(`span`,{className:`muted`,style:{margin:`0 8px`},children:`→`}),(0,L.jsx)(`code`,{children:e.child}),(0,L.jsxs)(`div`,{className:`muted tiny`,style:{marginTop:4},children:[`FK: `,e.foreignKey]})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>_(i),title:`Remove`,children:`×`})]},`${e.parent}-${e.child}`))})})]}),(t.scopedTables??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Scoped Tables (`,t.scopedTables.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.scopedTables.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsx)(`div`,{style:{marginTop:4,display:`grid`,gap:4},children:e.scopeThrough.map((e,t)=>(0,L.jsxs)(`p`,{className:`muted tiny`,children:[`via `,(0,L.jsx)(jm,{variant:`outline`,children:e.root}),` `,`column`in e?(0,L.jsxs)(`span`,{children:[`column `,(0,L.jsx)(`code`,{children:e.column})]}):(0,L.jsxs)(`span`,{children:[`join `,e.join.map(e=>`${e.from} -> ${e.to}`).join(`, `)]})]},t))})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>v(t),title:`Remove`,children:`×`})]},e.id))})})]}),(t.polymorphicTables??[]).length>0&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsxs)(`h3`,{children:[`Polymorphic Tables (`,t.polymorphicTables.length,`)`]})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:t.polymorphicTables.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,padding:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`span`,{className:`mono`,style:{fontWeight:600,fontSize:13},children:e.id}),(0,L.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4},children:[`Type: `,(0,L.jsx)(`code`,{children:e.typeColumn}),` · ID: `,(0,L.jsx)(`code`,{children:e.idColumn})]}),(0,L.jsx)(`div`,{style:{marginTop:4,display:`flex`,flexWrap:`wrap`,gap:4},children:Object.entries(e.mapping).map(([e,t])=>(0,L.jsxs)(jm,{variant:`outline`,children:[e,` → `,t]},e))})]}),(0,L.jsx)(`button`,{type:`button`,className:`btn ghost sm`,onClick:()=>y(t),title:`Remove`,children:`×`})]},e.id))})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Global Tables`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Global tables are shared across all tenants and never filtered.`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:e.map(e=>x.has(e.physical.id)||S.has(e.physical.id)||C.has(e.physical.id)?null:(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:w.has(e.physical.id),onChange:()=>b(e.physical.id)}),e.physical.schema,`.`,e.physical.name]},e.physical.id))})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Documentation (body)`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsx)(`p`,{className:`muted`,style:{fontSize:13,marginBottom:8},children:`Optional markdown body explaining the tenant policy.`}),(0,L.jsx)(Pm,{className:`min-h-48 font-mono text-xs`,value:n,onChange:e=>s(e.target.value)})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Frontmatter Preview`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsx)(`pre`,{className:`plain-block`,style:{fontSize:12},children:JSON.stringify(t,null,2)})})]})]})})]})}function rh({title:e,count:t,children:n,defaultOpen:r=!0}){let[a,o]=(0,S.useState)(r);return(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`button`,{type:`button`,className:`collapsible-btn`,onClick:()=>o(!a),children:[a?(0,L.jsx)(hi,{size:14}):(0,L.jsx)(gi,{size:14}),e,t==null?``:` (${t})`]}),a&&n]})}function ih({label:e,count:t,variant:n}){return(0,L.jsxs)(`div`,{className:`card`,style:{textAlign:`center`,padding:12,background:n===`primary`?`var(--red-50)`:n===`secondary`?`var(--surface-2)`:`#fef3c7`},children:[(0,L.jsx)(`div`,{style:{fontSize:24,fontWeight:700},children:t}),(0,L.jsx)(`div`,{className:`muted tiny`,children:e})]})}function ah(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function oh(e){return{schemaId:e.schemaId,enforcement:e.enforcement,roots:sh(e.roots),...e.hierarchy.length>0?{hierarchy:sh(e.hierarchy)}:{},...e.scopedTables.length>0?{scopedTables:sh(e.scopedTables)}:{},...e.polymorphicTables.length>0?{polymorphicTables:sh(e.polymorphicTables)}:{},...e.globalTables.length>0?{globalTables:[...e.globalTables]}:{}}}function sh(e){return JSON.parse(JSON.stringify(e))}function ch({text:e}){return(0,L.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-6 text-center text-sm text-muted-foreground`,children:e})}function lh(){let{workspace:e}=wr(),{ragStatus:t,ragMessage:n,ragQuestion:r,setRagQuestion:a,ragK:o,setRagK:s,ragTypes:c,setRagTypes:l,ragResults:u,ragIndexUsage:d,busy:f,allChunkTypes:p,refreshRagStatus:m,handleBuildRag:h,handleQueryRag:g}=Lr();if(!e)return null;let _=!t?.hasIndex||t.stale||f.has(`rag-query`);return(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsxs)(`div`,{className:`main-hd`,children:[(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(zi,{size:18,style:{display:`inline`,marginRight:8}}),`RAG Index`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Retrieval-augmented generation index and query debugger`})]}),(0,L.jsxs)(`div`,{className:`main-actions`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>void m(),children:[(0,L.jsx)(Pi,{size:14}),` Refresh`]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>void h(),disabled:f.has(`rag-build`),children:[f.has(`rag-build`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(pi,{size:14}),`Build Index`]})]})]}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[n&&(0,L.jsx)(Om,{status:n}),t?(0,L.jsxs)(`div`,{className:`grid-4`,children:[(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Chunks`}),(0,L.jsx)(`div`,{className:`stat-num`,children:xr(t.chunksTotal)})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Indexed`}),(0,L.jsx)(`div`,{className:`stat-num`,children:xr(t.chunksIndexed)})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Sensitive excluded`}),(0,L.jsx)(`div`,{className:`stat-num`,children:t.sensitiveExcluded})]}),(0,L.jsxs)(`div`,{className:`card stat-card`,children:[(0,L.jsx)(`div`,{className:`stat-label`,children:`Sensitive included`}),(0,L.jsx)(`div`,{className:`stat-num`,children:t.sensitiveIncluded})]})]}):(0,L.jsx)(ch,{text:`RAG status is unavailable.`}),t&&(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Index Details`})}),(0,L.jsxs)(`div`,{className:`card-bd`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8,marginBottom:12},children:[(0,L.jsx)(jm,{variant:t.hasIndex?`secondary`:`warning`,children:t.hasIndex?`Index present`:`No index`}),(0,L.jsx)(jm,{variant:t.stale?`warning`:`secondary`,children:t.stale?`Stale`:`Fresh`}),(0,L.jsx)(jm,{variant:t.embedder.configured?`secondary`:`warning`,children:t.embedder.label})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:4,fontSize:12,color:`var(--ink-400)`},children:[(0,L.jsxs)(`span`,{children:[`Expected: `,t.expectedEmbedderId]}),(0,L.jsxs)(`span`,{children:[`Indexed: `,t.embedder.indexedId??`none`]}),(0,L.jsxs)(`span`,{children:[`Dimensions: `,t.dimensions,` / expected `,t.expectedDimensions]}),(0,L.jsxs)(`span`,{children:[`Updated: `,t.updatedAt??`never`]}),(0,L.jsxs)(`span`,{children:[`Store: `,t.store.kind]})]}),(0,L.jsx)(`div`,{className:`bar`,style:{marginTop:14},children:(0,L.jsx)(`i`,{style:{width:t.chunksTotal>0?`${Math.round(t.chunksIndexed/t.chunksTotal*100)}%`:`0%`}})})]})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Query Debugger`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,L.jsx)($,{label:`Question`,children:(0,L.jsx)(Pm,{value:r,onChange:e=>a(e.target.value),placeholder:`Which customers placed orders last month?`})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12,gridTemplateColumns:`120px 1fr`},children:[(0,L.jsx)($,{label:`Top K`,children:(0,L.jsx)(Np,{min:1,max:25,type:`number`,value:o,onChange:e=>s(Number(e.target.value))})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:12,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Chunk types`}),(0,L.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:8},children:p.map(e=>(0,L.jsxs)(`label`,{className:`chunk-toggle`,children:[(0,L.jsx)(`input`,{checked:c.includes(e),type:`checkbox`,onChange:t=>{t.target.checked?l([...c,e]):l(c.filter(t=>t!==e))}}),e]},e))})]})]}),(0,L.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:_,onClick:()=>void g(),children:[f.has(`rag-query`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(Ii,{size:14}),`Query RAG`]}),(0,L.jsx)(dh,{title:`Last Index Usage`,usage:d}),(0,L.jsx)(dh,{title:`Last Query Usage`,usage:u?.usage??null})]})})]}),(0,L.jsx)(uh,{chunks:u?.results??[],emptyText:`No chunks retrieved yet.`})]})})]})}function uh({chunks:e,emptyText:t}){return(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Retrieved Chunks`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:e.length>0?(0,L.jsx)(`div`,{style:{display:`grid`,gap:12},children:e.map(e=>(0,L.jsxs)(`article`,{className:`chunk-card`,children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`start`,justifyContent:`space-between`,gap:12},children:[(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:8},children:[(0,L.jsx)(`h4`,{style:{fontSize:13,fontWeight:600,wordBreak:`break-all`},children:e.id}),(0,L.jsx)(jm,{variant:`outline`,children:e.type}),e.sensitive&&(0,L.jsx)(jm,{variant:`danger`,children:`sensitive`})]}),(0,L.jsxs)(`p`,{className:`muted tiny`,style:{marginTop:4,wordBreak:`break-all`},children:[`refs: `,e.refs.length>0?e.refs.join(`, `):`none`]})]}),(0,L.jsx)(jm,{variant:`secondary`,children:e.score.toFixed(3)})]}),(0,L.jsx)(`pre`,{className:`chunk-text`,children:e.text})]},e.id))}):(0,L.jsx)(ch,{text:t})})]})}function dh({title:e,usage:t}){if(!t)return null;let n=t.promptTokens??t.embeddingTokens;return(0,L.jsxs)(`section`,{className:`usage-summary`,"aria-label":e,children:[(0,L.jsx)(`h3`,{children:e}),(0,L.jsxs)(`dl`,{className:`usage-grid`,children:[n!==null&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:t.embeddingTokens===null?`Prompt`:`Embeddings`}),(0,L.jsx)(`dd`,{children:xr(n)})]}),t.completionTokens!==null&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`dt`,{children:`Completion`}),(0,L.jsx)(`dd`,{children:xr(t.completionTokens)})]}),(0,L.jsxs)(`div`,{className:`usage-total`,children:[(0,L.jsx)(`dt`,{children:`Total`}),(0,L.jsx)(`dd`,{children:xr(t.totalTokens)})]})]})]})}function fh({value:e}){let[t,n]=(0,S.useState)(!1);return(0,L.jsxs)(Mp,{variant:`ghost`,size:`sm`,onClick:(0,S.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]),children:[t?(0,L.jsx)(mi,{className:`h-3.5 w-3.5 text-green-500`}):(0,L.jsx)(bi,{className:`h-3.5 w-3.5`}),t?`Copied`:`Copy`]})}var ph=`h-9 w-full rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,mh={border:0,padding:0,margin:0};function hh(e){return`${e}-${globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`}`}function gh(){let{workspace:e}=wr(),{ragAvailable:t}=Lr(),{askQuestion:n,setAskQuestion:r,askMode:a,setAskMode:o,askMessage:s,askResult:c,askTenantEnabled:l,setAskTenantEnabled:u,askTenantAccessKind:d,setAskTenantAccessKind:f,askTenantRoot:p,setAskTenantRoot:m,askTenantIdsText:h,setAskTenantIdsText:g,askTenantMultiRootRows:_,setAskTenantMultiRootRows:v,askTenantGlobalReason:y,setAskTenantGlobalReason:b,askTenantContext:x,setAskTenantContext:C,askTenantContextAttributes:w,setAskTenantContextAttributes:T,askTenantFilterRows:E,setAskTenantFilterRows:D,generatedTenantScopeJson:ee,tenantScopeValidationError:O,askTenantSqlMode:te,setAskTenantSqlMode:k,executeResult:A,executeMessage:ne,executeStatus:j,historyEntries:re,busy:ie,handleAsk:M,handleExecute:N,loadHistoryEntry:ae,handleDeleteHistory:oe,handleInstallExecuteDriver:se}=Wr(),P=(0,S.useCallback)(e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&!ie.has(`ask`)&&(e.preventDefault(),M())},[ie,M]);if((0,S.useEffect)(()=>(document.addEventListener(`keydown`,P),()=>document.removeEventListener(`keydown`,P)),[P]),!e)return null;let F=!!e.tenantPolicy,I=e.tenantPolicy?.roots??[],ce=e.tenantPolicy?.polymorphicTables??[],le=I[0]?.id??``,ue=ce[0];return(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Mi,{size:18,style:{display:`inline`,marginRight:8}}),`Query Playground`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Generate SQL from natural language and execute it against your database`})]})}),(0,L.jsx)(`div`,{className:`main-body`,style:{overflow:`hidden`,padding:0},children:(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`2fr 3fr`,height:`100%`},children:[(0,L.jsxs)(`div`,{style:{borderRight:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,overflow:`auto`},children:[(0,L.jsx)(`div`,{style:{padding:`var(--pad-y) var(--pad-x)`},children:(0,L.jsxs)(`div`,{style:{display:`grid`,gap:12},children:[(0,L.jsx)($,{label:`Natural language question`,children:(0,L.jsx)(Pm,{value:n,onChange:e=>r(e.target.value),placeholder:`How many users placed orders last month?`,rows:4})}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Retrieval mode`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Retrieval mode`}),(0,L.jsx)(`button`,{className:a===`full`?`active`:``,onClick:()=>o(`full`),children:`Full schema`}),(0,L.jsxs)(`button`,{className:a===`rag`?`active`:``,disabled:!t,title:t?void 0:`Build the RAG index first to query with retrieval.`,onClick:()=>o(`rag`),children:[!t&&(0,L.jsx)(Oi,{size:12,style:{display:`inline`,marginRight:4}}),`RAG`]})]})]}),F&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,L.jsxs)(`label`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),(0,L.jsxs)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600},children:[(0,L.jsx)(Ri,{size:12,style:{display:`inline`,marginRight:4}}),`Tenant scope`]})]}),l&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:10},children:[(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Access kind`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Tenant scope access kind`}),(0,L.jsx)(`button`,{className:d===`ids`?`active`:``,onClick:()=>f(`ids`),children:`IDs`}),(0,L.jsx)(`button`,{className:d===`subtree`?`active`:``,onClick:()=>f(`subtree`),children:`Subtree`}),(0,L.jsx)(`button`,{className:d===`multi_root`?`active`:``,onClick:()=>f(`multi_root`),children:`Multi-root`}),(0,L.jsx)(`button`,{className:d===`global`?`active`:``,onClick:()=>f(`global`),children:`Super / global`})]})]}),(d===`ids`||d===`subtree`)&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[(0,L.jsx)($,{label:`Tenant root`,children:(0,L.jsx)(`select`,{className:ph,value:p,onChange:e=>m(e.target.value),children:I.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id))})}),(0,L.jsx)($,{label:d===`ids`?`Tenant IDs`:`Subtree root IDs`,description:`Comma-separated IDs from your app's auth context.`,children:(0,L.jsx)(Np,{value:h,onChange:e=>g(e.target.value),placeholder:d===`ids`?`org-1, org-2`:`region-1`})})]}),d===`multi_root`&&(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8},children:[_.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Tenant root`,className:`min-w-0`,children:(0,L.jsx)(`select`,{className:ph,value:e.tenantRoot,onChange:n=>{let r=[..._];r[t]={...e,tenantRoot:n.target.value},v(r)},children:I.map(e=>(0,L.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id))})}),(0,L.jsx)($,{label:`IDs`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.idsText,onChange:n=>{let r=[..._];r[t]={...e,idsText:n.target.value},v(r)},placeholder:`org-1, org-2`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,disabled:_.length===1,onClick:()=>v(_.filter((e,n)=>n!==t)),title:`Remove scope row`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>v([..._,{id:hh(`multi-root`),tenantRoot:le,idsText:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add root`]})})]}),d===`global`&&(0,L.jsx)($,{label:`Super / global reason`,description:`Required for audit context.`,children:(0,L.jsx)(Np,{value:y,onChange:e=>b(e.target.value),placeholder:`superuser access for support investigation`})}),(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{className:`muted`,style:{cursor:`pointer`,fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Advisory context`}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8,marginTop:8},children:[(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr`,gap:8},children:[(0,L.jsx)($,{label:`Role`,children:(0,L.jsx)(Np,{value:x.role,onChange:e=>C({...x,role:e.target.value}),placeholder:`regional_manager`})}),(0,L.jsx)($,{label:`Label`,children:(0,L.jsx)(Np,{value:x.label,onChange:e=>C({...x,label:e.target.value}),placeholder:`Jane Smith, Northeast`})}),(0,L.jsx)($,{label:`Department`,children:(0,L.jsx)(Np,{value:x.department,onChange:e=>C({...x,department:e.target.value}),placeholder:`operations`})}),(0,L.jsx)($,{label:`Region`,children:(0,L.jsx)(Np,{value:x.region,onChange:e=>C({...x,region:e.target.value}),placeholder:`northeast`})})]}),(0,L.jsx)($,{label:`Description`,children:(0,L.jsx)(Pm,{value:x.description,onChange:e=>C({...x,description:e.target.value}),placeholder:`Business context for this user's scope.`,rows:2})}),w.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1fr) minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Attribute key`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.key,onChange:n=>{let r=[...w];r[t]={...e,key:n.target.value},T(r)},placeholder:`team`})}),(0,L.jsx)($,{label:`Attribute value`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.value,onChange:n=>{let r=[...w];r[t]={...e,value:n.target.value},T(r)},placeholder:`field-sales`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>T(w.filter((e,n)=>n!==t)),title:`Remove attribute`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>T([...w,{id:hh(`context-attribute`),key:``,value:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add attribute`]})})]})]}),ce.length>0&&(0,L.jsxs)(`details`,{children:[(0,L.jsx)(`summary`,{className:`muted`,style:{cursor:`pointer`,fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`Tenant filters`}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:8,marginTop:8},children:[E.map((e,t)=>(0,L.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`minmax(0, 1.2fr) minmax(0, 1fr) 88px minmax(0, 1fr) auto`,gap:8,alignItems:`end`},children:[(0,L.jsx)($,{label:`Table`,className:`min-w-0`,children:(0,L.jsx)(`select`,{className:ph,value:e.tableId,onChange:n=>{let r=ce.find(e=>e.id===n.target.value),a=[...E];a[t]={...e,tableId:n.target.value,column:e.column||r?.typeColumn||``},D(a)},children:ce.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.id},e.id))})}),(0,L.jsx)($,{label:`Column`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.column,onChange:n=>{let r=[...E];r[t]={...e,column:n.target.value},D(r)},placeholder:`owner_type`})}),(0,L.jsx)($,{label:`Operator`,className:`min-w-0`,children:(0,L.jsxs)(`select`,{className:ph,value:e.operator,onChange:n=>{let r=[...E];r[t]={...e,operator:n.target.value},D(r)},children:[(0,L.jsx)(`option`,{value:`=`,children:`=`}),(0,L.jsx)(`option`,{value:`IN`,children:`IN`}),(0,L.jsx)(`option`,{value:`!=`,children:`!=`}),(0,L.jsx)(`option`,{value:`NOT IN`,children:`NOT IN`})]})}),(0,L.jsx)($,{label:`Value`,className:`min-w-0`,children:(0,L.jsx)(Np,{value:e.valueText,onChange:n=>{let r=[...E];r[t]={...e,valueText:n.target.value},D(r)},placeholder:e.operator===`IN`||e.operator===`NOT IN`?`client, agency`:`client`})}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:()=>D(E.filter((e,n)=>n!==t)),title:`Remove condition`,children:(0,L.jsx)(Hi,{size:14})})]},e.id)),(0,L.jsx)(`div`,{children:(0,L.jsxs)(`button`,{className:`btn ghost sm`,onClick:()=>D([...E,{id:hh(`tenant-filter`),tableId:ue.id,column:ue.typeColumn,operator:`=`,valueText:``}]),children:[(0,L.jsx)(Ni,{size:14}),`Add condition`]})})]})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`tenantScope JSON preview`}),ee&&(0,L.jsx)(fh,{value:ee})]}),(0,L.jsx)(`pre`,{className:`mono`,style:{minHeight:116,margin:0,overflow:`auto`,whiteSpace:`pre-wrap`,border:`1px solid var(--border)`,borderRadius:6,padding:10,fontSize:11,background:`var(--surface-2)`},children:ee||O||`Complete the tenant scope fields to preview the JSON passed to ask().`}),O&&(0,L.jsx)(`span`,{style:{color:`var(--red-600)`,fontSize:12},children:O})]}),(0,L.jsxs)(`div`,{style:{display:`grid`,gap:6},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:`SQL output mode`}),(0,L.jsxs)(`fieldset`,{className:`toggle-seg`,style:mh,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`SQL output mode`}),(0,L.jsx)(`button`,{className:te===`sql-only`?`active`:``,onClick:()=>k(`sql-only`),children:`Inline literals`}),(0,L.jsx)(`button`,{className:te===`sql-params`?`active`:``,onClick:()=>k(`sql-params`),children:`$N parameters`})]})]})]})]}),(0,L.jsxs)(`button`,{className:`btn primary`,disabled:ie.has(`ask`),onClick:()=>void M(),title:`Generate SQL (⌘↵)`,children:[ie.has(`ask`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(zi,{size:14}),`Generate SQL`,(0,L.jsx)(`kbd`,{className:`kbd`,style:{marginLeft:4,opacity:.7},children:`⌘↵`})]}),s&&(0,L.jsx)(Om,{status:s})]})}),re.length>0&&(0,L.jsxs)(`div`,{style:{borderTop:`1px solid var(--border)`,flex:1,overflow:`auto`},children:[(0,L.jsx)(`div`,{style:{padding:`8px var(--pad-x)`},children:(0,L.jsxs)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600,textTransform:`uppercase`,letterSpacing:`0.04em`},children:[`History (`,re.length,`)`]})}),(0,L.jsx)(`div`,{children:re.slice(0,20).map(e=>(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:8,padding:`6px var(--pad-x)`,cursor:`pointer`,fontSize:12,borderBottom:`1px solid var(--border)`},onClick:()=>ae(e),children:[(0,L.jsx)(`span`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,flex:1},children:e.question}),(0,L.jsx)(`span`,{className:`chip ${e.mode===`rag`?`red`:``}`,style:{flexShrink:0},children:e.mode}),(0,L.jsx)(`button`,{className:`btn ghost sm`,onClick:t=>{t.stopPropagation(),oe(e.id)},title:`Delete`,style:{flexShrink:0,padding:2},children:`×`})]},e.id))})]})]}),(0,L.jsx)(`div`,{style:{overflow:`auto`},children:c?(0,L.jsxs)(`div`,{style:{display:`grid`,gap:0},children:[(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600},children:`Generated SQL`}),c.sql&&(0,L.jsx)(fh,{value:c.sql})]}),c.sql?(0,L.jsx)(`pre`,{className:`sql-block`,children:c.sql}):(0,L.jsx)(ch,{text:`No SQL generated.`})]}),c.explain!==null&&c.explain!==void 0&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600,marginBottom:8},children:`Explain`}),(0,L.jsx)(`pre`,{className:`plain-block`,children:_h(c.explain)})]}),c.tenant?.enabled&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600,marginBottom:8},children:`Tenant Params`}),c.tenant.params.length>0?(0,L.jsxs)(`div`,{style:{padding:8,border:`1px solid var(--border)`,borderRadius:`var(--radius)`,fontSize:12},children:[(0,L.jsx)(`span`,{style:{fontWeight:600},children:`Positional params:`}),` `,(0,L.jsx)(`code`,{children:JSON.stringify(c.tenant.params)})]}):(0,L.jsx)(ch,{text:`No tenant params.`})]}),(0,L.jsxs)(`div`,{style:{padding:`var(--pad-y) var(--pad-x)`,borderBottom:`1px solid var(--border)`,display:`flex`,flexDirection:`column`,gap:8},children:[j&&(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`},children:[(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11,fontWeight:600},children:j.label}),j.configured?(0,L.jsx)(`span`,{className:`chip`,style:{fontSize:11},children:j.connectionKind===`file`?`file configured`:`URL configured`}):(0,L.jsx)(`span`,{className:`chip red`,style:{fontSize:11},children:j.connectionKind===`file`?`no file`:`no URL`}),j.installed?(0,L.jsxs)(`span`,{className:`chip`,style:{fontSize:11},children:[j.packageName,` ready`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`chip red`,style:{fontSize:11},children:[j.packageName,` missing`]}),j.canInstallFromStudio&&(0,L.jsxs)(`button`,{className:`btn ghost sm`,disabled:ie.has(`install-driver`),onClick:()=>void se(),style:{fontSize:11},children:[ie.has(`install-driver`)?(0,L.jsx)(Di,{size:12,className:`animate-spin`}):null,`Install `,j.packageName]}),!j.canInstallFromStudio&&j.manualInstallReason&&(0,L.jsx)(`span`,{className:`muted`,style:{fontSize:11},children:j.installCommand})]})]}),(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:12},children:[(0,L.jsxs)(`button`,{className:`btn primary`,disabled:ie.has(`execute`)||!c.sql||j!==null&&(!j.configured||!j.installed),onClick:()=>void N(),children:[ie.has(`execute`)?(0,L.jsx)(Di,{size:14,className:`animate-spin`}):(0,L.jsx)(Mi,{size:14}),`Execute Query`]}),ne&&(0,L.jsx)(Om,{status:ne})]})]}),A?.ok===!0&&(0,L.jsxs)(`section`,{style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,marginBottom:8},children:[(0,L.jsx)(`h3`,{style:{fontSize:13,fontWeight:600},children:`Results`}),A.truncated&&(0,L.jsx)(`span`,{className:`chip amber`,children:`Showing first 500 rows`})]}),A.columns&&A.rows?(0,L.jsx)(`div`,{style:{overflowX:`auto`},children:(0,L.jsxs)(`table`,{className:`tbl`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:A.columns.map(e=>(0,L.jsx)(`th`,{children:e},e))})}),(0,L.jsx)(`tbody`,{children:A.rows.map((e,t)=>(0,L.jsx)(`tr`,{children:e.map((e,t)=>(0,L.jsx)(`td`,{className:`mono`,style:{fontSize:11},children:e==null?(0,L.jsx)(`span`,{className:`muted`,children:`NULL`}):String(e)},t))},t))})]})}):(0,L.jsx)(ch,{text:`No results.`})]})]}):(0,L.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`,padding:32},children:(0,L.jsx)(ch,{text:`Ask a question to generate SQL`})})})]})})]})}function _h(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function vh(){let{workspace:e}=wr(),{ragStatus:t}=Lr();return e?(0,L.jsxs)(`main`,{className:`main-pane`,children:[(0,L.jsx)(`div`,{className:`main-hd`,children:(0,L.jsxs)(`div`,{className:`main-title`,children:[(0,L.jsxs)(`h1`,{children:[(0,L.jsx)(Li,{size:18,style:{display:`inline`,marginRight:8}}),`Settings`]}),(0,L.jsx)(`div`,{className:`main-sub`,children:`Workspace configuration and diagnostics`})]})}),(0,L.jsx)(`div`,{className:`main-body`,children:(0,L.jsxs)(`div`,{className:`stack`,style:{padding:`var(--pad-y) var(--pad-x)`},children:[(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Workspace`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:(0,L.jsxs)(`dl`,{className:`definition-list`,children:[(0,L.jsx)(`dt`,{children:`Schema ID`}),(0,L.jsx)(`dd`,{children:e.schemaId}),(0,L.jsx)(`dt`,{children:`Schema path`}),(0,L.jsx)(`dd`,{children:e.schemaDir}),(0,L.jsx)(`dt`,{children:`AI provider`}),(0,L.jsx)(`dd`,{children:e.aiProvider}),(0,L.jsx)(`dt`,{children:`Model`}),(0,L.jsx)(`dd`,{children:e.model}),(0,L.jsx)(`dt`,{children:`AI suggestions`}),(0,L.jsx)(`dd`,{children:e.aiConfigured?`Configured`:`Not configured`})]})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`RAG Store`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:t?(0,L.jsxs)(`dl`,{className:`definition-list`,children:[(0,L.jsx)(`dt`,{children:`Store`}),(0,L.jsx)(`dd`,{children:t.store.kind}),(0,L.jsx)(`dt`,{children:`Lock file`}),(0,L.jsx)(`dd`,{children:t.files.lock?`present`:`missing`}),t.store.kind===`file`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Base path`}),(0,L.jsx)(`dd`,{children:t.store.basePath??`n/a`}),(0,L.jsx)(`dt`,{children:`Embeddings JSON`}),(0,L.jsx)(`dd`,{children:t.files.embeddingsJson?`present`:`missing`}),(0,L.jsx)(`dt`,{children:`Embeddings binary`}),(0,L.jsx)(`dd`,{children:t.files.embeddingsBin?`present`:`missing`})]}),t.store.kind===`pgvector`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Table`}),(0,L.jsx)(`dd`,{children:t.store.table??`askdb_rag_chunks`}),(0,L.jsx)(`dt`,{children:`Index strategy`}),(0,L.jsx)(`dd`,{children:t.store.indexStrategy??`default`})]}),t.store.kind===`memory`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Persistence`}),(0,L.jsx)(`dd`,{children:`In-process only`})]})]}):(0,L.jsx)(ch,{text:`RAG status is unavailable.`})})]}),(0,L.jsxs)(`section`,{className:`card`,children:[(0,L.jsx)(`div`,{className:`card-hd`,children:(0,L.jsx)(`h3`,{children:`Schema Warnings`})}),(0,L.jsx)(`div`,{className:`card-bd`,children:e.warnings.length>0?(0,L.jsx)(`div`,{style:{display:`grid`,gap:8},children:e.warnings.map((e,t)=>(0,L.jsx)(`pre`,{className:`warning-block`,children:typeof e==`string`?e:JSON.stringify(e,null,2)},t))}):(0,L.jsx)(ch,{text:`No schema warnings.`})})]})]})})]}):null}function yh(){return(0,L.jsx)($n,{children:(0,L.jsx)(Dr,{children:(0,L.jsx)(Br,{children:(0,L.jsx)(bh,{})})})})}function bh(){let{load:e,loadState:t,suggestionDialog:n,setSuggestionDialog:r,applySuggestion:a}=wr(),{refreshRagStatus:o,ragAvailable:s}=Lr();return(0,S.useEffect)(()=>{e().then(()=>void o())},[e,o]),t.kind===`loading`?(0,L.jsx)(`div`,{className:`app-shell`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,L.jsx)(`p`,{style:{color:`var(--ink-400)`,fontSize:13},children:`Loading workspace…`})}):t.kind===`error`?(0,L.jsx)(`div`,{className:`app-shell`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,L.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,L.jsx)(`p`,{style:{color:`var(--red-600)`,fontWeight:600,marginBottom:8},children:`Failed to load workspace`}),(0,L.jsx)(`p`,{style:{color:`var(--ink-400)`,fontSize:13},children:t.message})]})}):(0,L.jsxs)(Gr,{ragAvailable:s,children:[(0,L.jsxs)(em,{defaultOpen:!0,className:`!min-h-0 h-svh`,style:{"--sidebar-width":`var(--nav-w)`},children:[(0,L.jsx)(ym,{}),(0,L.jsxs)(rm,{className:`min-h-0 overflow-hidden`,children:[(0,L.jsxs)(`header`,{className:`topbar`,children:[(0,L.jsx)(nm,{className:`-ml-1`}),(0,L.jsx)(Pp,{orientation:`vertical`,className:`mr-2 !h-4`}),(0,L.jsx)(hm,{})]}),(0,L.jsx)(`div`,{className:`app-content`,children:(0,L.jsxs)(Rt,{children:[(0,L.jsx)(It,{path:`/`,element:(0,L.jsx)(Pt,{to:`/overview`,replace:!0})}),(0,L.jsx)(It,{path:`/overview`,element:(0,L.jsx)(xm,{})}),(0,L.jsx)(It,{path:`/tables`,element:(0,L.jsx)(Em,{}),children:(0,L.jsxs)(It,{path:`:schema/:name`,element:(0,L.jsx)(km,{}),children:[(0,L.jsx)(It,{index:!0,element:(0,L.jsx)(Pt,{to:`enrichment`,replace:!0})}),(0,L.jsx)(It,{path:`enrichment`,element:(0,L.jsx)(Fm,{})}),(0,L.jsx)(It,{path:`schema`,element:(0,L.jsx)(Rm,{})}),(0,L.jsx)(It,{path:`sensitivity`,element:(0,L.jsx)(zm,{})})]})}),(0,L.jsx)(It,{path:`/concepts`,element:(0,L.jsx)(Wm,{})}),(0,L.jsx)(It,{path:`/tenancy`,element:(0,L.jsx)(Xm,{})}),(0,L.jsx)(It,{path:`/rag-index`,element:(0,L.jsx)(lh,{})}),(0,L.jsx)(It,{path:`/playground`,element:(0,L.jsx)(gh,{})}),(0,L.jsx)(It,{path:`/settings`,element:(0,L.jsx)(vh,{})})]})})]})]}),n&&(0,L.jsx)(bm,{dialog:n,onApply:a,onClose:()=>r(null)})]})}var xh=document.getElementById(`root`);if(!xh)throw Error(`Missing #root element.`);(0,Yn.createRoot)(xh).render((0,L.jsx)(S.StrictMode,{children:(0,L.jsx)(En,{children:(0,L.jsx)(yh,{})})}));
|
package/dist/client/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>AskDB Studio</title>
|
|
7
7
|
<link rel="icon" type="image/png" media="(prefers-color-scheme: light)" href="/assets/brand/light-icon.png" />
|
|
8
8
|
<link rel="icon" type="image/png" media="(prefers-color-scheme: dark)" href="/assets/brand/dark-icon.png" />
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-DyBQErXG.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-Bj6qGfT6.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
|
@@ -29,10 +29,6 @@ export type StudioDriverDefinition = {
|
|
|
29
29
|
export declare const EXECUTE_DRIVER_REGISTRY: Record<StudioExecuteProvider, StudioDriverDefinition>;
|
|
30
30
|
/**
|
|
31
31
|
* Check whether a driver package is resolvable from the user's project root.
|
|
32
|
-
*
|
|
33
|
-
* Uses `createRequire` so that packages installed in the project's own
|
|
34
|
-
* node_modules are found even when Studio runs from the global npx cache,
|
|
35
|
-
* where a bare `import(packageName)` would not see them.
|
|
36
32
|
*/
|
|
37
33
|
export declare function isDriverInstalled(packageName: string, projectRoot: string): boolean;
|
|
38
34
|
//# sourceMappingURL=execute-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-registry.d.ts","sourceRoot":"","sources":["../src/execute-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"execute-registry.d.ts","sourceRoot":"","sources":["../src/execute-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMvD,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAElF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,IAAI,GAAG,QAAQ,GAAG,gBAAgB,GAAG,OAAO,CAAC;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9D,CAAC;AA0PF,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,qBAAqB,EAAE,sBAAsB,CA6BzF,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAanF"}
|
package/dist/execute-registry.js
CHANGED
|
@@ -9,45 +9,10 @@
|
|
|
9
9
|
* load time; every import lives inside an `executeXxx()` function so a missing
|
|
10
10
|
* package only fails when the user actually tries to execute a query.
|
|
11
11
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
// Driver resolution helpers
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
/**
|
|
19
|
-
* Resolve the absolute entry-point path of a driver package from the user's
|
|
20
|
-
* project root. Uses `createRequire` so that packages installed in the
|
|
21
|
-
* user's own node_modules are found even when Studio is running from the
|
|
22
|
-
* global npx cache (where bare `import(packageName)` cannot see them).
|
|
23
|
-
*
|
|
24
|
-
* The stub filename passed to `createRequire` never needs to exist on disk —
|
|
25
|
-
* Node only uses its directory as the starting point for resolution.
|
|
26
|
-
*/
|
|
27
|
-
function resolveDriverPath(packageName, projectRoot) {
|
|
28
|
-
try {
|
|
29
|
-
const req = createRequire(join(projectRoot, "__stub__.js"));
|
|
30
|
-
return req.resolve(packageName);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Import a driver package resolved from the user's project root.
|
|
38
|
-
* Falls back to a bare import (works when Studio itself has the package)
|
|
39
|
-
* but the project-root resolution path is tried first.
|
|
40
|
-
*/
|
|
41
|
-
async function importDriver(packageName, projectRoot) {
|
|
42
|
-
const resolved = resolveDriverPath(packageName, projectRoot);
|
|
43
|
-
if (resolved) {
|
|
44
|
-
// Convert the absolute path to a file URL so dynamic import accepts it
|
|
45
|
-
// on all platforms, including Windows.
|
|
46
|
-
return import(pathToFileURL(resolved).href);
|
|
47
|
-
}
|
|
48
|
-
// Last resort: bare specifier (will work if Studio ships the package itself)
|
|
49
|
-
return import(packageName);
|
|
50
|
-
}
|
|
12
|
+
import { loadPgDriver, isPgDriverInstalled } from "@askdb/postgres";
|
|
13
|
+
import { loadMysql2Driver, isMysql2DriverInstalled } from "@askdb/mysql";
|
|
14
|
+
import { loadBetterSqlite3Driver, isBetterSqlite3DriverInstalled } from "@askdb/sqlite";
|
|
15
|
+
import { loadMssqlDriver, isMssqlDriverInstalled, resolveConnectionInput, } from "@askdb/sqlserver";
|
|
51
16
|
// ---------------------------------------------------------------------------
|
|
52
17
|
// Normalization helpers
|
|
53
18
|
// ---------------------------------------------------------------------------
|
|
@@ -70,11 +35,10 @@ async function executePostgres(input) {
|
|
|
70
35
|
}
|
|
71
36
|
let pgMod;
|
|
72
37
|
try {
|
|
73
|
-
|
|
74
|
-
pgMod = (mod.default ?? mod);
|
|
38
|
+
pgMod = await loadPgDriver({ resolveFrom: projectRoot });
|
|
75
39
|
}
|
|
76
|
-
catch {
|
|
77
|
-
return { ok: false, error:
|
|
40
|
+
catch (err) {
|
|
41
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
78
42
|
}
|
|
79
43
|
const client = new pgMod.Client({ connectionString });
|
|
80
44
|
try {
|
|
@@ -108,13 +72,10 @@ async function executeMySQL(input) {
|
|
|
108
72
|
}
|
|
109
73
|
let mysql2Mod;
|
|
110
74
|
try {
|
|
111
|
-
|
|
112
|
-
// then let Node follow the exports map from the package root.
|
|
113
|
-
const mod = await importDriver("mysql2/promise", projectRoot);
|
|
114
|
-
mysql2Mod = (mod.default ?? mod);
|
|
75
|
+
mysql2Mod = await loadMysql2Driver({ resolveFrom: projectRoot });
|
|
115
76
|
}
|
|
116
|
-
catch {
|
|
117
|
-
return { ok: false, error:
|
|
77
|
+
catch (err) {
|
|
78
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
118
79
|
}
|
|
119
80
|
let conn;
|
|
120
81
|
try {
|
|
@@ -149,11 +110,11 @@ async function executeSQLite(input) {
|
|
|
149
110
|
}
|
|
150
111
|
let Sqlite3;
|
|
151
112
|
try {
|
|
152
|
-
const mod = await
|
|
113
|
+
const mod = await loadBetterSqlite3Driver({ resolveFrom: projectRoot });
|
|
153
114
|
Sqlite3 = mod.default;
|
|
154
115
|
}
|
|
155
|
-
catch {
|
|
156
|
-
return { ok: false, error:
|
|
116
|
+
catch (err) {
|
|
117
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
157
118
|
}
|
|
158
119
|
const startMs = Date.now();
|
|
159
120
|
const db = new Sqlite3(file, { readonly: true, fileMustExist: true });
|
|
@@ -197,15 +158,14 @@ async function executeSQLServer(input) {
|
|
|
197
158
|
}
|
|
198
159
|
let mssqlMod;
|
|
199
160
|
try {
|
|
200
|
-
|
|
201
|
-
mssqlMod = (mod.default ?? mod);
|
|
161
|
+
mssqlMod = await loadMssqlDriver({ resolveFrom: projectRoot });
|
|
202
162
|
}
|
|
203
|
-
catch {
|
|
204
|
-
return { ok: false, error:
|
|
163
|
+
catch (err) {
|
|
164
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
205
165
|
}
|
|
206
166
|
let pool;
|
|
207
167
|
try {
|
|
208
|
-
pool = await new mssqlMod.ConnectionPool(connectionString).connect();
|
|
168
|
+
pool = await new mssqlMod.ConnectionPool(resolveConnectionInput(connectionString)).connect();
|
|
209
169
|
}
|
|
210
170
|
catch (err) {
|
|
211
171
|
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
@@ -266,12 +226,19 @@ export const EXECUTE_DRIVER_REGISTRY = {
|
|
|
266
226
|
};
|
|
267
227
|
/**
|
|
268
228
|
* Check whether a driver package is resolvable from the user's project root.
|
|
269
|
-
*
|
|
270
|
-
* Uses `createRequire` so that packages installed in the project's own
|
|
271
|
-
* node_modules are found even when Studio runs from the global npx cache,
|
|
272
|
-
* where a bare `import(packageName)` would not see them.
|
|
273
229
|
*/
|
|
274
230
|
export function isDriverInstalled(packageName, projectRoot) {
|
|
275
|
-
|
|
231
|
+
switch (packageName) {
|
|
232
|
+
case "pg":
|
|
233
|
+
return isPgDriverInstalled({ resolveFrom: projectRoot });
|
|
234
|
+
case "mysql2":
|
|
235
|
+
return isMysql2DriverInstalled({ resolveFrom: projectRoot });
|
|
236
|
+
case "better-sqlite3":
|
|
237
|
+
return isBetterSqlite3DriverInstalled({ resolveFrom: projectRoot });
|
|
238
|
+
case "mssql":
|
|
239
|
+
return isMssqlDriverInstalled({ resolveFrom: projectRoot });
|
|
240
|
+
default:
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
276
243
|
}
|
|
277
244
|
//# sourceMappingURL=execute-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-registry.js","sourceRoot":"","sources":["../src/execute-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"execute-registry.js","sourceRoot":"","sources":["../src/execute-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,kBAAkB,CAAC;AA0B1B,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,SAAS,eAAe,CACtB,OAAiB,EACjB,IAAiB,EACjB,QAAgB,EAChB,UAAkB;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IACzC,OAAO;QACL,EAAE,EAAE,IAAI;QACR,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC;QAC7B,QAAQ;QACR,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC;AAkBD,KAAK,UAAU,eAAe,CAAC,KAAyB;IACtD,MAAM,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC7D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,wIAAwI,EAAE,CAAC;IACxK,CAAC;IAED,IAAI,KAAY,CAAC;IACjB,IAAI,CAAC;QACH,KAAK,GAAG,MAAM,YAAY,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAqB,CAAC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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askdb/studio",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.28",
|
|
4
4
|
"description": "AskDB Studio: local browser UI for Schema v2 enrichment and sample NL-to-SQL checks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"askdb",
|
|
@@ -47,16 +47,19 @@
|
|
|
47
47
|
"react-dom": "^19.2.7",
|
|
48
48
|
"react-router": "^7.17.0",
|
|
49
49
|
"tailwind-merge": "^3.6.0",
|
|
50
|
-
"@askdb/ai-anthropic": "1.0.0-beta.1",
|
|
51
50
|
"@askdb/ai": "0.1.0-beta.3",
|
|
51
|
+
"@askdb/ai-anthropic": "1.0.0-beta.1",
|
|
52
52
|
"@askdb/ai-azure": "1.0.0-beta.3",
|
|
53
|
-
"@askdb/ai-google": "1.0.0-beta.3",
|
|
54
53
|
"@askdb/ai-openai": "1.0.0-beta.3",
|
|
54
|
+
"@askdb/ai-google": "1.0.0-beta.3",
|
|
55
55
|
"@askdb/config": "1.0.0-beta.9",
|
|
56
|
-
"@askdb/enrich": "0.2.0-beta.9",
|
|
57
56
|
"@askdb/core": "1.0.0-beta.26",
|
|
57
|
+
"@askdb/postgres": "0.2.0-beta.14",
|
|
58
|
+
"@askdb/enrich": "0.2.0-beta.9",
|
|
58
59
|
"@askdb/rag": "0.2.0-beta.18",
|
|
59
|
-
"@askdb/
|
|
60
|
+
"@askdb/sqlite": "0.1.0-beta.13",
|
|
61
|
+
"@askdb/sqlserver": "0.1.0-beta.14",
|
|
62
|
+
"@askdb/mysql": "0.1.0-beta.13"
|
|
60
63
|
},
|
|
61
64
|
"peerDependencies": {
|
|
62
65
|
"better-sqlite3": ">=9",
|