@duckcodeailabs/dql-cli 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/apps-api.d.ts +225 -5
  2. package/dist/apps-api.d.ts.map +1 -1
  3. package/dist/apps-api.js +1950 -117
  4. package/dist/apps-api.js.map +1 -1
  5. package/dist/args.d.ts +2 -0
  6. package/dist/args.d.ts.map +1 -1
  7. package/dist/args.js +3 -0
  8. package/dist/args.js.map +1 -1
  9. package/dist/assets/dql-notebook/assets/{AgentLogPage-CBGEoGmU.js → AgentLogPage-BlUE3qsX.js} +1 -1
  10. package/dist/assets/dql-notebook/assets/{AiBuildDialog-CwAD3tXE.js → AiBuildDialog-O88iK6UW.js} +1 -1
  11. package/dist/assets/dql-notebook/assets/AiBuildResult-D-6G4Sh3.js +33 -0
  12. package/dist/assets/dql-notebook/assets/{AiSidePanel-DjB8PWHG.js → AiSidePanel-MRSGtQDV.js} +1 -1
  13. package/dist/assets/dql-notebook/assets/AnalyticsHome-CcRVO6zN.js +6 -0
  14. package/dist/assets/dql-notebook/assets/AppsView-BTkGC-wl.js +5588 -0
  15. package/dist/assets/dql-notebook/assets/BlockStudio-BrTNaDpb.js +55 -0
  16. package/dist/assets/dql-notebook/assets/{BusinessArtifactView-C4SZVNW-.js → BusinessArtifactView-itEIUrYy.js} +1 -1
  17. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CbAqOpNc.js +22 -0
  18. package/dist/assets/dql-notebook/assets/{GitPage-BfVD4tVq.js → GitPage-BxOqRYu2.js} +1 -1
  19. package/dist/assets/dql-notebook/assets/GlobalAiRail-Tfkx76CI.js +1 -0
  20. package/dist/assets/dql-notebook/assets/GovernedContextPage-CeaDbepP.js +7 -0
  21. package/dist/assets/dql-notebook/assets/{HelpDocsPage-BDPNVot1.js → HelpDocsPage-D1lAryYv.js} +1 -1
  22. package/dist/assets/dql-notebook/assets/{HomePage-DiOnRhEG.js → HomePage-GB6se6xW.js} +1 -1
  23. package/dist/assets/dql-notebook/assets/{LineageDAG-BiUFX2KL.js → LineageDAG-zCyN-hdg.js} +1 -1
  24. package/dist/assets/dql-notebook/assets/{LineageDetailView-CfbSvlPJ.js → LineageDetailView-Cg0TgG2Y.js} +1 -1
  25. package/dist/assets/dql-notebook/assets/{LineageDrawer-CgTScaGB.js → LineageDrawer-DwMcenDf.js} +1 -1
  26. package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-D7ZA7k68.js → LineagePathBreadcrumb-DUZx3ksU.js} +1 -1
  27. package/dist/assets/dql-notebook/assets/{MiniLineageGraph-GkD4y17x.js → MiniLineageGraph-DT_ycl6s.js} +1 -1
  28. package/dist/assets/dql-notebook/assets/{NewBlockModal-B9TfRjt7.js → NewBlockModal-qdhzeJPF.js} +1 -1
  29. package/dist/assets/dql-notebook/assets/{NewNotebookModal-BbO9NKUl.js → NewNotebookModal-BnaDzs1A.js} +1 -1
  30. package/dist/assets/dql-notebook/assets/{NotebookEditor-CuMpvXR9.js → NotebookEditor-CouPFzdo.js} +26 -31
  31. package/dist/assets/dql-notebook/assets/{ReadinessPage-BROJ9YBM.js → ReadinessPage-DB_KbH9Y.js} +1 -1
  32. package/dist/assets/dql-notebook/assets/{SetupOnboarding-BCcZlpuQ.js → SetupOnboarding-CamQq_N2.js} +1 -1
  33. package/dist/assets/dql-notebook/assets/SkillsPage--mYkOAK2.js +10 -0
  34. package/dist/assets/dql-notebook/assets/{TrustBadge-vQQh8d0D.js → TrustBadge-ClEYiYeA.js} +1 -1
  35. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-DBfsmXes.js +88 -0
  36. package/dist/assets/dql-notebook/assets/{answer-to-notebook-DuqCcDDl.js → answer-to-notebook-Cg3UyGwh.js} +1 -1
  37. package/dist/assets/dql-notebook/assets/{arrow-left-CMe1kkOL.js → arrow-left-DnYPGqlr.js} +1 -1
  38. package/dist/assets/dql-notebook/assets/{arrow-right-DvB_DONr.js → arrow-right-Ct_YGrmU.js} +1 -1
  39. package/dist/assets/dql-notebook/assets/{book-open-text-CJ3NAvrs.js → book-open-text-DULlwbj6.js} +1 -1
  40. package/dist/assets/dql-notebook/assets/{circle-x-BCgtha1W.js → circle-x-ByYxoiS9.js} +1 -1
  41. package/dist/assets/dql-notebook/assets/{dagre.esm-GKp7qoUL.js → dagre.esm-BjYSO53F.js} +1 -1
  42. package/dist/assets/dql-notebook/assets/{external-link-C-PXokWV.js → external-link-DprWh9Yf.js} +1 -1
  43. package/dist/assets/dql-notebook/assets/{grip-vertical-B4EHbGXW.js → grip-vertical-CrEEYkXN.js} +1 -1
  44. package/dist/assets/dql-notebook/assets/{index-1mIC_XX4.js → index-9w93YPF9.js} +127 -126
  45. package/dist/assets/dql-notebook/assets/index-B3shyZsg.css +1 -0
  46. package/dist/assets/dql-notebook/assets/{link-2-BLx-goet.js → link-2-BkW-rkEC.js} +1 -1
  47. package/dist/assets/dql-notebook/assets/{list-tree-BRFpEmvV.js → list-tree-BipBLmIE.js} +1 -1
  48. package/dist/assets/dql-notebook/assets/{minimize-2-CDwSCGlO.js → minimize-2-BhXsglrO.js} +1 -1
  49. package/dist/assets/dql-notebook/assets/{panel-right-open-CunA1xO7.js → panel-right-open-BoCSilYB.js} +1 -1
  50. package/dist/assets/dql-notebook/assets/{bot-CV8DYRrt.js → play-mdoZawPu.js} +7 -2
  51. package/dist/assets/dql-notebook/assets/{rotate-ccw-DOrfTZk8.js → rotate-ccw-ELiDRUmj.js} +1 -1
  52. package/dist/assets/dql-notebook/assets/{semantic-fields-AfQvjt5R.js → semantic-fields-DVNRLfeU.js} +1 -1
  53. package/dist/assets/dql-notebook/assets/sliders-horizontal-GeUzpmKz.js +6 -0
  54. package/dist/assets/dql-notebook/assets/{star-DDhv4e8M.js → star-D63O81Wp.js} +1 -1
  55. package/dist/assets/dql-notebook/assets/{triangle-alert-2ZXx8wAu.js → triangle-alert-BWrCxQVE.js} +1 -1
  56. package/dist/assets/dql-notebook/assets/upload-CI-ldXhC.js +6 -0
  57. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-Cv7Yq2hK.js +32 -0
  58. package/dist/assets/dql-notebook/assets/{user-round-BA074kiQ.js → user-round-Do21aFGo.js} +1 -1
  59. package/dist/assets/dql-notebook/assets/{wand-sparkles-CEYHLt9b.js → wand-sparkles-DT7u7F_x.js} +1 -1
  60. package/dist/assets/dql-notebook/assets/{workflow-CZtyrcR-.js → workflow-DHh2mMbn.js} +1 -1
  61. package/dist/assets/dql-notebook/assets/{wrench-Ong23-wu.js → wrench-7tYr_GKb.js} +1 -1
  62. package/dist/assets/dql-notebook/assets/{x-CSo1M3tu.js → x-CcYceFMz.js} +1 -1
  63. package/dist/assets/dql-notebook/index.html +2 -2
  64. package/dist/commands/app.d.ts.map +1 -1
  65. package/dist/commands/app.js +65 -133
  66. package/dist/commands/app.js.map +1 -1
  67. package/dist/commands/model.d.ts.map +1 -1
  68. package/dist/commands/model.js +83 -3
  69. package/dist/commands/model.js.map +1 -1
  70. package/dist/index.js +3 -0
  71. package/dist/index.js.map +1 -1
  72. package/dist/llm/providers/dql-agent-provider.d.ts +16 -0
  73. package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
  74. package/dist/llm/providers/dql-agent-provider.js +65 -2
  75. package/dist/llm/providers/dql-agent-provider.js.map +1 -1
  76. package/dist/local-runtime.d.ts +75 -0
  77. package/dist/local-runtime.d.ts.map +1 -1
  78. package/dist/local-runtime.js +2015 -88
  79. package/dist/local-runtime.js.map +1 -1
  80. package/dist/package.json +10 -10
  81. package/dist/sql-result-filter.d.ts +9 -0
  82. package/dist/sql-result-filter.d.ts.map +1 -1
  83. package/dist/sql-result-filter.js +25 -0
  84. package/dist/sql-result-filter.js.map +1 -1
  85. package/package.json +10 -10
  86. package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +0 -5
  87. package/dist/assets/dql-notebook/assets/AiBuildResult-CyqTuQe5.js +0 -33
  88. package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +0 -6
  89. package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +0 -4583
  90. package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +0 -60
  91. package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +0 -22
  92. package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +0 -1
  93. package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +0 -7
  94. package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +0 -83
  95. package/dist/assets/dql-notebook/assets/chevron-up-HxU1l85K.js +0 -6
  96. package/dist/assets/dql-notebook/assets/index-DKu4CZt3.css +0 -1
  97. package/dist/assets/dql-notebook/assets/maximize-2-CCd5uRIZ.js +0 -6
  98. package/dist/assets/dql-notebook/assets/pencil-D_I14Wyk.js +0 -6
  99. package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +0 -18
