@duckcodeailabs/dql-cli 1.12.2 → 1.12.3

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.
Files changed (70) hide show
  1. package/dist/assets/dql-notebook/assets/AgentAnswerCard-BEIwKGm4.js +5 -0
  2. package/dist/assets/dql-notebook/assets/AgentLogPage-CsSC2tOR.js +1 -0
  3. package/dist/assets/dql-notebook/assets/AiBuildDialog-CjJ-9bQW.js +1 -0
  4. package/dist/assets/dql-notebook/assets/AiBuildResult-BvTcW9oE.js +33 -0
  5. package/dist/assets/dql-notebook/assets/AiSidePanel-CxFrOfCE.js +6 -0
  6. package/dist/assets/dql-notebook/assets/AnalyticsHome-BtXEdJNR.js +6 -0
  7. package/dist/assets/dql-notebook/assets/AppsView-HjQkbbE6.js +4471 -0
  8. package/dist/assets/dql-notebook/assets/BlockStudio-oQHTJsXC.js +60 -0
  9. package/dist/assets/dql-notebook/assets/BusinessArtifactView-Dpsftjs7.js +1 -0
  10. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-c6ZteaI6.js +22 -0
  11. package/dist/assets/dql-notebook/assets/GitPage-Cj6mc-Yv.js +7 -0
  12. package/dist/assets/dql-notebook/assets/GlobalAiRail-8G_rEyhK.js +1 -0
  13. package/dist/assets/dql-notebook/assets/GovernedContextPage-BTtzt0Za.js +7 -0
  14. package/dist/assets/dql-notebook/assets/HelpDocsPage-e2CesE73.js +22 -0
  15. package/dist/assets/dql-notebook/assets/HomePage-U3ryMLEF.js +117 -0
  16. package/dist/assets/dql-notebook/assets/LineageDAG-CEmgJzm3.js +1 -0
  17. package/dist/assets/dql-notebook/assets/LineageDetailView-CeV5QMXS.js +1 -0
  18. package/dist/assets/dql-notebook/assets/LineageDrawer-B1oAn-N_.js +1 -0
  19. package/dist/assets/dql-notebook/assets/LineagePathBreadcrumb-fP6RTXut.js +14 -0
  20. package/dist/assets/dql-notebook/assets/MiniLineageGraph-CBYSTmRC.js +1 -0
  21. package/dist/assets/dql-notebook/assets/NewBlockModal-ksEwimjl.js +1 -0
  22. package/dist/assets/dql-notebook/assets/NewNotebookModal-CUx0WmXb.js +46 -0
  23. package/dist/assets/dql-notebook/assets/NotebookEditor-BdxJL3LX.js +202 -0
  24. package/dist/assets/dql-notebook/assets/ReadinessPage-DZ9wDW76.js +1 -0
  25. package/dist/assets/dql-notebook/assets/SetupOnboarding-Bt0AAe0h.js +6 -0
  26. package/dist/assets/dql-notebook/assets/TrustBadge-DNVJK_mP.js +1 -0
  27. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BNqE169i.js +83 -0
  28. package/dist/assets/dql-notebook/assets/ai-build-bus-1BR770pY.js +1 -0
  29. package/dist/assets/dql-notebook/assets/answer-to-notebook-B_gE6rsY.js +2 -0
  30. package/dist/assets/dql-notebook/assets/arrow-left-DnKGhzOR.js +6 -0
  31. package/dist/assets/dql-notebook/assets/arrow-right-CQ73DG7_.js +6 -0
  32. package/dist/assets/dql-notebook/assets/book-open-text-CyBV5Nhw.js +6 -0
  33. package/dist/assets/dql-notebook/assets/bot-UOPtBzCj.js +6 -0
  34. package/dist/assets/dql-notebook/assets/chevron-up-CDHDU3N3.js +6 -0
  35. package/dist/assets/dql-notebook/assets/circle-x-DC5nkL_u.js +6 -0
  36. package/dist/assets/dql-notebook/assets/{codemirror-Co0dCEDr.js → codemirror-1_I9gm6Z.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/dagre-BZV40eAE.css +1 -0
  38. package/dist/assets/dql-notebook/assets/dagre.esm-C7ujXipB.js +23 -0
  39. package/dist/assets/dql-notebook/assets/external-link-BiJ_dtTM.js +6 -0
  40. package/dist/assets/dql-notebook/assets/grip-vertical-eXvkUerq.js +6 -0
  41. package/dist/assets/dql-notebook/assets/index-BMVfPaXr.js +644 -0
  42. package/dist/assets/dql-notebook/assets/{index-DvLT6Kls.css → index-DKu4CZt3.css} +1 -1
  43. package/dist/assets/dql-notebook/assets/link-2-DkHVJTuH.js +6 -0
  44. package/dist/assets/dql-notebook/assets/list-tree-8lYW2Itb.js +6 -0
  45. package/dist/assets/dql-notebook/assets/maximize-2-DjSovOdP.js +6 -0
  46. package/dist/assets/dql-notebook/assets/minimize-2-DGlmQLES.js +6 -0
  47. package/dist/assets/dql-notebook/assets/panel-right-open-DPc4gShM.js +6 -0
  48. package/dist/assets/dql-notebook/assets/pencil-nwaGtOdL.js +6 -0
  49. package/dist/assets/dql-notebook/assets/{react-BRY8hXab.js → react-CRB3T2We.js} +2 -2
  50. package/dist/assets/dql-notebook/assets/rotate-ccw-ByjLhAu7.js +6 -0
  51. package/dist/assets/dql-notebook/assets/semantic-fields-eEhwnQhG.js +3 -0
  52. package/dist/assets/dql-notebook/assets/triangle-alert-zws0cKhp.js +6 -0
  53. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-hxi1RZDm.js +18 -0
  54. package/dist/assets/dql-notebook/assets/user-round-CM8xNakq.js +11 -0
  55. package/dist/assets/dql-notebook/assets/wand-sparkles-CIKc8r-4.js +6 -0
  56. package/dist/assets/dql-notebook/assets/workflow-6C0ZLbTi.js +6 -0
  57. package/dist/assets/dql-notebook/assets/wrench-CeU7hF12.js +6 -0
  58. package/dist/assets/dql-notebook/assets/x-DLWEzvri.js +6 -0
  59. package/dist/assets/dql-notebook/index.html +3 -4
  60. package/dist/local-runtime.d.ts +10 -2
  61. package/dist/local-runtime.d.ts.map +1 -1
  62. package/dist/local-runtime.js +130 -39
  63. package/dist/local-runtime.js.map +1 -1
  64. package/dist/package.json +10 -10
  65. package/dist/warehouse-metadata.d.ts +1 -1
  66. package/dist/warehouse-metadata.d.ts.map +1 -1
  67. package/dist/warehouse-metadata.js +2 -2
  68. package/dist/warehouse-metadata.js.map +1 -1
  69. package/package.json +10 -10
  70. package/dist/assets/dql-notebook/assets/index-BRCtmVPa.js +0 -5952
@@ -0,0 +1,7 @@
1
+ import{g as Ue,u as fe,t as we,r as d,a as T,j as e,a0 as se,Y as ye,L as H,S as ne,P as X,B as Ye,b as Ae,T as ie,X as We,J as de,N as Ie,h as Je,aF as Oe,e as Ve}from"./index-BMVfPaXr.js";import{T as Le}from"./triangle-alert-zws0cKhp.js";import{U as Te,G as re}from"./user-round-CM8xNakq.js";import{C as Fe}from"./chevron-up-CDHDU3N3.js";import{P as Ne}from"./pencil-nwaGtOdL.js";import{X as me}from"./x-DLWEzvri.js";/**
2
+ * @license lucide-react v0.563.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Xe=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],Ze=Ue("tags",Xe),le="dql-context-bootstrap-session",ae="dql-context-bootstrap-selection";function et(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function $e(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function tt(){return{id:"",name:"",owner:"",boundedContext:"",sourceSystems:[],description:""}}function nt({embedded:t=!1}={}){const{state:n}=fe(),i=we[n.themeMode],[l,s]=d.useState([]),[p,o]=d.useState(!0),[r,g]=d.useState(null),[k,m]=d.useState(null),[c,W]=d.useState(null),[j,h]=d.useState(!1),[u,I]=d.useState(null),[b,B]=d.useState(null),[P,y]=d.useState(!1),[v,A]=d.useState(!1),[O,M]=d.useState(null),[$,a]=d.useState([]),C=d.useCallback(()=>{let x=!1;return o(!0),g(null),T.getDomains().then(S=>{x||s(Array.isArray(S==null?void 0:S.domains)?S.domains:[])}).catch(S=>{x||(s([]),g(S instanceof Error&&S.message?S.message:"Could not load domains. Is the local DQL server running?"))}).finally(()=>{x||o(!1)}),()=>{x=!0}},[]);d.useEffect(()=>C(),[C]),d.useEffect(()=>{const x=window.sessionStorage.getItem(le);let S=!1;const D=F=>{if(F&&!S){B(F);try{const R=JSON.parse(window.sessionStorage.getItem(ae)??"[]");a(Array.isArray(R)?R.filter(f=>typeof f=="string"):F.candidates.filter(f=>f.action!=="unchanged").map(f=>f.id))}catch{a(F.candidates.filter(R=>R.action!=="unchanged").map(R=>R.id))}}};return(x?T.getContextBootstrap(x):T.getLatestContextBootstrap()).then(D).catch(async()=>{window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),x&&D(await T.getLatestContextBootstrap().catch(()=>null))}),()=>{S=!0}},[]),d.useEffect(()=>{b&&(window.sessionStorage.setItem(le,b.id),window.sessionStorage.setItem(ae,JSON.stringify($)))},[b==null?void 0:b.id,$]);const L=d.useMemo(()=>[...l].sort((x,S)=>x.name.localeCompare(S.name)),[l]),z=d.useCallback(x=>{s(S=>{const D=S.findIndex(F=>F.id===x.id);if(D===-1)return[...S,x];const E=[...S];return E[D]=x,E}),m(null)},[]),J=d.useCallback(async()=>{if(c){h(!0),I(null);try{await T.deleteDomain(c.id),s(x=>x.filter(S=>S.id!==c.id)),W(null)}catch(x){I(x instanceof Error&&x.message?x.message:"Could not delete this domain.")}finally{h(!1)}}},[c]),K=d.useCallback(async()=>{y(!0),M(null);try{const x=await T.startContextBootstrap({ai:!0});B(x);const S=x.candidates.filter(D=>D.action!=="unchanged").map(D=>D.id);a(S),window.sessionStorage.setItem(le,x.id),window.sessionStorage.setItem(ae,JSON.stringify(S))}catch(x){M(x instanceof Error?x.message:"Could not draft repository context.")}finally{y(!1)}},[]);d.useEffect(()=>{if(!t)return;const x=()=>{K()};return window.addEventListener("dql:context-build",x),()=>window.removeEventListener("dql:context-build",x)},[t,K]),d.useEffect(()=>{if(!b||["ready","needs_attention"].includes(b.status))return;let x=!1;const S=async()=>{try{const E=await T.getContextBootstrap(b.id);x||B(E)}catch(E){x||M(E instanceof Error?E.message:"Could not update AI draft progress.")}};S();const D=window.setInterval(()=>void S(),750);return()=>{x=!0,window.clearInterval(D)}},[b==null?void 0:b.id,b==null?void 0:b.status]);const Q=d.useCallback(async()=>{if(!(!b||$.length===0)){A(!0),M(null);try{await T.saveContextBootstrapSelected(b.id,$),B(null),a([]),window.sessionStorage.removeItem(le),window.sessionStorage.removeItem(ae),C()}catch(x){M(x instanceof Error?x.message:"Could not save selected drafts.")}finally{A(!1)}}},[b,$,C]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(se,{size:20,strokeWidth:1.9,color:i.accent}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:i.textPrimary},children:"Domains"})]}),e.jsx("div",{style:{fontSize:13,color:i.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:"Domains are the top of your business model — each one owns the terms, skills, and blocks beneath it. Name the business area, who owns it, the bounded context, and the source systems it draws from."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>C(),title:"Refresh",style:Z(i),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>void K(),disabled:P,style:Z(i),children:[P?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ne,{size:13,strokeWidth:2})," Draft with AI"]}),e.jsxs("button",{type:"button",onClick:()=>m({kind:"create"}),style:ue(i),children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add domain"]})]})]}),p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:i.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(H,{size:15,strokeWidth:2})," Loading domains…"]}):r?e.jsx(ot,{t:i,message:r,onRetry:()=>C()}):L.length===0?e.jsx(rt,{t:i,onAdd:()=>m({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:L.map(x=>e.jsx(it,{domain:x,t:i,onEdit:()=>m({kind:"edit",domain:x}),onDelete:()=>{I(null),W(x)}},x.id))}),O?e.jsx("div",{style:{marginTop:12},children:e.jsx(pe,{t:i,tone:"error",children:O})}):null,b?e.jsxs("section",{style:{marginTop:18,border:`1px solid ${i.cellBorder}`,borderRadius:10,background:i.cellBg,padding:14},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:750,color:i.textPrimary},children:"Repository-guided AI draft"}),e.jsx("div",{style:{fontSize:12,color:i.textMuted,marginTop:3},children:"Inventory is deterministic; AI may enrich only grounded prose and guidance. Nothing is written to Git until you save."})]}),e.jsxs("button",{type:"button",disabled:v||$.length===0||!["ready","needs_attention"].includes(b.status),onClick:()=>void Q(),style:{...ue(i),opacity:v||$.length===0||!["ready","needs_attention"].includes(b.status)?.55:1},children:[v?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(X,{size:13,strokeWidth:2})," Save selected drafts"]})]}),e.jsx(lt,{t:i,session:b}),e.jsx("div",{style:{display:"grid",gap:9,marginTop:12},children:b.candidates.map(x=>{const S=x.action!=="unchanged",D=$.includes(x.id);return e.jsx(at,{candidate:x,selected:D,selectable:S,disabled:v,t:i,onToggle:()=>a(E=>D?E.filter(F=>F!==x.id):[...E,x.id])},x.id)})})]}):null]}),k?e.jsx(st,{mode:k,existingIds:l.map(x=>x.id),domains:l,t:i,onClose:()=>m(null),onSaved:z}):null,c?e.jsx(dt,{domain:c,t:i,deleting:j,error:u,onCancel:()=>{j||W(null)},onConfirm:J}):null]})}function it({domain:t,t:n,onEdit:i,onDelete:l}){const s=t.sourceSystems??[],[p,o]=d.useState(!1);return e.jsxs("section",{style:{border:`1px solid ${n.cellBorder}`,borderRadius:10,background:n.cellBg,padding:"13px 15px",display:"flex",alignItems:"flex-start",gap:14},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:750,color:n.textPrimary},children:t.name}),t.parent?e.jsxs("span",{style:Se(n),children:["↳ ",t.parent]}):null,t.owner?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,color:n.textMuted},children:[e.jsx(Te,{size:11,strokeWidth:2})," ",t.owner]}):null,t.businessOwner?e.jsxs("span",{style:Se(n),children:[e.jsx(Te,{size:10,strokeWidth:2.2})," Business owner: ",t.businessOwner]}):null]}),t.description?e.jsx("div",{style:{fontSize:12.5,color:n.textSecondary,marginTop:5,lineHeight:1.5},children:t.description}):e.jsx("div",{style:{fontSize:12,color:n.textMuted,marginTop:5,fontStyle:"italic"},children:"No description yet."}),s.length>0?e.jsx("div",{style:{display:"flex",gap:5,marginTop:9,flexWrap:"wrap"},children:s.map(r=>e.jsx("span",{style:Ce(n),children:r},r))}):null,e.jsxs("div",{style:{display:"flex",gap:7,marginTop:9,flexWrap:"wrap"},children:[e.jsx(je,{t:n,icon:e.jsx(Ye,{size:11,strokeWidth:2}),label:"blocks",count:t.blockCount??0}),e.jsx(je,{t:n,icon:e.jsx(re,{size:11,strokeWidth:2}),label:"skills",count:t.skillCount??0}),e.jsx(je,{t:n,icon:e.jsx(Ze,{size:11,strokeWidth:2}),label:"terms",count:t.termCount??0})]}),p?e.jsxs("div",{style:{display:"grid",gap:9,marginTop:12,paddingTop:11,borderTop:`1px solid ${n.btnBorder}`},children:[t.boundedContext?e.jsx(De,{t:n,label:"Business boundary",children:t.boundedContext}):null,t.businessOutcome?e.jsx(De,{t:n,label:"Decision outcome",children:t.businessOutcome}):null,e.jsx(ce,{t:n,label:"In scope",values:t.inScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Out of scope",values:t.outOfScope,empty:"Not defined yet"}),e.jsx(ce,{t:n,label:"Primary terms",values:t.primaryTerms,empty:"No terms linked yet"}),e.jsx(ce,{t:n,label:"Tags",values:t.tags,empty:"No tags"})]}):null]}),e.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>o(r=>!r),style:{...Z(n),padding:"5px 7px",fontSize:11.5},title:p?"Hide domain details":"Show domain details",children:[p?e.jsx(Fe,{size:13}):e.jsx(Ae,{size:13}),p?"Less":"Details"]}),e.jsx("button",{type:"button",onClick:i,style:ke(n),title:"Edit domain",children:e.jsx(Ne,{size:13,strokeWidth:2})}),e.jsx("button",{type:"button",onClick:l,style:ke(n),title:"Delete domain",children:e.jsx(ie,{size:13,strokeWidth:2})})]})]})}function st({mode:t,existingIds:n,domains:i,t:l,onClose:s,onSaved:p}){const o=t.kind==="edit",[r,g]=d.useState(()=>t.kind==="edit"?{...t.domain}:tt()),[k,m]=d.useState(o),[c,W]=d.useState(!1),[j,h]=d.useState(null),u=d.useCallback((y,v)=>{g(A=>({...A,[y]:v}))},[]),I=y=>{g(v=>({...v,name:y,...!o&&!k?{id:$e(y)}:{}}))},b=!o&&r.id.length>0&&n.includes(r.id),B=r.id.trim().length>0&&r.name.trim().length>0&&!b&&!c,P=d.useCallback(async()=>{var v,A,O,M,$;const y={...r,id:r.id.trim(),name:r.name.trim(),owner:(v=r.owner)!=null&&v.trim()?r.owner.trim():void 0,businessOwner:(A=r.businessOwner)!=null&&A.trim()?r.businessOwner.trim():void 0,parent:(O=r.parent)!=null&&O.trim()?r.parent.trim():void 0,boundedContext:(M=r.boundedContext)!=null&&M.trim()?r.boundedContext.trim():void 0,description:($=r.description)!=null&&$.trim()?r.description.trim():void 0,sourceSystems:(r.sourceSystems??[]).map(a=>a.trim()).filter(Boolean),primaryTerms:(r.primaryTerms??[]).map(a=>a.trim()).filter(Boolean),tags:(r.tags??[]).map(a=>a.trim()).filter(Boolean),inScope:(r.inScope??[]).map(a=>a.trim()).filter(Boolean),outOfScope:(r.outOfScope??[]).map(a=>a.trim()).filter(Boolean),dbtGroups:(r.dbtGroups??[]).map(a=>a.trim()).filter(Boolean),dbtPaths:(r.dbtPaths??[]).map(a=>a.trim()).filter(Boolean),dbtTags:(r.dbtTags??[]).map(a=>a.trim()).filter(Boolean),semanticDomains:(r.semanticDomains??[]).map(a=>a.trim()).filter(Boolean),semanticTags:(r.semanticTags??[]).map(a=>a.trim()).filter(Boolean)};W(!0),h(null);try{const a=o?await T.updateDomain(y.id,y):await T.createDomain(y);p(a.domain??y)}catch(a){h(a instanceof Error&&a.message?a.message:"Could not save this domain. Try again.")}finally{W(!1)}},[r,o,p]);return e.jsx("div",{style:gt,onClick:()=>!c&&s(),children:e.jsxs("div",{style:ht(l),onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{style:ft(l),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(se,{size:16,strokeWidth:2,color:l.accent}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:l.textPrimary},children:o?"Edit domain":"New domain"})]}),e.jsx("button",{type:"button",onClick:()=>!c&&s(),style:ke(l),title:"Close",children:e.jsx(me,{size:15,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"16px 18px",display:"grid",gap:16},children:[e.jsx(q,{label:"Name",t:l,hint:o?void 0:"A short, human label for this business area.",children:e.jsx("input",{type:"text",value:r.name,onChange:y=>I(y.target.value),placeholder:"Revenue",style:U(l)})}),e.jsxs(q,{label:"ID (slug)",t:l,hint:"Used as the on-disk identifier. Letters, numbers, and dashes.",children:[e.jsx("input",{type:"text",value:r.id,disabled:o,onChange:y=>{m(!0),u("id",et(y.target.value))},onBlur:()=>u("id",$e(r.id)),placeholder:"revenue",style:{...U(l),fontFamily:l.fontMono,opacity:o?.7:1}}),b?e.jsx(pe,{t:l,tone:"error",children:"A domain with this id already exists."}):null]}),e.jsx(q,{label:"Parent domain",t:l,hint:"Optional. Depth becomes Domain, Subdomain, Microdomain, and beyond.",children:e.jsxs("select",{value:r.parent??"",onChange:y=>u("parent",y.target.value||void 0),style:U(l),children:[e.jsx("option",{value:"",children:"Top-level domain"}),i.filter(y=>y.id!==r.id).map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})}),e.jsx(q,{label:"Owner",t:l,hint:"The team or person accountable for this domain.",children:e.jsx("input",{type:"text",value:r.owner??"",onChange:y=>u("owner",y.target.value),placeholder:"finance-analytics",style:U(l)})}),e.jsx(q,{label:"Business owner",t:l,hint:"The stakeholder accountable for business use and definitions.",children:e.jsx("input",{type:"text",value:r.businessOwner??"",onChange:y=>u("businessOwner",y.target.value),placeholder:"Revenue Operations",style:U(l)})}),e.jsx(q,{label:"Bounded context",t:l,hint:"The conceptual boundary this domain owns, e.g. 'recognized revenue and invoicing'.",children:e.jsx("input",{type:"text",value:r.boundedContext??"",onChange:y=>u("boundedContext",y.target.value),placeholder:"Recognized revenue and invoicing",style:U(l)})}),e.jsx(q,{label:"Source systems",t:l,hint:"The upstream systems this domain draws from — type a name and press Enter.",children:e.jsx(be,{t:l,values:r.sourceSystems??[],onChange:y=>u("sourceSystems",y),placeholder:"Add a source system…"})}),e.jsx(q,{label:"Primary terms",t:l,hint:"Business concepts the agent should use to recognize this domain.",children:e.jsx(be,{t:l,values:r.primaryTerms??[],onChange:y=>u("primaryTerms",y),placeholder:"Add a term…"})}),e.jsx(q,{label:"Scope tags",t:l,hint:"Short labels used for routing and discovery.",children:e.jsx(be,{t:l,values:r.tags??[],onChange:y=>u("tags",y),placeholder:"Add a tag…"})}),e.jsx(q,{label:"Description",t:l,hint:"What this domain covers and how it's used.",children:e.jsx("textarea",{value:r.description??"",onChange:y=>u("description",y.target.value),rows:5,placeholder:"All recognized-revenue metrics and the blocks that report them, sourced from the billing warehouse.",style:pt(l)})}),j?e.jsx(pe,{t:l,tone:"error",children:j}):null]}),e.jsxs("div",{style:yt(l),children:[e.jsx("button",{type:"button",onClick:()=>!c&&s(),style:Z(l),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:P,disabled:!B,style:{...ue(l),opacity:B?1:.55},children:[c?e.jsx(H,{size:13,strokeWidth:2}):null,c?"Saving…":o?"Save changes":"Create domain"]})]})]})})}function be({t,values:n,onChange:i,placeholder:l}){const[s,p]=d.useState(""),o=r=>{const g=r.trim();!g||n.includes(g)||(i([...n,g]),p(""))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[n.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:n.map(r=>e.jsxs("span",{style:ut(t),children:[r,e.jsx("button",{type:"button",onClick:()=>i(n.filter(g=>g!==r)),style:xt(t),title:"Remove",children:e.jsx(me,{size:11,strokeWidth:2.4})})]},r))}):null,e.jsx("input",{type:"text",value:s,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),o(s))},placeholder:l,style:U(t)})]})}function rt({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(se,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Name your business domains"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:`Domains organize everything below them — terms, skills, and blocks. Add your first one, like "Revenue" or "Customer", and you'll be able to pick it when authoring blocks and skills.`}),e.jsxs("button",{type:"button",onClick:n,style:{...ue(t),marginTop:4},children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add your first domain"]})]})}function ot({t,message:n,onRetry:i}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Le,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Domains are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:i,style:{...Z(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function lt({t,session:n}){var s;const i=!["ready","needs_attention"].includes(n.status),l=n.ai.mode==="evidence_only"?"Evidence-only":n.ai.provider?`${n.ai.provider} grounded`:"Preparing AI";return e.jsxs("div",{style:{marginTop:14,padding:"10px 11px",borderRadius:8,background:t.appBg,border:`1px solid ${t.btnBorder}`},children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center",flexWrap:"wrap",fontSize:12,color:t.textSecondary},children:[i?e.jsx(H,{size:14,strokeWidth:2,color:t.accent}):e.jsx(ne,{size:14,strokeWidth:2,color:t.accent}),e.jsx("strong",{style:{color:t.textPrimary,textTransform:"capitalize"},children:n.status.replace("_"," ")}),e.jsx("span",{children:l}),e.jsxs("span",{children:[n.progress.domains.ready,"/",n.progress.domains.total," domains"]}),e.jsxs("span",{children:[n.progress.skills.ready,"/",n.progress.skills.total," skills"]})]}),e.jsx("div",{style:{height:5,borderRadius:999,background:t.btnBg,overflow:"hidden",marginTop:9},children:e.jsx("div",{style:{width:`${Math.max(3,Math.min(100,n.progress.percent))}%`,height:"100%",background:t.accent,transition:"width 260ms ease"}})}),e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.textMuted,lineHeight:1.45},children:n.progress.message}),(s=n.warnings)!=null&&s.length?e.jsx("div",{style:{marginTop:7,fontSize:11.5,color:t.warning,lineHeight:1.45},children:n.warnings.slice(-2).join(" ")}):null]})}function at({candidate:t,selected:n,selectable:i,disabled:l,t:s,onToggle:p}){var W,j,h,u,I,b,B,P,y,v,A,O,M,$,a,C,L,z,J,K,Q,x,S,D,E,F;const[o,r]=d.useState(!1),g=t.kind==="domain",k=((W=t.domain)==null?void 0:W.name)??((j=t.skill)==null?void 0:j.id)??t.id.replace(/^(domain|skill):/,""),m=g?((h=t.domain)==null?void 0:h.description)??((u=t.domain)==null?void 0:u.boundedContext):((I=t.skill)==null?void 0:I.description)??((B=(b=t.skill)==null?void 0:b.body)==null?void 0:B.split(`
7
+ `).find(Boolean)),c=g?[["Business outcome",(P=t.domain)==null?void 0:P.businessOutcome],["In scope",(v=(y=t.domain)==null?void 0:y.inScope)==null?void 0:v.join(" · ")],["Out of scope",(O=(A=t.domain)==null?void 0:A.outOfScope)==null?void 0:O.join(" · ")],["Primary terms",($=(M=t.domain)==null?void 0:M.primaryTerms)==null?void 0:$.join(" · ")]]:[["Applies when",(C=(a=t.skill)==null?void 0:a.triggers)==null?void 0:C.join(" · ")],["Ask first when",(z=(L=t.skill)==null?void 0:L.clarifyWhen)==null?void 0:z.join(" · ")],["Avoid when",(K=(J=t.skill)==null?void 0:J.exclusions)==null?void 0:K.join(" · ")],["Preferred metrics",(x=(Q=t.skill)==null?void 0:Q.preferredMetrics)==null?void 0:x.join(" · ")],["Preferred blocks",(D=(S=t.skill)==null?void 0:S.preferredBlocks)==null?void 0:D.join(" · ")]];return e.jsx("article",{style:{border:`1px solid ${n?`${s.accent}66`:s.btnBorder}`,background:n?`${s.accent}08`:s.appBg,borderRadius:8,padding:"10px 11px",opacity:i?1:.72},children:e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"flex-start"},children:[e.jsx("input",{"aria-label":`Select ${g?"domain":"skill"} ${k}`,type:"checkbox",disabled:!i||l,checked:n,onChange:p,style:{marginTop:3}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",flexWrap:"wrap"},children:[e.jsxs("strong",{style:{color:s.textPrimary,fontSize:12.5},children:[g?"Domain":"Skill"," · ",k]}),e.jsx("span",{style:Se(s),children:t.action.replace("_"," ")}),e.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[Math.round(t.confidence*100),"% evidence confidence"]})]}),m?e.jsx("p",{style:{marginTop:5,color:s.textSecondary,fontSize:12,lineHeight:1.45},children:m}):e.jsx("p",{style:{marginTop:5,color:s.textMuted,fontSize:12,fontStyle:"italic"},children:"Waiting for grounded guidance…"}),e.jsx("div",{style:{display:"flex",gap:5,marginTop:7,flexWrap:"wrap"},children:t.evidence.map(R=>e.jsx("span",{style:Ce(s),children:R},R))}),o?e.jsxs("div",{style:{marginTop:9,display:"grid",gap:6,borderTop:`1px solid ${s.btnBorder}`,paddingTop:9},children:[c.filter(([,R])=>!!R).map(([R,f])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"116px minmax(0, 1fr)",gap:8,fontSize:11.5,lineHeight:1.45},children:[e.jsx("strong",{style:{color:s.textMuted},children:R}),e.jsx("span",{style:{color:s.textSecondary},children:f})]},R)),!g&&((E=t.skill)!=null&&E.body)?e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",fontFamily:s.font,fontSize:11.5,color:s.textSecondary,background:s.cellBg,padding:9,borderRadius:6,maxHeight:180,overflow:"auto"},children:t.skill.body}):null,(F=t.notes)!=null&&F.length?e.jsx("div",{style:{fontSize:11.5,color:s.accent},children:t.notes.join(" ")}):null]}):null]}),e.jsxs("button",{type:"button",onClick:()=>r(R=>!R),style:{...Z(s),padding:"4px 6px",fontSize:11.5},"aria-expanded":o,children:[o?e.jsx(Fe,{size:13}):e.jsx(Ae,{size:13}),o?"Less":"Review"]})]})})}function dt({domain:t,t:n,deleting:i,error:l,onCancel:s,onConfirm:p}){return e.jsx("div",{style:mt,onClick:s,children:e.jsxs("div",{style:bt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this domain?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontWeight:700,color:n.textPrimary},children:t.name})," will be removed. Blocks, skills, and terms that referenced it will become unassigned. This can't be undone."]}),l?e.jsx(pe,{t:n,tone:"error",children:l}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:i,style:Z(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:p,disabled:i,style:{...ct(n),opacity:i?.6:1},children:[i?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),i?"Deleting…":"Delete"]})]})]})})}function je({t,icon:n,label:i,count:l}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,fontWeight:600,color:l>0?t.textSecondary:t.textMuted,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px"},children:[n,l," ",i]})}function De({t,label:n,children:i}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("span",{style:{color:t.textSecondary},children:i})]})}function ce({t,label:n,values:i,empty:l}){return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"118px minmax(0, 1fr)",gap:10,fontSize:12,lineHeight:1.5},children:[e.jsx("strong",{style:{color:t.textMuted},children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:i!=null&&i.length?i.map(s=>e.jsx("span",{style:Ce(t),children:s},s)):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:l})})]})}function q({label:t,hint:n,t:i,children:l}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:i.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:i.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,l]})}function pe({t,tone:n,children:i}){const l=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:l,lineHeight:1.45},children:i})}function ue(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function Z(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function ct(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function ke(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function U(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function pt(t){return{...U(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Se(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 8px"}}function Ce(t){return{fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",fontFamily:t.fontMono}}function ut(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11.5,fontWeight:600,color:t.textPrimary,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:6,padding:"3px 4px 3px 9px",fontFamily:t.fontMono}}function xt(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",color:t.textMuted,cursor:"pointer",padding:2,borderRadius:4}}const gt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",justifyContent:"flex-end",zIndex:60};function ht(t){return{width:"min(560px, 100%)",height:"100%",background:t.appBg,borderLeft:`1px solid ${t.headerBorder}`,display:"flex",flexDirection:"column",boxShadow:"-8px 0 28px rgba(0,0,0,0.18)"}}function ft(t){return{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 18px",borderBottom:`1px solid ${t.headerBorder}`,flexShrink:0}}function yt(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"13px 18px",borderTop:`1px solid ${t.headerBorder}`,flexShrink:0}}const mt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function bt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function jt(t,n,i){var p,o;if(n&&t.domain!==n&&!((p=t.domains)!=null&&p.includes(n)))return!1;const l=(o=i==null?void 0:i.split("::").at(-1))==null?void 0:o.toLowerCase();if(!l)return!0;const s=(t.modelAreaRefs??[]).map(r=>{var g;return(g=r.split("::").at(-1))==null?void 0:g.toLowerCase()});return s.length===0||s.includes(l)}function vt(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function Re(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function kt(){return{id:"",scope:"project",description:"",body:"",preferredMetrics:[],preferredBlocks:[],vocabulary:{},sourcePath:""}}function St({embedded:t=!1,domainFilter:n=null,modelAreaFilter:i=null}={}){var R;const{state:l}=fe(),s=we[l.themeMode],[p,o]=d.useState([]),[r,g]=d.useState(!0),[k,m]=d.useState(null),[c,W]=d.useState({metrics:[],blocks:[]}),[j,h]=d.useState([]),[u,I]=d.useState(null),[b,B]=d.useState(!1),[P,y]=d.useState("skills"),[v,A]=d.useState(!1),[O,M]=d.useState(null),[$,a]=d.useState(null),[C,L]=d.useState(null),[z,J]=d.useState(!1),[K,Q]=d.useState(null),x=d.useCallback(()=>{let f=!1;return g(!0),m(null),T.getSkills().then(w=>{f||o(Array.isArray(w==null?void 0:w.skills)?w.skills:[])}).catch(w=>{f||(o([]),m(w instanceof Error&&w.message?w.message:"Could not load skills. Is the local DQL server running?"))}).finally(()=>{f||g(!1)}),T.getSkillOptions().then(w=>{f||W({metrics:Array.isArray(w==null?void 0:w.metrics)?w.metrics:[],blocks:Array.isArray(w==null?void 0:w.blocks)?w.blocks:[]})}).catch(()=>{f||W({metrics:[],blocks:[]})}),T.getDomains().then(w=>{f||h(Array.isArray(w==null?void 0:w.domains)?w.domains:[])}).catch(()=>{f||h([])}),T.getSkillPathSettings().then(w=>{f||(I(w),y(w.path))}).catch(()=>{f||I(null)}),()=>{f=!0}},[]);d.useEffect(()=>x(),[x]);const S=d.useMemo(()=>p.filter(f=>jt(f,n,i)).sort((f,w)=>f.id.localeCompare(w.id)),[p,n,i]),D=d.useCallback(f=>{o(w=>{const oe=w.findIndex(Be=>(Be.qualifiedId??Be.id)===(f.qualifiedId??f.id));if(oe===-1)return[...w,f];const ze=[...w];return ze[oe]=f,ze}),a(null)},[]),E=d.useCallback(async()=>{if(C){J(!0),Q(null);try{const f=C.qualifiedId??C.id;await T.deleteSkill(f),o(w=>w.filter(oe=>(oe.qualifiedId??oe.id)!==f)),L(null)}catch(f){Q(f instanceof Error&&f.message?f.message:"Could not delete this skill.")}finally{J(!1)}}},[C]),F=d.useCallback(async()=>{A(!0),M(null);try{const f=await T.updateSkillPath(P);I(f),y(f.path),B(!1),x()}catch(f){M(f instanceof Error&&f.message?f.message:"Could not use this Skills folder.")}finally{A(!1)}},[x,P]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:s.appBg},children:[e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:t?"18px 20px 40px":"22px 28px 40px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-end",justifyContent:"space-between",gap:18,marginBottom:18},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(re,{size:20,strokeWidth:1.9,color:s.accent}),e.jsx("div",{style:{fontSize:t?18:22,fontWeight:700,color:s.textPrimary},children:i?`${(R=i.split("::").at(-1))==null?void 0:R.replace(/_/g," ")} skills`:n?`${n} skills`:"Skills"})]}),e.jsxs("div",{style:{fontSize:13,color:s.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:["Definitions, vocabulary, and instructions the AI follows when answering",i?" in this model area":n?" in this domain":"",". Applied only when their triggers match — drafts never guide answers."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:7,color:s.textMuted,fontSize:10.5,minWidth:0},children:[e.jsx(We,{size:12,strokeWidth:1.8}),e.jsx("span",{children:"Skill folder"}),e.jsx("code",{style:{color:s.textSecondary,fontFamily:s.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(u==null?void 0:u.path)??"skills"}),u?e.jsxs("span",{children:["· ",u.exists?`${u.skillCount} loaded`:"not found"]}):null]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>x(),title:"Refresh",style:Y(s),children:[e.jsx(ye,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>{M(null),B(f=>!f)},style:Y(s),children:[e.jsx(We,{size:13,strokeWidth:2})," Skill folder"]}),e.jsxs("button",{type:"button",onClick:()=>a({kind:"create"}),style:ge(s),children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add skill"]})]})]}),b?e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:s.cellBg,padding:"12px 14px",marginBottom:16,display:"grid",gap:8},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:s.textPrimary},children:"Use an existing Skills folder"}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx("input",{"aria-label":"Existing Skills folder",value:P,onChange:f=>y(f.target.value),onKeyDown:f=>{f.key==="Enter"&&P.trim()&&!v&&F()},placeholder:"skills or ../skills",style:{...N(s),flex:1,fontFamily:s.fontMono}}),e.jsx("button",{type:"button",onClick:()=>B(!1),disabled:v,style:Y(s),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void F(),disabled:!P.trim()||v,style:{...ge(s),opacity:P.trim()&&!v?1:.55},children:[v?e.jsx(H,{size:13,strokeWidth:2}):null,v?"Connecting…":"Use folder"]})]}),e.jsxs("div",{style:{fontSize:10.5,lineHeight:1.45,color:s.textMuted},children:["Relative paths start from the DQL project. If DQL is in a ",e.jsx("code",{style:{fontFamily:s.fontMono},children:"/dql"})," folder inside your dbt repo, use ",e.jsx("code",{style:{fontFamily:s.fontMono},children:"../skills"}),". Existing ",e.jsx("code",{style:{fontFamily:s.fontMono},children:".skill.md"})," and Markdown skill files are loaded in place and stay Git-owned by that repo."]}),u!=null&&u.resolvedPath?e.jsxs("div",{style:{fontSize:10.5,color:s.textMuted,fontFamily:s.fontMono,overflowWrap:"anywhere"},children:["Resolved: ",u.resolvedPath]}):null,O?e.jsx(xe,{t:s,tone:"error",children:O}):null]}):null,r?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:s.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(H,{size:15,strokeWidth:2})," Loading skills…"]}):k?e.jsx(It,{t:s,message:k,onRetry:()=>x()}):S.length===0?e.jsx(Wt,{t:s,onAdd:()=>a({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:S.map(f=>e.jsx(wt,{skill:f,t:s,onEdit:()=>a({kind:"edit",skill:f}),onDelete:()=>{Q(null),L(f)}},f.qualifiedId??f.id))})]}),$?e.jsx(Ct,{mode:$,options:c,domains:j,defaultDomain:n,defaultModelArea:i,existingIds:p.map(f=>f.id),t:s,onClose:()=>a(null),onSaved:D}):null,C?e.jsx(Tt,{skill:C,t:s,deleting:z,error:K,onCancel:()=>{z||L(null)},onConfirm:E}):null]})}function wt({skill:t,t:n,onEdit:i,onDelete:l}){var r,g,k;const[s,p]=d.useState(!1),o=(r=t.domains)!=null&&r.length?t.domains:t.domain?[t.domain]:[];return e.jsxs("section",{style:{border:"1px solid var(--border-subtle)",borderRadius:11,background:n.cellBg,overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"12px 14px"},children:[e.jsx("span",{style:{width:28,height:28,borderRadius:7,background:"var(--accent-dim)",color:n.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:14,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:13,fontWeight:650,color:n.textPrimary,fontFamily:n.fontMono},children:t.id}),t.status==="draft"?e.jsx("span",{style:Pe(n),children:"draft — inactive"}):null,t.status==="active"||!t.status?e.jsx("span",{style:$t(n),children:"active"}):null,o.map(m=>e.jsx("span",{style:Dt(n),children:m},m)),t.isStarter?e.jsxs("span",{style:Pe(n),title:"A dbt-seeded starter — edit it to make it yours",children:[e.jsx(ne,{size:10,strokeWidth:2.2})," starter — edit me"]}):null]}),e.jsx("div",{style:{fontSize:12,color:t.description?n.textSecondary:n.textMuted,fontStyle:t.description?void 0:"italic",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.description||"No description yet."}),e.jsx("div",{title:t.sourcePath,style:{marginTop:3,color:n.textMuted,fontSize:10,fontFamily:n.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.sourcePath})]}),e.jsx("button",{type:"button",onClick:()=>p(m=>!m),style:{...Y(n),height:26,padding:"0 10px",fontSize:11},title:s?"Hide skill details":"Show skill details",children:s?"Hide details":"Details"}),e.jsx("button",{type:"button",onClick:i,style:{...he(n),width:26,height:26},title:"Edit skill",children:e.jsx(Ne,{size:12,strokeWidth:1.75})}),e.jsx("button",{type:"button",onClick:l,style:{...he(n),width:26,height:26},title:"Delete skill",children:e.jsx(ie,{size:12,strokeWidth:1.75})})]}),s?e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"12px 14px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 20px"},children:[e.jsx(ee,{t:n,label:"Apply when",values:t.triggers,empty:"No trigger phrases defined"}),e.jsx(ee,{t:n,label:"Prefer these metrics",values:t.preferredMetrics,empty:"No preferred metrics",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Reuse these blocks",values:t.preferredBlocks,empty:"No preferred blocks",accent:!0,mono:!0}),e.jsx(ee,{t:n,label:"Ask first when",values:t.clarifyWhen,empty:"No clarification rule defined"}),(g=t.exclusions)!=null&&g.length?e.jsx(ee,{t:n,label:"Avoid when",values:t.exclusions,empty:""}):null,(k=t.modelAreaRefs)!=null&&k.length?e.jsx(ee,{t:n,label:"Focus on model areas",values:t.modelAreaRefs,empty:"",mono:!0}):null,t.body?e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:te(n),children:"Guidance"}),e.jsx("div",{style:{fontSize:12,lineHeight:1.6,color:n.textSecondary,background:"var(--bg-1)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"10px 12px",whiteSpace:"pre-wrap",maxHeight:220,overflow:"auto"},children:t.body})]}):null]}):null]})}function Ct({mode:t,options:n,domains:i,defaultDomain:l=null,defaultModelArea:s=null,existingIds:p,t:o,onClose:r,onSaved:g}){const{dispatch:k}=fe(),m=t.kind==="edit",[c,W]=d.useState(()=>t.kind==="edit"?{...t.skill}:{...kt(),domain:l??void 0,domains:l?[l]:[],modelAreaRefs:s?[s]:[]}),[j,h]=d.useState(m),[u,I]=d.useState(()=>t.kind==="edit"?t.skill.id:""),[b,B]=d.useState(!1),[P,y]=d.useState(null),v=d.useCallback((a,C)=>{W(L=>({...L,[a]:C}))},[]),A=a=>{I(a),!m&&!j&&v("id",Re(a))},O=!m&&c.id.length>0&&p.includes(c.id),M=c.id.trim().length>0&&c.body.trim().length>0&&!O&&!b,$=d.useCallback(async()=>{var C,L;const a={...c,id:c.id.trim(),description:(C=c.description)!=null&&C.trim()?c.description.trim():void 0,body:c.body,domain:(L=c.domain)!=null&&L.trim()?c.domain.trim():void 0,domains:(c.domains??(c.domain?[c.domain]:[])).map(z=>z.trim()).filter(Boolean),modelAreaRefs:(c.modelAreaRefs??[]).map(z=>z.trim()).filter(Boolean),triggers:(c.triggers??[]).map(z=>z.trim()).filter(Boolean),exclusions:(c.exclusions??[]).map(z=>z.trim()).filter(Boolean),preferredDimensions:(c.preferredDimensions??[]).map(z=>z.trim()).filter(Boolean),requiredFilters:(c.requiredFilters??[]).map(z=>z.trim()).filter(Boolean),clarifyWhen:(c.clarifyWhen??[]).map(z=>z.trim()).filter(Boolean),examples:(c.examples??[]).map(z=>z.trim()).filter(Boolean)};B(!0),y(null);try{const z=m?await T.updateSkill(a.id,a):await T.createSkill(a);g(z.skill??a)}catch(z){y(z instanceof Error&&z.message?z.message:"Could not save this skill. Try again.")}finally{B(!1)}},[c,m,g]);return e.jsx("div",{style:Et,onClick:()=>!b&&r(),children:e.jsxs("div",{style:At(o),onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{style:Ot(),children:[e.jsx("span",{style:{width:30,height:30,borderRadius:8,background:"var(--accent-dim)",color:o.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(re,{size:15,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:o.textPrimary},children:m?"Edit skill":"New skill"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted,marginTop:1},children:"Git-backed guidance · applied only when triggers match"})]}),e.jsx("button",{type:"button",onClick:()=>!b&&r(),style:{...he(o),width:26,height:26,border:"none",background:"none"},title:"Close",children:e.jsx(me,{size:14,strokeWidth:2})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"18px 22px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"20px 28px",alignContent:"start"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Identity"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Name"}),e.jsx("input",{type:"text",value:u,onChange:a=>A(a.target.value),placeholder:"e.g. Revenue definition",style:N(o)}),e.jsxs("span",{style:{fontSize:10.5,color:o.textMuted},children:["Saved as"," ",e.jsx("input",{type:"text",value:`skills/${c.id}.skill.md`,disabled:m,onChange:a=>{h(!0),v("id",vt(a.target.value.replace(/^skills\//,"").replace(/\.skill\.md$/,"")))},onBlur:()=>v("id",Re(c.id)),title:"File name — letters, numbers, and dashes",style:{border:"none",background:"none",outline:"none",padding:0,fontFamily:o.fontMono,fontSize:10.5,color:o.textSecondary,width:`${Math.max(20,c.id.length+15)}ch`,borderBottom:m?"none":`1px dashed ${o.btnBorder}`}})]}),O?e.jsx(xe,{t:o,tone:"error",children:"A skill with this id already exists."}):null]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Domain"}),e.jsxs("select",{value:c.domain??"",onChange:a=>{const C=a.target.value||void 0;v("domain",C),v("domains",C?[C]:[])},style:{...N(o),cursor:"pointer",color:c.domain?o.textPrimary:o.textMuted},children:[e.jsx("option",{value:"",children:i.length===0?"No domains yet":"No domain"}),i.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Type"}),e.jsxs("select",{value:c.kind??"custom",onChange:a=>v("kind",a.target.value),style:{...N(o),cursor:"pointer"},children:[e.jsx("option",{value:"custom",children:"Custom guidance"}),e.jsx("option",{value:"domain_reference",children:"Domain reference — broad context"}),e.jsx("option",{value:"metric_policy",children:"Policy — focused rule"}),e.jsx("option",{value:"glossary",children:"Glossary"}),e.jsx("option",{value:"analysis_pattern",children:"Analysis pattern"}),e.jsx("option",{value:"sql_policy",children:"SQL policy"})]})]})]}),e.jsx("button",{type:"button",onClick:()=>k({type:"SET_MAIN_VIEW",view:"domains"}),style:{border:"none",background:"none",padding:0,fontSize:10.5,color:o.accent,cursor:"pointer",fontFamily:o.font,alignSelf:"flex-start"},title:"Create a new domain on the Domains page",children:"+ New domain"}),e.jsxs("div",{children:[e.jsx("span",{style:{..._(o),display:"block",marginBottom:5},children:"Lifecycle"}),e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${o.btnBorder}`,borderRadius:7,background:"var(--bg-1)"},children:["active","draft","deprecated"].map(a=>{const C=(c.status??"active")===a;return e.jsx("button",{type:"button",onClick:()=>v("status",a),style:{border:"none",borderRadius:5,padding:"4px 12px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:o.font,background:C?o.cellBg:"transparent",color:C?o.textPrimary:o.textMuted,boxShadow:C?"0 1px 3px rgba(26,26,26,0.1)":"none",textTransform:"capitalize"},children:a},a)})}),e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,marginLeft:8},children:(c.status??"active")==="active"?"Guides matching answers.":c.status==="draft"?"Drafts never guide answers.":"Kept in Git for history only."})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"When to apply"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Apply when the question mentions"}),e.jsx(zt,{t:o,values:c.triggers??[],onChange:a=>v("triggers",a),placeholder:"Add phrase, press Enter"})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Ask first when"}),e.jsx(de,{values:c.clarifyWhen??[],onChange:a=>v("clarifyWhen",a),placeholder:"e.g. 'sales' could mean revenue or order count",style:N(o)})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Avoid when"}),e.jsx(de,{values:c.exclusions??[],onChange:a=>v("exclusions",a),placeholder:"e.g. question is about pipeline or bookings",style:N(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,gridRow:"span 2"},children:[e.jsx("div",{style:te(o),children:"Guidance"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"One-line summary"}),e.jsx("input",{type:"text",value:c.description??"",onChange:a=>v("description",a.target.value),placeholder:"What rule does this skill encode?",style:N(o)})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Full guidance"}),e.jsx("textarea",{value:c.body,onChange:a=>v("body",a.target.value),rows:9,placeholder:"Definitions, exclusions, edge cases — written for the agent.",style:Mt(o)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:te(o),children:"Prefer these assets"}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Metrics"}),e.jsx(Me,{t:o,options:n.metrics,optionKind:"metrics",selected:c.preferredMetrics,onChange:a=>v("preferredMetrics",a),placeholder:"Search metrics…",emptyOptionsHint:"No metrics available from the project yet."})]}),e.jsxs("label",{style:G,children:[e.jsx("span",{style:_(o),children:"Blocks"}),e.jsx(Me,{t:o,options:n.blocks,optionKind:"blocks",selected:c.preferredBlocks,onChange:a=>v("preferredBlocks",a),placeholder:"Search blocks…",emptyOptionsHint:"No blocks available from the project yet."})]})]}),e.jsxs("details",{style:{gridColumn:"1 / -1"},children:[e.jsx("summary",{style:{fontSize:11.5,fontWeight:650,color:o.accent,cursor:"pointer"},children:"Advanced — model areas, dimensions, and vocabulary"}),e.jsxs("div",{style:{display:"grid",gap:14,marginTop:12},children:[e.jsx(ve,{label:"Focused model areas (optional)",t:o,hint:"Comma-separated area ids from the Model workspace. This boosts the skill only inside its selected domain; it never expands access.",children:e.jsx(de,{values:c.modelAreaRefs??[],onChange:a=>v("modelAreaRefs",a),placeholder:"customer_lifecycle, revenue_reporting",style:N(o)})}),e.jsx(ve,{label:"Preferred dimensions",t:o,hint:"Business-safe dimensions the agent should prefer when they are compatible.",children:e.jsx(de,{values:c.preferredDimensions??[],onChange:a=>v("preferredDimensions",a),placeholder:"region, month",style:N(o)})}),e.jsx(ve,{label:"Vocabulary",t:o,hint:"Map your terms to a target, e.g. arr → metric:arr or revenue → block:revenue_by_region.",children:e.jsx(Bt,{t:o,value:c.vocabulary,onChange:a=>v("vocabulary",a)})})]})]}),P?e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(xe,{t:o,tone:"error",children:P})}):null]}),e.jsxs("div",{style:Lt(),children:[e.jsx("span",{style:{fontSize:10.5,color:o.textMuted,flex:1,textAlign:"left"},children:"Saved to Git — review in source control before merging."}),e.jsx("button",{type:"button",onClick:()=>!b&&r(),style:Y(o),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:$,disabled:!M,style:{...ge(o),opacity:M?1:.55},children:[b?e.jsx(H,{size:13,strokeWidth:2}):null,b?"Saving…":m?"Save changes":"Create skill"]})]})]})})}function zt({t,values:n,onChange:i,placeholder:l}){const[s,p]=d.useState(""),o=r=>{const g=r.trim().replace(/,$/,"");!g||n.includes(g)||(i([...n,g]),p(""))};return e.jsxs("div",{style:He(t),children:[n.map(r=>e.jsxs("span",{style:qe(t),children:[r,e.jsx("button",{type:"button",onClick:()=>i(n.filter(g=>g!==r)),style:Ge(t),title:"Remove",children:"×"})]},r)),e.jsx("input",{type:"text",value:s,onChange:r=>p(r.target.value),onKeyDown:r=>{r.key==="Enter"||r.key===","?(r.preventDefault(),o(s)):r.key==="Backspace"&&!s&&n.length&&i(n.slice(0,-1))},onBlur:()=>o(s),placeholder:n.length?"":l,style:_e(t)})]})}function Me({t,options:n,optionKind:i,selected:l,onChange:s,placeholder:p,emptyOptionsHint:o}){const[r,g]=d.useState(""),[k,m]=d.useState(n);d.useEffect(()=>{let j=!1;const h=window.setTimeout(()=>{T.getSkillOptions(r).then(u=>{j||m(i==="metrics"?u.metrics:u.blocks)}).catch(()=>{j||m(n)})},160);return()=>{j=!0,window.clearTimeout(h)}},[i,n,r]);const c=d.useMemo(()=>k.filter(j=>!l.includes(j)).filter(j=>r?j.toLowerCase().includes(r.toLowerCase()):!0).slice(0,8),[k,l,r]),W=j=>{const h=j.trim();!h||l.includes(h)||(s([...l,h]),g(""))};return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:He(t),children:[l.map(j=>e.jsxs("span",{style:{...qe(t),fontFamily:t.fontMono},children:[j,e.jsx("button",{type:"button",onClick:()=>s(l.filter(h=>h!==j)),style:Ge(t),title:"Remove",children:"×"})]},j)),e.jsx("input",{type:"text",value:r,onChange:j=>g(j.target.value),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),W(r))},placeholder:l.length?"":p,style:_e(t)})]}),c.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:c.map(j=>e.jsxs("button",{type:"button",onClick:()=>W(j),style:Pt(t),children:[e.jsx(X,{size:10,strokeWidth:2.4})," ",j]},j))}):k.length===0?e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[o," You can still type a value and press Enter."]}):null]})}function Bt({t,value:n,onChange:i}){const[l,s]=d.useState(()=>Object.entries(n??{}).map(([r,g])=>({term:r,target:g}))),p=r=>{s(r);const g={};for(const k of r){const m=k.term.trim();m&&(g[m]=k.target.trim())}i(g)},o=(r,g)=>{p(l.map((k,m)=>m===r?{...k,...g}:k))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[l.map((r,g)=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{type:"text",value:r.term,onChange:k=>o(g,{term:k.target.value}),placeholder:"arr",style:{...N(t),flex:1}}),e.jsx("span",{style:{color:t.textMuted,fontSize:13},children:"→"}),e.jsx("input",{type:"text",value:r.target,onChange:k=>o(g,{target:k.target.value}),placeholder:"metric:arr",style:{...N(t),flex:1.3,fontFamily:t.fontMono}}),e.jsx("button",{type:"button",onClick:()=>p(l.filter((k,m)=>m!==g)),style:he(t),title:"Remove row",children:e.jsx(me,{size:13,strokeWidth:2})})]},g)),e.jsxs("button",{type:"button",onClick:()=>s([...l,{term:"",target:""}]),style:{...Y(t),justifySelf:"start"},children:[e.jsx(X,{size:12,strokeWidth:2.2})," Add term"]})]})}function Wt({t,onAdd:n}){return e.jsxs("div",{style:{border:`1px dashed ${t.cellBorder}`,borderRadius:12,background:t.cellBg,padding:"34px 28px",textAlign:"center",display:"grid",gap:12,justifyItems:"center"},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,background:`${t.accent}18`,color:t.accent,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(re,{size:22,strokeWidth:1.9})}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:t.textPrimary},children:"Teach the AI your business rules"}),e.jsx("div",{style:{fontSize:13,color:t.textMuted,maxWidth:460,lineHeight:1.55},children:'Skills are the definitions, rules, and vocabulary the AI follows when it answers — like "revenue = recognized, not bookings" or "always exclude test accounts." Add your first one to start guiding every answer.'}),e.jsxs("button",{type:"button",onClick:n,style:{...ge(t),marginTop:4},children:[e.jsx(X,{size:14,strokeWidth:2.2})," Add your first skill"]})]})}function It({t,message:n,onRetry:i}){return e.jsxs("div",{style:{border:`1px solid ${t.warning}55`,borderRadius:10,background:`${t.warning}12`,padding:"16px 18px",display:"flex",alignItems:"flex-start",gap:11},children:[e.jsx(Le,{size:16,strokeWidth:2,color:t.warning,style:{marginTop:1,flexShrink:0}}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:"Skills are not available right now"}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.5},children:n}),e.jsxs("button",{type:"button",onClick:i,style:{...Y(t),marginTop:10},children:[e.jsx(ye,{size:13,strokeWidth:2})," Retry"]})]})]})}function Tt({skill:t,t:n,deleting:i,error:l,onCancel:s,onConfirm:p}){return e.jsx("div",{style:Ft,onClick:s,children:e.jsxs("div",{style:Nt(n),onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(ie,{size:16,strokeWidth:2,color:n.error}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:n.textPrimary},children:"Delete this skill?"})]}),e.jsxs("div",{style:{fontSize:13,color:n.textSecondary,lineHeight:1.55},children:[e.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:t.id})," will be removed and the AI will stop following it. This can't be undone."]}),l?e.jsx(xe,{t:n,tone:"error",children:l}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:s,disabled:i,style:Y(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:p,disabled:i,style:{...Rt(n),opacity:i?.6:1},children:[i?e.jsx(H,{size:13,strokeWidth:2}):e.jsx(ie,{size:13,strokeWidth:2}),i?"Deleting…":"Delete"]})]})]})})}function te(t){return{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.textMuted,marginBottom:5}}function ee({t,label:n,values:i,empty:l,accent:s=!1,mono:p=!1}){return e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:te(t),children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:i!=null&&i.length?i.map(o=>e.jsx("span",{style:{fontSize:11,padding:"3px 9px",borderRadius:999,background:s?"var(--accent-dim)":"var(--bg-1)",color:s?t.accent:t.textSecondary,border:s?`1px solid ${t.accent}33`:"1px solid var(--border-subtle)",fontFamily:p?t.fontMono:void 0},children:o},o)):e.jsx("span",{style:{fontSize:11.5,color:t.textMuted,fontStyle:"italic"},children:l})})]})}function ve({label:t,hint:n,t:i,children:l}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:i.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:i.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,l]})}function xe({t,tone:n,children:i}){const l=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:l,lineHeight:1.45},children:i})}function $t(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.success,background:`${t.success}14`,border:`1px solid ${t.success}38`,borderRadius:999,padding:"2px 7px"}}function Dt(t){return{display:"inline-flex",alignItems:"center",fontSize:10.5,fontWeight:700,color:t.accent,background:`${t.accent}14`,border:`1px solid ${t.accent}38`,borderRadius:999,padding:"2px 7px"}}function ge(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function Y(t){return{display:"inline-flex",alignItems:"center",gap:5,padding:"7px 11px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontSize:12,fontWeight:600,fontFamily:t.font,cursor:"pointer"}}function Rt(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:`1px solid ${t.error}`,background:t.error,color:"#ffffff",fontSize:12.5,fontWeight:700,fontFamily:t.font,cursor:"pointer"}}function he(t){return{display:"inline-flex",alignItems:"center",justifyContent:"center",width:30,height:30,borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,cursor:"pointer",flexShrink:0}}function N(t){return{width:"100%",border:`1px solid ${t.btnBorder}`,borderRadius:7,background:t.cellBg,color:t.textPrimary,fontSize:12.5,fontFamily:t.font,padding:"8px 10px",boxSizing:"border-box"}}function Mt(t){return{...N(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function Pe(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:700,letterSpacing:"0.02em",color:t.warning,background:`${t.warning}16`,border:`1px solid ${t.warning}40`,borderRadius:999,padding:"2px 8px"}}function He(t){return{display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",border:`1px solid ${t.btnBorder}`,background:t.cellBg,borderRadius:7,padding:"6px 8px"}}function _e(t){return{flex:1,minWidth:110,border:"none",background:"none",outline:"none",fontSize:11.5,fontFamily:t.font,color:t.textPrimary,padding:2}}function qe(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"2.5px 8px",borderRadius:999,background:"var(--accent-dim)",color:t.accent,border:`1px solid ${t.accent}33`}}function Ge(t){return{border:"none",background:"none",color:t.accent,cursor:"pointer",padding:0,fontSize:12,lineHeight:1,fontFamily:t.font}}const G={display:"flex",flexDirection:"column",gap:4};function _(t){return{fontSize:11,fontWeight:650,color:t.textSecondary}}function Pt(t){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:t.textSecondary,background:t.btnBg,border:`1px solid ${t.btnBorder}`,borderRadius:6,padding:"3px 8px",cursor:"pointer",fontFamily:t.fontMono}}const Et={position:"fixed",inset:0,background:"rgba(26, 26, 26, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60};function At(t){return{width:"min(860px, 94vw)",height:"min(640px, 90vh)",background:t.cellBg,border:`1px solid ${t.headerBorder}`,borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 24px 70px rgba(26,26,26,0.22)"}}function Ot(t){return{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0}}function Lt(t){return{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 18px",borderTop:"1px solid var(--border-subtle)",background:"var(--bg-1)",flexShrink:0}}const Ft={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function Nt(t){return{width:"min(420px, 100%)",background:t.cellBg,border:`1px solid ${t.cellBorder}`,borderRadius:12,padding:20,display:"grid",gap:13,boxShadow:"0 18px 48px rgba(0,0,0,0.3)"}}function Ht({initialTab:t="overview"}){const{state:n}=fe(),i=we[n.themeMode],[l,s]=d.useState(t),[p,o]=d.useState([]),[r,g]=d.useState([]),[k,m]=d.useState(!0);d.useEffect(()=>s(t),[t]);const c=d.useCallback(()=>{let u=!1;return m(!0),Promise.all([T.getDomains(),T.getSkills()]).then(([I,b])=>{u||(o(Array.isArray(I.domains)?I.domains:[]),g(Array.isArray(b.skills)?b.skills:[]))}).catch(()=>{u||(o([]),g([]))}).finally(()=>{u||m(!1)}),()=>{u=!0}},[]);d.useEffect(()=>c(),[c]);const W=d.useMemo(()=>{const u=p.filter(B=>!!(B.businessOwner||B.owner)).length,I=r.filter(B=>!B.status||B.status==="active").length,b=r.filter(B=>B.status==="draft").length;return{ownedDomains:u,activeSkills:I,draftSkills:b}},[p,r]),j=d.useCallback(()=>{s("domains"),window.setTimeout(()=>window.dispatchEvent(new Event("dql:context-build")),50)},[]),h=[{id:"overview",label:"Overview"},{id:"domains",label:"Domains",count:p.length},{id:"skills",label:"Skills",count:r.length},{id:"knowledge",label:"Knowledge 360"}];return e.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto",background:i.appBg},children:e.jsxs("div",{style:{maxWidth:1040,margin:"0 auto",padding:"22px 28px 40px"},children:[e.jsxs("header",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-end",gap:18,marginBottom:15},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:9,alignItems:"center"},children:[e.jsx(se,{size:20,color:i.accent}),e.jsx("h1",{style:{fontSize:22,color:i.textPrimary},children:"Governed context"})]}),e.jsx("p",{style:{marginTop:6,fontSize:13,lineHeight:1.5,color:i.textMuted,maxWidth:700},children:"Domains define business boundaries. Skills teach the agent approved vocabulary, reuse rules, and when to ask for clarification."})]}),e.jsxs("button",{type:"button",onClick:j,style:Qe(i),children:[e.jsx(ne,{size:14})," Build with AI"]})]}),e.jsx("nav",{"aria-label":"Governed context sections",style:{display:"flex",gap:3,borderBottom:`1px solid ${i.headerBorder}`,marginBottom:18},children:h.map(u=>e.jsxs("button",{type:"button",onClick:()=>s(u.id),style:{border:"none",borderBottom:`2px solid ${l===u.id?i.accent:"transparent"}`,background:"transparent",padding:"9px 12px",color:l===u.id?i.textPrimary:i.textMuted,fontWeight:l===u.id?700:600,cursor:"pointer",fontFamily:i.font,fontSize:12.5},children:[u.label,u.count!==void 0?` · ${u.count}`:""]},u.id))}),l==="overview"?e.jsx(_t,{t:i,loading:k,domains:p,skills:r,status:W,onBuild:j,onTab:s}):null,l==="domains"?e.jsx(nt,{embedded:!0}):null,l==="skills"?e.jsx(St,{embedded:!0}):null,l==="knowledge"?e.jsx(Ke,{t:i,domains:p}):null]})})}function Ke({t,domains:n,initialDomainId:i}){var W,j;const[l,s]=d.useState(i??((W=n[0])==null?void 0:W.id)??""),[p,o]=d.useState(null),[r,g]=d.useState(!1),[k,m]=d.useState(null);d.useEffect(()=>{var h;!l&&((h=n[0])!=null&&h.id)&&s(n[0].id)},[l,n]),d.useEffect(()=>{i&&n.some(h=>h.id===i)&&s(i)},[n,i]),d.useEffect(()=>{if(!l){o(null);return}let h=!1;return g(!0),m(null),T.getDomainKnowledge(l).then(u=>{h||o(u)}).catch(u=>{h||(o(null),m(u instanceof Error?u.message:"Could not load the compiled knowledge capsule."))}).finally(()=>{h||g(!1)}),()=>{h=!0}},[l]);const c=d.useMemo(()=>{const h={};for(const u of(p==null?void 0:p.objects)??[])h[u.kind]=(h[u.kind]??0)+1;return Object.entries(h).sort((u,I)=>I[1]-u[1]||u[0].localeCompare(I[0]))},[p]);return e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsx("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:15},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:7,alignItems:"center",color:t.textPrimary,fontWeight:700,fontSize:13},children:[e.jsx(Ie,{size:16,color:t.accent})," Compiled Domain 360"]}),e.jsx("div",{style:{marginTop:4,color:t.textMuted,fontSize:12},children:"The same qualified graph, route policy, and skill snapshot used by Ask."})]}),e.jsxs("select",{"aria-label":"Domain knowledge capsule",value:l,onChange:h=>s(h.target.value),style:{minWidth:210,border:`1px solid ${t.inputBorder}`,borderRadius:7,background:t.inputBg,color:t.textPrimary,padding:"7px 9px",fontFamily:t.font},children:[e.jsx("option",{value:"",children:"Select a domain"}),[...n].sort((h,u)=>h.name.localeCompare(u.name)).map(h=>e.jsx("option",{value:h.id,children:h.name},h.id))]})]})}),r?e.jsxs("div",{style:{color:t.textMuted,display:"flex",gap:8,alignItems:"center",padding:24},children:[e.jsx(H,{size:15})," Loading compiled knowledge…"]}):null,k?e.jsx("div",{style:{border:`1px solid ${t.error}`,background:t.cellBg,color:t.error,borderRadius:8,padding:12,fontSize:12.5},children:k}):null,p?e.jsxs(e.Fragment,{children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:9},children:[e.jsx(V,{t,label:"Objects",value:p.counts.objects,detail:"qualified knowledge",icon:e.jsx(se,{size:16})}),e.jsx(V,{t,label:"Relations",value:p.counts.edges,detail:"provenance + policy",icon:e.jsx(Ie,{size:16})}),e.jsx(V,{t,label:"Authorized",value:p.counts.routeStates.authorized??0,detail:"safe cross-domain routes",icon:e.jsx(Je,{size:16})}),e.jsx(V,{t,label:"Blocked / stale",value:(p.counts.routeStates.blocked??0)+(p.counts.routeStates.stale??0),detail:"never auto-joined",icon:e.jsx(Oe,{size:16})})]}),e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.2fr) minmax(0, 1fr)",gap:12},children:[e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Knowledge capsule"}),e.jsx("p",{style:{color:t.textSecondary,fontSize:12.5,lineHeight:1.5,margin:"7px 0 11px"},children:((j=p.capsule)==null?void 0:j.description)||"Compiled domain boundary and governed references."}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:c.map(([h,u])=>e.jsxs("span",{style:{border:`1px solid ${t.cellBorder}`,background:t.pillBg,color:t.textSecondary,borderRadius:999,padding:"3px 7px",fontSize:11},children:[h.replace(/_/g," ")," · ",u]},h))}),e.jsxs("div",{style:{marginTop:11,color:t.textMuted,fontSize:11},children:["Snapshot ",p.snapshotId.slice(0,12)," · graph ",p.sourceFingerprint.slice(0,12),p.truncated?" · bounded response":""]})]}),e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:14},children:[e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Cross-domain routes"}),e.jsx("div",{style:{display:"grid",gap:7,marginTop:9},children:p.routes.length?p.routes.map(h=>e.jsxs("div",{style:{borderTop:`1px solid ${t.headerBorder}`,paddingTop:7},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:8,color:t.textSecondary,fontSize:12},children:[e.jsxs("span",{children:[h.providerDomainId," → ",h.consumerDomainId]}),e.jsx("span",{style:{color:h.state==="authorized"?t.success:h.state==="observed"?t.textMuted:t.warning,fontWeight:700},children:h.state})]}),e.jsx("div",{style:{marginTop:3,color:t.textMuted,fontSize:11},children:h.purpose||h.reasonCodes.join(", ")||"governed route"})]},h.id)):e.jsx("div",{style:{color:t.textMuted,fontSize:12,marginTop:8},children:"No cross-domain routes declared."})})]})]})]}):null]})}function _t({t,loading:n,domains:i,skills:l,status:s,onBuild:p,onTab:o}){if(n)return e.jsxs("div",{style:{padding:"42px 0",color:t.textMuted,display:"flex",gap:8,alignItems:"center",fontSize:13},children:[e.jsx(H,{size:15})," Loading governed context…"]});const r=[];return i.length?s.ownedDomains<i.length&&r.push(`${i.length-s.ownedDomains} domain${i.length-s.ownedDomains===1?"":"s"} still need an owner.`):r.push("Create a business domain before relying on AI guidance."),l.length||r.push("Draft a domain skill so the agent has governed business guidance."),s.draftSkills&&r.push(`${s.draftSkills} skill${s.draftSkills===1?" is":"s are"} still draft-only and will not guide answers.`),e.jsxs("div",{style:{display:"grid",gap:16},children:[e.jsxs("section",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(V,{t,label:"Domains",value:i.length,detail:`${s.ownedDomains} with an owner`,icon:e.jsx(se,{size:17})}),e.jsx(V,{t,label:"Active skills",value:s.activeSkills,detail:"available to the agent",icon:e.jsx(re,{size:17})}),e.jsx(V,{t,label:"Draft skills",value:s.draftSkills,detail:"review before activation",icon:e.jsx(ne,{size:17})})]}),e.jsxs("section",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:10,background:t.cellBg,padding:16,display:"grid",gap:10},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsx(Ve,{size:16,color:r.length?t.warning:t.success}),e.jsx("strong",{style:{color:t.textPrimary,fontSize:13},children:"Readiness"})]}),r.length?e.jsx("div",{style:{display:"grid",gap:6},children:r.map(g=>e.jsxs("div",{style:{display:"flex",gap:7,color:t.textSecondary,fontSize:12.5},children:[e.jsx(Oe,{size:14,color:t.warning}),g]},g))}):e.jsx("div",{style:{color:t.success,fontSize:12.5},children:"Your agent has owned domains and active governed skills available for retrieval."}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:2},children:[e.jsxs("button",{type:"button",onClick:p,style:Qe(t),children:[e.jsx(ne,{size:13})," Build domains & skills with AI"]}),e.jsx("button",{type:"button",onClick:()=>o("domains"),style:Ee(t),children:"Manage domains"}),e.jsx("button",{type:"button",onClick:()=>o("skills"),style:Ee(t),children:"Manage skills"})]})]})]})}function V({t,label:n,value:i,detail:l,icon:s}){return e.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:9,background:t.cellBg,padding:13},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:t.textMuted,fontSize:12},children:[n,s]}),e.jsx("div",{style:{color:t.textPrimary,fontSize:25,fontWeight:750,marginTop:7},children:i}),e.jsx("div",{style:{color:t.textMuted,fontSize:11.5,marginTop:3},children:l})]})}function Qe(t){return{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 12px",borderRadius:7,border:`1px solid ${t.accent}`,background:t.accent,color:"#fff",fontWeight:700,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}function Ee(t){return{display:"inline-flex",alignItems:"center",padding:"7px 12px",borderRadius:7,border:`1px solid ${t.btnBorder}`,background:t.btnBg,color:t.textSecondary,fontWeight:650,fontSize:12.5,fontFamily:t.font,cursor:"pointer"}}const Jt=Object.freeze(Object.defineProperty({__proto__:null,GovernedContextPage:Ht,Knowledge360:Ke},Symbol.toStringTag,{value:"Module"}));export{Jt as G,Ke as K,St as S};
@@ -0,0 +1,22 @@
1
+ import{g as v,u as z,t as R,r as u,j as e,av as I}from"./index-BMVfPaXr.js";import"./react-CRB3T2We.js";/**
2
+ * @license lucide-react v0.563.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const q=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],A=v("image",q);/**
7
+ * @license lucide-react v0.563.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const B=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],W=v("info",B),F=[{title:"Installation",mins:"3 min"},{title:"Run CLI commands",mins:"3 min"},{title:"Connect your database",mins:"4 min"},{title:"Sync your dbt project",mins:"2 min"},{title:"Create your first block",mins:"5 min"},{title:"Ask your first question",mins:"3 min"},{title:"Share your work",mins:"3 min"},{title:"Troubleshooting",mins:"—"}],j="https://github.com/duckcode-ai/dql/blob/main/docs/reference/cli.md";function _(){const{state:k,dispatch:S}=z(),t=R[k.themeMode],[w,T]=u.useState(0),[d,f]=u.useState(null),g=u.useRef(null),m=u.useRef([]),C=()=>{const n=g.current;if(!n)return;const r=n.scrollTop+90;let i=0;m.current.forEach((b,L)=>{b&&b.offsetTop<=r&&(i=L)}),T(i)},D=n=>{const r=g.current,i=m.current[n];!r||!i||r.scrollTo({top:Math.max(0,i.offsetTop-24),behavior:"smooth"})},p=t.fontMono,y={margin:"12px 0 0",border:`1px solid ${t.cellBorder}`,background:"#1e1c26",borderRadius:10,padding:"13px 16px",fontSize:12.5,lineHeight:1.7,fontFamily:p,color:"#e8e6f0",overflowX:"auto",whiteSpace:"pre"},c={color:"#8a8d96"},s={fontFamily:p,fontSize:12,background:"var(--bg-0)",borderRadius:4,padding:"1px 5px"},l=(n,r)=>e.jsxs("h2",{style:{margin:0,fontSize:20,fontWeight:700,letterSpacing:"-0.01em",color:t.textPrimary,display:"flex",alignItems:"center",gap:9},children:[e.jsx("span",{style:{color:t.textMuted,fontFamily:p,fontSize:15},children:n}),r]}),o={margin:"12px 0 0"},h=(n,r)=>e.jsxs("div",{style:{margin:"16px 0 0"},children:[e.jsxs("div",{style:{width:"100%",height:300,borderRadius:10,border:`1.5px dashed ${t.cellBorder}`,background:t.appBg,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,color:t.textMuted},children:[e.jsx(A,{size:22,strokeWidth:1.5}),e.jsx("span",{style:{fontSize:12,fontStyle:"italic",maxWidth:420,textAlign:"center"},children:r})]}),e.jsx("div",{style:{marginTop:6,fontSize:11.5,color:t.textMuted,textAlign:"center"},children:n})]}),x=(n,r)=>e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:t.cellBg,padding:"12px 14px"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:650,color:t.textPrimary},children:n}),e.jsx("div",{style:{fontSize:12.5,color:t.textSecondary,marginTop:4,lineHeight:1.6},children:r})]}),a=n=>r=>{m.current[n]=r};return e.jsxs("div",{style:{flex:1,minWidth:0,minHeight:0,display:"flex",overflow:"hidden",background:"var(--bg-canvas)",fontFamily:t.font},children:[e.jsxs("div",{style:{width:"clamp(200px, 18vw, 252px)",flexShrink:0,borderRight:`1px solid ${t.headerBorder}`,background:t.cellBg,display:"flex",flexDirection:"column",minHeight:0,overflow:"auto",padding:"16px 8px"},children:[e.jsx("div",{style:{padding:"0 10px 8px",fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.textMuted},children:"Getting started"}),F.map((n,r)=>{const i=w===r;return e.jsxs("button",{type:"button",onClick:()=>D(r),style:{display:"flex",alignItems:"center",gap:8,padding:"6.5px 10px",borderRadius:7,border:"none",cursor:"pointer",textAlign:"left",fontSize:12,fontWeight:550,fontFamily:t.font,width:"100%",background:i?"var(--accent-dim)":"transparent",color:i?t.accent:t.textSecondary},children:[e.jsx("span",{style:{width:18,height:18,borderRadius:5,background:i?t.accent:"var(--bg-0)",color:i?"#fff":t.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9.5,fontWeight:700,flexShrink:0,fontFamily:p},children:String(r+1).padStart(2,"0")}),e.jsx("span",{style:{flex:1},children:n.title}),e.jsx("span",{style:{fontSize:9.5,color:t.textMuted},children:n.mins})]},n.title)}),e.jsx("div",{style:{height:1,background:"var(--border-subtle)",margin:"12px 10px"}}),e.jsxs("div",{style:{padding:"0 10px",display:"flex",flexDirection:"column",gap:7,fontSize:11.5},children:[e.jsx("a",{href:"https://github.com/duckcode-ai/dql#readme",target:"_blank",rel:"noreferrer",style:{color:t.accent,textDecoration:"none"},children:"Keyboard shortcuts"}),e.jsx("a",{href:j,target:"_blank",rel:"noreferrer",style:{color:t.accent,textDecoration:"none"},children:"CLI reference"}),e.jsx("a",{href:"https://github.com/duckcode-ai/dql/discussions",target:"_blank",rel:"noreferrer",style:{color:t.accent,textDecoration:"none"},children:"Community & support"})]}),e.jsx("div",{style:{flex:1}}),e.jsxs("div",{style:{margin:"12px 10px 0",border:"1px solid var(--border-subtle)",borderRadius:9,background:t.appBg,padding:"10px 11px",fontSize:11,color:t.textMuted,lineHeight:1.5},children:["Stuck? Ask the assistant — it reads these docs.",e.jsx("div",{children:e.jsxs("button",{type:"button",onClick:()=>S({type:"OPEN_GLOBAL_AI",autoRun:{text:"Help me finish setting up DQL — what is left to configure in this workspace?"}}),style:{marginTop:7,display:"inline-flex",alignItems:"center",gap:5,height:26,padding:"0 10px",borderRadius:6,border:`1px solid ${t.cellBorder}`,background:t.cellBg,color:t.accent,fontSize:11,fontWeight:650,cursor:"pointer",fontFamily:t.font},children:[e.jsx(I,{size:11,strokeWidth:1.75})," Ask about setup"]})})]})]}),e.jsx("div",{ref:g,onScroll:C,style:{flex:1,minWidth:0,overflow:"auto"},children:e.jsxs("div",{style:{width:"min(680px, 100% - 56px)",margin:"0 auto",padding:"34px 0 80px",fontSize:14,lineHeight:1.7,color:t.textSecondary},children:[e.jsx("div",{style:{fontSize:11,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:t.accent},children:"Guide"}),e.jsx("h1",{style:{margin:"6px 0 0",fontSize:28,fontWeight:700,letterSpacing:"-0.02em",color:t.textPrimary,lineHeight:1.25},children:"Getting started with DQL"}),e.jsx("div",{style:{marginTop:8,fontSize:13.5,color:t.textMuted},children:"From install to your first governed answer — about 20 minutes."}),e.jsxs("div",{ref:a(0),style:{marginTop:36},children:[l("01","Installation"),e.jsxs("p",{style:o,children:["DQL runs locally next to your dbt project. The recommended setup creates a ",e.jsx("span",{style:s,children:"dql/"})," workspace and installs the CLI inside it, so every repository keeps the version it was tested with."]}),e.jsxs("pre",{style:{...y,margin:"14px 0 0"},children:["cd my-dbt-project",`
12
+ `,"dbt parse",`
13
+ `,"npx create-dql-app@latest dql",`
14
+ `,"cd dql",`
15
+ `,"npm install",`
16
+ `,"npm run doctor",`
17
+ `,"npm run notebook"]}),e.jsxs("div",{style:{margin:"14px 0 0",display:"flex",gap:9,alignItems:"flex-start",border:"1px solid var(--status-info-border)",background:"var(--accent-dim)",borderRadius:10,padding:"11px 13px"},children:[e.jsx(W,{size:13,color:t.accent,style:{flexShrink:0,marginTop:2}}),e.jsxs("span",{style:{fontSize:12.5,lineHeight:1.6,color:t.textSecondary},children:[e.jsx("strong",{children:"Requirements:"})," Node 20+, git, and a dbt project (dbt-core 1.6+ or dbt Cloud). DQL can install optional DuckDB and Snowflake drivers into the project when needed; Databricks uses the built-in HTTPS connector."]})]}),h("The workbench opens on localhost with your project loaded.","Screenshot: terminal after `npm run notebook` opens the workbench")]}),e.jsxs("div",{ref:a(1),style:{marginTop:44},children:[l("02","Run CLI commands"),e.jsxs("p",{style:o,children:["A project-local install puts the executable in ",e.jsx("span",{style:s,children:"node_modules/.bin"}),". npm scripts can use it automatically; your normal shell cannot. Use a starter script for daily commands or ",e.jsx("span",{style:s,children:"npm exec -- dql"})," for any other command."]}),e.jsxs("pre",{style:y,children:["npm run doctor ",e.jsx("span",{style:c,children:"# project setup and readiness"}),`
18
+ `,"npm run notebook ",e.jsx("span",{style:c,children:"# local browser UI"}),`
19
+ `,"npm run sync ",e.jsx("span",{style:c,children:"# refresh dbt state"}),`
20
+ `,"npm run compile ",e.jsx("span",{style:c,children:"# write dql-manifest.json"}),`
21
+ `,"npm exec -- dql model list",`
22
+ `,"npm exec -- dql --help"]}),e.jsxs("p",{style:o,children:["A bare ",e.jsx("span",{style:s,children:"dql ..."})," command requires the optional global install: ",e.jsx("span",{style:s,children:"npm install -g @duckcodeailabs/dql-cli"}),". See the ",e.jsx("a",{href:j,target:"_blank",rel:"noreferrer",style:{color:t.accent,textDecoration:"none"},children:"complete CLI reference"})," for all commands, subcommands, flags, examples, and exit codes."]})]}),e.jsxs("div",{ref:a(2),style:{marginTop:44},children:[l("03","Connect your database"),e.jsxs("p",{style:o,children:["Open ",e.jsx("strong",{children:"Settings → Database"}),". Pick your warehouse and the form adjusts to what that warehouse needs — DuckDB uses a file path, while Snowflake supports password, key-pair, SSO, OAuth, and workload-identity authentication."]}),e.jsxs("ol",{style:{margin:"12px 0 0",paddingLeft:22,display:"flex",flexDirection:"column",gap:8},children:[e.jsx("li",{children:"Choose your warehouse from the dropdown."}),e.jsxs("li",{children:["Fill the connection fields (credentials stay in ",e.jsx("span",{style:s,children:".dql/"}),", never leave your machine)."]}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Test connection"})," — you should see model count and latency."]}),e.jsx("li",{children:"Save. The status dot in the sidebar turns green."})]}),h("A successful test shows models found and round-trip time.","Screenshot: Settings → Database with a passing test")]}),e.jsxs("div",{ref:a(3),style:{marginTop:44},children:[l("04","Sync your dbt project"),e.jsx("p",{style:o,children:"DQL reads your dbt manifest and keeps ownership where it belongs: models, columns, tests, and lineage stay in dbt. DQL layers governed context on top — domains, blocks, skills."}),e.jsxs("pre",{style:y,children:["npm run sync ",e.jsx("span",{style:c,children:"# runs dql sync dbt with the local CLI"})]}),e.jsxs("p",{style:o,children:["After a sync, the ",e.jsx("strong",{children:"Domains"})," page shows your models grouped by folder, ready to bind into business entities. Re-run after any dbt change."]})]}),e.jsxs("div",{ref:a(4),style:{marginTop:44},children:[l("05","Create your first block"),e.jsx("p",{style:o,children:'Blocks are reusable, governed questions — "total revenue", "churn by tier". Answers route through certified blocks before anything is generated, so every block you certify makes the whole workspace more trustworthy.'}),e.jsxs("ol",{style:{margin:"12px 0 0",paddingLeft:22,display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("li",{children:["Open ",e.jsx("strong",{children:"Blocks"})," and hit ",e.jsx("strong",{children:"+"}),", or start from an Ask AI answer with ",e.jsx("em",{children:"Save as block"}),"."]}),e.jsx("li",{children:"In the Visual Builder, pick measures and dimensions from the semantic picker — or paste raw SQL and convert it."}),e.jsxs("li",{children:["Add parameters (like ",e.jsx("span",{style:s,children:"${region}"}),") so the block is reusable."]}),e.jsxs("li",{children:["Run it, check the result, and ",e.jsx("strong",{children:"Save draft"}),". Certification happens in review."]})]}),h("The semantic picker searches all certified measures — no SQL required.","Screenshot: Visual Builder with the semantic picker open")]}),e.jsxs("div",{ref:a(5),style:{marginTop:44},children:[l("06","Ask your first question"),e.jsxs("p",{style:o,children:["Open ",e.jsx("strong",{children:"Ask"})," and type a business question. DQL answers in a strict order — certified blocks first, semantic metrics next, generated SQL last — and labels every answer with how it was produced."]}),e.jsx("div",{style:{margin:"14px 0 0",border:"1px solid var(--border-subtle)",borderRadius:10,background:t.cellBg,overflow:"hidden"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"110px 1fr",fontSize:12.5},children:[e.jsx("div",{style:{padding:"9px 13px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)",fontWeight:650,color:"var(--status-success)"},children:"Certified"}),e.jsx("div",{style:{padding:"9px 13px",borderBottom:"1px solid var(--border-subtle)",color:t.textSecondary},children:"Answered from a certified block — instant and trusted."}),e.jsx("div",{style:{padding:"9px 13px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-1)",fontWeight:650,color:t.accent},children:"Governed"}),e.jsx("div",{style:{padding:"9px 13px",borderBottom:"1px solid var(--border-subtle)",color:t.textSecondary},children:"Composed from semantic metrics and proven joins."}),e.jsx("div",{style:{padding:"9px 13px",background:"var(--bg-1)",fontWeight:650,color:"var(--status-warning)"},children:"AI-generated"}),e.jsx("div",{style:{padding:"9px 13px",color:t.textSecondary},children:"Fresh SQL grounded in your schema, verified, and clearly labeled."})]})}),e.jsxs("p",{style:o,children:["Click any artifact chip in the chat to inspect the result, chart, DQL, SQL, and the full trust trail. Good answers deserve ",e.jsx("em",{children:"Save as block"})," — that's how the certified layer grows."]})]}),e.jsxs("div",{ref:a(6),style:{marginTop:44},children:[l("07","Share your work"),e.jsxs("p",{style:o,children:["Everything you author is a file in Git. The ",e.jsx("strong",{children:"Source control"})," page walks you through it without git commands: pick changes, describe them in plain words, share to your branch, and open a review request. Nothing reaches main without an approval."]}),h("Three steps: pick, describe, share — then ask for review.","Screenshot: Source control with the guided share flow")]}),e.jsxs("div",{ref:a(7),style:{marginTop:44},children:[l("08","Troubleshooting"),e.jsxs("div",{style:{margin:"14px 0 0",display:"flex",flexDirection:"column",gap:10},children:[x("“dbt manifest not found”",e.jsxs(e.Fragment,{children:["Run ",e.jsx("span",{style:s,children:"dbt parse"})," in the dbt project, then ",e.jsx("span",{style:s,children:"npm run sync"})," from its DQL workspace. DQL needs a compiled manifest to read lineage."]})),x("“dql: command not found”",e.jsxs(e.Fragment,{children:["A project-local install uses ",e.jsx("span",{style:s,children:"npm run ..."})," or ",e.jsx("span",{style:s,children:"npm exec -- dql ..."}),". Install the CLI globally only if you want bare ",e.jsx("span",{style:s,children:"dql ..."})," commands."]})),x("Connection test fails",e.jsxs(e.Fragment,{children:["Check ",e.jsx("span",{style:s,children:"npm run doctor"})," and ",e.jsx("strong",{children:"Settings → Database"}),". Test candidate credentials before saving them."]})),x("AI answers feel wrong",e.jsx(e.Fragment,{children:'Add a skill with your definitions ("revenue = recognized, not bookings") and certify more blocks. Trust labels tell you which route produced each answer.'}))]})]}),e.jsxs("div",{style:{marginTop:44,borderTop:"1px solid var(--border-subtle)",paddingTop:18,display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"Was this guide helpful?"}),e.jsx("button",{type:"button",onClick:()=>f("yes"),style:{height:26,padding:"0 11px",borderRadius:999,border:`1px solid ${d==="yes"?"var(--status-success)":t.cellBorder}`,background:d==="yes"?"var(--status-success-bg)":t.cellBg,color:d==="yes"?"var(--status-success)":t.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:t.font},children:"Yes"}),e.jsx("button",{type:"button",onClick:()=>f("no"),style:{height:26,padding:"0 11px",borderRadius:999,border:`1px solid ${d==="no"?"var(--status-error)":t.cellBorder}`,background:d==="no"?"var(--status-error-bg)":t.cellBg,color:d==="no"?"var(--status-error)":t.textSecondary,fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:t.font},children:"Not quite"}),e.jsx("div",{style:{flex:1}}),d?e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"Thanks for the feedback."}):null]})]})})]})}export{_ as HelpDocsPage};