mastra 1.40.3-alpha.5 → 1.40.3-alpha.7

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 (80) hide show
  1. package/dist/docs/SKILL.md +1 -1
  2. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  3. package/dist/factory/assets/{AlertDialog.es-Rg-H7EnF.js → AlertDialog.es-3WmOEwXa.js} +1 -1
  4. package/dist/factory/assets/{BoardConfigPage-NB2k-1Qh.js → BoardConfigPage-CQcVX8Gf.js} +1 -1
  5. package/dist/factory/assets/{BoardIntakePage-By4eWK1c.js → BoardIntakePage-BwkaGHwo.js} +1 -1
  6. package/dist/factory/assets/{Breadcrumb.es-CKCI3tup.js → Breadcrumb.es-DAMWsvYc.js} +1 -1
  7. package/dist/factory/assets/{ChatHeaderSidebarTrigger-mtBYROhr.js → ChatHeaderSidebarTrigger-RUl38HSh.js} +1 -1
  8. package/dist/factory/assets/{ChatPageLayout-BKZT1lH5.js → ChatPageLayout-DUflHoxO.js} +1 -1
  9. package/dist/factory/assets/{CompositeRoot-BrygrnvW.js → CompositeRoot-DuwlKdte.js} +1 -1
  10. package/dist/factory/assets/{EmptyState-IMGHVwoU-DXFO08zt.js → EmptyState-IMGHVwoU-BG_Y81ux.js} +1 -1
  11. package/dist/factory/assets/{FactorySkillPage-CFnqwmX3.js → FactorySkillPage-C8RLCAac.js} +1 -1
  12. package/dist/factory/assets/{Field.es-DHZ-9qma.js → Field.es-0wnJ5PYU.js} +1 -1
  13. package/dist/factory/assets/{HrefLink-DkNJBJtp.js → HrefLink-B8qef5fl.js} +1 -1
  14. package/dist/factory/assets/{IconArrowRotateClockwise.es-BcQNYkaq.js → IconArrowRotateClockwise.es-rlyZLQNP.js} +1 -1
  15. package/dist/factory/assets/{IconArrowSplitUp.es-D-sYhilw.js → IconArrowSplitUp.es-Dc9FE6G_.js} +1 -1
  16. package/dist/factory/assets/{IconClock.es-DlAabv8B.js → IconClock.es-DLEl_5Yx.js} +1 -1
  17. package/dist/factory/assets/{IconCodeTree.es-HDK0_9QW.js → IconCodeTree.es-BArfyzTq.js} +1 -1
  18. package/dist/factory/assets/{Input-BUZ-jnqE.js → Input-CE799VRP.js} +1 -1
  19. package/dist/factory/assets/{InputNumber.es-CHWsEKgx.js → InputNumber.es-DCXJJF_B.js} +1 -1
  20. package/dist/factory/assets/{KnowledgePage-ByFKHdU-.js → KnowledgePage-CwkQ0e7q.js} +1 -1
  21. package/dist/factory/assets/{MarkdownRenderer-zGEV5K_s-CzimEVDm.js → MarkdownRenderer-By9XK05q-BijTU3K0.js} +1 -1
  22. package/dist/factory/assets/{NewBoardPage-k5fygzRq.js → NewBoardPage-DaQqdcTD.js} +1 -1
  23. package/dist/factory/assets/{NewPage-DWlcaO-z.js → NewPage-YDCidBpi.js} +1 -1
  24. package/dist/factory/assets/{OnboardingPage-BSNZ_waV.js → OnboardingPage-BTmbqYCr.js} +1 -1
  25. package/dist/factory/assets/{RadioGroup-BLrZAwSh.js → RadioGroup-Du9_UyvT.js} +1 -1
  26. package/dist/factory/assets/{RootGuards-BZ_pfW2K.js → RootGuards-rm4Ylv0S.js} +1 -1
  27. package/dist/factory/assets/{RulesPage-DuK6ZgXW.js → RulesPage-BiiMPw6k.js} +1 -1
  28. package/dist/factory/assets/{SessionLayout-DI2J3HER.js → SessionLayout-B5PCTLC_.js} +2 -2
  29. package/dist/factory/assets/{SessionPage-Ck_ASaLK.js → SessionPage-B8yW7UKW.js} +1 -1
  30. package/dist/factory/assets/{SettingsHrefLink-tZUUWydT.js → SettingsHrefLink-Db7cEjn2.js} +1 -1
  31. package/dist/factory/assets/SettingsPage-CkNg5X4l.js +3 -0
  32. package/dist/factory/assets/{Sidebar-zeEMJHoc-Cp0LKo-n.js → Sidebar-zeEMJHoc-DKyBJBJH.js} +1 -1
  33. package/dist/factory/assets/{SignInPage-yQ5EioOJ.js → SignInPage-GDsFKl9j.js} +1 -1
  34. package/dist/factory/assets/{SkillBadges-Cp5_yMjO.js → SkillBadges-0KsadppP.js} +1 -1
  35. package/dist/factory/assets/{SlackConnectionPage-BgbtdrG9.js → SlackConnectionPage-BCzqd05N.js} +1 -1
  36. package/dist/factory/assets/{StackedDiffs-C9sterKQ.js → StackedDiffs-CdQG4t5W.js} +1 -1
  37. package/dist/factory/assets/{TabsRoot-DcVywXPZ.js → TabsRoot-D-RAt6qK.js} +1 -1
  38. package/dist/factory/assets/{boardViews-Dd2NN2MG.js → boardViews-BIfUY2Os.js} +1 -1
  39. package/dist/factory/assets/{buttons-group-DA_wORqQ-pL6Cywsn.js → buttons-group-DA_wORqQ-B964Ed1w.js} +1 -1
  40. package/dist/factory/assets/{code-block-ftl_9xy4-DbShK5LK.js → code-block-somfQ1kL-GjQOZjFs.js} +2 -2
  41. package/dist/factory/assets/{code-editor-BLzt8hly-D15pz_na.js → code-editor-BLzt8hly-_gqni7f_.js} +1 -1
  42. package/dist/factory/assets/{copy-button-C3L1ZoAD-GwioHrvT.js → copy-button-C3L1ZoAD-CiQHdgY0.js} +1 -1
  43. package/dist/factory/assets/{esm-DjkVODAY.js → esm-DfwJCjuJ.js} +1 -1
  44. package/dist/factory/assets/index-COIkekLT.css +1 -0
  45. package/dist/factory/assets/{index-DjubxEY0.js → index-DJ3zJOT1.js} +35 -35
  46. package/dist/factory/assets/{input-DqReKX0A-Di5bISel.js → input-DqReKX0A-BkAmakZI.js} +1 -1
  47. package/dist/factory/assets/{input-group-BXqgO3Q2-De5e_WR9.js → input-group-BXqgO3Q2-6Yh1L4oM.js} +1 -1
  48. package/dist/factory/assets/{integration-icon-CGw0bkxw-D7TAlIER.js → integration-icon-CGw0bkxw-B39o4-g7.js} +1 -1
  49. package/dist/factory/assets/{onboardingFlow-Dm4xmmUV.js → onboardingFlow-BX9jjhmr.js} +1 -1
  50. package/dist/factory/assets/{provider-credential-DVI65Be5.js → provider-credential-BgFHqSZH.js} +1 -1
  51. package/dist/factory/assets/relative-time.es-Dt77VwGg.js +1 -0
  52. package/dist/factory/assets/{remarkKnowledgeLinks.es-BLDvlSql.js → remarkKnowledgeLinks.es-BFaqWZJJ.js} +1 -1
  53. package/dist/factory/assets/{use-clock.es-mOw2EjvR.js → use-clock.es-Do-U-d8-.js} +1 -1
  54. package/dist/factory/assets/{use-providers-xnyC8ePn.js → use-providers-Cdm0eFqP.js} +1 -1
  55. package/dist/factory/assets/{use-voice-settings-BnebPrsQ.js → use-voice-settings-BDYjvGVA.js} +1 -1
  56. package/dist/factory/assets/{useBoardConfigRoute-D3HWEvrn.js → useBoardConfigRoute-BTs9lUfW.js} +1 -1
  57. package/dist/factory/assets/{useDraftModelGuards-BFI_tz6G.js → useDraftModelGuards-DDpK2hrL.js} +2 -2
  58. package/dist/factory/assets/{useFactories-BSnLX5pf.js → useFactories-BbPGoUnu.js} +5 -7
  59. package/dist/factory/assets/{useGlobalSearchControls-DALH9Rx1.js → useGlobalSearchControls-BjhZ6EQt.js} +1 -1
  60. package/dist/factory/assets/{useLinearData-C2hbv473.js → useLinearData-D-jzoXrj.js} +1 -1
  61. package/dist/factory/assets/{useRouteSessionId-B19eYDwZ.js → useRouteSessionId-BFqqoexq.js} +1 -1
  62. package/dist/factory/assets/{useSessionCard-Bwu6ADRJ.js → useSessionCard-DYJmE0w-.js} +1 -1
  63. package/dist/factory/assets/{useSessionRepository-yC1buCos.js → useSessionRepository-Bz4GA4Xr.js} +1 -1
  64. package/dist/factory/assets/{useSessionRows-DqWZeKoh.js → useSessionRows-BFZXJZw8.js} +1 -1
  65. package/dist/factory/assets/{useThreadWorkspacePath-DMOuMkkk.js → useThreadWorkspacePath-DB43LqLV.js} +1 -1
  66. package/dist/factory/assets/workspaces-DEE7EtbG.js +2 -0
  67. package/dist/factory/index.html +29 -29
  68. package/dist/index.js +1 -1
  69. package/dist/studio/assets/{index-D9EdpNNB.js → index-9jBk0PLz.js} +2 -2
  70. package/dist/studio/assets/{main-DCx1Pcha.js → main-wtDneH92.js} +274 -276
  71. package/dist/studio/assets/style-CPAFAxRe.css +2 -0
  72. package/dist/studio/index.html +2 -2
  73. package/package.json +5 -5
  74. package/dist/factory/assets/SettingsPage-CC1pZxHZ.js +0 -3
  75. package/dist/factory/assets/index-m70p3VEr.css +0 -1
  76. package/dist/factory/assets/relative-time.es-DiIHgsBj.js +0 -1
  77. package/dist/factory/assets/workspaces-CCLGypS7.js +0 -2
  78. package/dist/studio/assets/style-D0EnDGr-.css +0 -2
  79. /package/dist/factory/assets/{MarkdownRenderer-zGEV5K_s-C04mQel5.css → MarkdownRenderer-By9XK05q-C04mQel5.css} +0 -0
  80. /package/dist/factory/assets/{code-block-ftl_9xy4-BQpfUmVC.css → code-block-somfQ1kL-BQpfUmVC.css} +0 -0
@@ -3,7 +3,7 @@ name: mastra
3
3
  description: Documentation for mastra. Use when working with mastra APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "mastra"
6
- version: "1.40.3-alpha.5"
6
+ version: "1.40.3-alpha.7"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.3-alpha.5",
2
+ "version": "1.40.3-alpha.7",
3
3
  "package": "mastra",