@@ -1 +1 @@
1
- import{h as F,i as H,k as _,r as n,a as R,j as e,S as q,a0 as P,aG as Q,L as N,l as V,d as U,e as K,B as J,f as X}from"./index-1mIC_XX4.js";import{T as Y}from"./TrustBadge-vQQh8d0D.js";import{o as O}from"./ai-build-bus-1BR770pY.js";import{W as G}from"./wand-sparkles-CEYHLt9b.js";import{U as Z,G as ee}from"./user-round-BA074kiQ.js";import{T as B}from"./triangle-alert-2ZXx8wAu.js";import{A as se}from"./arrow-right-DvB_DONr.js";import"./react-CRB3T2We.js";function Re(){const s=F(H(t=>({files:t.files}))),c=_(),[o,u]=n.useState(null),[w,x]=n.useState(!0),[p,f]=n.useState(new Set),[l,k]=n.useState(!1),[T,z]=n.useState(null),[W,C]=n.useState(null);n.useEffect(()=>{let t=!1;return R.getIdentity().then(r=>{!t&&(r!=null&&r.owner)&&C(r.owner)}).catch(()=>{}),()=>{t=!0}},[]);const I=n.useCallback(async(t,r)=>{const i={name:t.split("/").pop()??`${r}.dql`,path:t,type:"block",folder:"blocks"};s.files.some(a=>a.path===t)||c({type:"FILE_ADDED",file:i});const y=await R.openBlockStudio(t);c({type:"OPEN_BLOCK_STUDIO",file:i,payload:y})},[c,s.files]),b=n.useCallback(()=>{let t=!1;return x(!0),R.getProposeReadiness().then(r=>{if(t)return;u(r);const i=r.ready?r.plan.domains.flatMap(y=>y.candidates.map(a=>a.slug)):[];f(new Set(i))}).catch(()=>{t||u(null)}).finally(()=>{t||x(!1)}),()=>{t=!0}},[]);n.useEffect(()=>b(),[b]);const m=n.useCallback(()=>{c({type:"SET_MAIN_VIEW",view:"block_studio"})},[c]),D=n.useCallback(t=>{f(r=>{const i=new Set(r);return i.has(t)?i.delete(t):i.add(t),i})},[]),v=n.useCallback(t=>{f(r=>{const i=new Set(r),y=t.candidates.map(g=>g.slug),a=y.every(g=>i.has(g));for(const g of y)a?i.delete(g):i.add(g);return i})},[]),L=n.useCallback(async()=>{const t=[...p];if(t.length!==0){k(!0),z(null);try{const r=await R.generateProposeDrafts({slugs:t});if(!r.ready){z(r.reason??"Could not generate drafts.");return}const i=r.proposals.find(y=>y.path);i!=null&&i.path?I(i.path,i.slug):m()}catch(r){z(r instanceof Error?r.message:String(r))}finally{k(!1)}}},[p,m,I]),d=o==null?void 0:o.summary,h=o!=null&&o.ready?o.plan:null;return e.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto"},children:e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:"22px 28px 40px",display:"grid",gap:16},children:[e.jsxs("header",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(q,{size:20}),e.jsx("div",{style:{fontSize:22,fontWeight:750},children:"Get started"}),e.jsx("div",{style:{flex:1}}),e.jsxs("button",{type:"button",onClick:()=>O({target:"block",lockTarget:!0,sourceLabel:"Describe a block to draft from your project context."}),style:ye,children:[e.jsx(G,{size:14})," Ask AI to build a block"]})]}),e.jsx("div",{style:{fontSize:13,opacity:.72,maxWidth:760,lineHeight:1.55},children:d!=null&&d.modelsScanned?`I scanned your dbt project and found ${d.businessModels} ${d.businessModels===1?"thing":"things"} worth governing — here's what each one does. Expand a row to see the SQL it would run and what's still missing to certify. Plumbing and low-value models are left out. Nothing is drafted or certified until you approve it.`:"I scanned your dbt project for the business models worth governing — here's what each one does. Expand a row to see the SQL it would run and what's still missing to certify. Nothing is drafted or certified until you approve it."}),W?e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11.5,opacity:.62},children:[e.jsx(Z,{size:12})," drafting as ",W]}):null,e.jsxs("button",{type:"button",onClick:()=>c({type:"SET_MAIN_VIEW",view:"skills"}),style:{display:"inline-flex",alignItems:"center",gap:6,alignSelf:"start",marginTop:2,padding:0,border:"none",background:"transparent",color:"var(--color-accent-blue, #6b5dd3)",fontSize:12,fontWeight:650,cursor:"pointer"},children:[e.jsx(ee,{size:13})," Teach the AI your business rules →"]})]}),w?e.jsx("div",{style:E,children:"Classifying dbt models and planning the business seed…"}):o?o.ready?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:10},children:[e.jsx(S,{label:"dbt models scanned",value:d.modelsScanned}),e.jsx(S,{label:"Business models",value:d.businessModels,tone:"success"}),e.jsx(S,{label:"Plumbing excluded",value:d.plumbingExcluded}),e.jsx(S,{label:"Metrics found",value:d.metricsFound})]}),d.reviewTelemetry&&d.reviewTelemetry.existingDrafts>0?e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(S,{label:"Drafts ready for review",value:`${Math.round((d.reviewTelemetry.readyForReviewRate??0)*100)}%`,tone:"success"}),e.jsx(S,{label:"Median draft age",value:d.reviewTelemetry.medianReviewAgeHours!=null?`${d.reviewTelemetry.medianReviewAgeHours.toFixed(1)}h`:"—"}),e.jsx(S,{label:"Est. review time",value:`~${d.reviewTelemetry.estimatedReviewMinutes} min`})]}):null,e.jsxs("div",{style:he,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(Q,{size:16}),e.jsxs("div",{style:{fontSize:13},children:[e.jsxs("strong",{children:["Will generate ",p.size]}),e.jsxs("span",{style:{opacity:.65},children:[" ","of ",h.willGenerate," planned · skipping ",h.willSkip," · ≤ ",h.config.maxPerDomain," per domain"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("button",{type:"button",onClick:b,style:$,children:[e.jsx(P,{size:13})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>void L(),disabled:l||p.size===0,style:{...me,opacity:l||p.size===0?.6:1},children:[l?e.jsx(N,{size:13,className:"spin"}):e.jsx(V,{size:13}),l?"Generating…":e.jsxs(e.Fragment,{children:["Approve & generate ",p.size>0?`(${p.size})`:""]})]})]})]}),T?e.jsxs("div",{style:{...E,display:"flex",gap:8,alignItems:"center",borderColor:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:16})," ",T]}):null,e.jsx("div",{style:{display:"grid",gap:12},children:h.domains.length===0?e.jsxs("div",{style:E,children:["No business models found to govern. Tag a layer in ",e.jsx("code",{children:"dql.config.json"})," ","(",e.jsx("code",{children:"propose.businessLayers"}),") or add ",e.jsx("code",{children:"meta.dql.business"})," to your dbt models."]}):h.domains.map(t=>e.jsx(te,{domain:t,selected:p,onToggleSlug:D,onToggleDomain:v,onOpenInBlockStudio:I},t.name))}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsxs("button",{type:"button",onClick:m,style:be,children:["Open Block Studio ",e.jsx(se,{size:13})]})})]}):e.jsxs("div",{style:{...E,display:"flex",alignItems:"flex-start",gap:10},children:[e.jsx(B,{size:18,style:{flexShrink:0,marginTop:1}}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("div",{style:{fontWeight:650},children:"Not ready to propose yet"}),e.jsx("div",{style:{opacity:.8},children:o.reason}),e.jsxs("button",{type:"button",onClick:b,style:$,children:[e.jsx(P,{size:13})," Re-check"]})]})]}):e.jsx("div",{style:E,children:"Could not load readiness."})]})})}function te({domain:s,selected:c,onToggleSlug:o,onToggleDomain:u,onOpenInBlockStudio:w}){const x=s.candidates.map(l=>l.slug),p=x.every(l=>c.has(l)),f=x.some(l=>c.has(l));return e.jsxs("div",{style:oe,children:[e.jsxs("div",{style:ae,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p,ref:l=>{l&&(l.indeterminate=!p&&f)},onChange:()=>u(s)}),e.jsx("span",{style:{fontSize:13,fontWeight:700},children:s.name}),e.jsxs("span",{style:{fontSize:11,opacity:.6},children:[s.modelCount," model",s.modelCount===1?"":"s"]})]}),s.owner?e.jsxs("span",{style:{fontSize:11,opacity:.6},children:["owner ",s.owner]}):null]}),e.jsx("div",{style:{display:"grid",gap:6},children:s.candidates.map(l=>e.jsx(re,{candidate:l,checked:c.has(l.slug),onToggle:()=>o(l.slug),onOpenInBlockStudio:w},l.slug))})]})}function re({candidate:s,checked:c,onToggle:o,onOpenInBlockStudio:u}){const w=n.useMemo(()=>s.evidence.slice(0,3),[s.evidence]),[x,p]=n.useState(!1),[f,l]=n.useState(null),[k,T]=n.useState(!1),[z,W]=n.useState(null),[C,I]=n.useState(!1),[b,m]=n.useState(null),D=n.useCallback(()=>{p(a=>{const g=!a;return g&&!f&&!k&&(T(!0),W(null),R.proposePreview(s.slug).then(j=>l(j.candidate)).catch(j=>W(j instanceof Error?j.message:"Could not load the preview.")).finally(()=>T(!1))),g})},[s.slug,f,k]),v=f??s,L=v.sqlPreview,d=v.outputs??[],h=v.examples??[],t=v.certifierVerdict,r=v.description,i=n.useCallback(async()=>{I(!0),m(null);try{const a=await R.generateProposeDrafts({slugs:[s.slug]}),g=a.proposals.find(M=>M.slug===s.slug)??a.proposals[0],j=g==null?void 0:g.path;if(!j){m("No draft path was returned for this model yet.");return}await u(j,s.model)}catch(a){m(a instanceof Error?a.message:"Could not open this draft.")}finally{I(!1)}},[s.model,s.slug,u]),y=n.useCallback(()=>{O({target:"block",lockTarget:!0,prompt:`Refine the "${s.model}" block: ${r??`a ${s.pattern??"business"} model${s.grain?` at ${s.grain} grain`:""}`}.`,sourceLabel:`Refining ${s.model}`})},[s.grain,s.model,s.pattern,r]);return e.jsxs("div",{style:{...de,opacity:c?1:.7},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",gap:10,alignItems:"start"},children:[e.jsx("input",{type:"checkbox",checked:c,onChange:o,style:{marginTop:3},"aria-label":`Include ${s.model}`}),e.jsxs("div",{style:{display:"grid",gap:4,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700},children:s.model}),e.jsx(Y,{state:"ai_generated"}),s.pattern?e.jsx(le,{children:s.pattern}):null,s.grain?e.jsxs("span",{style:{fontSize:11,opacity:.6},children:["grain ",s.grain]}):null]}),w.length>0?e.jsxs("div",{style:{fontSize:11,opacity:.66},children:[e.jsx("span",{style:{opacity:.8},children:"why: "}),w.join(" · ")]}):null]}),e.jsxs("button",{type:"button",onClick:D,"aria-expanded":x,style:pe,children:[x?e.jsx(U,{size:13}):e.jsx(K,{size:13}),x?"Hide":"Details"]})]}),x?e.jsx("div",{style:ce,children:k?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,opacity:.75},children:[e.jsx(N,{size:13,className:"spin"})," Loading the generated SQL and verdict…"]}):z?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:14})," ",z]}):e.jsxs(e.Fragment,{children:[r?e.jsx("div",{style:{fontSize:12,opacity:.82,lineHeight:1.5},children:r}):null,e.jsxs("div",{style:{display:"grid",gap:5},children:[e.jsx(A,{children:"SQL this block will run"}),L?e.jsx("pre",{style:ge,children:e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:L.trim()})}):e.jsx("div",{style:{fontSize:11.5,opacity:.6},children:"The generated SQL is not available for this model yet."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:12},children:[e.jsxs("div",{style:{display:"grid",gap:5,alignContent:"start"},children:[e.jsx(A,{children:"Outputs"}),d.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:d.map(a=>e.jsx(ie,{children:a},a))}):e.jsx("div",{style:{fontSize:11,opacity:.6},children:"No declared outputs yet."})]}),e.jsxs("div",{style:{display:"grid",gap:5,alignContent:"start"},children:[e.jsx(A,{children:"Answers questions like"}),h.length>0?e.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:h.slice(0,3).map(a=>e.jsx("li",{style:{fontSize:11.5,opacity:.82,lineHeight:1.45},children:a},a))}):e.jsx("div",{style:{fontSize:11,opacity:.6},children:"No example questions yet."})]})]}),e.jsx(ne,{verdict:t}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",onClick:()=>void i(),disabled:C,style:{...ue,opacity:C?.65:1},children:[C?e.jsx(N,{size:13,className:"spin"}):e.jsx(J,{size:13}),C?"Opening…":"Open in Block Studio"]}),e.jsxs("button",{type:"button",onClick:y,style:xe,children:[e.jsx(G,{size:13})," Refine with AI"]})]}),b?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11.5,color:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:13})," ",b]}):null]})}):null]})}function ne({verdict:s}){const c=!!(s!=null&&s.ready&&s.blocking.length===0),o=s?[...s.blocking,...s.warnings]:[];return e.jsxs("div",{style:{display:"grid",gap:5},children:[e.jsx(A,{children:"What's missing to certify"}),c?e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:"var(--status-success, #1f883d)"},children:[e.jsx(X,{size:14})," Grain, outputs, and context are set."]}):e.jsxs("div",{style:{display:"grid",gap:4},children:[e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:"var(--status-warning, #9a6700)"},children:[e.jsx(B,{size:14})," Needs an owner and passing tests before it can be certified."]}),o.length>0?e.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:o.map(u=>e.jsx("li",{style:{fontSize:11,opacity:.78,lineHeight:1.4},children:u},u))}):s?null:e.jsx("div",{style:{fontSize:11,opacity:.6},children:"Expand to load the Certifier verdict."})]})]})}function A({children:s}){return e.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",opacity:.55},children:s})}function ie({children:s}){return e.jsx("span",{style:{fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"var(--surface-hover, rgba(0,0,0,0.04))",fontFamily:"var(--font-mono, monospace)"},children:s})}function S({label:s,value:c,tone:o}){return e.jsxs("div",{style:{...fe,borderTop:`2px solid ${o==="success"?"var(--status-success, #1f883d)":"var(--border-color, rgba(0,0,0,0.10))"}`},children:[e.jsx("div",{style:{fontSize:11,opacity:.62},children:s}),e.jsx("div",{style:{fontSize:24,fontWeight:800},children:c})]})}function le({children:s}){return e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,background:"var(--surface-hover, rgba(0,0,0,0.06))",opacity:.82},children:s})}const oe={border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:8,background:"var(--surface, rgba(0,0,0,0.02))",padding:12,display:"grid",gap:8},ae={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,paddingBottom:6,borderBottom:"1px solid var(--border-color, rgba(0,0,0,0.08))"},de={width:"100%",border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderLeft:"3px solid var(--status-warning, #9a6700)",borderRadius:7,background:"var(--surface, rgba(0,0,0,0.02))",padding:10,display:"grid",gap:10},ce={borderTop:"1px solid var(--border-color, rgba(0,0,0,0.08))",paddingTop:10,marginLeft:26,display:"grid",gap:12},pe={display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:11,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",alignSelf:"start"},ge={margin:0,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",borderRadius:8,background:"var(--color-bg-primary, rgba(0,0,0,0.03))",padding:"9px 11px",overflow:"auto",maxHeight:280},ue={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:6,border:"1px solid var(--color-accent-blue, #6b5dd3)",background:"var(--color-accent-blue, #6b5dd3)",color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"},xe={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},ye={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:"1px solid var(--color-clay, #b4593f)",background:"var(--color-clay, #b4593f)",color:"#fff",fontSize:12.5,fontWeight:700,cursor:"pointer",whiteSpace:"nowrap"},fe={border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:7,background:"var(--surface, rgba(0,0,0,0.02))",padding:12},he={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:8,background:"var(--surface, rgba(0,0,0,0.02))",padding:"10px 12px"},be={display:"inline-flex",alignItems:"center",gap:5,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"var(--surface, transparent)",color:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},me={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:6,border:"1px solid var(--status-success, #1f883d)",background:"var(--status-success, #1f883d)",color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"},$={display:"inline-flex",alignItems:"center",gap:5,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:12,cursor:"pointer"},E={border:"1px dashed var(--border-color, rgba(0,0,0,0.16))",borderRadius:8,padding:24,fontSize:13,opacity:.85};export{Re as ReadinessPage};
1
+ import{h as F,i as H,k as _,r as n,a as R,j as e,S as q,a0 as P,aG as Q,L as N,l as V,d as U,e as K,B as J,f as X}from"./index-9w93YPF9.js";import{T as Y}from"./TrustBadge-ClEYiYeA.js";import{o as O}from"./ai-build-bus-1BR770pY.js";import{W as G}from"./wand-sparkles-DT7u7F_x.js";import{U as Z,G as ee}from"./user-round-Do21aFGo.js";import{T as B}from"./triangle-alert-BWrCxQVE.js";import{A as se}from"./arrow-right-Ct_YGrmU.js";import"./react-CRB3T2We.js";function Re(){const s=F(H(t=>({files:t.files}))),c=_(),[o,u]=n.useState(null),[w,x]=n.useState(!0),[p,f]=n.useState(new Set),[l,k]=n.useState(!1),[T,z]=n.useState(null),[W,C]=n.useState(null);n.useEffect(()=>{let t=!1;return R.getIdentity().then(r=>{!t&&(r!=null&&r.owner)&&C(r.owner)}).catch(()=>{}),()=>{t=!0}},[]);const I=n.useCallback(async(t,r)=>{const i={name:t.split("/").pop()??`${r}.dql`,path:t,type:"block",folder:"blocks"};s.files.some(a=>a.path===t)||c({type:"FILE_ADDED",file:i});const y=await R.openBlockStudio(t);c({type:"OPEN_BLOCK_STUDIO",file:i,payload:y})},[c,s.files]),b=n.useCallback(()=>{let t=!1;return x(!0),R.getProposeReadiness().then(r=>{if(t)return;u(r);const i=r.ready?r.plan.domains.flatMap(y=>y.candidates.map(a=>a.slug)):[];f(new Set(i))}).catch(()=>{t||u(null)}).finally(()=>{t||x(!1)}),()=>{t=!0}},[]);n.useEffect(()=>b(),[b]);const m=n.useCallback(()=>{c({type:"SET_MAIN_VIEW",view:"block_studio"})},[c]),D=n.useCallback(t=>{f(r=>{const i=new Set(r);return i.has(t)?i.delete(t):i.add(t),i})},[]),v=n.useCallback(t=>{f(r=>{const i=new Set(r),y=t.candidates.map(g=>g.slug),a=y.every(g=>i.has(g));for(const g of y)a?i.delete(g):i.add(g);return i})},[]),L=n.useCallback(async()=>{const t=[...p];if(t.length!==0){k(!0),z(null);try{const r=await R.generateProposeDrafts({slugs:t});if(!r.ready){z(r.reason??"Could not generate drafts.");return}const i=r.proposals.find(y=>y.path);i!=null&&i.path?I(i.path,i.slug):m()}catch(r){z(r instanceof Error?r.message:String(r))}finally{k(!1)}}},[p,m,I]),d=o==null?void 0:o.summary,h=o!=null&&o.ready?o.plan:null;return e.jsx("div",{style:{flex:1,minWidth:0,overflow:"auto"},children:e.jsxs("div",{style:{maxWidth:980,margin:"0 auto",padding:"22px 28px 40px",display:"grid",gap:16},children:[e.jsxs("header",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(q,{size:20}),e.jsx("div",{style:{fontSize:22,fontWeight:750},children:"Get started"}),e.jsx("div",{style:{flex:1}}),e.jsxs("button",{type:"button",onClick:()=>O({target:"block",lockTarget:!0,sourceLabel:"Describe a block to draft from your project context."}),style:ye,children:[e.jsx(G,{size:14})," Ask AI to build a block"]})]}),e.jsx("div",{style:{fontSize:13,opacity:.72,maxWidth:760,lineHeight:1.55},children:d!=null&&d.modelsScanned?`I scanned your dbt project and found ${d.businessModels} ${d.businessModels===1?"thing":"things"} worth governing — here's what each one does. Expand a row to see the SQL it would run and what's still missing to certify. Plumbing and low-value models are left out. Nothing is drafted or certified until you approve it.`:"I scanned your dbt project for the business models worth governing — here's what each one does. Expand a row to see the SQL it would run and what's still missing to certify. Nothing is drafted or certified until you approve it."}),W?e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11.5,opacity:.62},children:[e.jsx(Z,{size:12})," drafting as ",W]}):null,e.jsxs("button",{type:"button",onClick:()=>c({type:"SET_MAIN_VIEW",view:"skills"}),style:{display:"inline-flex",alignItems:"center",gap:6,alignSelf:"start",marginTop:2,padding:0,border:"none",background:"transparent",color:"var(--color-accent-blue, #6b5dd3)",fontSize:12,fontWeight:650,cursor:"pointer"},children:[e.jsx(ee,{size:13})," Teach the AI your business rules →"]})]}),w?e.jsx("div",{style:E,children:"Classifying dbt models and planning the business seed…"}):o?o.ready?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:10},children:[e.jsx(S,{label:"dbt models scanned",value:d.modelsScanned}),e.jsx(S,{label:"Business models",value:d.businessModels,tone:"success"}),e.jsx(S,{label:"Plumbing excluded",value:d.plumbingExcluded}),e.jsx(S,{label:"Metrics found",value:d.metricsFound})]}),d.reviewTelemetry&&d.reviewTelemetry.existingDrafts>0?e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:10},children:[e.jsx(S,{label:"Drafts ready for review",value:`${Math.round((d.reviewTelemetry.readyForReviewRate??0)*100)}%`,tone:"success"}),e.jsx(S,{label:"Median draft age",value:d.reviewTelemetry.medianReviewAgeHours!=null?`${d.reviewTelemetry.medianReviewAgeHours.toFixed(1)}h`:"—"}),e.jsx(S,{label:"Est. review time",value:`~${d.reviewTelemetry.estimatedReviewMinutes} min`})]}):null,e.jsxs("div",{style:he,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(Q,{size:16}),e.jsxs("div",{style:{fontSize:13},children:[e.jsxs("strong",{children:["Will generate ",p.size]}),e.jsxs("span",{style:{opacity:.65},children:[" ","of ",h.willGenerate," planned · skipping ",h.willSkip," · ≤ ",h.config.maxPerDomain," per domain"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[e.jsxs("button",{type:"button",onClick:b,style:$,children:[e.jsx(P,{size:13})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>void L(),disabled:l||p.size===0,style:{...me,opacity:l||p.size===0?.6:1},children:[l?e.jsx(N,{size:13,className:"spin"}):e.jsx(V,{size:13}),l?"Generating…":e.jsxs(e.Fragment,{children:["Approve & generate ",p.size>0?`(${p.size})`:""]})]})]})]}),T?e.jsxs("div",{style:{...E,display:"flex",gap:8,alignItems:"center",borderColor:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:16})," ",T]}):null,e.jsx("div",{style:{display:"grid",gap:12},children:h.domains.length===0?e.jsxs("div",{style:E,children:["No business models found to govern. Tag a layer in ",e.jsx("code",{children:"dql.config.json"})," ","(",e.jsx("code",{children:"propose.businessLayers"}),") or add ",e.jsx("code",{children:"meta.dql.business"})," to your dbt models."]}):h.domains.map(t=>e.jsx(te,{domain:t,selected:p,onToggleSlug:D,onToggleDomain:v,onOpenInBlockStudio:I},t.name))}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsxs("button",{type:"button",onClick:m,style:be,children:["Open Block Studio ",e.jsx(se,{size:13})]})})]}):e.jsxs("div",{style:{...E,display:"flex",alignItems:"flex-start",gap:10},children:[e.jsx(B,{size:18,style:{flexShrink:0,marginTop:1}}),e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("div",{style:{fontWeight:650},children:"Not ready to propose yet"}),e.jsx("div",{style:{opacity:.8},children:o.reason}),e.jsxs("button",{type:"button",onClick:b,style:$,children:[e.jsx(P,{size:13})," Re-check"]})]})]}):e.jsx("div",{style:E,children:"Could not load readiness."})]})})}function te({domain:s,selected:c,onToggleSlug:o,onToggleDomain:u,onOpenInBlockStudio:w}){const x=s.candidates.map(l=>l.slug),p=x.every(l=>c.has(l)),f=x.some(l=>c.has(l));return e.jsxs("div",{style:oe,children:[e.jsxs("div",{style:ae,children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p,ref:l=>{l&&(l.indeterminate=!p&&f)},onChange:()=>u(s)}),e.jsx("span",{style:{fontSize:13,fontWeight:700},children:s.name}),e.jsxs("span",{style:{fontSize:11,opacity:.6},children:[s.modelCount," model",s.modelCount===1?"":"s"]})]}),s.owner?e.jsxs("span",{style:{fontSize:11,opacity:.6},children:["owner ",s.owner]}):null]}),e.jsx("div",{style:{display:"grid",gap:6},children:s.candidates.map(l=>e.jsx(re,{candidate:l,checked:c.has(l.slug),onToggle:()=>o(l.slug),onOpenInBlockStudio:w},l.slug))})]})}function re({candidate:s,checked:c,onToggle:o,onOpenInBlockStudio:u}){const w=n.useMemo(()=>s.evidence.slice(0,3),[s.evidence]),[x,p]=n.useState(!1),[f,l]=n.useState(null),[k,T]=n.useState(!1),[z,W]=n.useState(null),[C,I]=n.useState(!1),[b,m]=n.useState(null),D=n.useCallback(()=>{p(a=>{const g=!a;return g&&!f&&!k&&(T(!0),W(null),R.proposePreview(s.slug).then(j=>l(j.candidate)).catch(j=>W(j instanceof Error?j.message:"Could not load the preview.")).finally(()=>T(!1))),g})},[s.slug,f,k]),v=f??s,L=v.sqlPreview,d=v.outputs??[],h=v.examples??[],t=v.certifierVerdict,r=v.description,i=n.useCallback(async()=>{I(!0),m(null);try{const a=await R.generateProposeDrafts({slugs:[s.slug]}),g=a.proposals.find(M=>M.slug===s.slug)??a.proposals[0],j=g==null?void 0:g.path;if(!j){m("No draft path was returned for this model yet.");return}await u(j,s.model)}catch(a){m(a instanceof Error?a.message:"Could not open this draft.")}finally{I(!1)}},[s.model,s.slug,u]),y=n.useCallback(()=>{O({target:"block",lockTarget:!0,prompt:`Refine the "${s.model}" block: ${r??`a ${s.pattern??"business"} model${s.grain?` at ${s.grain} grain`:""}`}.`,sourceLabel:`Refining ${s.model}`})},[s.grain,s.model,s.pattern,r]);return e.jsxs("div",{style:{...de,opacity:c?1:.7},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",gap:10,alignItems:"start"},children:[e.jsx("input",{type:"checkbox",checked:c,onChange:o,style:{marginTop:3},"aria-label":`Include ${s.model}`}),e.jsxs("div",{style:{display:"grid",gap:4,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700},children:s.model}),e.jsx(Y,{state:"ai_generated"}),s.pattern?e.jsx(le,{children:s.pattern}):null,s.grain?e.jsxs("span",{style:{fontSize:11,opacity:.6},children:["grain ",s.grain]}):null]}),w.length>0?e.jsxs("div",{style:{fontSize:11,opacity:.66},children:[e.jsx("span",{style:{opacity:.8},children:"why: "}),w.join(" · ")]}):null]}),e.jsxs("button",{type:"button",onClick:D,"aria-expanded":x,style:pe,children:[x?e.jsx(U,{size:13}):e.jsx(K,{size:13}),x?"Hide":"Details"]})]}),x?e.jsx("div",{style:ce,children:k?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,opacity:.75},children:[e.jsx(N,{size:13,className:"spin"})," Loading the generated SQL and verdict…"]}):z?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:14})," ",z]}):e.jsxs(e.Fragment,{children:[r?e.jsx("div",{style:{fontSize:12,opacity:.82,lineHeight:1.5},children:r}):null,e.jsxs("div",{style:{display:"grid",gap:5},children:[e.jsx(A,{children:"SQL this block will run"}),L?e.jsx("pre",{style:ge,children:e.jsx("code",{style:{fontFamily:"var(--font-mono, monospace)",fontSize:11.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:L.trim()})}):e.jsx("div",{style:{fontSize:11.5,opacity:.6},children:"The generated SQL is not available for this model yet."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:12},children:[e.jsxs("div",{style:{display:"grid",gap:5,alignContent:"start"},children:[e.jsx(A,{children:"Outputs"}),d.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:d.map(a=>e.jsx(ie,{children:a},a))}):e.jsx("div",{style:{fontSize:11,opacity:.6},children:"No declared outputs yet."})]}),e.jsxs("div",{style:{display:"grid",gap:5,alignContent:"start"},children:[e.jsx(A,{children:"Answers questions like"}),h.length>0?e.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:h.slice(0,3).map(a=>e.jsx("li",{style:{fontSize:11.5,opacity:.82,lineHeight:1.45},children:a},a))}):e.jsx("div",{style:{fontSize:11,opacity:.6},children:"No example questions yet."})]})]}),e.jsx(ne,{verdict:t}),e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",onClick:()=>void i(),disabled:C,style:{...ue,opacity:C?.65:1},children:[C?e.jsx(N,{size:13,className:"spin"}):e.jsx(J,{size:13}),C?"Opening…":"Open in Block Studio"]}),e.jsxs("button",{type:"button",onClick:y,style:xe,children:[e.jsx(G,{size:13})," Refine with AI"]})]}),b?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11.5,color:"var(--status-error, #cf222e)"},children:[e.jsx(B,{size:13})," ",b]}):null]})}):null]})}function ne({verdict:s}){const c=!!(s!=null&&s.ready&&s.blocking.length===0),o=s?[...s.blocking,...s.warnings]:[];return e.jsxs("div",{style:{display:"grid",gap:5},children:[e.jsx(A,{children:"What's missing to certify"}),c?e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:"var(--status-success, #1f883d)"},children:[e.jsx(X,{size:14})," Grain, outputs, and context are set."]}):e.jsxs("div",{style:{display:"grid",gap:4},children:[e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,fontSize:12,color:"var(--status-warning, #9a6700)"},children:[e.jsx(B,{size:14})," Needs an owner and passing tests before it can be certified."]}),o.length>0?e.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:2},children:o.map(u=>e.jsx("li",{style:{fontSize:11,opacity:.78,lineHeight:1.4},children:u},u))}):s?null:e.jsx("div",{style:{fontSize:11,opacity:.6},children:"Expand to load the Certifier verdict."})]})]})}function A({children:s}){return e.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",opacity:.55},children:s})}function ie({children:s}){return e.jsx("span",{style:{fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"var(--surface-hover, rgba(0,0,0,0.04))",fontFamily:"var(--font-mono, monospace)"},children:s})}function S({label:s,value:c,tone:o}){return e.jsxs("div",{style:{...fe,borderTop:`2px solid ${o==="success"?"var(--status-success, #1f883d)":"var(--border-color, rgba(0,0,0,0.10))"}`},children:[e.jsx("div",{style:{fontSize:11,opacity:.62},children:s}),e.jsx("div",{style:{fontSize:24,fontWeight:800},children:c})]})}function le({children:s}){return e.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:4,background:"var(--surface-hover, rgba(0,0,0,0.06))",opacity:.82},children:s})}const oe={border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:8,background:"var(--surface, rgba(0,0,0,0.02))",padding:12,display:"grid",gap:8},ae={display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,paddingBottom:6,borderBottom:"1px solid var(--border-color, rgba(0,0,0,0.08))"},de={width:"100%",border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderLeft:"3px solid var(--status-warning, #9a6700)",borderRadius:7,background:"var(--surface, rgba(0,0,0,0.02))",padding:10,display:"grid",gap:10},ce={borderTop:"1px solid var(--border-color, rgba(0,0,0,0.08))",paddingTop:10,marginLeft:26,display:"grid",gap:12},pe={display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:11,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap",alignSelf:"start"},ge={margin:0,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",borderRadius:8,background:"var(--color-bg-primary, rgba(0,0,0,0.03))",padding:"9px 11px",overflow:"auto",maxHeight:280},ue={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:6,border:"1px solid var(--color-accent-blue, #6b5dd3)",background:"var(--color-accent-blue, #6b5dd3)",color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"},xe={display:"inline-flex",alignItems:"center",gap:6,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},ye={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:7,border:"1px solid var(--color-clay, #b4593f)",background:"var(--color-clay, #b4593f)",color:"#fff",fontSize:12.5,fontWeight:700,cursor:"pointer",whiteSpace:"nowrap"},fe={border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:7,background:"var(--surface, rgba(0,0,0,0.02))",padding:12},he={display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,border:"1px solid var(--border-color, rgba(0,0,0,0.10))",borderRadius:8,background:"var(--surface, rgba(0,0,0,0.02))",padding:"10px 12px"},be={display:"inline-flex",alignItems:"center",gap:5,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"var(--surface, transparent)",color:"inherit",fontSize:12,fontWeight:600,cursor:"pointer",whiteSpace:"nowrap"},me={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:6,border:"1px solid var(--status-success, #1f883d)",background:"var(--status-success, #1f883d)",color:"#fff",fontSize:12,fontWeight:650,cursor:"pointer",whiteSpace:"nowrap"},$={display:"inline-flex",alignItems:"center",gap:5,padding:"6px 11px",borderRadius:6,border:"1px solid var(--border-color, rgba(0,0,0,0.12))",background:"transparent",color:"inherit",fontSize:12,cursor:"pointer"},E={border:"1px dashed var(--border-color, rgba(0,0,0,0.16))",borderRadius:8,padding:24,fontSize:13,opacity:.85};export{Re as ReadinessPage};
@@ -1,4 +1,4 @@
1
- import{c as ne,u as ae,t as de,r as a,a as S,j as t,a1 as le,a2 as pe,a3 as ce,a4 as fe,F as ue,S as ge}from"./index-1mIC_XX4.js";import{A as xe}from"./arrow-left-CMe1kkOL.js";import{A as ye}from"./arrow-right-DvB_DONr.js";import"./react-CRB3T2We.js";/**
1
+ import{c as ne,u as ae,t as de,r as a,a as S,j as t,a1 as le,a2 as pe,a3 as ce,a4 as fe,F as ue,S as ge}from"./index-9w93YPF9.js";import{A as xe}from"./arrow-left-DnYPGqlr.js";import{A as ye}from"./arrow-right-Ct_YGrmU.js";import"./react-CRB3T2We.js";/**
2
2
  * @license lucide-react v0.563.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,10 @@
1
+ import{c as Pe,r as x,j as e,l as he,f as Te,a0 as le,L as Q,a as $,u as je,t as ke,$ as ge,S as Se,P as Y,T as se,a5 as De,Q as U}from"./index-9w93YPF9.js";import{U as Ae}from"./UnifiedAgentRunPanel-DBfsmXes.js";import{X as ae}from"./x-CcYceFMz.js";import{T as we}from"./triangle-alert-BWrCxQVE.js";import{G as Z}from"./user-round-Do21aFGo.js";import{u as Ee,P as _e}from"./usePersistedAgentThreadId-Cv7Yq2hK.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 He=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],qe=Pe("file-diff",He);function Ne(t,n,l){var c,i;if(n&&t.domain!==n&&!((c=t.domains)!=null&&c.includes(n)))return!1;const r=(i=l==null?void 0:l.split("::").at(-1))==null?void 0:i.toLowerCase();if(!r)return!0;const a=(t.modelAreaRefs??[]).map(p=>{var f;return(f=p.split("::").at(-1))==null?void 0:f.toLowerCase()});return a.length===0||a.includes(r)}function ye(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,"")}function Le(t,n){if(!n)return!0;const l=ye(t.sourcePath);return n.some(r=>{const a=ye(r);return l===a||l.endsWith(`/${a}`)})}function Oe({proposal:t,theme:n,onClose:l,onCommitted:r}){const[a,c]=x.useState(t),[i,p]=x.useState(()=>t.operations.map(o=>o.id)),[f,y]=x.useState(null),[m,s]=x.useState(null),[w,h]=x.useState(!1),C=a.diagnostics.filter(o=>o.severity==="blocking"),v=x.useMemo(()=>new Map(a.operations.map(o=>[o.id,a.patches.filter(j=>j.operationId===o.id)])),[a]),P=x.useRef(null),z=x.useRef(null);x.useEffect(()=>()=>{z.current&&window.clearTimeout(z.current)},[]);const _=(o,j)=>{const k=P.current??i,T=j?[...k,o]:k.filter(I=>I!==o);P.current=T,p(T),s(null),h(!1),z.current&&window.clearTimeout(z.current),z.current=window.setTimeout(()=>{const I=P.current??T;P.current=null,y("preview"),$.repreviewContextProposal(a.id,I).then(R=>{c(R),p(R.operations.map(d=>d.id))}).catch(R=>{p(a.operations.map(d=>d.id)),s(R instanceof Error?R.message:String(R))}).finally(()=>y(null))},350)},W=async()=>{y("commit"),s(null),h(!1);try{const o=await $.commitContextProposal(a.id,a.proposalHash,crypto.randomUUID());c(o.proposal),r(o.proposal)}catch(o){s(o instanceof Error?o.message:String(o)),h(!0)}finally{y(null)}},H=async()=>{y("rebase"),s(null);try{const o=await $.repreviewContextProposal(a.id,i,{rebase:!0});c(o),p(o.operations.map(j=>j.id)),h(!1)}catch(o){s(o instanceof Error?o.message:String(o))}finally{y(null)}};return e.jsx("div",{role:"presentation",onClick:()=>!f&&l(),style:{position:"fixed",inset:0,zIndex:130,background:"rgba(8, 10, 16, .48)",display:"flex",justifyContent:"flex-end"},children:e.jsxs("aside",{role:"dialog","aria-modal":"true","aria-label":"Review context proposal",onClick:o=>o.stopPropagation(),style:{width:"min(720px, 96vw)",height:"100%",background:n.appBg,borderLeft:"1px solid var(--border-default)",boxShadow:"-18px 0 50px rgba(0,0,0,.24)",display:"flex",flexDirection:"column"},children:[e.jsxs("header",{style:{minHeight:58,padding:"0 18px",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{width:30,height:30,borderRadius:8,background:"var(--accent-dim)",color:n.accent,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(qe,{size:16})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("strong",{style:{fontSize:14},children:"Review exact proposal"}),e.jsxs("div",{style:{marginTop:2,fontSize:10.5,color:n.textMuted},children:[a.origin.replace(/_/g," ")," · immutable revision · ",a.trustState.replace(/_/g," ")]})]}),e.jsx("button",{type:"button","aria-label":"Close proposal",disabled:!!f,onClick:l,style:Ge(n),children:e.jsx(ae,{size:15})})]}),e.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:18},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gap:8,marginBottom:14},children:[e.jsx(ie,{label:"Files",value:a.impact.files,theme:n}),e.jsx(ie,{label:"Modeling",value:a.impact.modelingChanges,theme:n}),e.jsx(ie,{label:"Skills",value:a.impact.skillChanges,theme:n})]}),e.jsxs("div",{style:{padding:"10px 12px",border:"1px solid var(--border-subtle)",borderRadius:9,background:"var(--bg-1)",color:n.textSecondary,fontSize:11,lineHeight:1.5,marginBottom:14},children:[e.jsx(he,{size:14,style:{verticalAlign:-3,marginRight:7,color:n.accent}}),"Nothing below has changed source. Saving compiles the complete candidate and writes every selected patch together or writes nothing."]}),a.diagnostics.map((o,j)=>e.jsxs("div",{style:{display:"flex",gap:8,padding:"8px 10px",marginBottom:6,borderRadius:7,background:o.severity==="blocking"?"var(--status-error-bg, rgba(180,50,50,.1))":"var(--bg-1)",color:o.severity==="blocking"?"var(--status-error, #c45555)":n.textSecondary,fontSize:10.5},children:[o.severity==="blocking"?e.jsx(we,{size:13}):e.jsx(Te,{size:13}),e.jsxs("span",{children:[e.jsx("b",{children:o.code})," · ",o.message]})]},`${o.code}-${j}`)),e.jsx("div",{style:{display:"grid",gap:10,marginTop:14},children:a.operations.map(o=>{const j=v.get(o.id)??[];return e.jsxs("section",{style:{border:"1px solid var(--border-subtle)",borderRadius:9,overflow:"hidden",background:n.cellBg},children:[e.jsxs("label",{style:{display:"flex",gap:9,alignItems:"flex-start",padding:"11px 12px",cursor:f?"wait":"pointer"},children:[e.jsx("input",{type:"checkbox",checked:i.includes(o.id),disabled:!!f,onChange:k=>_(o.id,k.target.checked)}),e.jsxs("span",{style:{flex:1,minWidth:0},children:[e.jsx("b",{style:{display:"block",fontSize:11.5},children:Fe(o)}),e.jsx("code",{style:{display:"block",marginTop:3,color:n.textMuted,fontSize:9.5,overflowWrap:"anywhere"},children:o.id})]}),e.jsxs("span",{style:{fontSize:10,color:n.textMuted},children:[j.length," patch",j.length===1?"":"es"]})]}),j.map(k=>e.jsxs("details",{style:{borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("summary",{style:{padding:"8px 12px",cursor:"pointer",color:n.textSecondary,fontSize:10.5},children:e.jsx("code",{children:k.path})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,background:"var(--border-subtle)"},children:[e.jsx(me,{title:"Before",value:k.before,theme:n}),e.jsx(me,{title:"After",value:k.after,theme:n})]})]},`${k.operationId}-${k.path}`))]},o.id)})}),m?e.jsx("div",{role:"alert",style:{color:"var(--status-error, #c45555)",fontSize:11,marginTop:12},children:m}):null]}),e.jsxs("footer",{style:{padding:"12px 18px",borderTop:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:9},children:[e.jsxs("span",{style:{flex:1,fontSize:10.5,color:n.textMuted},children:["Proposal ",e.jsx("code",{children:a.proposalHash.slice(0,12)})]}),w?e.jsxs("button",{type:"button",onClick:()=>void H(),disabled:!!f,style:oe(n),children:[e.jsx(le,{size:13})," Rebase proposal"]}):null,e.jsx("button",{type:"button",onClick:l,disabled:!!f,style:oe(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void W(),disabled:!!f||i.length===0||C.length>0,style:{...Qe(n),opacity:f||i.length===0||C.length?.55:1},children:[f?e.jsx(Q,{size:13}):e.jsx(he,{size:13})," ",f==="preview"?"Repreviewing…":f==="commit"?"Saving…":"Save as draft"]})]})]})})}function Fe(t){if(t.kind==="skill_change")return`${t.operation==="create"?"Create":t.operation==="move"?"Move":"Update"} skill ${t.value.id}`;if(t.kind==="dbt_source_change")return"Patch dbt source";const n=t.change,l=(r,a)=>[r,a].filter(Boolean).join(" / ");switch(n.operation){case"upsert_domain":return`Create domain ${n.value.id}`;case"upsert_area":return`Create subject area ${n.value.name||n.value.id} in ${n.value.domain}`;case"upsert_entity":return`Bind ${n.value.dbtModel.split(".").at(-1)} as ${n.value.businessName||n.value.id} in ${l(n.value.domain,n.value.areaId)}`;case"upsert_relationship":{const r=n.value.keys.map(a=>`${a.from} = ${a.to}`).join(", ");return`Connect ${n.value.from} to ${n.value.to} on ${r} (${n.value.cardinality}, draft)`}case"remove_entity":return`Remove model ${n.value.id}`;case"remove_relationship":return`Remove relationship ${n.value.id}`;case"remove_area":return`Remove subject area ${n.value.id}`;default:return n.operation.replace(/_/g," ")}}function ie({label:t,value:n,theme:l}){return e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:8,padding:"9px 10px",background:l.cellBg},children:[e.jsx("b",{style:{fontSize:15},children:n}),e.jsx("span",{style:{display:"block",marginTop:2,color:l.textMuted,fontSize:9.5},children:t})]})}function me({title:t,value:n,theme:l}){return e.jsxs("div",{style:{minWidth:0,background:"var(--bg-1)",padding:9},children:[e.jsx("b",{style:{fontSize:9,color:l.textMuted},children:t}),e.jsx("pre",{style:{margin:"7px 0 0",fontSize:9.5,lineHeight:1.45,whiteSpace:"pre-wrap",overflowWrap:"anywhere",maxHeight:240,overflow:"auto",color:l.textSecondary},children:n||"∅"})]})}const Ge=t=>({border:"1px solid var(--border-subtle)",background:t.cellBg,color:t.textSecondary,width:29,height:29,borderRadius:7,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"}),oe=t=>({border:"1px solid var(--border-default)",background:t.cellBg,color:t.textPrimary,minHeight:31,borderRadius:7,padding:"0 12px",cursor:"pointer"}),Qe=t=>({...oe(t),background:t.accent,borderColor:t.accent,color:"var(--accent-fg)",display:"inline-flex",alignItems:"center",gap:6,fontWeight:650});function Ue(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").slice(0,64)}function be(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,64)}function Ke(){return{id:"",scope:"project",description:"",body:"",preferredMetrics:[],preferredBlocks:[],vocabulary:{},sourcePath:""}}function vt({embedded:t=!1,domainFilter:n=null,modelAreaFilter:l=null,sourcePathFilter:r}={}){var pe;const{state:a}=je(),c=ke[a.themeMode],[i,p]=x.useState([]),[f,y]=x.useState(!0),[m,s]=x.useState(null),[w,h]=x.useState({metrics:[],blocks:[],modelingRefs:[]}),C=a.authoredDomains,[v,P]=x.useState(null),[z,_]=x.useState(!1),[W,H]=x.useState("skills"),[o,j]=x.useState(!1),[k,T]=x.useState(null),[I,R]=x.useState(null),[d,S]=x.useState(!1),[q,b]=x.useState(null),[A,Be]=x.useState(()=>{try{const u=window.sessionStorage.getItem("dql-skill-ai-correction");return u?(window.sessionStorage.removeItem("dql-skill-ai-correction"),JSON.parse(u)):null}catch{return null}}),[O,ee]=x.useState(null),[de,ce]=x.useState(!1),[We,te]=x.useState(null),N=x.useCallback(()=>{let u=!1;return y(!0),s(null),$.getSkills().then(g=>{u||p(Array.isArray(g==null?void 0:g.skills)?g.skills:[])}).catch(g=>{u||(p([]),s(g instanceof Error&&g.message?g.message:"Could not load skills. Is the local DQL server running?"))}).finally(()=>{u||y(!1)}),$.getSkillOptions().then(g=>{u||h({metrics:Array.isArray(g==null?void 0:g.metrics)?g.metrics:[],blocks:Array.isArray(g==null?void 0:g.blocks)?g.blocks:[],modelingRefs:Array.isArray(g==null?void 0:g.modelingRefs)?g.modelingRefs:[]})}).catch(()=>{u||h({metrics:[],blocks:[],modelingRefs:[]})}),$.getSkillPathSettings().then(g=>{u||(P(g),H(g.path))}).catch(()=>{u||P(null)}),()=>{u=!0}},[]);x.useEffect(()=>N(),[N]),x.useEffect(()=>{A&&S(!0)},[A]);const ne=x.useMemo(()=>i.filter(u=>Ne(u,n,l)).filter(u=>Le(u,r)).sort((u,g)=>u.id.localeCompare(g.id)),[i,n,l,r]),Me=x.useCallback(u=>{p(g=>{const G=g.findIndex(fe=>(fe.qualifiedId??fe.id)===(u.qualifiedId??u.id));if(G===-1)return[...g,u];const xe=[...g];return xe[G]=u,xe}),R(null)},[]),$e=x.useCallback(async()=>{if(O){ce(!0),te(null);try{const u=O.qualifiedId??O.id;await $.deleteSkill(u),p(g=>g.filter(G=>(G.qualifiedId??G.id)!==u)),ee(null)}catch(u){te(u instanceof Error&&u.message?u.message:"Could not delete this skill.")}finally{ce(!1)}}},[O]),ue=x.useCallback(async()=>{j(!0),T(null);try{const u=await $.updateSkillPath(W);P(u),H(u.path),_(!1),N()}catch(u){T(u instanceof Error&&u.message?u.message:"Could not use this Skills folder.")}finally{j(!1)}},[N,W]);return e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",background:c.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(Z,{size:20,strokeWidth:1.9,color:c.accent}),e.jsx("div",{style:{fontSize:t?18:22,fontWeight:700,color:c.textPrimary},children:l?`${(pe=l.split("::").at(-1))==null?void 0:pe.replace(/_/g," ")} skills`:n?`${n} skills`:r?"Authored domain skills":"Skills"})]}),e.jsxs("div",{style:{fontSize:13,color:c.textMuted,marginTop:6,maxWidth:680,lineHeight:1.5},children:["Definitions, vocabulary, and instructions the AI follows when answering",l?" in this model area":n?" in this domain":r?" from authored domains":"",". Applied only when their triggers match — drafts never guide answers."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:7,color:c.textMuted,fontSize:10.5,minWidth:0},children:[e.jsx(ge,{size:12,strokeWidth:1.8}),e.jsx("span",{children:"Skill folder"}),e.jsx("code",{style:{color:c.textSecondary,fontFamily:c.fontMono,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(v==null?void 0:v.path)??"skills"}),v?e.jsxs("span",{children:["· ",v.exists?`${v.skillCount} loaded${r?` · ${ne.length} shown here`:""}`:"not found"]}):null]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[e.jsxs("button",{type:"button",onClick:()=>N(),title:"Refresh",style:E(c),children:[e.jsx(le,{size:13,strokeWidth:2})," Refresh"]}),e.jsxs("button",{type:"button",onClick:()=>{T(null),_(u=>!u)},style:E(c),children:[e.jsx(ge,{size:13,strokeWidth:2})," Skill folder"]}),e.jsxs("button",{type:"button",onClick:()=>S(u=>!u),style:E(c),children:[e.jsx(Se,{size:13,strokeWidth:2})," Skills AI"]}),e.jsxs("button",{type:"button",onClick:()=>R({kind:"create"}),style:J(c),children:[e.jsx(Y,{size:14,strokeWidth:2.2})," Add skill"]})]})]}),z?e.jsxs("div",{style:{border:"1px solid var(--border-subtle)",borderRadius:10,background:c.cellBg,padding:"12px 14px",marginBottom:16,display:"grid",gap:8},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:c.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:W,onChange:u=>H(u.target.value),onKeyDown:u=>{u.key==="Enter"&&W.trim()&&!o&&ue()},placeholder:"skills or ../skills",style:{...B(c),flex:1,fontFamily:c.fontMono}}),e.jsx("button",{type:"button",onClick:()=>_(!1),disabled:o,style:E(c),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:()=>void ue(),disabled:!W.trim()||o,style:{...J(c),opacity:W.trim()&&!o?1:.55},children:[o?e.jsx(Q,{size:13,strokeWidth:2}):null,o?"Connecting…":"Use folder"]})]}),e.jsxs("div",{style:{fontSize:10.5,lineHeight:1.45,color:c.textMuted},children:["Relative paths start from the DQL project. If DQL is in a ",e.jsx("code",{style:{fontFamily:c.fontMono},children:"/dql"})," folder inside your dbt repo, use ",e.jsx("code",{style:{fontFamily:c.fontMono},children:"../skills"}),". Existing ",e.jsx("code",{style:{fontFamily:c.fontMono},children:".skill.md"})," and Markdown skill files are loaded in place and stay Git-owned by that repo."]}),v!=null&&v.resolvedPath?e.jsxs("div",{style:{fontSize:10.5,color:c.textMuted,fontFamily:c.fontMono,overflowWrap:"anywhere"},children:["Resolved: ",v.resolvedPath]}):null,k?e.jsx(V,{t:c,tone:"error",children:k}):null]}):null,d?e.jsx(Ve,{themeMode:a.themeMode,domain:n,modelAreaId:l,selectedSkill:(I==null?void 0:I.kind)==="edit"?I.skill:i.find(u=>(u.qualifiedId??u.id)===(A==null?void 0:A.skillId)||u.id===(A==null?void 0:A.skillId)),correction:A,onCorrectionStarted:()=>Be(null),onReviewProposal:b}):null,f?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:c.textMuted,fontSize:13,padding:"40px 0"},children:[e.jsx(Q,{size:15,strokeWidth:2})," Loading skills…"]}):m?e.jsx(tt,{t:c,message:m,onRetry:()=>N()}):ne.length===0?e.jsx(et,{t:c,onAdd:()=>R({kind:"create"})}):e.jsx("div",{style:{display:"grid",gap:10},children:ne.map(u=>e.jsx(Je,{skill:u,t:c,onEdit:()=>R({kind:"edit",skill:u}),onDelete:()=>{te(null),ee(u)}},u.qualifiedId??u.id))})]}),I?e.jsx(Xe,{mode:I,options:w,domains:C,defaultDomain:n,defaultModelArea:l,existingIds:i.map(u=>u.id),t:c,onClose:()=>R(null),onSaved:Me}):null,O?e.jsx(nt,{skill:O,t:c,deleting:de,error:We,onCancel:()=>{de||ee(null)},onConfirm:$e}):null,q?e.jsx(Oe,{proposal:q,theme:c,onClose:()=>b(null),onCommitted:()=>{b(null),N()}}):null]})}function Ve({themeMode:t,domain:n,modelAreaId:l,selectedSkill:r,correction:a,onCorrectionStarted:c,onReviewProposal:i}){const p=ke[t],f=`skills:${n??"all"}:${l??"all"}:${(r==null?void 0:r.qualifiedId)??(r==null?void 0:r.id)??"new"}`,{threadId:y,onThreadIdChange:m}=Ee(f);return e.jsx("section",{style:{height:"min(600px, calc(100vh - 260px))",minHeight:400,marginBottom:18,border:"1px solid var(--border-default)",borderRadius:11,overflow:"hidden",background:p.cellBg},children:e.jsx(Ae,{themeMode:t,title:"Skills AI",scopeHint:"Skill proposal · metadata only · activation stays separate",composerPlaceholder:"Describe skill guidance or a correction…",initialMode:"skill",selectedObject:r?{kind:"skill",id:r.qualifiedId??r.id,title:r.id,path:r.sourcePath}:l?{kind:"model_area",id:l}:n?{kind:"domain",id:n}:{kind:"workspace",title:"New skill draft"},workspaceContext:{domain:n,modelAreaId:l,targetSkillId:(r==null?void 0:r.qualifiedId)??(r==null?void 0:r.id),providerSafety:"metadata_only"},threadId:y,onThreadIdChange:m,autoRun:a&&r?{text:`${a.feedback??"Correct this skill."}
7
+
8
+ Applied skill: ${r.qualifiedId??r.id}
9
+ Question: ${a.question??"Not retained"}
10
+ Save any corrected version as draft and preserve its analytical policy.`,mode:"skill",nonce:1}:void 0,onRunningChange:s=>{s&&a&&c()},onReviewAuthoringProposal:s=>{const w=s.payload;(w==null?void 0:w.version)===1&&w.trustState==="review_required"&&i(w)},emptyHint:"Describe the skill guidance or correction. Skills AI can draft metadata and canonical references, but cannot activate, grant tools, or make joins permissible.",examplePrompts:[{label:"Create a skill",prompt:"Create a draft skill for the selected domain and area, with triggers, exclusions, clarification rules, and examples."},{label:"Improve this skill",prompt:"Improve the selected skill while preserving its analytical policy and governed references."},{label:"Add vocabulary rules",prompt:"Propose vocabulary and clarification guidance for this domain without inventing governed references."}]})})}function Je({skill:t,t:n,onEdit:l,onDelete:r}){var p,f,y,m;const[a,c]=x.useState(!1),i=(p=t.domains)!=null&&p.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(Z,{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:ve(n),children:"draft — inactive"}):null,t.status==="active"||!t.status?e.jsx("span",{style:it(n),children:"active"}):null,i.map(s=>e.jsx("span",{style:rt(n),children:s},s)),t.isStarter?e.jsxs("span",{style:ve(n),title:"A dbt-seeded starter — edit it to make it yours",children:[e.jsx(Se,{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:()=>c(s=>!s),style:{...E(n),height:26,padding:"0 10px",fontSize:11},title:a?"Hide skill details":"Show skill details",children:a?"Hide details":"Details"}),e.jsx("button",{type:"button",onClick:l,style:{...X(n),width:26,height:26},title:"Edit skill",children:e.jsx(_e,{size:12,strokeWidth:1.75})}),e.jsx("button",{type:"button",onClick:r,style:{...X(n),width:26,height:26},title:"Delete skill",children:e.jsx(se,{size:12,strokeWidth:1.75})})]}),a?e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",padding:"12px 14px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px 20px"},children:[e.jsx(L,{t:n,label:"Apply when",values:t.triggers,empty:"No trigger phrases defined"}),e.jsx(L,{t:n,label:"Prefer these metrics",values:t.preferredMetrics,empty:"No preferred metrics",accent:!0,mono:!0}),e.jsx(L,{t:n,label:"Reuse these blocks",values:t.preferredBlocks,empty:"No preferred blocks",accent:!0,mono:!0}),e.jsx(L,{t:n,label:"Ask first when",values:t.clarifyWhen,empty:"No clarification rule defined"}),(f=t.exclusions)!=null&&f.length?e.jsx(L,{t:n,label:"Avoid when",values:t.exclusions,empty:""}):null,(y=t.modelAreaRefs)!=null&&y.length?e.jsx(L,{t:n,label:"Focus on model areas",values:t.modelAreaRefs,empty:"",mono:!0}):null,(m=t.sourceRefs)!=null&&m.length?e.jsx(L,{t:n,label:"Guided modeling objects",values:t.sourceRefs,empty:"",mono:!0}):null,t.body?e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("div",{style:F(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 Xe({mode:t,options:n,domains:l,defaultDomain:r=null,defaultModelArea:a=null,existingIds:c,t:i,onClose:p,onSaved:f}){const{dispatch:y}=je(),m=t.kind==="edit",[s,w]=x.useState(()=>t.kind==="edit"?{...t.skill}:{...Ke(),domain:r??void 0,domains:r?[r]:[],modelAreaRefs:a?[a]:[]}),[h,C]=x.useState(m),[v,P]=x.useState(()=>t.kind==="edit"?t.skill.id:""),[z,_]=x.useState(!1),[W,H]=x.useState(null),o=x.useCallback((d,S)=>{w(q=>({...q,[d]:S}))},[]),j=d=>{P(d),!m&&!h&&o("id",be(d))},k=!m&&s.id.length>0&&c.includes(s.id),T=s.id.trim().length>0&&s.body.trim().length>0&&!k&&!z,I=De(s.domain,l),R=x.useCallback(async()=>{var S,q;const d={...s,id:s.id.trim(),description:(S=s.description)!=null&&S.trim()?s.description.trim():void 0,body:s.body,domain:(q=s.domain)!=null&&q.trim()?s.domain.trim():void 0,domains:(s.domains??(s.domain?[s.domain]:[])).map(b=>b.trim()).filter(Boolean),modelAreaRefs:(s.modelAreaRefs??[]).map(b=>b.trim()).filter(Boolean),triggers:(s.triggers??[]).map(b=>b.trim()).filter(Boolean),exclusions:(s.exclusions??[]).map(b=>b.trim()).filter(Boolean),preferredDimensions:(s.preferredDimensions??[]).map(b=>b.trim()).filter(Boolean),requiredFilters:(s.requiredFilters??[]).map(b=>b.trim()).filter(Boolean),clarifyWhen:(s.clarifyWhen??[]).map(b=>b.trim()).filter(Boolean),examples:(s.examples??[]).map(b=>b.trim()).filter(Boolean),sourceRefs:(s.sourceRefs??[]).map(b=>b.trim()).filter(Boolean)};_(!0),H(null);try{const b=m?await $.updateSkill(t.kind==="edit"?t.skill.qualifiedId??t.skill.id:d.id,d):await $.createSkill(d);f(b.skill??d)}catch(b){H(b instanceof Error&&b.message?b.message:"Could not save this skill. Try again.")}finally{_(!1)}},[s,m,t,f]);return e.jsx("div",{style:at,onClick:()=>!z&&p(),children:e.jsxs("div",{style:dt(i),onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{style:ct(),children:[e.jsx("span",{style:{width:30,height:30,borderRadius:8,background:"var(--accent-dim)",color:i.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Z,{size:15,strokeWidth:1.75})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:i.textPrimary},children:m?"Edit skill":"New skill"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted,marginTop:1},children:"Git-backed guidance · applied only when triggers match"})]}),e.jsx("button",{type:"button",onClick:()=>!z&&p(),style:{...X(i),width:26,height:26,border:"none",background:"none"},title:"Close",children:e.jsx(ae,{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:F(i),children:"Identity"}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Name"}),e.jsx("input",{type:"text",value:v,onChange:d=>j(d.target.value),placeholder:"e.g. Revenue definition",style:B(i)}),e.jsxs("span",{style:{fontSize:10.5,color:i.textMuted},children:["Saved as"," ",e.jsx("input",{type:"text",value:`skills/${s.id}.skill.md`,disabled:m,onChange:d=>{C(!0),o("id",Ue(d.target.value.replace(/^skills\//,"").replace(/\.skill\.md$/,"")))},onBlur:()=>o("id",be(s.id)),title:"File name — letters, numbers, and dashes",style:{border:"none",background:"none",outline:"none",padding:0,fontFamily:i.fontMono,fontSize:10.5,color:i.textSecondary,width:`${Math.max(20,s.id.length+15)}ch`,borderBottom:m?"none":`1px dashed ${i.btnBorder}`}})]}),k?e.jsx(V,{t:i,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:D,children:[e.jsx("span",{style:M(i),children:"Domain"}),e.jsxs("select",{value:s.domain??"",onChange:d=>{const S=d.target.value||void 0;o("domain",S),o("domains",S?[S]:[])},style:{...B(i),cursor:"pointer",color:s.domain?i.textPrimary:i.textMuted},children:[e.jsx("option",{value:"",children:l.length===0?"No domains yet":"No domain"}),I.map(d=>e.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value))]})]}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Type"}),e.jsxs("select",{value:s.kind??"custom",onChange:d=>o("kind",d.target.value),style:{...B(i),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:()=>y({type:"SET_MAIN_VIEW",view:"domains"}),style:{border:"none",background:"none",padding:0,fontSize:10.5,color:i.accent,cursor:"pointer",fontFamily:i.font,alignSelf:"flex-start"},title:"Create a new domain in the Modeling workspace",children:"+ New domain"}),e.jsxs("div",{children:[e.jsx("span",{style:{...M(i),display:"block",marginBottom:5},children:"Lifecycle"}),e.jsx("div",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,border:`1px solid ${i.btnBorder}`,borderRadius:7,background:"var(--bg-1)"},children:["active","draft","deprecated"].map(d=>{const S=(s.status??"active")===d;return e.jsx("button",{type:"button",onClick:()=>o("status",d),style:{border:"none",borderRadius:5,padding:"4px 12px",fontSize:11.5,fontWeight:600,cursor:"pointer",fontFamily:i.font,background:S?i.cellBg:"transparent",color:S?i.textPrimary:i.textMuted,boxShadow:S?"0 1px 3px rgba(26,26,26,0.1)":"none",textTransform:"capitalize"},children:d},d)})}),e.jsx("span",{style:{fontSize:10.5,color:i.textMuted,marginLeft:8},children:(s.status??"active")==="active"?"Guides matching answers.":s.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:F(i),children:"When to apply"}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Apply when the question mentions"}),e.jsx(Ye,{t:i,values:s.triggers??[],onChange:d=>o("triggers",d),placeholder:"Add phrase, press Enter"})]}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Ask first when"}),e.jsx(U,{values:s.clarifyWhen??[],onChange:d=>o("clarifyWhen",d),placeholder:"e.g. 'sales' could mean revenue or order count",style:B(i)})]}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Avoid when"}),e.jsx(U,{values:s.exclusions??[],onChange:d=>o("exclusions",d),placeholder:"e.g. question is about pipeline or bookings",style:B(i)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,gridRow:"span 2"},children:[e.jsx("div",{style:F(i),children:"Guidance"}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"One-line summary"}),e.jsx("input",{type:"text",value:s.description??"",onChange:d=>o("description",d.target.value),placeholder:"What rule does this skill encode?",style:B(i)})]}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Full guidance"}),e.jsx("textarea",{value:s.body,onChange:d=>o("body",d.target.value),rows:9,placeholder:"Definitions, exclusions, edge cases — written for the agent.",style:ot(i)})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsx("div",{style:F(i),children:"Prefer these assets"}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Metrics"}),e.jsx(re,{t:i,options:n.metrics,optionKind:"metrics",selected:s.preferredMetrics,onChange:d=>o("preferredMetrics",d),placeholder:"Search metrics…",emptyOptionsHint:"No metrics available from the project yet."})]}),e.jsxs("label",{style:D,children:[e.jsx("span",{style:M(i),children:"Blocks"}),e.jsx(re,{t:i,options:n.blocks,optionKind:"blocks",selected:s.preferredBlocks,onChange:d=>o("preferredBlocks",d),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:i.accent,cursor:"pointer"},children:"Advanced — subject areas, dimensions, and vocabulary"}),e.jsxs("div",{style:{display:"grid",gap:14,marginTop:12},children:[e.jsx(K,{label:"Focused subject areas (optional)",t:i,hint:"Comma-separated subject-area ids from the Modeling workspace. This boosts the skill only inside its selected domain; it never expands access.",children:e.jsx(U,{values:s.modelAreaRefs??[],onChange:d=>o("modelAreaRefs",d),placeholder:"customer_lifecycle, revenue_reporting",style:B(i)})}),e.jsx(K,{label:"Preferred dimensions",t:i,hint:"Business-safe dimensions the agent should prefer when they are compatible.",children:e.jsx(U,{values:s.preferredDimensions??[],onChange:d=>o("preferredDimensions",d),placeholder:"region, month",style:B(i)})}),e.jsx(K,{label:"Qualified models and relationships",t:i,hint:"Optional canonical IDs from Modeling. Validated references create guided_by edges; legacy free text cannot authorize joins.",children:e.jsx(re,{t:i,options:n.modelingRefs,optionKind:"modelingRefs",selected:s.sourceRefs??[],onChange:d=>o("sourceRefs",d),placeholder:"Search qualified models and relationships…",emptyOptionsHint:"No governed Modeling references are available yet."})}),e.jsx(K,{label:"Vocabulary",t:i,hint:"Map your terms to a target, e.g. arr → metric:arr or revenue → block:revenue_by_region.",children:e.jsx(Ze,{t:i,value:s.vocabulary,onChange:d=>o("vocabulary",d)})})]})]}),W?e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(V,{t:i,tone:"error",children:W})}):null]}),e.jsxs("div",{style:ut(),children:[e.jsx("span",{style:{fontSize:10.5,color:i.textMuted,flex:1,textAlign:"left"},children:"Saved to Git — review in source control before merging."}),e.jsx("button",{type:"button",onClick:()=>!z&&p(),style:E(i),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:R,disabled:!T,style:{...J(i),opacity:T?1:.55},children:[z?e.jsx(Q,{size:13,strokeWidth:2}):null,z?"Saving…":m?"Save changes":"Create skill"]})]})]})})}function Ye({t,values:n,onChange:l,placeholder:r}){const[a,c]=x.useState(""),i=p=>{const f=p.trim().replace(/,$/,"");!f||n.includes(f)||(l([...n,f]),c(""))};return e.jsxs("div",{style:Ce(t),children:[n.map(p=>e.jsxs("span",{style:Re(t),children:[p,e.jsx("button",{type:"button",onClick:()=>l(n.filter(f=>f!==p)),style:Ie(t),title:"Remove",children:"×"})]},p)),e.jsx("input",{type:"text",value:a,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"||p.key===","?(p.preventDefault(),i(a)):p.key==="Backspace"&&!a&&n.length&&l(n.slice(0,-1))},onBlur:()=>i(a),placeholder:n.length?"":r,style:ze(t)})]})}function re({t,options:n,optionKind:l,selected:r,onChange:a,placeholder:c,emptyOptionsHint:i}){const[p,f]=x.useState(""),[y,m]=x.useState(n);x.useEffect(()=>{let h=!1;const C=window.setTimeout(()=>{$.getSkillOptions(p).then(v=>{h||m(l==="metrics"?v.metrics:l==="blocks"?v.blocks:v.modelingRefs)}).catch(()=>{h||m(n)})},160);return()=>{h=!0,window.clearTimeout(C)}},[l,n,p]);const s=x.useMemo(()=>y.filter(h=>!r.includes(h)).filter(h=>p?h.toLowerCase().includes(p.toLowerCase()):!0).slice(0,8),[y,r,p]),w=h=>{const C=h.trim();!C||r.includes(C)||(a([...r,C]),f(""))};return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsxs("div",{style:Ce(t),children:[r.map(h=>e.jsxs("span",{style:{...Re(t),fontFamily:t.fontMono},children:[h,e.jsx("button",{type:"button",onClick:()=>a(r.filter(C=>C!==h)),style:Ie(t),title:"Remove",children:"×"})]},h)),e.jsx("input",{type:"text",value:p,onChange:h=>f(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),w(p))},placeholder:r.length?"":c,style:ze(t)})]}),s.length>0?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:s.map(h=>e.jsxs("button",{type:"button",onClick:()=>w(h),style:lt(t),children:[e.jsx(Y,{size:10,strokeWidth:2.4})," ",h]},h))}):y.length===0?e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[i," You can still type a value and press Enter."]}):null]})}function Ze({t,value:n,onChange:l}){const[r,a]=x.useState(()=>Object.entries(n??{}).map(([p,f])=>({term:p,target:f}))),c=p=>{a(p);const f={};for(const y of p){const m=y.term.trim();m&&(f[m]=y.target.trim())}l(f)},i=(p,f)=>{c(r.map((y,m)=>m===p?{...y,...f}:y))};return e.jsxs("div",{style:{display:"grid",gap:7},children:[r.map((p,f)=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx("input",{type:"text",value:p.term,onChange:y=>i(f,{term:y.target.value}),placeholder:"arr",style:{...B(t),flex:1}}),e.jsx("span",{style:{color:t.textMuted,fontSize:13},children:"→"}),e.jsx("input",{type:"text",value:p.target,onChange:y=>i(f,{target:y.target.value}),placeholder:"metric:arr",style:{...B(t),flex:1.3,fontFamily:t.fontMono}}),e.jsx("button",{type:"button",onClick:()=>c(r.filter((y,m)=>m!==f)),style:X(t),title:"Remove row",children:e.jsx(ae,{size:13,strokeWidth:2})})]},f)),e.jsxs("button",{type:"button",onClick:()=>a([...r,{term:"",target:""}]),style:{...E(t),justifySelf:"start"},children:[e.jsx(Y,{size:12,strokeWidth:2.2})," Add term"]})]})}function et({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(Z,{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:{...J(t),marginTop:4},children:[e.jsx(Y,{size:14,strokeWidth:2.2})," Add your first skill"]})]})}function tt({t,message:n,onRetry:l}){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(we,{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:l,style:{...E(t),marginTop:10},children:[e.jsx(le,{size:13,strokeWidth:2})," Retry"]})]})]})}function nt({skill:t,t:n,deleting:l,error:r,onCancel:a,onConfirm:c}){return e.jsx("div",{style:pt,onClick:a,children:e.jsxs("div",{style:xt(n),onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[e.jsx(se,{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."]}),r?e.jsx(V,{t:n,tone:"error",children:r}):null,e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8,marginTop:4},children:[e.jsx("button",{type:"button",onClick:a,disabled:l,style:E(n),children:"Cancel"}),e.jsxs("button",{type:"button",onClick:c,disabled:l,style:{...st(n),opacity:l?.6:1},children:[l?e.jsx(Q,{size:13,strokeWidth:2}):e.jsx(se,{size:13,strokeWidth:2}),l?"Deleting…":"Delete"]})]})]})})}function F(t){return{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:t.textMuted,marginBottom:5}}function L({t,label:n,values:l,empty:r,accent:a=!1,mono:c=!1}){return e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:F(t),children:n}),e.jsx("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:l!=null&&l.length?l.map(i=>e.jsx("span",{style:{fontSize:11,padding:"3px 9px",borderRadius:999,background:a?"var(--accent-dim)":"var(--bg-1)",color:a?t.accent:t.textSecondary,border:a?`1px solid ${t.accent}33`:"1px solid var(--border-subtle)",fontFamily:c?t.fontMono:void 0},children:i},i)):e.jsx("span",{style:{fontSize:11.5,color:t.textMuted,fontStyle:"italic"},children:r})})]})}function K({label:t,hint:n,t:l,children:r}){return e.jsxs("div",{style:{display:"grid",gap:6},children:[e.jsx("label",{style:{fontSize:12,fontWeight:700,color:l.textPrimary},children:t}),n?e.jsx("div",{style:{fontSize:11.5,color:l.textMuted,lineHeight:1.45,marginTop:-2},children:n}):null,r]})}function V({t,tone:n,children:l}){const r=n==="error"?t.error:t.textMuted;return e.jsx("div",{style:{fontSize:11.5,color:r,lineHeight:1.45},children:l})}function it(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 rt(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 J(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 E(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 st(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 X(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 B(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 ot(t){return{...B(t),resize:"vertical",lineHeight:1.5,padding:"9px 11px"}}function ve(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 Ce(t){return{display:"flex",alignItems:"center",gap:5,flexWrap:"wrap",border:`1px solid ${t.btnBorder}`,background:t.cellBg,borderRadius:7,padding:"6px 8px"}}function ze(t){return{flex:1,minWidth:110,border:"none",background:"none",outline:"none",fontSize:11.5,fontFamily:t.font,color:t.textPrimary,padding:2}}function Re(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 Ie(t){return{border:"none",background:"none",color:t.accent,cursor:"pointer",padding:0,fontSize:12,lineHeight:1,fontFamily:t.font}}const D={display:"flex",flexDirection:"column",gap:4};function M(t){return{fontSize:11,fontWeight:650,color:t.textSecondary}}function lt(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 at={position:"fixed",inset:0,background:"rgba(26, 26, 26, 0.22)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60};function dt(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 ct(t){return{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0}}function ut(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 pt={position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.42)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:70,padding:20};function xt(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)"}}export{Oe as C,vt as S};
@@ -1 +1 @@
1
- import{j as c,b3 as l}from"./index-1mIC_XX4.js";const e={certified:{base:"Certified",tone:"success"},reviewed:{base:"Reviewed",tone:"info"},ai_generated:{base:"AI-Generated",tone:"warning"},insufficient_context:{base:"Insufficient-Context",tone:"neutral"},conflict:{base:"Conflict",tone:"error"}},s="insufficient_context";function d({state:t,qualifier:i,label:a}){if(!t)return null;const n=o[t]??o[s],r=i?`${n.label} · ${i}`:n.label;return c.jsx(l,{tone:n.tone,children:a??r})}const o={certified:{tone:e.certified.tone,label:e.certified.base},reviewed:{tone:e.reviewed.tone,label:e.reviewed.base},ai_generated:{tone:e.ai_generated.tone,label:e.ai_generated.base},insufficient_context:{tone:e.insufficient_context.tone,label:e.insufficient_context.base},conflict:{tone:e.conflict.tone,label:e.conflict.base},draft:{tone:"warning",label:"Draft"},pending:{tone:"warning",label:"Pending review"},review:{tone:"warning",label:"Review"},uncertified:{tone:"warning",label:"Uncertified"},deprecated:{tone:"neutral",label:"Deprecated"},no_answer:{tone:"error",label:"No answer"}};export{d as T};
1
+ import{j as c,b6 as l}from"./index-9w93YPF9.js";const e={certified:{base:"Certified",tone:"success"},reviewed:{base:"Reviewed",tone:"info"},ai_generated:{base:"AI-Generated",tone:"warning"},insufficient_context:{base:"Insufficient-Context",tone:"neutral"},conflict:{base:"Conflict",tone:"error"}},s="insufficient_context";function d({state:t,qualifier:i,label:a}){if(!t)return null;const n=o[t]??o[s],r=i?`${n.label} · ${i}`:n.label;return c.jsx(l,{tone:n.tone,children:a??r})}const o={certified:{tone:e.certified.tone,label:e.certified.base},reviewed:{tone:e.reviewed.tone,label:e.reviewed.base},ai_generated:{tone:e.ai_generated.tone,label:e.ai_generated.base},insufficient_context:{tone:e.insufficient_context.tone,label:e.insufficient_context.base},conflict:{tone:e.conflict.tone,label:e.conflict.base},draft:{tone:"warning",label:"Draft"},pending:{tone:"warning",label:"Pending review"},review:{tone:"warning",label:"Review"},uncertified:{tone:"warning",label:"Uncertified"},deprecated:{tone:"neutral",label:"Deprecated"},no_answer:{tone:"error",label:"No answer"}};export{d as T};