@zaip-ai/cli 1.3.6 → 1.3.8

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 (68) hide show
  1. package/README.md +31 -1
  2. package/dist/commands/init.d.ts.map +1 -1
  3. package/dist/commands/init.js +22 -0
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/services/sqlite-bootstrap.d.ts +29 -0
  8. package/dist/services/sqlite-bootstrap.d.ts.map +1 -0
  9. package/dist/services/sqlite-bootstrap.js +141 -0
  10. package/dist/services/sqlite-bootstrap.js.map +1 -0
  11. package/dist/services/stack-install.d.ts +14 -0
  12. package/dist/services/stack-install.d.ts.map +1 -0
  13. package/dist/services/stack-install.js +176 -0
  14. package/dist/services/stack-install.js.map +1 -0
  15. package/dist/services/stack-node.d.ts +12 -0
  16. package/dist/services/stack-node.d.ts.map +1 -0
  17. package/dist/services/stack-node.js +150 -0
  18. package/dist/services/stack-node.js.map +1 -0
  19. package/dist/services/stack-package-manager.d.ts +12 -0
  20. package/dist/services/stack-package-manager.d.ts.map +1 -0
  21. package/dist/services/stack-package-manager.js +178 -0
  22. package/dist/services/stack-package-manager.js.map +1 -0
  23. package/dist/services/stack-plan.d.ts +33 -0
  24. package/dist/services/stack-plan.d.ts.map +1 -0
  25. package/dist/services/stack-plan.js +116 -0
  26. package/dist/services/stack-plan.js.map +1 -0
  27. package/dist/types.d.ts +3 -0
  28. package/dist/types.d.ts.map +1 -1
  29. package/package.json +2 -2
  30. package/templates/.agents/dashboard/.zaip-managed.json +35 -27
  31. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-3Lrfq645.js → DashboardHelpDialog-VcLx9iOO.js} +1 -1
  32. package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-BwnJpl02.js +3 -0
  33. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-BomxqCBU.css → ProjectSettingsPage-GgzpZ_PY.css} +1 -1
  34. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-diq9g1L8.js → TraceabilityWorkspace-DFZwIXSC.js} +1 -1
  35. package/templates/.agents/dashboard/apps/frontend/dist/assets/{index-Deo_W81f.js → index-Dyo_wpL4.js} +2 -2
  36. package/templates/.agents/dashboard/apps/frontend/dist/index.html +1 -1
  37. package/templates/.agents/dashboard/apps/frontend/src/ProjectSettingsPage.tsx +15 -2
  38. package/templates/.agents/dashboard/apps/frontend/src/ProjectStackEditor.tsx +22 -6
  39. package/templates/.agents/dashboard/apps/frontend/src/dashboard-api.ts +2 -0
  40. package/templates/.agents/dashboard/apps/frontend/src/project-settings-model.ts +1 -1
  41. package/templates/.agents/dashboard/apps/frontend/src/project-settings-page.css +0 -104
  42. package/templates/.agents/dashboard/apps/frontend/src/project-settings.test.ts +26 -0
  43. package/templates/.agents/dashboard/apps/frontend/src/project-stack-versions.css +117 -0
  44. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +119 -119
  45. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +119 -119
  46. package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.test.ts +153 -0
  47. package/templates/.agents/dashboard/packages/local-runtime/src/project-settings.ts +161 -40
  48. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-prerequisites.mjs +5 -5
  49. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-prerequisites.test.mjs +8 -0
  50. package/templates/.agents/dashboard/stack-dependencies.json +14 -0
  51. package/templates/.agents/requirements/autonomous-assurance.md +1 -1
  52. package/templates/.agents/requirements/comparative-audit.md +1 -1
  53. package/templates/.agents/requirements/context-engine.md +1 -1
  54. package/templates/.agents/requirements/cost-observability.md +1 -1
  55. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  56. package/templates/.agents/requirements/data-export.md +1 -1
  57. package/templates/.agents/requirements/design-system.md +1 -1
  58. package/templates/.agents/requirements/execution-engine.md +1 -1
  59. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  60. package/templates/.agents/requirements/model-orchestration.md +1 -1
  61. package/templates/.agents/requirements/public-distribution.md +1 -1
  62. package/templates/.agents/requirements/software-architecture.md +1 -1
  63. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  64. package/templates/.agents/requirements/work-lifecycle.md +1 -1
  65. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  66. package/templates/README.md +1 -1
  67. package/templates/template-manifest.json +53 -45
  68. package/templates/.agents/dashboard/apps/frontend/dist/assets/ProjectSettingsPage-B_Oj6Dlf.js +0 -3
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardHelpDialog-3Lrfq645.js","assets/cost-monitor-C09KmlSw.js","assets/rolldown-runtime-D9-fqq9M.js","assets/cost-monitor-PoJA2PI1.css","assets/dashboard-localization-CLJ0lT9v.js","assets/DashboardHelpDialog-Je5nK-Et.css","assets/PricingSettingsDialog-CyjMXkm8.js","assets/ProjectSettingsPage-B_Oj6Dlf.js","assets/ProjectSettingsPage-BomxqCBU.css","assets/CostCalculationGuidePage-DwVZOmMV.js","assets/TraceabilityWorkspace-diq9g1L8.js","assets/traceability-I4AKqVDX.js","assets/icons-vendor-DXBOtWNI.js","assets/traceability-DFY7ZDlu.css","assets/TraceabilityWorkspace-DvvavDLY.css"])))=>i.map(i=>d[i]);
2
- import{S as e,a as t,b as n,g as r,h as i,i as a,n as o,r as s,t as c}from"./cost-monitor-C09KmlSw.js";import{t as l}from"./react-vendor-DaNXQPyk.js";import{n as u,t as d}from"./traceability-I4AKqVDX.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(),p=l(),m=n();function h({locale:e}){let t=e===`pt-BR`?[`Definição`,`Planejamento`,`Pronto para Executar`,`Execução`,`Verificação`]:[`Definition`,`Planning`,`Ready to Execute`,`Execution`,`Verification`];return(0,m.jsxs)(`main`,{"aria-busy":`true`,"aria-live":`polite`,"aria-label":e===`pt-BR`?`Preparando dashboard`:`Preparing dashboard`,className:`app-skeleton`,role:`status`,children:[(0,m.jsxs)(`header`,{className:`app-skeleton-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`h1`,{children:`Dashboard Zaip AIOS`})]}),(0,m.jsxs)(`div`,{className:`app-skeleton-actions`,children:[(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-kpis`,"aria-hidden":`true`,children:Array.from({length:4},(e,t)=>`skeleton-kpi-${t}`).map(e=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`span`,{className:`app-skeleton-value`}),(0,m.jsx)(`span`,{className:`app-skeleton-line`})]},e))}),(0,m.jsxs)(`section`,{className:`app-skeleton-panels`,"aria-hidden":`true`,children:[(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart`})]}),(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart app-skeleton-chart-small`})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-board`,"aria-hidden":`true`,children:t.map((e,t)=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`h2`,{children:e}),Array.from({length:t%2==0?2:1},(t,n)=>`${e}-${n}`).map(e=>(0,m.jsxs)(`div`,{className:`app-skeleton-card`,children:[(0,m.jsx)(`span`,{className:`app-skeleton-line`}),(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`span`,{className:`app-skeleton-pill`})]},e))]},e))})]})}function g(e,t){let n=t===`pt-BR`;return e===`costs`?n?{title:`Carregando Monitor de Custos…`,detail:`Isso costuma levar poucos segundos.`}:{title:`Loading Cost Monitor…`,detail:`This usually takes a few seconds.`}:e===`traceability`?n?{title:`Carregando Rastreabilidade…`,detail:`Estamos preparando as 6 etapas da task.`}:{title:`Loading Traceability…`,detail:`Preparing the task's 6 stages.`}:n?{title:`Atualizando dados do dashboard…`,detail:`Você pode continuar navegando.`}:{title:`Refreshing dashboard data…`,detail:`You can keep navigating.`}}function _({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-busy":`true`,"aria-live":`polite`,className:`app-loading-panel`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function v({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function y({locale:e,onRetry:t}){return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-loading-panel app-loading-panel-error`,role:`status`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Não foi possível carregar os custos`:`Couldn't load costs`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`A tela continua disponível. Tente novamente quando quiser.`:`The dashboard remains available. Try again whenever you want.`})]}),(0,m.jsx)(`button`,{onClick:t,type:`button`,children:e===`pt-BR`?`Tentar novamente`:`Try again`})]})}function ee({costsLoaded:e,currency:t,snapshotCurrency:n}){return!e||n!==t}function te({aborted:e,currentCurrency:t,currentPeriod:n,currentRequestVersion:r,requestVersion:i,requestedCurrency:a,requestedPeriod:o}){return!e&&i===r&&a===t&&o.from===n.from&&o.to===n.to}function b(e,t){return e===t}function x(e,t,n,r){return b(e,t)&&n.from===r.from&&n.to===r.to}function S(e){return e instanceof DOMException&&e.name===`AbortError`}function ne(e,t){return e===t}function C(e,t,n){return b(e,t)&&!n.aborted}function re(e,t){let n=e=>[...new Map(e.map(e=>[e.id,e])).values()];return{...e,prds:n([...e.prds,...t.flatMap(e=>e.prds)]),specs:n([...e.specs,...t.flatMap(e=>e.specs)]),tasks:n([...e.tasks,...t.flatMap(e=>e.tasks)]),changes:n([...e.changes,...t.flatMap(e=>e.changes)])}}function ie(){let e=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.current?.focus()},[]),(0,m.jsx)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`period-transition-overlay`,onKeyDownCapture:e=>e.preventDefault(),ref:e,role:`status`,tabIndex:-1,children:(0,m.jsxs)(`div`,{className:`period-transition-overlay__content`,children:[(0,m.jsx)(`i`,{"aria-hidden":`true`,className:`period-transition-overlay__spinner`}),(0,m.jsx)(`span`,{className:`period-transition-overlay__label`,children:`Carregando...`})]})})}function ae({pending:e,children:t}){return(0,m.jsx)(`div`,{"aria-hidden":e||void 0,inert:e,children:t})}function oe({children:e,error:t,globalLoadingPending:n,locale:r,onRefresh:i,operations:a,snapshotNotice:o,setupRoute:s}){return s===null?t&&a===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:`Dashboard local indisponível`}),(0,m.jsx)(`h1`,{children:`Não foi possível ler o workspace V2.`}),(0,m.jsx)(`pre`,{children:t}),(0,m.jsx)(`button`,{onClick:i,type:`button`,children:`Tentar novamente`})]}):a===null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(h,{locale:r}),o,n?(0,m.jsx)(ie,{}):null]}):e:s}var se=`modulepreload`,w=function(e){return`/`+e},ce={},T=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=w(t,n),t=s(t),t in ce)return;ce[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:se,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},le=(0,f.lazy)(async()=>({default:(await T(async()=>{let{DashboardHelpDialog:e}=await import(`./DashboardHelpDialog-3Lrfq645.js`);return{DashboardHelpDialog:e}},__vite__mapDeps([0,1,2,3,4,5]))).DashboardHelpDialog}));function ue({costLocale:e,documentDetail:n,helpOpen:i,loadingArea:a,operations:s,reconciliationResult:c,refreshDialog:l,showTrace:p,trace:h,traceLink:g,traceLoadingTaskId:_,closeDocument:y,onCloseHelp:ee,onCloseTrace:te,onDismissReconciliation:b,onOpenDocument:x,onOpenTrace:S,onOpenTraceChange:ne,onOpenTraceMacro:C,onRefreshCancel:re,onRefreshFromDialog:ie,setTraceLink:ae}){return(0,m.jsxs)(m.Fragment,{children:[p?null:_?(0,m.jsx)(d,{locale:e,taskId:_}):h?(0,m.jsx)(u,{locale:e,onClose:te,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),trace:h}):null,g?.kind===`change`?(0,m.jsx)(r,{details:{kind:`change`,row:g.row},locale:e,onClose:()=>ae(null)}):null,g?.kind===`macro`?(0,m.jsx)(t,{label:g.label,locale:e,onClose:()=>ae(null),onOpenDocument:x,onOpenTrace:e=>{ae(null),S(e)},row:g.row,runs:s.runs,specs:s.specs,tasks:s.tasks}):null,n?(0,m.jsx)(o,{detail:n.detail,error:n.error,label:n.label,locale:e,loading:!n.detail&&!n.error,onClose:y,onRetry:()=>x(n.kind,n.preview.id),preview:n.preview}):null,i?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(le,{locale:e,onClose:ee})}):null,l===`choose`?(0,m.jsx)(`div`,{className:`app-refresh-dialog-backdrop`,children:(0,m.jsxs)(`section`,{"aria-label":`Atualizar dashboard`,"aria-modal":`true`,className:`app-refresh-dialog`,role:`dialog`,children:[(0,m.jsx)(`h2`,{children:e===`pt-BR`?`Atualizar dashboard`:`Refresh dashboard`}),(0,m.jsx)(`p`,{children:e===`pt-BR`?`Escolha uma atualização rápida ou reconcilie os itens que ainda estão em aberto.`:`Choose a quick refresh or reconcile work items that are still open.`}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`button`,{onClick:()=>ie(!1),type:`button`,children:e===`pt-BR`?`Apenas atualizar dados`:`Refresh data only`}),(0,m.jsx)(`button`,{onClick:()=>ie(!0),type:`button`,children:e===`pt-BR`?`Reconciliar itens abertos`:`Reconcile open work`})]}),(0,m.jsx)(`button`,{className:`app-refresh-cancel`,onClick:re,type:`button`,children:e===`pt-BR`?`Cancelar`:`Cancel`})]})}):null,l===`refreshing`||l===`reconciling`?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:l===`reconciling`?e===`pt-BR`?`Reconciliando itens em aberto…`:`Reconciling open work…`:e===`pt-BR`?`Atualizando dados…`:`Refreshing data…`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`Você pode continuar usando o dashboard.`:`You can keep using the dashboard.`})]})]}):null,c!==null&&l===null?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-reconciliation-result`,role:`status`,children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Resultado da reconciliação manual`:`Manual reconciliation result`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`${c.reconciled_ids.length} item(ns) reconciliado(s).`:`${c.reconciled_ids.length} item(s) reconciled.`}),c.reconciled_ids.length>0?(0,m.jsx)(`p`,{children:c.reconciled_ids.join(`, `)}):null,c.blocked.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Bloqueados: `:`Blocked: `,c.blocked.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,c.not_reconciled.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Não reconciliados: `:`Not reconciled: `,c.not_reconciled.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,(0,m.jsx)(`button`,{onClick:b,type:`button`,children:e===`pt-BR`?`Fechar`:`Dismiss`})]}):null,a!==null&&a!==`operations`&&l===null?(0,m.jsx)(v,{area:a,locale:e}):null]})}var de=(0,f.lazy)(async()=>({default:(await T(async()=>{let{PricingSettingsPage:e}=await import(`./PricingSettingsDialog-CyjMXkm8.js`);return{PricingSettingsPage:e}},__vite__mapDeps([6,1,2,3,4]))).PricingSettingsPage})),fe=(0,f.lazy)(async()=>({default:(await T(async()=>{let{ProjectSettingsPage:e}=await import(`./ProjectSettingsPage-B_Oj6Dlf.js`);return{ProjectSettingsPage:e}},__vite__mapDeps([7,1,2,3,8]))).ProjectSettingsPage})),pe=(0,f.lazy)(async()=>({default:(await T(async()=>{let{CostCalculationGuidePage:e}=await import(`./CostCalculationGuidePage-DwVZOmMV.js`);return{CostCalculationGuidePage:e}},__vite__mapDeps([9,1,2,3]))).CostCalculationGuidePage})),me=`/setup-pricing`,he=`/setup-project`,ge=`/cost-calculation-guide`;function _e(e){let{api:t,costLocale:n,fxRate:r,navigate:i,pathname:a,pricing:o,refresh:s,setFxRate:c,setPricing:l}=e;return a===`/setup-pricing`?o===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:n===`pt-BR`?`Configuração do projeto`:`Project settings`}),(0,m.jsx)(`h1`,{children:n===`pt-BR`?`Carregando catálogo de preços…`:`Loading pricing catalog…`}),(0,m.jsx)(`button`,{onClick:()=>i(`/`),type:`button`,children:n===`pt-BR`?`Voltar ao dashboard`:`Back to dashboard`})]}):(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(de,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`),onSave:async e=>{l(await t.savePricing(e)),await s()},onSaveFxRate:async e=>{c(await t.saveFxRate(e)),await s()}})}):a===`/cost-calculation-guide`&&o!==null?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(pe,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`)})}):a===`/setup-project`?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(fe,{api:t,locale:n,onClose:()=>i(`/`)})}):null}var ve=`/zaip-cost-monitor`,E=`zaip-dashboard-session-token`,ye=`zaip-dashboard-locale`,D=`zaip-dashboard-currency`;function be(){return window.localStorage.getItem(`zaip-dashboard-locale`)===`en-US`?`en-US`:`pt-BR`}function xe(e){return e.replace(/\/+$/,``)===ve?`cost-monitor`:null}function Se(){let e=new URL(window.location.href),t=e.searchParams.get(`token`)??window.localStorage.getItem(`zaip-dashboard-session-token`)??window.sessionStorage.getItem(`zaip-dashboard-session-token`)??``;return t&&(window.localStorage.setItem(E,t),window.sessionStorage.setItem(E,t)),e.searchParams.has(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)),t}var Ce=(0,f.lazy)(async()=>({default:(await T(async()=>{let{TraceabilityWorkspace:e}=await import(`./TraceabilityWorkspace-diq9g1L8.js`);return{TraceabilityWorkspace:e}},__vite__mapDeps([10,1,2,3,11,12,13,14]))).TraceabilityWorkspace}));function we({costs:e,costLocale:t,currency:n,dashboardView:r,failedArea:i,lastUpdatedAt:a,loadCostDetail:o,loadCostReadModelPage:s,loadCostRunPage:l,loadCostGroupPage:u,loadingArea:d,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:ee,onLoadMoreTraceTasks:te,onRefresh:b,onRetry:x,onSelectTraceTask:S,onOpenTraceChange:ne,onOpenTraceMacro:C,operations:re,selectedTraceTaskId:ie,trace:ae,traceLoadingTaskId:oe,traceTasksHasMore:se,traceTasksLoading:w,traceTasks:ce}){return r===`cost-monitor`?e===null?()=>i===`costs`?(0,m.jsx)(y,{locale:t,onRetry:x}):(0,m.jsx)(_,{area:`costs`,locale:t}):r=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`costs`,locale:t}),children:(0,m.jsx)(c,{currency:n,data:e,embedded:!0,globalFilters:r,lastUpdatedAt:a,locale:t,loading:d===`costs`,loadDetail:o,loadReadModelPage:s,loadRunPage:l,loadGroupPage:u,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:ee,onRefresh:b,operations:re})}):r===`traceability`?()=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`operations`,locale:t}),children:(0,m.jsx)(Ce,{loadingTaskId:oe,locale:t,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),onLoadMoreTasks:te,onSelectTask:S,selectedTaskId:ie,tasks:ce.length>0?ce:re.tasks,hasMoreTasks:se,isLoadingTasks:w,trace:ae})}):r===null?(0,m.jsx)(`span`,{"aria-hidden":`true`,hidden:!0}):void 0}var O={"pt-BR":{label:`Áreas do dashboard`,operations:`Operação`,operationsHint:`Trabalho em andamento e priorização`,costs:`Monitor de Custos`,costsHint:`Tempo, tokens e custo`,traceability:`Rastreabilidade`,traceabilityHint:`Ciclo completo em 6 etapas`},"en-US":{label:`Dashboard areas`,operations:`Operations`,operationsHint:`Lifecycle and work in progress`,costs:`Cost Monitor`,costsHint:`Time, tokens, and cost`,traceability:`Traceability`,traceabilityHint:`Complete 6-stage lifecycle`}};function Te({activeView:e,locale:t,onChange:n}){let r=O[t],i=e=>{n(e),window.requestAnimationFrame(()=>{document.querySelector(`.dashboard-global-controls`)?.scrollIntoView({behavior:`smooth`,block:`start`})})};return(0,m.jsxs)(`nav`,{"aria-label":r.label,className:`dashboard-capability-nav`,children:[(0,m.jsxs)(`button`,{"aria-current":e===`cost-monitor`?`page`:void 0,className:e===`cost-monitor`?`is-active`:void 0,onClick:()=>i(`cost-monitor`),type:`button`,children:[(0,m.jsx)(Ee,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.costs}),(0,m.jsx)(`small`,{children:r.costsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`operations`?`page`:void 0,className:e===`operations`?`is-active`:void 0,onClick:()=>i(`operations`),type:`button`,children:[(0,m.jsx)(k,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.operations}),(0,m.jsx)(`small`,{children:r.operationsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`traceability`?`page`:void 0,className:e===`traceability`?`is-active`:void 0,onClick:()=>i(`traceability`),type:`button`,children:[(0,m.jsx)(A,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.traceability}),(0,m.jsx)(`small`,{children:r.traceabilityHint})]})]})]})}function k(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-square-kanban`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`rect`,{height:`18`,rx:`2`,width:`18`,x:`3`,y:`3`}),(0,m.jsx)(`path`,{d:`M8 7v7`}),(0,m.jsx)(`path`,{d:`M12 7v4`}),(0,m.jsx)(`path`,{d:`M16 7v9`})]})}function Ee(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-circle-dollar-sign`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,m.jsx)(`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}),(0,m.jsx)(`path`,{d:`M12 18V6`})]})}function A(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-route`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,m.jsx)(`path`,{d:`M9 19h6.5a3.5 3.5 0 0 0 0-7h-7a3.5 3.5 0 0 1 0-7H18`}),(0,m.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]})}function De({currency:e,locale:t,onCurrencyChange:n,onHelpOpen:r,onNavigate:i,pricingSetupPath:a,projectSetupPath:o,costCalculationGuidePath:s}){return(0,m.jsxs)(`div`,{className:`dashboard-global-settings`,children:[(0,m.jsxs)(`label`,{children:[(0,m.jsx)(`span`,{children:t===`pt-BR`?`Moeda`:`Currency`}),(0,m.jsxs)(`select`,{"aria-label":t===`pt-BR`?`Moeda`:`Currency`,onChange:e=>n(e.target.value),value:e,children:[(0,m.jsx)(`option`,{value:`BRL`,children:`BRL · Real brasileiro`}),(0,m.jsx)(`option`,{value:`USD`,children:`USD · US Dollar`})]})]}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:r,type:`button`,children:t===`pt-BR`?`Central de Ajuda`:`Open help and guides`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(a),type:`button`,children:t===`pt-BR`?`Configurar preços e câmbio`:`Configure pricing and FX`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(o),type:`button`,children:t===`pt-BR`?`Configurar projeto`:`Configure project`})]})}var Oe=class{token;constructor(e){this.token=e}ready(){return this.get(`/api/v2/ready`)}operations(e,t=`detail`,n,r=!1){let a=`${i.operations}?scope=${t}${r?`&fresh=1`:``}`;return this.get(P(a,e),n)}sqliteViewPage(e,t,n={},r){let i=new URLSearchParams({view:e,offset:String(n.offset??0)});return n.limit!==void 0&&i.set(`limit`,String(n.limit)),n.query&&i.set(`query`,n.query),n.status&&i.set(`status`,n.status),n.risk&&i.set(`risk`,n.risk),n.provider&&i.set(`provider`,n.provider),n.model&&i.set(`model`,n.model),n.agent&&i.set(`agent`,n.agent),n.phase&&i.set(`phase`,n.phase),n.origin&&i.set(`origin`,n.origin),n.workType&&i.set(`workType`,n.workType),n.priority&&i.set(`priority`,n.priority),n.kind&&i.set(`kind`,n.kind),this.get(P(`/api/v2/sqlite-views?${i.toString()}`,t),r)}operationsBoard(e,t,n=0,r,a,o=4){let s=new URLSearchParams({scope:`board`,stage:t,offset:String(n),limit:String(o)});return r?.query&&s.set(`query`,r.query),r?.status&&s.set(`status`,r.status),r?.risk&&s.set(`risk`,r.risk),r?.origin&&s.set(`origin`,r.origin),r?.kind&&s.set(`kind`,r.kind),this.get(P(`${i.operations}?${s.toString()}`,e),a)}operationsClassification(e,t,n,r=0,a,o=50){let s=new URLSearchParams({scope:`classification`,kind:t,classification:n,offset:String(r),limit:String(o)});return this.get(P(`${i.operations}?${s.toString()}`,e),a)}operationsEntityPage(e,t,n=0,r,a){let o=j(t,n,r);return this.get(P(`${i.operations}/runs?${o}`,e),a)}operationsLifecyclePage(e,t,n=0,r,a){let o=j(t,n,r);return this.get(P(`${i.operations}/entities?${o}`,e),a)}operationsReadModelPage(e,t,n=0,r=50,a=``,o){let s=new URLSearchParams({kind:t,offset:String(n),limit:String(r)});return a&&s.set(`query`,a),this.get(P(`${i.operations}/read-models?${s.toString()}`,e),o)}costMonitor(e=`BRL`,t,n=`detail`,r,a,o=!1){let s=new URLSearchParams({currency:e,scope:n});o&&s.set(`fresh`,`1`);for(let[e,t]of Object.entries(a??{}))t&&s.set(e,t);return this.get(P(`${i.costMonitor}?${s.toString()}`,t),r)}costMonitorRuns(e=`BRL`,t,n,r=100,a,o){let s=new URLSearchParams({currency:e,scope:`runs`,offset:String(n),limit:String(r)});for(let[e,t]of Object.entries(o??{}))t&&s.set(e,t);return this.get(P(`${i.costMonitor}?${s.toString()}`,t),a)}snapshot(e=`BRL`,t){return this.get(P(`${i.snapshot}?currency=${e}`,t))}reconcileOpenWork(e=`BRL`,t){return this.post(P(`${i.reconcileOpenWork}?currency=${e}`,t),ke)}refreshProjection(e=`BRL`,t){return this.post(P(`${i.refreshProjection}?currency=${e}`,t),ke)}task(e){return this.get(i.task(e))}prd(e){return this.get(i.prd(e))}spec(e){return this.get(i.spec(e))}taskTrace(e,t){return this.get(i.taskTrace(e),t)}pricing(){return this.get(`/api/v2/pricing`)}async savePricing(e){let t=await fetch(`/api/v2/pricing`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok)throw Error(`Pricing update failed with HTTP ${t.status}`);return await t.json()}fxRate(){return this.get(`/api/v2/fx-rate`)}agentCatalog(){return this.get(i.agentCatalog)}agentPortraitUrl(e){return`/api/v2/agent-catalog-assets/${encodeURIComponent(e)}?token=${encodeURIComponent(this.token)}`}projectSettings(){return this.get(i.projectSettings)}projectOverview(){return this.get(`${i.projectSettings}/overview`)}async saveWorkPriority(e){let t=await fetch(i.workPriority,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({item_ids:e})});if(!t.ok)throw Error(`Work priority update failed with HTTP ${t.status}`);return await t.json()}async saveProjectSettings(e){let t=await fetch(i.projectSettings,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Project settings update failed with HTTP ${t.status}`)}return await t.json()}async saveAgentCatalog(e){let t=e.map(({nickname_candidates:e,...t})=>t),n=await fetch(i.agentCatalog,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({agents:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Agent catalog update failed with HTTP ${n.status}`)}return await n.json()}async saveFxRate(e){let t=await fetch(`/api/v2/fx-rate`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({rate:e})});if(!t.ok)throw Error(`FX update failed with HTTP ${t.status}`);return await t.json()}async get(e,t){let n=await N(e,{cache:`no-cache`,headers:{"x-zaip-session":this.token}},M,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}async post(e,t=M){let n=await N(e,{method:`POST`,headers:{"x-zaip-session":this.token}},t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}};function j(e,t,n){let r=new URLSearchParams({kind:e,offset:String(t),limit:`100`});return n?.query&&r.set(`query`,n.query),n?.status&&r.set(`status`,n.status),n?.risk&&r.set(`risk`,n.risk),r.toString()}var M=6e4,ke=18e4;async function N(e,t,n=M,r){let i=new AbortController,a=()=>i.abort();r?.addEventListener(`abort`,a,{once:!0}),r?.aborted&&i.abort();let o=window.setTimeout(()=>i.abort(),n);try{return await fetch(e,{...t,signal:i.signal})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`A leitura demorou mais de ${Math.ceil(n/1e3)} segundos. Tente novamente.`):e}finally{window.clearTimeout(o),r?.removeEventListener(`abort`,a)}}function P(e,t){if(t===void 0)return e;let n=new URL(e,`http://dashboard.local`);return t.from!==null&&n.searchParams.set(`from`,t.from),t.to!==null&&n.searchParams.set(`to`,t.to),`${n.pathname}${n.search}`}var Ae={preset:`all`,range:a(`this-month`)};function F(e){return e.preset===`all`?{from:null,to:null}:{from:e.range.start,to:e.range.end}}function je(e,t){return e.preset===`all`&&t.preset===`all`}var Me=1500;function Ne({snapshotUpdating:e,initialDataPending:t,dismissed:n,delayElapsed:r}){return e&&t&&!n&&r}function Pe({cursor:e,page:t,tasks:n}){let r=new Map(n.map(e=>[e.id,e]));for(let e of t.tasks)r.set(e.id,e);let i=e.offset+t.tasks.length;return{tasks:[...r.values()],cursor:t.tasks.length===0||i>=t.total?{offset:0,stageIndex:e.stageIndex+1}:{...e,offset:i}}}function Fe(e,t,n){return Math.min(t,e+n)}function I(e){return typeof e==`number`?e:null}function L(e){return typeof e==`number`?{known_sum:e,unknown:0,complete:!0,coverage_ratio:1}:{known_sum:0,unknown:1,complete:!1,coverage_ratio:0}}function Ie(e){return Object.hasOwn(e,`total_duration`)?I(e.total_duration):I(e.cost_monitor_total_duration)}function Le(e,t,n){let{filters:r,query:i}=e;return{offset:t,limit:n,...i===void 0||i===``?{}:{query:i},...r.provider?{provider:r.provider}:{},...r.model?{model:r.model}:{},...r.agent?{agent:r.agent}:{},...r.phase?{phase:r.phase}:{},...r.status?{status:r.status}:{},...r.origin?{origin:r.origin}:{},...r.workType?{workType:r.workType}:{},...r.priority?{priority:r.priority}:{},...r.risk?{risk:r.risk}:{}}}function R(e){let t=Ie(e),n=Number(e.duration_unknown??+(t===null)),r=I(e.duration_known)??t??0;return{key:String(e.key??e.period_key??`total`),label:String(e.label??e.key??e.period_key??``),latest_started_at:typeof e.latest_started_at==`string`?e.latest_started_at:``,persona:typeof e.persona==`string`?e.persona:null,job:typeof e.job==`string`?e.job:null,run_count:Number(e.total_run_count??e.invocation_count??0),task_count:I(e.task_count),prd_count:Number(e.prd_count??0),spec_count:Number(e.spec_count??0),evidence_count:Number(e.evidence_count??0),test_count:Number(e.validation_count??0),event_count:Number(e.source_event_count??0),total_tokens:I(e.total_tokens),estimated_usd:I(e.total_cost_usd),estimated_brl:I(e.total_cost_brl),duration_ms:t,duration:{known_sum:r,unknown:n,complete:n===0,coverage_ratio:+(n===0)},coverage:{events:0,tokens:0,usd:0,brl:0}}}async function Re(e,t){let{from:n,limit:r,offset:i,signal:a,to:o,view:s}=t,c=n===void 0||o===void 0?void 0:{from:n,to:o};if(s===`daily`){let n=await e.sqliteViewPage(`cost_monitor_daily`,c,Le(t,i,r),a);return{offset:n.offset,limit:n.limit,total_count:n.total_count,has_more:n.has_more,rows:n.rows.map(R),...n.totals===void 0?{}:{totals:R(n.totals)}}}let l={monthly:`cost_monitor_monthly`,annual:`cost_monitor_annual`,agents:`cost_monitor_zaip_agents`,models:`cost_monitor_models`,providers:`cost_monitor_providers`}[s],u=await e.sqliteViewPage(l,c,Le(t,i,r),a);return{offset:u.offset,limit:u.limit,total_count:u.total_count,has_more:u.has_more,rows:u.rows.map(R),...u.totals===void 0?{}:{totals:R(u.totals)}}}async function z(e,t){let{filters:n,from:r,limit:i=10,offset:a,signal:o,to:s}=t,c=await e.sqliteViewPage(`cost_monitor_agent_invocations`,r===void 0||s===void 0?void 0:{from:r,to:s},{offset:a,limit:i,...n?.query?{query:n.query}:{},...n?.provider?{provider:n.provider}:{},...n?.model?{model:n.model}:{},...n?.agent?{agent:n.agent}:{},...n?.phase?{phase:n.phase}:{},...n?.status?{status:n.status}:{}},o);return{page_only:!0,runs:c.rows.map(ze),run_page:{offset:c.offset,limit:c.limit,total:c.total_count,has_more:c.has_more}}}function ze(e){let t=(e,t)=>typeof e==`string`?e:t,n=e=>typeof e==`number`?e:null,r=t(e.agent_invocation_id,`unavailable`),i=typeof e.task_id==`string`?e.task_id:null,a=typeof e.spec_id==`string`?e.spec_id:null,o=typeof e.prd_id==`string`?e.prd_id:null,s=t(e.phase,`execution`),c=e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`estimated`||e.duration_provenance===`legacy_inferred`?e.duration_provenance:`unavailable`,l=Object.hasOwn(e,`calculated_cost_usd`)?n(e.calculated_cost_usd):n(e.cost_usd),u=n(e.current_fx_rate)??n(e.fx_rate),d=n(e.recorded_cost_usd)??n(e.recorded_usd),f=Object.hasOwn(e,`recorded_fx_rate`)?n(e.recorded_fx_rate):n(e.fx_rate),p=n(e.recorded_brl)??(!Object.hasOwn(e,`recorded_brl`)&&d!==null?n(e.cost_brl):null),m=l!==null&&u!==null?Math.round(l*u*1e6)/1e6:null;return{run_id:r,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:t(e.run_id,r),task_id:i,task_title:t(e.task_title,i??`Tarefa avulsa`),task_status:t(e.task_status,`unavailable`),priority:t(e.priority,`unavailable`),risk:t(e.risk,`unavailable`),spec_id:a,prd_id:o,change_id:typeof e.change_id==`string`?e.change_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_role:e.invocation_kind===`subagent`?`subagent`:`orchestrator`,run_kind:e.run_kind===`subrun`?`subrun`:`run`,run_purpose:`execution`,requires_finalizer:!1,client:t(e.client,`unavailable`),agent:t(e.zaip_agent,`unavailable`),agent_name:t(e.zaip_agent,`unavailable`),provider:typeof e.provider==`string`?e.provider:null,model:t(e.model,`unavailable`),requested_model:t(e.requested_model,`unavailable`),reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,effective_reasoning_effort:typeof e.effective_reasoning_effort==`string`?e.effective_reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,call_count:n(e.llm_call_count),status:t(e.status,`completed`),phase:s,origin:o===null?a===null?i===null?`conversation`:`task`:`spec`:`prd`,work_type:e.work_type===`rework`?`rework`:`new`,started_at:t(e.occurred_at,``),finished_at:typeof e.finished_at==`string`?e.finished_at:null,duration_ms:n(e.duration_ms),duration_provenance:c,estimation_basis:typeof e.estimation_basis==`string`?e.estimation_basis:null,source_started_at:typeof e.source_started_at==`string`?e.source_started_at:null,source_finished_at:typeof e.source_finished_at==`string`?e.source_finished_at:null,capture_lag_ms:n(e.capture_lag_ms),event_count:n(e.source_event_count),input_tokens:n(e.input_tokens),cached_input_tokens:n(e.cached_input_tokens),output_tokens:n(e.output_tokens),reasoning_tokens:n(e.reasoning_tokens),total_tokens:n(e.total_tokens),uncached_input_tokens:n(e.uncached_input_tokens),visible_output_tokens:n(e.visible_output_tokens),input_rate_usd_per_million:n(e.input_rate_usd_per_million),cached_input_rate_usd_per_million:n(e.cached_input_rate_usd_per_million),output_rate_usd_per_million:n(e.output_rate_usd_per_million),reasoning_rate_usd_per_million:n(e.reasoning_rate_usd_per_million),context_input_multiplier:n(e.context_input_multiplier),context_output_multiplier:n(e.context_output_multiplier),speed_cost_multiplier:n(e.speed_cost_multiplier),standard_cost_usd:n(e.standard_cost_usd),speed_uplift_usd:n(e.speed_uplift_usd),input_cost_usd:n(e.input_cost_usd),cached_input_cost_usd:n(e.cached_input_cost_usd),output_cost_usd:n(e.output_cost_usd),reasoning_cost_usd:n(e.reasoning_cost_usd),fx_rate:u,estimated_usd:l,estimated_brl:m,recorded_usd:d,recorded_brl:p,recorded_fx_rate:f,coverage:{events:0,tokens:0,usd:0,brl:0},artifact_path:`.agents/records/runs/${r}`}}function Be(e,t){let n=t.totals,r=e=>L(n?.[e]);return{data_source:`lifecycle_daily_read_models`,snapshot_id:null,source_latest_at:null,kind:e,offset:t.offset,limit:t.limit,total:t.total_count,has_more:t.has_more,next_cursor:null,subtotal:{entity_count:typeof n?.entity_count==`number`?n.entity_count:t.total_count,run_count:r(`invocation_count`),metrics:{duration:r(`total_duration`),total_tokens:r(`total_tokens`),cost_brl:r(`total_cost_brl`),cost_usd:r(`total_cost_usd`)}},rows:t.rows.map(t=>({id:String(t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??t.id??`unavailable`),title:String(t.title??t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??`Unavailable`),kind:e===`tasks`?`task`:e===`specs`?`spec`:e===`prds`?`prd`:e===`executions`?`execution`:`conversation`,status:typeof t.status==`string`?t.status:null,risk:typeof t.risk==`string`?t.risk:null,occurred_at:typeof t.occurred_at==`string`?t.occurred_at:typeof t.started_at==`string`?t.started_at:typeof t.last_day==`string`?`${t.last_day}T12:00:00.000Z`:``,parent_id:null,run_count:Number(t.invocation_count??0),cost_currency:`BRL`,metrics:{duration:L(t.total_duration),total_tokens:L(t.total_tokens),cost:L(t.total_cost_brl)}}))}}function Ve(e){return{loadCostDetail:(0,f.useCallback)(async()=>{throw Error(`SQLite Cost Monitor loads the selected paginated view; full detail is disabled.`)},[]),loadCostReadModelPage:(0,f.useCallback)(async({filters:t,from:n,kind:r,limit:i,offset:a,query:o,signal:s,to:c})=>{let l={tasks:`cost_monitor_tasks`,specs:`cost_monitor_specs`,prds:`cost_monitor_prds`,executions:`cost_monitor_executions`,conversations:`cost_monitor_conversations`}[r];return Be(r,await e.sqliteViewPage(l,n===void 0||c===void 0?void 0:{from:n,to:c},{offset:a,limit:i,...o===void 0||o===``?{}:{query:o},...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.agent?{agent:t.agent}:{},...t.phase?{phase:t.phase}:{},...t.status?{status:t.status}:{},...t.origin?{origin:t.origin}:{},...t.workType?{workType:t.workType}:{},...t.priority?{priority:t.priority}:{},...t.risk?{risk:t.risk}:{}},s))},[e]),loadCostRunPage:(0,f.useCallback)(t=>z(e,t),[e]),loadCostGroupPage:(0,f.useCallback)(t=>Re(e,t),[e])}}function He(e,t){return!1}function Ue(e,t=window,n=0){let r=!1,i=!1,a=new AbortController,o=t.setTimeout(()=>{r||i||(i=!0,e(a.signal))},n);return()=>{r||(r=!0,a.abort(),t.clearTimeout(o))}}function We({inFlight:e,lastRefreshAt:t,now:n,visibilityState:r}){return r===`visible`&&!e&&n-t>=5e3}function Ge({api:e,costLocale:t,currency:n,dashboardView:r,loadOperationsDetails:i,operations:a,operationsDetailAbortRef:o,operationsDetailCancelRef:s,operationsPageAbortRef:c,pathname:l,pricing:u,refresh:d,refreshVersion:p,setError:m,setFxRate:h,setPathname:g,setPricing:_}){let v=(0,f.useRef)(!1),y=(0,f.useRef)(0);(0,f.useEffect)(()=>(d(),()=>{s.current?.(),s.current=null,o.current?.abort(),o.current=null,c.current?.abort(),c.current=null,++p.current}),[o,s,c,d,p]),(0,f.useEffect)(()=>{let e=()=>{let e=Date.now();We({inFlight:v.current,lastRefreshAt:y.current,now:e,visibilityState:document.visibilityState})&&(y.current=e,v.current=!0,d(!1,!1,!0).finally(()=>{v.current=!1}))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[d]),(0,f.useEffect)(()=>{if(!He(r,a?.summary.overview_metrics?.partial===!0))return;let e=Ue(async e=>{await i(e)});return s.current=e,()=>{s.current===e&&(s.current=null),e()}},[r,i,a?.summary.overview_metrics?.partial,s]),(0,f.useEffect)(()=>window.localStorage.setItem(ye,t),[t]),(0,f.useEffect)(()=>window.localStorage.setItem(D,n),[n]),(0,f.useEffect)(()=>{[`/`,`/setup-pricing`,`/setup-project`].includes(window.location.pathname)||(window.history.replaceState(null,``,`/${window.location.search}${window.location.hash}`),g(`/`))},[g]),(0,f.useEffect)(()=>{let e=()=>g(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[g]),(0,f.useEffect)(()=>{l!==`/setup-pricing`||u!==null||Promise.all([e.pricing(),e.fxRate()]).then(([e,t])=>{_(e),h(t)}).catch(e=>m(String(e)))},[e,l,u,m,h,_])}var B={events:0,tokens:{input:null,cached_input:null,output:null,reasoning:null,total:null},cost:{usd:null,brl:null},coverage:{events:0,tokens:0,usd:0,brl:0}};function Ke(e,t,n){let r=e=>e===`intake`||e===`orchestration`||e===`execution`||e===`review`||e===`audit`||e===`finalization`?e:`execution`,i=n.rows.map(e=>({id:e.id,artifact_path:`.agents/records/runs/${e.id}`,status:e.status===`running`||e.status===`failed`||e.status===`cancelled`?e.status:`completed`,phase:e.phase??`execution`,entrypoint:e.conversation_id===null?`task`:`conversation`,work_type:`new`,run_role:e.run_kind===`subrun`?`subagent`:`orchestrator`,run_kind:e.run_kind??`run`,run_purpose:r(e.run_purpose),requires_finalizer:!1,parent_run_id:e.parent_run_id,client:e.client??`unknown`,agent:e.agent??`unknown`,agent_name:e.agent??`unknown`,agent_persona:e.agent_persona??null,agent_job:e.agent_job??null,provider:e.provider??null,model:e.model??`unknown`,reasoning_effort:e.reasoning_effort??null,effective_model:e.model??null,effective_reasoning_effort:e.reasoning_effort??null,effective_config_mixed:e.pricing_mixed??!1,service_tier:e.service_tier??null,call_count:e.llm_call_count??null,terminal_call_count:null,failed_call_count:null,cancelled_call_count:null,conversation_id:e.conversation_id??e.id,execution_id:e.execution_id,task_id:e.task_id,spec_id:null,prd_id:null,change_id:null,started_at:e.started_at,finished_at:e.finished_at,duration_ms:e.duration_ms,source_duration_ms:e.source_duration_ms===void 0?e.duration_ms:e.source_duration_ms,duration_provenance:e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`legacy_inferred`||e.duration_provenance===`estimated`?e.duration_provenance:`unavailable`,llm_call_count:e.llm_call_count??null,input_tokens:e.input_tokens??null,cached_input_tokens:e.cached_input_tokens??null,uncached_input_tokens:e.uncached_input_tokens??null,output_tokens:e.output_tokens??null,reasoning_tokens:e.reasoning_tokens??null,visible_output_tokens:e.visible_output_tokens??null,input_rate_usd_per_million:e.input_rate_usd_per_million??null,cached_input_rate_usd_per_million:e.cached_input_rate_usd_per_million??null,output_rate_usd_per_million:e.output_rate_usd_per_million??null,reasoning_rate_usd_per_million:e.reasoning_rate_usd_per_million??null,context_input_multiplier:e.context_input_multiplier??null,context_output_multiplier:e.context_output_multiplier??null,speed_cost_multiplier:e.speed_cost_multiplier??null,pricing_scenario:e.pricing_scenario??null,standard_cost_usd:e.standard_cost_usd??null,speed_uplift_usd:e.speed_uplift_usd??null,input_cost_usd:e.input_cost_usd??null,cached_input_cost_usd:e.cached_input_cost_usd??null,output_cost_usd:e.output_cost_usd??null,reasoning_cost_usd:e.reasoning_cost_usd??null,calculated_cost_usd:e.calculated_cost_usd??null,recorded_cost_usd:e.recorded_cost_usd??null,cost_variance_usd:e.cost_variance_usd??null,cost_usd:e.cost_usd??null,cost_brl:e.currency===`BRL`?e.cost:null,fx_rate:e.fx_rate??null,pricing_segment_count:e.pricing_segment_count??null,pricing_mixed:e.pricing_mixed??!1,pricing_model:e.pricing_model??null,pricing_source:e.pricing_source??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},usage:{conversation:B,planning:B,execution:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},total:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},new_work:B,rework:B}}));return{...e,runs:i,executions:t===`executions`||t===`conversations`?n.rows.map((e,n)=>{let r=i[n],a=r.execution_id??r.conversation_id,o=e.status??`unavailable`;return{id:a,kind:t===`conversations`?`interaction`:`delivery`,created_at:r.started_at,status:o,work_status:o,origin:t===`conversations`?{type:`interaction`,conversation_id:r.conversation_id}:{type:`task`,task_id:r.task_id??`unavailable`},dag:{nodes:[],topological_order:[]},result:null,artifact_path:`.agents/records/executions/${a}`,agent_call_count:0,orchestrator_run_count:0,subagent_run_count:0,finalizer_run_count:0,finalized_task_count:0,llm_call_count:0,llm_call_count_complete:!1,task_count:0,spec_count:0,prd_count:0,duration_ms:r.source_duration_ms??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},total_tokens:r.usage.total.tokens.total,cost_brl:r.usage.total.cost.brl}}):e.executions}}function qe(e){if(typeof e!=`string`)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Je({api:e,entityFiltersRef:t,operationsPageAbortRef:n,operationsPageRequestVersionRef:r,operationsPeriod:i,operationsPeriodRef:a,refreshVersion:o,setEntityPage:s,setEntityPageKind:c,setOperations:l}){return{loadOperationsEntityPage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=F(i),_=()=>C(m,r.current,p.signal)&&x(h,o.current,g,F(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t={runs:`operations_agent_invocations`,executions:`operations_executions`,conversations:`operations_conversations`}[u],n=await e.sqliteViewPage(t,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),r={kind:u,offset:n.offset,limit:n.limit,total:n.total_count,aggregation:`canonical_entity`,rows:n.rows.map(e=>({id:String(e.agent_invocation_id??e.execution_id??e.conversation_id??e.id),started_at:String(e.occurred_at??e.started_at??`1970-01-01T00:00:00.000Z`),finished_at:typeof e.finished_at==`string`?e.finished_at:null,task_id:typeof e.task_id==`string`?e.task_id:null,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:typeof e.conversation_id==`string`?e.conversation_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_kind:e.invocation_kind===`delegated`||e.invocation_kind===`subagent`?`subrun`:e.invocation_kind===`orchestrator`?`run`:null,run_purpose:typeof e.purpose==`string`?e.purpose:null,phase:typeof e.phase==`string`?e.phase:null,status:typeof e.status==`string`?e.status:null,agent:typeof e.zaip_agent==`string`?e.zaip_agent:null,agent_persona:typeof e.zaip_agent_persona==`string`?e.zaip_agent_persona:null,agent_job:typeof e.zaip_agent_job==`string`?e.zaip_agent_job:null,client:typeof e.client==`string`?e.client:null,provider:typeof e.provider==`string`?e.provider:null,model:typeof e.model==`string`?e.model:null,reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,duration_ms:typeof e.duration_ms==`number`?e.duration_ms:typeof e.total_duration==`number`?e.total_duration:null,source_duration_ms:typeof e.source_duration_ms==`number`?e.source_duration_ms:null,duration_provenance:typeof e.duration_provenance==`string`?e.duration_provenance:null,llm_call_count:typeof e.llm_call_count==`number`?e.llm_call_count:null,input_tokens:typeof e.input_tokens==`number`?e.input_tokens:null,cached_input_tokens:typeof e.cached_input_tokens==`number`?e.cached_input_tokens:null,uncached_input_tokens:typeof e.uncached_input_tokens==`number`?e.uncached_input_tokens:null,output_tokens:typeof e.output_tokens==`number`?e.output_tokens:null,reasoning_tokens:typeof e.reasoning_tokens==`number`?e.reasoning_tokens:null,visible_output_tokens:typeof e.visible_output_tokens==`number`?e.visible_output_tokens:null,total_tokens:typeof e.total_tokens==`number`?e.total_tokens:null,input_rate_usd_per_million:typeof e.input_rate_usd_per_million==`number`?e.input_rate_usd_per_million:null,cached_input_rate_usd_per_million:typeof e.cached_input_rate_usd_per_million==`number`?e.cached_input_rate_usd_per_million:null,output_rate_usd_per_million:typeof e.output_rate_usd_per_million==`number`?e.output_rate_usd_per_million:null,reasoning_rate_usd_per_million:typeof e.reasoning_rate_usd_per_million==`number`?e.reasoning_rate_usd_per_million:null,context_input_multiplier:typeof e.context_input_multiplier==`number`?e.context_input_multiplier:null,context_output_multiplier:typeof e.context_output_multiplier==`number`?e.context_output_multiplier:null,speed_cost_multiplier:typeof e.speed_cost_multiplier==`number`?e.speed_cost_multiplier:null,pricing_scenario:typeof e.pricing_scenario==`string`?e.pricing_scenario:null,standard_cost_usd:typeof e.standard_cost_usd==`number`?e.standard_cost_usd:null,speed_uplift_usd:typeof e.speed_uplift_usd==`number`?e.speed_uplift_usd:null,input_cost_usd:typeof e.input_cost_usd==`number`?e.input_cost_usd:null,cached_input_cost_usd:typeof e.cached_input_cost_usd==`number`?e.cached_input_cost_usd:null,output_cost_usd:typeof e.output_cost_usd==`number`?e.output_cost_usd:null,reasoning_cost_usd:typeof e.reasoning_cost_usd==`number`?e.reasoning_cost_usd:null,calculated_cost_usd:typeof e.calculated_cost_usd==`number`?e.calculated_cost_usd:null,recorded_cost_usd:typeof e.recorded_cost_usd==`number`?e.recorded_cost_usd:null,cost_variance_usd:typeof e.cost_variance_usd==`number`?e.cost_variance_usd:null,cost_usd:typeof e.cost_usd==`number`?e.cost_usd:null,fx_rate:typeof e.fx_rate==`number`?e.fx_rate:null,pricing_segment_count:typeof e.pricing_segment_count==`number`?e.pricing_segment_count:null,pricing_mixed:e.pricing_mixed===1||e.pricing_mixed===!0,pricing_model:typeof e.audit_pricing_model==`string`?e.audit_pricing_model:typeof e.pricing_model==`string`?e.pricing_model:null,pricing_source:typeof e.audit_pricing_source==`string`?e.audit_pricing_source:typeof e.pricing_source==`string`?e.pricing_source:null,cost:typeof e.total_cost_brl==`number`?e.total_cost_brl:typeof e.cost_brl==`number`?e.cost_brl:null,currency:`BRL`}))};if(!_())return;l(e=>e===null?e:Ke(e,u,r)),s({offset:r.offset,total:r.total,loading:!1,error:null,aggregation:r.aggregation})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l]),loadOperationsLifecyclePage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=F(i),_=()=>C(m,r.current,p.signal)&&x(h,o.current,g,F(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t=await e.sqliteViewPage(u===`changes`?`operations_changes`:`operations_decisions`,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),n=u===`changes`?t.rows.map(e=>{let t=String(e.source_type),n=String(e.source_id);return{id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:null,status:typeof e.status==`string`?e.status:`unclassified`,risk:typeof e.risk==`string`?e.risk:`unclassified`,source:t===`spec`?{type:`spec`,spec_id:n}:t===`prd`?{type:`prd`,prd_id:n,spec_id:null}:{type:`task`,task_id:n},requirement_ids:qe(e.requirement_ids_json),acceptance_ids:qe(e.acceptance_ids_json),task_ids:qe(e.task_ids_json),result:typeof e.result==`string`?e.result:null,artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id)}}):t.rows.map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),origin:e.origin===`human`?`human`:`agent`,scope_type:e.scope_type===`execution`?`execution`:`change`,scope_id:String(e.scope_id),artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:`1970-01-01T00:00:00.000Z`})),r={kind:u,offset:t.offset,limit:t.limit,total:t.total_count,rows:n};if(!_())return;l(e=>e===null?e:{...e,...u===`changes`?{changes:r.rows}:{decisions:r.rows}}),s({offset:r.offset,total:r.total,loading:!1,error:null})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l])}}function Ye({api:e,operations:t,setError:n,setFailedArea:r,setLoadingArea:i}){let[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)([]),[l,u]=(0,f.useState)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(0),h=(0,f.useRef)(0),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),[y,ee]=(0,f.useState)(``);async function te(a){let c=++h.current;g.current?.abort();let l=new AbortController;g.current=l,n(null),r(null),o(null),v(a),i(`traceability`),await new Promise(e=>window.requestAnimationFrame(()=>e()));try{let n=await e.taskTrace(a,l.signal);if(h.current!==c)return!1;let r=s.find(e=>e.id===a)??t?.tasks.find(e=>e.id===a);return o({...n,task_title:r?.title||n.task_title||a,task_risk:r?.risk||n.task_risk||null,task_created_at:r?.created_at||n.task_created_at||null,task_progress:r?.progress??n.task_progress??0}),!0}catch(e){return l.signal.aborted||h.current!==c?!1:(n(e instanceof Error?e.message:String(e)),r(`traceability`),!1)}finally{h.current===c&&(g.current===l&&(g.current=null),v(null),i(e=>e===`traceability`?null:e))}}function b(e){let n=t?.changes.find(t=>t.id===e);n!==void 0&&(o(null),p({kind:`change`,row:n}))}function x(e,n){let r=(e===`PRD`?t?.prds:t?.specs)?.find(e=>e.id===n);r!==void 0&&(o(null),p({kind:`macro`,label:e,row:r}))}async function S(n,r){let i=(n===`prd`?t?.prds:t?.specs)?.find(e=>e.id===r);if(!i)return;let a=++m.current,o=n===`prd`?`PRD`:`SPEC`;u({kind:n,label:o,preview:i});try{let t=n===`prd`?await e.prd(r):await e.spec(r);if(m.current!==a)return;u({kind:n,label:o,preview:i,detail:t})}catch(e){if(m.current!==a)return;u({kind:n,label:o,preview:i,error:e instanceof Error?e.message:String(e)})}}function ne(){m.current+=1,u(null)}return{closeDocument:ne,documentDetail:l,openDocument:S,openTrace:te,openTraceChange:b,openTraceMacro:x,selectedTraceTaskId:y,setSelectedTraceTaskId:ee,setTrace:o,setTraceLink:p,setTraceLoadingTaskId:v,setTraceTasks:c,trace:a,traceLink:d,traceLoadingTaskId:_,traceTasks:s}}function Xe(e,t){return JSON.stringify([e.query,e.status,e.risk,e.origin??``,e.kind??``,t.from??``,t.to??``])}function Ze(e,t,n){return e===`explicit`||t!==n}function Qe(e,t){return{...e,kind:e.kind??t.kind??``}}var $e={offset:0,limit:10,total:null,hasMore:!1,typeFilter:`all`,rows:[],loading:!1,error:null};function et({api:e,operationsPeriod:t,operationsPeriodRef:n}){let[r,i]=(0,f.useState)($e),a=(0,f.useRef)({query:``,status:``,risk:``}),o=(0,f.useRef)(null),s=(0,f.useRef)(0),c=(0,f.useRef)(null),l=(0,f.useCallback)(async(r,l=0,u=`explicit`)=>{let d=F(t),f=Qe(r,a.current),p=Xe(f,d);if(!Ze(u,p,c.current))return;o.current?.abort();let m=new AbortController;o.current=m;let h=++s.current;a.current=f,c.current=p;let g=f.kind||`all`;i(e=>({...e,offset:l,typeFilter:g,loading:!0,error:null}));try{let t=await e.sqliteViewPage(`operations_work_list`,d,{offset:l,limit:10,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{},...f.origin?{origin:f.origin}:{},...g===`all`?{}:{kind:g}},m.signal);if(m.signal.aborted||h!==s.current||d.from!==F(n.current).from||d.to!==F(n.current).to)return;i({offset:t.offset,limit:t.limit,total:t.total_count,hasMore:t.has_more,typeFilter:g,rows:t.rows,loading:!1,error:null})}catch(e){if(m.signal.aborted||h!==s.current)return;c.current===p&&(c.current=null),i(t=>({...t,offset:l,typeFilter:g,loading:!1,error:e instanceof Error?e.message:String(e)}))}finally{o.current===m&&(o.current=null)}},[e,t,n]),u=(0,f.useCallback)(()=>{o.current?.abort(),o.current=null,++s.current,c.current=null,i($e)},[]);return{workListPage:r,workListFiltersRef:a,loadWorkListFilters:(0,f.useCallback)(e=>l(e,0,`filter-hydration`),[l]),loadWorkListPage:l,resetWorkListPage:u}}async function*tt(e,t){let n=e;for(;;){if(n.rows.length===0)return;yield n.rows;let e=n.offset+n.rows.length;if(!n.has_more||e>=n.total_count)return;n=await t(e)}}function nt({api:e,operationsPeriod:t}){return(0,f.useCallback)((n,r)=>{let i=F(t);if(n===`work-kanban`)return;let a={"work-list":`operations_work_list`,changes:`operations_changes`,decisions:`operations_decisions`,executions:`operations_executions`,runs:`operations_agent_invocations`,conversations:`operations_conversations`,daily:`operations_daily`,monthly:`operations_monthly`,yearly:`operations_annual`}[n];if(a===void 0)return;let o=e=>({offset:e,limit:100,...r.query?{query:r.query}:{},...r.status?{status:r.status}:{},...r.risk?{risk:r.risk}:{},...r.origin?{origin:r.origin}:{},...a===`operations_work_list`&&r.kind?{kind:r.kind}:{}});return{prepare:async()=>{let t=await e.sqliteViewPage(a,i,o(0));return{totalRows:t.total_count,pages:()=>tt(t,t=>e.sqliteViewPage(a,i,o(t)))}}}},[e,t])}var rt=(e,t)=>`${e}:${t}`,it=(e,t)=>`${e}:${t}`,at=[`definition`,`planning`,`ready`,`executing`,`verifying`,`completed`,`blocked`,`cancelled`,`failed`],ot=[`completed`,`executing`,`ready`,`blocked`,`verifying`,`failed`,`cancelled`,`planning`,`definition`];function st(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=(0,f.useMemo)(Se,[]),c=(0,f.useMemo)(()=>new Oe(o),[o]),{loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p}=Ve(c),[h,g]=(0,f.useState)(()=>xe(window.location.pathname)),_=(0,f.useRef)(h);_.current=h;let[v,y]=(0,f.useState)(null),[C,se]=(0,f.useState)({offset:0,total:null,loading:!1,error:null}),[w,ce]=(0,f.useState)(`runs`),T=(0,f.useRef)({query:``,status:``,risk:``}),[le,de]=(0,f.useState)({}),[fe,pe]=(0,f.useState)({}),[ve,E]=(0,f.useState)({}),[ye,D]=(0,f.useState)({}),[Ce,O]=(0,f.useState)({}),[k,Ee]=(0,f.useState)(null),[A,j]=(0,f.useState)(null),[M,ke]=(0,f.useState)(be),[N,P]=(0,f.useState)(()=>window.localStorage.getItem(`zaip-dashboard-currency`)===`USD`?`USD`:`BRL`),Fe=(0,f.useRef)(N);Fe.current=N;let I=(0,f.useCallback)(e=>{ke(e),P(e===`en-US`?`USD`:`BRL`)},[]),[L,Ie]=(0,f.useState)(()=>Ae),Le=L.preset===`all`?null:L.range.start,R=L.preset===`all`?null:L.range.end,Re=(0,f.useMemo)(()=>({from:Le,to:R}),[Le,R]),z=(0,f.useRef)(L);z.current=L;let[ze,Be]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(null),[We,B]=(0,f.useState)(null),[Ke,qe]=(0,f.useState)(window.location.pathname),[Xe,Ze]=(0,f.useState)(!0),[,Qe]=(0,f.useState)(!1),[,$e]=(0,f.useState)(!1),[tt,st]=(0,f.useState)(!1),[ct,V]=(0,f.useState)(`operations`),[lt,H]=(0,f.useState)(null),[ut,dt]=(0,f.useState)(null);(0,f.useEffect)(()=>{c.ready().then(e=>t(e.snapshot_state===`updating`)).catch(()=>{})},[c]);let[ft,U]=(0,f.useState)(null),[pt,mt]=(0,f.useState)(null),[ht,gt]=(0,f.useState)(null),[_t,vt]=(0,f.useState)({title:`Dashboard Zaip AIOS`,repositoryName:``}),{closeDocument:yt,documentDetail:bt,openDocument:xt,openTrace:W,openTraceChange:St,openTraceMacro:Ct,selectedTraceTaskId:wt,setSelectedTraceTaskId:Tt,setTrace:Et,setTraceLink:Dt,setTraceLoadingTaskId:Ot,setTraceTasks:kt,trace:At,traceLink:jt,traceLoadingTaskId:Mt,traceTasks:Nt}=Ye({api:c,operations:v,setError:U,setFailedArea:H,setLoadingArea:V}),G=(0,f.useRef)(Nt),Pt=(0,f.useRef)({offset:0,stageIndex:0}),Ft=(0,f.useRef)(!1),[It,Lt]=(0,f.useState)(!1),[Rt,zt]=(0,f.useState)(!1),K=(0,f.useRef)(0);(0,f.useEffect)(()=>{G.current=Nt},[Nt]);let Bt=(0,f.useRef)(0),Vt=(0,f.useRef)(!1),q=(0,f.useRef)(0),Ht=(0,f.useRef)(0),J=(0,f.useRef)(null),Ut=(0,f.useRef)(!1),Wt=(0,f.useRef)(!1),Gt=(0,f.useRef)(null),Y=(0,f.useRef)(null),Kt=(0,f.useRef)(null),qt=(0,f.useRef)(0),Jt=(0,f.useRef)({}),X=(0,f.useRef)(new Set),Z=(0,f.useRef)(new Map),Yt=(0,f.useRef)(new Set),Xt=(0,f.useRef)(new Set),Zt=(0,f.useRef)({query:``,status:``,risk:``,origin:``,kind:``}),Qt=(0,f.useRef)(`||||`),Q=(0,f.useRef)(0),$t=(0,f.useRef)(void 0),{workListPage:en,workListFiltersRef:tn,loadWorkListFilters:nn,loadWorkListPage:rn,resetWorkListPage:an}=et({api:c,operationsPeriod:L,operationsPeriodRef:z}),on=(0,f.useRef)(!1),sn=(0,f.useCallback)(async(e=!0,t=!1,n=!1)=>{Gt.current?.(),Gt.current=null,Y.current?.abort(),Y.current=null,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({});let r=++K.current,i=Bt.current,a=_.current,o=Re,s=()=>b(r,K.current)&&x(r,K.current,o,F(z.current));e&&(Ze(!0),V(`operations`)),U(null),H(null);try{if(t||n){let e,n=null;if(t){let t=await c.reconcileOpenWork(N,o);n=t.reconciliation,e=t}else e=await c.refreshProjection(N,o);if(!s())return;n!==null&&mt(n),y(e.operations),$t.current=e.operations.summary.overview_metrics,Wt.current=!0,Ee(e.costs),Ut.current=!0,j(null),e.dashboard&&vt({title:e.dashboard.title,repositoryName:e.dashboard.repository_name}),gt(e.projection.source_latest_at)}else{let[e,t]=await Promise.all([c.operations(o,`quick`,void 0,on.current),N===`USD`?c.costMonitor(N,o,`summary`):Promise.resolve(null)]);if(!s())return;on.current=!1,y(e),$t.current=e.summary.overview_metrics,Wt.current=!1,t!==null&&(Ee(t),Ut.current=!1,j(null)),gt(e.summary.source_latest_at)}}catch(e){if(!s())return;U(e instanceof Error?e.message:String(e)),H(a===`cost-monitor`?`costs`:`operations`)}finally{s()&&ne(i,Bt.current)&&st(!1),e&&s()&&(Ze(!1),V(e=>e===`operations`?null:e))}},[c,N,Re]),cn=(0,f.useCallback)(async e=>{if(Wt.current||Vt.current||e?.aborted)return null;Y.current?.abort();let t=e===void 0?new AbortController:null,n=e??t?.signal;if(n===void 0)return null;t!==null&&(Y.current=t),Vt.current=!0,q.current+=1,V(`costs`),H(null);try{let e=++K.current,t=F(L),r=()=>b(e,K.current)&&x(e,K.current,t,F(z.current)),i=await c.operations(t,`detail`,n);return r()?(y(i),Wt.current=!0,i):null}catch(e){return n.aborted||S(e)?null:(U(e instanceof Error?e.message:String(e)),H(`operations`),null)}finally{t!==null&&Y.current===t&&(Y.current=null),Vt.current=!1,q.current=Math.max(0,q.current-1),q.current===0&&V(e=>e===`costs`?null:e)}},[c,L]),{loadOperationsEntityPage:ln,loadOperationsLifecyclePage:un}=Je({api:c,entityFiltersRef:T,operationsPageAbortRef:Kt,operationsPageRequestVersionRef:qt,operationsPeriod:L,operationsPeriodRef:z,refreshVersion:K,setEntityPage:se,setEntityPageKind:ce,setOperations:y}),dn=(0,f.useCallback)((e,t)=>{T.current=t,e===`changes`||e===`decisions`?un(e,0,t):ln(e,0,t)},[ln,un]),fn=(0,f.useCallback)(async e=>{if(v===null||X.current.has(e))return;X.current.add(e),Z.current.get(e)?.abort();let t=new AbortController;Z.current.set(e,t);let n=Q.current,r=F(L);E(t=>({...t,[e]:{loading:!0,error:null}}));let i=Jt.current[e]??0;try{let a=await c.operationsBoard(r,e,i,Zt.current,t.signal,10);if(t.signal.aborted||n!==Q.current||r.from!==F(z.current).from||r.to!==F(z.current).to)return;y(e=>e===null?e:{...re(e,[a]),summary:e.summary}),de(t=>({...t,[e]:a.total})),pe(t=>({...t,[e]:a.totals_by_kind}));let o=i+a.prds.length+a.specs.length+a.tasks.length;Jt.current={...Jt.current,[e]:o}}catch(r){if(t.signal.aborted||n!==Q.current||S(r))return;E(t=>({...t,[e]:{loading:!1,error:r instanceof Error?r.message:String(r)}}))}finally{n===Q.current&&(X.current.delete(e),Z.current.get(e)===t&&Z.current.delete(e),E(t=>t[e]?.error===null?{...t,[e]:{loading:!1,error:null}}:t))}},[c,v,L]),pn=(0,f.useCallback)(e=>{let t={...e,kind:e.kind??Zt.current.kind??``},n=`${t.query}|${t.status}|${t.risk}|${t.origin??``}|${t.kind}`;if(n!==Qt.current){Qt.current=n,Zt.current=t,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({}),y(e=>e===null?e:{...e,prds:[],specs:[],tasks:[],changes:[],summary:n===`||||`&&$t.current!==void 0?{...e.summary,overview_metrics:$t.current}:e.summary})}},[]),mn=(0,f.useCallback)(async(e,t,n)=>{let r=rt(e,t);if(Yt.current.has(r))return;Yt.current.add(r);let i=Q.current,a=F(L);D(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsBoard(a,e,n,{kind:t===`task`?`all-tasks`:t});if(i!==Q.current||a.from!==F(z.current).from||a.to!==F(z.current).to)return;let s=t===`task`?o.tasks:t===`spec`?o.specs:o.prds;D(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==Q.current||S(e))return;D(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Yt.current.delete(r)}},[c,L]),hn=(0,f.useCallback)(async(e,t,n)=>{let r=it(e,t);if(Yt.current.has(r))return;Yt.current.add(r);let i=Q.current,a=F(L);O(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsClassification(a,e,t,n);if(i!==Q.current||a.from!==F(z.current).from||a.to!==F(z.current).to)return;let s=e===`task`?o.tasks:e===`spec`?o.specs:o.prds;O(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==Q.current||S(e))return;O(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Yt.current.delete(r)}},[c,L]),gn=(0,f.useCallback)(e=>{let t={...Zt.current,...e},n=F(L);return{prepare:async()=>{let e=await Promise.all(at.map(e=>c.operationsBoard(n,e,0,t))),r=e=>[...e.prds.map(({kind:e,...t})=>({kind:`prd`,...t})),...e.specs.map(({kind:e,...t})=>({kind:`spec`,...t})),...e.tasks.map(e=>({kind:`task`,...e}))];return{totalRows:e.reduce((e,t)=>e+t.total,0),pages:async function*(){for(let i of e){let e=i,a=0;for(;;){let i=r(e);if(i.length===0||(a+=i.length,yield i,a>=e.total))break;e=await c.operationsBoard(n,e.stage,a,t)}}}}}}},[c,L]),_n=nt({api:c,operationsPeriod:L});(0,f.useEffect)(()=>{if(h!==`operations`||v===null)return;let e=!1,t=async()=>{if(e)return;let t=at.filter(e=>!Xt.current.has(e)&&!X.current.has(e));for(let n=0;n<t.length&&!e;n+=3){let e=t.slice(n,n+3);for(let t of e)Xt.current.add(t);await Promise.all(e.map(e=>fn(e)))}},n=typeof window.requestIdleCallback==`function`?{kind:`idle`,id:window.requestIdleCallback(()=>void t())}:{kind:`timeout`,id:window.setTimeout(()=>void t(),0)};return()=>{e=!0,n.kind===`idle`?window.cancelIdleCallback(n.id):window.clearTimeout(n.id)}},[h,fn,v]);let vn=async e=>{e&&mt(null),dt(e?`reconciling`:`refreshing`),await sn(!1,e,!e),dt(null)};Ge({api:c,costLocale:M,currency:N,dashboardView:h,loadOperationsDetails:cn,operations:v,operationsDetailAbortRef:Y,operationsDetailCancelRef:Gt,operationsPageAbortRef:Kt,pathname:Ke,pricing:He,refresh:sn,refreshVersion:K,setError:U,setFxRate:B,setPathname:qe,setPricing:Ue});let yn=e=>{window.history.pushState(null,``,e),qe(e),window.scrollTo({left:0,top:0})},$=(0,f.useCallback)(async()=>{J.current?.abort();let e=new AbortController;J.current=e;let t=++Ht.current,n=F(L);q.current+=1,V(`costs`),U(null),H(null);try{let r=await c.costMonitor(N,n,`summary`,e.signal),i=F(z.current);if(!te({aborted:e.signal.aborted,currentCurrency:Fe.current,currentPeriod:i,currentRequestVersion:Ht.current,requestVersion:t,requestedCurrency:N,requestedPeriod:n}))return;Ee(r),Ut.current=!0,j(null)}catch(n){if(e.signal.aborted||t!==Ht.current)return;U(n instanceof Error?n.message:String(n)),H(`costs`)}finally{q.current=Math.max(0,q.current-1),q.current===0&&V(e=>e===`costs`?null:e),J.current===e&&(J.current=null)}},[c,N,L]);(0,f.useEffect)(()=>{N!==`USD`||k?.currency===N||$()},[k?.currency,N,$]),(0,f.useEffect)(()=>{h!==`cost-monitor`&&L.preset!==`all`||J.current!==null||ee({costsLoaded:Ut.current,currency:N,snapshotCurrency:k?.currency})&&$()},[k?.currency,N,h,$,L.preset]);let bn=(0,f.useCallback)(async(e=!1,t=!1)=>{if(Ft.current||(t&&(Pt.current={offset:0,stageIndex:0},G.current=[],kt([]),Lt(!0)),Pt.current.stageIndex>=ot.length))return G.current;Ft.current=!0,zt(!0);try{do{let t=Pt.current,n=ot[t.stageIndex];if(n===void 0)break;let r=await c.operationsBoard({from:null,to:null},n,t.offset,{kind:`all-tasks`},void 0,10),i=Pe({cursor:t,page:r,tasks:G.current});if(G.current=i.tasks,kt(G.current),Pt.current=i.cursor,r.tasks.length>0&&!e)break}while(Pt.current.stageIndex<ot.length);return Lt(Pt.current.stageIndex<ot.length),G.current}finally{Ft.current=!1,zt(!1)}},[c,kt]),xn=async e=>{if(g(e),window.scrollTo({left:0,top:0}),e===`cost-monitor`?ee({costsLoaded:Ut.current,currency:N,snapshotCurrency:k?.currency})&&$():J.current?.abort(),e===`traceability`){let e=Nt;if(e.length===0){let t=Q.current;if(e=await bn(!1,!0),t!==Q.current)return;kt(e)}let t=e.toSorted((e,t)=>Date.parse(t.finished_at??t.updated_at)-Date.parse(e.finished_at??e.updated_at)),n=t.find(e=>e.status===`completed`)??t[0];n&&(Tt(n.id),W(n.id));return}Et(null),Ot(null)},Sn=(0,m.jsx)(`div`,{className:`dashboard-capability-shell dashboard-capability-shell--${h??`initial`}`,children:(0,m.jsx)(Te,{activeView:h,locale:M,onChange:e=>void xn(e)})}),Cn=(0,f.useMemo)(()=>new Map((A??k)?.runs.map(e=>[e.run_id,N===`USD`?e.estimated_usd:e.estimated_brl])??[]),[k,N,A]),wn=(0,f.useMemo)(()=>{let e=A??k;return e?.currency===N?N===`USD`?e.overview.estimated_usd:e.overview.estimated_brl:null},[k,N,A]),Tn=(0,f.useMemo)(()=>{let e=A??k;if(e?.currency===N)return{day:e.groups.daily,month:e.groups.monthly,year:e.groups.annual}},[k,N,A]),En=()=>{U(null),lt===`costs`?$():lt===`traceability`&&wt?W(wt):lt===`operations`&&v!==null?cn():sn()},Dn=_e({api:c,costLocale:M,fxRate:We,navigate:yn,pathname:Ke,pricing:He,refresh:sn,setFxRate:B,setPricing:Ue}),On=tt||N===`USD`&&k?.currency!==N,kn=v===null&&Xe;(0,f.useEffect)(()=>{if(!e||!kn||n){a(!1);return}let t=window.setTimeout(()=>a(!0),Me);return()=>window.clearTimeout(t)},[kn,n,e]);let An=Ne({snapshotUpdating:e,initialDataPending:kn,dismissed:n,delayElapsed:i})?(0,m.jsxs)(`div`,{"aria-live":`polite`,className:`app-notice app-snapshot-status`,role:`status`,children:[(0,m.jsx)(`span`,{children:`Exibindo o último snapshot local validado. Os dados canônicos estão sendo atualizados em segundo plano e estarão atuais na próxima abertura.`}),(0,m.jsx)(`button`,{"aria-label":M===`pt-BR`?`Fechar aviso de atualização do snapshot`:`Dismiss snapshot update notice`,onClick:()=>r(!0),type:`button`,children:`×`})]}):null,jn=v;return(0,m.jsxs)(oe,{error:ft,globalLoadingPending:On,locale:M,onRefresh:()=>void sn(),operations:v,snapshotNotice:An,setupRoute:Dn,children:[(0,m.jsxs)(ae,{pending:On,children:[ft?(0,m.jsxs)(`div`,{"aria-live":`assertive`,className:`app-warning app-error`,role:`alert`,children:[(0,m.jsx)(`span`,{children:ft}),lt?(0,m.jsx)(`button`,{onClick:En,type:`button`,children:M===`pt-BR`?`Tentar novamente`:`Try again`}):null,(0,m.jsx)(`button`,{"aria-label":M===`pt-BR`?`Fechar erro`:`Dismiss error`,onClick:()=>U(null),type:`button`,children:`×`})]}):null,(0,m.jsx)(s,{alternateContent:we({costs:k,costLocale:M,currency:N,dashboardView:h,failedArea:lt,lastUpdatedAt:ht,loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p,loadingArea:ct,onActiveDataChange:j,onCurrencyChange:P,onLoadingChange:$e,onLocaleChange:I,onLoadMoreTraceTasks:bn,onOpenTrace:e=>void W(e),onRefresh:()=>dt(`choose`),onRetry:En,onSelectTraceTask:e=>{Tt(e),W(e)},onOpenTraceChange:St,onOpenTraceMacro:Ct,operations:jn,selectedTraceTaskId:wt,trace:At,traceLoadingTaskId:Mt,traceTasksHasMore:It,traceTasksLoading:Rt,traceTasks:Nt}),capabilityNavigation:Sn,boardTotals:le,boardKindTotals:fe,boardExportSource:gn,detailExportSource:_n,boardStates:ve,data:jn,datePreset:L.preset,dateRange:L.range,entityPage:C,dashboardTitle:_t.title,repositoryName:_t.repositoryName,loading:Xe,locale:M,currency:N,factualCostTotal:wn,factualCostPeriods:Tn,onLoadingChange:Qe,resolveRunCost:k===null?void 0:e=>Cn.get(e)??null,onLocaleChange:I,onDetailDataRequest:e=>{let t=e===`conversations`?`conversations`:e===`executions`?`executions`:e===`runs`?`runs`:null;t===null?e===`changes`||e===`decisions`?un(e):cn():ln(t)},onLoadMacroMetrics:()=>void cn(),onEntityPageChange:e=>{w===`changes`||w===`decisions`?un(w,e):ln(w,e)},onEntityFiltersChange:dn,onBoardFiltersChange:pn,onWorkListFiltersChange:nn,onWorkListPageChange:e=>void rn(tn.current,e),onBoardTypeChange:e=>pn({...Zt.current,kind:e===`all`?``:e}),onWorkListTypeChange:e=>void rn({...tn.current,kind:e===`all`?``:e}),onLoadMoreBoard:e=>void fn(e),workListPage:en,statusPage:(e,t)=>ye[rt(e,t)],onLoadStatusPage:(e,t,n)=>void mn(e,t,n),classificationPage:(e,t)=>Ce[it(e,t)],onLoadClassificationPage:(e,t,n)=>void hn(e,t,n),onOpenDocument:(e,t)=>void xt(e,t),onOpenTask:W,onPriorityChange:async e=>{try{await c.saveWorkPriority(e)}catch(e){throw U(e instanceof Error?e.message:String(e)),e}},onDateChange:(e,t)=>{let n={preset:e,range:t};if(je(z.current,n)){Ie(n);return}Wt.current=!1,Gt.current?.(),Gt.current=null,Y.current?.abort(),Y.current=null,Kt.current?.abort(),Kt.current=null,an(),++qt.current,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({}),++K.current,J.current?.abort(),J.current=null,++Ht.current,se({offset:0,total:null,loading:!1,error:null}),Ut.current=!1,Ee(null),j(null),Ze(!0),Bt.current+=1,st(!0),V(`operations`),Ie(n)},onRefresh:()=>dt(`choose`),settings:(0,m.jsx)(De,{costCalculationGuidePath:ge,currency:N,locale:M,onCurrencyChange:P,onHelpOpen:()=>Be(!0),onNavigate:yn,pricingSetupPath:me,projectSetupPath:he})}),(0,m.jsx)(ue,{closeDocument:yt,costLocale:M,documentDetail:bt,helpOpen:ze,loadingArea:h===`cost-monitor`&&k===null?null:ct,operations:jn,reconciliationResult:pt,refreshDialog:ut,showTrace:h===`traceability`,trace:At,traceLink:jt,traceLoadingTaskId:Mt,onCloseHelp:()=>Be(!1),onCloseTrace:()=>Et(null),onDismissReconciliation:()=>mt(null),onOpenDocument:(e,t)=>void xt(e,t),onOpenTrace:e=>void W(e),onOpenTraceChange:St,onOpenTraceMacro:Ct,onRefreshCancel:()=>dt(null),onRefreshFromDialog:e=>void vn(e),setTraceLink:e=>Dt(e)})]}),On?(0,m.jsx)(ie,{}):null]})}var ct=document.getElementById(`root`);if(!ct)throw Error(`Elemento #root não encontrado`);(0,p.createRoot)(ct).render((0,m.jsx)(f.StrictMode,{children:(0,m.jsx)(st,{})}));export{Fe as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardHelpDialog-VcLx9iOO.js","assets/cost-monitor-C09KmlSw.js","assets/rolldown-runtime-D9-fqq9M.js","assets/cost-monitor-PoJA2PI1.css","assets/dashboard-localization-CLJ0lT9v.js","assets/DashboardHelpDialog-Je5nK-Et.css","assets/PricingSettingsDialog-CyjMXkm8.js","assets/ProjectSettingsPage-BwnJpl02.js","assets/ProjectSettingsPage-GgzpZ_PY.css","assets/CostCalculationGuidePage-DwVZOmMV.js","assets/TraceabilityWorkspace-DFZwIXSC.js","assets/traceability-I4AKqVDX.js","assets/icons-vendor-DXBOtWNI.js","assets/traceability-DFY7ZDlu.css","assets/TraceabilityWorkspace-DvvavDLY.css"])))=>i.map(i=>d[i]);
2
+ import{S as e,a as t,b as n,g as r,h as i,i as a,n as o,r as s,t as c}from"./cost-monitor-C09KmlSw.js";import{t as l}from"./react-vendor-DaNXQPyk.js";import{n as u,t as d}from"./traceability-I4AKqVDX.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(),p=l(),m=n();function h({locale:e}){let t=e===`pt-BR`?[`Definição`,`Planejamento`,`Pronto para Executar`,`Execução`,`Verificação`]:[`Definition`,`Planning`,`Ready to Execute`,`Execution`,`Verification`];return(0,m.jsxs)(`main`,{"aria-busy":`true`,"aria-live":`polite`,"aria-label":e===`pt-BR`?`Preparando dashboard`:`Preparing dashboard`,className:`app-skeleton`,role:`status`,children:[(0,m.jsxs)(`header`,{className:`app-skeleton-header`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`h1`,{children:`Dashboard Zaip AIOS`})]}),(0,m.jsxs)(`div`,{className:`app-skeleton-actions`,children:[(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{}),(0,m.jsx)(`span`,{})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-kpis`,"aria-hidden":`true`,children:Array.from({length:4},(e,t)=>`skeleton-kpi-${t}`).map(e=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-short`}),(0,m.jsx)(`span`,{className:`app-skeleton-value`}),(0,m.jsx)(`span`,{className:`app-skeleton-line`})]},e))}),(0,m.jsxs)(`section`,{className:`app-skeleton-panels`,"aria-hidden":`true`,children:[(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart`})]}),(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`div`,{className:`app-skeleton-chart app-skeleton-chart-small`})]})]}),(0,m.jsx)(`section`,{className:`app-skeleton-board`,"aria-hidden":`true`,children:t.map((e,t)=>(0,m.jsxs)(`article`,{children:[(0,m.jsx)(`h2`,{children:e}),Array.from({length:t%2==0?2:1},(t,n)=>`${e}-${n}`).map(e=>(0,m.jsxs)(`div`,{className:`app-skeleton-card`,children:[(0,m.jsx)(`span`,{className:`app-skeleton-line`}),(0,m.jsx)(`span`,{className:`app-skeleton-line app-skeleton-line-medium`}),(0,m.jsx)(`span`,{className:`app-skeleton-pill`})]},e))]},e))})]})}function g(e,t){let n=t===`pt-BR`;return e===`costs`?n?{title:`Carregando Monitor de Custos…`,detail:`Isso costuma levar poucos segundos.`}:{title:`Loading Cost Monitor…`,detail:`This usually takes a few seconds.`}:e===`traceability`?n?{title:`Carregando Rastreabilidade…`,detail:`Estamos preparando as 6 etapas da task.`}:{title:`Loading Traceability…`,detail:`Preparing the task's 6 stages.`}:n?{title:`Atualizando dados do dashboard…`,detail:`Você pode continuar navegando.`}:{title:`Refreshing dashboard data…`,detail:`You can keep navigating.`}}function _({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-busy":`true`,"aria-live":`polite`,className:`app-loading-panel`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function v({area:e,locale:t}){let n=g(e,t);return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:n.title}),(0,m.jsx)(`span`,{children:n.detail})]})]})}function y({locale:e,onRetry:t}){return(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-loading-panel app-loading-panel-error`,role:`status`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Não foi possível carregar os custos`:`Couldn't load costs`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`A tela continua disponível. Tente novamente quando quiser.`:`The dashboard remains available. Try again whenever you want.`})]}),(0,m.jsx)(`button`,{onClick:t,type:`button`,children:e===`pt-BR`?`Tentar novamente`:`Try again`})]})}function ee({costsLoaded:e,currency:t,snapshotCurrency:n}){return!e||n!==t}function te({aborted:e,currentCurrency:t,currentPeriod:n,currentRequestVersion:r,requestVersion:i,requestedCurrency:a,requestedPeriod:o}){return!e&&i===r&&a===t&&o.from===n.from&&o.to===n.to}function b(e,t){return e===t}function x(e,t,n,r){return b(e,t)&&n.from===r.from&&n.to===r.to}function S(e){return e instanceof DOMException&&e.name===`AbortError`}function ne(e,t){return e===t}function C(e,t,n){return b(e,t)&&!n.aborted}function re(e,t){let n=e=>[...new Map(e.map(e=>[e.id,e])).values()];return{...e,prds:n([...e.prds,...t.flatMap(e=>e.prds)]),specs:n([...e.specs,...t.flatMap(e=>e.specs)]),tasks:n([...e.tasks,...t.flatMap(e=>e.tasks)]),changes:n([...e.changes,...t.flatMap(e=>e.changes)])}}function ie(){let e=(0,f.useRef)(null);return(0,f.useEffect)(()=>{e.current?.focus()},[]),(0,m.jsx)(`div`,{"aria-busy":`true`,"aria-live":`polite`,className:`period-transition-overlay`,onKeyDownCapture:e=>e.preventDefault(),ref:e,role:`status`,tabIndex:-1,children:(0,m.jsxs)(`div`,{className:`period-transition-overlay__content`,children:[(0,m.jsx)(`i`,{"aria-hidden":`true`,className:`period-transition-overlay__spinner`}),(0,m.jsx)(`span`,{className:`period-transition-overlay__label`,children:`Carregando...`})]})})}function ae({pending:e,children:t}){return(0,m.jsx)(`div`,{"aria-hidden":e||void 0,inert:e,children:t})}function oe({children:e,error:t,globalLoadingPending:n,locale:r,onRefresh:i,operations:a,snapshotNotice:o,setupRoute:s}){return s===null?t&&a===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:`Dashboard local indisponível`}),(0,m.jsx)(`h1`,{children:`Não foi possível ler o workspace V2.`}),(0,m.jsx)(`pre`,{children:t}),(0,m.jsx)(`button`,{onClick:i,type:`button`,children:`Tentar novamente`})]}):a===null?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(h,{locale:r}),o,n?(0,m.jsx)(ie,{}):null]}):e:s}var se=`modulepreload`,w=function(e){return`/`+e},ce={},T=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=w(t,n),t=s(t),t in ce)return;ce[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:se,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},le=(0,f.lazy)(async()=>({default:(await T(async()=>{let{DashboardHelpDialog:e}=await import(`./DashboardHelpDialog-VcLx9iOO.js`);return{DashboardHelpDialog:e}},__vite__mapDeps([0,1,2,3,4,5]))).DashboardHelpDialog}));function ue({costLocale:e,documentDetail:n,helpOpen:i,loadingArea:a,operations:s,reconciliationResult:c,refreshDialog:l,showTrace:p,trace:h,traceLink:g,traceLoadingTaskId:_,closeDocument:y,onCloseHelp:ee,onCloseTrace:te,onDismissReconciliation:b,onOpenDocument:x,onOpenTrace:S,onOpenTraceChange:ne,onOpenTraceMacro:C,onRefreshCancel:re,onRefreshFromDialog:ie,setTraceLink:ae}){return(0,m.jsxs)(m.Fragment,{children:[p?null:_?(0,m.jsx)(d,{locale:e,taskId:_}):h?(0,m.jsx)(u,{locale:e,onClose:te,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),trace:h}):null,g?.kind===`change`?(0,m.jsx)(r,{details:{kind:`change`,row:g.row},locale:e,onClose:()=>ae(null)}):null,g?.kind===`macro`?(0,m.jsx)(t,{label:g.label,locale:e,onClose:()=>ae(null),onOpenDocument:x,onOpenTrace:e=>{ae(null),S(e)},row:g.row,runs:s.runs,specs:s.specs,tasks:s.tasks}):null,n?(0,m.jsx)(o,{detail:n.detail,error:n.error,label:n.label,locale:e,loading:!n.detail&&!n.error,onClose:y,onRetry:()=>x(n.kind,n.preview.id),preview:n.preview}):null,i?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(le,{locale:e,onClose:ee})}):null,l===`choose`?(0,m.jsx)(`div`,{className:`app-refresh-dialog-backdrop`,children:(0,m.jsxs)(`section`,{"aria-label":`Atualizar dashboard`,"aria-modal":`true`,className:`app-refresh-dialog`,role:`dialog`,children:[(0,m.jsx)(`h2`,{children:e===`pt-BR`?`Atualizar dashboard`:`Refresh dashboard`}),(0,m.jsx)(`p`,{children:e===`pt-BR`?`Escolha uma atualização rápida ou reconcilie os itens que ainda estão em aberto.`:`Choose a quick refresh or reconcile work items that are still open.`}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`button`,{onClick:()=>ie(!1),type:`button`,children:e===`pt-BR`?`Apenas atualizar dados`:`Refresh data only`}),(0,m.jsx)(`button`,{onClick:()=>ie(!0),type:`button`,children:e===`pt-BR`?`Reconciliar itens abertos`:`Reconcile open work`})]}),(0,m.jsx)(`button`,{className:`app-refresh-cancel`,onClick:re,type:`button`,children:e===`pt-BR`?`Cancelar`:`Cancel`})]})}):null,l===`refreshing`||l===`reconciling`?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-refresh-status`,role:`status`,children:[(0,m.jsx)(`i`,{}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`strong`,{children:l===`reconciling`?e===`pt-BR`?`Reconciliando itens em aberto…`:`Reconciling open work…`:e===`pt-BR`?`Atualizando dados…`:`Refreshing data…`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`Você pode continuar usando o dashboard.`:`You can keep using the dashboard.`})]})]}):null,c!==null&&l===null?(0,m.jsxs)(`section`,{"aria-live":`polite`,className:`app-reconciliation-result`,role:`status`,children:[(0,m.jsx)(`strong`,{children:e===`pt-BR`?`Resultado da reconciliação manual`:`Manual reconciliation result`}),(0,m.jsx)(`span`,{children:e===`pt-BR`?`${c.reconciled_ids.length} item(ns) reconciliado(s).`:`${c.reconciled_ids.length} item(s) reconciled.`}),c.reconciled_ids.length>0?(0,m.jsx)(`p`,{children:c.reconciled_ids.join(`, `)}):null,c.blocked.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Bloqueados: `:`Blocked: `,c.blocked.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,c.not_reconciled.length>0?(0,m.jsxs)(`p`,{children:[e===`pt-BR`?`Não reconciliados: `:`Not reconciled: `,c.not_reconciled.map(e=>`${e.id}${e.reason===null?``:` (${e.reason})`}`).join(`; `)]}):null,(0,m.jsx)(`button`,{onClick:b,type:`button`,children:e===`pt-BR`?`Fechar`:`Dismiss`})]}):null,a!==null&&a!==`operations`&&l===null?(0,m.jsx)(v,{area:a,locale:e}):null]})}var de=(0,f.lazy)(async()=>({default:(await T(async()=>{let{PricingSettingsPage:e}=await import(`./PricingSettingsDialog-CyjMXkm8.js`);return{PricingSettingsPage:e}},__vite__mapDeps([6,1,2,3,4]))).PricingSettingsPage})),fe=(0,f.lazy)(async()=>({default:(await T(async()=>{let{ProjectSettingsPage:e}=await import(`./ProjectSettingsPage-BwnJpl02.js`);return{ProjectSettingsPage:e}},__vite__mapDeps([7,1,2,3,8]))).ProjectSettingsPage})),pe=(0,f.lazy)(async()=>({default:(await T(async()=>{let{CostCalculationGuidePage:e}=await import(`./CostCalculationGuidePage-DwVZOmMV.js`);return{CostCalculationGuidePage:e}},__vite__mapDeps([9,1,2,3]))).CostCalculationGuidePage})),me=`/setup-pricing`,he=`/setup-project`,ge=`/cost-calculation-guide`;function _e(e){let{api:t,costLocale:n,fxRate:r,navigate:i,pathname:a,pricing:o,refresh:s,setFxRate:c,setPricing:l}=e;return a===`/setup-pricing`?o===null?(0,m.jsxs)(`main`,{className:`app-state`,children:[(0,m.jsx)(`p`,{children:n===`pt-BR`?`Configuração do projeto`:`Project settings`}),(0,m.jsx)(`h1`,{children:n===`pt-BR`?`Carregando catálogo de preços…`:`Loading pricing catalog…`}),(0,m.jsx)(`button`,{onClick:()=>i(`/`),type:`button`,children:n===`pt-BR`?`Voltar ao dashboard`:`Back to dashboard`})]}):(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(de,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`),onSave:async e=>{l(await t.savePricing(e)),await s()},onSaveFxRate:async e=>{c(await t.saveFxRate(e)),await s()}})}):a===`/cost-calculation-guide`&&o!==null?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(pe,{catalog:o,fxRate:r,locale:n,onClose:()=>i(`/`)})}):a===`/setup-project`?(0,m.jsx)(f.Suspense,{fallback:null,children:(0,m.jsx)(fe,{api:t,locale:n,onClose:()=>i(`/`)})}):null}var ve=`/zaip-cost-monitor`,E=`zaip-dashboard-session-token`,ye=`zaip-dashboard-locale`,D=`zaip-dashboard-currency`;function be(){return window.localStorage.getItem(`zaip-dashboard-locale`)===`en-US`?`en-US`:`pt-BR`}function xe(e){return e.replace(/\/+$/,``)===ve?`cost-monitor`:null}function Se(){let e=new URL(window.location.href),t=e.searchParams.get(`token`)??window.localStorage.getItem(`zaip-dashboard-session-token`)??window.sessionStorage.getItem(`zaip-dashboard-session-token`)??``;return t&&(window.localStorage.setItem(E,t),window.sessionStorage.setItem(E,t)),e.searchParams.has(`token`)&&(e.searchParams.delete(`token`),window.history.replaceState(null,``,`${e.pathname}${e.search}${e.hash}`)),t}var Ce=(0,f.lazy)(async()=>({default:(await T(async()=>{let{TraceabilityWorkspace:e}=await import(`./TraceabilityWorkspace-DFZwIXSC.js`);return{TraceabilityWorkspace:e}},__vite__mapDeps([10,1,2,3,11,12,13,14]))).TraceabilityWorkspace}));function we({costs:e,costLocale:t,currency:n,dashboardView:r,failedArea:i,lastUpdatedAt:a,loadCostDetail:o,loadCostReadModelPage:s,loadCostRunPage:l,loadCostGroupPage:u,loadingArea:d,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:ee,onLoadMoreTraceTasks:te,onRefresh:b,onRetry:x,onSelectTraceTask:S,onOpenTraceChange:ne,onOpenTraceMacro:C,operations:re,selectedTraceTaskId:ie,trace:ae,traceLoadingTaskId:oe,traceTasksHasMore:se,traceTasksLoading:w,traceTasks:ce}){return r===`cost-monitor`?e===null?()=>i===`costs`?(0,m.jsx)(y,{locale:t,onRetry:x}):(0,m.jsx)(_,{area:`costs`,locale:t}):r=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`costs`,locale:t}),children:(0,m.jsx)(c,{currency:n,data:e,embedded:!0,globalFilters:r,lastUpdatedAt:a,locale:t,loading:d===`costs`,loadDetail:o,loadReadModelPage:s,loadRunPage:l,loadGroupPage:u,onActiveDataChange:p,onCurrencyChange:h,onLoadingChange:g,onLocaleChange:v,onOpenTrace:ee,onRefresh:b,operations:re})}):r===`traceability`?()=>(0,m.jsx)(f.Suspense,{fallback:(0,m.jsx)(_,{area:`operations`,locale:t}),children:(0,m.jsx)(Ce,{loadingTaskId:oe,locale:t,onOpenChange:ne,onOpenPrd:e=>C(`PRD`,e),onOpenSpec:e=>C(`SPEC`,e),onLoadMoreTasks:te,onSelectTask:S,selectedTaskId:ie,tasks:ce.length>0?ce:re.tasks,hasMoreTasks:se,isLoadingTasks:w,trace:ae})}):r===null?(0,m.jsx)(`span`,{"aria-hidden":`true`,hidden:!0}):void 0}var O={"pt-BR":{label:`Áreas do dashboard`,operations:`Operação`,operationsHint:`Trabalho em andamento e priorização`,costs:`Monitor de Custos`,costsHint:`Tempo, tokens e custo`,traceability:`Rastreabilidade`,traceabilityHint:`Ciclo completo em 6 etapas`},"en-US":{label:`Dashboard areas`,operations:`Operations`,operationsHint:`Lifecycle and work in progress`,costs:`Cost Monitor`,costsHint:`Time, tokens, and cost`,traceability:`Traceability`,traceabilityHint:`Complete 6-stage lifecycle`}};function Te({activeView:e,locale:t,onChange:n}){let r=O[t],i=e=>{n(e),window.requestAnimationFrame(()=>{document.querySelector(`.dashboard-global-controls`)?.scrollIntoView({behavior:`smooth`,block:`start`})})};return(0,m.jsxs)(`nav`,{"aria-label":r.label,className:`dashboard-capability-nav`,children:[(0,m.jsxs)(`button`,{"aria-current":e===`cost-monitor`?`page`:void 0,className:e===`cost-monitor`?`is-active`:void 0,onClick:()=>i(`cost-monitor`),type:`button`,children:[(0,m.jsx)(Ee,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.costs}),(0,m.jsx)(`small`,{children:r.costsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`operations`?`page`:void 0,className:e===`operations`?`is-active`:void 0,onClick:()=>i(`operations`),type:`button`,children:[(0,m.jsx)(k,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.operations}),(0,m.jsx)(`small`,{children:r.operationsHint})]})]}),(0,m.jsxs)(`button`,{"aria-current":e===`traceability`?`page`:void 0,className:e===`traceability`?`is-active`:void 0,onClick:()=>i(`traceability`),type:`button`,children:[(0,m.jsx)(A,{}),(0,m.jsxs)(`span`,{children:[(0,m.jsx)(`strong`,{children:r.traceability}),(0,m.jsx)(`small`,{children:r.traceabilityHint})]})]})]})}function k(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-square-kanban`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`rect`,{height:`18`,rx:`2`,width:`18`,x:`3`,y:`3`}),(0,m.jsx)(`path`,{d:`M8 7v7`}),(0,m.jsx)(`path`,{d:`M12 7v4`}),(0,m.jsx)(`path`,{d:`M16 7v9`})]})}function Ee(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-circle-dollar-sign`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,m.jsx)(`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`}),(0,m.jsx)(`path`,{d:`M12 18V6`})]})}function A(){return(0,m.jsxs)(`svg`,{"aria-hidden":`true`,className:`lucide lucide-route`,viewBox:`0 0 24 24`,children:[(0,m.jsx)(`circle`,{cx:`6`,cy:`19`,r:`3`}),(0,m.jsx)(`path`,{d:`M9 19h6.5a3.5 3.5 0 0 0 0-7h-7a3.5 3.5 0 0 1 0-7H18`}),(0,m.jsx)(`circle`,{cx:`18`,cy:`5`,r:`3`})]})}function De({currency:e,locale:t,onCurrencyChange:n,onHelpOpen:r,onNavigate:i,pricingSetupPath:a,projectSetupPath:o,costCalculationGuidePath:s}){return(0,m.jsxs)(`div`,{className:`dashboard-global-settings`,children:[(0,m.jsxs)(`label`,{children:[(0,m.jsx)(`span`,{children:t===`pt-BR`?`Moeda`:`Currency`}),(0,m.jsxs)(`select`,{"aria-label":t===`pt-BR`?`Moeda`:`Currency`,onChange:e=>n(e.target.value),value:e,children:[(0,m.jsx)(`option`,{value:`BRL`,children:`BRL · Real brasileiro`}),(0,m.jsx)(`option`,{value:`USD`,children:`USD · US Dollar`})]})]}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:r,type:`button`,children:t===`pt-BR`?`Central de Ajuda`:`Open help and guides`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(a),type:`button`,children:t===`pt-BR`?`Configurar preços e câmbio`:`Configure pricing and FX`}),(0,m.jsx)(`button`,{className:`dashboard-help-open`,onClick:()=>i(o),type:`button`,children:t===`pt-BR`?`Configurar projeto`:`Configure project`})]})}var Oe=class{token;constructor(e){this.token=e}ready(){return this.get(`/api/v2/ready`)}operations(e,t=`detail`,n,r=!1){let a=`${i.operations}?scope=${t}${r?`&fresh=1`:``}`;return this.get(P(a,e),n)}sqliteViewPage(e,t,n={},r){let i=new URLSearchParams({view:e,offset:String(n.offset??0)});return n.limit!==void 0&&i.set(`limit`,String(n.limit)),n.query&&i.set(`query`,n.query),n.status&&i.set(`status`,n.status),n.risk&&i.set(`risk`,n.risk),n.provider&&i.set(`provider`,n.provider),n.model&&i.set(`model`,n.model),n.agent&&i.set(`agent`,n.agent),n.phase&&i.set(`phase`,n.phase),n.origin&&i.set(`origin`,n.origin),n.workType&&i.set(`workType`,n.workType),n.priority&&i.set(`priority`,n.priority),n.kind&&i.set(`kind`,n.kind),this.get(P(`/api/v2/sqlite-views?${i.toString()}`,t),r)}operationsBoard(e,t,n=0,r,a,o=4){let s=new URLSearchParams({scope:`board`,stage:t,offset:String(n),limit:String(o)});return r?.query&&s.set(`query`,r.query),r?.status&&s.set(`status`,r.status),r?.risk&&s.set(`risk`,r.risk),r?.origin&&s.set(`origin`,r.origin),r?.kind&&s.set(`kind`,r.kind),this.get(P(`${i.operations}?${s.toString()}`,e),a)}operationsClassification(e,t,n,r=0,a,o=50){let s=new URLSearchParams({scope:`classification`,kind:t,classification:n,offset:String(r),limit:String(o)});return this.get(P(`${i.operations}?${s.toString()}`,e),a)}operationsEntityPage(e,t,n=0,r,a){let o=j(t,n,r);return this.get(P(`${i.operations}/runs?${o}`,e),a)}operationsLifecyclePage(e,t,n=0,r,a){let o=j(t,n,r);return this.get(P(`${i.operations}/entities?${o}`,e),a)}operationsReadModelPage(e,t,n=0,r=50,a=``,o){let s=new URLSearchParams({kind:t,offset:String(n),limit:String(r)});return a&&s.set(`query`,a),this.get(P(`${i.operations}/read-models?${s.toString()}`,e),o)}costMonitor(e=`BRL`,t,n=`detail`,r,a,o=!1){let s=new URLSearchParams({currency:e,scope:n});o&&s.set(`fresh`,`1`);for(let[e,t]of Object.entries(a??{}))t&&s.set(e,t);return this.get(P(`${i.costMonitor}?${s.toString()}`,t),r)}costMonitorRuns(e=`BRL`,t,n,r=100,a,o){let s=new URLSearchParams({currency:e,scope:`runs`,offset:String(n),limit:String(r)});for(let[e,t]of Object.entries(o??{}))t&&s.set(e,t);return this.get(P(`${i.costMonitor}?${s.toString()}`,t),a)}snapshot(e=`BRL`,t){return this.get(P(`${i.snapshot}?currency=${e}`,t))}reconcileOpenWork(e=`BRL`,t){return this.post(P(`${i.reconcileOpenWork}?currency=${e}`,t),ke)}refreshProjection(e=`BRL`,t){return this.post(P(`${i.refreshProjection}?currency=${e}`,t),ke)}task(e){return this.get(i.task(e))}prd(e){return this.get(i.prd(e))}spec(e){return this.get(i.spec(e))}taskTrace(e,t){return this.get(i.taskTrace(e),t)}pricing(){return this.get(`/api/v2/pricing`)}async savePricing(e){let t=await fetch(`/api/v2/pricing`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok)throw Error(`Pricing update failed with HTTP ${t.status}`);return await t.json()}fxRate(){return this.get(`/api/v2/fx-rate`)}agentCatalog(){return this.get(i.agentCatalog)}agentPortraitUrl(e){return`/api/v2/agent-catalog-assets/${encodeURIComponent(e)}?token=${encodeURIComponent(this.token)}`}projectSettings(){return this.get(i.projectSettings)}projectOverview(){return this.get(`${i.projectSettings}/overview`)}async saveWorkPriority(e){let t=await fetch(i.workPriority,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({item_ids:e})});if(!t.ok)throw Error(`Work priority update failed with HTTP ${t.status}`);return await t.json()}async saveProjectSettings(e){let t=await fetch(i.projectSettings,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error??`Project settings update failed with HTTP ${t.status}`)}return await t.json()}async saveAgentCatalog(e){let t=e.map(({nickname_candidates:e,...t})=>t),n=await fetch(i.agentCatalog,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({agents:t})});if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Agent catalog update failed with HTTP ${n.status}`)}return await n.json()}async saveFxRate(e){let t=await fetch(`/api/v2/fx-rate`,{method:`PUT`,headers:{"content-type":`application/json`,"x-zaip-session":this.token},body:JSON.stringify({rate:e})});if(!t.ok)throw Error(`FX update failed with HTTP ${t.status}`);return await t.json()}async get(e,t){let n=await N(e,{cache:`no-cache`,headers:{"x-zaip-session":this.token}},M,t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}async post(e,t=M){let n=await N(e,{method:`POST`,headers:{"x-zaip-session":this.token}},t);if(!n.ok){let e=await n.json().catch(()=>null);throw Error(e?.error??`Dashboard API failed with HTTP ${n.status}`)}return await n.json()}};function j(e,t,n){let r=new URLSearchParams({kind:e,offset:String(t),limit:`100`});return n?.query&&r.set(`query`,n.query),n?.status&&r.set(`status`,n.status),n?.risk&&r.set(`risk`,n.risk),r.toString()}var M=6e4,ke=18e4;async function N(e,t,n=M,r){let i=new AbortController,a=()=>i.abort();r?.addEventListener(`abort`,a,{once:!0}),r?.aborted&&i.abort();let o=window.setTimeout(()=>i.abort(),n);try{return await fetch(e,{...t,signal:i.signal})}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`A leitura demorou mais de ${Math.ceil(n/1e3)} segundos. Tente novamente.`):e}finally{window.clearTimeout(o),r?.removeEventListener(`abort`,a)}}function P(e,t){if(t===void 0)return e;let n=new URL(e,`http://dashboard.local`);return t.from!==null&&n.searchParams.set(`from`,t.from),t.to!==null&&n.searchParams.set(`to`,t.to),`${n.pathname}${n.search}`}var Ae={preset:`all`,range:a(`this-month`)};function F(e){return e.preset===`all`?{from:null,to:null}:{from:e.range.start,to:e.range.end}}function je(e,t){return e.preset===`all`&&t.preset===`all`}var Me=1500;function Ne({snapshotUpdating:e,initialDataPending:t,dismissed:n,delayElapsed:r}){return e&&t&&!n&&r}function Pe({cursor:e,page:t,tasks:n}){let r=new Map(n.map(e=>[e.id,e]));for(let e of t.tasks)r.set(e.id,e);let i=e.offset+t.tasks.length;return{tasks:[...r.values()],cursor:t.tasks.length===0||i>=t.total?{offset:0,stageIndex:e.stageIndex+1}:{...e,offset:i}}}function Fe(e,t,n){return Math.min(t,e+n)}function I(e){return typeof e==`number`?e:null}function L(e){return typeof e==`number`?{known_sum:e,unknown:0,complete:!0,coverage_ratio:1}:{known_sum:0,unknown:1,complete:!1,coverage_ratio:0}}function Ie(e){return Object.hasOwn(e,`total_duration`)?I(e.total_duration):I(e.cost_monitor_total_duration)}function Le(e,t,n){let{filters:r,query:i}=e;return{offset:t,limit:n,...i===void 0||i===``?{}:{query:i},...r.provider?{provider:r.provider}:{},...r.model?{model:r.model}:{},...r.agent?{agent:r.agent}:{},...r.phase?{phase:r.phase}:{},...r.status?{status:r.status}:{},...r.origin?{origin:r.origin}:{},...r.workType?{workType:r.workType}:{},...r.priority?{priority:r.priority}:{},...r.risk?{risk:r.risk}:{}}}function R(e){let t=Ie(e),n=Number(e.duration_unknown??+(t===null)),r=I(e.duration_known)??t??0;return{key:String(e.key??e.period_key??`total`),label:String(e.label??e.key??e.period_key??``),latest_started_at:typeof e.latest_started_at==`string`?e.latest_started_at:``,persona:typeof e.persona==`string`?e.persona:null,job:typeof e.job==`string`?e.job:null,run_count:Number(e.total_run_count??e.invocation_count??0),task_count:I(e.task_count),prd_count:Number(e.prd_count??0),spec_count:Number(e.spec_count??0),evidence_count:Number(e.evidence_count??0),test_count:Number(e.validation_count??0),event_count:Number(e.source_event_count??0),total_tokens:I(e.total_tokens),estimated_usd:I(e.total_cost_usd),estimated_brl:I(e.total_cost_brl),duration_ms:t,duration:{known_sum:r,unknown:n,complete:n===0,coverage_ratio:+(n===0)},coverage:{events:0,tokens:0,usd:0,brl:0}}}async function Re(e,t){let{from:n,limit:r,offset:i,signal:a,to:o,view:s}=t,c=n===void 0||o===void 0?void 0:{from:n,to:o};if(s===`daily`){let n=await e.sqliteViewPage(`cost_monitor_daily`,c,Le(t,i,r),a);return{offset:n.offset,limit:n.limit,total_count:n.total_count,has_more:n.has_more,rows:n.rows.map(R),...n.totals===void 0?{}:{totals:R(n.totals)}}}let l={monthly:`cost_monitor_monthly`,annual:`cost_monitor_annual`,agents:`cost_monitor_zaip_agents`,models:`cost_monitor_models`,providers:`cost_monitor_providers`}[s],u=await e.sqliteViewPage(l,c,Le(t,i,r),a);return{offset:u.offset,limit:u.limit,total_count:u.total_count,has_more:u.has_more,rows:u.rows.map(R),...u.totals===void 0?{}:{totals:R(u.totals)}}}async function z(e,t){let{filters:n,from:r,limit:i=10,offset:a,signal:o,to:s}=t,c=await e.sqliteViewPage(`cost_monitor_agent_invocations`,r===void 0||s===void 0?void 0:{from:r,to:s},{offset:a,limit:i,...n?.query?{query:n.query}:{},...n?.provider?{provider:n.provider}:{},...n?.model?{model:n.model}:{},...n?.agent?{agent:n.agent}:{},...n?.phase?{phase:n.phase}:{},...n?.status?{status:n.status}:{}},o);return{page_only:!0,runs:c.rows.map(ze),run_page:{offset:c.offset,limit:c.limit,total:c.total_count,has_more:c.has_more}}}function ze(e){let t=(e,t)=>typeof e==`string`?e:t,n=e=>typeof e==`number`?e:null,r=t(e.agent_invocation_id,`unavailable`),i=typeof e.task_id==`string`?e.task_id:null,a=typeof e.spec_id==`string`?e.spec_id:null,o=typeof e.prd_id==`string`?e.prd_id:null,s=t(e.phase,`execution`),c=e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`estimated`||e.duration_provenance===`legacy_inferred`?e.duration_provenance:`unavailable`,l=Object.hasOwn(e,`calculated_cost_usd`)?n(e.calculated_cost_usd):n(e.cost_usd),u=n(e.current_fx_rate)??n(e.fx_rate),d=n(e.recorded_cost_usd)??n(e.recorded_usd),f=Object.hasOwn(e,`recorded_fx_rate`)?n(e.recorded_fx_rate):n(e.fx_rate),p=n(e.recorded_brl)??(!Object.hasOwn(e,`recorded_brl`)&&d!==null?n(e.cost_brl):null),m=l!==null&&u!==null?Math.round(l*u*1e6)/1e6:null;return{run_id:r,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:t(e.run_id,r),task_id:i,task_title:t(e.task_title,i??`Tarefa avulsa`),task_status:t(e.task_status,`unavailable`),priority:t(e.priority,`unavailable`),risk:t(e.risk,`unavailable`),spec_id:a,prd_id:o,change_id:typeof e.change_id==`string`?e.change_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_role:e.invocation_kind===`subagent`?`subagent`:`orchestrator`,run_kind:e.run_kind===`subrun`?`subrun`:`run`,run_purpose:`execution`,requires_finalizer:!1,client:t(e.client,`unavailable`),agent:t(e.zaip_agent,`unavailable`),agent_name:t(e.zaip_agent,`unavailable`),provider:typeof e.provider==`string`?e.provider:null,model:t(e.model,`unavailable`),requested_model:t(e.requested_model,`unavailable`),reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,effective_reasoning_effort:typeof e.effective_reasoning_effort==`string`?e.effective_reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,call_count:n(e.llm_call_count),status:t(e.status,`completed`),phase:s,origin:o===null?a===null?i===null?`conversation`:`task`:`spec`:`prd`,work_type:e.work_type===`rework`?`rework`:`new`,started_at:t(e.occurred_at,``),finished_at:typeof e.finished_at==`string`?e.finished_at:null,duration_ms:n(e.duration_ms),duration_provenance:c,estimation_basis:typeof e.estimation_basis==`string`?e.estimation_basis:null,source_started_at:typeof e.source_started_at==`string`?e.source_started_at:null,source_finished_at:typeof e.source_finished_at==`string`?e.source_finished_at:null,capture_lag_ms:n(e.capture_lag_ms),event_count:n(e.source_event_count),input_tokens:n(e.input_tokens),cached_input_tokens:n(e.cached_input_tokens),output_tokens:n(e.output_tokens),reasoning_tokens:n(e.reasoning_tokens),total_tokens:n(e.total_tokens),uncached_input_tokens:n(e.uncached_input_tokens),visible_output_tokens:n(e.visible_output_tokens),input_rate_usd_per_million:n(e.input_rate_usd_per_million),cached_input_rate_usd_per_million:n(e.cached_input_rate_usd_per_million),output_rate_usd_per_million:n(e.output_rate_usd_per_million),reasoning_rate_usd_per_million:n(e.reasoning_rate_usd_per_million),context_input_multiplier:n(e.context_input_multiplier),context_output_multiplier:n(e.context_output_multiplier),speed_cost_multiplier:n(e.speed_cost_multiplier),standard_cost_usd:n(e.standard_cost_usd),speed_uplift_usd:n(e.speed_uplift_usd),input_cost_usd:n(e.input_cost_usd),cached_input_cost_usd:n(e.cached_input_cost_usd),output_cost_usd:n(e.output_cost_usd),reasoning_cost_usd:n(e.reasoning_cost_usd),fx_rate:u,estimated_usd:l,estimated_brl:m,recorded_usd:d,recorded_brl:p,recorded_fx_rate:f,coverage:{events:0,tokens:0,usd:0,brl:0},artifact_path:`.agents/records/runs/${r}`}}function Be(e,t){let n=t.totals,r=e=>L(n?.[e]);return{data_source:`lifecycle_daily_read_models`,snapshot_id:null,source_latest_at:null,kind:e,offset:t.offset,limit:t.limit,total:t.total_count,has_more:t.has_more,next_cursor:null,subtotal:{entity_count:typeof n?.entity_count==`number`?n.entity_count:t.total_count,run_count:r(`invocation_count`),metrics:{duration:r(`total_duration`),total_tokens:r(`total_tokens`),cost_brl:r(`total_cost_brl`),cost_usd:r(`total_cost_usd`)}},rows:t.rows.map(t=>({id:String(t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??t.id??`unavailable`),title:String(t.title??t.task_id??t.spec_id??t.prd_id??t.execution_id??t.conversation_id??`Unavailable`),kind:e===`tasks`?`task`:e===`specs`?`spec`:e===`prds`?`prd`:e===`executions`?`execution`:`conversation`,status:typeof t.status==`string`?t.status:null,risk:typeof t.risk==`string`?t.risk:null,occurred_at:typeof t.occurred_at==`string`?t.occurred_at:typeof t.started_at==`string`?t.started_at:typeof t.last_day==`string`?`${t.last_day}T12:00:00.000Z`:``,parent_id:null,run_count:Number(t.invocation_count??0),cost_currency:`BRL`,metrics:{duration:L(t.total_duration),total_tokens:L(t.total_tokens),cost:L(t.total_cost_brl)}}))}}function Ve(e){return{loadCostDetail:(0,f.useCallback)(async()=>{throw Error(`SQLite Cost Monitor loads the selected paginated view; full detail is disabled.`)},[]),loadCostReadModelPage:(0,f.useCallback)(async({filters:t,from:n,kind:r,limit:i,offset:a,query:o,signal:s,to:c})=>{let l={tasks:`cost_monitor_tasks`,specs:`cost_monitor_specs`,prds:`cost_monitor_prds`,executions:`cost_monitor_executions`,conversations:`cost_monitor_conversations`}[r];return Be(r,await e.sqliteViewPage(l,n===void 0||c===void 0?void 0:{from:n,to:c},{offset:a,limit:i,...o===void 0||o===``?{}:{query:o},...t.provider?{provider:t.provider}:{},...t.model?{model:t.model}:{},...t.agent?{agent:t.agent}:{},...t.phase?{phase:t.phase}:{},...t.status?{status:t.status}:{},...t.origin?{origin:t.origin}:{},...t.workType?{workType:t.workType}:{},...t.priority?{priority:t.priority}:{},...t.risk?{risk:t.risk}:{}},s))},[e]),loadCostRunPage:(0,f.useCallback)(t=>z(e,t),[e]),loadCostGroupPage:(0,f.useCallback)(t=>Re(e,t),[e])}}function He(e,t){return!1}function Ue(e,t=window,n=0){let r=!1,i=!1,a=new AbortController,o=t.setTimeout(()=>{r||i||(i=!0,e(a.signal))},n);return()=>{r||(r=!0,a.abort(),t.clearTimeout(o))}}function We({inFlight:e,lastRefreshAt:t,now:n,visibilityState:r}){return r===`visible`&&!e&&n-t>=5e3}function Ge({api:e,costLocale:t,currency:n,dashboardView:r,loadOperationsDetails:i,operations:a,operationsDetailAbortRef:o,operationsDetailCancelRef:s,operationsPageAbortRef:c,pathname:l,pricing:u,refresh:d,refreshVersion:p,setError:m,setFxRate:h,setPathname:g,setPricing:_}){let v=(0,f.useRef)(!1),y=(0,f.useRef)(0);(0,f.useEffect)(()=>(d(),()=>{s.current?.(),s.current=null,o.current?.abort(),o.current=null,c.current?.abort(),c.current=null,++p.current}),[o,s,c,d,p]),(0,f.useEffect)(()=>{let e=()=>{let e=Date.now();We({inFlight:v.current,lastRefreshAt:y.current,now:e,visibilityState:document.visibilityState})&&(y.current=e,v.current=!0,d(!1,!1,!0).finally(()=>{v.current=!1}))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[d]),(0,f.useEffect)(()=>{if(!He(r,a?.summary.overview_metrics?.partial===!0))return;let e=Ue(async e=>{await i(e)});return s.current=e,()=>{s.current===e&&(s.current=null),e()}},[r,i,a?.summary.overview_metrics?.partial,s]),(0,f.useEffect)(()=>window.localStorage.setItem(ye,t),[t]),(0,f.useEffect)(()=>window.localStorage.setItem(D,n),[n]),(0,f.useEffect)(()=>{[`/`,`/setup-pricing`,`/setup-project`].includes(window.location.pathname)||(window.history.replaceState(null,``,`/${window.location.search}${window.location.hash}`),g(`/`))},[g]),(0,f.useEffect)(()=>{let e=()=>g(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[g]),(0,f.useEffect)(()=>{l!==`/setup-pricing`||u!==null||Promise.all([e.pricing(),e.fxRate()]).then(([e,t])=>{_(e),h(t)}).catch(e=>m(String(e)))},[e,l,u,m,h,_])}var B={events:0,tokens:{input:null,cached_input:null,output:null,reasoning:null,total:null},cost:{usd:null,brl:null},coverage:{events:0,tokens:0,usd:0,brl:0}};function Ke(e,t,n){let r=e=>e===`intake`||e===`orchestration`||e===`execution`||e===`review`||e===`audit`||e===`finalization`?e:`execution`,i=n.rows.map(e=>({id:e.id,artifact_path:`.agents/records/runs/${e.id}`,status:e.status===`running`||e.status===`failed`||e.status===`cancelled`?e.status:`completed`,phase:e.phase??`execution`,entrypoint:e.conversation_id===null?`task`:`conversation`,work_type:`new`,run_role:e.run_kind===`subrun`?`subagent`:`orchestrator`,run_kind:e.run_kind??`run`,run_purpose:r(e.run_purpose),requires_finalizer:!1,parent_run_id:e.parent_run_id,client:e.client??`unknown`,agent:e.agent??`unknown`,agent_name:e.agent??`unknown`,agent_persona:e.agent_persona??null,agent_job:e.agent_job??null,provider:e.provider??null,model:e.model??`unknown`,reasoning_effort:e.reasoning_effort??null,effective_model:e.model??null,effective_reasoning_effort:e.reasoning_effort??null,effective_config_mixed:e.pricing_mixed??!1,service_tier:e.service_tier??null,call_count:e.llm_call_count??null,terminal_call_count:null,failed_call_count:null,cancelled_call_count:null,conversation_id:e.conversation_id??e.id,execution_id:e.execution_id,task_id:e.task_id,spec_id:null,prd_id:null,change_id:null,started_at:e.started_at,finished_at:e.finished_at,duration_ms:e.duration_ms,source_duration_ms:e.source_duration_ms===void 0?e.duration_ms:e.source_duration_ms,duration_provenance:e.duration_provenance===`observed`||e.duration_provenance===`reconciled`||e.duration_provenance===`legacy_inferred`||e.duration_provenance===`estimated`?e.duration_provenance:`unavailable`,llm_call_count:e.llm_call_count??null,input_tokens:e.input_tokens??null,cached_input_tokens:e.cached_input_tokens??null,uncached_input_tokens:e.uncached_input_tokens??null,output_tokens:e.output_tokens??null,reasoning_tokens:e.reasoning_tokens??null,visible_output_tokens:e.visible_output_tokens??null,input_rate_usd_per_million:e.input_rate_usd_per_million??null,cached_input_rate_usd_per_million:e.cached_input_rate_usd_per_million??null,output_rate_usd_per_million:e.output_rate_usd_per_million??null,reasoning_rate_usd_per_million:e.reasoning_rate_usd_per_million??null,context_input_multiplier:e.context_input_multiplier??null,context_output_multiplier:e.context_output_multiplier??null,speed_cost_multiplier:e.speed_cost_multiplier??null,pricing_scenario:e.pricing_scenario??null,standard_cost_usd:e.standard_cost_usd??null,speed_uplift_usd:e.speed_uplift_usd??null,input_cost_usd:e.input_cost_usd??null,cached_input_cost_usd:e.cached_input_cost_usd??null,output_cost_usd:e.output_cost_usd??null,reasoning_cost_usd:e.reasoning_cost_usd??null,calculated_cost_usd:e.calculated_cost_usd??null,recorded_cost_usd:e.recorded_cost_usd??null,cost_variance_usd:e.cost_variance_usd??null,cost_usd:e.cost_usd??null,cost_brl:e.currency===`BRL`?e.cost:null,fx_rate:e.fx_rate??null,pricing_segment_count:e.pricing_segment_count??null,pricing_mixed:e.pricing_mixed??!1,pricing_model:e.pricing_model??null,pricing_source:e.pricing_source??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},usage:{conversation:B,planning:B,execution:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},total:{...B,events:e.llm_call_count??0,tokens:{input:e.input_tokens??null,cached_input:e.cached_input_tokens??null,output:e.output_tokens??null,reasoning:e.reasoning_tokens??null,total:e.total_tokens},cost:{usd:e.cost_usd??null,brl:e.currency===`BRL`?e.cost:null}},new_work:B,rework:B}}));return{...e,runs:i,executions:t===`executions`||t===`conversations`?n.rows.map((e,n)=>{let r=i[n],a=r.execution_id??r.conversation_id,o=e.status??`unavailable`;return{id:a,kind:t===`conversations`?`interaction`:`delivery`,created_at:r.started_at,status:o,work_status:o,origin:t===`conversations`?{type:`interaction`,conversation_id:r.conversation_id}:{type:`task`,task_id:r.task_id??`unavailable`},dag:{nodes:[],topological_order:[]},result:null,artifact_path:`.agents/records/executions/${a}`,agent_call_count:0,orchestrator_run_count:0,subagent_run_count:0,finalizer_run_count:0,finalized_task_count:0,llm_call_count:0,llm_call_count_complete:!1,task_count:0,spec_count:0,prd_count:0,duration_ms:r.source_duration_ms??null,...e.lifecycle_elapsed_ms===void 0?{}:{lifecycle_elapsed_ms:e.lifecycle_elapsed_ms},total_tokens:r.usage.total.tokens.total,cost_brl:r.usage.total.cost.brl}}):e.executions}}function qe(e){if(typeof e!=`string`)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Je({api:e,entityFiltersRef:t,operationsPageAbortRef:n,operationsPageRequestVersionRef:r,operationsPeriod:i,operationsPeriodRef:a,refreshVersion:o,setEntityPage:s,setEntityPageKind:c,setOperations:l}){return{loadOperationsEntityPage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=F(i),_=()=>C(m,r.current,p.signal)&&x(h,o.current,g,F(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t={runs:`operations_agent_invocations`,executions:`operations_executions`,conversations:`operations_conversations`}[u],n=await e.sqliteViewPage(t,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),r={kind:u,offset:n.offset,limit:n.limit,total:n.total_count,aggregation:`canonical_entity`,rows:n.rows.map(e=>({id:String(e.agent_invocation_id??e.execution_id??e.conversation_id??e.id),started_at:String(e.occurred_at??e.started_at??`1970-01-01T00:00:00.000Z`),finished_at:typeof e.finished_at==`string`?e.finished_at:null,task_id:typeof e.task_id==`string`?e.task_id:null,execution_id:typeof e.execution_id==`string`?e.execution_id:null,conversation_id:typeof e.conversation_id==`string`?e.conversation_id:null,parent_run_id:typeof e.parent_agent_invocation_id==`string`?e.parent_agent_invocation_id:null,run_kind:e.invocation_kind===`delegated`||e.invocation_kind===`subagent`?`subrun`:e.invocation_kind===`orchestrator`?`run`:null,run_purpose:typeof e.purpose==`string`?e.purpose:null,phase:typeof e.phase==`string`?e.phase:null,status:typeof e.status==`string`?e.status:null,agent:typeof e.zaip_agent==`string`?e.zaip_agent:null,agent_persona:typeof e.zaip_agent_persona==`string`?e.zaip_agent_persona:null,agent_job:typeof e.zaip_agent_job==`string`?e.zaip_agent_job:null,client:typeof e.client==`string`?e.client:null,provider:typeof e.provider==`string`?e.provider:null,model:typeof e.model==`string`?e.model:null,reasoning_effort:typeof e.reasoning_effort==`string`?e.reasoning_effort:null,service_tier:typeof e.service_tier==`string`?e.service_tier:null,duration_ms:typeof e.duration_ms==`number`?e.duration_ms:typeof e.total_duration==`number`?e.total_duration:null,source_duration_ms:typeof e.source_duration_ms==`number`?e.source_duration_ms:null,duration_provenance:typeof e.duration_provenance==`string`?e.duration_provenance:null,llm_call_count:typeof e.llm_call_count==`number`?e.llm_call_count:null,input_tokens:typeof e.input_tokens==`number`?e.input_tokens:null,cached_input_tokens:typeof e.cached_input_tokens==`number`?e.cached_input_tokens:null,uncached_input_tokens:typeof e.uncached_input_tokens==`number`?e.uncached_input_tokens:null,output_tokens:typeof e.output_tokens==`number`?e.output_tokens:null,reasoning_tokens:typeof e.reasoning_tokens==`number`?e.reasoning_tokens:null,visible_output_tokens:typeof e.visible_output_tokens==`number`?e.visible_output_tokens:null,total_tokens:typeof e.total_tokens==`number`?e.total_tokens:null,input_rate_usd_per_million:typeof e.input_rate_usd_per_million==`number`?e.input_rate_usd_per_million:null,cached_input_rate_usd_per_million:typeof e.cached_input_rate_usd_per_million==`number`?e.cached_input_rate_usd_per_million:null,output_rate_usd_per_million:typeof e.output_rate_usd_per_million==`number`?e.output_rate_usd_per_million:null,reasoning_rate_usd_per_million:typeof e.reasoning_rate_usd_per_million==`number`?e.reasoning_rate_usd_per_million:null,context_input_multiplier:typeof e.context_input_multiplier==`number`?e.context_input_multiplier:null,context_output_multiplier:typeof e.context_output_multiplier==`number`?e.context_output_multiplier:null,speed_cost_multiplier:typeof e.speed_cost_multiplier==`number`?e.speed_cost_multiplier:null,pricing_scenario:typeof e.pricing_scenario==`string`?e.pricing_scenario:null,standard_cost_usd:typeof e.standard_cost_usd==`number`?e.standard_cost_usd:null,speed_uplift_usd:typeof e.speed_uplift_usd==`number`?e.speed_uplift_usd:null,input_cost_usd:typeof e.input_cost_usd==`number`?e.input_cost_usd:null,cached_input_cost_usd:typeof e.cached_input_cost_usd==`number`?e.cached_input_cost_usd:null,output_cost_usd:typeof e.output_cost_usd==`number`?e.output_cost_usd:null,reasoning_cost_usd:typeof e.reasoning_cost_usd==`number`?e.reasoning_cost_usd:null,calculated_cost_usd:typeof e.calculated_cost_usd==`number`?e.calculated_cost_usd:null,recorded_cost_usd:typeof e.recorded_cost_usd==`number`?e.recorded_cost_usd:null,cost_variance_usd:typeof e.cost_variance_usd==`number`?e.cost_variance_usd:null,cost_usd:typeof e.cost_usd==`number`?e.cost_usd:null,fx_rate:typeof e.fx_rate==`number`?e.fx_rate:null,pricing_segment_count:typeof e.pricing_segment_count==`number`?e.pricing_segment_count:null,pricing_mixed:e.pricing_mixed===1||e.pricing_mixed===!0,pricing_model:typeof e.audit_pricing_model==`string`?e.audit_pricing_model:typeof e.pricing_model==`string`?e.pricing_model:null,pricing_source:typeof e.audit_pricing_source==`string`?e.audit_pricing_source:typeof e.pricing_source==`string`?e.pricing_source:null,cost:typeof e.total_cost_brl==`number`?e.total_cost_brl:typeof e.cost_brl==`number`?e.cost_brl:null,currency:`BRL`}))};if(!_())return;l(e=>e===null?e:Ke(e,u,r)),s({offset:r.offset,total:r.total,loading:!1,error:null,aggregation:r.aggregation})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l]),loadOperationsLifecyclePage:(0,f.useCallback)(async(u,d=0,f=t.current)=>{n.current?.abort();let p=new AbortController;n.current=p;let m=++r.current,h=o.current,g=F(i),_=()=>C(m,r.current,p.signal)&&x(h,o.current,g,F(a.current));c(u),s({offset:d,total:null,loading:!0,error:null});try{let t=await e.sqliteViewPage(u===`changes`?`operations_changes`:`operations_decisions`,g,{offset:d,limit:100,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{}},p.signal),n=u===`changes`?t.rows.map(e=>{let t=String(e.source_type),n=String(e.source_id);return{id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:null,status:typeof e.status==`string`?e.status:`unclassified`,risk:typeof e.risk==`string`?e.risk:`unclassified`,source:t===`spec`?{type:`spec`,spec_id:n}:t===`prd`?{type:`prd`,prd_id:n,spec_id:null}:{type:`task`,task_id:n},requirement_ids:qe(e.requirement_ids_json),acceptance_ids:qe(e.acceptance_ids_json),task_ids:qe(e.task_ids_json),result:typeof e.result==`string`?e.result:null,artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id)}}):t.rows.map(e=>({id:String(e.id),title:typeof e.title==`string`?e.title:String(e.id),origin:e.origin===`human`?`human`:`agent`,scope_type:e.scope_type===`execution`?`execution`:`change`,scope_id:String(e.scope_id),artifact_path:typeof e.source_path==`string`?e.source_path:String(e.id),created_at:typeof e.occurred_at==`string`?e.occurred_at:`1970-01-01T00:00:00.000Z`})),r={kind:u,offset:t.offset,limit:t.limit,total:t.total_count,rows:n};if(!_())return;l(e=>e===null?e:{...e,...u===`changes`?{changes:r.rows}:{decisions:r.rows}}),s({offset:r.offset,total:r.total,loading:!1,error:null})}catch(e){if(!_()||S(e))return;s({offset:d,total:null,loading:!1,error:e instanceof Error?e.message:String(e)})}finally{n.current===p&&(n.current=null)}},[e,t,n,r,i,a,o,s,c,l])}}function Ye({api:e,operations:t,setError:n,setFailedArea:r,setLoadingArea:i}){let[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)([]),[l,u]=(0,f.useState)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(0),h=(0,f.useRef)(0),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),[y,ee]=(0,f.useState)(``);async function te(a){let c=++h.current;g.current?.abort();let l=new AbortController;g.current=l,n(null),r(null),o(null),v(a),i(`traceability`),await new Promise(e=>window.requestAnimationFrame(()=>e()));try{let n=await e.taskTrace(a,l.signal);if(h.current!==c)return!1;let r=s.find(e=>e.id===a)??t?.tasks.find(e=>e.id===a);return o({...n,task_title:r?.title||n.task_title||a,task_risk:r?.risk||n.task_risk||null,task_created_at:r?.created_at||n.task_created_at||null,task_progress:r?.progress??n.task_progress??0}),!0}catch(e){return l.signal.aborted||h.current!==c?!1:(n(e instanceof Error?e.message:String(e)),r(`traceability`),!1)}finally{h.current===c&&(g.current===l&&(g.current=null),v(null),i(e=>e===`traceability`?null:e))}}function b(e){let n=t?.changes.find(t=>t.id===e);n!==void 0&&(o(null),p({kind:`change`,row:n}))}function x(e,n){let r=(e===`PRD`?t?.prds:t?.specs)?.find(e=>e.id===n);r!==void 0&&(o(null),p({kind:`macro`,label:e,row:r}))}async function S(n,r){let i=(n===`prd`?t?.prds:t?.specs)?.find(e=>e.id===r);if(!i)return;let a=++m.current,o=n===`prd`?`PRD`:`SPEC`;u({kind:n,label:o,preview:i});try{let t=n===`prd`?await e.prd(r):await e.spec(r);if(m.current!==a)return;u({kind:n,label:o,preview:i,detail:t})}catch(e){if(m.current!==a)return;u({kind:n,label:o,preview:i,error:e instanceof Error?e.message:String(e)})}}function ne(){m.current+=1,u(null)}return{closeDocument:ne,documentDetail:l,openDocument:S,openTrace:te,openTraceChange:b,openTraceMacro:x,selectedTraceTaskId:y,setSelectedTraceTaskId:ee,setTrace:o,setTraceLink:p,setTraceLoadingTaskId:v,setTraceTasks:c,trace:a,traceLink:d,traceLoadingTaskId:_,traceTasks:s}}function Xe(e,t){return JSON.stringify([e.query,e.status,e.risk,e.origin??``,e.kind??``,t.from??``,t.to??``])}function Ze(e,t,n){return e===`explicit`||t!==n}function Qe(e,t){return{...e,kind:e.kind??t.kind??``}}var $e={offset:0,limit:10,total:null,hasMore:!1,typeFilter:`all`,rows:[],loading:!1,error:null};function et({api:e,operationsPeriod:t,operationsPeriodRef:n}){let[r,i]=(0,f.useState)($e),a=(0,f.useRef)({query:``,status:``,risk:``}),o=(0,f.useRef)(null),s=(0,f.useRef)(0),c=(0,f.useRef)(null),l=(0,f.useCallback)(async(r,l=0,u=`explicit`)=>{let d=F(t),f=Qe(r,a.current),p=Xe(f,d);if(!Ze(u,p,c.current))return;o.current?.abort();let m=new AbortController;o.current=m;let h=++s.current;a.current=f,c.current=p;let g=f.kind||`all`;i(e=>({...e,offset:l,typeFilter:g,loading:!0,error:null}));try{let t=await e.sqliteViewPage(`operations_work_list`,d,{offset:l,limit:10,...f.query?{query:f.query}:{},...f.status?{status:f.status}:{},...f.risk?{risk:f.risk}:{},...f.origin?{origin:f.origin}:{},...g===`all`?{}:{kind:g}},m.signal);if(m.signal.aborted||h!==s.current||d.from!==F(n.current).from||d.to!==F(n.current).to)return;i({offset:t.offset,limit:t.limit,total:t.total_count,hasMore:t.has_more,typeFilter:g,rows:t.rows,loading:!1,error:null})}catch(e){if(m.signal.aborted||h!==s.current)return;c.current===p&&(c.current=null),i(t=>({...t,offset:l,typeFilter:g,loading:!1,error:e instanceof Error?e.message:String(e)}))}finally{o.current===m&&(o.current=null)}},[e,t,n]),u=(0,f.useCallback)(()=>{o.current?.abort(),o.current=null,++s.current,c.current=null,i($e)},[]);return{workListPage:r,workListFiltersRef:a,loadWorkListFilters:(0,f.useCallback)(e=>l(e,0,`filter-hydration`),[l]),loadWorkListPage:l,resetWorkListPage:u}}async function*tt(e,t){let n=e;for(;;){if(n.rows.length===0)return;yield n.rows;let e=n.offset+n.rows.length;if(!n.has_more||e>=n.total_count)return;n=await t(e)}}function nt({api:e,operationsPeriod:t}){return(0,f.useCallback)((n,r)=>{let i=F(t);if(n===`work-kanban`)return;let a={"work-list":`operations_work_list`,changes:`operations_changes`,decisions:`operations_decisions`,executions:`operations_executions`,runs:`operations_agent_invocations`,conversations:`operations_conversations`,daily:`operations_daily`,monthly:`operations_monthly`,yearly:`operations_annual`}[n];if(a===void 0)return;let o=e=>({offset:e,limit:100,...r.query?{query:r.query}:{},...r.status?{status:r.status}:{},...r.risk?{risk:r.risk}:{},...r.origin?{origin:r.origin}:{},...a===`operations_work_list`&&r.kind?{kind:r.kind}:{}});return{prepare:async()=>{let t=await e.sqliteViewPage(a,i,o(0));return{totalRows:t.total_count,pages:()=>tt(t,t=>e.sqliteViewPage(a,i,o(t)))}}}},[e,t])}var rt=(e,t)=>`${e}:${t}`,it=(e,t)=>`${e}:${t}`,at=[`definition`,`planning`,`ready`,`executing`,`verifying`,`completed`,`blocked`,`cancelled`,`failed`],ot=[`completed`,`executing`,`ready`,`blocked`,`verifying`,`failed`,`cancelled`,`planning`,`definition`];function st(){let[e,t]=(0,f.useState)(!1),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=(0,f.useMemo)(Se,[]),c=(0,f.useMemo)(()=>new Oe(o),[o]),{loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p}=Ve(c),[h,g]=(0,f.useState)(()=>xe(window.location.pathname)),_=(0,f.useRef)(h);_.current=h;let[v,y]=(0,f.useState)(null),[C,se]=(0,f.useState)({offset:0,total:null,loading:!1,error:null}),[w,ce]=(0,f.useState)(`runs`),T=(0,f.useRef)({query:``,status:``,risk:``}),[le,de]=(0,f.useState)({}),[fe,pe]=(0,f.useState)({}),[ve,E]=(0,f.useState)({}),[ye,D]=(0,f.useState)({}),[Ce,O]=(0,f.useState)({}),[k,Ee]=(0,f.useState)(null),[A,j]=(0,f.useState)(null),[M,ke]=(0,f.useState)(be),[N,P]=(0,f.useState)(()=>window.localStorage.getItem(`zaip-dashboard-currency`)===`USD`?`USD`:`BRL`),Fe=(0,f.useRef)(N);Fe.current=N;let I=(0,f.useCallback)(e=>{ke(e),P(e===`en-US`?`USD`:`BRL`)},[]),[L,Ie]=(0,f.useState)(()=>Ae),Le=L.preset===`all`?null:L.range.start,R=L.preset===`all`?null:L.range.end,Re=(0,f.useMemo)(()=>({from:Le,to:R}),[Le,R]),z=(0,f.useRef)(L);z.current=L;let[ze,Be]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(null),[We,B]=(0,f.useState)(null),[Ke,qe]=(0,f.useState)(window.location.pathname),[Xe,Ze]=(0,f.useState)(!0),[,Qe]=(0,f.useState)(!1),[,$e]=(0,f.useState)(!1),[tt,st]=(0,f.useState)(!1),[ct,V]=(0,f.useState)(`operations`),[lt,H]=(0,f.useState)(null),[ut,dt]=(0,f.useState)(null);(0,f.useEffect)(()=>{c.ready().then(e=>t(e.snapshot_state===`updating`)).catch(()=>{})},[c]);let[ft,U]=(0,f.useState)(null),[pt,mt]=(0,f.useState)(null),[ht,gt]=(0,f.useState)(null),[_t,vt]=(0,f.useState)({title:`Dashboard Zaip AIOS`,repositoryName:``}),{closeDocument:yt,documentDetail:bt,openDocument:xt,openTrace:W,openTraceChange:St,openTraceMacro:Ct,selectedTraceTaskId:wt,setSelectedTraceTaskId:Tt,setTrace:Et,setTraceLink:Dt,setTraceLoadingTaskId:Ot,setTraceTasks:kt,trace:At,traceLink:jt,traceLoadingTaskId:Mt,traceTasks:Nt}=Ye({api:c,operations:v,setError:U,setFailedArea:H,setLoadingArea:V}),G=(0,f.useRef)(Nt),Pt=(0,f.useRef)({offset:0,stageIndex:0}),Ft=(0,f.useRef)(!1),[It,Lt]=(0,f.useState)(!1),[Rt,zt]=(0,f.useState)(!1),K=(0,f.useRef)(0);(0,f.useEffect)(()=>{G.current=Nt},[Nt]);let Bt=(0,f.useRef)(0),Vt=(0,f.useRef)(!1),q=(0,f.useRef)(0),Ht=(0,f.useRef)(0),J=(0,f.useRef)(null),Ut=(0,f.useRef)(!1),Wt=(0,f.useRef)(!1),Gt=(0,f.useRef)(null),Y=(0,f.useRef)(null),Kt=(0,f.useRef)(null),qt=(0,f.useRef)(0),Jt=(0,f.useRef)({}),X=(0,f.useRef)(new Set),Z=(0,f.useRef)(new Map),Yt=(0,f.useRef)(new Set),Xt=(0,f.useRef)(new Set),Zt=(0,f.useRef)({query:``,status:``,risk:``,origin:``,kind:``}),Qt=(0,f.useRef)(`||||`),Q=(0,f.useRef)(0),$t=(0,f.useRef)(void 0),{workListPage:en,workListFiltersRef:tn,loadWorkListFilters:nn,loadWorkListPage:rn,resetWorkListPage:an}=et({api:c,operationsPeriod:L,operationsPeriodRef:z}),on=(0,f.useRef)(!1),sn=(0,f.useCallback)(async(e=!0,t=!1,n=!1)=>{Gt.current?.(),Gt.current=null,Y.current?.abort(),Y.current=null,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({});let r=++K.current,i=Bt.current,a=_.current,o=Re,s=()=>b(r,K.current)&&x(r,K.current,o,F(z.current));e&&(Ze(!0),V(`operations`)),U(null),H(null);try{if(t||n){let e,n=null;if(t){let t=await c.reconcileOpenWork(N,o);n=t.reconciliation,e=t}else e=await c.refreshProjection(N,o);if(!s())return;n!==null&&mt(n),y(e.operations),$t.current=e.operations.summary.overview_metrics,Wt.current=!0,Ee(e.costs),Ut.current=!0,j(null),e.dashboard&&vt({title:e.dashboard.title,repositoryName:e.dashboard.repository_name}),gt(e.projection.source_latest_at)}else{let[e,t]=await Promise.all([c.operations(o,`quick`,void 0,on.current),N===`USD`?c.costMonitor(N,o,`summary`):Promise.resolve(null)]);if(!s())return;on.current=!1,y(e),$t.current=e.summary.overview_metrics,Wt.current=!1,t!==null&&(Ee(t),Ut.current=!1,j(null)),gt(e.summary.source_latest_at)}}catch(e){if(!s())return;U(e instanceof Error?e.message:String(e)),H(a===`cost-monitor`?`costs`:`operations`)}finally{s()&&ne(i,Bt.current)&&st(!1),e&&s()&&(Ze(!1),V(e=>e===`operations`?null:e))}},[c,N,Re]),cn=(0,f.useCallback)(async e=>{if(Wt.current||Vt.current||e?.aborted)return null;Y.current?.abort();let t=e===void 0?new AbortController:null,n=e??t?.signal;if(n===void 0)return null;t!==null&&(Y.current=t),Vt.current=!0,q.current+=1,V(`costs`),H(null);try{let e=++K.current,t=F(L),r=()=>b(e,K.current)&&x(e,K.current,t,F(z.current)),i=await c.operations(t,`detail`,n);return r()?(y(i),Wt.current=!0,i):null}catch(e){return n.aborted||S(e)?null:(U(e instanceof Error?e.message:String(e)),H(`operations`),null)}finally{t!==null&&Y.current===t&&(Y.current=null),Vt.current=!1,q.current=Math.max(0,q.current-1),q.current===0&&V(e=>e===`costs`?null:e)}},[c,L]),{loadOperationsEntityPage:ln,loadOperationsLifecyclePage:un}=Je({api:c,entityFiltersRef:T,operationsPageAbortRef:Kt,operationsPageRequestVersionRef:qt,operationsPeriod:L,operationsPeriodRef:z,refreshVersion:K,setEntityPage:se,setEntityPageKind:ce,setOperations:y}),dn=(0,f.useCallback)((e,t)=>{T.current=t,e===`changes`||e===`decisions`?un(e,0,t):ln(e,0,t)},[ln,un]),fn=(0,f.useCallback)(async e=>{if(v===null||X.current.has(e))return;X.current.add(e),Z.current.get(e)?.abort();let t=new AbortController;Z.current.set(e,t);let n=Q.current,r=F(L);E(t=>({...t,[e]:{loading:!0,error:null}}));let i=Jt.current[e]??0;try{let a=await c.operationsBoard(r,e,i,Zt.current,t.signal,10);if(t.signal.aborted||n!==Q.current||r.from!==F(z.current).from||r.to!==F(z.current).to)return;y(e=>e===null?e:{...re(e,[a]),summary:e.summary}),de(t=>({...t,[e]:a.total})),pe(t=>({...t,[e]:a.totals_by_kind}));let o=i+a.prds.length+a.specs.length+a.tasks.length;Jt.current={...Jt.current,[e]:o}}catch(r){if(t.signal.aborted||n!==Q.current||S(r))return;E(t=>({...t,[e]:{loading:!1,error:r instanceof Error?r.message:String(r)}}))}finally{n===Q.current&&(X.current.delete(e),Z.current.get(e)===t&&Z.current.delete(e),E(t=>t[e]?.error===null?{...t,[e]:{loading:!1,error:null}}:t))}},[c,v,L]),pn=(0,f.useCallback)(e=>{let t={...e,kind:e.kind??Zt.current.kind??``},n=`${t.query}|${t.status}|${t.risk}|${t.origin??``}|${t.kind}`;if(n!==Qt.current){Qt.current=n,Zt.current=t,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({}),y(e=>e===null?e:{...e,prds:[],specs:[],tasks:[],changes:[],summary:n===`||||`&&$t.current!==void 0?{...e.summary,overview_metrics:$t.current}:e.summary})}},[]),mn=(0,f.useCallback)(async(e,t,n)=>{let r=rt(e,t);if(Yt.current.has(r))return;Yt.current.add(r);let i=Q.current,a=F(L);D(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsBoard(a,e,n,{kind:t===`task`?`all-tasks`:t});if(i!==Q.current||a.from!==F(z.current).from||a.to!==F(z.current).to)return;let s=t===`task`?o.tasks:t===`spec`?o.specs:o.prds;D(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==Q.current||S(e))return;D(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Yt.current.delete(r)}},[c,L]),hn=(0,f.useCallback)(async(e,t,n)=>{let r=it(e,t);if(Yt.current.has(r))return;Yt.current.add(r);let i=Q.current,a=F(L);O(e=>({...e,[r]:{items:n===0?[]:e[r]?.items??[],total:e[r]?.total??0,loading:!0,error:null}}));try{let o=await c.operationsClassification(a,e,t,n);if(i!==Q.current||a.from!==F(z.current).from||a.to!==F(z.current).to)return;let s=e===`task`?o.tasks:e===`spec`?o.specs:o.prds;O(e=>({...e,[r]:{items:n===0?s:[...e[r]?.items??[],...s],total:o.total,loading:!1,error:null}}))}catch(e){if(i!==Q.current||S(e))return;O(t=>({...t,[r]:{items:t[r]?.items??[],total:t[r]?.total??0,loading:!1,error:e instanceof Error?e.message:String(e)}}))}finally{Yt.current.delete(r)}},[c,L]),gn=(0,f.useCallback)(e=>{let t={...Zt.current,...e},n=F(L);return{prepare:async()=>{let e=await Promise.all(at.map(e=>c.operationsBoard(n,e,0,t))),r=e=>[...e.prds.map(({kind:e,...t})=>({kind:`prd`,...t})),...e.specs.map(({kind:e,...t})=>({kind:`spec`,...t})),...e.tasks.map(e=>({kind:`task`,...e}))];return{totalRows:e.reduce((e,t)=>e+t.total,0),pages:async function*(){for(let i of e){let e=i,a=0;for(;;){let i=r(e);if(i.length===0||(a+=i.length,yield i,a>=e.total))break;e=await c.operationsBoard(n,e.stage,a,t)}}}}}}},[c,L]),_n=nt({api:c,operationsPeriod:L});(0,f.useEffect)(()=>{if(h!==`operations`||v===null)return;let e=!1,t=async()=>{if(e)return;let t=at.filter(e=>!Xt.current.has(e)&&!X.current.has(e));for(let n=0;n<t.length&&!e;n+=3){let e=t.slice(n,n+3);for(let t of e)Xt.current.add(t);await Promise.all(e.map(e=>fn(e)))}},n=typeof window.requestIdleCallback==`function`?{kind:`idle`,id:window.requestIdleCallback(()=>void t())}:{kind:`timeout`,id:window.setTimeout(()=>void t(),0)};return()=>{e=!0,n.kind===`idle`?window.cancelIdleCallback(n.id):window.clearTimeout(n.id)}},[h,fn,v]);let vn=async e=>{e&&mt(null),dt(e?`reconciling`:`refreshing`),await sn(!1,e,!e),dt(null)};Ge({api:c,costLocale:M,currency:N,dashboardView:h,loadOperationsDetails:cn,operations:v,operationsDetailAbortRef:Y,operationsDetailCancelRef:Gt,operationsPageAbortRef:Kt,pathname:Ke,pricing:He,refresh:sn,refreshVersion:K,setError:U,setFxRate:B,setPathname:qe,setPricing:Ue});let yn=e=>{window.history.pushState(null,``,e),qe(e),window.scrollTo({left:0,top:0})},$=(0,f.useCallback)(async()=>{J.current?.abort();let e=new AbortController;J.current=e;let t=++Ht.current,n=F(L);q.current+=1,V(`costs`),U(null),H(null);try{let r=await c.costMonitor(N,n,`summary`,e.signal),i=F(z.current);if(!te({aborted:e.signal.aborted,currentCurrency:Fe.current,currentPeriod:i,currentRequestVersion:Ht.current,requestVersion:t,requestedCurrency:N,requestedPeriod:n}))return;Ee(r),Ut.current=!0,j(null)}catch(n){if(e.signal.aborted||t!==Ht.current)return;U(n instanceof Error?n.message:String(n)),H(`costs`)}finally{q.current=Math.max(0,q.current-1),q.current===0&&V(e=>e===`costs`?null:e),J.current===e&&(J.current=null)}},[c,N,L]);(0,f.useEffect)(()=>{N!==`USD`||k?.currency===N||$()},[k?.currency,N,$]),(0,f.useEffect)(()=>{h!==`cost-monitor`&&L.preset!==`all`||J.current!==null||ee({costsLoaded:Ut.current,currency:N,snapshotCurrency:k?.currency})&&$()},[k?.currency,N,h,$,L.preset]);let bn=(0,f.useCallback)(async(e=!1,t=!1)=>{if(Ft.current||(t&&(Pt.current={offset:0,stageIndex:0},G.current=[],kt([]),Lt(!0)),Pt.current.stageIndex>=ot.length))return G.current;Ft.current=!0,zt(!0);try{do{let t=Pt.current,n=ot[t.stageIndex];if(n===void 0)break;let r=await c.operationsBoard({from:null,to:null},n,t.offset,{kind:`all-tasks`},void 0,10),i=Pe({cursor:t,page:r,tasks:G.current});if(G.current=i.tasks,kt(G.current),Pt.current=i.cursor,r.tasks.length>0&&!e)break}while(Pt.current.stageIndex<ot.length);return Lt(Pt.current.stageIndex<ot.length),G.current}finally{Ft.current=!1,zt(!1)}},[c,kt]),xn=async e=>{if(g(e),window.scrollTo({left:0,top:0}),e===`cost-monitor`?ee({costsLoaded:Ut.current,currency:N,snapshotCurrency:k?.currency})&&$():J.current?.abort(),e===`traceability`){let e=Nt;if(e.length===0){let t=Q.current;if(e=await bn(!1,!0),t!==Q.current)return;kt(e)}let t=e.toSorted((e,t)=>Date.parse(t.finished_at??t.updated_at)-Date.parse(e.finished_at??e.updated_at)),n=t.find(e=>e.status===`completed`)??t[0];n&&(Tt(n.id),W(n.id));return}Et(null),Ot(null)},Sn=(0,m.jsx)(`div`,{className:`dashboard-capability-shell dashboard-capability-shell--${h??`initial`}`,children:(0,m.jsx)(Te,{activeView:h,locale:M,onChange:e=>void xn(e)})}),Cn=(0,f.useMemo)(()=>new Map((A??k)?.runs.map(e=>[e.run_id,N===`USD`?e.estimated_usd:e.estimated_brl])??[]),[k,N,A]),wn=(0,f.useMemo)(()=>{let e=A??k;return e?.currency===N?N===`USD`?e.overview.estimated_usd:e.overview.estimated_brl:null},[k,N,A]),Tn=(0,f.useMemo)(()=>{let e=A??k;if(e?.currency===N)return{day:e.groups.daily,month:e.groups.monthly,year:e.groups.annual}},[k,N,A]),En=()=>{U(null),lt===`costs`?$():lt===`traceability`&&wt?W(wt):lt===`operations`&&v!==null?cn():sn()},Dn=_e({api:c,costLocale:M,fxRate:We,navigate:yn,pathname:Ke,pricing:He,refresh:sn,setFxRate:B,setPricing:Ue}),On=tt||N===`USD`&&k?.currency!==N,kn=v===null&&Xe;(0,f.useEffect)(()=>{if(!e||!kn||n){a(!1);return}let t=window.setTimeout(()=>a(!0),Me);return()=>window.clearTimeout(t)},[kn,n,e]);let An=Ne({snapshotUpdating:e,initialDataPending:kn,dismissed:n,delayElapsed:i})?(0,m.jsxs)(`div`,{"aria-live":`polite`,className:`app-notice app-snapshot-status`,role:`status`,children:[(0,m.jsx)(`span`,{children:`Exibindo o último snapshot local validado. Os dados canônicos estão sendo atualizados em segundo plano e estarão atuais na próxima abertura.`}),(0,m.jsx)(`button`,{"aria-label":M===`pt-BR`?`Fechar aviso de atualização do snapshot`:`Dismiss snapshot update notice`,onClick:()=>r(!0),type:`button`,children:`×`})]}):null,jn=v;return(0,m.jsxs)(oe,{error:ft,globalLoadingPending:On,locale:M,onRefresh:()=>void sn(),operations:v,snapshotNotice:An,setupRoute:Dn,children:[(0,m.jsxs)(ae,{pending:On,children:[ft?(0,m.jsxs)(`div`,{"aria-live":`assertive`,className:`app-warning app-error`,role:`alert`,children:[(0,m.jsx)(`span`,{children:ft}),lt?(0,m.jsx)(`button`,{onClick:En,type:`button`,children:M===`pt-BR`?`Tentar novamente`:`Try again`}):null,(0,m.jsx)(`button`,{"aria-label":M===`pt-BR`?`Fechar erro`:`Dismiss error`,onClick:()=>U(null),type:`button`,children:`×`})]}):null,(0,m.jsx)(s,{alternateContent:we({costs:k,costLocale:M,currency:N,dashboardView:h,failedArea:lt,lastUpdatedAt:ht,loadCostDetail:l,loadCostReadModelPage:u,loadCostRunPage:d,loadCostGroupPage:p,loadingArea:ct,onActiveDataChange:j,onCurrencyChange:P,onLoadingChange:$e,onLocaleChange:I,onLoadMoreTraceTasks:bn,onOpenTrace:e=>void W(e),onRefresh:()=>dt(`choose`),onRetry:En,onSelectTraceTask:e=>{Tt(e),W(e)},onOpenTraceChange:St,onOpenTraceMacro:Ct,operations:jn,selectedTraceTaskId:wt,trace:At,traceLoadingTaskId:Mt,traceTasksHasMore:It,traceTasksLoading:Rt,traceTasks:Nt}),capabilityNavigation:Sn,boardTotals:le,boardKindTotals:fe,boardExportSource:gn,detailExportSource:_n,boardStates:ve,data:jn,datePreset:L.preset,dateRange:L.range,entityPage:C,dashboardTitle:_t.title,repositoryName:_t.repositoryName,loading:Xe,locale:M,currency:N,factualCostTotal:wn,factualCostPeriods:Tn,onLoadingChange:Qe,resolveRunCost:k===null?void 0:e=>Cn.get(e)??null,onLocaleChange:I,onDetailDataRequest:e=>{let t=e===`conversations`?`conversations`:e===`executions`?`executions`:e===`runs`?`runs`:null;t===null?e===`changes`||e===`decisions`?un(e):cn():ln(t)},onLoadMacroMetrics:()=>void cn(),onEntityPageChange:e=>{w===`changes`||w===`decisions`?un(w,e):ln(w,e)},onEntityFiltersChange:dn,onBoardFiltersChange:pn,onWorkListFiltersChange:nn,onWorkListPageChange:e=>void rn(tn.current,e),onBoardTypeChange:e=>pn({...Zt.current,kind:e===`all`?``:e}),onWorkListTypeChange:e=>void rn({...tn.current,kind:e===`all`?``:e}),onLoadMoreBoard:e=>void fn(e),workListPage:en,statusPage:(e,t)=>ye[rt(e,t)],onLoadStatusPage:(e,t,n)=>void mn(e,t,n),classificationPage:(e,t)=>Ce[it(e,t)],onLoadClassificationPage:(e,t,n)=>void hn(e,t,n),onOpenDocument:(e,t)=>void xt(e,t),onOpenTask:W,onPriorityChange:async e=>{try{await c.saveWorkPriority(e)}catch(e){throw U(e instanceof Error?e.message:String(e)),e}},onDateChange:(e,t)=>{let n={preset:e,range:t};if(je(z.current,n)){Ie(n);return}Wt.current=!1,Gt.current?.(),Gt.current=null,Y.current?.abort(),Y.current=null,Kt.current?.abort(),Kt.current=null,an(),++qt.current,Q.current+=1;for(let e of Z.current.values())e.abort();Z.current.clear(),X.current.clear(),Xt.current.clear(),Jt.current={},de({}),pe({}),E({}),D({}),O({}),++K.current,J.current?.abort(),J.current=null,++Ht.current,se({offset:0,total:null,loading:!1,error:null}),Ut.current=!1,Ee(null),j(null),Ze(!0),Bt.current+=1,st(!0),V(`operations`),Ie(n)},onRefresh:()=>dt(`choose`),settings:(0,m.jsx)(De,{costCalculationGuidePath:ge,currency:N,locale:M,onCurrencyChange:P,onHelpOpen:()=>Be(!0),onNavigate:yn,pricingSetupPath:me,projectSetupPath:he})}),(0,m.jsx)(ue,{closeDocument:yt,costLocale:M,documentDetail:bt,helpOpen:ze,loadingArea:h===`cost-monitor`&&k===null?null:ct,operations:jn,reconciliationResult:pt,refreshDialog:ut,showTrace:h===`traceability`,trace:At,traceLink:jt,traceLoadingTaskId:Mt,onCloseHelp:()=>Be(!1),onCloseTrace:()=>Et(null),onDismissReconciliation:()=>mt(null),onOpenDocument:(e,t)=>void xt(e,t),onOpenTrace:e=>void W(e),onOpenTraceChange:St,onOpenTraceMacro:Ct,onRefreshCancel:()=>dt(null),onRefreshFromDialog:e=>void vn(e),setTraceLink:e=>Dt(e)})]}),On?(0,m.jsx)(ie,{}):null]})}var ct=document.getElementById(`root`);if(!ct)throw Error(`Elemento #root não encontrado`);(0,p.createRoot)(ct).render((0,m.jsx)(f.StrictMode,{children:(0,m.jsx)(st,{})}));export{Fe as t};
@@ -6,7 +6,7 @@
6
6
  <meta name="color-scheme" content="dark light" />
7
7
  <link rel="icon" type="image/png" href="/icon_zaip.png" />
8
8
  <title>ZAIP-AIOS</title>
9
- <script type="module" crossorigin src="/assets/index-Deo_W81f.js"></script>
9
+ <script type="module" crossorigin src="/assets/index-Dyo_wpL4.js"></script>
10
10
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-D9-fqq9M.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/cost-monitor-C09KmlSw.js">
12
12
  <link rel="modulepreload" crossorigin href="/assets/react-vendor-DaNXQPyk.js">
@@ -15,6 +15,7 @@ import {
15
15
  withDetectedStackVersions,
16
16
  } from "./project-settings-model.js";
17
17
  import "./project-settings-page.css";
18
+ import "./project-stack-versions.css";
18
19
 
19
20
  type Locale = "pt-BR" | "en-US";
20
21
  const copy = {
@@ -63,10 +64,16 @@ const copy = {
63
64
  overrides: "Opções avançadas (JSON)",
64
65
  overridesHint:
65
66
  "Use apenas fatos técnicos transversais confirmados. Deixe vazio quando não houver exceções.",
66
- versions: "Versões verificadas no workspace",
67
+ versions: "Versões detectadas no workspace",
67
68
  exact: "Verificada",
68
69
  constraint: "Requisito",
69
70
  versionUnavailable: "Não encontrada",
71
+ runtime: "Runtime do Dashboard",
72
+ installed: "Instalado no projeto",
73
+ missing: "Ausente no projeto",
74
+ bundled: "Empacotado no Dashboard",
75
+ current: "Atual",
76
+ configured: "Configurado",
70
77
  contextGuide:
71
78
  "O contexto começa pelas fontes canônicas e inclui somente arquivos relevantes para a tarefa. Saídas geradas são consultadas apenas em setup, release ou checagem de paridade.",
72
79
  contextDomains:
@@ -118,10 +125,16 @@ const copy = {
118
125
  overrides: "Advanced options (JSON)",
119
126
  overridesHint:
120
127
  "Use only confirmed cross-cutting technical facts. Leave empty when there are no exceptions.",
121
- versions: "Versions verified in the workspace",
128
+ versions: "Versions detected in the workspace",
122
129
  exact: "Verified",
123
130
  constraint: "Requirement",
124
131
  versionUnavailable: "Not found",
132
+ runtime: "Dashboard runtime",
133
+ installed: "Installed in project",
134
+ missing: "Missing from project",
135
+ bundled: "Bundled in Dashboard",
136
+ current: "Current",
137
+ configured: "Configured",
125
138
  contextGuide:
126
139
  "Context starts from canonical sources and includes only files relevant to the task. Generated outputs are consulted only for setup, release, or parity checks.",
127
140
  contextDomains:
@@ -122,6 +122,12 @@ export function StackVersions({
122
122
  versionUnavailable: string;
123
123
  exact: string;
124
124
  constraint: string;
125
+ runtime: string;
126
+ installed: string;
127
+ missing: string;
128
+ bundled: string;
129
+ current: string;
130
+ configured: string;
125
131
  };
126
132
  }) {
127
133
  if (components.length === 0) return null;
@@ -133,14 +139,24 @@ export function StackVersions({
133
139
  <article key={component.name}>
134
140
  <div className="project-stack-version-identity">
135
141
  <strong>{component.name}</strong>
136
- <code>{component.version ?? text.versionUnavailable}</code>
142
+ <code>
143
+ {text.current}: {component.version ?? text.versionUnavailable}
144
+ </code>
145
+ {component.configured_version !== null &&
146
+ component.configured_version !== component.version ? (
147
+ <code>
148
+ {text.configured}: {component.configured_version}
149
+ </code>
150
+ ) : null}
137
151
  </div>
138
152
  <span className={`is-${component.verification}`}>
139
- {component.verification === "exact"
140
- ? text.exact
141
- : component.verification === "constraint"
142
- ? text.constraint
143
- : text.versionUnavailable}
153
+ {component.installation === "runtime"
154
+ ? text.runtime
155
+ : component.installation === "installed"
156
+ ? text.installed
157
+ : component.installation === "bundled"
158
+ ? text.bundled
159
+ : text.missing}
144
160
  </span>
145
161
  {component.source ? <small>{component.source}</small> : null}
146
162
  </article>
@@ -794,8 +794,10 @@ export interface ProjectOverview {
794
794
  stack_components: Array<{
795
795
  name: string;
796
796
  version: string | null;
797
+ configured_version: string | null;
797
798
  source: string | null;
798
799
  verification: "exact" | "constraint" | "unavailable";
800
+ installation: "runtime" | "installed" | "missing" | "bundled";
799
801
  }>;
800
802
  areas: Array<{
801
803
  id:
@@ -60,7 +60,7 @@ export function withDetectedStackVersions(
60
60
  ): StackComponentsDraft {
61
61
  const versions = new Map(
62
62
  detected
63
- .filter((component) => component.verification === "exact" && component.version !== null)
63
+ .filter((component) => component.installation === "installed" && component.version !== null)
64
64
  .map((component) => [component.name.toLowerCase(), component.version as string]),
65
65
  );
66
66
  return Object.fromEntries(
@@ -396,88 +396,6 @@
396
396
  line-height: 1.45;
397
397
  }
398
398
 
399
- .project-stack-versions {
400
- margin: 0 22px 22px;
401
- }
402
-
403
- .project-stack-versions h3 {
404
- margin: 0 0 12px;
405
- font-size: 0.9rem;
406
- }
407
-
408
- .project-stack-versions > div {
409
- display: grid;
410
- grid-template-columns: repeat(2, minmax(0, 1fr));
411
- gap: 8px;
412
- }
413
-
414
- .project-stack-versions article {
415
- display: grid;
416
- grid-template-columns: minmax(0, 1fr) auto;
417
- grid-template-areas:
418
- "identity badge"
419
- "source source";
420
- gap: 7px 12px;
421
- align-items: start;
422
- min-width: 0;
423
- border: 1px solid #dbe4ef;
424
- border-radius: 12px;
425
- padding: 9px 12px;
426
- background: #f8fafc;
427
- }
428
-
429
- .project-stack-version-identity {
430
- display: flex;
431
- grid-area: identity;
432
- align-items: baseline;
433
- gap: 8px;
434
- min-width: 0;
435
- }
436
-
437
- .project-stack-version-identity strong {
438
- min-width: 0;
439
- color: #334155;
440
- font-size: 0.8rem;
441
- }
442
-
443
- .project-stack-version-identity code {
444
- flex: none;
445
- min-width: 0;
446
- color: #0f172a;
447
- font-size: 0.8rem;
448
- overflow-wrap: anywhere;
449
- }
450
-
451
- .project-stack-versions article small {
452
- grid-area: source;
453
- min-width: 0;
454
- color: #64748b;
455
- font-size: 0.68rem;
456
- line-height: 1.35;
457
- overflow-wrap: anywhere;
458
- }
459
-
460
- .project-stack-versions article span {
461
- grid-area: badge;
462
- width: fit-content;
463
- border-radius: 999px;
464
- padding: 3px 6px;
465
- font-size: 0.68rem;
466
- font-weight: 700;
467
- }
468
- .project-stack-versions .is-exact {
469
- background: #f0fdf4;
470
- color: #166534;
471
- }
472
- .project-stack-versions .is-constraint {
473
- background: #fff7ed;
474
- color: #9a3412;
475
- }
476
- .project-stack-versions .is-unavailable {
477
- background: #fef2f2;
478
- color: #b91c1c;
479
- }
480
-
481
399
  .project-settings-advanced summary {
482
400
  min-height: 48px;
483
401
  padding-top: 15px;
@@ -739,28 +657,6 @@
739
657
  grid-template-columns: 1fr;
740
658
  }
741
659
 
742
- .project-stack-versions article {
743
- grid-template-areas:
744
- "identity badge"
745
- "source source";
746
- grid-template-columns: minmax(0, 1fr) auto;
747
- gap: 6px 10px;
748
- align-items: start;
749
- padding: 10px 12px;
750
- }
751
-
752
- .project-stack-versions > div {
753
- grid-template-columns: 1fr;
754
- }
755
-
756
- .project-stack-versions article span {
757
- align-self: start;
758
- }
759
-
760
- .project-stack-versions article small {
761
- text-align: left;
762
- }
763
-
764
660
  .project-stack-table {
765
661
  display: grid;
766
662
  gap: 12px;
@@ -4,6 +4,7 @@ import {
4
4
  buildProjectSettingsPayload,
5
5
  projectSettingsDraft,
6
6
  shortFrameworkVersion,
7
+ withDetectedStackVersions,
7
8
  } from "./project-settings-model.js";
8
9
 
9
10
  const config: ProjectConfigSettings = {
@@ -121,4 +122,29 @@ describe("project settings form mapping", () => {
121
122
  expect(payload.execution).toEqual(configured.execution);
122
123
  expect(payload.assurance).toEqual(configured.assurance);
123
124
  });
125
+
126
+ it("uses only project-local installed package versions to fill an empty form field", () => {
127
+ const draft = projectSettingsDraft(config).components;
128
+ const detected = withDetectedStackVersions(draft, [
129
+ {
130
+ name: "Hono",
131
+ version: "4.12.35",
132
+ configured_version: "4.12.34",
133
+ source: "node_modules/hono/package.json",
134
+ verification: "exact",
135
+ installation: "installed",
136
+ },
137
+ {
138
+ name: "React",
139
+ version: "19.2.7",
140
+ configured_version: "19.2.7",
141
+ source: ".agents/dashboard/apps/frontend/dist",
142
+ verification: "constraint",
143
+ installation: "bundled",
144
+ },
145
+ ]);
146
+
147
+ expect(detected.backend_api.version).toBe("4.12.35");
148
+ expect(detected.web_framework.version).toBe("");
149
+ });
124
150
  });