4
4
  "exports": {
5
5
  "PosthogAnalytics": {
@@ -1 +1 @@
1
- import{At as e,Et as t,Ft as n,It as r,Lt as i,Mt as a,Nt as o,Ot as s,Pt as c,Rt as l,jt as u,kt as d,xi as f}from"./useFactories-BSnLX5pf.js";import{D as p,w as m}from"./IconChevronRightMedium.es-ETbnXMk8.js";var h=p();function g(e){return(0,h.jsx)(t,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...t}){return(0,h.jsx)(u,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...t,role:`alertdialog`})}function v({children:t,loading:n,...r}){return(0,h.jsx)(e,{render:(0,h.jsx)(f,{variant:`primary`,size:`md`,loading:n,className:m(i,l.md),children:t}),...r})}g.Trigger=r,g.Content=_,g.Header=c,g.Footer=o,g.Body=s,g.Title=n,g.Description=a,g.Action=v,g.Cancel=d;export{g as t};
1
+ import{At as e,Et as t,Ft as n,It as r,Lt as i,Mt as a,Nt as o,Ot as s,Pt as c,Rt as l,jt as u,kt as d,xi as f}from"./useFactories-BbPGoUnu.js";import{D as p,w as m}from"./IconChevronRightMedium.es-ETbnXMk8.js";var h=p();function g(e){return(0,h.jsx)(t,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...t}){return(0,h.jsx)(u,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...t,role:`alertdialog`})}function v({children:t,loading:n,...r}){return(0,h.jsx)(e,{render:(0,h.jsx)(f,{variant:`primary`,size:`md`,loading:n,className:m(i,l.md),children:t}),...r})}g.Trigger=r,g.Content=_,g.Header=c,g.Footer=o,g.Body=s,g.Title=n,g.Description=a,g.Action=v,g.Cancel=d;export{g as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./SettingsHrefLink-tZUUWydT.js";import{t as r}from"./AlertDialog.es-Rg-H7EnF.js";import{c as i,l as a,o}from"./TabsRoot-DcVywXPZ.js";import{$i as s,Li as c,Mr as l,Ni as u,Tr as d,Tt as f,Y as p,Zn as m,_i as h,ea as g,ec as _,kr as v,na as y,on as b,ot as x,rc as S,tc as C,wr as ee,wt as w,xi as T}from"./useFactories-BSnLX5pf.js";import{t as E}from"./IconArrowRotateCounterClockwise.es-mQeFJ69W.js";import{S as te,c as ne,y as D}from"./boardViews-Dd2NN2MG.js";import{D as O,O as k,a as re,d as A,n as j,s as M,t as ie,w as N}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{A as ae,B as P,C as F,D as I,F as L,G as oe,H as se,I as R,L as z,M as B,O as V,P as ce,R as le,S as ue,T as de,U as fe,W as pe,_ as me,a as he,b as ge,d as _e,g as ve,h as ye,i as be,j as xe,k as Se,m as Ce,n as we,o as Te,p as Ee,r as De,s as Oe,t as ke,w as Ae,x as je,y as Me,z as Ne}from"./useBoardConfigRoute-D3HWEvrn.js";import{n as Pe,t as H}from"./IconLock.es-ClES7xwW.js";import{s as Fe}from"./highlight-B5yoRWjq-BF8vnsDR.js";import{b as U,g as Ie,v as Le,x as W,y as Re}from"./useLinearData-C2hbv473.js";import{t as ze}from"./password-manager-autofill.es-Cs1VH0JI.js";import{n as Be,t as Ve}from"./IconArrowSplitUp.es-D-sYhilw.js";import{$r as He,Ar as Ue,Cr as We,Dn as Ge,Dr as Ke,Er as qe,Fr as Je,Gi as Ye,Gr as Xe,Ji as Ze,Jn as Qe,Ki as $e,Kn as et,Mn as tt,Nn as nt,Qr as G,Sr as rt,Tr as it,Un as at,Vn as ot,Wn as st,Xr as ct,Yi as lt,_a as ut,_r as dt,br as ft,dr as pt,ei as mt,er as ht,fr as gt,gr as _t,hr as vt,ia as yt,ii as bt,ir as xt,jn as St,jr as Ct,kr as wt,lr as Tt,ma as K,mr as Et,na as Dt,nr as Ot,pr as kt,qi as At,qn as jt,ra as Mt,ri as Nt,ta as Pt,ti as Ft,ur as It,vr as Lt,wr as Rt,xr as zt,ya as Bt,yr as Vt,zn as Ht,zr as Ut}from"./index-DjubxEY0.js";import{t as Wt}from"./IconTarget.es-vG08S5YA.js";import{i as q,t as Gt}from"./EmptyState-IMGHVwoU-DXFO08zt.js";import{a as Kt,n as qt}from"./SkillBadges-Cp5_yMjO.js";import{l as Jt,r as Yt,t as Xt,u as Zt}from"./HrefLink-DkNJBJtp.js";import{Dt as Qt,Et as $t,Tt as en,bn as tn,kn as nn,kt as rn}from"./useSessionRows-DqWZeKoh.js";import{a as an,r as on,t as sn}from"./Field.es-DHZ-9qma.js";import{t as cn}from"./input-DqReKX0A-Di5bISel.js";import{t as ln}from"./code-editor-BLzt8hly-D15pz_na.js";import{a as un,n as dn}from"./input-group-BXqgO3Q2-De5e_WR9.js";import{a as fn,i as pn,n as mn,r as hn,t as gn}from"./InputNumber.es-CHWsEKgx.js";import{n as _n}from"./IconClock.es-DlAabv8B.js";import{a as vn}from"./RadioGroup-BLrZAwSh.js";import{a as yn,c as bn,l as xn}from"./settingsSections-rQ9VqtBb.js";var J=O();function Sn({hold:e,stale:t,error:n,saving:r,onSave:i,onDiscard:a,onReload:o}){return(0,J.jsxs)(`div`,{className:`flex w-full max-w-130 flex-col items-center gap-2`,children:[t&&(0,J.jsx)(w,{variant:`warning`,title:`Someone else changed this board`,action:(0,J.jsx)(w.Button,{onClick:o,children:`Reload`}),className:`w-full bg-card shadow-overlay`,children:(0,J.jsx)(w.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),n&&!t&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,className:`w-full bg-card shadow-overlay`,children:(0,J.jsxs)(w.Message,{children:[`The board was not saved. `,n]})}),(0,J.jsx)(R,{label:e??`Unsaved changes`,held:e!==void 0,saveLabel:`Save`,saving:r,onSave:i,onDiscard:a})]})}function Cn({boardName:e,open:t,onStay:n,onLeave:i}){return(0,J.jsx)(r,{open:t,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Discard changes to `,e,`?`]}),(0,J.jsx)(r.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Keep editing`}),(0,J.jsx)(T,{variant:`destructive`,size:`md`,onClick:i,children:`Discard`})]})]})})}var Y=e(k(),1);function wn({boardName:e,resettable:t,deletable:n,busy:i,disabled:o,onReset:s,onDelete:c}){let[l,u]=(0,Y.useState)();return!t&&!n?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(a,{children:[(0,J.jsx)(a.Trigger,{variant:`ghost`,size:`icon-sm`,tooltip:`Board actions`,"aria-label":`Board actions`,disabled:o||i,children:i?(0,J.jsx)(S,{size:`sm`}):(0,J.jsx)(le,{})}),(0,J.jsxs)(a.Content,{align:`start`,children:[t&&(0,J.jsxs)(a.Item,{onClick:()=>u(`reset`),children:[(0,J.jsx)(E,{}),`Reset to default`]}),n&&(0,J.jsxs)(a.Item,{variant:`destructive`,onClick:()=>u(`delete`),children:[(0,J.jsx)(te,{}),`Delete board`]})]})]}),(0,J.jsx)(r,{open:l===`reset`,onOpenChange:e=>!e&&u(void 0),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Reset `,e,` to default?`]}),(0,J.jsx)(r.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Cancel`}),(0,J.jsx)(r.Action,{onClick:s,children:`Reset`})]})]})}),(0,J.jsx)(r,{open:l===`delete`,onOpenChange:e=>!e&&u(void 0),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Delete `,e,`?`]}),(0,J.jsx)(r.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Cancel`}),(0,J.jsx)(r.Action,{onClick:c,children:`Delete`})]})]})})]})}function Tn({resetError:e,deleteError:t}){return(0,J.jsxs)(J.Fragment,{children:[e!==void 0&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,children:(0,J.jsxs)(w.Message,{children:[`The board was not reset. `,e]})}),t!==void 0&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,children:(0,J.jsxs)(w.Message,{children:[`The board was not deleted. `,t]})})]})}var En=`mb-10 flex max-w-2xl flex-col gap-1`;function Dn({name:e,description:n,readOnly:r,manageable:i,editable:a,problems:o,rulesFailed:s,actions:c,errors:l,onChange:u}){return(0,J.jsxs)(`header`,{className:En,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(j,{as:`h1`,variant:`display`,tone:`ink`,className:`min-w-0`,children:(0,J.jsx)(t,{value:e,label:`Board name`,required:!0,readOnly:r,variant:`display`,tone:`ink`,onChange:e=>u({name:e})})}),i&&(0,J.jsx)(wn,{...c})]}),(n||!r)&&(0,J.jsx)(j,{as:`p`,variant:`body`,tone:`muted`,children:(0,J.jsx)(t,{value:n??``,label:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:r,variant:`body`,tone:`muted`,className:`w-[calc(100%+--spacing(3))] placeholder:text-subtle-foreground`,onChange:e=>u({description:e||null})})}),(!i||o.length>0||s||l.resetError!==void 0||l.deleteError!==void 0)&&(0,J.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[!i&&(0,J.jsx)(w,{variant:`note`,icon:(0,J.jsx)(H,{}),children:(0,J.jsx)(w.Message,{children:a?`Only organization admins can change this board.`:`This board is defined in code, so it can’t be changed here.`})}),o.length>0&&(0,J.jsx)(w,{variant:`warning`,title:`This board has problems`,children:(0,J.jsx)(w.Message,{children:o.join(` `)})}),s&&(0,J.jsx)(w,{variant:`warning`,children:(0,J.jsx)(w.Message,{children:`Rules didn’t load, so the map doesn’t show them.`})}),(0,J.jsx)(Tn,{...l})]})]})}var On=`duration-normal ease-out-custom transition-opacity motion-reduce:transition-none group-data-dragging/flow:opacity-0`,kn=`relative mb-8 flex w-89.5 flex-col gap-1 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`;function An({sentence:e,reorderHref:t,linked:n,LinkComponent:r}){return(0,J.jsxs)(`section`,{"data-intake-start":``,"aria-labelledby":`canvas-intake`,className:N(_,kn),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(Fe,{className:`size-icon-sm shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(j,{as:`h2`,id:`canvas-intake`,variant:`card-title-strong`,tone:`ink`,className:`min-w-0 flex-1 truncate`,children:`New issues and pull requests`}),(0,J.jsxs)(r,{href:t,className:N(`flex shrink-0 items-center gap-1 rounded-sm text-caption text-muted-foreground hover:text-foreground`,M),children:[`Reorder`,(0,J.jsx)(Re,{className:`size-icon-xs`,"aria-hidden":!0})]})]}),e!==void 0&&(0,J.jsx)(j,{variant:`caption`,tone:`muted`,className:`pl-6 text-pretty`,children:e}),n&&(0,J.jsx)(B,{className:N(`absolute -bottom-1.25 left-3.75`,On)})]})}function jn({linked:e}){return(0,J.jsx)(`span`,{"aria-hidden":!0,"data-intake-branch":e?``:void 0,className:N(`-mr-1 flex min-w-2.5 flex-1 items-center justify-end max-sm:hidden`,On,!e&&`opacity-0`),children:(0,J.jsx)(B,{})})}function Mn({flow:e}){let[t,n]=(0,Y.useState)();return(0,Y.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=Nn(t);n(t=>t?.join()===e?.join()?t:e)};r();let i=new ResizeObserver(r);i.observe(t);for(let e of t.querySelectorAll(`[data-rules-in]`))i.observe(e);return()=>i.disconnect()}),t?(0,J.jsx)(`svg`,{"aria-hidden":!0,className:N(ae,`pointer-events-none absolute inset-0 size-full overflow-visible`,On),children:t.map(e=>(0,J.jsx)(`path`,{d:e},e))}):null}function Nn(e){let t=e.querySelector(`[data-intake-start] [data-port]`),n=[...e.querySelectorAll(`[data-intake-branch] [data-port]`)].filter(e=>e instanceof HTMLElement);if(!(t instanceof HTMLElement)||n.length===0)return;let r=L(t,e),i=r.left+t.offsetWidth/2,a=r.top+t.offsetHeight,o=n.map(t=>{let n=L(t,e);return{y:n.top+t.offsetHeight/2,to:n.left}}),s=Math.max(...o.map(e=>e.y));return o.map(e=>ce([...e.y===s?[{x:i,y:a}]:[],{x:i,y:e.y},{x:e.to,y:e.y}]))}var Pn=A(`IconArrowDownRight`,()=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d:`M18 9V18H9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`path`,{d:`M6.25 6.25L17 17`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),3);function Fn({rule:e,stray:t=!1,LinkComponent:n}){let{emphasis:r}=e,i=t?`into a phase this board doesn’t have`:`here`;return(0,J.jsx)(F,{title:void 0,lines:[`“${e.name}” on ${e.boardName} moves cards ${i}.`,...e.conditions,...e.enabled?[]:[`Off, skipped`]],children:(0,J.jsxs)(n,{"data-join":``,"data-dimmed":r===`dimmed`||void 0,href:e.href,"aria-label":e.enabled?e.boardName:`${e.boardName}, off`,className:N(Ae,`border border-border bg-transparent text-body-sm transition-opacity`,e.enabled?`text-foreground`:`text-muted-foreground opacity-50`,r===`dimmed`&&`opacity-35`,r===`selected`&&`ring-foreground ring-2`),children:[(0,J.jsx)(Pn,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate`,children:e.boardName}),!e.enabled&&(0,J.jsx)(`span`,{className:`shrink-0 text-caption`,children:`Off`})]})})}var In=`hover:bg-fill -mx-1.5 min-w-0 flex-1 rounded-md bg-transparent px-1.5 outline-none`;function Ln({boardId:e,takenKeys:t,linked:n,keyFromName:r,keyProblem:i,onAdd:a,onCancel:o}){let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=l??r(s),p=l===void 0&&s.trim()===``?void 0:i(f,t),m=s.trim()!==``&&p===void 0,h=e=>{d.current||(d.current=!0,e())};return(0,J.jsxs)(`form`,{"aria-label":`New phase`,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),m&&h(()=>a({key:f,name:s.trim()},!0))):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),h(o)))},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(s.trim()===``?h(o):m&&h(()=>a({key:f,name:s.trim()},!1)))},className:N(_,`relative flex w-75 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`,`has-focus-visible:[--surface-rim:var(--border-focus)]`),children:[(0,J.jsx)(B,{className:N(Se,`-top-1.25`)}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(U,{stage:f,kind:W(e,`resting`),decorative:!0}),(0,J.jsx)(`input`,{"aria-label":`New phase name`,value:s,placeholder:`Phase name`,autoFocus:!0,...ze,onChange:e=>c(e.currentTarget.value),className:N(In,`text-card-title-strong text-foreground placeholder:text-muted-foreground`)})]}),(0,J.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-caption text-muted-foreground`,children:[`Key`,(0,J.jsx)(`input`,{"aria-label":`New phase key`,value:f,...ze,onChange:e=>u(e.currentTarget.value),className:N(In,`font-mono text-caption text-foreground`)})]}),p?(0,J.jsx)(`span`,{role:`alert`,className:`text-caption text-destructive-foreground`,children:p}):(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Enter adds it. The key can’t change once added.`}),n&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-bottom-1.25`)})]})}var Rn=`relative flex w-75 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`;function zn({boardId:e,phase:t,phases:n,next:r,automatic:i,work:a,total:o,href:s,emphasis:c,problem:l,unreached:u,start:d,movable:f,moves:p,LinkComponent:m}){let h=o===void 0?void 0:o.toLocaleString(),g=t.kind===`terminal`,v=c===`selected`,y=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{v&&y.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[v]),(0,J.jsxs)(`article`,{ref:y,"aria-label":t.name,className:N(_,C,`group/node scroll-mt-20 scroll-mb-40`,Rn,`transition-[opacity,box-shadow] duration-normal ease-out-custom motion-reduce:transition-none`,`group-data-dragging/row:shadow-overlay has-focus-visible:[--surface-rim:var(--border-focus)]`,c===`selected`&&`ring-foreground ring-2`,c===`dimmed`&&`opacity-35`,l&&c!==`selected`&&`ring-1 ring-warning-indicator`),children:[(0,J.jsxs)(`div`,{"data-inlet-at":``,className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(U,{stage:t.key,kind:W(e,t.kind),decorative:!0}),(0,J.jsx)(m,{href:s,"aria-current":c===`selected`?`true`:void 0,"aria-description":f?`Alt+Up or Alt+Down moves this phase.`:void 0,className:N(`truncate rounded-sm text-card-title-strong text-foreground`,`after:absolute after:inset-0 after:rounded-2xl`,M),children:t.name}),l&&(0,J.jsx)(z,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-label":`This phase has problems`}),!g&&h!==void 0&&(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-caption text-muted-foreground tabular-nums`,children:h})]}),g&&h!==void 0&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground tabular-nums`,children:h}),d&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`New cards start here`}),(0,J.jsx)(Bn,{kind:t.kind,work:a}),u&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[(0,J.jsx)(z,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-hidden":!0}),`No rule or move leads here`]}),(r.length>0||p)&&(0,J.jsxs)(`div`,{className:`flex gap-2 border-t border-border pt-2.5`,children:[p?(0,J.jsx)(Hn,{boardId:e,phase:t,phases:n,next:r,shown:c===`selected`,...p}):(0,J.jsx)(Ve,{className:`mt-1.25 size-icon-xs shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`ul`,{"aria-label":`Moves to`,className:`flex min-w-0 flex-wrap gap-1.5`,children:r.map(t=>{let r=n.find(e=>e.key===t);return(0,J.jsxs)(`li`,{className:`flex h-6 min-w-0 items-center gap-1 rounded-lg bg-background px-1.5`,children:[r&&(0,J.jsx)(U,{stage:t,kind:W(e,r.kind),decorative:!0}),(0,J.jsx)(`span`,{className:`truncate text-body-sm text-foreground`,children:r?.name??t}),i.has(t)&&(0,J.jsx)(Ne,{className:`size-icon-xs shrink-0 text-muted-foreground`,"aria-label":`on its own`})]},t)})})]})]})}function Bn({kind:e,work:t}){if(e===`resting`)return(0,J.jsx)(X,{icon:Pe,label:`Waits for someone`});if(e!==`working`||!t)return null;let{goal:n,tools:r}=t;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{icon:Bt,label:t.skill??`No skill`,broken:t.skillProblem!==void 0,detailIcon:t.autoStart?Ne:Pe,detail:t.autoStart?`On its own`:`By hand`}),t.skillProblem&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-destructive-foreground`,children:[(0,J.jsx)(z,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),t.skillProblem]}),t.exit&&(0,J.jsx)(X,{icon:yt,label:t.exit.id,detail:t.exit.approval}),n&&(0,J.jsx)(X,{icon:Wt,label:`Goal`,detail:n.maxRuns===void 0?void 0:`Pauses after ${n.maxRuns} runs`}),r&&(0,J.jsx)(X,{icon:Ie,label:r})]})}function X({icon:e,label:t,broken:n=!1,detail:r,detailIcon:i}){return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,J.jsx)(e,{className:`mt-0.75 size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3`,children:[(0,J.jsx)(`span`,{className:N(`min-w-0 truncate text-body-sm`,n?`text-destructive-foreground`:`text-foreground`),children:t}),r&&(0,J.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-1 text-caption text-muted-foreground`,children:[i&&(0,J.jsx)(i,{className:`size-icon-xs shrink-0`}),(0,J.jsx)(`span`,{className:`line-clamp-2`,children:r})]})]})]})}var Vn=`col-start-1 row-start-1 size-icon-xs duration-normal ease-out-custom transition-opacity motion-reduce:transition-none`;function Hn({boardId:e,phase:t,phases:n,next:r,shown:i,required:o,onChange:s}){let c=e=>s(r.includes(e)?r.filter(t=>t!==e):n.filter(t=>t.key===e||r.includes(t.key)).map(e=>e.key));return(0,J.jsxs)(a,{children:[(0,J.jsx)(a.Trigger,{render:(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Change moves from ${t.name}`,className:N(`group/moves relative z-10 -mx-1.25 grid size-6 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-fill-hover hover:text-foreground`,`data-popup-open:bg-fill-hover data-popup-open:text-foreground`,M),children:[(0,J.jsx)(Ve,{className:N(Vn,i?`opacity-0`:`group-hover/node:opacity-0 group-focus-visible/moves:opacity-0 group-data-popup-open/moves:opacity-0`)}),(0,J.jsx)(K,{className:N(Vn,!i&&`opacity-0 group-hover/node:opacity-100 group-focus-visible/moves:opacity-100 group-data-popup-open/moves:opacity-100`)})]})}),(0,J.jsxs)(a.Content,{align:`start`,className:`w-56`,children:[(0,J.jsx)(a.Label,{children:`Cards can move to`}),n.filter(e=>e.key!==t.key).map(t=>{let n=r.includes(t.key)&&o.has(t.key);return(0,J.jsxs)(a.CheckboxItem,{checked:r.includes(t.key),disabled:n,onCheckedChange:()=>c(t.key),children:[(0,J.jsx)(U,{stage:t.key,kind:W(e,t.kind),decorative:!0}),(0,J.jsx)(`span`,{className:`truncate`,children:t.name}),n&&(0,J.jsx)(H,{className:`ml-auto size-icon-xs`,"aria-label":`Factory makes this move`})]},t.key)})]})]})}var Un=5,Wn=`border-muted-foreground/35 border-l-2`,Gn=`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,Kn=`w-30 shrink-0 max-sm:hidden`,qn=`border-border-strong text-caption text-muted-foreground hover:text-foreground flex items-center gap-1 rounded-full border border-dashed focus-visible:opacity-100`;function Jn(e,t){if(e)return`card`;if(t)return`entry`}function Yn({boardId:e,model:t,totals:n,selectedPhase:r,selectedRule:i,problems:a,rulesEditable:o,edit:s,intake:c,LinkComponent:l}){let u=t.rows.map(e=>e.phase),d=fe(),[f,p]=(0,Y.useState)(),m=e=>t.sessions.find(t=>e>=t.from&&e<=t.to),[h,g]=(0,Y.useState)(``),_=V({min:1,max:u.length-1,onDrop:(e,t)=>{s?.onReorder(e,t),g(`${u[e]?.name} moved to position ${t+1} of ${u.length}.`)}}),v=(0,Y.useRef)(null),{asked:y}=c,b=y&&t.rows.some(e=>e.lines.some(e=>e.opened&&!e.movesCardsOnly)),x=s!==void 0&&f===void 0,S=u.at(-1);return(0,J.jsxs)(`div`,{ref:v,"data-dragging":_.drag?``:void 0,className:`group/flow relative flex flex-col`,children:[(0,J.jsx)(An,{sentence:c.sentence,reorderHref:c.reorderHref,linked:b,LinkComponent:l}),!d&&(0,J.jsx)(Mn,{flow:v}),(0,J.jsx)(`ol`,{"aria-label":`Phases`,className:`flex flex-col`,children:t.rows.map((t,c)=>{let{phase:h}=t,g=m(c),v=u[c-1],S=u[c+1],C=_.drag?.from===c,ee=_.rowMotion(c),w=x&&c>0&&u.length>2,T=S!==void 0||f===c;return(0,J.jsxs)(`li`,{"data-dragging":C||void 0,style:ee.style,onPointerDown:w?e=>_.onPointerDown(e,c):void 0,onKeyDown:w?e=>_.onKeyDown(e,c):void 0,className:N(`group/row relative flex flex-col`,ee.className),children:[v&&(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`flex items-center justify-end text-caption text-muted-foreground max-sm:order-last max-sm:w-auto`),children:h.kind===`terminal`&&v.kind!==`terminal`&&`Cards are finished here`}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,g&&g.from<c&&Wn)})]}),(0,J.jsxs)(`div`,{className:`group/phase relative flex gap-4 max-sm:flex-col max-sm:gap-2`,children:[(0,J.jsx)(Zn,{row:t,selectedPhase:r,selectedRule:i,rulesEditable:o,asked:y,linkedFrom:Jn(v,b),LinkComponent:l}),(0,J.jsxs)(`div`,{"data-grip":w?``:void 0,className:`flex flex-col items-center max-sm:items-stretch`,children:[(0,J.jsxs)(`div`,{"data-inlet-card":``,className:`relative`,children:[(v||b)&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-top-1.25`,!v&&`sm:hidden`)}),(0,J.jsx)(zn,{boardId:e,phase:h,phases:u,next:t.next,automatic:t.automatic,work:t.work,total:n.get(h.key),href:t.href,emphasis:t.emphasis,problem:a.has(h.key),unreached:t.unreached,start:t.start,movable:w,moves:s&&{required:s.required(h.key),onChange:e=>s.onMoves(h.key,e)},LinkComponent:l}),T&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-bottom-1.25`)})]}),T&&(0,J.jsxs)(`span`,{className:`group/gap relative flex flex-1 justify-center self-stretch`,children:[(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`}),x&&(0,J.jsx)(`span`,{className:`absolute inset-x-0 top-0 -bottom-8 z-10 flex items-center justify-center max-sm:hidden pointer-coarse:hidden`,children:(0,J.jsx)(Xn,{after:h,onClick:()=>p(c),className:`opacity-0 group-hover/gap:opacity-100`})})]})]}),(0,J.jsx)(`div`,{className:N(Kn,`pl-2.5 text-caption text-muted-foreground`,g&&Wn),children:g?.from===c&&g.label}),!d&&(0,J.jsx)(xe,{})]}),s&&f===c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,S&&g&&g.to>c&&Wn)})]}),(0,J.jsxs)(`div`,{className:`flex gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(Ln,{boardId:e,takenKeys:u.map(e=>e.key),linked:S!==void 0,keyFromName:s.keyFromName,keyProblem:s.keyProblem,onAdd:(e,t)=>{p(void 0),s.onAdd(e,c+1,t)},onCancel:()=>p(void 0)}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,S&&g&&g.to>c&&Wn)})]})]})]},h.key)})}),x&&S&&(0,J.jsxs)(`div`,{className:`flex gap-4 pt-3`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-auto max-sm:justify-start`,children:(0,J.jsx)(Xn,{after:S,onClick:()=>p(u.length-1),className:`opacity-0 group-hover/flow:opacity-100 pointer-coarse:opacity-100`})})]}),(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:h})]})}function Xn({after:e,onClick:t,className:n}){return(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Add a phase after ${e.name}`,onClick:t,className:N(qn,`z-10 h-5 bg-card px-2 transition-opacity group-data-dragging/flow:invisible`,M,n),children:[(0,J.jsx)(K,{className:`size-icon-xs`,"aria-hidden":!0}),`Phase`]})}function Zn({row:e,selectedPhase:t,selectedRule:n,rulesEditable:r,asked:i,linkedFrom:a,LinkComponent:o}){let[s,c]=(0,Y.useState)(!1),l=e.lines.slice(Un),u=s||l.some(e=>e.ruleId===n),d=u?e.lines:e.lines.slice(0,Un),f=t===e.phase.key,p=t=>e.lines.some(e=>e.event===t&&!e.movesCardsOnly);return(0,J.jsxs)(`div`,{"data-rules-in":``,className:N(Gn,`relative flex flex-col items-end gap-1.5 pt-2 pl-7 max-sm:items-start max-sm:pt-0 max-sm:pl-10`),children:[a&&(0,J.jsx)(`span`,{"aria-hidden":!0,className:N(`bg-canvas-link w-px`,`absolute -bottom-2 left-5 -translate-x-1/2 sm:hidden`,a===`entry`?`-top-8`:`top-0`)}),d.map((e,t)=>{let n=e.emphasis,r=d[t-1]?.event!==e.event,a=r&&e.opened;return(0,J.jsxs)(`div`,{className:N(`flex max-w-full min-w-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 max-sm:justify-start`,a&&`w-full`),children:[a&&(0,J.jsx)(jn,{linked:i&&p(e.event)}),r&&(0,J.jsx)(I,{trigger:e.trigger,dimmed:n===`dimmed`}),(0,J.jsx)(de,{line:e,LinkComponent:o})]},`${e.event}:${e.ruleId}`)}),l.length>0&&!u&&(0,J.jsxs)(`button`,{type:`button`,"data-join":``,onClick:()=>c(!0),className:N(`h-6.5 rounded-full border border-border px-2.5 text-caption text-muted-foreground hover:text-foreground`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[`+`,l.length,` more`]}),e.incoming.map(e=>(0,J.jsx)(Fn,{rule:e,LinkComponent:o},e.ruleId)),r&&(0,J.jsxs)(o,{href:e.newRuleHref,"aria-label":`Add a rule into ${e.phase.name}`,className:N(qn,`h-6.5 px-2.5`,f?`opacity-100`:`opacity-0 group-has-[[data-rules-in]:hover,[data-inlet-card]:hover]/phase:opacity-100 pointer-coarse:opacity-100`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[(0,J.jsx)(K,{className:`size-icon-xs`,"aria-hidden":!0}),`Rule`]})]})}var Z=`motion-reduce:before:animate-none`,Qn=3;function $n(){return(0,J.jsxs)(`div`,{"aria-hidden":!0,className:En,children:[(0,J.jsx)(q,{line:`text-display`,className:N(`h-5 w-40`,Z)}),(0,J.jsx)(q,{line:`text-body`,className:N(`w-72 max-w-full`,Z)})]})}function er(){return(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading board`,className:`flex flex-col`,children:[(0,J.jsxs)(`div`,{"aria-hidden":!0,className:N(_,kn),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(Fe,{className:`size-icon-sm shrink-0 text-muted-foreground`}),(0,J.jsx)(q,{line:`text-card-title-strong`,className:N(`w-44`,Z)})]}),(0,J.jsx)(`span`,{className:`pl-6`,children:(0,J.jsx)(q,{line:`text-caption`,className:N(`w-56 max-w-full`,Z)})})]}),(0,J.jsx)(`ol`,{"aria-hidden":!0,className:`flex flex-col`,children:Array.from({length:Qn},(e,t)=>(0,J.jsxs)(`li`,{className:`flex flex-col`,children:[t>0&&(0,J.jsxs)(`div`,{className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:order-last max-sm:w-auto`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:`w-30 shrink-0 max-sm:hidden`})]}),(0,J.jsxs)(`div`,{className:`flex gap-4 max-sm:flex-col`,children:[(0,J.jsx)(`span`,{className:N(Gn,`max-sm:hidden`)}),(0,J.jsxs)(`div`,{className:N(_,Rn),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(o,{className:N(`size-4 shrink-0 rounded-full`,Z)}),(0,J.jsx)(q,{line:`text-card-title-strong`,className:N(`w-24`,Z)})]}),(0,J.jsx)(q,{line:`text-body-sm`,className:N(`w-40`,Z)})]}),(0,J.jsx)(`span`,{className:Kn})]})]},t))})]})}function tr({leaving:e,stray:t,strayIncoming:n,LinkComponent:r}){return(0,J.jsxs)(J.Fragment,{children:[e.length>0&&(0,J.jsxs)(`section`,{"aria-labelledby":`canvas-leaving`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(j,{as:`h2`,id:`canvas-leaving`,variant:`body-sm`,tone:`muted`,children:`To other boards`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map(e=>{let{line:t,stage:n}=e,i=t.emphasis===`dimmed`;return(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,J.jsx)(I,{trigger:t.trigger,dimmed:i}),(0,J.jsx)(de,{line:t,LinkComponent:r}),(0,J.jsxs)(r,{href:e.href,className:N(`bg-card hover:bg-card active:bg-card shadow-raised [--field:var(--field-on-surface)] [--field-disabled:var(--field-on-surface)] [--field-hover:var(--field-hover-on-surface)] [--field-open:var(--field-open-on-surface)]`,`state-layer`,`flex min-w-36 flex-col gap-0.5 rounded-2xl px-3.25 py-2.5 transition-opacity`,i&&`opacity-35`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-card-title-strong text-foreground`,children:[n&&(0,J.jsx)(U,{stage:n.key,kind:W(n.boardId,n.kind),decorative:!0}),e.phaseName??`A removed phase`]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Re,{className:`size-icon-xs`,"aria-hidden":!0}),e.boardName]})]})]},`${t.event}:${t.ruleId}`)})})]}),t.length+n.length>0&&(0,J.jsxs)(`section`,{"aria-labelledby":`canvas-stray`,className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(j,{as:`h2`,id:`canvas-stray`,variant:`body-sm`,tone:`muted`,children:`Into a removed phase`}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`These rules name a phase this board doesn’t have, so they can’t move cards. Open one to pick another phase.`})]}),(0,J.jsxs)(`ul`,{className:`flex flex-col items-start gap-1.5`,children:[t.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,J.jsx)(I,{trigger:e.trigger,dimmed:e.emphasis===`dimmed`}),(0,J.jsx)(de,{line:e,LinkComponent:r})]},`${e.event}:${e.ruleId}`)),n.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Fn,{rule:e,stray:!0,LinkComponent:r})},e.ruleId))]})]})]})}function Q({icon:e,title:t,children:n}){return(0,J.jsxs)(`section`,{"aria-label":t,className:`group/step grid grid-cols-[var(--spacing-icon-md)_minmax(0,1fr)] gap-x-2 gap-y-2.5 px-1`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`grid h-4 place-items-center text-foreground [&_svg]:size-3.25`,children:e}),(0,J.jsx)(j,{as:`h3`,variant:`column`,tone:`ink`,className:`font-semibold`,children:t}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`-mt-1.5 -mb-3 w-px justify-self-center bg-border-strong group-last-of-type/step:hidden`}),(0,J.jsx)(`div`,{className:`col-start-2 flex min-w-0 flex-col gap-2.5`,children:n})]})}function $({label:e,children:t,className:n}){return(0,J.jsxs)(`div`,{className:N(`flex min-h-5 min-w-0 items-center justify-between gap-1.5`,n),children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`min-w-0 truncate`,children:e}),t]})}function nr({length:e,max:t}){return(0,J.jsxs)(j,{as:`span`,variant:`caption`,tone:e>t?void 0:`muted`,className:N(`tabular-nums`,e>t&&`text-warning-foreground`),children:[e.toLocaleString(`en-US`),` / `,t]})}function rr({boardTitle:e,boardHref:t,LinkComponent:n}){return(0,J.jsxs)(se,{label:`Phase not found`,children:[(0,J.jsxs)(j,{variant:`body-sm`,tone:`ink`,role:`alert`,children:[e,` has no such phase.`]}),(0,J.jsx)(n,{href:t,className:`text-body-sm text-muted-foreground hover:text-foreground`,children:`Back to the board`})]})}var ir={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},ar=[`resting`,`working`,`terminal`];function or({phase:e,boardId:n,total:r,readOnly:a,kindLocked:o,onName:c,onDescription:l,onKind:u,onClose:d}){let f=ir[e.kind],p=e.description??``;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-2 pl-1`,children:[(0,J.jsx)(`span`,{className:`grid size-icon-md shrink-0 place-items-center`,children:(0,J.jsx)(U,{stage:e.key,kind:W(n,e.kind),decorative:!0})}),(0,J.jsx)(j,{as:`h2`,variant:`card-title-strong`,className:`min-w-0 truncate`,children:(0,J.jsx)(t,{value:e.name,label:`Phase name`,required:!0,readOnly:a,variant:`card-title-strong`,tone:`ink`,onChange:c})}),a||o?(0,J.jsxs)(s,{children:[(0,J.jsx)(y,{render:(0,J.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${f.label}. ${o?`${f.meaning} This phase keeps its kind.`:f.meaning}`,className:N(`inline-flex shrink-0 rounded-sm`,M),children:(0,J.jsx)(i,{size:`sm`,icon:o?(0,J.jsx)(H,{}):void 0,children:f.label})})}),(0,J.jsx)(g,{side:`bottom`,className:`max-w-72`,children:o?`${f.meaning} The first phase and phases Factory's code declares keep their kind.`:f.meaning})]}):(0,J.jsxs)(en,{value:e.kind,onValueChange:t=>{let n=ar.find(e=>e===t);n&&n!==e.kind&&u(n)},children:[(0,J.jsx)(rn,{size:`sm`,variant:`ghost`,"aria-label":`Phase kind`,className:`w-auto shrink-0`,children:f.label}),(0,J.jsx)($t,{children:ar.map(e=>(0,J.jsx)(Qt,{value:e,children:(0,J.jsxs)(`span`,{className:`flex max-w-56 flex-col gap-0.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`label`,children:ir[e].label}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:ir[e].meaning})]})},e))})]}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`ml-auto shrink-0 tabular-nums`,children:r===void 0?null:(0,J.jsxs)(J.Fragment,{children:[r,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` `,r===1?`card`:`cards`]})]})}),(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Close ${e.name}`,onClick:d,children:(0,J.jsx)(b,{})})]}),(p||!a)&&(0,J.jsx)(`div`,{className:`pl-7.5`,children:(0,J.jsx)(t,{value:p,label:`Phase description`,placeholder:`Add a description`,multiline:!0,readOnly:a,variant:`caption`,tone:`muted`,className:`w-full`,onChange:e=>l(e||null)})})]})}var sr=`Factory's code makes this move`;function cr({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let c=t.filter(t=>t.key!==e.key&&n.includes(t.key)),l=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.25`,children:[c.length===0&&(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`Cards stay here; no move is allowed.`}),c.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`contents`,children:c.map(e=>{let t=r.includes(e.key),n=(0,J.jsxs)(`span`,{tabIndex:t?0:void 0,className:`inline-flex h-6 max-w-full min-w-0 items-center gap-1.25 rounded-xl bg-fill pr-2 pl-1.5 text-foreground`,children:[(0,J.jsx)(lr,{phase:e,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`caption`,className:`truncate`,children:e.name}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(H,{"aria-hidden":!0,className:`size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`(locked)`})]})]});return(0,J.jsx)(`li`,{className:`min-w-0`,children:t?(0,J.jsxs)(s,{children:[(0,J.jsx)(y,{render:n}),(0,J.jsx)(g,{children:sr})]}):n},e.key)})}),!a&&(0,J.jsxs)(At,{children:[(0,J.jsx)(lt,{size:`icon-sm`,variant:`ghost`,tooltip:`Change moves from ${e.name}`,children:(0,J.jsx)(K,{})}),(0,J.jsxs)(Ze,{align:`start`,className:`w-72 p-1.5`,children:[(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`px-2 pt-0.5 pb-1.5`,children:[e.name,` can move cards to`]}),(0,J.jsx)(`ul`,{"aria-label":`Moves from ${e.name}`,className:`flex flex-col gap-0.5`,children:t.map(t=>{if(t.key===e.key)return(0,J.jsxs)(`li`,{className:`flex h-7.5 items-center gap-2 px-2`,children:[(0,J.jsx)(lr,{phase:t,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`body-sm`,tone:`muted`,className:`truncate`,children:t.name}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`ml-auto shrink-0`,children:`this phase`})]},t.key);let a=n.includes(t.key),o=a&&r.includes(t.key);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":a,"aria-label":o?`${t.name} (locked)`:void 0,"aria-disabled":o||void 0,title:o?sr:void 0,onClick:o?void 0:()=>l(t.key),className:N(tn,`w-full`,o&&`cursor-default`),children:[(0,J.jsx)(lr,{phase:t,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`body-sm`,tone:a?`ink`:`muted`,className:`truncate`,children:t.name}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`ml-auto grid shrink-0 place-items-center text-muted-foreground`,children:o?(0,J.jsx)(H,{className:`size-icon-sm`}):a?(0,J.jsx)(nn,{className:`size-icon-sm`}):(0,J.jsx)(K,{className:`size-icon-sm`})})]})},t.key)})}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`px-2 pt-1.5`,children:`Waits for the board's Save.`})]})]})]})}function lr({phase:e,boardId:t}){return(0,J.jsx)(U,{stage:e.key,kind:W(t,e.kind),decorative:!0})}function ur({phase:e,phases:t,next:n,info:r,disabled:i,onChange:a}){let o=e.outcomes?.length?e.outcomes:void 0,{defaults:s,problems:c,added:l,exitToolPick:u,max:d}=r,f=e=>t.find(t=>t.key===e)?.name??e;if(n.length===0)return(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`Allow a move first; each outcome goes to one of them.`});let p=e.exitTool?.id;if(!o)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`ul`,{"aria-label":`${e.name} outcomes`,className:`flex flex-col gap-1`,children:s.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(j,{as:`span`,variant:`caption`,tone:`muted`,children:[(0,J.jsx)(`code`,{children:e.key}),` moves the card to `,f(e.to)]})},e.key))}),p&&(0,J.jsx)(dr,{exitTool:p,picked:u,phases:t}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`The agent may report any allowed move by the key of the phase it goes to. Customize them to describe each one, or to offer fewer moves than people have.`}),!i&&(0,J.jsx)(`div`,{children:(0,J.jsx)(T,{size:`sm`,variant:`ghost`,onClick:()=>a(s.slice(0,d)),children:`Customize outcomes`})})]});let m=(e,t)=>a(o.map((n,r)=>r===e?{...n,...t}:n));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`The agent reports one by its key when its work is done; the description tells it when, and shows in the card's history.`}),(0,J.jsx)(`ul`,{"aria-label":`${e.name} outcomes`,className:`flex flex-col gap-1.5`,children:o.map((t,r)=>{let s=c[r]??{},l=`outcome ${t.key||r+1}`;return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-2xl bg-fill-subtle p-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,J.jsxs)(sn,{invalid:!!s.key,disabled:i,className:`min-w-0 flex-1`,children:[(0,J.jsx)(cn,{size:`sm`,"aria-label":`${e.name} outcome ${r+1} key`,value:t.key,placeholder:`Key, e.g. review`,disabled:i,onChange:e=>m(r,{key:e.target.value.trim()})}),s.key&&(0,J.jsx)(on,{children:s.key})]}),(0,J.jsx)(ut,{"aria-hidden":!0,className:`mt-2 size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsxs)(en,{value:t.to,disabled:i,onValueChange:e=>m(r,{to:String(e)}),children:[(0,J.jsx)(rn,{size:`sm`,"aria-label":`${e.name} ${l} goes to`,className:`w-24 shrink-0`,children:(0,J.jsx)(`span`,{className:`truncate`,children:f(t.to)})}),(0,J.jsx)($t,{children:n.map(e=>(0,J.jsx)(Qt,{value:e,children:f(e)},e))})]}),!i&&(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Remove ${l}`,onClick:()=>{let e=o.filter((e,t)=>t!==r);a(e.length>0?e:null)},children:(0,J.jsx)(te,{})})]}),(0,J.jsxs)(sn,{invalid:!!s.label,disabled:i,children:[(0,J.jsx)(cn,{size:`sm`,"aria-label":`${e.name} outcome ${r+1} label`,value:t.label,placeholder:`Description, e.g. Change request opened`,disabled:i,onChange:e=>m(r,{label:e.target.value})}),s.label&&(0,J.jsx)(on,{children:s.label})]})]},r)})}),p&&(0,J.jsx)(dr,{exitTool:p,picked:u,phases:t}),!i&&(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[l&&o.length<d&&(0,J.jsx)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(K,{}),onClick:()=>a([...o,l]),children:`Add outcome`}),(0,J.jsx)(T,{size:`sm`,variant:`ghost`,onClick:()=>a(null),children:`Use one per move`})]})]})}function dr({exitTool:e,picked:t,phases:n}){if(!t)return(0,J.jsx)(w,{variant:`warning`,children:(0,J.jsxs)(w.Message,{children:[`When `,(0,J.jsx)(`code`,{children:e}),` succeeds, no outcome is picked, so the card waits for the agent to report one. Key an outcome `,(0,J.jsx)(`code`,{children:`advance`}),` to choose where its success moves the card.`]})});let r=n.find(e=>e.key===t.to)?.name??t.to;return(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,children:[`When `,(0,J.jsx)(`code`,{children:e}),` succeeds, it reports `,(0,J.jsx)(`code`,{children:t.key}),`, moving the card to `,r,`.`]})}var fr=(e,t)=>e.runner?.context||t;function pr({phase:e,phases:t,boardId:n,defaultSession:r,phaseTools:i,disabled:a,onRunner:o,onTools:s,onBack:c}){let l=e.runner?.instructions??``,u=e.runner?.goal,d=u?.objective??``,f=e.tools??[],p=fr(e,r),h=t.filter(t=>t.key!==e.key&&t.kind===`working`&&fr(t,r)===p).map(e=>e.name);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-2`,children:[(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Back to ${e.name}`,onClick:c,children:(0,J.jsx)(m,{})}),(0,J.jsx)(U,{stage:e.key,kind:W(n,e.kind),decorative:!0}),(0,J.jsx)(j,{as:`h2`,variant:`card-title-strong`,className:`min-w-0 truncate`,children:e.name}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`shrink-0`,children:`Agent runs`})]}),(0,J.jsx)(mr,{title:`Instructions`,label:`${e.name} instructions`,value:l,max:Pt,placeholder:`Added to the agent's prompt when the phase starts.`,disabled:a,onChange:e=>o({instructions:e})}),(0,J.jsx)(mr,{title:`Goal`,label:`${e.name} goal`,value:d,max:Dt,placeholder:`The agent keeps working until a judge finds this met. Leave empty for a single run.`,disabled:a,onChange:e=>o({goal:e.trim()?{...u,objective:e}:void 0}),children:u&&(0,J.jsxs)(sn,{invalid:!Mt(u.maxRuns),disabled:a,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(an,{size:`smaller`,info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,J.jsx)(gn,{className:`w-32`,min:1,max:50,allowOutOfRange:!0,value:u.maxRuns??null,disabled:a,onValueChange:e=>{let{maxRuns:t,...n}=u;o({goal:e===null?n:{...n,maxRuns:e}})},children:(0,J.jsxs)(hn,{size:`sm`,children:[(0,J.jsx)(fn,{placeholder:`Default`}),(0,J.jsxs)(dn,{align:`inline-end`,variant:`flush`,children:[(0,J.jsx)(un,{className:`mr-1`,children:`runs`}),(0,J.jsx)(mn,{}),(0,J.jsx)(pn,{})]})]})})]}),!Mt(u.maxRuns)&&(0,J.jsxs)(on,{children:[`Use a whole number from 1 to `,50,`.`]})]})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,J.jsx)($,{label:`Session`,children:(0,J.jsx)(cn,{size:`sm`,className:`w-28`,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:r,disabled:a,onChange:e=>o({context:e.target.value})})}),(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,J.jsx)($e,{"aria-hidden":!0,className:`size-icon-xs shrink-0`}),h.length>0?`Shared with ${h.join(`, `)}, one per card`:`One per card`]})]}),(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Factory tools`,className:`flex flex-col gap-2.5 px-1`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:`Factory tools`}),i.map(t=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,children:t.label}),(0,J.jsx)(_n,{"aria-label":`${e.name}: ${t.label}`,checked:f.includes(t.id),disabled:a,onCheckedChange:e=>{let n=i.map(({id:e})=>e).filter(n=>n===t.id?e:f.includes(n));s(n.length>0?n:null)}})]},t.id))]})]})}function mr({title:e,label:t,value:n,max:r,placeholder:i,disabled:a,onChange:o,children:s}){let l=n.length>r;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,J.jsxs)(sn,{invalid:l,disabled:a,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(an,{size:`smaller`,children:e}),(0,J.jsx)(nr,{length:n.length,max:r})]}),(0,J.jsx)(ln,{"aria-label":t,value:n,placeholder:i,editable:!a,onChange:o,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1,className:N(c,u,`rounded-xl px-2 py-1.5`,a&&`bg-field-disabled`),"data-base-ui-swipe-ignore":``}),l&&(0,J.jsx)(on,{children:`Too long to save.`})]}),s]})}var hr=`__none__`;function gr({phaseName:e,skillName:t,skills:n,skillsEditable:r,skillHref:a,skillsHref:o,newSkillHref:s,badges:c,disabled:l,LinkComponent:u,onChange:d}){let p=t?n?.find(e=>e.name===t):void 0,m=t!==void 0&&n!==void 0&&p===void 0,h=(n??[]).map(e=>e.name);t&&!h.includes(t)&&h.push(t);let g=[{value:hr,label:`No skill`},...h.map(e=>({value:e,label:e}))],_=p!==void 0&&c.length>0;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)($,{label:`Skill`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,J.jsx)(Be,{options:g,value:t??hr,variant:`ghost`,size:`sm`,align:`end`,searchPlaceholder:`Search skills`,emptyText:`No skill matches`,"aria-label":`${e} skill`,disabled:l,className:`min-w-0`,onValueChange:e=>d(e===hr||e===``?void 0:e)}),p&&(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`${r?`Edit`:`View`} ${p.name}`,render:(0,J.jsx)(u,{href:a}),children:r?(0,J.jsx)(vn,{}):(0,J.jsx)(f,{})})]})}),(m||p?.error||_)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[m&&(0,J.jsx)(i,{variant:`destructive`,size:`sm`,children:`Not found`}),p?.error&&(0,J.jsx)(i,{variant:`destructive`,size:`sm`,children:`Failed to load`}),p&&c.map(e=>(0,J.jsx)(i,{children:e},e))]}),(0,J.jsx)(_r,{skill:p,missing:m,skillName:t,phaseName:e}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,J.jsx)(T,{size:`sm`,variant:`ghost`,render:(0,J.jsx)(u,{href:o}),children:`All skills`}),r&&(0,J.jsx)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(K,{}),render:(0,J.jsx)(u,{href:s}),children:`New skill`})]})]})}function _r({skill:e,missing:t,skillName:n,phaseName:r}){return e?.error?(0,J.jsxs)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,e.error]}):t?(0,J.jsxs)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,n,` skill, so cards entering `,r,` fail to start.`]}):e?.description?(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`line-clamp-2`,children:e.description}):null}function vr({phase:e,phases:t,nextPhases:n,requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,skillHref:s,skillsHref:c,newSkillHref:l,skillBadges:u,outcomes:d,defaultSession:f,phaseTools:p,boardId:m,disabled:h,total:g,autoStartConditions:_,autoStartProblem:v,autoApproveConditions:y,autoApproveProblem:b,LinkComponent:x,onName:S,onDescription:C,onKind:ee,onAutoStart:w,onRunner:E,onTools:ne,onExitTool:D,onAutoApprove:O,onNextPhases:k,onOutcomes:A,onUnfinished:M,onRemove:N,onClose:ae}){let[P,F]=(0,Y.useState)(!1),I=e.kind===`working`,L=e.exitTool?.id??``,oe=e.runner?.instructions??``,R=e.runner?.goal;if(I&&P)return(0,J.jsx)(se,{label:`${e.name} agent runs`,children:(0,J.jsx)(pr,{phase:e,phases:t,boardId:m,defaultSession:f,phaseTools:p,disabled:h,onRunner:E,onTools:ne,onBack:()=>F(!1)})});let z=[oe.length>1e3&&(0,J.jsx)($,{label:`Instructions`,children:(0,J.jsx)(nr,{length:oe.length,max:1e3})},`instructions`),(R?.objective.length??0)>2e3&&(0,J.jsx)($,{label:`Goal`,children:(0,J.jsx)(nr,{length:R?.objective.length??0,max:2e3})},`goal`),!Mt(R?.maxRuns)&&(0,J.jsx)($,{label:`Pause goal after`,children:(0,J.jsxs)(j,{as:`span`,variant:`caption`,className:`text-warning-foreground`,children:[R?.maxRuns,` runs`]})},`runs`)].filter(Boolean);return(0,J.jsxs)(se,{label:e.name,children:[(0,J.jsx)(or,{phase:e,boardId:m,total:g,readOnly:h,kindLocked:i,onName:S,onDescription:C,onKind:e=>{M(`autoStartWhen`,!1),M(`autoApproveWhen`,!1),ee(e)},onClose:ae}),I&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Q,{icon:(0,J.jsx)(Le,{}),title:`Starts`,children:[(0,J.jsx)($,{label:`Start on its own`,children:(0,J.jsx)(_n,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:h,onCheckedChange:e=>{w(e),e||M(`autoStartWhen`,!1)}})}),e.autoStart&&(0,J.jsx)(yr,{rule:e.autoStartWhen,problem:v,disabled:h,children:_},`${e.key}.autoStartWhen`)]}),(0,J.jsxs)(Q,{icon:(0,J.jsx)(Bt,{}),title:`Agent runs`,children:[(0,J.jsx)(gr,{phaseName:e.name,skillName:e.runner?.skill,skills:a,skillsEditable:o,skillHref:s,skillsHref:c,newSkillHref:l,badges:u,disabled:h,LinkComponent:x,onChange:e=>E({skill:e})}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>F(!0),className:`flex min-h-6 items-center justify-between gap-1.5 text-left text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,children:`Instructions, goal, session, tools`}),z.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(re,{"aria-hidden":!0,className:`ml-auto size-icon-xs text-warning-foreground`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`(can't save)`})]}),(0,J.jsx)(ie,{"aria-hidden":!0,className:`size-icon-xs shrink-0`})]}),z]}),(0,J.jsxs)(Q,{icon:(0,J.jsx)(yt,{}),title:`Ends`,children:[(0,J.jsx)($,{label:`Exit tool`,children:(0,J.jsx)(cn,{size:`sm`,className:`w-32`,"aria-label":`${e.name} exit tool`,value:L,placeholder:`None`,disabled:h,onChange:e=>{let t=e.target.value.trim();D(t),t||M(`autoApproveWhen`,!1)}})}),L!==``&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{label:`Approve on its own`,children:(0,J.jsx)(_n,{"aria-label":`${e.name}: approve ${L} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:h,onCheckedChange:e=>{O(e),e||M(`autoApproveWhen`,!1)}})}),e.exitTool?.autoApprove&&(0,J.jsx)(yr,{rule:e.exitTool.autoApproveWhen,problem:b,disabled:h,children:y},`${e.key}.autoApproveWhen`)]})]})]}),(0,J.jsx)(Q,{icon:(0,J.jsx)(Ye,{}),title:`Allowed moves`,children:(0,J.jsx)(cr,{phase:e,phases:t,next:n,required:r,boardId:m,disabled:h,onChange:k})}),I&&(0,J.jsx)(Q,{icon:(0,J.jsx)(Wt,{}),title:`Outcomes`,children:(0,J.jsx)(ur,{phase:e,phases:t,next:n,info:d,disabled:h,onChange:A})}),N&&(0,J.jsx)(`div`,{children:(0,J.jsxs)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(te,{}),onClick:N,children:[`Remove `,e.name]})})]})}function yr({rule:e,problem:t,disabled:n,children:r}){return n&&!e?.conditions.length?null:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:`Only when`}),r,t&&(0,J.jsx)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:t})]})}var br=(0,Y.createContext)(void 0);function xr(e,t,n){return`${e}:${t}:${n.revision??`code`}`}function Sr({children:e}){let t=(0,Y.useState)(void 0);return(0,J.jsx)(br.Provider,{value:t,children:e})}function Cr(e,t,n){let r=(0,Y.useContext)(br);if(!r)throw Error(`useBoardDraft must be used inside BoardDraftProvider`);let[i,a]=r,o=st(e,t),s=xr(e,t,n),c=i?.key===s?i:{key:s,draft:dt(n)},l=e=>a(t=>e(t?.key===s?t:{key:s,draft:dt(n)}));return{draft:c.draft,locked:o,setDraft:e=>l(t=>({...t,draft:e(t.draft)})),discard:()=>a(void 0)}}var wr=D(new URLSearchParams,!0);function Tr(e,t){let n=Yt(e),r=Ht(e),i=Oe(e),a=_e(e),o=je(e),s=x(e,Ge({board:t,sort:ne,search:``,filters:wr,windows:{},item:void 0})),c=new Map((o.data?.boards??[]).flatMap(e=>e.rules.map(e=>[e.routeId,e.filed]))),l=new Map((a.data?.skipped??[]).map(e=>[e.routeId,e])),u=new Map((s.data?.phases??[]).map(e=>[e.phase,e.total]));return{boards:n.data??[],installed:n.data?.find(e=>e.id===t),rules:r.data?.intakeRoutes,rulesFailed:r.isError,rulesEditable:r.data?.canEdit??!1,order:i.data,filed:c,skips:l,totals:u}}function Er(e){let[t,n]=(0,Y.useState)({page:e,fields:[]});return t.page!==e&&n({page:e,fields:[]}),{fields:t.page===e?t.fields:[],mark:(t,r)=>n(n=>{let i=(n.page===e?n.fields:[]).filter(e=>e!==t);return{page:e,fields:r?[...i,t]:i}})}}function Dr({factoryId:e,boardId:t,boards:n,onDeleted:r}){let i=l();return{reset:jt(e,t),remove:et(e,t,()=>{r();let a=Zt(n).find(e=>e.id!==t);i(a?Jt(e,a.id):`/factories/${e}`,{replace:!0})})}}function Or({board:e,draft:t,readOnly:n,manageable:r,locked:i,writes:a,rulesFailed:o,onChange:s}){let{reset:c,remove:l}=a;return(0,J.jsx)(Dn,{name:t.name,description:t.description,readOnly:n,manageable:r,editable:e.editable,problems:e.problems,rulesFailed:o,actions:{boardName:e.name,resettable:e.source!==`stored`,deletable:e.source!==`builtin`,busy:c.isPending||l.isPending,disabled:i,onReset:()=>c.mutate(e.revision??0),onDelete:()=>l.mutate(e.revision??0)},errors:{resetError:c.error?.reasons,deleteError:l.error?.reasons},onChange:s})}function kr({phase:e,phases:t,requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,factoryId:s,boardId:c,disabled:l,total:u,unfinished:d,onChange:f,onUnfinished:p,onRemove:m,onClose:h}){let g=he(s),_=e.exitTool?.id??``,v=e.runner?.skill,y=v?a?.find(e=>e.name===v):void 0,b=e.outcomes?.length?e.outcomes:void 0,x=vt(e,t),S=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));f({...e,runner:Object.keys(r).length>0?r:null})},C={"source.repository":g};return(0,J.jsx)(vr,{phase:e,phases:t,nextPhases:Rt(e,t),requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,skillHref:v?xn(s,v):void 0,skillsHref:bn(s,`skills`),newSkillHref:yn(s),skillBadges:y?qt(y):[],outcomes:{defaults:x,problems:b?it(b):[],added:b?We(e,t,b):void 0,exitToolPick:Lt(b??x,t),max:20},defaultSession:pt,phaseTools:gt,boardId:c,disabled:l,total:u,autoStartConditions:(0,J.jsx)(be,{label:`Only when`,rule:e.autoStartWhen,facts:Je,options:C,disabled:l,emptyHint:`Leave empty to start every card on its own.`,onChange:(t,n)=>{p(`autoStartWhen`,n),n||f({...e,autoStartWhen:t})}}),autoStartProblem:d.includes(`autoStartWhen`)?void 0:Et(e.autoStartWhen),autoApproveConditions:(0,J.jsx)(be,{label:`Only when`,rule:e.exitTool?.autoApproveWhen,facts:Je,options:C,disabled:l,emptyHint:`Leave empty to approve for every card.`,onChange:(t,n)=>{p(`autoApproveWhen`,n),n||f({...e,exitTool:{...e.exitTool,id:_,autoApprove:!0,autoApproveWhen:t??void 0}})}}),autoApproveProblem:d.includes(`autoApproveWhen`)?void 0:Et(e.exitTool?.autoApproveWhen),LinkComponent:n,onName:t=>f({...e,name:t}),onDescription:t=>f({...e,description:t}),onKind:n=>f(Ue(e,n,t)),onAutoStart:t=>f(wt(e,t)),onRunner:S,onTools:t=>f({...e,tools:t}),onExitTool:t=>f({...e,exitTool:t?{...e.exitTool,id:t}:null}),onAutoApprove:t=>f({...e,exitTool:{...e.exitTool,id:_,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),onNextPhases:t=>f(Ct(e,t)),onOutcomes:t=>f({...e,outcomes:t}),onUnfinished:p,onRemove:m,onClose:h})}function Ar({factoryId:e,boardId:t,focus:n,phase:r,phasePage:i,phases:a,boardTitle:o,codeBehaviour:s,skills:c,disabled:l,totals:u,onFocus:d,onClose:f,onChange:p,unfinished:m,onUnfinished:h,onRemove:g}){if(n&&`rule`in n)return(0,J.jsx)(De,{factoryId:e,boardId:t,focus:{rule:n.rule},backTo:n.test,onFocus:d,onClose:f},n.rule);if(n&&`newRule`in n){let{on:r,into:i,board:a}=n.newRule;return(0,J.jsx)(De,{factoryId:e,boardId:t,focus:n,onFocus:d,onClose:f},`new:${r??``}:${i??``}:${a??``}`)}if(n){let{test:r}=n;return(0,J.jsx)(we,{factoryId:e,boardId:t,subject:r,onEditRule:e=>d({rule:e,test:r}),onClose:f})}if(r){let n=!l&&kt(a,r.key,s);return(0,J.jsx)(kr,{phase:r,phases:a,requiredNextPhases:s?.[r.key]?.requiredNextPhases??[],kindLocked:zt(a,r.key,s),skills:c?.skills,skillsEditable:c?.canEdit??!1,factoryId:e,boardId:t,disabled:l,total:u.get(r.key),unfinished:m,onChange:p,onUnfinished:h,onRemove:n?()=>g(r.key):void 0,onClose:f},i)}return(0,J.jsx)(rr,{boardTitle:o,boardHref:G(e,t),LinkComponent:Xt})}function jr(e,t,n){let r=Ut(e,n);return r?r.parts.map((e,t)=>t===0?e:`${r.join} ${e.charAt(0).toLowerCase()}${e.slice(1)}`):[t]}function Mr(e,t,n,r,i){return{ruleId:e.rule.id,name:e.rule.name,enabled:e.rule.enabled,event:e.event,trigger:xt(e.event),opened:Ot(e.event),rank:e.rank,of:e.of,label:e.label,conditions:jr(e.rule.when,ht(e.event),nt(i)),filed:e.filed,skipsOutsiders:e.skipsOutsiders,movesCardsOnly:e.movesCardsOnly,notes:Me(e),place:r.note(e),href:t,emphasis:n,onPeek:t=>r.onPeek(t?e.event:void 0)}}function Nr(e,t,n,r){let i=t.find(t=>t.id===e.target.boardKey);return{ruleId:e.id,name:e.name,enabled:e.enabled,conditions:jr(e.when,`Every card`,nt(i)),boardName:i?St(i):e.target.boardKey,href:n,emphasis:r}}function Pr({factoryId:e,boardId:t,boards:n,leaving:r,stray:i,strayIncoming:a,emphasis:o,outside:s,lanes:c}){let l=n.find(e=>e.id===t),u=n=>Mr(n,G(e,t,void 0,{rule:n.rule.id}),o(n),c,l),d=r.map(t=>{let r=t.rule.target.moveToBoardKey??t.rule.target.boardKey,i=n.find(e=>e.id===r),a=t.rule.target.phaseKey??i?.initialPhase,o=i?.phases.find(e=>e.id===a);return{line:u(t),href:G(e,r,a??void 0),stage:a&&i?{key:a,boardId:r,kind:o?.kind??`resting`}:void 0,phaseName:tt(i,t.rule.target.phaseKey),boardName:i?St(i):r}});return(0,J.jsx)(tr,{leaving:d,stray:i.map(u),strayIncoming:a.map(t=>Nr(t,n,G(e,t.target.boardKey,void 0,{rule:t.id}),s(t.id))),LinkComponent:Xt})}function Fr(e,t){if(!e||t===void 0)return;let n=t.find(t=>t.name===e);return n?n.error===void 0?void 0:`Skill failed to load`:`Skill not found`}function Ir({factoryId:e,boardId:t,model:n,boards:r,totals:i,emphasis:a,lanes:o,selectedPhase:s,selectedRule:c,problems:l,rulesEditable:u,edit:d,order:f,skills:p}){let m=n.rows.map(e=>e.phase),h=r.find(e=>e.id===t),g={rows:n.rows.map(n=>{let{phase:i}=n;return{phase:i,lines:n.lines.map(n=>Mr(n,G(e,t,void 0,{rule:n.rule.id}),a.line(n,i.key),o,h)),incoming:n.incoming.map(t=>Nr(t,r,G(e,t.target.boardKey,void 0,{rule:t.id}),a.outside(t.id))),unreached:n.unreached,start:n.start,emphasis:a.node(i.key),next:Rt(i,m).filter(e=>e!==i.key),automatic:ve(i,m),work:i.kind===`working`?{skill:i.runner?.skill,skillProblem:Fr(i.runner?.skill,p),autoStart:!!i.autoStart,exit:i.exitTool?{id:i.exitTool.id,approval:Tt(i.exitTool)}:void 0,goal:i.runner?.goal,tools:(i.tools??[]).map(It).join(`, `)}:void 0,href:G(e,t,i.key),newRuleHref:G(e,t,void 0,{newRule:{into:i.key}})}}),sessions:ge(m)};return(0,J.jsx)(Yn,{boardId:t,model:g,totals:i,selectedPhase:s,selectedRule:c,problems:l,rulesEditable:u,edit:d&&{...d,keyFromName:Vt,keyProblem:ft},intake:{sentence:f&&ye(f.boards,f.evaluator,t),reorderHref:He(e,t,{anchor:ct}),asked:f!==void 0&&(f.evaluator===`route-list`||f.boards.some(e=>e.boardKey===t))},LinkComponent:Xt})}function Lr(e,t){if(e.name.trim()===``)return`Name the board to save.`;if(t.length!==0)return`Fix ${t.map(e=>e.name||e.key).join(`, `)} to save.`}function Rr({factoryId:e,boardId:t,phaseKey:n,response:r,onReload:i}){let{board:a,canEdit:o=!1}=r,{draft:s,locked:c,setDraft:u,discard:f}=Cr(e,t,a),m=Tr(e,t),g=Kt(e),[_]=d(),y=Ft(_),b=l(),x=h(),S=Qe(e,t),C=Dr({factoryId:e,boardId:t,boards:m.boards,onDeleted:f}),w=fe(),[T,E]=(0,Y.useState)(0),[te,ne]=(0,Y.useState)(),D=!o||!a.editable,O=D||c,k=n?s.phases.find(e=>e.key===n):void 0,re=s.name||a.name,A=(n,r)=>void b(G(e,t,n,r)),j=k&&`${k.key}:${a.revision??`code`}:${T}:${w?`phone`:`wide`}`,M=Er(j),ie=!D&&(_t(s,a)||M.fields.length>0),N=s.phases.filter(e=>qe(e)||e===k&&M.fields.length>0),ae=Lr(s,N),F=S.error?.code===`revision_mismatch`,I=v(({nextLocation:n})=>{let r=x.getQueryData(p.boardCatalog(e))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=mt(n.pathname);return i?.factoryId!==e||i.boardId!==t||i.intake===!0});ee(e=>{ie&&e.preventDefault()});let L=()=>{f(),E(e=>e+1)},se=e=>u(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)})),R=Ee({boardKey:t,phases:s.phases,rules:m.rules,flow:m.installed?.flow,filed:m.filed,skips:m.skips}),z=y&&`rule`in y?y.rule:void 0,B=y?void 0:k?.key,V=y&&`test`in y?y.test:void 0,ce=ue(e,z?void 0:V),le=Ce(R,s.phases,{phase:B,rule:z,test:ce.data&&{boardKey:t,result:ce.data},lane:te}),de=e=>{let n=e.rule.target.moveToBoardKey;if(n&&n!==t){let e=m.boards.find(e=>e.id===n);return e?St(e):n}let r=e.rule.target.phaseKey??s.phases[0]?.key;return s.phases.find(e=>e.key===r)?.name??`a removed phase`},he={note:e=>me(e,R.lines,de),onPeek:ne};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P,{label:`${re} settings`,tabs:(0,J.jsx)(Te,{factoryId:e,boardId:t,active:`settings`}),header:(0,J.jsx)(Or,{board:a,draft:s,readOnly:O,manageable:!D,locked:c,writes:C,rulesFailed:m.rulesFailed,onChange:e=>u(t=>({...t,...e}))}),panel:y||n?{content:(0,J.jsx)(Ar,{factoryId:e,boardId:t,focus:y,phase:k,phasePage:j,phases:s.phases,boardTitle:re,codeBehaviour:a.codeBehaviour,skills:g.data,disabled:O,totals:m.totals,onFocus:e=>A(void 0,e),onClose:()=>A(),onChange:se,unfinished:M.fields,onUnfinished:M.mark,onRemove:e=>{u(t=>({...t,phases:Ke(t.phases,e)})),A()}}),onClose:()=>A()}:void 0,bar:(0,J.jsxs)(J.Fragment,{children:[ie&&(0,J.jsx)(Sn,{hold:ae,stale:F,error:S.error?.reasons,saving:S.isPending,onSave:()=>S.mutate({name:s.name,description:s.description,phases:s.phases,expectedRevision:a.revision??0}),onDiscard:L,onReload:i}),(0,J.jsx)(pe,{children:(0,J.jsx)(oe,{defaultValue:V,onTest:e=>A(void 0,{test:e})},V)})]}),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-14`,children:[(0,J.jsx)(Ir,{factoryId:e,boardId:t,model:R,boards:m.boards,totals:m.totals,emphasis:le,lanes:he,selectedPhase:B,selectedRule:z,problems:new Set(N.map(e=>e.key)),rulesEditable:m.rulesEditable,order:m.order,skills:g.data?.skills,edit:O?void 0:{required:e=>new Set(a.codeBehaviour?.[e]?.requiredNextPhases),onMoves:(e,t)=>u(n=>({...n,phases:n.phases.map(n=>n.key===e?Ct(n,t):n)})),onReorder:(e,t)=>u(n=>({...n,phases:rt(n.phases,e,t)})),onAdd:(e,t,n)=>{u(n=>({...n,phases:[...n.phases.slice(0,t),{...e,kind:`resting`,nextPhases:[]},...n.phases.slice(t)]})),n&&A(e.key)}}}),(0,J.jsx)(Pr,{factoryId:e,boardId:t,boards:m.boards,leaving:R.leaving,stray:R.stray,strayIncoming:R.strayIncoming,emphasis:e=>le.line(e),outside:le.outside,lanes:he})]})}),(0,J.jsx)(Cn,{boardName:a.name,open:I.state===`blocked`,onStay:()=>I.reset?.(),onLeave:()=>{f(),I.proceed?.()}})]})}function zr(){return(0,J.jsx)(Sr,{children:(0,J.jsx)(bt,{variant:`page`,body:`fixed`,children:(0,J.jsx)(Br,{})})})}function Br(){let e=Xe(),t=ke(),n=t?.boardId??``,r=at(e.id,n);return r.isPending?(0,J.jsx)(P,{label:`Board settings`,tabs:(0,J.jsx)(Te,{factoryId:e.id,boardId:n,active:`settings`}),header:(0,J.jsx)($n,{}),children:(0,J.jsx)(er,{})}):r.isError&&r.error instanceof ot&&r.error.code===`board_not_found`?(0,J.jsx)(Vr,{factoryId:e.id,boardId:n,children:(0,J.jsx)(Gt,{variant:`fill`,titleSlot:(0,J.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})})}):r.isError?(0,J.jsx)(Vr,{factoryId:e.id,boardId:n,children:(0,J.jsx)(Nt,{title:`Couldn’t load this board`,error:r.error,onRetry:()=>void r.refetch(),retrying:r.isFetching})}):(0,J.jsx)(Rr,{factoryId:e.id,boardId:n,phaseKey:t?.phaseKey,response:r.data,onReload:()=>void r.refetch()},`${n}:${r.data.board.revision??`code`}`)}function Vr({factoryId:e,boardId:t,children:n}){return(0,J.jsx)(P,{label:`Board settings`,tabs:(0,J.jsx)(Te,{factoryId:e,boardId:t,active:`settings`}),status:n})}export{zr as BoardConfigPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./SettingsHrefLink-Db7cEjn2.js";import{t as r}from"./AlertDialog.es-3WmOEwXa.js";import{c as i,l as a,o}from"./TabsRoot-D-RAt6qK.js";import{$i as s,Li as c,Mr as l,Ni as u,Tr as d,Tt as f,Y as p,Zn as m,_i as h,ea as g,ec as _,kr as v,na as y,on as b,ot as x,rc as S,tc as C,wr as ee,wt as w,xi as T}from"./useFactories-BbPGoUnu.js";import{t as E}from"./IconArrowRotateCounterClockwise.es-mQeFJ69W.js";import{S as te,c as ne,y as D}from"./boardViews-BIfUY2Os.js";import{D as O,O as k,a as re,d as A,n as j,s as M,t as ie,w as N}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{A as ae,B as P,C as F,D as I,F as L,G as oe,H as se,I as R,L as z,M as B,O as V,P as ce,R as le,S as ue,T as de,U as fe,W as pe,_ as me,a as he,b as ge,d as _e,g as ve,h as ye,i as be,j as xe,k as Se,m as Ce,n as we,o as Te,p as Ee,r as De,s as Oe,t as ke,w as Ae,x as je,y as Me,z as Ne}from"./useBoardConfigRoute-BTs9lUfW.js";import{n as Pe,t as H}from"./IconLock.es-ClES7xwW.js";import{s as Fe}from"./highlight-B5yoRWjq-BF8vnsDR.js";import{b as U,g as Ie,v as Le,x as W,y as Re}from"./useLinearData-D-jzoXrj.js";import{t as ze}from"./password-manager-autofill.es-Cs1VH0JI.js";import{n as Be,t as Ve}from"./IconArrowSplitUp.es-Dc9FE6G_.js";import{$r as He,Ar as Ue,Cr as We,Dn as Ge,Dr as Ke,Er as qe,Fr as Je,Gi as Ye,Gr as Xe,Ji as Ze,Jn as Qe,Ki as $e,Kn as et,Mn as tt,Nn as nt,Qr as G,Sr as rt,Tr as it,Un as at,Vn as ot,Wn as st,Xr as ct,Yi as lt,_a as ut,_r as dt,br as ft,dr as pt,ei as mt,er as ht,fr as gt,gr as _t,hr as vt,ia as yt,ii as bt,ir as xt,jn as St,jr as Ct,kr as wt,lr as Tt,ma as K,mr as Et,na as Dt,nr as Ot,pr as kt,qi as At,qn as jt,ra as Mt,ri as Nt,ta as Pt,ti as Ft,ur as It,vr as Lt,wr as Rt,xr as zt,ya as Bt,yr as Vt,zn as Ht,zr as Ut}from"./index-DJ3zJOT1.js";import{t as Wt}from"./IconTarget.es-vG08S5YA.js";import{i as q,t as Gt}from"./EmptyState-IMGHVwoU-BG_Y81ux.js";import{a as Kt,n as qt}from"./SkillBadges-0KsadppP.js";import{l as Jt,r as Yt,t as Xt,u as Zt}from"./HrefLink-B8qef5fl.js";import{Dt as Qt,Et as $t,Tt as en,bn as tn,kn as nn,kt as rn}from"./useSessionRows-BFZXJZw8.js";import{a as an,r as on,t as sn}from"./Field.es-0wnJ5PYU.js";import{t as cn}from"./input-DqReKX0A-BkAmakZI.js";import{t as ln}from"./code-editor-BLzt8hly-_gqni7f_.js";import{a as un,n as dn}from"./input-group-BXqgO3Q2-6Yh1L4oM.js";import{a as fn,i as pn,n as mn,r as hn,t as gn}from"./InputNumber.es-DCXJJF_B.js";import{n as _n}from"./IconClock.es-DLEl_5Yx.js";import{a as vn}from"./RadioGroup-Du9_UyvT.js";import{a as yn,c as bn,l as xn}from"./settingsSections-rQ9VqtBb.js";var J=O();function Sn({hold:e,stale:t,error:n,saving:r,onSave:i,onDiscard:a,onReload:o}){return(0,J.jsxs)(`div`,{className:`flex w-full max-w-130 flex-col items-center gap-2`,children:[t&&(0,J.jsx)(w,{variant:`warning`,title:`Someone else changed this board`,action:(0,J.jsx)(w.Button,{onClick:o,children:`Reload`}),className:`w-full bg-card shadow-overlay`,children:(0,J.jsx)(w.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),n&&!t&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,className:`w-full bg-card shadow-overlay`,children:(0,J.jsxs)(w.Message,{children:[`The board was not saved. `,n]})}),(0,J.jsx)(R,{label:e??`Unsaved changes`,held:e!==void 0,saveLabel:`Save`,saving:r,onSave:i,onDiscard:a})]})}function Cn({boardName:e,open:t,onStay:n,onLeave:i}){return(0,J.jsx)(r,{open:t,onOpenChange:e=>!e&&n(),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Discard changes to `,e,`?`]}),(0,J.jsx)(r.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Keep editing`}),(0,J.jsx)(T,{variant:`destructive`,size:`md`,onClick:i,children:`Discard`})]})]})})}var Y=e(k(),1);function wn({boardName:e,resettable:t,deletable:n,busy:i,disabled:o,onReset:s,onDelete:c}){let[l,u]=(0,Y.useState)();return!t&&!n?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(a,{children:[(0,J.jsx)(a.Trigger,{variant:`ghost`,size:`icon-sm`,tooltip:`Board actions`,"aria-label":`Board actions`,disabled:o||i,children:i?(0,J.jsx)(S,{size:`sm`}):(0,J.jsx)(le,{})}),(0,J.jsxs)(a.Content,{align:`start`,children:[t&&(0,J.jsxs)(a.Item,{onClick:()=>u(`reset`),children:[(0,J.jsx)(E,{}),`Reset to default`]}),n&&(0,J.jsxs)(a.Item,{variant:`destructive`,onClick:()=>u(`delete`),children:[(0,J.jsx)(te,{}),`Delete board`]})]})]}),(0,J.jsx)(r,{open:l===`reset`,onOpenChange:e=>!e&&u(void 0),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Reset `,e,` to default?`]}),(0,J.jsx)(r.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Cancel`}),(0,J.jsx)(r.Action,{onClick:s,children:`Reset`})]})]})}),(0,J.jsx)(r,{open:l===`delete`,onOpenChange:e=>!e&&u(void 0),children:(0,J.jsxs)(r.Content,{children:[(0,J.jsxs)(r.Header,{children:[(0,J.jsxs)(r.Title,{children:[`Delete `,e,`?`]}),(0,J.jsx)(r.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,J.jsxs)(r.Footer,{children:[(0,J.jsx)(r.Cancel,{children:`Cancel`}),(0,J.jsx)(r.Action,{onClick:c,children:`Delete`})]})]})})]})}function Tn({resetError:e,deleteError:t}){return(0,J.jsxs)(J.Fragment,{children:[e!==void 0&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,children:(0,J.jsxs)(w.Message,{children:[`The board was not reset. `,e]})}),t!==void 0&&(0,J.jsx)(w,{variant:`destructive`,role:`alert`,children:(0,J.jsxs)(w.Message,{children:[`The board was not deleted. `,t]})})]})}var En=`mb-10 flex max-w-2xl flex-col gap-1`;function Dn({name:e,description:n,readOnly:r,manageable:i,editable:a,problems:o,rulesFailed:s,actions:c,errors:l,onChange:u}){return(0,J.jsxs)(`header`,{className:En,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(j,{as:`h1`,variant:`display`,tone:`ink`,className:`min-w-0`,children:(0,J.jsx)(t,{value:e,label:`Board name`,required:!0,readOnly:r,variant:`display`,tone:`ink`,onChange:e=>u({name:e})})}),i&&(0,J.jsx)(wn,{...c})]}),(n||!r)&&(0,J.jsx)(j,{as:`p`,variant:`body`,tone:`muted`,children:(0,J.jsx)(t,{value:n??``,label:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:r,variant:`body`,tone:`muted`,className:`w-[calc(100%+--spacing(3))] placeholder:text-subtle-foreground`,onChange:e=>u({description:e||null})})}),(!i||o.length>0||s||l.resetError!==void 0||l.deleteError!==void 0)&&(0,J.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[!i&&(0,J.jsx)(w,{variant:`note`,icon:(0,J.jsx)(H,{}),children:(0,J.jsx)(w.Message,{children:a?`Only organization admins can change this board.`:`This board is defined in code, so it can’t be changed here.`})}),o.length>0&&(0,J.jsx)(w,{variant:`warning`,title:`This board has problems`,children:(0,J.jsx)(w.Message,{children:o.join(` `)})}),s&&(0,J.jsx)(w,{variant:`warning`,children:(0,J.jsx)(w.Message,{children:`Rules didn’t load, so the map doesn’t show them.`})}),(0,J.jsx)(Tn,{...l})]})]})}var On=`duration-normal ease-out-custom transition-opacity motion-reduce:transition-none group-data-dragging/flow:opacity-0`,kn=`relative mb-8 flex w-89.5 flex-col gap-1 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`;function An({sentence:e,reorderHref:t,linked:n,LinkComponent:r}){return(0,J.jsxs)(`section`,{"data-intake-start":``,"aria-labelledby":`canvas-intake`,className:N(_,kn),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(Fe,{className:`size-icon-sm shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(j,{as:`h2`,id:`canvas-intake`,variant:`card-title-strong`,tone:`ink`,className:`min-w-0 flex-1 truncate`,children:`New issues and pull requests`}),(0,J.jsxs)(r,{href:t,className:N(`flex shrink-0 items-center gap-1 rounded-sm text-caption text-muted-foreground hover:text-foreground`,M),children:[`Reorder`,(0,J.jsx)(Re,{className:`size-icon-xs`,"aria-hidden":!0})]})]}),e!==void 0&&(0,J.jsx)(j,{variant:`caption`,tone:`muted`,className:`pl-6 text-pretty`,children:e}),n&&(0,J.jsx)(B,{className:N(`absolute -bottom-1.25 left-3.75`,On)})]})}function jn({linked:e}){return(0,J.jsx)(`span`,{"aria-hidden":!0,"data-intake-branch":e?``:void 0,className:N(`-mr-1 flex min-w-2.5 flex-1 items-center justify-end max-sm:hidden`,On,!e&&`opacity-0`),children:(0,J.jsx)(B,{})})}function Mn({flow:e}){let[t,n]=(0,Y.useState)();return(0,Y.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=Nn(t);n(t=>t?.join()===e?.join()?t:e)};r();let i=new ResizeObserver(r);i.observe(t);for(let e of t.querySelectorAll(`[data-rules-in]`))i.observe(e);return()=>i.disconnect()}),t?(0,J.jsx)(`svg`,{"aria-hidden":!0,className:N(ae,`pointer-events-none absolute inset-0 size-full overflow-visible`,On),children:t.map(e=>(0,J.jsx)(`path`,{d:e},e))}):null}function Nn(e){let t=e.querySelector(`[data-intake-start] [data-port]`),n=[...e.querySelectorAll(`[data-intake-branch] [data-port]`)].filter(e=>e instanceof HTMLElement);if(!(t instanceof HTMLElement)||n.length===0)return;let r=L(t,e),i=r.left+t.offsetWidth/2,a=r.top+t.offsetHeight,o=n.map(t=>{let n=L(t,e);return{y:n.top+t.offsetHeight/2,to:n.left}}),s=Math.max(...o.map(e=>e.y));return o.map(e=>ce([...e.y===s?[{x:i,y:a}]:[],{x:i,y:e.y},{x:e.to,y:e.y}]))}var Pn=A(`IconArrowDownRight`,()=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d:`M18 9V18H9`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`path`,{d:`M6.25 6.25L17 17`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),3);function Fn({rule:e,stray:t=!1,LinkComponent:n}){let{emphasis:r}=e,i=t?`into a phase this board doesn’t have`:`here`;return(0,J.jsx)(F,{title:void 0,lines:[`“${e.name}” on ${e.boardName} moves cards ${i}.`,...e.conditions,...e.enabled?[]:[`Off, skipped`]],children:(0,J.jsxs)(n,{"data-join":``,"data-dimmed":r===`dimmed`||void 0,href:e.href,"aria-label":e.enabled?e.boardName:`${e.boardName}, off`,className:N(Ae,`border border-border bg-transparent text-body-sm transition-opacity`,e.enabled?`text-foreground`:`text-muted-foreground opacity-50`,r===`dimmed`&&`opacity-35`,r===`selected`&&`ring-foreground ring-2`),children:[(0,J.jsx)(Pn,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`truncate`,children:e.boardName}),!e.enabled&&(0,J.jsx)(`span`,{className:`shrink-0 text-caption`,children:`Off`})]})})}var In=`hover:bg-fill -mx-1.5 min-w-0 flex-1 rounded-md bg-transparent px-1.5 outline-none`;function Ln({boardId:e,takenKeys:t,linked:n,keyFromName:r,keyProblem:i,onAdd:a,onCancel:o}){let[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(),d=(0,Y.useRef)(!1),f=l??r(s),p=l===void 0&&s.trim()===``?void 0:i(f,t),m=s.trim()!==``&&p===void 0,h=e=>{d.current||(d.current=!0,e())};return(0,J.jsxs)(`form`,{"aria-label":`New phase`,onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Enter`?(e.preventDefault(),m&&h(()=>a({key:f,name:s.trim()},!0))):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),h(o)))},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(s.trim()===``?h(o):m&&h(()=>a({key:f,name:s.trim()},!1)))},className:N(_,`relative flex w-75 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`,`has-focus-visible:[--surface-rim:var(--border-focus)]`),children:[(0,J.jsx)(B,{className:N(Se,`-top-1.25`)}),(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(U,{stage:f,kind:W(e,`resting`),decorative:!0}),(0,J.jsx)(`input`,{"aria-label":`New phase name`,value:s,placeholder:`Phase name`,autoFocus:!0,...ze,onChange:e=>c(e.currentTarget.value),className:N(In,`text-card-title-strong text-foreground placeholder:text-muted-foreground`)})]}),(0,J.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-caption text-muted-foreground`,children:[`Key`,(0,J.jsx)(`input`,{"aria-label":`New phase key`,value:f,...ze,onChange:e=>u(e.currentTarget.value),className:N(In,`font-mono text-caption text-foreground`)})]}),p?(0,J.jsx)(`span`,{role:`alert`,className:`text-caption text-destructive-foreground`,children:p}):(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`Enter adds it. The key can’t change once added.`}),n&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-bottom-1.25`)})]})}var Rn=`relative flex w-75 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3 max-sm:w-full`;function zn({boardId:e,phase:t,phases:n,next:r,automatic:i,work:a,total:o,href:s,emphasis:c,problem:l,unreached:u,start:d,movable:f,moves:p,LinkComponent:m}){let h=o===void 0?void 0:o.toLocaleString(),g=t.kind===`terminal`,v=c===`selected`,y=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{v&&y.current?.scrollIntoView({block:`nearest`,behavior:`smooth`})},[v]),(0,J.jsxs)(`article`,{ref:y,"aria-label":t.name,className:N(_,C,`group/node scroll-mt-20 scroll-mb-40`,Rn,`transition-[opacity,box-shadow] duration-normal ease-out-custom motion-reduce:transition-none`,`group-data-dragging/row:shadow-overlay has-focus-visible:[--surface-rim:var(--border-focus)]`,c===`selected`&&`ring-foreground ring-2`,c===`dimmed`&&`opacity-35`,l&&c!==`selected`&&`ring-1 ring-warning-indicator`),children:[(0,J.jsxs)(`div`,{"data-inlet-at":``,className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(U,{stage:t.key,kind:W(e,t.kind),decorative:!0}),(0,J.jsx)(m,{href:s,"aria-current":c===`selected`?`true`:void 0,"aria-description":f?`Alt+Up or Alt+Down moves this phase.`:void 0,className:N(`truncate rounded-sm text-card-title-strong text-foreground`,`after:absolute after:inset-0 after:rounded-2xl`,M),children:t.name}),l&&(0,J.jsx)(z,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-label":`This phase has problems`}),!g&&h!==void 0&&(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-caption text-muted-foreground tabular-nums`,children:h})]}),g&&h!==void 0&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground tabular-nums`,children:h}),d&&(0,J.jsx)(`span`,{className:`text-caption text-muted-foreground`,children:`New cards start here`}),(0,J.jsx)(Bn,{kind:t.kind,work:a}),u&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-muted-foreground`,children:[(0,J.jsx)(z,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-hidden":!0}),`No rule or move leads here`]}),(r.length>0||p)&&(0,J.jsxs)(`div`,{className:`flex gap-2 border-t border-border pt-2.5`,children:[p?(0,J.jsx)(Hn,{boardId:e,phase:t,phases:n,next:r,shown:c===`selected`,...p}):(0,J.jsx)(Ve,{className:`mt-1.25 size-icon-xs shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(`ul`,{"aria-label":`Moves to`,className:`flex min-w-0 flex-wrap gap-1.5`,children:r.map(t=>{let r=n.find(e=>e.key===t);return(0,J.jsxs)(`li`,{className:`flex h-6 min-w-0 items-center gap-1 rounded-lg bg-background px-1.5`,children:[r&&(0,J.jsx)(U,{stage:t,kind:W(e,r.kind),decorative:!0}),(0,J.jsx)(`span`,{className:`truncate text-body-sm text-foreground`,children:r?.name??t}),i.has(t)&&(0,J.jsx)(Ne,{className:`size-icon-xs shrink-0 text-muted-foreground`,"aria-label":`on its own`})]},t)})})]})]})}function Bn({kind:e,work:t}){if(e===`resting`)return(0,J.jsx)(X,{icon:Pe,label:`Waits for someone`});if(e!==`working`||!t)return null;let{goal:n,tools:r}=t;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{icon:Bt,label:t.skill??`No skill`,broken:t.skillProblem!==void 0,detailIcon:t.autoStart?Ne:Pe,detail:t.autoStart?`On its own`:`By hand`}),t.skillProblem&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-caption text-destructive-foreground`,children:[(0,J.jsx)(z,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),t.skillProblem]}),t.exit&&(0,J.jsx)(X,{icon:yt,label:t.exit.id,detail:t.exit.approval}),n&&(0,J.jsx)(X,{icon:Wt,label:`Goal`,detail:n.maxRuns===void 0?void 0:`Pauses after ${n.maxRuns} runs`}),r&&(0,J.jsx)(X,{icon:Ie,label:r})]})}function X({icon:e,label:t,broken:n=!1,detail:r,detailIcon:i}){return(0,J.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5`,children:[(0,J.jsx)(e,{className:`mt-0.75 size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-between gap-x-3`,children:[(0,J.jsx)(`span`,{className:N(`min-w-0 truncate text-body-sm`,n?`text-destructive-foreground`:`text-foreground`),children:t}),r&&(0,J.jsxs)(`span`,{className:`flex max-w-full min-w-0 items-center gap-1 text-caption text-muted-foreground`,children:[i&&(0,J.jsx)(i,{className:`size-icon-xs shrink-0`}),(0,J.jsx)(`span`,{className:`line-clamp-2`,children:r})]})]})]})}var Vn=`col-start-1 row-start-1 size-icon-xs duration-normal ease-out-custom transition-opacity motion-reduce:transition-none`;function Hn({boardId:e,phase:t,phases:n,next:r,shown:i,required:o,onChange:s}){let c=e=>s(r.includes(e)?r.filter(t=>t!==e):n.filter(t=>t.key===e||r.includes(t.key)).map(e=>e.key));return(0,J.jsxs)(a,{children:[(0,J.jsx)(a.Trigger,{render:(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Change moves from ${t.name}`,className:N(`group/moves relative z-10 -mx-1.25 grid size-6 shrink-0 place-items-center rounded-full text-muted-foreground hover:bg-fill-hover hover:text-foreground`,`data-popup-open:bg-fill-hover data-popup-open:text-foreground`,M),children:[(0,J.jsx)(Ve,{className:N(Vn,i?`opacity-0`:`group-hover/node:opacity-0 group-focus-visible/moves:opacity-0 group-data-popup-open/moves:opacity-0`)}),(0,J.jsx)(K,{className:N(Vn,!i&&`opacity-0 group-hover/node:opacity-100 group-focus-visible/moves:opacity-100 group-data-popup-open/moves:opacity-100`)})]})}),(0,J.jsxs)(a.Content,{align:`start`,className:`w-56`,children:[(0,J.jsx)(a.Label,{children:`Cards can move to`}),n.filter(e=>e.key!==t.key).map(t=>{let n=r.includes(t.key)&&o.has(t.key);return(0,J.jsxs)(a.CheckboxItem,{checked:r.includes(t.key),disabled:n,onCheckedChange:()=>c(t.key),children:[(0,J.jsx)(U,{stage:t.key,kind:W(e,t.kind),decorative:!0}),(0,J.jsx)(`span`,{className:`truncate`,children:t.name}),n&&(0,J.jsx)(H,{className:`ml-auto size-icon-xs`,"aria-label":`Factory makes this move`})]},t.key)})]})]})}var Un=5,Wn=`border-muted-foreground/35 border-l-2`,Gn=`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,Kn=`w-30 shrink-0 max-sm:hidden`,qn=`border-border-strong text-caption text-muted-foreground hover:text-foreground flex items-center gap-1 rounded-full border border-dashed focus-visible:opacity-100`;function Jn(e,t){if(e)return`card`;if(t)return`entry`}function Yn({boardId:e,model:t,totals:n,selectedPhase:r,selectedRule:i,problems:a,rulesEditable:o,edit:s,intake:c,LinkComponent:l}){let u=t.rows.map(e=>e.phase),d=fe(),[f,p]=(0,Y.useState)(),m=e=>t.sessions.find(t=>e>=t.from&&e<=t.to),[h,g]=(0,Y.useState)(``),_=V({min:1,max:u.length-1,onDrop:(e,t)=>{s?.onReorder(e,t),g(`${u[e]?.name} moved to position ${t+1} of ${u.length}.`)}}),v=(0,Y.useRef)(null),{asked:y}=c,b=y&&t.rows.some(e=>e.lines.some(e=>e.opened&&!e.movesCardsOnly)),x=s!==void 0&&f===void 0,S=u.at(-1);return(0,J.jsxs)(`div`,{ref:v,"data-dragging":_.drag?``:void 0,className:`group/flow relative flex flex-col`,children:[(0,J.jsx)(An,{sentence:c.sentence,reorderHref:c.reorderHref,linked:b,LinkComponent:l}),!d&&(0,J.jsx)(Mn,{flow:v}),(0,J.jsx)(`ol`,{"aria-label":`Phases`,className:`flex flex-col`,children:t.rows.map((t,c)=>{let{phase:h}=t,g=m(c),v=u[c-1],S=u[c+1],C=_.drag?.from===c,ee=_.rowMotion(c),w=x&&c>0&&u.length>2,T=S!==void 0||f===c;return(0,J.jsxs)(`li`,{"data-dragging":C||void 0,style:ee.style,onPointerDown:w?e=>_.onPointerDown(e,c):void 0,onKeyDown:w?e=>_.onKeyDown(e,c):void 0,className:N(`group/row relative flex flex-col`,ee.className),children:[v&&(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`flex items-center justify-end text-caption text-muted-foreground max-sm:order-last max-sm:w-auto`),children:h.kind===`terminal`&&v.kind!==`terminal`&&`Cards are finished here`}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,g&&g.from<c&&Wn)})]}),(0,J.jsxs)(`div`,{className:`group/phase relative flex gap-4 max-sm:flex-col max-sm:gap-2`,children:[(0,J.jsx)(Zn,{row:t,selectedPhase:r,selectedRule:i,rulesEditable:o,asked:y,linkedFrom:Jn(v,b),LinkComponent:l}),(0,J.jsxs)(`div`,{"data-grip":w?``:void 0,className:`flex flex-col items-center max-sm:items-stretch`,children:[(0,J.jsxs)(`div`,{"data-inlet-card":``,className:`relative`,children:[(v||b)&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-top-1.25`,!v&&`sm:hidden`)}),(0,J.jsx)(zn,{boardId:e,phase:h,phases:u,next:t.next,automatic:t.automatic,work:t.work,total:n.get(h.key),href:t.href,emphasis:t.emphasis,problem:a.has(h.key),unreached:t.unreached,start:t.start,movable:w,moves:s&&{required:s.required(h.key),onChange:e=>s.onMoves(h.key,e)},LinkComponent:l}),T&&(0,J.jsx)(B,{className:N(`absolute left-1/2 -translate-x-1/2 max-sm:left-5`,`-bottom-1.25`)})]}),T&&(0,J.jsxs)(`span`,{className:`group/gap relative flex flex-1 justify-center self-stretch`,children:[(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`}),x&&(0,J.jsx)(`span`,{className:`absolute inset-x-0 top-0 -bottom-8 z-10 flex items-center justify-center max-sm:hidden pointer-coarse:hidden`,children:(0,J.jsx)(Xn,{after:h,onClick:()=>p(c),className:`opacity-0 group-hover/gap:opacity-100`})})]})]}),(0,J.jsx)(`div`,{className:N(Kn,`pl-2.5 text-caption text-muted-foreground`,g&&Wn),children:g?.from===c&&g.label}),!d&&(0,J.jsx)(xe,{})]}),s&&f===c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,S&&g&&g.to>c&&Wn)})]}),(0,J.jsxs)(`div`,{className:`flex gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(Ln,{boardId:e,takenKeys:u.map(e=>e.key),linked:S!==void 0,keyFromName:s.keyFromName,keyProblem:s.keyProblem,onAdd:(e,t)=>{p(void 0),s.onAdd(e,c+1,t)},onCancel:()=>p(void 0)}),(0,J.jsx)(`span`,{className:N(`w-30 shrink-0 max-sm:hidden`,S&&g&&g.to>c&&Wn)})]})]})]},h.key)})}),x&&S&&(0,J.jsxs)(`div`,{className:`flex gap-4 pt-3`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:hidden`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-auto max-sm:justify-start`,children:(0,J.jsx)(Xn,{after:S,onClick:()=>p(u.length-1),className:`opacity-0 group-hover/flow:opacity-100 pointer-coarse:opacity-100`})})]}),(0,J.jsx)(`span`,{role:`status`,className:`sr-only`,children:h})]})}function Xn({after:e,onClick:t,className:n}){return(0,J.jsxs)(`button`,{type:`button`,"aria-label":`Add a phase after ${e.name}`,onClick:t,className:N(qn,`z-10 h-5 bg-card px-2 transition-opacity group-data-dragging/flow:invisible`,M,n),children:[(0,J.jsx)(K,{className:`size-icon-xs`,"aria-hidden":!0}),`Phase`]})}function Zn({row:e,selectedPhase:t,selectedRule:n,rulesEditable:r,asked:i,linkedFrom:a,LinkComponent:o}){let[s,c]=(0,Y.useState)(!1),l=e.lines.slice(Un),u=s||l.some(e=>e.ruleId===n),d=u?e.lines:e.lines.slice(0,Un),f=t===e.phase.key,p=t=>e.lines.some(e=>e.event===t&&!e.movesCardsOnly);return(0,J.jsxs)(`div`,{"data-rules-in":``,className:N(Gn,`relative flex flex-col items-end gap-1.5 pt-2 pl-7 max-sm:items-start max-sm:pt-0 max-sm:pl-10`),children:[a&&(0,J.jsx)(`span`,{"aria-hidden":!0,className:N(`bg-canvas-link w-px`,`absolute -bottom-2 left-5 -translate-x-1/2 sm:hidden`,a===`entry`?`-top-8`:`top-0`)}),d.map((e,t)=>{let n=e.emphasis,r=d[t-1]?.event!==e.event,a=r&&e.opened;return(0,J.jsxs)(`div`,{className:N(`flex max-w-full min-w-0 flex-wrap items-center justify-end gap-x-2.5 gap-y-1 max-sm:justify-start`,a&&`w-full`),children:[a&&(0,J.jsx)(jn,{linked:i&&p(e.event)}),r&&(0,J.jsx)(I,{trigger:e.trigger,dimmed:n===`dimmed`}),(0,J.jsx)(de,{line:e,LinkComponent:o})]},`${e.event}:${e.ruleId}`)}),l.length>0&&!u&&(0,J.jsxs)(`button`,{type:`button`,"data-join":``,onClick:()=>c(!0),className:N(`h-6.5 rounded-full border border-border px-2.5 text-caption text-muted-foreground hover:text-foreground`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[`+`,l.length,` more`]}),e.incoming.map(e=>(0,J.jsx)(Fn,{rule:e,LinkComponent:o},e.ruleId)),r&&(0,J.jsxs)(o,{href:e.newRuleHref,"aria-label":`Add a rule into ${e.phase.name}`,className:N(qn,`h-6.5 px-2.5`,f?`opacity-100`:`opacity-0 group-has-[[data-rules-in]:hover,[data-inlet-card]:hover]/phase:opacity-100 pointer-coarse:opacity-100`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[(0,J.jsx)(K,{className:`size-icon-xs`,"aria-hidden":!0}),`Rule`]})]})}var Z=`motion-reduce:before:animate-none`,Qn=3;function $n(){return(0,J.jsxs)(`div`,{"aria-hidden":!0,className:En,children:[(0,J.jsx)(q,{line:`text-display`,className:N(`h-5 w-40`,Z)}),(0,J.jsx)(q,{line:`text-body`,className:N(`w-72 max-w-full`,Z)})]})}function er(){return(0,J.jsxs)(`div`,{role:`status`,"aria-label":`Loading board`,className:`flex flex-col`,children:[(0,J.jsxs)(`div`,{"aria-hidden":!0,className:N(_,kn),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(Fe,{className:`size-icon-sm shrink-0 text-muted-foreground`}),(0,J.jsx)(q,{line:`text-card-title-strong`,className:N(`w-44`,Z)})]}),(0,J.jsx)(`span`,{className:`pl-6`,children:(0,J.jsx)(q,{line:`text-caption`,className:N(`w-56 max-w-full`,Z)})})]}),(0,J.jsx)(`ol`,{"aria-hidden":!0,className:`flex flex-col`,children:Array.from({length:Qn},(e,t)=>(0,J.jsxs)(`li`,{className:`flex flex-col`,children:[t>0&&(0,J.jsxs)(`div`,{className:`flex h-8 gap-4`,children:[(0,J.jsx)(`span`,{className:N(`mr-4 w-89.5 shrink-0 max-sm:mr-0 max-sm:w-full`,`max-sm:order-last max-sm:w-auto`)}),(0,J.jsx)(`span`,{className:`flex w-75 shrink-0 justify-center max-sm:w-10`,children:(0,J.jsx)(`span`,{className:`bg-canvas-link w-px`})}),(0,J.jsx)(`span`,{className:`w-30 shrink-0 max-sm:hidden`})]}),(0,J.jsxs)(`div`,{className:`flex gap-4 max-sm:flex-col`,children:[(0,J.jsx)(`span`,{className:N(Gn,`max-sm:hidden`)}),(0,J.jsxs)(`div`,{className:N(_,Rn),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(o,{className:N(`size-4 shrink-0 rounded-full`,Z)}),(0,J.jsx)(q,{line:`text-card-title-strong`,className:N(`w-24`,Z)})]}),(0,J.jsx)(q,{line:`text-body-sm`,className:N(`w-40`,Z)})]}),(0,J.jsx)(`span`,{className:Kn})]})]},t))})]})}function tr({leaving:e,stray:t,strayIncoming:n,LinkComponent:r}){return(0,J.jsxs)(J.Fragment,{children:[e.length>0&&(0,J.jsxs)(`section`,{"aria-labelledby":`canvas-leaving`,className:`flex flex-col gap-4`,children:[(0,J.jsx)(j,{as:`h2`,id:`canvas-leaving`,variant:`body-sm`,tone:`muted`,children:`To other boards`}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map(e=>{let{line:t,stage:n}=e,i=t.emphasis===`dimmed`;return(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,J.jsx)(I,{trigger:t.trigger,dimmed:i}),(0,J.jsx)(de,{line:t,LinkComponent:r}),(0,J.jsxs)(r,{href:e.href,className:N(`bg-card hover:bg-card active:bg-card shadow-raised [--field:var(--field-on-surface)] [--field-disabled:var(--field-on-surface)] [--field-hover:var(--field-hover-on-surface)] [--field-open:var(--field-open-on-surface)]`,`state-layer`,`flex min-w-36 flex-col gap-0.5 rounded-2xl px-3.25 py-2.5 transition-opacity`,i&&`opacity-35`,`focus-visible:outline-1 focus-visible:outline-solid focus-visible:outline-border-focus focus-visible:outline-offset-0`),children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2 text-card-title-strong text-foreground`,children:[n&&(0,J.jsx)(U,{stage:n.key,kind:W(n.boardId,n.kind),decorative:!0}),e.phaseName??`A removed phase`]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-caption text-muted-foreground`,children:[(0,J.jsx)(Re,{className:`size-icon-xs`,"aria-hidden":!0}),e.boardName]})]})]},`${t.event}:${t.ruleId}`)})})]}),t.length+n.length>0&&(0,J.jsxs)(`section`,{"aria-labelledby":`canvas-stray`,className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(j,{as:`h2`,id:`canvas-stray`,variant:`body-sm`,tone:`muted`,children:`Into a removed phase`}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`These rules name a phase this board doesn’t have, so they can’t move cards. Open one to pick another phase.`})]}),(0,J.jsxs)(`ul`,{className:`flex flex-col items-start gap-1.5`,children:[t.map(e=>(0,J.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,J.jsx)(I,{trigger:e.trigger,dimmed:e.emphasis===`dimmed`}),(0,J.jsx)(de,{line:e,LinkComponent:r})]},`${e.event}:${e.ruleId}`)),n.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(Fn,{rule:e,stray:!0,LinkComponent:r})},e.ruleId))]})]})]})}function Q({icon:e,title:t,children:n}){return(0,J.jsxs)(`section`,{"aria-label":t,className:`group/step grid grid-cols-[var(--spacing-icon-md)_minmax(0,1fr)] gap-x-2 gap-y-2.5 px-1`,children:[(0,J.jsx)(`span`,{"aria-hidden":!0,className:`grid h-4 place-items-center text-foreground [&_svg]:size-3.25`,children:e}),(0,J.jsx)(j,{as:`h3`,variant:`column`,tone:`ink`,className:`font-semibold`,children:t}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`-mt-1.5 -mb-3 w-px justify-self-center bg-border-strong group-last-of-type/step:hidden`}),(0,J.jsx)(`div`,{className:`col-start-2 flex min-w-0 flex-col gap-2.5`,children:n})]})}function $({label:e,children:t,className:n}){return(0,J.jsxs)(`div`,{className:N(`flex min-h-5 min-w-0 items-center justify-between gap-1.5`,n),children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`min-w-0 truncate`,children:e}),t]})}function nr({length:e,max:t}){return(0,J.jsxs)(j,{as:`span`,variant:`caption`,tone:e>t?void 0:`muted`,className:N(`tabular-nums`,e>t&&`text-warning-foreground`),children:[e.toLocaleString(`en-US`),` / `,t]})}function rr({boardTitle:e,boardHref:t,LinkComponent:n}){return(0,J.jsxs)(se,{label:`Phase not found`,children:[(0,J.jsxs)(j,{variant:`body-sm`,tone:`ink`,role:`alert`,children:[e,` has no such phase.`]}),(0,J.jsx)(n,{href:t,className:`text-body-sm text-muted-foreground hover:text-foreground`,children:`Back to the board`})]})}var ir={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},ar=[`resting`,`working`,`terminal`];function or({phase:e,boardId:n,total:r,readOnly:a,kindLocked:o,onName:c,onDescription:l,onKind:u,onClose:d}){let f=ir[e.kind],p=e.description??``;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-2 pl-1`,children:[(0,J.jsx)(`span`,{className:`grid size-icon-md shrink-0 place-items-center`,children:(0,J.jsx)(U,{stage:e.key,kind:W(n,e.kind),decorative:!0})}),(0,J.jsx)(j,{as:`h2`,variant:`card-title-strong`,className:`min-w-0 truncate`,children:(0,J.jsx)(t,{value:e.name,label:`Phase name`,required:!0,readOnly:a,variant:`card-title-strong`,tone:`ink`,onChange:c})}),a||o?(0,J.jsxs)(s,{children:[(0,J.jsx)(y,{render:(0,J.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${f.label}. ${o?`${f.meaning} This phase keeps its kind.`:f.meaning}`,className:N(`inline-flex shrink-0 rounded-sm`,M),children:(0,J.jsx)(i,{size:`sm`,icon:o?(0,J.jsx)(H,{}):void 0,children:f.label})})}),(0,J.jsx)(g,{side:`bottom`,className:`max-w-72`,children:o?`${f.meaning} The first phase and phases Factory's code declares keep their kind.`:f.meaning})]}):(0,J.jsxs)(en,{value:e.kind,onValueChange:t=>{let n=ar.find(e=>e===t);n&&n!==e.kind&&u(n)},children:[(0,J.jsx)(rn,{size:`sm`,variant:`ghost`,"aria-label":`Phase kind`,className:`w-auto shrink-0`,children:f.label}),(0,J.jsx)($t,{children:ar.map(e=>(0,J.jsx)(Qt,{value:e,children:(0,J.jsxs)(`span`,{className:`flex max-w-56 flex-col gap-0.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`label`,children:ir[e].label}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:ir[e].meaning})]})},e))})]}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`ml-auto shrink-0 tabular-nums`,children:r===void 0?null:(0,J.jsxs)(J.Fragment,{children:[r,(0,J.jsxs)(`span`,{className:`sr-only`,children:[` `,r===1?`card`:`cards`]})]})}),(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Close ${e.name}`,onClick:d,children:(0,J.jsx)(b,{})})]}),(p||!a)&&(0,J.jsx)(`div`,{className:`pl-7.5`,children:(0,J.jsx)(t,{value:p,label:`Phase description`,placeholder:`Add a description`,multiline:!0,readOnly:a,variant:`caption`,tone:`muted`,className:`w-full`,onChange:e=>l(e||null)})})]})}var sr=`Factory's code makes this move`;function cr({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let c=t.filter(t=>t.key!==e.key&&n.includes(t.key)),l=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.25`,children:[c.length===0&&(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`Cards stay here; no move is allowed.`}),c.length>0&&(0,J.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`contents`,children:c.map(e=>{let t=r.includes(e.key),n=(0,J.jsxs)(`span`,{tabIndex:t?0:void 0,className:`inline-flex h-6 max-w-full min-w-0 items-center gap-1.25 rounded-xl bg-fill pr-2 pl-1.5 text-foreground`,children:[(0,J.jsx)(lr,{phase:e,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`caption`,className:`truncate`,children:e.name}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(H,{"aria-hidden":!0,className:`size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`(locked)`})]})]});return(0,J.jsx)(`li`,{className:`min-w-0`,children:t?(0,J.jsxs)(s,{children:[(0,J.jsx)(y,{render:n}),(0,J.jsx)(g,{children:sr})]}):n},e.key)})}),!a&&(0,J.jsxs)(At,{children:[(0,J.jsx)(lt,{size:`icon-sm`,variant:`ghost`,tooltip:`Change moves from ${e.name}`,children:(0,J.jsx)(K,{})}),(0,J.jsxs)(Ze,{align:`start`,className:`w-72 p-1.5`,children:[(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`px-2 pt-0.5 pb-1.5`,children:[e.name,` can move cards to`]}),(0,J.jsx)(`ul`,{"aria-label":`Moves from ${e.name}`,className:`flex flex-col gap-0.5`,children:t.map(t=>{if(t.key===e.key)return(0,J.jsxs)(`li`,{className:`flex h-7.5 items-center gap-2 px-2`,children:[(0,J.jsx)(lr,{phase:t,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`body-sm`,tone:`muted`,className:`truncate`,children:t.name}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`ml-auto shrink-0`,children:`this phase`})]},t.key);let a=n.includes(t.key),o=a&&r.includes(t.key);return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,"aria-pressed":a,"aria-label":o?`${t.name} (locked)`:void 0,"aria-disabled":o||void 0,title:o?sr:void 0,onClick:o?void 0:()=>l(t.key),className:N(tn,`w-full`,o&&`cursor-default`),children:[(0,J.jsx)(lr,{phase:t,boardId:i}),(0,J.jsx)(j,{as:`span`,variant:`body-sm`,tone:a?`ink`:`muted`,className:`truncate`,children:t.name}),(0,J.jsx)(`span`,{"aria-hidden":!0,className:`ml-auto grid shrink-0 place-items-center text-muted-foreground`,children:o?(0,J.jsx)(H,{className:`size-icon-sm`}):a?(0,J.jsx)(nn,{className:`size-icon-sm`}):(0,J.jsx)(K,{className:`size-icon-sm`})})]})},t.key)})}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`px-2 pt-1.5`,children:`Waits for the board's Save.`})]})]})]})}function lr({phase:e,boardId:t}){return(0,J.jsx)(U,{stage:e.key,kind:W(t,e.kind),decorative:!0})}function ur({phase:e,phases:t,next:n,info:r,disabled:i,onChange:a}){let o=e.outcomes?.length?e.outcomes:void 0,{defaults:s,problems:c,added:l,exitToolPick:u,max:d}=r,f=e=>t.find(t=>t.key===e)?.name??e;if(n.length===0)return(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`Allow a move first; each outcome goes to one of them.`});let p=e.exitTool?.id;if(!o)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(`ul`,{"aria-label":`${e.name} outcomes`,className:`flex flex-col gap-1`,children:s.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsxs)(j,{as:`span`,variant:`caption`,tone:`muted`,children:[(0,J.jsx)(`code`,{children:e.key}),` moves the card to `,f(e.to)]})},e.key))}),p&&(0,J.jsx)(dr,{exitTool:p,picked:u,phases:t}),(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`The agent may report any allowed move by the key of the phase it goes to. Customize them to describe each one, or to offer fewer moves than people have.`}),!i&&(0,J.jsx)(`div`,{children:(0,J.jsx)(T,{size:`sm`,variant:`ghost`,onClick:()=>a(s.slice(0,d)),children:`Customize outcomes`})})]});let m=(e,t)=>a(o.map((n,r)=>r===e?{...n,...t}:n));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,children:`The agent reports one by its key when its work is done; the description tells it when, and shows in the card's history.`}),(0,J.jsx)(`ul`,{"aria-label":`${e.name} outcomes`,className:`flex flex-col gap-1.5`,children:o.map((t,r)=>{let s=c[r]??{},l=`outcome ${t.key||r+1}`;return(0,J.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-2xl bg-fill-subtle p-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,J.jsxs)(sn,{invalid:!!s.key,disabled:i,className:`min-w-0 flex-1`,children:[(0,J.jsx)(cn,{size:`sm`,"aria-label":`${e.name} outcome ${r+1} key`,value:t.key,placeholder:`Key, e.g. review`,disabled:i,onChange:e=>m(r,{key:e.target.value.trim()})}),s.key&&(0,J.jsx)(on,{children:s.key})]}),(0,J.jsx)(ut,{"aria-hidden":!0,className:`mt-2 size-icon-xs shrink-0 text-muted-foreground`}),(0,J.jsxs)(en,{value:t.to,disabled:i,onValueChange:e=>m(r,{to:String(e)}),children:[(0,J.jsx)(rn,{size:`sm`,"aria-label":`${e.name} ${l} goes to`,className:`w-24 shrink-0`,children:(0,J.jsx)(`span`,{className:`truncate`,children:f(t.to)})}),(0,J.jsx)($t,{children:n.map(e=>(0,J.jsx)(Qt,{value:e,children:f(e)},e))})]}),!i&&(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Remove ${l}`,onClick:()=>{let e=o.filter((e,t)=>t!==r);a(e.length>0?e:null)},children:(0,J.jsx)(te,{})})]}),(0,J.jsxs)(sn,{invalid:!!s.label,disabled:i,children:[(0,J.jsx)(cn,{size:`sm`,"aria-label":`${e.name} outcome ${r+1} label`,value:t.label,placeholder:`Description, e.g. Change request opened`,disabled:i,onChange:e=>m(r,{label:e.target.value})}),s.label&&(0,J.jsx)(on,{children:s.label})]})]},r)})}),p&&(0,J.jsx)(dr,{exitTool:p,picked:u,phases:t}),!i&&(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[l&&o.length<d&&(0,J.jsx)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(K,{}),onClick:()=>a([...o,l]),children:`Add outcome`}),(0,J.jsx)(T,{size:`sm`,variant:`ghost`,onClick:()=>a(null),children:`Use one per move`})]})]})}function dr({exitTool:e,picked:t,phases:n}){if(!t)return(0,J.jsx)(w,{variant:`warning`,children:(0,J.jsxs)(w.Message,{children:[`When `,(0,J.jsx)(`code`,{children:e}),` succeeds, no outcome is picked, so the card waits for the agent to report one. Key an outcome `,(0,J.jsx)(`code`,{children:`advance`}),` to choose where its success moves the card.`]})});let r=n.find(e=>e.key===t.to)?.name??t.to;return(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,children:[`When `,(0,J.jsx)(`code`,{children:e}),` succeeds, it reports `,(0,J.jsx)(`code`,{children:t.key}),`, moving the card to `,r,`.`]})}var fr=(e,t)=>e.runner?.context||t;function pr({phase:e,phases:t,boardId:n,defaultSession:r,phaseTools:i,disabled:a,onRunner:o,onTools:s,onBack:c}){let l=e.runner?.instructions??``,u=e.runner?.goal,d=u?.objective??``,f=e.tools??[],p=fr(e,r),h=t.filter(t=>t.key!==e.key&&t.kind===`working`&&fr(t,r)===p).map(e=>e.name);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex min-h-7 min-w-0 items-center gap-2`,children:[(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`Back to ${e.name}`,onClick:c,children:(0,J.jsx)(m,{})}),(0,J.jsx)(U,{stage:e.key,kind:W(n,e.kind),decorative:!0}),(0,J.jsx)(j,{as:`h2`,variant:`card-title-strong`,className:`min-w-0 truncate`,children:e.name}),(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,className:`shrink-0`,children:`Agent runs`})]}),(0,J.jsx)(mr,{title:`Instructions`,label:`${e.name} instructions`,value:l,max:Pt,placeholder:`Added to the agent's prompt when the phase starts.`,disabled:a,onChange:e=>o({instructions:e})}),(0,J.jsx)(mr,{title:`Goal`,label:`${e.name} goal`,value:d,max:Dt,placeholder:`The agent keeps working until a judge finds this met. Leave empty for a single run.`,disabled:a,onChange:e=>o({goal:e.trim()?{...u,objective:e}:void 0}),children:u&&(0,J.jsxs)(sn,{invalid:!Mt(u.maxRuns),disabled:a,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(an,{size:`smaller`,info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,J.jsx)(gn,{className:`w-32`,min:1,max:50,allowOutOfRange:!0,value:u.maxRuns??null,disabled:a,onValueChange:e=>{let{maxRuns:t,...n}=u;o({goal:e===null?n:{...n,maxRuns:e}})},children:(0,J.jsxs)(hn,{size:`sm`,children:[(0,J.jsx)(fn,{placeholder:`Default`}),(0,J.jsxs)(dn,{align:`inline-end`,variant:`flush`,children:[(0,J.jsx)(un,{className:`mr-1`,children:`runs`}),(0,J.jsx)(mn,{}),(0,J.jsx)(pn,{})]})]})})]}),!Mt(u.maxRuns)&&(0,J.jsxs)(on,{children:[`Use a whole number from 1 to `,50,`.`]})]})}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,J.jsx)($,{label:`Session`,children:(0,J.jsx)(cn,{size:`sm`,className:`w-28`,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:r,disabled:a,onChange:e=>o({context:e.target.value})})}),(0,J.jsxs)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,J.jsx)($e,{"aria-hidden":!0,className:`size-icon-xs shrink-0`}),h.length>0?`Shared with ${h.join(`, `)}, one per card`:`One per card`]})]}),(0,J.jsxs)(`div`,{role:`group`,"aria-label":`Factory tools`,className:`flex flex-col gap-2.5 px-1`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:`Factory tools`}),i.map(t=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,children:t.label}),(0,J.jsx)(_n,{"aria-label":`${e.name}: ${t.label}`,checked:f.includes(t.id),disabled:a,onCheckedChange:e=>{let n=i.map(({id:e})=>e).filter(n=>n===t.id?e:f.includes(n));s(n.length>0?n:null)}})]},t.id))]})]})}function mr({title:e,label:t,value:n,max:r,placeholder:i,disabled:a,onChange:o,children:s}){let l=n.length>r;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-1`,children:[(0,J.jsxs)(sn,{invalid:l,disabled:a,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-1.5`,children:[(0,J.jsx)(an,{size:`smaller`,children:e}),(0,J.jsx)(nr,{length:n.length,max:r})]}),(0,J.jsx)(ln,{"aria-label":t,value:n,placeholder:i,editable:!a,onChange:o,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1,className:N(c,u,`rounded-xl px-2 py-1.5`,a&&`bg-field-disabled`),"data-base-ui-swipe-ignore":``}),l&&(0,J.jsx)(on,{children:`Too long to save.`})]}),s]})}var hr=`__none__`;function gr({phaseName:e,skillName:t,skills:n,skillsEditable:r,skillHref:a,skillsHref:o,newSkillHref:s,badges:c,disabled:l,LinkComponent:u,onChange:d}){let p=t?n?.find(e=>e.name===t):void 0,m=t!==void 0&&n!==void 0&&p===void 0,h=(n??[]).map(e=>e.name);t&&!h.includes(t)&&h.push(t);let g=[{value:hr,label:`No skill`},...h.map(e=>({value:e,label:e}))],_=p!==void 0&&c.length>0;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)($,{label:`Skill`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,J.jsx)(Be,{options:g,value:t??hr,variant:`ghost`,size:`sm`,align:`end`,searchPlaceholder:`Search skills`,emptyText:`No skill matches`,"aria-label":`${e} skill`,disabled:l,className:`min-w-0`,onValueChange:e=>d(e===hr||e===``?void 0:e)}),p&&(0,J.jsx)(T,{size:`icon-sm`,variant:`ghost`,tooltip:`${r?`Edit`:`View`} ${p.name}`,render:(0,J.jsx)(u,{href:a}),children:r?(0,J.jsx)(vn,{}):(0,J.jsx)(f,{})})]})}),(m||p?.error||_)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[m&&(0,J.jsx)(i,{variant:`destructive`,size:`sm`,children:`Not found`}),p?.error&&(0,J.jsx)(i,{variant:`destructive`,size:`sm`,children:`Failed to load`}),p&&c.map(e=>(0,J.jsx)(i,{children:e},e))]}),(0,J.jsx)(_r,{skill:p,missing:m,skillName:t,phaseName:e}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,J.jsx)(T,{size:`sm`,variant:`ghost`,render:(0,J.jsx)(u,{href:o}),children:`All skills`}),r&&(0,J.jsx)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(K,{}),render:(0,J.jsx)(u,{href:s}),children:`New skill`})]})]})}function _r({skill:e,missing:t,skillName:n,phaseName:r}){return e?.error?(0,J.jsxs)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,e.error]}):t?(0,J.jsxs)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,n,` skill, so cards entering `,r,` fail to start.`]}):e?.description?(0,J.jsx)(j,{as:`p`,variant:`caption`,tone:`muted`,className:`line-clamp-2`,children:e.description}):null}function vr({phase:e,phases:t,nextPhases:n,requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,skillHref:s,skillsHref:c,newSkillHref:l,skillBadges:u,outcomes:d,defaultSession:f,phaseTools:p,boardId:m,disabled:h,total:g,autoStartConditions:_,autoStartProblem:v,autoApproveConditions:y,autoApproveProblem:b,LinkComponent:x,onName:S,onDescription:C,onKind:ee,onAutoStart:w,onRunner:E,onTools:ne,onExitTool:D,onAutoApprove:O,onNextPhases:k,onOutcomes:A,onUnfinished:M,onRemove:N,onClose:ae}){let[P,F]=(0,Y.useState)(!1),I=e.kind===`working`,L=e.exitTool?.id??``,oe=e.runner?.instructions??``,R=e.runner?.goal;if(I&&P)return(0,J.jsx)(se,{label:`${e.name} agent runs`,children:(0,J.jsx)(pr,{phase:e,phases:t,boardId:m,defaultSession:f,phaseTools:p,disabled:h,onRunner:E,onTools:ne,onBack:()=>F(!1)})});let z=[oe.length>1e3&&(0,J.jsx)($,{label:`Instructions`,children:(0,J.jsx)(nr,{length:oe.length,max:1e3})},`instructions`),(R?.objective.length??0)>2e3&&(0,J.jsx)($,{label:`Goal`,children:(0,J.jsx)(nr,{length:R?.objective.length??0,max:2e3})},`goal`),!Mt(R?.maxRuns)&&(0,J.jsx)($,{label:`Pause goal after`,children:(0,J.jsxs)(j,{as:`span`,variant:`caption`,className:`text-warning-foreground`,children:[R?.maxRuns,` runs`]})},`runs`)].filter(Boolean);return(0,J.jsxs)(se,{label:e.name,children:[(0,J.jsx)(or,{phase:e,boardId:m,total:g,readOnly:h,kindLocked:i,onName:S,onDescription:C,onKind:e=>{M(`autoStartWhen`,!1),M(`autoApproveWhen`,!1),ee(e)},onClose:ae}),I&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Q,{icon:(0,J.jsx)(Le,{}),title:`Starts`,children:[(0,J.jsx)($,{label:`Start on its own`,children:(0,J.jsx)(_n,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:h,onCheckedChange:e=>{w(e),e||M(`autoStartWhen`,!1)}})}),e.autoStart&&(0,J.jsx)(yr,{rule:e.autoStartWhen,problem:v,disabled:h,children:_},`${e.key}.autoStartWhen`)]}),(0,J.jsxs)(Q,{icon:(0,J.jsx)(Bt,{}),title:`Agent runs`,children:[(0,J.jsx)(gr,{phaseName:e.name,skillName:e.runner?.skill,skills:a,skillsEditable:o,skillHref:s,skillsHref:c,newSkillHref:l,badges:u,disabled:h,LinkComponent:x,onChange:e=>E({skill:e})}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>F(!0),className:`flex min-h-6 items-center justify-between gap-1.5 text-left text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,children:`Instructions, goal, session, tools`}),z.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(re,{"aria-hidden":!0,className:`ml-auto size-icon-xs text-warning-foreground`}),(0,J.jsx)(`span`,{className:`sr-only`,children:`(can't save)`})]}),(0,J.jsx)(ie,{"aria-hidden":!0,className:`size-icon-xs shrink-0`})]}),z]}),(0,J.jsxs)(Q,{icon:(0,J.jsx)(yt,{}),title:`Ends`,children:[(0,J.jsx)($,{label:`Exit tool`,children:(0,J.jsx)(cn,{size:`sm`,className:`w-32`,"aria-label":`${e.name} exit tool`,value:L,placeholder:`None`,disabled:h,onChange:e=>{let t=e.target.value.trim();D(t),t||M(`autoApproveWhen`,!1)}})}),L!==``&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($,{label:`Approve on its own`,children:(0,J.jsx)(_n,{"aria-label":`${e.name}: approve ${L} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:h,onCheckedChange:e=>{O(e),e||M(`autoApproveWhen`,!1)}})}),e.exitTool?.autoApprove&&(0,J.jsx)(yr,{rule:e.exitTool.autoApproveWhen,problem:b,disabled:h,children:y},`${e.key}.autoApproveWhen`)]})]})]}),(0,J.jsx)(Q,{icon:(0,J.jsx)(Ye,{}),title:`Allowed moves`,children:(0,J.jsx)(cr,{phase:e,phases:t,next:n,required:r,boardId:m,disabled:h,onChange:k})}),I&&(0,J.jsx)(Q,{icon:(0,J.jsx)(Wt,{}),title:`Outcomes`,children:(0,J.jsx)(ur,{phase:e,phases:t,next:n,info:d,disabled:h,onChange:A})}),N&&(0,J.jsx)(`div`,{children:(0,J.jsxs)(T,{size:`sm`,variant:`ghost`,icon:(0,J.jsx)(te,{}),onClick:N,children:[`Remove `,e.name]})})]})}function yr({rule:e,problem:t,disabled:n,children:r}){return n&&!e?.conditions.length?null:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,J.jsx)(j,{as:`span`,variant:`caption`,tone:`muted`,children:`Only when`}),r,t&&(0,J.jsx)(j,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:t})]})}var br=(0,Y.createContext)(void 0);function xr(e,t,n){return`${e}:${t}:${n.revision??`code`}`}function Sr({children:e}){let t=(0,Y.useState)(void 0);return(0,J.jsx)(br.Provider,{value:t,children:e})}function Cr(e,t,n){let r=(0,Y.useContext)(br);if(!r)throw Error(`useBoardDraft must be used inside BoardDraftProvider`);let[i,a]=r,o=st(e,t),s=xr(e,t,n),c=i?.key===s?i:{key:s,draft:dt(n)},l=e=>a(t=>e(t?.key===s?t:{key:s,draft:dt(n)}));return{draft:c.draft,locked:o,setDraft:e=>l(t=>({...t,draft:e(t.draft)})),discard:()=>a(void 0)}}var wr=D(new URLSearchParams,!0);function Tr(e,t){let n=Yt(e),r=Ht(e),i=Oe(e),a=_e(e),o=je(e),s=x(e,Ge({board:t,sort:ne,search:``,filters:wr,windows:{},item:void 0})),c=new Map((o.data?.boards??[]).flatMap(e=>e.rules.map(e=>[e.routeId,e.filed]))),l=new Map((a.data?.skipped??[]).map(e=>[e.routeId,e])),u=new Map((s.data?.phases??[]).map(e=>[e.phase,e.total]));return{boards:n.data??[],installed:n.data?.find(e=>e.id===t),rules:r.data?.intakeRoutes,rulesFailed:r.isError,rulesEditable:r.data?.canEdit??!1,order:i.data,filed:c,skips:l,totals:u}}function Er(e){let[t,n]=(0,Y.useState)({page:e,fields:[]});return t.page!==e&&n({page:e,fields:[]}),{fields:t.page===e?t.fields:[],mark:(t,r)=>n(n=>{let i=(n.page===e?n.fields:[]).filter(e=>e!==t);return{page:e,fields:r?[...i,t]:i}})}}function Dr({factoryId:e,boardId:t,boards:n,onDeleted:r}){let i=l();return{reset:jt(e,t),remove:et(e,t,()=>{r();let a=Zt(n).find(e=>e.id!==t);i(a?Jt(e,a.id):`/factories/${e}`,{replace:!0})})}}function Or({board:e,draft:t,readOnly:n,manageable:r,locked:i,writes:a,rulesFailed:o,onChange:s}){let{reset:c,remove:l}=a;return(0,J.jsx)(Dn,{name:t.name,description:t.description,readOnly:n,manageable:r,editable:e.editable,problems:e.problems,rulesFailed:o,actions:{boardName:e.name,resettable:e.source!==`stored`,deletable:e.source!==`builtin`,busy:c.isPending||l.isPending,disabled:i,onReset:()=>c.mutate(e.revision??0),onDelete:()=>l.mutate(e.revision??0)},errors:{resetError:c.error?.reasons,deleteError:l.error?.reasons},onChange:s})}function kr({phase:e,phases:t,requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,factoryId:s,boardId:c,disabled:l,total:u,unfinished:d,onChange:f,onUnfinished:p,onRemove:m,onClose:h}){let g=he(s),_=e.exitTool?.id??``,v=e.runner?.skill,y=v?a?.find(e=>e.name===v):void 0,b=e.outcomes?.length?e.outcomes:void 0,x=vt(e,t),S=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));f({...e,runner:Object.keys(r).length>0?r:null})},C={"source.repository":g};return(0,J.jsx)(vr,{phase:e,phases:t,nextPhases:Rt(e,t),requiredNextPhases:r,kindLocked:i,skills:a,skillsEditable:o,skillHref:v?xn(s,v):void 0,skillsHref:bn(s,`skills`),newSkillHref:yn(s),skillBadges:y?qt(y):[],outcomes:{defaults:x,problems:b?it(b):[],added:b?We(e,t,b):void 0,exitToolPick:Lt(b??x,t),max:20},defaultSession:pt,phaseTools:gt,boardId:c,disabled:l,total:u,autoStartConditions:(0,J.jsx)(be,{label:`Only when`,rule:e.autoStartWhen,facts:Je,options:C,disabled:l,emptyHint:`Leave empty to start every card on its own.`,onChange:(t,n)=>{p(`autoStartWhen`,n),n||f({...e,autoStartWhen:t})}}),autoStartProblem:d.includes(`autoStartWhen`)?void 0:Et(e.autoStartWhen),autoApproveConditions:(0,J.jsx)(be,{label:`Only when`,rule:e.exitTool?.autoApproveWhen,facts:Je,options:C,disabled:l,emptyHint:`Leave empty to approve for every card.`,onChange:(t,n)=>{p(`autoApproveWhen`,n),n||f({...e,exitTool:{...e.exitTool,id:_,autoApprove:!0,autoApproveWhen:t??void 0}})}}),autoApproveProblem:d.includes(`autoApproveWhen`)?void 0:Et(e.exitTool?.autoApproveWhen),LinkComponent:n,onName:t=>f({...e,name:t}),onDescription:t=>f({...e,description:t}),onKind:n=>f(Ue(e,n,t)),onAutoStart:t=>f(wt(e,t)),onRunner:S,onTools:t=>f({...e,tools:t}),onExitTool:t=>f({...e,exitTool:t?{...e.exitTool,id:t}:null}),onAutoApprove:t=>f({...e,exitTool:{...e.exitTool,id:_,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),onNextPhases:t=>f(Ct(e,t)),onOutcomes:t=>f({...e,outcomes:t}),onUnfinished:p,onRemove:m,onClose:h})}function Ar({factoryId:e,boardId:t,focus:n,phase:r,phasePage:i,phases:a,boardTitle:o,codeBehaviour:s,skills:c,disabled:l,totals:u,onFocus:d,onClose:f,onChange:p,unfinished:m,onUnfinished:h,onRemove:g}){if(n&&`rule`in n)return(0,J.jsx)(De,{factoryId:e,boardId:t,focus:{rule:n.rule},backTo:n.test,onFocus:d,onClose:f},n.rule);if(n&&`newRule`in n){let{on:r,into:i,board:a}=n.newRule;return(0,J.jsx)(De,{factoryId:e,boardId:t,focus:n,onFocus:d,onClose:f},`new:${r??``}:${i??``}:${a??``}`)}if(n){let{test:r}=n;return(0,J.jsx)(we,{factoryId:e,boardId:t,subject:r,onEditRule:e=>d({rule:e,test:r}),onClose:f})}if(r){let n=!l&&kt(a,r.key,s);return(0,J.jsx)(kr,{phase:r,phases:a,requiredNextPhases:s?.[r.key]?.requiredNextPhases??[],kindLocked:zt(a,r.key,s),skills:c?.skills,skillsEditable:c?.canEdit??!1,factoryId:e,boardId:t,disabled:l,total:u.get(r.key),unfinished:m,onChange:p,onUnfinished:h,onRemove:n?()=>g(r.key):void 0,onClose:f},i)}return(0,J.jsx)(rr,{boardTitle:o,boardHref:G(e,t),LinkComponent:Xt})}function jr(e,t,n){let r=Ut(e,n);return r?r.parts.map((e,t)=>t===0?e:`${r.join} ${e.charAt(0).toLowerCase()}${e.slice(1)}`):[t]}function Mr(e,t,n,r,i){return{ruleId:e.rule.id,name:e.rule.name,enabled:e.rule.enabled,event:e.event,trigger:xt(e.event),opened:Ot(e.event),rank:e.rank,of:e.of,label:e.label,conditions:jr(e.rule.when,ht(e.event),nt(i)),filed:e.filed,skipsOutsiders:e.skipsOutsiders,movesCardsOnly:e.movesCardsOnly,notes:Me(e),place:r.note(e),href:t,emphasis:n,onPeek:t=>r.onPeek(t?e.event:void 0)}}function Nr(e,t,n,r){let i=t.find(t=>t.id===e.target.boardKey);return{ruleId:e.id,name:e.name,enabled:e.enabled,conditions:jr(e.when,`Every card`,nt(i)),boardName:i?St(i):e.target.boardKey,href:n,emphasis:r}}function Pr({factoryId:e,boardId:t,boards:n,leaving:r,stray:i,strayIncoming:a,emphasis:o,outside:s,lanes:c}){let l=n.find(e=>e.id===t),u=n=>Mr(n,G(e,t,void 0,{rule:n.rule.id}),o(n),c,l),d=r.map(t=>{let r=t.rule.target.moveToBoardKey??t.rule.target.boardKey,i=n.find(e=>e.id===r),a=t.rule.target.phaseKey??i?.initialPhase,o=i?.phases.find(e=>e.id===a);return{line:u(t),href:G(e,r,a??void 0),stage:a&&i?{key:a,boardId:r,kind:o?.kind??`resting`}:void 0,phaseName:tt(i,t.rule.target.phaseKey),boardName:i?St(i):r}});return(0,J.jsx)(tr,{leaving:d,stray:i.map(u),strayIncoming:a.map(t=>Nr(t,n,G(e,t.target.boardKey,void 0,{rule:t.id}),s(t.id))),LinkComponent:Xt})}function Fr(e,t){if(!e||t===void 0)return;let n=t.find(t=>t.name===e);return n?n.error===void 0?void 0:`Skill failed to load`:`Skill not found`}function Ir({factoryId:e,boardId:t,model:n,boards:r,totals:i,emphasis:a,lanes:o,selectedPhase:s,selectedRule:c,problems:l,rulesEditable:u,edit:d,order:f,skills:p}){let m=n.rows.map(e=>e.phase),h=r.find(e=>e.id===t),g={rows:n.rows.map(n=>{let{phase:i}=n;return{phase:i,lines:n.lines.map(n=>Mr(n,G(e,t,void 0,{rule:n.rule.id}),a.line(n,i.key),o,h)),incoming:n.incoming.map(t=>Nr(t,r,G(e,t.target.boardKey,void 0,{rule:t.id}),a.outside(t.id))),unreached:n.unreached,start:n.start,emphasis:a.node(i.key),next:Rt(i,m).filter(e=>e!==i.key),automatic:ve(i,m),work:i.kind===`working`?{skill:i.runner?.skill,skillProblem:Fr(i.runner?.skill,p),autoStart:!!i.autoStart,exit:i.exitTool?{id:i.exitTool.id,approval:Tt(i.exitTool)}:void 0,goal:i.runner?.goal,tools:(i.tools??[]).map(It).join(`, `)}:void 0,href:G(e,t,i.key),newRuleHref:G(e,t,void 0,{newRule:{into:i.key}})}}),sessions:ge(m)};return(0,J.jsx)(Yn,{boardId:t,model:g,totals:i,selectedPhase:s,selectedRule:c,problems:l,rulesEditable:u,edit:d&&{...d,keyFromName:Vt,keyProblem:ft},intake:{sentence:f&&ye(f.boards,f.evaluator,t),reorderHref:He(e,t,{anchor:ct}),asked:f!==void 0&&(f.evaluator===`route-list`||f.boards.some(e=>e.boardKey===t))},LinkComponent:Xt})}function Lr(e,t){if(e.name.trim()===``)return`Name the board to save.`;if(t.length!==0)return`Fix ${t.map(e=>e.name||e.key).join(`, `)} to save.`}function Rr({factoryId:e,boardId:t,phaseKey:n,response:r,onReload:i}){let{board:a,canEdit:o=!1}=r,{draft:s,locked:c,setDraft:u,discard:f}=Cr(e,t,a),m=Tr(e,t),g=Kt(e),[_]=d(),y=Ft(_),b=l(),x=h(),S=Qe(e,t),C=Dr({factoryId:e,boardId:t,boards:m.boards,onDeleted:f}),w=fe(),[T,E]=(0,Y.useState)(0),[te,ne]=(0,Y.useState)(),D=!o||!a.editable,O=D||c,k=n?s.phases.find(e=>e.key===n):void 0,re=s.name||a.name,A=(n,r)=>void b(G(e,t,n,r)),j=k&&`${k.key}:${a.revision??`code`}:${T}:${w?`phone`:`wide`}`,M=Er(j),ie=!D&&(_t(s,a)||M.fields.length>0),N=s.phases.filter(e=>qe(e)||e===k&&M.fields.length>0),ae=Lr(s,N),F=S.error?.code===`revision_mismatch`,I=v(({nextLocation:n})=>{let r=x.getQueryData(p.boardCatalog(e))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=mt(n.pathname);return i?.factoryId!==e||i.boardId!==t||i.intake===!0});ee(e=>{ie&&e.preventDefault()});let L=()=>{f(),E(e=>e+1)},se=e=>u(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)})),R=Ee({boardKey:t,phases:s.phases,rules:m.rules,flow:m.installed?.flow,filed:m.filed,skips:m.skips}),z=y&&`rule`in y?y.rule:void 0,B=y?void 0:k?.key,V=y&&`test`in y?y.test:void 0,ce=ue(e,z?void 0:V),le=Ce(R,s.phases,{phase:B,rule:z,test:ce.data&&{boardKey:t,result:ce.data},lane:te}),de=e=>{let n=e.rule.target.moveToBoardKey;if(n&&n!==t){let e=m.boards.find(e=>e.id===n);return e?St(e):n}let r=e.rule.target.phaseKey??s.phases[0]?.key;return s.phases.find(e=>e.key===r)?.name??`a removed phase`},he={note:e=>me(e,R.lines,de),onPeek:ne};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P,{label:`${re} settings`,tabs:(0,J.jsx)(Te,{factoryId:e,boardId:t,active:`settings`}),header:(0,J.jsx)(Or,{board:a,draft:s,readOnly:O,manageable:!D,locked:c,writes:C,rulesFailed:m.rulesFailed,onChange:e=>u(t=>({...t,...e}))}),panel:y||n?{content:(0,J.jsx)(Ar,{factoryId:e,boardId:t,focus:y,phase:k,phasePage:j,phases:s.phases,boardTitle:re,codeBehaviour:a.codeBehaviour,skills:g.data,disabled:O,totals:m.totals,onFocus:e=>A(void 0,e),onClose:()=>A(),onChange:se,unfinished:M.fields,onUnfinished:M.mark,onRemove:e=>{u(t=>({...t,phases:Ke(t.phases,e)})),A()}}),onClose:()=>A()}:void 0,bar:(0,J.jsxs)(J.Fragment,{children:[ie&&(0,J.jsx)(Sn,{hold:ae,stale:F,error:S.error?.reasons,saving:S.isPending,onSave:()=>S.mutate({name:s.name,description:s.description,phases:s.phases,expectedRevision:a.revision??0}),onDiscard:L,onReload:i}),(0,J.jsx)(pe,{children:(0,J.jsx)(oe,{defaultValue:V,onTest:e=>A(void 0,{test:e})},V)})]}),children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-14`,children:[(0,J.jsx)(Ir,{factoryId:e,boardId:t,model:R,boards:m.boards,totals:m.totals,emphasis:le,lanes:he,selectedPhase:B,selectedRule:z,problems:new Set(N.map(e=>e.key)),rulesEditable:m.rulesEditable,order:m.order,skills:g.data?.skills,edit:O?void 0:{required:e=>new Set(a.codeBehaviour?.[e]?.requiredNextPhases),onMoves:(e,t)=>u(n=>({...n,phases:n.phases.map(n=>n.key===e?Ct(n,t):n)})),onReorder:(e,t)=>u(n=>({...n,phases:rt(n.phases,e,t)})),onAdd:(e,t,n)=>{u(n=>({...n,phases:[...n.phases.slice(0,t),{...e,kind:`resting`,nextPhases:[]},...n.phases.slice(t)]})),n&&A(e.key)}}}),(0,J.jsx)(Pr,{factoryId:e,boardId:t,boards:m.boards,leaving:R.leaving,stray:R.stray,strayIncoming:R.strayIncoming,emphasis:e=>le.line(e),outside:le.outside,lanes:he})]})}),(0,J.jsx)(Cn,{boardName:a.name,open:I.state===`blocked`,onStay:()=>I.reset?.(),onLeave:()=>{f(),I.proceed?.()}})]})}function zr(){return(0,J.jsx)(Sr,{children:(0,J.jsx)(bt,{variant:`page`,body:`fixed`,children:(0,J.jsx)(Br,{})})})}function Br(){let e=Xe(),t=ke(),n=t?.boardId??``,r=at(e.id,n);return r.isPending?(0,J.jsx)(P,{label:`Board settings`,tabs:(0,J.jsx)(Te,{factoryId:e.id,boardId:n,active:`settings`}),header:(0,J.jsx)($n,{}),children:(0,J.jsx)(er,{})}):r.isError&&r.error instanceof ot&&r.error.code===`board_not_found`?(0,J.jsx)(Vr,{factoryId:e.id,boardId:n,children:(0,J.jsx)(Gt,{variant:`fill`,titleSlot:(0,J.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})})}):r.isError?(0,J.jsx)(Vr,{factoryId:e.id,boardId:n,children:(0,J.jsx)(Nt,{title:`Couldn’t load this board`,error:r.error,onRetry:()=>void r.refetch(),retrying:r.isFetching})}):(0,J.jsx)(Rr,{factoryId:e.id,boardId:n,phaseKey:t?.phaseKey,response:r.data,onReload:()=>void r.refetch()},`${n}:${r.data.board.revision??`code`}`)}function Vr({factoryId:e,boardId:t,children:n}){return(0,J.jsx)(P,{label:`Board settings`,tabs:(0,J.jsx)(Te,{factoryId:e,boardId:t,active:`settings`}),status:n})}export{zr as BoardConfigPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$r as t,Bn as n,Gr as r,Ln as i,Mn as a,Qr as o,Xi as s,Xr as c,Yn as l,Zr as u,dn as d,gn as f,hn as p,ii as m,ir as h,ma as g,nr as _,ti as ee,zn as v}from"./index-DjubxEY0.js";import{D as y,O as b,a as x,d as S,n as C,s as w,w as T}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{A as te,B as E,E as ne,G as re,I as ie,N as D,O as ae,V as oe,W as se,c as ce,d as le,f as ue,l as de,n as fe,o as pe,r as O,s as me,t as he,u as k,v as A,x as j,y as M}from"./useBoardConfigRoute-D3HWEvrn.js";import{$s as N,Ar as P,Mr as F,Qi as I,Tr as L,d as R,ec as z,wt as B,xi as V}from"./useFactories-BSnLX5pf.js";import{t as ge}from"./IconArrowDown.es-BkL10ZrR.js";import{t as _e}from"./IconArrowUp.es-7nbeX70P.js";import{t as H}from"./IconCircleDashed.es-Da4Pxk5L.js";import{b as ve,y as U}from"./useLinearData-C2hbv473.js";import{r as W,t as G}from"./HrefLink-DkNJBJtp.js";import{An as K}from"./useSessionRows-DqWZeKoh.js";import{t as q}from"./integration-icon-CGw0bkxw-D7TAlIER.js";import{c as ye}from"./settingsSections-rQ9VqtBb.js";var J=y();function be({onAdd:e}){return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:e,className:T(`flex h-5.5 items-center gap-1.5 rounded-md pr-1.5 text-foreground hover:bg-fill-hover`,w),children:[(0,J.jsx)(g,{className:`size-icon-xs`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,children:`Rule`})]})})}function xe({stats:e}){return(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center justify-between gap-1.5`,children:[(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,children:[`Last `,e.sampled,` items`]}),(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,children:[e.takes===0?`None land here`:`${e.takes} land here`,`,`,` `,e.lost===0?`none lost to earlier boards`:`${e.lost} lost to earlier boards`]})]})}function Se({boards:e,movable:t,onMove:n,renderBoard:r}){let i=ae({min:0,max:e.length-1,onDrop:n});return(0,J.jsx)(`ol`,{"aria-label":`Boards in intake order`,className:`flex flex-col`,children:e.map((e,n)=>{let a=i.rowMotion(n);return(0,J.jsxs)(`li`,{style:a.style,onPointerDown:t?e=>i.onPointerDown(e,n):void 0,onKeyDown:t?e=>i.onKeyDown(e,n):void 0,className:T(`relative flex flex-col`,a.className),children:[n>0&&(0,J.jsx)(D,{}),r(e,{index:n,dragging:i.drag?.from===n})]},e)})})}function Ce({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,J.jsx)(oe,{className:`-mt-3`,children:(0,J.jsx)(B,{variant:`info`,className:`mt-3`,children:(0,J.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,J.jsx)(`span`,{children:e},e))})})})}function we({earlier:e,later:t,onMove:n}){return(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!e,onClick:()=>n(-1),children:(0,J.jsx)(_e,{})}),(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!t,onClick:()=>n(1),children:(0,J.jsx)(ge,{})})]})}function Te({phase:e}){return(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center gap-1.5 rounded-md border border-dashed border-border-strong px-1.5`,children:[(0,J.jsx)(H,{className:`size-icon-xs shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`ink`,className:`flex-1`,children:`New rule`}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:e??`Pick a phase`})]})}var Ee=S(`IconChevronTopMedium`,()=>(0,J.jsx)(`path`,{d:`M6 14.5L12 8.5L18 14.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})),Y=e(b(),1);function De({id:e,defaultOpen:t,count:n,pending:r,error:i,hasMore:a,loadingMore:o,onLoadMore:s,children:c}){let[l,u]=(0,Y.useState)(t),d=n>0||a;return(0,J.jsxs)(`section`,{id:e,"aria-label":`Not routed`,className:T(z,`flex scroll-mt-4 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`),children:[(0,J.jsxs)(`header`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(H,{className:`size-icon-sm shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,children:`Not routed`}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`min-w-0 flex-1 truncate`,children:Oe({pending:r,error:i,hasMore:a},n)}),d&&(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,"aria-expanded":l,tooltip:l?`Hide items not routed`:`Show items not routed`,onClick:()=>u(!l),children:l?(0,J.jsx)(Ee,{}):(0,J.jsx)(I,{})})]}),!d&&!r&&!i&&(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`A new issue or pull request ends up here when no board’s rules take it.`}),l&&d&&(0,J.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`flex flex-col`,children:[c,a&&(0,J.jsx)(`li`,{className:`flex justify-center border-t border-border pt-2`,children:(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:s,loading:o,children:`Load more`})})]})]})}function Oe(e,t){return e.pending?`Loading…`:e.error?`Items not routed didn’t load.`:e.hasMore?t>0?`${t}+ waiting`:`More waiting`:t===0?`Every new issue and pull request found a board.`:`${t} waiting`}function ke({item:e,icon:t,source:n,routing:r,onWhy:i,onRouteAgain:a}){return(0,J.jsxs)(`li`,{className:`flex items-center gap-2 border-t border-border py-2`,children:[t,(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(C,{as:`span`,variant:`body-sm`,tone:`ink`,className:`truncate`,children:e.url?(0,J.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:e.title}):e.title}),(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`flex min-w-0 gap-1.5`,children:[n&&(0,J.jsx)(`span`,{className:`truncate`,children:n}),(0,J.jsx)(`span`,{className:`truncate`,children:e.reason??`No board’s rules match it.`}),(0,J.jsx)(`time`,{dateTime:e.decidedAt,className:`shrink-0`,children:new Date(e.decidedAt).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})})]})]}),(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:i,children:`Why?`}),a&&(0,J.jsx)(V,{size:`sm`,variant:`ghost`,tooltip:`Change a board’s rules, then route it again.`,onClick:a,loading:r,children:`Route again`})]})}function Ae({name:e,current:t,dragging:n,header:r,children:i}){return(0,J.jsxs)(`article`,{"aria-label":e,"aria-current":t?`true`:void 0,className:T(`group/card flex flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`,`transition-shadow duration-normal ease-out-custom motion-reduce:transition-none`,n?N:z,t&&`outline -outline-offset-1 outline-foreground`),children:[r,(0,J.jsx)(`hr`,{className:`border-border`}),i]})}function je({name:e,current:t,place:n,grip:r,dragging:i,routingHref:a,rulesHref:o,LinkComponent:c,children:l}){return(0,J.jsxs)(`header`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsxs)(`span`,{"data-grip":r?``:void 0,className:T(`relative flex h-4 min-w-4 shrink-0 items-center justify-center`,r&&`cursor-grab touch-none active:cursor-grabbing`),children:[(0,J.jsx)(C,{as:`span`,variant:`meta`,tone:`muted`,className:T(`flex h-4 min-w-4 items-center justify-center rounded-lg bg-background px-1.25 font-semibold tabular-nums`,r&&`group-hover/card:invisible`,i&&`invisible`),children:n}),r&&(0,J.jsx)(s,{"aria-hidden":!0,className:T(`absolute size-icon-xs text-muted-foreground`,i?`visible`:`invisible group-hover/card:visible`)})]}),(0,J.jsx)(Me,{name:e,current:t,href:a,LinkComponent:c}),(0,J.jsx)(`span`,{className:`flex-1`}),l,(0,J.jsxs)(c,{href:o,"aria-label":`All rules on ${e}`,className:T(`flex items-center gap-1 rounded-sm text-caption text-muted-foreground hover:text-foreground`,w),children:[`All rules`,(0,J.jsx)(U,{className:`size-icon-xs`,"aria-hidden":!0})]})]})}function Me({name:e,current:t,href:n,LinkComponent:r}){return t?(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,className:`min-w-0 truncate`,children:e}):(0,J.jsx)(r,{href:n,className:`min-w-0 truncate hover:underline`,children:(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,className:`truncate`,children:e})})}function Ne({name:e,lanes:t,last:n,children:r}){return(0,J.jsxs)(`ul`,{"aria-label":`${e} rules for new items`,className:`flex flex-col gap-0.5`,children:[t&&t.map(e=>e.rules.length===0?(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center gap-1.5`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:n?`No rules, ends Not routed`:`No rules, goes to the next board`})]},e.event):e.rules),r]})}function Pe({label:e,icon:t,rank:n,skipped:r,stage:i,phase:a,filed:o,notes:s,onOpen:c}){return(0,J.jsxs)(`li`,{className:`flex flex-col`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:c,className:T(`-mx-1 flex h-5.5 items-center gap-1.5 rounded-md px-1 text-left hover:bg-fill-hover`,w,r&&`opacity-50`),children:[t,n,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`ink`,className:`min-w-0 flex-1 truncate`,children:e}),(0,J.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center gap-1.25`,children:[i&&(0,J.jsx)(ve,{stage:i.key,kind:i.kind,decorative:!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`truncate`,children:a})]}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`w-7.5 shrink-0 text-right tabular-nums`,children:o})]}),s.map(e=>(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`flex items-center gap-1.5 pl-4.5`,children:[e.tone===`warning`&&(0,J.jsx)(x,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-hidden":!0}),e.text]},e.text))]})}function Fe({total:e,where:t,canEdit:n,moving:r,onMove:i}){let[a,o]=(0,Y.useState)(!1);if(a||e===0)return null;let s=e===1?`1 untouched card now belongs`:`${e} untouched cards now belong`;return(0,J.jsxs)(B,{variant:`info`,title:`Rules changed`,actionPlacement:`end`,action:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>o(!0),children:`Not now`}),n&&(0,J.jsx)(V,{size:`sm`,variant:`primary`,onClick:i,loading:r,children:`Move them`})]}),children:[s,` on `,t,`.`]})}function Ie(e,t){let n=(t.x-e.x)/2;return`M${e.x} ${e.y}C${e.x+n} ${e.y} ${t.x-n} ${t.y} ${t.x} ${t.y}`}var X=e=>{let t=e.getBoundingClientRect();return t.top+t.height/2};function Le(){let e=(0,Y.useRef)(null),[t,n]=(0,Y.useState)();return(0,Y.useLayoutEffect)(()=>{let t=e.current,r=t?.parentElement;if(!t||!r)return;let i=()=>{let e=t.getScreenCTM()?.inverse(),i=r.querySelector(`[data-link-order]`),a=i?.querySelector(`header`),o=a?.parentElement;if(!e||!i||!a||!o)return n(void 0);let s=(t,n)=>{let r=new DOMPoint(t,n).matrixTransform(e);return{x:Math.round(r.x),y:Math.round(r.y)}},c=s(0,X(a)).y-s(0,o.getBoundingClientRect().top).y,l=i.getBoundingClientRect(),u=s(l.left,l.top);n({order:{x:u.x,y:u.y+c},sources:[...r.querySelectorAll(`[data-link-source]`)].map(e=>s(e.getBoundingClientRect().right,X(e.firstElementChild??e)))})};i();let a=new ResizeObserver(i);for(let e of r.children)e!==t&&a.observe(e);return()=>a.disconnect()},[]),(0,J.jsxs)(`svg`,{ref:e,"aria-hidden":!0,className:T(te,`pointer-events-none absolute inset-0 size-full overflow-visible max-sm:hidden`),children:[t?.sources.map(e=>(0,J.jsx)(`path`,{d:Ie(e,t.order)},`${e.x},${e.y}`)),t&&[...t.sources,t.order].map(e=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:4.5,className:`fill-card`},`${e.x},${e.y}`))]})}function Re({lanes:e,routeList:t,intakeHref:n,LinkComponent:r}){return(0,J.jsxs)(`section`,{"aria-label":`Sources`,className:`flex w-63 shrink-0 flex-col gap-3 max-sm:w-full`,children:[(0,J.jsxs)(`div`,{className:`flex h-5 items-center justify-between`,children:[(0,J.jsx)(C,{as:`h2`,variant:`column`,tone:`muted`,children:`Sources`}),(0,J.jsxs)(r,{href:n,className:`flex items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(C,{as:`span`,variant:`caption`,children:`Work Intake`}),(0,J.jsx)(U,{className:`size-icon-xs`,"aria-hidden":!0})]})]}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map(e=>(0,J.jsxs)(`li`,{"data-link-source":!0,"aria-label":e.label,className:T(z,`flex h-17 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`card-title-strong`,tone:`ink`,className:`flex-1`,children:e.label}),e.filed!==void 0&&(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`tabular-nums`,children:e.filed})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.sources.map(e=>(0,J.jsxs)(`span`,{className:`flex items-center gap-1.25`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:e.name})]},e.key)),e.sources.length===0&&(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:`No source connected`})]})]},e.event))}),!t&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.25 pt-2`,children:[(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`A new issue or pull request is offered to the boards in this order. The first rule that matches keeps it.`}),(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`After that, only its board’s card rules apply.`})]})]})}function ze({factoryId:e,onWhy:t}){let n=ce(e),r=de(e),i=W(e),a=P(),o=new Map((i.data??[]).map(e=>[e.id,e.name])),s=n.data?.pages??[],c=s.flatMap(e=>e.notRouted),l=s[0]?.canEdit??!1,d=e=>r.mutate(e.id,{onSuccess:t=>K.success(`Filing “${e.title}” on ${o.get(t.boardKey)??t.boardKey}.`),onError:e=>K.error(e.message)});return(0,J.jsx)(De,{id:u,defaultOpen:a.hash===`#${u}`,count:c.length,pending:n.isPending,error:n.isError,hasMore:n.hasNextPage,loadingMore:n.isFetchingNextPage,onLoadMore:()=>void n.fetchNextPage(),children:c.map(e=>{let{provider:n,source:i}=Be(e.sourceKey);return(0,J.jsx)(ke,{item:e,icon:n&&(0,J.jsx)(q,{provider:n,className:`size-icon-xs`}),source:i,routing:r.isPending&&r.variables===e.id,onWhy:()=>t(e.id),onRouteAgain:l?()=>d(e):void 0},e.id)})})}function Be(e){if(!e)return{};let t=e.indexOf(`:`),n=e.slice(0,t);return t<0||!f(n)?{source:e}:{provider:n,source:e.slice(t+1)}}var Z=l.filter(_);function Q({event:e,className:t}){let{icon:n}=h(e);return(0,J.jsx)(n,{className:T(`text-muted-foreground size-icon-xs shrink-0`,t),"aria-hidden":!0})}function Ve({line:e,board:t,onOpen:n}){let{rule:r}=e,i=r.target.phaseKey??t?.initialPhase;return(0,J.jsx)(Pe,{label:e.label,icon:(0,J.jsx)(Q,{event:e.event}),rank:e.of>1&&(0,J.jsx)(ne,{line:e}),skipped:!r.enabled||e.hiddenBy!==void 0||e.movesCardsOnly,stage:t&&i?{key:i,kind:d(t,i)}:void 0,phase:t?a(t,r.target.phaseKey)??i:r.target.phaseKey,filed:e.filed,notes:M(e),onOpen:()=>n(r.id)})}function $({name:e,lines:t,board:n,last:r,onOpenRule:i,children:a}){let o=t&&Z.map(e=>({event:e,icon:(0,J.jsx)(Q,{event:e}),rules:t.filter(t=>t.event===e).map(t=>(0,J.jsx)(Ve,{line:t,board:n,onOpen:i},`${e}:${t.rule.id}`))}));return(0,J.jsx)(Ne,{name:e,lanes:o,last:r,children:a})}function He({factoryId:e,canEdit:t,boardNames:r}){let a=n(e),o=i(e),s=new Set(a.data?.moves.map(e=>e.toBoard)),[c]=s,l=s.size===1&&c?r.get(c)??c:`other boards`;return(0,J.jsx)(Fe,{total:a.data?.total??0,where:l,canEdit:t,moving:o.isPending,onMove:()=>o.mutate(void 0,{onSuccess:({moved:e,skipped:t})=>{let n=t>0?` ${t} changed meanwhile and stayed.`:``;K.success(`Moved ${e===1?`1 card`:`${e} cards`}.${n}`)},onError:e=>K.error(e.message)})})}function Ue({factoryId:e,boardId:t,focus:n,onFocus:r}){return`newRule`in n?(0,J.jsx)(O,{factoryId:e,boardId:t,focus:n,onFocus:r,onClose:()=>r()},`new`):`rule`in n?(0,J.jsx)(O,{factoryId:e,boardId:t,focus:{rule:n.rule},backTo:n.test,onFocus:r,onClose:()=>r()},n.rule):(0,J.jsx)(fe,{factoryId:e,boardId:t,subject:n.test,onEditRule:e=>r({rule:e,test:n.test}),onClose:()=>r()},n.test)}var We=[`github`,`gitlab`];function Ge({factoryId:e,repositories:t,filed:n,routeList:r}){let i=R(),a=new Set(t.map(e=>e.provider??`github`));for(let t of i.data??[])t.factoryProjectId===e&&f(t.integrationId)&&a.add(t.integrationId);let o=Z.map(e=>({event:e,label:h(e).label,icon:(0,J.jsx)(Q,{event:e,className:`text-foreground size-icon-sm`}),filed:n&&(n.get(e)??0),sources:[...a].filter(t=>e!==`pull_request.opened`||We.includes(t)).map(e=>({key:e,name:p[e],icon:(0,J.jsx)(q,{provider:e,className:`size-icon-xs`})}))}));return(0,J.jsx)(Re,{lanes:o,routeList:r,intakeHref:ye(e,`intake`),LinkComponent:G})}function Ke(e){let t=me(e),n=k(e),[r,i]=(0,Y.useState)(),a=t.data?.boards.map(e=>e.boardKey)??[],o=r&&qe(r,a)?r:void 0,s=o??a,c=(t.data?.canEdit??!1)&&s.length>1;return{query:t,saved:a,shown:s,changed:o!==void 0&&o.some((e,t)=>e!==a[t]),sortable:c,movable:c&&!n.isPending,saving:n.isPending,move:(e,t)=>{let n=[...s],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),i(n))},save:()=>n.mutate(s,{onSuccess:()=>{i(void 0),K.success(`Intake order saved.`)},onError:e=>K.error(e.message)}),discard:()=>i(void 0)}}function qe(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function Je(e,t){let n=v(e).data?.intakeRoutes,r=j(e).data,i=le(e).data?.skipped,a=r&&new Map(r.boards.flatMap(e=>e.rules.map(e=>[e.routeId,e.filed]))),o=new Map((i??[]).map(e=>[e.routeId,e])),s=n&&new Map(t.map(e=>[e,A(ue(n,e),{filed:a,skips:o}).filter(e=>_(e.event))]));return{lines:s,filedByEvent:a&&Ye(s?.values()??[])}}function Ye(e){let t=new Map;for(let n of e)for(let e of n)t.set(e.event,(t.get(e.event)??0)+(e.filed??0));return t}function Xe({factoryId:e,boardId:n,repositories:r}){let i=F(),[s]=L(),l=ee(s),u=r=>i(t(e,n,{focus:r})),d=Ke(e),f=v(e),p=j(e).data,m=W(e).data??[],{lines:h,filedByEvent:g}=Je(e,d.shown),_=d.query.data,y=f.data?.canEdit??!1,b=new Map(_?.boards.map(e=>[e.boardKey,e.name])),x=Ze(p,n),S=l&&`newRule`in l?l.newRule:void 0,w=S&&(S.board??n),T=l&&`test`in l?l.test:void 0;return(0,J.jsx)(E,{label:`Routing`,tabs:(0,J.jsx)(pe,{factoryId:e,boardId:n,active:`routing`}),panel:l?{content:(0,J.jsx)(Ue,{factoryId:e,boardId:n,focus:l,onFocus:u}),onClose:()=>u()}:void 0,bar:(0,J.jsxs)(J.Fragment,{children:[_?.canEdit&&d.changed&&(0,J.jsx)(ie,{label:`Order not saved`,saveLabel:`Save order`,saving:d.saving,onSave:d.save,onDiscard:d.discard}),(0,J.jsx)(se,{children:(0,J.jsx)(re,{defaultValue:T,onTest:e=>u({test:e})},T)})]}),children:(0,J.jsxs)(`div`,{className:`relative mx-auto flex w-max items-start gap-16 max-sm:w-full max-sm:flex-col max-sm:gap-10`,children:[(0,J.jsx)(Ge,{factoryId:e,repositories:r,filed:g,routeList:_?.evaluator===`route-list`}),(0,J.jsxs)(`section`,{id:c,"aria-label":`Intake order`,className:`flex w-115 shrink-0 scroll-mt-4 flex-col gap-3 max-sm:w-full`,children:[(0,J.jsx)(C,{as:`h2`,variant:`column`,tone:`muted`,className:`flex h-5 items-center`,children:`Intake order`}),d.query.isError&&(0,J.jsx)(B,{variant:`destructive`,children:`The intake order didn’t load.`}),f.isError&&(0,J.jsx)(B,{variant:`warning`,children:`Rules didn’t load.`}),(0,J.jsx)(He,{factoryId:e,canEdit:y,boardNames:b}),_&&(0,J.jsx)(Ce,{order:_,changed:d.changed}),_&&!d.saved.includes(n)&&(0,J.jsx)(B,{variant:`info`,children:`Not in the intake order: new issues and pull requests never reach this board.`}),(0,J.jsxs)(`div`,{"data-link-order":!0,className:`flex flex-col`,children:[(0,J.jsx)(Se,{boards:d.shown,movable:d.movable,onMove:d.move,renderBoard:(r,{index:i,dragging:s})=>{let c=r===n,l=b.get(r)??r,f=m.find(e=>e.id===r);return(0,J.jsx)(Ae,{name:l,current:c,dragging:s,header:(0,J.jsx)(je,{name:l,current:c,place:i+1,grip:d.movable,dragging:s,routingHref:t(e,r),rulesHref:o(e,r),LinkComponent:G,children:d.sortable&&(0,J.jsx)(we,{earlier:d.movable&&i>0,later:d.movable&&i<d.shown.length-1,onMove:e=>d.move(i,i+e)})}),children:(0,J.jsxs)($,{name:l,lines:h?.get(r),board:f,last:i===d.shown.length-1,onOpenRule:e=>u({rule:e}),children:[S&&w===r&&(0,J.jsx)(Te,{phase:S.into&&a(f,S.into)}),c&&x&&(0,J.jsx)(xe,{stats:x}),c&&y&&w!==r&&(0,J.jsx)(be,{onAdd:()=>u({newRule:{board:r}})})]})})}}),d.shown.length>0&&(0,J.jsx)(D,{}),(0,J.jsx)(ze,{factoryId:e,onWhy:e=>u({test:e})})]})]}),(0,J.jsx)(Le,{})]})})}function Ze(e,t){let n=e?.boards.find(e=>e.boardKey===t);if(e&&n)return{sampled:e.sampled,takes:n.takes.length,lost:n.lostTo.reduce((e,t)=>e+t.keys.length,0)}}function Qe(){let e=r(),t=he()?.boardId??``;return(0,J.jsx)(m,{variant:`page`,body:`fixed`,children:(0,J.jsx)(Xe,{factoryId:e.id,boardId:t,repositories:e.repositories},e.id)})}export{Qe as BoardIntakePage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$r as t,Bn as n,Gr as r,Ln as i,Mn as a,Qr as o,Xi as s,Xr as c,Yn as l,Zr as u,dn as d,gn as f,hn as p,ii as m,ir as h,ma as g,nr as _,ti as ee,zn as v}from"./index-DJ3zJOT1.js";import{D as y,O as b,a as x,d as S,n as C,s as w,w as T}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{A as te,B as E,E as ne,G as re,I as ie,N as D,O as ae,V as oe,W as se,c as ce,d as le,f as ue,l as de,n as fe,o as pe,r as O,s as me,t as he,u as k,v as A,x as j,y as M}from"./useBoardConfigRoute-BTs9lUfW.js";import{$s as N,Ar as P,Mr as F,Qi as I,Tr as L,d as R,ec as z,wt as B,xi as V}from"./useFactories-BbPGoUnu.js";import{t as ge}from"./IconArrowDown.es-BkL10ZrR.js";import{t as _e}from"./IconArrowUp.es-7nbeX70P.js";import{t as H}from"./IconCircleDashed.es-Da4Pxk5L.js";import{b as ve,y as U}from"./useLinearData-D-jzoXrj.js";import{r as W,t as G}from"./HrefLink-B8qef5fl.js";import{An as K}from"./useSessionRows-BFZXJZw8.js";import{t as q}from"./integration-icon-CGw0bkxw-B39o4-g7.js";import{c as ye}from"./settingsSections-rQ9VqtBb.js";var J=y();function be({onAdd:e}){return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:e,className:T(`flex h-5.5 items-center gap-1.5 rounded-md pr-1.5 text-foreground hover:bg-fill-hover`,w),children:[(0,J.jsx)(g,{className:`size-icon-xs`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,children:`Rule`})]})})}function xe({stats:e}){return(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center justify-between gap-1.5`,children:[(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,children:[`Last `,e.sampled,` items`]}),(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,children:[e.takes===0?`None land here`:`${e.takes} land here`,`,`,` `,e.lost===0?`none lost to earlier boards`:`${e.lost} lost to earlier boards`]})]})}function Se({boards:e,movable:t,onMove:n,renderBoard:r}){let i=ae({min:0,max:e.length-1,onDrop:n});return(0,J.jsx)(`ol`,{"aria-label":`Boards in intake order`,className:`flex flex-col`,children:e.map((e,n)=>{let a=i.rowMotion(n);return(0,J.jsxs)(`li`,{style:a.style,onPointerDown:t?e=>i.onPointerDown(e,n):void 0,onKeyDown:t?e=>i.onKeyDown(e,n):void 0,className:T(`relative flex flex-col`,a.className),children:[n>0&&(0,J.jsx)(D,{}),r(e,{index:n,dragging:i.drag?.from===n})]},e)})})}function Ce({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,J.jsx)(oe,{className:`-mt-3`,children:(0,J.jsx)(B,{variant:`info`,className:`mt-3`,children:(0,J.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,J.jsx)(`span`,{children:e},e))})})})}function we({earlier:e,later:t,onMove:n}){return(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!e,onClick:()=>n(-1),children:(0,J.jsx)(_e,{})}),(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!t,onClick:()=>n(1),children:(0,J.jsx)(ge,{})})]})}function Te({phase:e}){return(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center gap-1.5 rounded-md border border-dashed border-border-strong px-1.5`,children:[(0,J.jsx)(H,{className:`size-icon-xs shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`ink`,className:`flex-1`,children:`New rule`}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:e??`Pick a phase`})]})}var Ee=S(`IconChevronTopMedium`,()=>(0,J.jsx)(`path`,{d:`M6 14.5L12 8.5L18 14.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})),Y=e(b(),1);function De({id:e,defaultOpen:t,count:n,pending:r,error:i,hasMore:a,loadingMore:o,onLoadMore:s,children:c}){let[l,u]=(0,Y.useState)(t),d=n>0||a;return(0,J.jsxs)(`section`,{id:e,"aria-label":`Not routed`,className:T(z,`flex scroll-mt-4 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`),children:[(0,J.jsxs)(`header`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsx)(H,{className:`size-icon-sm shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,children:`Not routed`}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`min-w-0 flex-1 truncate`,children:Oe({pending:r,error:i,hasMore:a},n)}),d&&(0,J.jsx)(V,{size:`icon-sm`,variant:`ghost`,"aria-expanded":l,tooltip:l?`Hide items not routed`:`Show items not routed`,onClick:()=>u(!l),children:l?(0,J.jsx)(Ee,{}):(0,J.jsx)(I,{})})]}),!d&&!r&&!i&&(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`A new issue or pull request ends up here when no board’s rules take it.`}),l&&d&&(0,J.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`flex flex-col`,children:[c,a&&(0,J.jsx)(`li`,{className:`flex justify-center border-t border-border pt-2`,children:(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:s,loading:o,children:`Load more`})})]})]})}function Oe(e,t){return e.pending?`Loading…`:e.error?`Items not routed didn’t load.`:e.hasMore?t>0?`${t}+ waiting`:`More waiting`:t===0?`Every new issue and pull request found a board.`:`${t} waiting`}function ke({item:e,icon:t,source:n,routing:r,onWhy:i,onRouteAgain:a}){return(0,J.jsxs)(`li`,{className:`flex items-center gap-2 border-t border-border py-2`,children:[t,(0,J.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(C,{as:`span`,variant:`body-sm`,tone:`ink`,className:`truncate`,children:e.url?(0,J.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:e.title}):e.title}),(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`flex min-w-0 gap-1.5`,children:[n&&(0,J.jsx)(`span`,{className:`truncate`,children:n}),(0,J.jsx)(`span`,{className:`truncate`,children:e.reason??`No board’s rules match it.`}),(0,J.jsx)(`time`,{dateTime:e.decidedAt,className:`shrink-0`,children:new Date(e.decidedAt).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})})]})]}),(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:i,children:`Why?`}),a&&(0,J.jsx)(V,{size:`sm`,variant:`ghost`,tooltip:`Change a board’s rules, then route it again.`,onClick:a,loading:r,children:`Route again`})]})}function Ae({name:e,current:t,dragging:n,header:r,children:i}){return(0,J.jsxs)(`article`,{"aria-label":e,"aria-current":t?`true`:void 0,className:T(`group/card flex flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`,`transition-shadow duration-normal ease-out-custom motion-reduce:transition-none`,n?N:z,t&&`outline -outline-offset-1 outline-foreground`),children:[r,(0,J.jsx)(`hr`,{className:`border-border`}),i]})}function je({name:e,current:t,place:n,grip:r,dragging:i,routingHref:a,rulesHref:o,LinkComponent:c,children:l}){return(0,J.jsxs)(`header`,{className:`flex min-h-5.5 items-center gap-2`,children:[(0,J.jsxs)(`span`,{"data-grip":r?``:void 0,className:T(`relative flex h-4 min-w-4 shrink-0 items-center justify-center`,r&&`cursor-grab touch-none active:cursor-grabbing`),children:[(0,J.jsx)(C,{as:`span`,variant:`meta`,tone:`muted`,className:T(`flex h-4 min-w-4 items-center justify-center rounded-lg bg-background px-1.25 font-semibold tabular-nums`,r&&`group-hover/card:invisible`,i&&`invisible`),children:n}),r&&(0,J.jsx)(s,{"aria-hidden":!0,className:T(`absolute size-icon-xs text-muted-foreground`,i?`visible`:`invisible group-hover/card:visible`)})]}),(0,J.jsx)(Me,{name:e,current:t,href:a,LinkComponent:c}),(0,J.jsx)(`span`,{className:`flex-1`}),l,(0,J.jsxs)(c,{href:o,"aria-label":`All rules on ${e}`,className:T(`flex items-center gap-1 rounded-sm text-caption text-muted-foreground hover:text-foreground`,w),children:[`All rules`,(0,J.jsx)(U,{className:`size-icon-xs`,"aria-hidden":!0})]})]})}function Me({name:e,current:t,href:n,LinkComponent:r}){return t?(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,className:`min-w-0 truncate`,children:e}):(0,J.jsx)(r,{href:n,className:`min-w-0 truncate hover:underline`,children:(0,J.jsx)(C,{as:`h2`,variant:`card-title-strong`,tone:`ink`,className:`truncate`,children:e})})}function Ne({name:e,lanes:t,last:n,children:r}){return(0,J.jsxs)(`ul`,{"aria-label":`${e} rules for new items`,className:`flex flex-col gap-0.5`,children:[t&&t.map(e=>e.rules.length===0?(0,J.jsxs)(`li`,{className:`flex h-5.5 items-center gap-1.5`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:n?`No rules, ends Not routed`:`No rules, goes to the next board`})]},e.event):e.rules),r]})}function Pe({label:e,icon:t,rank:n,skipped:r,stage:i,phase:a,filed:o,notes:s,onOpen:c}){return(0,J.jsxs)(`li`,{className:`flex flex-col`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:c,className:T(`-mx-1 flex h-5.5 items-center gap-1.5 rounded-md px-1 text-left hover:bg-fill-hover`,w,r&&`opacity-50`),children:[t,n,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`ink`,className:`min-w-0 flex-1 truncate`,children:e}),(0,J.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center gap-1.25`,children:[i&&(0,J.jsx)(ve,{stage:i.key,kind:i.kind,decorative:!0}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`truncate`,children:a})]}),(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`w-7.5 shrink-0 text-right tabular-nums`,children:o})]}),s.map(e=>(0,J.jsxs)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`flex items-center gap-1.5 pl-4.5`,children:[e.tone===`warning`&&(0,J.jsx)(x,{className:`size-icon-xs shrink-0 text-warning-indicator`,"aria-hidden":!0}),e.text]},e.text))]})}function Fe({total:e,where:t,canEdit:n,moving:r,onMove:i}){let[a,o]=(0,Y.useState)(!1);if(a||e===0)return null;let s=e===1?`1 untouched card now belongs`:`${e} untouched cards now belong`;return(0,J.jsxs)(B,{variant:`info`,title:`Rules changed`,actionPlacement:`end`,action:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(V,{size:`sm`,variant:`ghost`,onClick:()=>o(!0),children:`Not now`}),n&&(0,J.jsx)(V,{size:`sm`,variant:`primary`,onClick:i,loading:r,children:`Move them`})]}),children:[s,` on `,t,`.`]})}function Ie(e,t){let n=(t.x-e.x)/2;return`M${e.x} ${e.y}C${e.x+n} ${e.y} ${t.x-n} ${t.y} ${t.x} ${t.y}`}var X=e=>{let t=e.getBoundingClientRect();return t.top+t.height/2};function Le(){let e=(0,Y.useRef)(null),[t,n]=(0,Y.useState)();return(0,Y.useLayoutEffect)(()=>{let t=e.current,r=t?.parentElement;if(!t||!r)return;let i=()=>{let e=t.getScreenCTM()?.inverse(),i=r.querySelector(`[data-link-order]`),a=i?.querySelector(`header`),o=a?.parentElement;if(!e||!i||!a||!o)return n(void 0);let s=(t,n)=>{let r=new DOMPoint(t,n).matrixTransform(e);return{x:Math.round(r.x),y:Math.round(r.y)}},c=s(0,X(a)).y-s(0,o.getBoundingClientRect().top).y,l=i.getBoundingClientRect(),u=s(l.left,l.top);n({order:{x:u.x,y:u.y+c},sources:[...r.querySelectorAll(`[data-link-source]`)].map(e=>s(e.getBoundingClientRect().right,X(e.firstElementChild??e)))})};i();let a=new ResizeObserver(i);for(let e of r.children)e!==t&&a.observe(e);return()=>a.disconnect()},[]),(0,J.jsxs)(`svg`,{ref:e,"aria-hidden":!0,className:T(te,`pointer-events-none absolute inset-0 size-full overflow-visible max-sm:hidden`),children:[t?.sources.map(e=>(0,J.jsx)(`path`,{d:Ie(e,t.order)},`${e.x},${e.y}`)),t&&[...t.sources,t.order].map(e=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:4.5,className:`fill-card`},`${e.x},${e.y}`))]})}function Re({lanes:e,routeList:t,intakeHref:n,LinkComponent:r}){return(0,J.jsxs)(`section`,{"aria-label":`Sources`,className:`flex w-63 shrink-0 flex-col gap-3 max-sm:w-full`,children:[(0,J.jsxs)(`div`,{className:`flex h-5 items-center justify-between`,children:[(0,J.jsx)(C,{as:`h2`,variant:`column`,tone:`muted`,children:`Sources`}),(0,J.jsxs)(r,{href:n,className:`flex items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,J.jsx)(C,{as:`span`,variant:`caption`,children:`Work Intake`}),(0,J.jsx)(U,{className:`size-icon-xs`,"aria-hidden":!0})]})]}),(0,J.jsx)(`ul`,{className:`flex flex-col gap-3`,children:e.map(e=>(0,J.jsxs)(`li`,{"data-link-source":!0,"aria-label":e.label,className:T(z,`flex h-17 flex-col gap-1.75 rounded-2xl px-3.25 pt-2.75 pb-3`),children:[(0,J.jsxs)(`div`,{className:`flex min-h-5.5 items-center gap-2`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`card-title-strong`,tone:`ink`,className:`flex-1`,children:e.label}),e.filed!==void 0&&(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,className:`tabular-nums`,children:e.filed})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.sources.map(e=>(0,J.jsxs)(`span`,{className:`flex items-center gap-1.25`,children:[e.icon,(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:e.name})]},e.key)),e.sources.length===0&&(0,J.jsx)(C,{as:`span`,variant:`caption`,tone:`muted`,children:`No source connected`})]})]},e.event))}),!t&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-3.25 pt-2`,children:[(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`A new issue or pull request is offered to the boards in this order. The first rule that matches keeps it.`}),(0,J.jsx)(C,{as:`p`,variant:`caption`,tone:`muted`,children:`After that, only its board’s card rules apply.`})]})]})}function ze({factoryId:e,onWhy:t}){let n=ce(e),r=de(e),i=W(e),a=P(),o=new Map((i.data??[]).map(e=>[e.id,e.name])),s=n.data?.pages??[],c=s.flatMap(e=>e.notRouted),l=s[0]?.canEdit??!1,d=e=>r.mutate(e.id,{onSuccess:t=>K.success(`Filing “${e.title}” on ${o.get(t.boardKey)??t.boardKey}.`),onError:e=>K.error(e.message)});return(0,J.jsx)(De,{id:u,defaultOpen:a.hash===`#${u}`,count:c.length,pending:n.isPending,error:n.isError,hasMore:n.hasNextPage,loadingMore:n.isFetchingNextPage,onLoadMore:()=>void n.fetchNextPage(),children:c.map(e=>{let{provider:n,source:i}=Be(e.sourceKey);return(0,J.jsx)(ke,{item:e,icon:n&&(0,J.jsx)(q,{provider:n,className:`size-icon-xs`}),source:i,routing:r.isPending&&r.variables===e.id,onWhy:()=>t(e.id),onRouteAgain:l?()=>d(e):void 0},e.id)})})}function Be(e){if(!e)return{};let t=e.indexOf(`:`),n=e.slice(0,t);return t<0||!f(n)?{source:e}:{provider:n,source:e.slice(t+1)}}var Z=l.filter(_);function Q({event:e,className:t}){let{icon:n}=h(e);return(0,J.jsx)(n,{className:T(`text-muted-foreground size-icon-xs shrink-0`,t),"aria-hidden":!0})}function Ve({line:e,board:t,onOpen:n}){let{rule:r}=e,i=r.target.phaseKey??t?.initialPhase;return(0,J.jsx)(Pe,{label:e.label,icon:(0,J.jsx)(Q,{event:e.event}),rank:e.of>1&&(0,J.jsx)(ne,{line:e}),skipped:!r.enabled||e.hiddenBy!==void 0||e.movesCardsOnly,stage:t&&i?{key:i,kind:d(t,i)}:void 0,phase:t?a(t,r.target.phaseKey)??i:r.target.phaseKey,filed:e.filed,notes:M(e),onOpen:()=>n(r.id)})}function $({name:e,lines:t,board:n,last:r,onOpenRule:i,children:a}){let o=t&&Z.map(e=>({event:e,icon:(0,J.jsx)(Q,{event:e}),rules:t.filter(t=>t.event===e).map(t=>(0,J.jsx)(Ve,{line:t,board:n,onOpen:i},`${e}:${t.rule.id}`))}));return(0,J.jsx)(Ne,{name:e,lanes:o,last:r,children:a})}function He({factoryId:e,canEdit:t,boardNames:r}){let a=n(e),o=i(e),s=new Set(a.data?.moves.map(e=>e.toBoard)),[c]=s,l=s.size===1&&c?r.get(c)??c:`other boards`;return(0,J.jsx)(Fe,{total:a.data?.total??0,where:l,canEdit:t,moving:o.isPending,onMove:()=>o.mutate(void 0,{onSuccess:({moved:e,skipped:t})=>{let n=t>0?` ${t} changed meanwhile and stayed.`:``;K.success(`Moved ${e===1?`1 card`:`${e} cards`}.${n}`)},onError:e=>K.error(e.message)})})}function Ue({factoryId:e,boardId:t,focus:n,onFocus:r}){return`newRule`in n?(0,J.jsx)(O,{factoryId:e,boardId:t,focus:n,onFocus:r,onClose:()=>r()},`new`):`rule`in n?(0,J.jsx)(O,{factoryId:e,boardId:t,focus:{rule:n.rule},backTo:n.test,onFocus:r,onClose:()=>r()},n.rule):(0,J.jsx)(fe,{factoryId:e,boardId:t,subject:n.test,onEditRule:e=>r({rule:e,test:n.test}),onClose:()=>r()},n.test)}var We=[`github`,`gitlab`];function Ge({factoryId:e,repositories:t,filed:n,routeList:r}){let i=R(),a=new Set(t.map(e=>e.provider??`github`));for(let t of i.data??[])t.factoryProjectId===e&&f(t.integrationId)&&a.add(t.integrationId);let o=Z.map(e=>({event:e,label:h(e).label,icon:(0,J.jsx)(Q,{event:e,className:`text-foreground size-icon-sm`}),filed:n&&(n.get(e)??0),sources:[...a].filter(t=>e!==`pull_request.opened`||We.includes(t)).map(e=>({key:e,name:p[e],icon:(0,J.jsx)(q,{provider:e,className:`size-icon-xs`})}))}));return(0,J.jsx)(Re,{lanes:o,routeList:r,intakeHref:ye(e,`intake`),LinkComponent:G})}function Ke(e){let t=me(e),n=k(e),[r,i]=(0,Y.useState)(),a=t.data?.boards.map(e=>e.boardKey)??[],o=r&&qe(r,a)?r:void 0,s=o??a,c=(t.data?.canEdit??!1)&&s.length>1;return{query:t,saved:a,shown:s,changed:o!==void 0&&o.some((e,t)=>e!==a[t]),sortable:c,movable:c&&!n.isPending,saving:n.isPending,move:(e,t)=>{let n=[...s],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),i(n))},save:()=>n.mutate(s,{onSuccess:()=>{i(void 0),K.success(`Intake order saved.`)},onError:e=>K.error(e.message)}),discard:()=>i(void 0)}}function qe(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function Je(e,t){let n=v(e).data?.intakeRoutes,r=j(e).data,i=le(e).data?.skipped,a=r&&new Map(r.boards.flatMap(e=>e.rules.map(e=>[e.routeId,e.filed]))),o=new Map((i??[]).map(e=>[e.routeId,e])),s=n&&new Map(t.map(e=>[e,A(ue(n,e),{filed:a,skips:o}).filter(e=>_(e.event))]));return{lines:s,filedByEvent:a&&Ye(s?.values()??[])}}function Ye(e){let t=new Map;for(let n of e)for(let e of n)t.set(e.event,(t.get(e.event)??0)+(e.filed??0));return t}function Xe({factoryId:e,boardId:n,repositories:r}){let i=F(),[s]=L(),l=ee(s),u=r=>i(t(e,n,{focus:r})),d=Ke(e),f=v(e),p=j(e).data,m=W(e).data??[],{lines:h,filedByEvent:g}=Je(e,d.shown),_=d.query.data,y=f.data?.canEdit??!1,b=new Map(_?.boards.map(e=>[e.boardKey,e.name])),x=Ze(p,n),S=l&&`newRule`in l?l.newRule:void 0,w=S&&(S.board??n),T=l&&`test`in l?l.test:void 0;return(0,J.jsx)(E,{label:`Routing`,tabs:(0,J.jsx)(pe,{factoryId:e,boardId:n,active:`routing`}),panel:l?{content:(0,J.jsx)(Ue,{factoryId:e,boardId:n,focus:l,onFocus:u}),onClose:()=>u()}:void 0,bar:(0,J.jsxs)(J.Fragment,{children:[_?.canEdit&&d.changed&&(0,J.jsx)(ie,{label:`Order not saved`,saveLabel:`Save order`,saving:d.saving,onSave:d.save,onDiscard:d.discard}),(0,J.jsx)(se,{children:(0,J.jsx)(re,{defaultValue:T,onTest:e=>u({test:e})},T)})]}),children:(0,J.jsxs)(`div`,{className:`relative mx-auto flex w-max items-start gap-16 max-sm:w-full max-sm:flex-col max-sm:gap-10`,children:[(0,J.jsx)(Ge,{factoryId:e,repositories:r,filed:g,routeList:_?.evaluator===`route-list`}),(0,J.jsxs)(`section`,{id:c,"aria-label":`Intake order`,className:`flex w-115 shrink-0 scroll-mt-4 flex-col gap-3 max-sm:w-full`,children:[(0,J.jsx)(C,{as:`h2`,variant:`column`,tone:`muted`,className:`flex h-5 items-center`,children:`Intake order`}),d.query.isError&&(0,J.jsx)(B,{variant:`destructive`,children:`The intake order didn’t load.`}),f.isError&&(0,J.jsx)(B,{variant:`warning`,children:`Rules didn’t load.`}),(0,J.jsx)(He,{factoryId:e,canEdit:y,boardNames:b}),_&&(0,J.jsx)(Ce,{order:_,changed:d.changed}),_&&!d.saved.includes(n)&&(0,J.jsx)(B,{variant:`info`,children:`Not in the intake order: new issues and pull requests never reach this board.`}),(0,J.jsxs)(`div`,{"data-link-order":!0,className:`flex flex-col`,children:[(0,J.jsx)(Se,{boards:d.shown,movable:d.movable,onMove:d.move,renderBoard:(r,{index:i,dragging:s})=>{let c=r===n,l=b.get(r)??r,f=m.find(e=>e.id===r);return(0,J.jsx)(Ae,{name:l,current:c,dragging:s,header:(0,J.jsx)(je,{name:l,current:c,place:i+1,grip:d.movable,dragging:s,routingHref:t(e,r),rulesHref:o(e,r),LinkComponent:G,children:d.sortable&&(0,J.jsx)(we,{earlier:d.movable&&i>0,later:d.movable&&i<d.shown.length-1,onMove:e=>d.move(i,i+e)})}),children:(0,J.jsxs)($,{name:l,lines:h?.get(r),board:f,last:i===d.shown.length-1,onOpenRule:e=>u({rule:e}),children:[S&&w===r&&(0,J.jsx)(Te,{phase:S.into&&a(f,S.into)}),c&&x&&(0,J.jsx)(xe,{stats:x}),c&&y&&w!==r&&(0,J.jsx)(be,{onAdd:()=>u({newRule:{board:r}})})]})})}}),d.shown.length>0&&(0,J.jsx)(D,{}),(0,J.jsx)(ze,{factoryId:e,onWhy:e=>u({test:e})})]})]}),(0,J.jsx)(Le,{})]})})}function Ze(e,t){let n=e?.boards.find(e=>e.boardKey===t);if(e&&n)return{sampled:e.sampled,takes:n.takes.length,lost:n.lostTo.reduce((e,t)=>e+t.keys.length,0)}}function Qe(){let e=r(),t=he()?.boardId??``;return(0,J.jsx)(m,{variant:`page`,body:`fixed`,children:(0,J.jsx)(Xe,{factoryId:e.id,boardId:t,repositories:e.repositories},e.id)})}export{Qe as BoardIntakePage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Wi as t,Xi as n,Xn as r,Yn as i}from"./useFactories-BSnLX5pf.js";import{D as a,O as o,o as s,w as c}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{o as l}from"./TabsRoot-DcVywXPZ.js";import{t as u}from"./popup-anchor.es-BZFuBiYF.js";var d=e(o(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:c(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:o,href:l,isCurrent:m,action:g,switcher:_,icon:v,isLoading:y,children:b,...x})=>{let S=a||`span`,C=!(!_||!m&&(o||l)),w=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:w,className:c(`group flex h-control-sm min-w-0 items-center`,m?`shrink`:`shrink-0`,C&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(S,{"aria-current":m?`page`:void 0,className:c(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,t.sm,s,m?`max-w-xs cursor-default text-foreground`:C?c(r,`max-w-48`):c(i,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:o,href:l,...x,children:[v&&(0,f.jsx)(n,{className:c(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:v}),y?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:b})]}),_&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:c(`-ml-1 flex h-control-sm shrink-0 items-center`,C&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:w,children:_})}),g&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:g})]}),!m&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(n,{className:`text-subtle-foreground`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Wi as t,Xi as n,Xn as r,Yn as i}from"./useFactories-BbPGoUnu.js";import{D as a,O as o,o as s,w as c}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{o as l}from"./TabsRoot-D-RAt6qK.js";import{t as u}from"./popup-anchor.es-BZFuBiYF.js";var d=e(o(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:c(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:o,href:l,isCurrent:m,action:g,switcher:_,icon:v,isLoading:y,children:b,...x})=>{let S=a||`span`,C=!(!_||!m&&(o||l)),w=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:w,className:c(`group flex h-control-sm min-w-0 items-center`,m?`shrink`:`shrink-0`,C&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(S,{"aria-current":m?`page`:void 0,className:c(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,t.sm,s,m?`max-w-xs cursor-default text-foreground`:C?c(r,`max-w-48`):c(i,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:o,href:l,...x,children:[v&&(0,f.jsx)(n,{className:c(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:v}),y?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:b})]}),_&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:c(`-ml-1 flex h-control-sm shrink-0 items-center`,C&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:w,children:_})}),g&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:g})]}),!m&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(n,{className:`text-subtle-foreground`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./Sidebar-zeEMJHoc-Cp0LKo-n.js";import{D as n,w as r}from"./IconChevronRightMedium.es-ETbnXMk8.js";var i=n();function a({className:n}){let{isMobile:a,desktopState:o}=e();return!a&&o===`collapsed`?(0,i.jsx)(t.Trigger,{className:r(`shrink-0`,n)}):null}export{a as t};
1
+ import{a as e,n as t}from"./Sidebar-zeEMJHoc-DKyBJBJH.js";import{D as n,w as r}from"./IconChevronRightMedium.es-ETbnXMk8.js";var i=n();function a({className:n}){let{isMobile:a,desktopState:o}=e();return!a&&o===`collapsed`?(0,i.jsx)(t.Trigger,{className:r(`shrink-0`,n)}):null}export{a as t};
@@ -1 +1 @@
1
- import{D as e,E as t,d as n,n as r,w as i}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{ec as a}from"./useFactories-BSnLX5pf.js";import{C as o}from"./useThreadWorkspacePath-DMOuMkkk.js";import{ii as s,ni as c,oi as l}from"./index-DjubxEY0.js";var u=e(),d=n(`IconScript`,()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`path`,{d:`M7 20H5.5C4.39543 20 3.5 19.1046 3.5 18V17C3.5 16.4477 3.94772 16 4.5 16H12.5C13.0523 16 13.5 16.4477 13.5 17V18.25C13.5 19.2165 14.2835 20 15.25 20C16.2165 20 17 19.2165 17 18.25V5.75C17 4.7835 17.7835 4 18.75 4C19.7165 4 20.5 4.7835 20.5 5.75V8C20.5 8.55228 20.0523 9 19.5 9H17.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M19 4H8C6.89543 4 6 4.89543 6 6V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M15 20H6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M9.5 8.5H10L11 8L12 8.5H13.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M9.5 12H10L11 11.5L12 12H13.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),f=i(a,`pointer-events-auto flex w-fit min-w-0 items-center gap-0.5 rounded-full p-0.5 empty:hidden`),p=`flex flex-col gap-3 p-1.5 pb-3`;function m(e,t){let n=t-e;if(!Number.isFinite(n)||n<6e4)return`<1m`;let r=Math.floor(n/6e4);if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return r%60==0?`${i}h`:`${i}h ${r%60}m`;let a=Math.floor(i/24);return i%24==0?`${a}d`:`${a}d ${i%24}h`}var h=`flex min-h-0 w-full min-w-0 grow flex-col divide-y divide-border overflow-y-auto`,g=8,_=Number.parseFloat(t[`header-default`])+g,v={"--chat-header-top":`${g}px`,"--chat-header-room":`${_}px`};function y({title:e,titleMenu:t,headerCenter:n,headerActions:a,dockActions:d,children:p}){let m=c({breadcrumbs:e?(0,u.jsxs)(`div`,{className:`h-control-sm flex min-w-0 items-center gap-0.5`,children:[(0,u.jsx)(r,{as:`h1`,variant:`label`,tone:`ink`,className:`min-w-0 truncate px-3`,children:e}),t]}):void 0,triggerClassName:`size-control-sm rounded-full [&>svg]:size-icon-md`}),h=!!(m.breadcrumbs||a),g=a&&d?d(a):void 0;return(0,u.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,style:h?v:void 0,children:[h?(0,u.jsx)(`div`,{className:`[container-type:size] pointer-events-none absolute inset-0 z-20`,children:(0,u.jsxs)(`div`,{"data-slot":`chat-page-header`,className:i(`grid items-center gap-x-2 ps-3 pt-(--chat-header-top)`,o.header,n?`grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]`:`grid-cols-[minmax(0,1fr)_auto]`),children:[(0,u.jsxs)(l,{border:!1,className:i(`grid grid-cols-subgrid px-0`,g?`col-[1/-2]`:`col-span-full`),children:[(0,u.jsx)(`div`,{className:`flex min-w-0 items-center`,children:m.breadcrumbs&&(0,u.jsx)(`div`,{className:f,children:m.breadcrumbs})}),n?(0,u.jsx)(`div`,{className:`flex items-center`,children:n}):null,g?null:(0,u.jsx)(`div`,{className:`flex min-w-0 justify-end`,children:a&&(0,u.jsx)(`div`,{className:i(f,`shrink-0`),children:a})})]}),g]})}):null,(0,u.jsx)(s,{variant:`page`,body:`fixed`,children:p})]})}export{p as a,h as i,m as n,d as o,f as r,y as t};
1
+ import{D as e,E as t,d as n,n as r,w as i}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{ec as a}from"./useFactories-BbPGoUnu.js";import{C as o}from"./useThreadWorkspacePath-DB43LqLV.js";import{ii as s,ni as c,oi as l}from"./index-DJ3zJOT1.js";var u=e(),d=n(`IconScript`,()=>(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`path`,{d:`M7 20H5.5C4.39543 20 3.5 19.1046 3.5 18V17C3.5 16.4477 3.94772 16 4.5 16H12.5C13.0523 16 13.5 16.4477 13.5 17V18.25C13.5 19.2165 14.2835 20 15.25 20C16.2165 20 17 19.2165 17 18.25V5.75C17 4.7835 17.7835 4 18.75 4C19.7165 4 20.5 4.7835 20.5 5.75V8C20.5 8.55228 20.0523 9 19.5 9H17.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M19 4H8C6.89543 4 6 4.89543 6 6V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M15 20H6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M9.5 8.5H10L11 8L12 8.5H13.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,u.jsx)(`path`,{d:`M9.5 12H10L11 11.5L12 12H13.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),f=i(a,`pointer-events-auto flex w-fit min-w-0 items-center gap-0.5 rounded-full p-0.5 empty:hidden`),p=`flex flex-col gap-3 p-1.5 pb-3`;function m(e,t){let n=t-e;if(!Number.isFinite(n)||n<6e4)return`<1m`;let r=Math.floor(n/6e4);if(r<60)return`${r}m`;let i=Math.floor(r/60);if(i<24)return r%60==0?`${i}h`:`${i}h ${r%60}m`;let a=Math.floor(i/24);return i%24==0?`${a}d`:`${a}d ${i%24}h`}var h=`flex min-h-0 w-full min-w-0 grow flex-col divide-y divide-border overflow-y-auto`,g=8,_=Number.parseFloat(t[`header-default`])+g,v={"--chat-header-top":`${g}px`,"--chat-header-room":`${_}px`};function y({title:e,titleMenu:t,headerCenter:n,headerActions:a,dockActions:d,children:p}){let m=c({breadcrumbs:e?(0,u.jsxs)(`div`,{className:`h-control-sm flex min-w-0 items-center gap-0.5`,children:[(0,u.jsx)(r,{as:`h1`,variant:`label`,tone:`ink`,className:`min-w-0 truncate px-3`,children:e}),t]}):void 0,triggerClassName:`size-control-sm rounded-full [&>svg]:size-icon-md`}),h=!!(m.breadcrumbs||a),g=a&&d?d(a):void 0;return(0,u.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,style:h?v:void 0,children:[h?(0,u.jsx)(`div`,{className:`[container-type:size] pointer-events-none absolute inset-0 z-20`,children:(0,u.jsxs)(`div`,{"data-slot":`chat-page-header`,className:i(`grid items-center gap-x-2 ps-3 pt-(--chat-header-top)`,o.header,n?`grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]`:`grid-cols-[minmax(0,1fr)_auto]`),children:[(0,u.jsxs)(l,{border:!1,className:i(`grid grid-cols-subgrid px-0`,g?`col-[1/-2]`:`col-span-full`),children:[(0,u.jsx)(`div`,{className:`flex min-w-0 items-center`,children:m.breadcrumbs&&(0,u.jsx)(`div`,{className:f,children:m.breadcrumbs})}),n?(0,u.jsx)(`div`,{className:`flex items-center`,children:n}):null,g?null:(0,u.jsx)(`div`,{className:`flex min-w-0 justify-end`,children:a&&(0,u.jsx)(`div`,{className:i(f,`shrink-0`),children:a})})]}),g]})}):null,(0,u.jsx)(s,{variant:`page`,body:`fixed`,children:p})]})}export{p as a,h as i,m as n,d as o,f as r,y as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,O as n,b as r,p as i,v as a,y as o}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{sn as s,un as c}from"./useSessionRows-DqWZeKoh.js";import{An as l,Fn as u,Ln as d,Mn as f,Nn as p,Rn as m,co as h,do as g,ho as _,jn as v,ki as y,kn as b,mo as x,qs as S,sa as C,uo as w,wo as T,ws as E}from"./useFactories-BSnLX5pf.js";var D=e(n(),1),O=`data-composite-item-active`;function k(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:c,highlightedIndex:u,onHighlightedIndexChange:y,rootRef:C,enableHomeAndEndKeys:O=!1,stopEventPropagation:k,disabledIndices:M,modifierKeys:N=o}=e,[P,F]=D.useState(0),I=r!=null,L=D.useRef(null),R=a(L,C),z=D.useRef([]),B=D.useRef(!1),V=D.useRef(null),H=u??P,U=T((e,t=!1)=>{if(V.current=z.current[e]??null,(y??F)(e),t){let t=z.current[e];m(L.current,t,c,n)}}),W=T(e=>{if(e.size===0)return;if(B.current){let e=z.current,t=e.indexOf(V.current);if(t===-1){let t=e[H];!t||_(e,H,M)?U(A(e,M)):V.current=t}else t!==H&&U(t);return}B.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)U(i);else if(_(t,H,M)){let e=h(t,{disabledIndices:M});x(t,e)||U(e)}m(L.current,r,c,n)});S(()=>{if(M==null||u!=null||!B.current)return;let e=z.current;if(_(e,H,M)){let t=h(e,{disabledIndices:M});x(e,t)||U(t)}},[M,u,H,z,U]);let G=T((e,t,n)=>i?i(e,t,n,z):n),K=T(e=>{let a=e.key===`Home`||e.key===`End`;if(!p.has(e.key)||!O&&a||j(e,N)||!L.current)return;let o=c===`rtl`,u=o?l:v,m=o?v:l,_=n===`vertical`?b:u,y=n===`vertical`?f:m,S=E(e.nativeEvent);if(S!=null&&d(S)&&!s(S)){let t=S.selectionStart,n=S.selectionEnd,r=S.value;if(t==null||e.shiftKey||t!==n||e.key!==y&&t<r.length||e.key!==_&&t>0)return}let C=H,T=g(z,M),D=w(z,M);r!=null&&(C=r({disabledIndices:M,elementsRef:z,event:e,highlightedIndex:H,loopFocus:t,maxIndex:D,minIndex:T,onLoop:G,orientation:n,rtl:o}));let A=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowDown`,P=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;O&&(e.key===`Home`?C=T:e.key===`End`&&(C=D)),C===H&&(A||P)&&(t&&C===D&&A?(C=T,i&&(C=i(e,H,C,z))):t&&C===T&&P?(C=D,i&&(C=i(e,H,C,z))):C=h(z.current,{startingIndex:C,decrement:P,disabledIndices:M})),C!==H&&!x(z.current,C)&&(k&&e.stopPropagation(),(I||a||A||P)&&e.preventDefault(),U(C,!0),queueMicrotask(()=>{z.current[C]?.focus()}))});return{props:{ref:R,onFocus(e){let t=L.current,n=E(e.nativeEvent);t&&n!=null&&d(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:K},highlightedIndex:H,onHighlightedIndexChange:U,elementsRef:z,onMapChange:W,relayKeyboardEvent:K}}function A(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!_(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function j(e,t){for(let n of u)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}var M=t();function N(e){let{render:t,className:n,style:a,refs:s=o,props:l=o,state:u=r,stateAttributesMapping:d,highlightedIndex:f,onHighlightedIndexChange:p,orientation:m,grid:h,loopFocus:g,onLoop:_,enableHomeAndEndKeys:v,onMapChange:b,stopEventPropagation:x=!0,rootRef:S,disabledIndices:w,modifierKeys:T,highlightItemOnHover:E=!1,tag:O=`div`,...A}=e,{props:j,highlightedIndex:N,onHighlightedIndexChange:P,elementsRef:F,onMapChange:I,relayKeyboardEvent:L}=k({grid:h,loopFocus:g,onLoop:_,orientation:m,highlightedIndex:f,onHighlightedIndexChange:p,rootRef:S,stopEventPropagation:x,enableHomeAndEndKeys:v,direction:C(),disabledIndices:w,modifierKeys:T}),R=i(O,e,{state:u,ref:s,props:[j,...l,A],stateAttributesMapping:d}),z=D.useMemo(()=>({highlightedIndex:N,onHighlightedIndexChange:P,highlightItemOnHover:E,relayKeyboardEvent:L}),[N,P,E,L]);return(0,M.jsx)(y.Provider,{value:z,children:(0,M.jsx)(c,{elementsRef:F,onMapChange:e=>{b?.(e),I(e)},children:R})})}export{O as n,N as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{D as t,O as n,b as r,p as i,v as a,y as o}from"./IconChevronRightMedium.es-ETbnXMk8.js";import{sn as s,un as c}from"./useSessionRows-BFZXJZw8.js";import{An as l,Fn as u,Ln as d,Mn as f,Nn as p,Rn as m,co as h,do as g,ho as _,jn as v,ki as y,kn as b,mo as x,qs as S,sa as C,uo as w,wo as T,ws as E}from"./useFactories-BbPGoUnu.js";var D=e(n(),1),O=`data-composite-item-active`;function k(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:c,highlightedIndex:u,onHighlightedIndexChange:y,rootRef:C,enableHomeAndEndKeys:O=!1,stopEventPropagation:k,disabledIndices:M,modifierKeys:N=o}=e,[P,F]=D.useState(0),I=r!=null,L=D.useRef(null),R=a(L,C),z=D.useRef([]),B=D.useRef(!1),V=D.useRef(null),H=u??P,U=T((e,t=!1)=>{if(V.current=z.current[e]??null,(y??F)(e),t){let t=z.current[e];m(L.current,t,c,n)}}),W=T(e=>{if(e.size===0)return;if(B.current){let e=z.current,t=e.indexOf(V.current);if(t===-1){let t=e[H];!t||_(e,H,M)?U(A(e,M)):V.current=t}else t!==H&&U(t);return}B.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)U(i);else if(_(t,H,M)){let e=h(t,{disabledIndices:M});x(t,e)||U(e)}m(L.current,r,c,n)});S(()=>{if(M==null||u!=null||!B.current)return;let e=z.current;if(_(e,H,M)){let t=h(e,{disabledIndices:M});x(e,t)||U(t)}},[M,u,H,z,U]);let G=T((e,t,n)=>i?i(e,t,n,z):n),K=T(e=>{let a=e.key===`Home`||e.key===`End`;if(!p.has(e.key)||!O&&a||j(e,N)||!L.current)return;let o=c===`rtl`,u=o?l:v,m=o?v:l,_=n===`vertical`?b:u,y=n===`vertical`?f:m,S=E(e.nativeEvent);if(S!=null&&d(S)&&!s(S)){let t=S.selectionStart,n=S.selectionEnd,r=S.value;if(t==null||e.shiftKey||t!==n||e.key!==y&&t<r.length||e.key!==_&&t>0)return}let C=H,T=g(z,M),D=w(z,M);r!=null&&(C=r({disabledIndices:M,elementsRef:z,event:e,highlightedIndex:H,loopFocus:t,maxIndex:D,minIndex:T,onLoop:G,orientation:n,rtl:o}));let A=n!==`vertical`&&e.key===u||n!==`horizontal`&&e.key===`ArrowDown`,P=n!==`vertical`&&e.key===m||n!==`horizontal`&&e.key===`ArrowUp`;O&&(e.key===`Home`?C=T:e.key===`End`&&(C=D)),C===H&&(A||P)&&(t&&C===D&&A?(C=T,i&&(C=i(e,H,C,z))):t&&C===T&&P?(C=D,i&&(C=i(e,H,C,z))):C=h(z.current,{startingIndex:C,decrement:P,disabledIndices:M})),C!==H&&!x(z.current,C)&&(k&&e.stopPropagation(),(I||a||A||P)&&e.preventDefault(),U(C,!0),queueMicrotask(()=>{z.current[C]?.focus()}))});return{props:{ref:R,onFocus(e){let t=L.current,n=E(e.nativeEvent);t&&n!=null&&d(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:K},highlightedIndex:H,onHighlightedIndexChange:U,elementsRef:z,onMapChange:W,relayKeyboardEvent:K}}function A(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!_(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function j(e,t){for(let n of u)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}var M=t();function N(e){let{render:t,className:n,style:a,refs:s=o,props:l=o,state:u=r,stateAttributesMapping:d,highlightedIndex:f,onHighlightedIndexChange:p,orientation:m,grid:h,loopFocus:g,onLoop:_,enableHomeAndEndKeys:v,onMapChange:b,stopEventPropagation:x=!0,rootRef:S,disabledIndices:w,modifierKeys:T,highlightItemOnHover:E=!1,tag:O=`div`,...A}=e,{props:j,highlightedIndex:N,onHighlightedIndexChange:P,elementsRef:F,onMapChange:I,relayKeyboardEvent:L}=k({grid:h,loopFocus:g,onLoop:_,orientation:m,highlightedIndex:f,onHighlightedIndexChange:p,rootRef:S,stopEventPropagation:x,enableHomeAndEndKeys:v,direction:C(),disabledIndices:w,modifierKeys:T}),R=i(O,e,{state:u,ref:s,props:[j,...l,A],stateAttributesMapping:d}),z=D.useMemo(()=>({highlightedIndex:N,onHighlightedIndexChange:P,highlightItemOnHover:E,relayKeyboardEvent:L}),[N,P,E,L]);return(0,M.jsx)(y.Provider,{value:z,children:(0,M.jsx)(c,{elementsRef:F,onMapChange:e=>{b?.(e),I(e)},children:R})})}export{O as n,N as t};