mastra 1.40.1-alpha.4 → 1.40.1

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 (35) hide show
  1. package/dist/docs/SKILL.md +2 -2
  2. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  3. package/dist/docs/references/docs-mastra-platform-api.md +2 -2
  4. package/dist/docs/references/reference-cli-mastra.md +2 -2
  5. package/dist/factory/assets/{BoardConfigPage-BEpNhTIY.js → BoardConfigPage-CQkAggYI.js} +1 -1
  6. package/dist/factory/assets/{BoardIntakePage-Uax6EALn.js → BoardIntakePage-yKGvstab.js} +1 -1
  7. package/dist/factory/assets/{BoardRulesPage-k7cjibZb.js → BoardRulesPage-BZNsaZF-.js} +1 -1
  8. package/dist/factory/assets/{ConditionRows-B6jx-I10.js → ConditionRows-01YU1Df-.js} +1 -1
  9. package/dist/factory/assets/{CreateFactoryPage-B2uyQCJb.js → CreateFactoryPage-Yc84nIhr.js} +1 -1
  10. package/dist/factory/assets/{FactorySkillPage-CF0l5PDU.js → FactorySkillPage-DFAnebSw.js} +1 -1
  11. package/dist/factory/assets/{FactorySkillsPage-BPxxSx7l.js → FactorySkillsPage-BSgAyCo_.js} +1 -1
  12. package/dist/factory/assets/{IconScript.es-DZhMCOw-.js → IconScript.es-C8Zj6DYo.js} +1 -1
  13. package/dist/factory/assets/{KnowledgePage-DpmTcrtO.js → KnowledgePage-DSXVPqWU.js} +1 -1
  14. package/dist/factory/assets/{MastraGatewayBilling-D78W-cOf.js → MastraGatewayBilling-B0GlYOnL.js} +1 -1
  15. package/dist/factory/assets/{NewBoardPage-CRVJp46m.js → NewBoardPage-DXLpjWTW.js} +1 -1
  16. package/dist/factory/assets/{NewPage-CnII4QED.js → NewPage-BGJLL_Zj.js} +1 -1
  17. package/dist/factory/assets/{OnboardingPage-BrIZDcx1.js → OnboardingPage-BlnVaasd.js} +1 -1
  18. package/dist/factory/assets/{ProviderBrandIcon-CKDJg6-Q.js → ProviderBrandIcon-Yslh2eXt.js} +1 -1
  19. package/dist/factory/assets/{RulesPage-Yw7ldvpL.js → RulesPage-BfFyAIEN.js} +1 -1
  20. package/dist/factory/assets/{SessionLayout-B3K-kNBW.js → SessionLayout-Bp1NF2zA.js} +2 -2
  21. package/dist/factory/assets/{SessionPage-B10K5AZ4.js → SessionPage-BEE91ZTo.js} +1 -1
  22. package/dist/factory/assets/{SettingsPage-ELRGDyM0.js → SettingsPage-BqYQrTTV.js} +1 -1
  23. package/dist/factory/assets/{SlackConnectionPage-JlsuAG4M.js → SlackConnectionPage-LZhBHwHW.js} +1 -1
  24. package/dist/factory/assets/{StackedDiffs-DQ44HStp.js → StackedDiffs-DuGbI0pl.js} +1 -1
  25. package/dist/factory/assets/{Tree-B90XgTY4-DU0TaZ8p.js → Tree-B90XgTY4-DK0G-xH9.js} +1 -1
  26. package/dist/factory/assets/{index-Du9_RN46.js → index-BP3ua7KI.js} +37 -37
  27. package/dist/factory/assets/{useDraftModelGuards-DGlzX4bp.js → useDraftModelGuards-uP97IT-S.js} +1 -1
  28. package/dist/factory/assets/{workspaces-48hVDR9p.js → workspaces-BpolXhLl.js} +1 -1
  29. package/dist/factory/index.html +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/studio/assets/{index-DAAXPRoL.js → index-BNhf8gAj.js} +2 -2
  32. package/dist/studio/assets/{main-BwwH19vb.js → main-Dzrywu-v.js} +238 -238
  33. package/dist/studio/index.html +1 -1
  34. package/package.json +7 -7
  35. /package/dist/docs/references/{docs-mastra-platform-observability.md → docs-mastra-platform-observability-overview.md} +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.1-alpha.4"
6
+ version: "1.40.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -17,7 +17,7 @@ Read the individual reference documents for detailed explanations and code examp
17
17
  ### Docs
18
18
 
19
19
  - [API Reference: Mastra platform](references/docs-mastra-platform-api.md) - Use the Mastra platform REST API to manage members, tokens, Studio and Server deployments, gateways, observability feedback and metrics, and project-scoped resources.
20
- - [Observability](references/docs-mastra-platform-observability.md) - Collect, import, and query hosted traces, logs, metrics, scores, and feedback from Mastra applications with Mastra Platform Observability and local fallback storage.
20
+ - [Observability](references/docs-mastra-platform-observability-overview.md) - Collect, import, and query hosted traces, logs, metrics, scores, and feedback from Mastra applications with Mastra Platform Observability and local fallback storage.
21
21
 
22
22
  ### Reference
23
23
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.1-alpha.4",
2
+ "version": "1.40.1",
3
3
  "package": "mastra",
4
4
  "exports": {
5
5
  "PosthogAnalytics": {
@@ -120,7 +120,7 @@ Use the root URL for your environment's data-residency region:
120
120
  | United States | `https://observability.mastra.ai/api/observability` |
121
121
  | European Union | `https://observability.eu.mastra.ai/api/observability` |
122
122
 
123
- Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/regions) for the environment-to-region mapping.
123
+ Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/deploy/regions) for the environment-to-region mapping.
124
124
 
125
125
  ### Authentication and project scope
126
126
 
@@ -192,7 +192,7 @@ Use the root URL for your environment's data-residency region:
192
192
  | United States | `https://observability.mastra.ai/api/observability` |
193
193
  | European Union | `https://observability.eu.mastra.ai/api/observability` |
194
194
 
195
- Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/regions) for the environment-to-region mapping.
195
+ Telemetry stays in its residency region. Querying the other region returns no records for the environment. See [Observability co-location](https://mastra.ai/docs/mastra-platform/deploy/regions) for the environment-to-region mapping.
196
196
 
197
197
  ### Authentication and project scope
198
198
 
@@ -488,7 +488,7 @@ mastra env restart <env>
488
488
 
489
489
  ### `mastra env vars pull`
490
490
 
491
- Pulls an environment's env vars into a local env file (default: `.env`). The file contains the set a deploy of that environment runs with: the vars stored on the environment itself (for example, added in the dashboard's environment editor). Each environment is pulled on its own, and values stored on another environment are never merged in. Projects still on the [legacy pipeline](https://mastra.ai/docs/mastra-platform/deploy) run from project-level vars instead, so pulling any of their environments returns those shared project-level values. Managed vars injected by attached databases are listed as comments (names only) since their values are platform-managed secrets.
491
+ Pulls an environment's env vars into a local env file (default: `.env`). The file contains the set a deploy of that environment runs with: the vars stored on the environment itself (for example, added in the dashboard's environment editor). Each environment is pulled on its own, and values stored on another environment are never merged in. Projects still on the [legacy pipeline](https://mastra.ai/docs/mastra-platform/deploy/overview) run from project-level vars instead, so pulling any of their environments returns those shared project-level values. Managed vars injected by attached databases are listed as comments (names only) since their values are platform-managed secrets.
492
492
 
493
493
  ```bash
494
494
  mastra env vars pull
@@ -1159,7 +1159,7 @@ The following provider is currently supported:
1159
1159
  | -------- | ---------- | -------------------------------------------------- |
1160
1160
  | Langfuse | `langfuse` | Langfuse Cloud or self-hosted Langfuse v4 or later |
1161
1161
 
1162
- See [Import existing traces](https://mastra.ai/docs/mastra-platform/observability) for the complete workflow, data mapping, local-file lifecycle, and limits.
1162
+ See [Import existing traces](https://mastra.ai/docs/mastra-platform/observability/overview) for the complete workflow, data mapping, local-file lifecycle, and limits.
1163
1163
 
1164
1164
  ### Options
1165
1165
 
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Ar as o,Bn as s,D as c,E as l,Hn as u,Jn as d,Qn as f,Sr as p,Vn as m,Xn as h,Yn as g,Zn as _,_r as v,br as y,cr as b,dn as ee,dr as te,en as x,er as S,ir as ne,jr as C,lr as w,mr as T,nn as E,nr as D,pr as re,qn as O,sr as k,tn as A,tr as ie,ur as j,vr as M,xr as ae}from"./index-Du9_RN46.js";import{A as oe,a as N,k as P}from"./Sidebar.es-CxsNkx78.js";import{d as se,f as F,r as ce,t as I,u as le}from"./settings-9ei5ML-D-BlNZeAdp.js";import{O as ue,T as L,k as de,n as R,s as z,t as fe}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as B}from"./lib-BeLi6vwy.js";import{c as pe,o as me,r as he,s as ge,t as _e}from"./useBoardEditor-ouq-2Nxa.js";import{i as ve,t as ye}from"./SkillBadges-mOvfA9IK.js";import{a as V,c as be,f as xe,l as Se,s as Ce}from"./boardConfigPaths-Btimpi_r.js";import{t as H}from"./AlertDialog.es-Clga3VZL.js";import{Ai as we,Pi as U,Qn as Te,Rt as Ee,cr as De,fa as Oe,ha as ke,n as Ae,pa as je,t as W}from"./Notice-BhWgws6f-kmCorboO.js";import{t as G}from"./SettingsSubsection-Bu3ZS9dr.js";import{n as Me,r as K,t as Ne}from"./settingsColumn-CrKuH8q1.js";import{n as Pe}from"./useBoardCatalog-CJ6zJlxZ.js";import{h as Fe,o as Ie}from"./useIntakeRoutes-CnY3Cu0c.js";import{a as Le,d as Re,t as ze}from"./BoardIcons-BKwzXIEg.js";import{n as Be,r as Ve,t as He}from"./HoverCard.es-CoejtwWy.js";import{r as Ue}from"./overlays-B3sO28Cg.js";import{t as We}from"./DescriptionMarkdown--4m-3qtV.js";import{h as Ge,w as Ke,y as qe}from"./ruleLanes-B980Mi2c.js";import{t as Je}from"./CodeEditor-AaW7HgY9-DMAOTJ4H.js";import{a as Ye,n as Xe,r as Ze,t as Qe}from"./Field.es-0a08x-Zj.js";import{t as $e}from"./input-DqReKX0A-De875Vkf.js";import{a as et,n as tt}from"./input-group-CXvse9n7-CJxvIZYL.js";import{a as nt,i as rt,n as it,r as at,t as ot}from"./InputNumber.es-CFkXhJOw.js";import{Y as st,a as ct,i as lt,o as ut,r as dt}from"./request-jghBar6W.js";import{E as ft}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";import{n as pt,t as mt}from"./ConditionRows-B6jx-I10.js";import{t as ht}from"./IconLock.es-9mYeLe9c.js";import{t as gt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as _t}from"./TrashIcon.es-DNb97Rim.js";import{t as q}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as vt,t as yt}from"./boardCatalog-y-s19dQU.js";import{t as bt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as xt}from"./InlineText-vWKzGKx_.js";import{t as St}from"./LoadErrorState-DJCV4DnP.js";var J=e(de(),1),Y=ue();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:L(Me,i),children:(0,Y.jsx)(`div`,{className:L(K,n),children:r})}):(0,Y.jsx)(`div`,{className:L(K,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?be(e,t,a):V(e,t,n.key),d=a?l:Ue;return(0,Y.jsxs)(He,{children:[(0,Y.jsxs)(Ve,{delay:0,closeDelay:100,render:(0,Y.jsx)(B,{to:u}),className:L(z,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Be,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(R,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(ye,{skill:o})]}),s?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(g,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(We,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(We,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(R,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(R,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(R,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(He,{children:[(0,Y.jsx)(Ve,{delay:0,closeDelay:100,render:(0,Y.jsx)(B,{to:n}),className:L(z,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ge(e.length)}),(0,Y.jsxs)(Be,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(R,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(u,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=Pe(e),s=Ie(e),c=o.isPending||s.isPending,l=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,u=n.map(e=>d(e,n)),f=s.data&&l?h(s.data.intakeRoutes,{key:t,initialPhase:l}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(W,{variant:`warning`,children:(0,Y.jsx)(W.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),f&&f.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(R,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:f.leaving,title:`Rules that send cards to other boards`,to:Ce(e,t,`leaving`),boardId:t,boards:o.data}),` `,f.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:L(`mx-auto flex w-max`,Et),children:n.map(i=>{let s=Le(t,i.kind),p=f?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(B,{to:V(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(ze,{stage:i.key,kind:s,decorative:!0}),(0,Y.jsx)(R,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(O,{boardId:t,phase:d(i,n),phases:u,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(oe,{className:`h-4 w-20`}):f?p.length>0?(0,Y.jsx)(Tt,{rules:p,title:`Rules that move cards into ${i.name}`,to:Ce(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Y.jsx)(g,{children:`No rule moves cards here`}):(0,Y.jsx)(g,{children:`Rules didn’t load`}),i.key===l&&(0,Y.jsx)(g,{children:`New cards start here`})]}),starts:(0,Y.jsx)(m,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=qe,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?y(s,n):v(s,p),_=e=>{m(e);let t=M(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Qe,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ye,{htmlFor:h,children:e}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,y(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(Xe,{children:t}),p===void 0?r?(0,Y.jsx)(R,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:Ke(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(mt,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,y(s,e))}})}):(0,Y.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Ze,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=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,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(ze,{stage:t.key,kind:Le(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:L(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:L(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,z),children:[(0,Y.jsx)(`span`,{className:L(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(ht,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(gt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(ke,{render:d}),(0,Y.jsx)(je,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(R,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(R,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ce,{children:[(0,Y.jsxs)(Qe,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(se,{children:e}),(0,Y.jsx)(Xe,{children:t}),i,n&&(0,Y.jsx)(Ze,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(I,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Je,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:a,factoryId:o,boardId:c,disabled:u,rawRules:d,onChange:p,onRawRule:m,onUnfinished:h,onRemove:g}){let v=pt(o),y=e.kind===`working`,te=b(e,t),x=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],E=e.exitTool?.id??``,D=e.runner?.skill,O=D?r?.find(e=>e.name===D):void 0,k=D!==void 0&&r!==void 0&&O===void 0,A=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));p({...e,runner:Object.keys(r).length>0?r:null})},ie=e=>({text:d[e],onChange:t=>m(e,t)}),j=(0,Y.jsx)(jt,{phase:e,phases:t,next:te,required:new Set(n),boardId:c,disabled:u,onChange:t=>p({...e,nextPhases:t})}),M=g&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(U,{variant:`ghost`,icon:(0,Y.jsx)(_t,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Re,{}),title:`Starts`,children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{label:`Start on its own`,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:u,onCheckedChange:t=>{p(re(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Fe,options:{"source.repository":v},disabled:u,json:ie(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>p({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(Ue,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(x.length,f)}`,error:x.length>1e3?`Too long to save.`:void 0,disabled:u,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:x,placeholder:`Tell the agent what to do, in Markdown`,disabled:u,onChange:e=>A({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(w.length,i)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:u,after:C&&(0,Y.jsxs)(Qe,{invalid:!ne(C.maxRuns),disabled:u,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ye,{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,Y.jsx)(ot,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:u,onValueChange:e=>{let{maxRuns:t,...n}=C;A({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(at,{size:`sm`,children:[(0,Y.jsx)(nt,{placeholder:`Default`}),(0,Y.jsxs)(tt,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(et,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(it,{}),(0,Y.jsx)(rt,{})]})]})})]}),!ne(C.maxRuns)&&(0,Y.jsxs)(Ze,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:u,onChange:e=>A({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:u,children:(0,Y.jsx)($e,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:_,disabled:u,onChange:e=>A({context:e.target.value})})}),(0,Y.jsx)(G,{title:`Skill`,children:(0,Y.jsx)(I,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(dt,{value:D??Pt,disabled:u,onValueChange:e=>A({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(ut,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:D??`No skill`})]})}),(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ct,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ct,{value:e.name,children:e.name},e.name))]})]}),k&&(0,Y.jsx)(P,{variant:`destructive`,children:`Not found`}),O?.error&&(0,Y.jsx)(P,{variant:`destructive`,children:`Failed to load`}),O&&(0,Y.jsx)(ye,{skill:O}),O&&(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,icon:a?(0,Y.jsx)(s,{}):(0,Y.jsx)(Ae,{}),"aria-label":`${a?`Edit`:`View`} ${O.name}`,className:`ml-auto`,render:(0,Y.jsx)(B,{to:be(o,c,O.name)}),children:a?`Edit`:`View`})]}),O?.error?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,O.error]}):k?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,D,` skill, so cards entering `,e.name,` fail to start.`]}):O?.description&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:O.description})]})})}),(0,Y.jsx)(G,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(I,{children:S.map(t=>(0,Y.jsx)(F,{label:t.label,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:u,onCheckedChange:n=>{let r=S.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));p({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ae,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:u,children:(0,Y.jsx)($e,{className:Ft,"aria-label":`${e.name} exit tool`,value:E,disabled:u,onChange:t=>{let n=t.target.value.trim();p({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),E!==``&&(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{label:`Approve on its own`,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: approve ${E} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:u,onCheckedChange:t=>{p({...e,exitTool:{...e.exitTool,id:E,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Fe,options:{"source.repository":v},disabled:u,json:ie(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>p({...e,exitTool:{...e.exitTool,id:E,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(ee,{}),title:`Allowed moves`,children:j})]}),M]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(G,{title:`Allowed moves`,children:j}),M]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=A(e.id,t,d),[y,b]=(0,J.useState)(0),ee=()=>{v(),b(e=>e+1)},x=De(),S=pe(e.id,t),ne=we(),C=!f||!d.editable,T=n?p.phases.find(e=>e.key===n):void 0,E=T&&`${T.key}:${d.revision??`code`}:${y}`,[O,k]=(0,J.useState)({page:E,fields:[]});O.page!==E&&k({page:E,fields:[]});let M=O.page===E?O.fields:[],ae=(e,t)=>k(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),oe=!C&&(D(p,d)||Object.keys(m).length>0||M.length>0),N=p.phases.filter(e=>w(e,m)||e===T&&M.length>0),P=p.name.trim()===``,se=S.error?.code===`revision_mismatch`,F=Te(({nextLocation:n})=>{let r=ne.getQueryData(Ee.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!oe||r===!1)return!1;let i=xe(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),ce=V(e.id,t),le;return le=n&&!T?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(U,{size:`sm`,render:(0,Y.jsx)(B,{to:ce}),children:`Back to general`})}):T?(0,Y.jsx)(Rt,{phase:T,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[T.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:C||h,rawRules:{autoStartWhen:m[j(T.key,`autoStartWhen`)],autoApproveWhen:m[j(T.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(j(T.key,e),t),ae(e,!1)},onUnfinished:ae,onRemove:C||h||!ie(p.phases,T.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(j(T.key,e),void 0);g(e=>({...e,phases:te(e.phases,T.key)})),x(ce)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},E):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:C||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?re(n,t):n)})),t||_(j(e,`autoStartWhen`),void 0)},action:s&&!C?(0,Y.jsx)(c,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(G,{title:`Factory`,children:(0,Y.jsx)(I,{children:(0,Y.jsxs)(B,{to:Se(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(R,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(fe,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:L(`flex flex-col gap-8 pb-4`,!T&&`w-max min-w-full`),children:[d.editable?!f&&(0,Y.jsx)(X,{pinned:!T,children:(0,Y.jsx)(W,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!T,children:(0,Y.jsx)(W,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!T&&d.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(W,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(W.Message,{children:d.problems.join(` `)})})}),le,oe&&(0,Y.jsxs)(X,{pinned:!T,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[se&&(0,Y.jsx)(W,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(W.Button,{onClick:u,children:`Reload`}),children:(0,Y.jsx)(W.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),S.error&&!se&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not saved. `,S.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:P?`Name the board to save.`:N.length>0?`Fix ${N.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,disabled:S.isPending,onClick:ee,children:`Discard`}),(0,Y.jsx)(U,{size:`sm`,variant:`primary`,disabled:S.isPending||P||N.length>0,onClick:()=>S.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:S.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(H,{open:F.state===`blocked`,onOpenChange:e=>!e&&F.reset?.(),children:(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Y.jsx)(H.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Keep editing`}),(0,Y.jsx)(U,{variant:`destructive`,size:`md`,onClick:()=>{v(),F.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(H,{children:[(0,Y.jsx)(H.Trigger,{render:(0,Y.jsx)(U,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(H.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Cancel`}),(0,Y.jsx)(H.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(H,{children:[(0,Y.jsx)(H.Trigger,{render:(0,Y.jsx)(U,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(bt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(H.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Cancel`}),(0,Y.jsx)(H.Action,{onClick:n,children:`Reset`})]})]})]})}var $={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.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(ke,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:L(`inline-flex rounded-sm`,z),children:n})}),(0,Y.jsx)(je,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l,discard:u}=A(e,t,i),d=Pe(e),f=De(),p=!a||!i.editable||s,m=ge(e,t),h=me(e,t,()=>{u();let n=vt(d.data??[]).find(e=>e.id!==t);f(n?yt(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,y=n?o.phases.find(e=>e.key===n):void 0;if(n&&!y)return null;let b=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{y&&(l(j(y.key,`autoStartWhen`),void 0),l(j(y.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===y.key?T(n,e,t.phases):n)})))},te=y?y.name:o.name,x=(y?y.description:o.description)??``,S=y!==void 0&&!p&&!k(o.phases,y.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(q,{children:[(0,Y.jsxs)(q.Title,{className:`gap-2.5`,children:[y&&(0,Y.jsx)(ze,{stage:y.key,kind:Le(t,y.kind),decorative:!0}),(0,Y.jsx)(xt,{value:te,label:y?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>y?b({name:e}):c(t=>({...t,name:e}))})]}),y&&(0,Y.jsx)(q.Meta,{beside:!0,children:S?(0,Y.jsxs)(dt,{value:y.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Y.jsx)(ut,{size:`sm`,"aria-label":`Phase kind`,children:$[y.kind].label}),(0,Y.jsx)(lt,{children:Ut.map(e=>(0,Y.jsx)(ct,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[y.kind].label,meaning:$[y.kind].meaning,children:(0,Y.jsx)(P,{children:$[y.kind].label})})}),(x||!p)&&(0,Y.jsx)(q.Description,{children:(0,Y.jsx)(xt,{value:x,label:y?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>y?b({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Y.jsxs)(q.Action,{className:`gap-1`,children:[_&&(0,Y.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Y.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=p(),i=x(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=N(),u=c||l===`collapsed`,d=he(e.id,a),f=ve(e.id),m=d.data?.board,h=E(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=V(e.id,a),v=o({breadcrumbs:u&&m?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:B,to:yt(e.id,a),children:h?.name||m.name}),s?(0,Y.jsx)(t,{as:B,to:_,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=d.isSuccess&&(!s||g)?(0,Y.jsx)(`div`,{className:L(K,s?`pb-8`:`pb-3`),children:(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:d.data},`${a}:${d.data.board.revision??`code`}`)}):void 0;return(0,Y.jsx)(C,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Y.jsx)(`div`,{className:s||!d.isSuccess?L(K,!s&&`px-4`):Ne,children:d.isPending?(0,Y.jsx)(I,{children:(0,Y.jsx)(le,{label:`Loading board`,rows:3})}):d.isError&&d.error instanceof _e&&d.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):d.isError?(0,Y.jsx)(St,{title:`Couldn’t load this board`,error:d.error,onRetry:()=>void d.refetch(),retrying:d.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:d.data,skills:f.data?.skills,skillsEditable:f.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void d.refetch()},`${a}:${d.data.board.revision??`code`}`)})})}export{Kt as BoardConfigPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Ar as o,Bn as s,D as c,E as l,Hn as u,Jn as d,Qn as f,Sr as p,Vn as m,Xn as h,Yn as g,Zn as _,_r as v,br as y,cr as b,dn as ee,dr as te,en as x,er as S,ir as ne,jr as C,lr as w,mr as T,nn as E,nr as D,pr as re,qn as O,sr as k,tn as A,tr as ie,ur as j,vr as M,xr as ae}from"./index-BP3ua7KI.js";import{A as oe,a as N,k as P}from"./Sidebar.es-CxsNkx78.js";import{d as se,f as F,r as ce,t as I,u as le}from"./settings-9ei5ML-D-BlNZeAdp.js";import{O as ue,T as L,k as de,n as R,s as z,t as fe}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as B}from"./lib-BeLi6vwy.js";import{c as pe,o as me,r as he,s as ge,t as _e}from"./useBoardEditor-ouq-2Nxa.js";import{i as ve,t as ye}from"./SkillBadges-mOvfA9IK.js";import{a as V,c as be,f as xe,l as Se,s as Ce}from"./boardConfigPaths-Btimpi_r.js";import{t as H}from"./AlertDialog.es-Clga3VZL.js";import{Ai as we,Pi as U,Qn as Te,Rt as Ee,cr as De,fa as Oe,ha as ke,n as Ae,pa as je,t as W}from"./Notice-BhWgws6f-kmCorboO.js";import{t as G}from"./SettingsSubsection-Bu3ZS9dr.js";import{n as Me,r as K,t as Ne}from"./settingsColumn-CrKuH8q1.js";import{n as Pe}from"./useBoardCatalog-CJ6zJlxZ.js";import{h as Fe,o as Ie}from"./useIntakeRoutes-CnY3Cu0c.js";import{a as Le,d as Re,t as ze}from"./BoardIcons-BKwzXIEg.js";import{n as Be,r as Ve,t as He}from"./HoverCard.es-CoejtwWy.js";import{r as Ue}from"./overlays-B3sO28Cg.js";import{t as We}from"./DescriptionMarkdown--4m-3qtV.js";import{h as Ge,w as Ke,y as qe}from"./ruleLanes-B980Mi2c.js";import{t as Je}from"./CodeEditor-AaW7HgY9-DMAOTJ4H.js";import{a as Ye,n as Xe,r as Ze,t as Qe}from"./Field.es-0a08x-Zj.js";import{t as $e}from"./input-DqReKX0A-De875Vkf.js";import{a as et,n as tt}from"./input-group-CXvse9n7-CJxvIZYL.js";import{a as nt,i as rt,n as it,r as at,t as ot}from"./InputNumber.es-CFkXhJOw.js";import{Y as st,a as ct,i as lt,o as ut,r as dt}from"./request-jghBar6W.js";import{E as ft}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";import{n as pt,t as mt}from"./ConditionRows-01YU1Df-.js";import{t as ht}from"./IconLock.es-9mYeLe9c.js";import{t as gt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as _t}from"./TrashIcon.es-DNb97Rim.js";import{t as q}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as vt,t as yt}from"./boardCatalog-y-s19dQU.js";import{t as bt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as xt}from"./InlineText-vWKzGKx_.js";import{t as St}from"./LoadErrorState-DJCV4DnP.js";var J=e(de(),1),Y=ue();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:L(Me,i),children:(0,Y.jsx)(`div`,{className:L(K,n),children:r})}):(0,Y.jsx)(`div`,{className:L(K,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?be(e,t,a):V(e,t,n.key),d=a?l:Ue;return(0,Y.jsxs)(He,{children:[(0,Y.jsxs)(Ve,{delay:0,closeDelay:100,render:(0,Y.jsx)(B,{to:u}),className:L(z,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Be,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(R,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(ye,{skill:o})]}),s?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(g,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(We,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(We,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(R,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(R,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(R,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(He,{children:[(0,Y.jsx)(Ve,{delay:0,closeDelay:100,render:(0,Y.jsx)(B,{to:n}),className:L(z,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ge(e.length)}),(0,Y.jsxs)(Be,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(R,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(u,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=Pe(e),s=Ie(e),c=o.isPending||s.isPending,l=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,u=n.map(e=>d(e,n)),f=s.data&&l?h(s.data.intakeRoutes,{key:t,initialPhase:l}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(W,{variant:`warning`,children:(0,Y.jsx)(W.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),f&&f.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(R,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:f.leaving,title:`Rules that send cards to other boards`,to:Ce(e,t,`leaving`),boardId:t,boards:o.data}),` `,f.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:L(`mx-auto flex w-max`,Et),children:n.map(i=>{let s=Le(t,i.kind),p=f?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(B,{to:V(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(ze,{stage:i.key,kind:s,decorative:!0}),(0,Y.jsx)(R,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(O,{boardId:t,phase:d(i,n),phases:u,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(oe,{className:`h-4 w-20`}):f?p.length>0?(0,Y.jsx)(Tt,{rules:p,title:`Rules that move cards into ${i.name}`,to:Ce(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Y.jsx)(g,{children:`No rule moves cards here`}):(0,Y.jsx)(g,{children:`Rules didn’t load`}),i.key===l&&(0,Y.jsx)(g,{children:`New cards start here`})]}),starts:(0,Y.jsx)(m,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=qe,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?y(s,n):v(s,p),_=e=>{m(e);let t=M(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Qe,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ye,{htmlFor:h,children:e}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,y(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(Xe,{children:t}),p===void 0?r?(0,Y.jsx)(R,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:Ke(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(mt,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,y(s,e))}})}):(0,Y.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Ze,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=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,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(ze,{stage:t.key,kind:Le(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:L(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:L(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,z),children:[(0,Y.jsx)(`span`,{className:L(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(ht,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(gt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(ke,{render:d}),(0,Y.jsx)(je,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(R,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(R,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ce,{children:[(0,Y.jsxs)(Qe,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(se,{children:e}),(0,Y.jsx)(Xe,{children:t}),i,n&&(0,Y.jsx)(Ze,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(I,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Je,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:a,factoryId:o,boardId:c,disabled:u,rawRules:d,onChange:p,onRawRule:m,onUnfinished:h,onRemove:g}){let v=pt(o),y=e.kind===`working`,te=b(e,t),x=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],E=e.exitTool?.id??``,D=e.runner?.skill,O=D?r?.find(e=>e.name===D):void 0,k=D!==void 0&&r!==void 0&&O===void 0,A=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));p({...e,runner:Object.keys(r).length>0?r:null})},ie=e=>({text:d[e],onChange:t=>m(e,t)}),j=(0,Y.jsx)(jt,{phase:e,phases:t,next:te,required:new Set(n),boardId:c,disabled:u,onChange:t=>p({...e,nextPhases:t})}),M=g&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(U,{variant:`ghost`,icon:(0,Y.jsx)(_t,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Re,{}),title:`Starts`,children:(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{label:`Start on its own`,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:u,onCheckedChange:t=>{p(re(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Fe,options:{"source.repository":v},disabled:u,json:ie(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>p({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(Ue,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(x.length,f)}`,error:x.length>1e3?`Too long to save.`:void 0,disabled:u,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:x,placeholder:`Tell the agent what to do, in Markdown`,disabled:u,onChange:e=>A({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(w.length,i)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:u,after:C&&(0,Y.jsxs)(Qe,{invalid:!ne(C.maxRuns),disabled:u,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ye,{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,Y.jsx)(ot,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:u,onValueChange:e=>{let{maxRuns:t,...n}=C;A({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(at,{size:`sm`,children:[(0,Y.jsx)(nt,{placeholder:`Default`}),(0,Y.jsxs)(tt,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(et,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(it,{}),(0,Y.jsx)(rt,{})]})]})})]}),!ne(C.maxRuns)&&(0,Y.jsxs)(Ze,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:u,onChange:e=>A({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:u,children:(0,Y.jsx)($e,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:_,disabled:u,onChange:e=>A({context:e.target.value})})}),(0,Y.jsx)(G,{title:`Skill`,children:(0,Y.jsx)(I,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(dt,{value:D??Pt,disabled:u,onValueChange:e=>A({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(ut,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:D??`No skill`})]})}),(0,Y.jsxs)(lt,{children:[(0,Y.jsx)(ct,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ct,{value:e.name,children:e.name},e.name))]})]}),k&&(0,Y.jsx)(P,{variant:`destructive`,children:`Not found`}),O?.error&&(0,Y.jsx)(P,{variant:`destructive`,children:`Failed to load`}),O&&(0,Y.jsx)(ye,{skill:O}),O&&(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,icon:a?(0,Y.jsx)(s,{}):(0,Y.jsx)(Ae,{}),"aria-label":`${a?`Edit`:`View`} ${O.name}`,className:`ml-auto`,render:(0,Y.jsx)(B,{to:be(o,c,O.name)}),children:a?`Edit`:`View`})]}),O?.error?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,O.error]}):k?(0,Y.jsxs)(R,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,D,` skill, so cards entering `,e.name,` fail to start.`]}):O?.description&&(0,Y.jsx)(R,{as:`p`,variant:`caption`,tone:`muted`,children:O.description})]})})}),(0,Y.jsx)(G,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(I,{children:S.map(t=>(0,Y.jsx)(F,{label:t.label,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:u,onCheckedChange:n=>{let r=S.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));p({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ae,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:u,children:(0,Y.jsx)($e,{className:Ft,"aria-label":`${e.name} exit tool`,value:E,disabled:u,onChange:t=>{let n=t.target.value.trim();p({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),E!==``&&(0,Y.jsxs)(I,{children:[(0,Y.jsx)(F,{label:`Approve on its own`,disabled:u,children:(0,Y.jsx)(ft,{"aria-label":`${e.name}: approve ${E} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:u,onCheckedChange:t=>{p({...e,exitTool:{...e.exitTool,id:E,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Fe,options:{"source.repository":v},disabled:u,json:ie(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>p({...e,exitTool:{...e.exitTool,id:E,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(ee,{}),title:`Allowed moves`,children:j})]}),M]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(G,{title:`Allowed moves`,children:j}),M]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=A(e.id,t,d),[y,b]=(0,J.useState)(0),ee=()=>{v(),b(e=>e+1)},x=De(),S=pe(e.id,t),ne=we(),C=!f||!d.editable,T=n?p.phases.find(e=>e.key===n):void 0,E=T&&`${T.key}:${d.revision??`code`}:${y}`,[O,k]=(0,J.useState)({page:E,fields:[]});O.page!==E&&k({page:E,fields:[]});let M=O.page===E?O.fields:[],ae=(e,t)=>k(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),oe=!C&&(D(p,d)||Object.keys(m).length>0||M.length>0),N=p.phases.filter(e=>w(e,m)||e===T&&M.length>0),P=p.name.trim()===``,se=S.error?.code===`revision_mismatch`,F=Te(({nextLocation:n})=>{let r=ne.getQueryData(Ee.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!oe||r===!1)return!1;let i=xe(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),ce=V(e.id,t),le;return le=n&&!T?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(U,{size:`sm`,render:(0,Y.jsx)(B,{to:ce}),children:`Back to general`})}):T?(0,Y.jsx)(Rt,{phase:T,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[T.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:C||h,rawRules:{autoStartWhen:m[j(T.key,`autoStartWhen`)],autoApproveWhen:m[j(T.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(j(T.key,e),t),ae(e,!1)},onUnfinished:ae,onRemove:C||h||!ie(p.phases,T.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(j(T.key,e),void 0);g(e=>({...e,phases:te(e.phases,T.key)})),x(ce)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},E):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:C||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?re(n,t):n)})),t||_(j(e,`autoStartWhen`),void 0)},action:s&&!C?(0,Y.jsx)(c,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(G,{title:`Factory`,children:(0,Y.jsx)(I,{children:(0,Y.jsxs)(B,{to:Se(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(R,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(fe,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:L(`flex flex-col gap-8 pb-4`,!T&&`w-max min-w-full`),children:[d.editable?!f&&(0,Y.jsx)(X,{pinned:!T,children:(0,Y.jsx)(W,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!T,children:(0,Y.jsx)(W,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!T&&d.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(W,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(W.Message,{children:d.problems.join(` `)})})}),le,oe&&(0,Y.jsxs)(X,{pinned:!T,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[se&&(0,Y.jsx)(W,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(W.Button,{onClick:u,children:`Reload`}),children:(0,Y.jsx)(W.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),S.error&&!se&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not saved. `,S.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(R,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:P?`Name the board to save.`:N.length>0?`Fix ${N.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(U,{size:`sm`,variant:`ghost`,disabled:S.isPending,onClick:ee,children:`Discard`}),(0,Y.jsx)(U,{size:`sm`,variant:`primary`,disabled:S.isPending||P||N.length>0,onClick:()=>S.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:S.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(H,{open:F.state===`blocked`,onOpenChange:e=>!e&&F.reset?.(),children:(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Y.jsx)(H.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Keep editing`}),(0,Y.jsx)(U,{variant:`destructive`,size:`md`,onClick:()=>{v(),F.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(H,{children:[(0,Y.jsx)(H.Trigger,{render:(0,Y.jsx)(U,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(H.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Cancel`}),(0,Y.jsx)(H.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(H,{children:[(0,Y.jsx)(H.Trigger,{render:(0,Y.jsx)(U,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(bt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(H.Content,{children:[(0,Y.jsxs)(H.Header,{children:[(0,Y.jsxs)(H.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(H.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(H.Footer,{children:[(0,Y.jsx)(H.Cancel,{children:`Cancel`}),(0,Y.jsx)(H.Action,{onClick:n,children:`Reset`})]})]})]})}var $={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.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(Oe,{children:[(0,Y.jsx)(ke,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:L(`inline-flex rounded-sm`,z),children:n})}),(0,Y.jsx)(je,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l,discard:u}=A(e,t,i),d=Pe(e),f=De(),p=!a||!i.editable||s,m=ge(e,t),h=me(e,t,()=>{u();let n=vt(d.data??[]).find(e=>e.id!==t);f(n?yt(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,y=n?o.phases.find(e=>e.key===n):void 0;if(n&&!y)return null;let b=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{y&&(l(j(y.key,`autoStartWhen`),void 0),l(j(y.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===y.key?T(n,e,t.phases):n)})))},te=y?y.name:o.name,x=(y?y.description:o.description)??``,S=y!==void 0&&!p&&!k(o.phases,y.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(q,{children:[(0,Y.jsxs)(q.Title,{className:`gap-2.5`,children:[y&&(0,Y.jsx)(ze,{stage:y.key,kind:Le(t,y.kind),decorative:!0}),(0,Y.jsx)(xt,{value:te,label:y?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>y?b({name:e}):c(t=>({...t,name:e}))})]}),y&&(0,Y.jsx)(q.Meta,{beside:!0,children:S?(0,Y.jsxs)(dt,{value:y.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Y.jsx)(ut,{size:`sm`,"aria-label":`Phase kind`,children:$[y.kind].label}),(0,Y.jsx)(lt,{children:Ut.map(e=>(0,Y.jsx)(ct,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[y.kind].label,meaning:$[y.kind].meaning,children:(0,Y.jsx)(P,{children:$[y.kind].label})})}),(x||!p)&&(0,Y.jsx)(q.Description,{children:(0,Y.jsx)(xt,{value:x,label:y?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>y?b({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Y.jsxs)(q.Action,{className:`gap-1`,children:[_&&(0,Y.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Y.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Y.jsx)(W,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(W.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=p(),i=x(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=N(),u=c||l===`collapsed`,d=he(e.id,a),f=ve(e.id),m=d.data?.board,h=E(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=V(e.id,a),v=o({breadcrumbs:u&&m?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:B,to:yt(e.id,a),children:h?.name||m.name}),s?(0,Y.jsx)(t,{as:B,to:_,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=d.isSuccess&&(!s||g)?(0,Y.jsx)(`div`,{className:L(K,s?`pb-8`:`pb-3`),children:(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:d.data},`${a}:${d.data.board.revision??`code`}`)}):void 0;return(0,Y.jsx)(C,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Y.jsx)(`div`,{className:s||!d.isSuccess?L(K,!s&&`px-4`):Ne,children:d.isPending?(0,Y.jsx)(I,{children:(0,Y.jsx)(le,{label:`Loading board`,rows:3})}):d.isError&&d.error instanceof _e&&d.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):d.isError?(0,Y.jsx)(St,{title:`Couldn’t load this board`,error:d.error,onRetry:()=>void d.refetch(),retrying:d.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:d.data,skills:f.data?.skills,skillsEditable:f.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void d.refetch()},`${a}:${d.data.board.revision??`code`}`)})})}export{Kt as BoardConfigPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Ar as i,Sr as a,en as o,jr as s}from"./index-Du9_RN46.js";import{a as c,k as l}from"./Sidebar.es-CxsNkx78.js";import{O as u,T as d,k as f,n as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as m}from"./lib-BeLi6vwy.js";import{r as h}from"./useBoardEditor-ouq-2Nxa.js";import{a as g,n as _,s as v,t as y}from"./boardConfigPaths-Btimpi_r.js";import{r as b}from"./settingsColumn-CrKuH8q1.js";import{Pi as x,t as S}from"./Notice-BhWgws6f-kmCorboO.js";import{X as C}from"./request-jghBar6W.js";import{a as w,o as T,t as E,u as D}from"./settings-9ei5ML-D-BlNZeAdp.js";import{a as O,c as k,d as A,i as j,l as M,n as N,o as P,r as F,t as I,u as L}from"./useRowDrag-DUPtpGn4.js";import{o as R}from"./useIntakeRoutes-CnY3Cu0c.js";import{h as z,p as B}from"./ruleLanes-B980Mi2c.js";import{s as V}from"./Field.es-0a08x-Zj.js";import{n as H}from"./useBoardCatalog-CJ6zJlxZ.js";import{t as U}from"./SettingsSubsection-Bu3ZS9dr.js";import{s as W}from"./settingsSections-B0_LEh3l.js";var G=e(f(),1),K=u();function q({factoryId:e}){let t=j(e),n=O(e),r=new Map((H(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>C.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>C.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,K.jsxs)(`section`,{id:_,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,K.jsx)(w,{media:(0,K.jsx)(T,{children:(0,K.jsx)(M,{})}),title:(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,K.jsx)(V,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,K.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,K.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,K.jsxs)(w,{title:t.url?(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,K.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,K.jsx)(`span`,{children:t.sourceKey}),(0,K.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,K.jsx)(`time`,{dateTime:t.decidedAt,children:J(t.decidedAt)})]}),children:[(0,K.jsx)(N,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,K.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function J(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var Y=d(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function X({factoryId:e}){let t=F(e);return(0,K.jsx)(U,{id:y,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,K.jsx)(E,{children:(0,K.jsx)(D,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(S,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,K.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,K.jsx)(q,{factoryId:e})})]}):(0,K.jsx)(Z,{factoryId:e,order:t.data},e)})}function Z({factoryId:e,order:t}){let n=R(e),r=P(e),[i,a]=(0,G.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&ee(i,o)?i:void 0,c=s??o,l=new Map(t.boards.map(e=>[e.boardKey,e.name])),u=s!==void 0&&s.some((e,t)=>e!==o[t]),f=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},h=I({min:0,max:c.length-1,onDrop:f}),g=()=>r.mutate(c,{onSuccess:()=>{a(void 0),C.success(`Intake order saved.`)},onError:e=>C.error(e.message)}),_=t.canEdit&&c.length>1,y=_&&!r.isPending;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)($,{order:t,changed:u}),n.isError&&(0,K.jsx)(S,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,K.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,K.jsx)(E,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=h.drag?.from===r,a=l.get(t)??t;return(0,K.jsx)(w,{role:`listitem`,"data-drop":h.dropAt(r),style:i?{transform:`translateY(${h.drag?.offset??0}px)`}:void 0,onPointerDown:y?e=>h.onPointerDown(e,r):void 0,onKeyDown:y?e=>h.onKeyDown(e,r):void 0,className:d(`group/row`,Y,i&&`z-10 opacity-90`),media:(0,K.jsxs)(T,{children:[(0,K.jsx)(p,{as:`span`,variant:`caption`,className:d(`tabular-nums`,_&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),_&&(0,K.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:d(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,K.jsx)(k,{className:`size-icon-md`})})]}),title:a,description:(0,K.jsx)(Q,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[_&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!y||r===0,onClick:()=>f(r,r-1),children:(0,K.jsx)(L,{})}),(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!y||r===c.length-1,onClick:()=>f(r,r+1),children:(0,K.jsx)(A,{})})]}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,K.jsx)(m,{to:v(e,t)}),children:`Edit rules`})]})},t)})}),(0,K.jsx)(q,{factoryId:e})]}),t.canEdit&&u&&(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,K.jsx)(x,{size:`sm`,variant:`primary`,onClick:g,disabled:r.isPending,children:`Save order`})]})]})}function Q({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=B(e.filter(e=>e.target.boardKey===t));return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${z(n)} for new issues and pull requests`}),r&&(0,K.jsx)(l,{children:`Ends in catch-all`})]})}function $({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,K.jsx)(S,{variant:`info`,children:(0,K.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,K.jsx)(`span`,{children:e},e))})})}function ee(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function te(){let e=a(),l=o()?.boardId??``,{isMobile:u,desktopState:f}=c(),p=u||f===`collapsed`,_=h(e.id,l).data?.board,v=i({breadcrumbs:p&&_?(0,K.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,K.jsx)(t,{as:m,to:g(e.id,l),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(s,{variant:`narrow`,header:(0,K.jsx)(`div`,{className:d(b,`pb-8`),children:(0,K.jsxs)(r,{children:[(0,K.jsx)(r.Title,{children:`Routing`}),(0,K.jsx)(r.Description,{children:(0,K.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,K.jsx)(m,{to:W(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]})}),...v,children:(0,K.jsx)(`div`,{className:d(b,`flex flex-col gap-8`),children:(0,K.jsx)(X,{factoryId:e.id})})})}export{te as BoardIntakePage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Ar as i,Sr as a,en as o,jr as s}from"./index-BP3ua7KI.js";import{a as c,k as l}from"./Sidebar.es-CxsNkx78.js";import{O as u,T as d,k as f,n as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as m}from"./lib-BeLi6vwy.js";import{r as h}from"./useBoardEditor-ouq-2Nxa.js";import{a as g,n as _,s as v,t as y}from"./boardConfigPaths-Btimpi_r.js";import{r as b}from"./settingsColumn-CrKuH8q1.js";import{Pi as x,t as S}from"./Notice-BhWgws6f-kmCorboO.js";import{X as C}from"./request-jghBar6W.js";import{a as w,o as T,t as E,u as D}from"./settings-9ei5ML-D-BlNZeAdp.js";import{a as O,c as k,d as A,i as j,l as M,n as N,o as P,r as F,t as I,u as L}from"./useRowDrag-DUPtpGn4.js";import{o as R}from"./useIntakeRoutes-CnY3Cu0c.js";import{h as z,p as B}from"./ruleLanes-B980Mi2c.js";import{s as V}from"./Field.es-0a08x-Zj.js";import{n as H}from"./useBoardCatalog-CJ6zJlxZ.js";import{t as U}from"./SettingsSubsection-Bu3ZS9dr.js";import{s as W}from"./settingsSections-B0_LEh3l.js";var G=e(f(),1),K=u();function q({factoryId:e}){let t=j(e),n=O(e),r=new Map((H(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>C.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>C.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,K.jsxs)(`section`,{id:_,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,K.jsx)(w,{media:(0,K.jsx)(T,{children:(0,K.jsx)(M,{})}),title:(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,K.jsx)(V,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,K.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,K.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,K.jsxs)(w,{title:t.url?(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,K.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,K.jsx)(`span`,{children:t.sourceKey}),(0,K.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,K.jsx)(`time`,{dateTime:t.decidedAt,children:J(t.decidedAt)})]}),children:[(0,K.jsx)(N,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,K.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function J(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var Y=d(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function X({factoryId:e}){let t=F(e);return(0,K.jsx)(U,{id:y,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,K.jsx)(E,{children:(0,K.jsx)(D,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(S,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,K.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,K.jsx)(q,{factoryId:e})})]}):(0,K.jsx)(Z,{factoryId:e,order:t.data},e)})}function Z({factoryId:e,order:t}){let n=R(e),r=P(e),[i,a]=(0,G.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&ee(i,o)?i:void 0,c=s??o,l=new Map(t.boards.map(e=>[e.boardKey,e.name])),u=s!==void 0&&s.some((e,t)=>e!==o[t]),f=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},h=I({min:0,max:c.length-1,onDrop:f}),g=()=>r.mutate(c,{onSuccess:()=>{a(void 0),C.success(`Intake order saved.`)},onError:e=>C.error(e.message)}),_=t.canEdit&&c.length>1,y=_&&!r.isPending;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)($,{order:t,changed:u}),n.isError&&(0,K.jsx)(S,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,K.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,K.jsx)(E,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=h.drag?.from===r,a=l.get(t)??t;return(0,K.jsx)(w,{role:`listitem`,"data-drop":h.dropAt(r),style:i?{transform:`translateY(${h.drag?.offset??0}px)`}:void 0,onPointerDown:y?e=>h.onPointerDown(e,r):void 0,onKeyDown:y?e=>h.onKeyDown(e,r):void 0,className:d(`group/row`,Y,i&&`z-10 opacity-90`),media:(0,K.jsxs)(T,{children:[(0,K.jsx)(p,{as:`span`,variant:`caption`,className:d(`tabular-nums`,_&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),_&&(0,K.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:d(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,K.jsx)(k,{className:`size-icon-md`})})]}),title:a,description:(0,K.jsx)(Q,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[_&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!y||r===0,onClick:()=>f(r,r-1),children:(0,K.jsx)(L,{})}),(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!y||r===c.length-1,onClick:()=>f(r,r+1),children:(0,K.jsx)(A,{})})]}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,K.jsx)(m,{to:v(e,t)}),children:`Edit rules`})]})},t)})}),(0,K.jsx)(q,{factoryId:e})]}),t.canEdit&&u&&(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,K.jsx)(x,{size:`sm`,variant:`primary`,onClick:g,disabled:r.isPending,children:`Save order`})]})]})}function Q({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=B(e.filter(e=>e.target.boardKey===t));return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${z(n)} for new issues and pull requests`}),r&&(0,K.jsx)(l,{children:`Ends in catch-all`})]})}function $({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,K.jsx)(S,{variant:`info`,children:(0,K.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,K.jsx)(`span`,{children:e},e))})})}function ee(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function te(){let e=a(),l=o()?.boardId??``,{isMobile:u,desktopState:f}=c(),p=u||f===`collapsed`,_=h(e.id,l).data?.board,v=i({breadcrumbs:p&&_?(0,K.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,K.jsx)(t,{as:m,to:g(e.id,l),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(s,{variant:`narrow`,header:(0,K.jsx)(`div`,{className:d(b,`pb-8`),children:(0,K.jsxs)(r,{children:[(0,K.jsx)(r.Title,{children:`Routing`}),(0,K.jsx)(r.Description,{children:(0,K.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,K.jsx)(m,{to:W(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]})}),...v,children:(0,K.jsx)(`div`,{className:d(b,`flex flex-col gap-8`),children:(0,K.jsx)(X,{factoryId:e.id})})})}export{te as BoardIntakePage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Ar as i,Gn as a,Kn as o,Sr as s,Un as c,Wn as l,Xn as u,en as d,jr as f}from"./index-Du9_RN46.js";import{A as p,a as m,k as h,p as g}from"./Sidebar.es-CxsNkx78.js";import{O as _,T as v,k as y,n as b}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as x,t as S}from"./lib-BeLi6vwy.js";import{r as C,t as w}from"./useBoardEditor-ouq-2Nxa.js";import{a as T,i as E,o as D,s as O,t as k}from"./boardConfigPaths-Btimpi_r.js";import{At as A,Ct as j,Et as M,Ot as N,Pi as P,kt as F,t as I,xt as ee}from"./Notice-BhWgws6f-kmCorboO.js";import{X as L}from"./request-jghBar6W.js";import{n as R}from"./useBoardCatalog-CJ6zJlxZ.js";import{c as z,d as te,l as ne,n as B,r as V,s as re,t as H,u as U}from"./useRowDrag-DUPtpGn4.js";import{a as W,d as ie,f as ae,g as oe,o as G,r as se,s as K}from"./useIntakeRoutes-CnY3Cu0c.js";import{C as ce,E as le,_ as ue,a as de,c as fe,d as q,f as pe,g as me,i as he,l as J,m as ge,n as _e,o as ve,s as ye,u as Y,w as be}from"./ruleLanes-B980Mi2c.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as xe,t as Se}from"./BoardIcons-BKwzXIEg.js";import{t as Ce}from"./input-DqReKX0A-De875Vkf.js";import{n as we,t as Te}from"./RadioGroup.es-DBj_NWnV.js";import{n as Ee,t as De}from"./ConditionRows-B6jx-I10.js";import{t as Oe}from"./GithubIcon.es-DGJTTitG.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";var Ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ae.node;var je=X(Ae),Me={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Me.node;var Ne=X(Me),Pe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Pe.node;var Fe=X(Pe),Ie={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ie.node;var Le=X(Ie),Re={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Re.node;var ze=X(Re),Be={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Be.node;var Ve=X(Be),He={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};He.node;var Ue=X(He),We={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};We.node;var Ge=X(We),Ke={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ke.node;var qe=X(Ke),Je={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Je.node;var Ye=X(Je),Xe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Xe.node;var Ze=X(Xe),Z=e(y(),1),Q=_();function Qe({when:e,options:t,everything:n}){let r=ce(e,t);return!e||!r?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)($e,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)($e,{children:t})]},n)})})}function $e({children:e}){return(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function et({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let a=r??i.initialPhase,o=i.phases.find(e=>e.id===a);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:c(i)}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),o&&(0,Q.jsx)(Se,{stage:o.id,kind:xe(i.id,o.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:l(i,a)??a})]})}function tt({factoryId:e,rules:t,board:n,boards:r}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(b,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let i=r.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(S,{to:O(e,t.target.boardKey),"aria-label":`${t.name}, on ${i?c(i):t.target.boardKey}`,className:v(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:i?c(i):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(Qe,{when:t.when,options:a(i),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function nt({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(S,{to:O(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(S,{to:D(e,t,k),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var rt=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,it=`border-border-focus bg-fill-hover`,at=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ot({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:v(rt,`disabled:opacity-50`,e?it:at),children:r})}function st({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:v(rt,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?it:at,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(we,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ct(){return(0,Q.jsx)(h,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(Oe,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=oe(K),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function dt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function ft(e,t){if(t){let e=ut.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return ae(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${be(t).charAt(0).toLowerCase()}${be(t).slice(1)}`:``}, move to ${n}`;return r.length>lt?`${r.slice(0,119)}…`:r}function mt({factoryId:e,board:t,boards:n,initial:r,initialEvent:i,initialStep:o,readOnly:s,saving:u,error:d,onSave:f,onClose:p}){let m=Ee(e),[h,g]=(0,Z.useState)(()=>r?.on??(i?[i]:[])),[_,y]=(0,Z.useState)(()=>r?.when??null),[x,S]=(0,Z.useState)(()=>(r?.when?.conditions.length??0)>0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(()=>r?.target.moveToBoardKey??t.id),[D,O]=(0,Z.useState)(()=>r?r.target.phaseKey??void 0:void 0),[k,L]=(0,Z.useState)(()=>r?.name),[R,z]=(0,Z.useState)(o),[te,ne]=(0,Z.useState)(0),B=ge(h),V=n.find(e=>e.id===T),re=dt(V,B),H=re.find(e=>e.id===(D??V?.initialPhase)),U=x?_:null,W=h.length?ft(h,U):void 0,ae=H&&V?`${c(V)} › ${l(V,H.id)}`:``,oe=k??(H?pt(h,U,ae):``),G={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!W,action:H!==void 0,review:oe.trim().length>0},se=!s&&G.trigger&&G.conditions&&G.action&&G.review,K=$.findIndex(e=>e.id===R),ce=$[K]??$[0],ue=e=>{g(e),ge(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{se&&H&&f({name:oe.trim(),on:h,when:U,target:{phaseKey:H.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(U===null?{operator:`AND`,conditions:[e]}:U.operator===`AND`?{...U,conditions:[...U.conditions,e]}:{operator:`AND`,conditions:[U,e]}),S(!0),w(!1),ne(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?be(U,a(t)):void 0,action:H?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:H.id}):void 0,review:void 0};return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(M,{size:`xl`,children:[(0,Q.jsx)(F,{children:(0,Q.jsx)(A,{children:s?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(j,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>G[e.id]),r=G[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":R===e.id?`step`:void 0,onClick:()=>z(e.id),className:v(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,R===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,className:v(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Ne,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),q[e.id]&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:q[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":ce.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(b,{as:`h3`,variant:`heading`,children:ce.question}),R===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:s,onChange:ue}),R===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Te,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:s,onValueChange:e=>{S(e===`matching`),w(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(st,{value:`every`,selected:!x,disabled:s,children:(0,Q.jsx)(ht,{title:B?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:s,children:(0,Q.jsx)(ht,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),x&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(De,{label:`Conditions`,rule:_,facts:le(h),options:{...a(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},te)}),W&&(0,Q.jsx)(I,{variant:`warning`,children:W}),!r?.outsiderPullRequestsGated&&ie(h,U)&&(0,Q.jsx)(I,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!s&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),R===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[B?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(Te,{"aria-label":`Board`,value:T,disabled:s,onValueChange:e=>{typeof e==`string`&&e!==T&&(E(e),O(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===T,disabled:s,children:(0,Q.jsxs)(b,{as:`span`,variant:`label`,tone:`ink`,children:[c(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(Te,{"aria-label":`Phase`,value:H?.id??null,disabled:s,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:V&&re.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===H?.id,disabled:s,onClick:()=>{O(e.id),z(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Se,{stage:e.id,kind:xe(V.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:l(V,e.id)})]})},e.id))})]})]}),R===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Ce,{value:oe,maxLength:lt,disabled:s,onChange:e=>L(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(gt,{label:`When`,children:q.trigger}),(0,Q.jsx)(gt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ze,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),q.conditions]})}),(0,Q.jsx)(gt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(je,{className:`size-icon-sm`,"aria-hidden":!0}),` `,q.action]})})]})]})]}),d&&(0,Q.jsx)(I,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:p,children:s?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(P,{variant:`default`,onClick:()=>z($[K-1].id),children:`Back`}),!s&&(R===`review`||r&&se?(0,Q.jsx)(P,{variant:`primary`,disabled:!se||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(P,{variant:`primary`,disabled:!G[R],onClick:()=>z($[K+1]?.id??`review`),children:`Continue`}))]})]})})}function ht({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function gt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,children:t})]})}function _t({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(I,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),_e.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=Y(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ot,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(ht,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ct,{})})]},r)})})]},r.title))]})}function vt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ve,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(S,{to:r}),children:`Show all`})]})}var yt=v(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function bt({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:a,skips:o,footer:s,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=de(t,e),w=fe(e),T=ve(e),E=H({min:0,max:t.length-1,onDrop:m}),D=a&&t.length>1&&!d,O=s??(t.length?`Otherwise, the card stays where it is`:u?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":x.label,className:v(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!u&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`h3`,variant:`label`,tone:`ink`,children:x.label}),x.githubOnly&&(0,Q.jsx)(ct,{})]}),x.description&&(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:x.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${x.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((s,u)=>{if(d&&!d.has(s.id))return null;let p=me(t,e,u),S=p>=0,O=!s.enabled||S,k=E.drag?.from===u,A=o?.get(s.id),j=r.find(e=>e.id===(s.target.moveToBoardKey??s.target.boardKey)),M=!pe(s.name,[x.label,be(s.when,i),j&&c(j),l(j,s.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":s.name,"data-drop":E.dropAt(u),style:k?{transform:`translateY(${E.drag?.offset??0}px)`}:void 0,onPointerDown:D?e=>E.onPointerDown(e,u):void 0,className:v(`group/rule flex flex-col`,yt,k&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${s.name}`,onClick:()=>f(s,`conditions`),onKeyDown:D?e=>E.onKeyDown(e,u):void 0,className:v(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,O?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:v(D&&`pointer-fine:group-hover/rule:hidden`,k&&`hidden`),children:u+1}),D&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:v(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,k&&`flex`),children:(0,Q.jsx)(z,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[M&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:s.name}),(0,Q.jsx)(Qe,{when:s.when,options:i,everything:T})]})]}),D&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(te,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:v(`flex min-w-0 items-center`,O&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:v(`h-px w-8 shrink-0`,O?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${s.name} moves the card`,onClick:()=>f(s,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:s.target.moveToBoardKey??s.target.boardKey,phaseKey:s.target.phaseKey})})]}),a&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${s.name} on`,checked:s.enabled,onCheckedChange:e=>h(s,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${s.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(s),children:[(0,Q.jsx)(Ye,{}),`Delete rule`]})})]})]})]})]}),O&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,T.toLowerCase(),`.`]}):`Off, skipped`}),s.problems.map(e=>(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),A&&(0,Q.jsx)(St,{skips:A}),ue(s,e)&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,a&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(s),className:`underline`,children:`Let outside authors match`})]}),q(s,e)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),w&&ye(s)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:Y(`work_item.created`).label}),u!==C&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},s.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[C<0&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(ne,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),a&&(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(qe,{}),onClick:p,children:`Add rule`})]})]}),u]})]})}function xt(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function St({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,xt(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Ct=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function wt(e){return e instanceof w&&e.code!==void 0&&Ct.has(e.code)}function Tt(e){return wt(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Et({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(p,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(I,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(Dt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(I,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=se(e,t.id),i=G(e),s=V(e),c=re(e),d=W(e),[f,m]=(0,Z.useState)(),h=(0,Z.useRef)(void 0),g=e=>{h.current=e,m(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=a(t),w=(i.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===t.id&&e.target.boardKey!==t.id),T=new Map(c.data?.skipped.map(e=>[e.routeId,e])),[D]=x(),k=D.get(`into`)??void 0,A=D.has(E),j=A||k!==void 0,M=j&&i.data?u(i.data.intakeRoutes,{key:t.id,initialPhase:t.initialPhase}):void 0,N=M&&new Set((A?M.leaving:M.into.get(k??``)??[]).map(e=>e.id)),P=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(p,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(I,{variant:`destructive`,children:`This board’s rules didn’t load.`});let F=e=>d.mutateAsync(e).catch(e=>L.error(Tt(e))),ee=(e,n,r)=>{let i=J(y,e).map(e=>e.id);F([{kind:`reorder`,boardKey:t.id,ids:o(y,i,n,r)}])},R=e=>{v(void 0),g(e)},z=async e=>{let n=h.current,r=n?.rule,i=()=>n!==void 0&&h.current===n;v(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[n]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ne(n,e.on).catch(e=>L.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return te(r);v(Tt(e))}},te=async e=>{let t=h.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&h.current===t&&(n?(g({...t,rule:n}),v(`Someone else changed this rule first. It now shows their version; make your change again.`)):(g(void 0),L.error(`Someone else deleted this rule first.`)))},ne=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),s=a.indexOf(e.id),c=n.flatMap(t=>{let n=J(i,t),r=n[me(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),l=Math.min(...c);s<0||!(l<s)||await d.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:o(i,a,s,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:he(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(I,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),j&&(0,Q.jsx)(vt,{count:N?.size,into:A||!k?`other boards`:l(t,k)??k,leaving:A,showAll:O(e,t.id)}),_e.filter(e=>e.events.some(e=>P([...J(y,e),...J(w,e)]))).map(r=>(0,Q.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.some(fe)?s.data&&(0,Q.jsx)(nt,{factoryId:e,boardKey:t.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Only cards already on this board; other boards never see them.`})]}),r.events.map(r=>{let i=fe(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return P([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?B:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:r,step:`conditions`}),onMove:(e,t)=>ee(r,e,t),onToggle:(e,t)=>void F([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void F([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&L.success(`Deleted “${e.name}”`)),onUngate:e=>void F([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&L.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),f&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!S,saving:d.isPending,error:_,onSave:e=>void z(e),onClose:()=>g(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=s(),a=d()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,u=C(e.id,a).data?.board,p=i({breadcrumbs:l&&u?(0,Q.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(t,{as:S,to:T(e.id,a),children:u.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(f,{variant:`narrow`,header:(0,Q.jsxs)(`div`,{className:v(Ot,`pb-8`),children:[(0,Q.jsxs)(r,{children:[(0,Q.jsx)(r.Title,{children:`Rules`}),(0,Q.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...p,children:(0,Q.jsx)(`div`,{className:Ot,children:(0,Q.jsx)(Et,{factoryId:e.id,boardId:a})})})}export{kt as BoardRulesPage};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-E9FvZNZw.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Ar as i,Gn as a,Kn as o,Sr as s,Un as c,Wn as l,Xn as u,en as d,jr as f}from"./index-BP3ua7KI.js";import{A as p,a as m,k as h,p as g}from"./Sidebar.es-CxsNkx78.js";import{O as _,T as v,k as y,n as b}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as x,t as S}from"./lib-BeLi6vwy.js";import{r as C,t as w}from"./useBoardEditor-ouq-2Nxa.js";import{a as T,i as E,o as D,s as O,t as k}from"./boardConfigPaths-Btimpi_r.js";import{At as A,Ct as j,Et as M,Ot as N,Pi as P,kt as F,t as I,xt as ee}from"./Notice-BhWgws6f-kmCorboO.js";import{X as L}from"./request-jghBar6W.js";import{n as R}from"./useBoardCatalog-CJ6zJlxZ.js";import{c as z,d as te,l as ne,n as B,r as V,s as re,t as H,u as U}from"./useRowDrag-DUPtpGn4.js";import{a as W,d as ie,f as ae,g as oe,o as G,r as se,s as K}from"./useIntakeRoutes-CnY3Cu0c.js";import{C as ce,E as le,_ as ue,a as de,c as fe,d as q,f as pe,g as me,i as he,l as J,m as ge,n as _e,o as ve,s as ye,u as Y,w as be}from"./ruleLanes-B980Mi2c.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as xe,t as Se}from"./BoardIcons-BKwzXIEg.js";import{t as Ce}from"./input-DqReKX0A-De875Vkf.js";import{n as we,t as Te}from"./RadioGroup.es-DBj_NWnV.js";import{n as Ee,t as De}from"./ConditionRows-01YU1Df-.js";import{t as Oe}from"./GithubIcon.es-DGJTTitG.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";var Ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ae.node;var je=X(Ae),Me={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Me.node;var Ne=X(Me),Pe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Pe.node;var Fe=X(Pe),Ie={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ie.node;var Le=X(Ie),Re={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Re.node;var ze=X(Re),Be={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Be.node;var Ve=X(Be),He={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};He.node;var Ue=X(He),We={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};We.node;var Ge=X(We),Ke={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ke.node;var qe=X(Ke),Je={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Je.node;var Ye=X(Je),Xe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Xe.node;var Ze=X(Xe),Z=e(y(),1),Q=_();function Qe({when:e,options:t,everything:n}){let r=ce(e,t);return!e||!r?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)($e,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)($e,{children:t})]},n)})})}function $e({children:e}){return(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function et({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let a=r??i.initialPhase,o=i.phases.find(e=>e.id===a);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:c(i)}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),o&&(0,Q.jsx)(Se,{stage:o.id,kind:xe(i.id,o.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:l(i,a)??a})]})}function tt({factoryId:e,rules:t,board:n,boards:r}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(b,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let i=r.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(S,{to:O(e,t.target.boardKey),"aria-label":`${t.name}, on ${i?c(i):t.target.boardKey}`,className:v(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:i?c(i):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(Qe,{when:t.when,options:a(i),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function nt({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(S,{to:O(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(S,{to:D(e,t,k),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var rt=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,it=`border-border-focus bg-fill-hover`,at=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ot({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:v(rt,`disabled:opacity-50`,e?it:at),children:r})}function st({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:v(rt,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?it:at,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(we,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ct(){return(0,Q.jsx)(h,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(Oe,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=oe(K),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function dt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function ft(e,t){if(t){let e=ut.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return ae(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${be(t).charAt(0).toLowerCase()}${be(t).slice(1)}`:``}, move to ${n}`;return r.length>lt?`${r.slice(0,119)}…`:r}function mt({factoryId:e,board:t,boards:n,initial:r,initialEvent:i,initialStep:o,readOnly:s,saving:u,error:d,onSave:f,onClose:p}){let m=Ee(e),[h,g]=(0,Z.useState)(()=>r?.on??(i?[i]:[])),[_,y]=(0,Z.useState)(()=>r?.when??null),[x,S]=(0,Z.useState)(()=>(r?.when?.conditions.length??0)>0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(()=>r?.target.moveToBoardKey??t.id),[D,O]=(0,Z.useState)(()=>r?r.target.phaseKey??void 0:void 0),[k,L]=(0,Z.useState)(()=>r?.name),[R,z]=(0,Z.useState)(o),[te,ne]=(0,Z.useState)(0),B=ge(h),V=n.find(e=>e.id===T),re=dt(V,B),H=re.find(e=>e.id===(D??V?.initialPhase)),U=x?_:null,W=h.length?ft(h,U):void 0,ae=H&&V?`${c(V)} › ${l(V,H.id)}`:``,oe=k??(H?pt(h,U,ae):``),G={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!W,action:H!==void 0,review:oe.trim().length>0},se=!s&&G.trigger&&G.conditions&&G.action&&G.review,K=$.findIndex(e=>e.id===R),ce=$[K]??$[0],ue=e=>{g(e),ge(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{se&&H&&f({name:oe.trim(),on:h,when:U,target:{phaseKey:H.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(U===null?{operator:`AND`,conditions:[e]}:U.operator===`AND`?{...U,conditions:[...U.conditions,e]}:{operator:`AND`,conditions:[U,e]}),S(!0),w(!1),ne(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?be(U,a(t)):void 0,action:H?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:H.id}):void 0,review:void 0};return(0,Q.jsx)(ee,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(M,{size:`xl`,children:[(0,Q.jsx)(F,{children:(0,Q.jsx)(A,{children:s?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(j,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>G[e.id]),r=G[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":R===e.id?`step`:void 0,onClick:()=>z(e.id),className:v(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,R===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,className:v(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Ne,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),q[e.id]&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:q[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":ce.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(b,{as:`h3`,variant:`heading`,children:ce.question}),R===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:s,onChange:ue}),R===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Te,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:s,onValueChange:e=>{S(e===`matching`),w(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(st,{value:`every`,selected:!x,disabled:s,children:(0,Q.jsx)(ht,{title:B?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:s,children:(0,Q.jsx)(ht,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),x&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(De,{label:`Conditions`,rule:_,facts:le(h),options:{...a(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},te)}),W&&(0,Q.jsx)(I,{variant:`warning`,children:W}),!r?.outsiderPullRequestsGated&&ie(h,U)&&(0,Q.jsx)(I,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!s&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),R===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[B?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(Te,{"aria-label":`Board`,value:T,disabled:s,onValueChange:e=>{typeof e==`string`&&e!==T&&(E(e),O(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===T,disabled:s,children:(0,Q.jsxs)(b,{as:`span`,variant:`label`,tone:`ink`,children:[c(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(Te,{"aria-label":`Phase`,value:H?.id??null,disabled:s,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:V&&re.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===H?.id,disabled:s,onClick:()=>{O(e.id),z(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Se,{stage:e.id,kind:xe(V.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:l(V,e.id)})]})},e.id))})]})]}),R===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Ce,{value:oe,maxLength:lt,disabled:s,onChange:e=>L(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(gt,{label:`When`,children:q.trigger}),(0,Q.jsx)(gt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ze,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),q.conditions]})}),(0,Q.jsx)(gt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(je,{className:`size-icon-sm`,"aria-hidden":!0}),` `,q.action]})})]})]})]}),d&&(0,Q.jsx)(I,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(P,{variant:`ghost`,onClick:p,children:s?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(P,{variant:`default`,onClick:()=>z($[K-1].id),children:`Back`}),!s&&(R===`review`||r&&se?(0,Q.jsx)(P,{variant:`primary`,disabled:!se||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(P,{variant:`primary`,disabled:!G[R],onClick:()=>z($[K+1]?.id??`review`),children:`Continue`}))]})]})})}function ht({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function gt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,children:t})]})}function _t({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(I,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),_e.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=Y(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ot,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(ht,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ct,{})})]},r)})})]},r.title))]})}function vt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ve,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(P,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(S,{to:r}),children:`Show all`})]})}var yt=v(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function bt({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:a,skips:o,footer:s,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=de(t,e),w=fe(e),T=ve(e),E=H({min:0,max:t.length-1,onDrop:m}),D=a&&t.length>1&&!d,O=s??(t.length?`Otherwise, the card stays where it is`:u?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":x.label,className:v(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!u&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`h3`,variant:`label`,tone:`ink`,children:x.label}),x.githubOnly&&(0,Q.jsx)(ct,{})]}),x.description&&(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:x.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${x.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((s,u)=>{if(d&&!d.has(s.id))return null;let p=me(t,e,u),S=p>=0,O=!s.enabled||S,k=E.drag?.from===u,A=o?.get(s.id),j=r.find(e=>e.id===(s.target.moveToBoardKey??s.target.boardKey)),M=!pe(s.name,[x.label,be(s.when,i),j&&c(j),l(j,s.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":s.name,"data-drop":E.dropAt(u),style:k?{transform:`translateY(${E.drag?.offset??0}px)`}:void 0,onPointerDown:D?e=>E.onPointerDown(e,u):void 0,className:v(`group/rule flex flex-col`,yt,k&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${s.name}`,onClick:()=>f(s,`conditions`),onKeyDown:D?e=>E.onKeyDown(e,u):void 0,className:v(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,O?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:v(D&&`pointer-fine:group-hover/rule:hidden`,k&&`hidden`),children:u+1}),D&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:v(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,k&&`flex`),children:(0,Q.jsx)(z,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[M&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:s.name}),(0,Q.jsx)(Qe,{when:s.when,options:i,everything:T})]})]}),D&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(te,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:v(`flex min-w-0 items-center`,O&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:v(`h-px w-8 shrink-0`,O?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${s.name} moves the card`,onClick:()=>f(s,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:s.target.moveToBoardKey??s.target.boardKey,phaseKey:s.target.phaseKey})})]}),a&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${s.name} on`,checked:s.enabled,onCheckedChange:e=>h(s,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(P,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${s.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(s),children:[(0,Q.jsx)(Ye,{}),`Delete rule`]})})]})]})]})]}),O&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,T.toLowerCase(),`.`]}):`Off, skipped`}),s.problems.map(e=>(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),A&&(0,Q.jsx)(St,{skips:A}),ue(s,e)&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,a&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(s),className:`underline`,children:`Let outside authors match`})]}),q(s,e)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),w&&ye(s)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:Y(`work_item.created`).label}),u!==C&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},s.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[C<0&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(ne,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),a&&(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(qe,{}),onClick:p,children:`Add rule`})]})]}),u]})]})}function xt(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function St({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,xt(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Ct=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function wt(e){return e instanceof w&&e.code!==void 0&&Ct.has(e.code)}function Tt(e){return wt(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Et({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(p,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(I,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(Dt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(I,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=se(e,t.id),i=G(e),s=V(e),c=re(e),d=W(e),[f,m]=(0,Z.useState)(),h=(0,Z.useRef)(void 0),g=e=>{h.current=e,m(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=a(t),w=(i.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===t.id&&e.target.boardKey!==t.id),T=new Map(c.data?.skipped.map(e=>[e.routeId,e])),[D]=x(),k=D.get(`into`)??void 0,A=D.has(E),j=A||k!==void 0,M=j&&i.data?u(i.data.intakeRoutes,{key:t.id,initialPhase:t.initialPhase}):void 0,N=M&&new Set((A?M.leaving:M.into.get(k??``)??[]).map(e=>e.id)),P=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(p,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(I,{variant:`destructive`,children:`This board’s rules didn’t load.`});let F=e=>d.mutateAsync(e).catch(e=>L.error(Tt(e))),ee=(e,n,r)=>{let i=J(y,e).map(e=>e.id);F([{kind:`reorder`,boardKey:t.id,ids:o(y,i,n,r)}])},R=e=>{v(void 0),g(e)},z=async e=>{let n=h.current,r=n?.rule,i=()=>n!==void 0&&h.current===n;v(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[n]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ne(n,e.on).catch(e=>L.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return te(r);v(Tt(e))}},te=async e=>{let t=h.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&h.current===t&&(n?(g({...t,rule:n}),v(`Someone else changed this rule first. It now shows their version; make your change again.`)):(g(void 0),L.error(`Someone else deleted this rule first.`)))},ne=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),s=a.indexOf(e.id),c=n.flatMap(t=>{let n=J(i,t),r=n[me(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),l=Math.min(...c);s<0||!(l<s)||await d.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:o(i,a,s,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:he(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(I,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),j&&(0,Q.jsx)(vt,{count:N?.size,into:A||!k?`other boards`:l(t,k)??k,leaving:A,showAll:O(e,t.id)}),_e.filter(e=>e.events.some(e=>P([...J(y,e),...J(w,e)]))).map(r=>(0,Q.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.some(fe)?s.data&&(0,Q.jsx)(nt,{factoryId:e,boardKey:t.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Only cards already on this board; other boards never see them.`})]}),r.events.map(r=>{let i=fe(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return P([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?B:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:r,step:`conditions`}),onMove:(e,t)=>ee(r,e,t),onToggle:(e,t)=>void F([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void F([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&L.success(`Deleted “${e.name}”`)),onUngate:e=>void F([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&L.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),f&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!S,saving:d.isPending,error:_,onSave:e=>void z(e),onClose:()=>g(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=s(),a=d()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,u=C(e.id,a).data?.board,p=i({breadcrumbs:l&&u?(0,Q.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(t,{as:S,to:T(e.id,a),children:u.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(f,{variant:`narrow`,header:(0,Q.jsxs)(`div`,{className:v(Ot,`pb-8`),children:[(0,Q.jsxs)(r,{children:[(0,Q.jsx)(r.Title,{children:`Rules`}),(0,Q.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...p,children:(0,Q.jsx)(`div`,{className:Ot,children:(0,Q.jsx)(Et,{factoryId:e.id,boardId:a})})})}export{kt as BoardRulesPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,f as r,i,k as a,n as o,s}from"./IconChevronRightMedium.es-BjSIsine.js";import{Kn as c,Pi as l,m as u,s as d}from"./Notice-BhWgws6f-kmCorboO.js";import{a as f,i as p,o as m,r as h}from"./request-jghBar6W.js";import{t as g}from"./IconPlusMedium.es-QmObHPf-.js";import{a as _,c as v,d as y,i as b,l as x,s as S,u as C}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";import{t as ee}from"./IconUser.es-8QnHQfy-.js";import{t as te}from"./IconCircleCheck.es-e9o_0ikv.js";import{D as ne,O as re,S as ie,b as w,x as T}from"./ruleLanes-B980Mi2c.js";import{m as ae}from"./useIntakeRoutes-CnY3Cu0c.js";import{t as oe}from"./createLucideIcon-B6gALBEh.js";import{a as E,r as D,t as se}from"./TrashIcon.es-DNb97Rim.js";import{d as ce,o as le,r as ue}from"./useLinearData-DMaNerAn.js";import{t as de}from"./input-DqReKX0A-De875Vkf.js";import{t as fe}from"./IconUserDuo.es-X0H45vYw.js";import{Dn as pe,Ln as O,Rn as k,gr as me,hr as he,wn as ge,yr as _e}from"./index-Du9_RN46.js";import{t as ve}from"./IconMerged.es-BudaK6HC.js";import{t as ye}from"./IconHashtag.es-DPNqJOUe.js";import{t as A}from"./IconPlugin1.es-cRNReen7.js";import{t as j}from"./IconShieldCheck.es-vPJGxBAr.js";var M={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};M.node;var be=oe(M);function xe({factoryProjectId:e,repositories:t=[],bindings:n=[],linearProjects:r=[],linearTeams:i=[],jiraProjects:a=[]}){let o=t=>new Set(n.filter(n=>n.integrationId===t&&n.factoryProjectId===e).map(e=>e.sourceId)),s=o(`linear`),c=o(`jira`),l=[...t.map(e=>({value:e.slug,provider:e.provider??`github`})),...r.filter(e=>s.has(e.id)).flatMap(e=>e.teams.map(e=>({value:e.key,provider:`linear`}))),...i.filter(e=>s.has(ce(e))).map(e=>({value:e.key,provider:`linear`})),...a.filter(e=>c.has(e.id)).map(e=>({value:e.key,provider:`jira`}))],u=new Set;return l.filter(e=>{let t=`${e.provider}\0${e.value.toLowerCase()}`;return!u.has(t)&&(u.add(t),!0)})}var Se=e=>`provider`in e&&typeof e.provider==`string`;function Ce(e,t){if(!Array.isArray(e.suggestions))return e;let n=me(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Se(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}function we(e){let t=d(e),n=u(),r=t=>(n.data??[]).some(n=>n.integrationId===t&&n.factoryProjectId===e),i=ue(r(`linear`)),a=le(r(`linear`)),o=pe(r(`jira`));return xe({factoryProjectId:e,repositories:t.data?.repositories,bindings:n.data,linearProjects:i.data?.projects,linearTeams:a.data?.teams,jiraProjects:o.data})}var N=t(),P=`flex h-control-sm w-14 shrink-0 items-center`;function F({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-lines`,className:n(`flex flex-col gap-2`,e),...t})}function I({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line`,className:n(`flex items-start gap-2`,e),...t})}function L({className:e,children:t,...r}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:n(P,i({variant:`caption`,tone:`muted`}),e),...r,children:t})}function Te({value:e,onValueChange:t,"aria-label":n=`Match all or any`}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-logic`,className:P,children:(0,N.jsxs)(h,{value:e,onValueChange:e=>e&&t(e),children:[(0,N.jsx)(m,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,N.jsx)(`span`,{className:i({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,N.jsxs)(p,{children:[(0,N.jsx)(f,{value:`AND`,children:`and`}),(0,N.jsx)(f,{value:`OR`,children:`or`})]})]})})}function R({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-content`,className:n(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function Ee({depth:e,className:t,...r}){return(0,N.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:n(`flex min-w-0 flex-1 items-start gap-2 rounded-lg border border-border p-2`,e%2==0?`bg-fill-subtle`:`bg-card`,`[&>[data-slot=rule-lines]]:min-w-0 [&>[data-slot=rule-lines]]:flex-1`,t),...r})}function De({className:e,...t}){return(0,N.jsx)(l,{variant:`ghost`,size:`icon-sm`,className:n(`ml-auto`,e),...t,children:(0,N.jsx)(c,{})})}function Oe({className:e,children:t,...r}){return(0,N.jsxs)(l,{variant:`ghost`,size:`sm`,className:n(`ml-auto`,e),...r,children:[(0,N.jsx)(se,{}),t]})}function ke({className:e,...t}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-hint`,className:n(i({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function z({icon:e,className:t,children:r,...a}){return(0,N.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:n(i({variant:`caption`,tone:`muted`}),`inline-flex h-control-sm items-center gap-1.5 rounded-full border border-dashed border-border px-3 hover:border-border-strong hover:text-foreground [&_svg]:size-icon-sm`,s,t),...a,children:[e,r]})}var Ae=r(`IconColumns3`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M18 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V6C20 4.89543 19.1046 4 18 4Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M9.33984 4V20`,stroke:`currentColor`,strokeWidth:`2`}),(0,N.jsx)(`path`,{d:`M14.6602 4V20`,stroke:`currentColor`,strokeWidth:`2`})]})),je=r(`IconFontStyle`,()=>(0,N.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M19.4639 19H20C20.5523 19 21 19.4477 21 20C21 20.5523 20.5523 21 20 21H14.5C13.9477 21 13.5 20.5523 13.5 20C13.5 19.4477 13.9477 19 14.5 19H15.2578L13.9551 15H8.15625L6.85449 19H7.5C8.05228 19 8.5 19.4477 8.5 20C8.5 20.5523 8.05228 21 7.5 21H4.5C3.94772 21 3.5 20.5523 3.5 20C3.5 19.4477 3.94772 19 4.5 19H4.75L9.29418 5.04203C9.69064 3.82426 10.8258 3 12.1065 3C13.3871 3 14.5223 3.82418 14.9188 5.04188L19.4639 19ZM8.80762 13H13.3037L11.3409 6.97096C11.251 6.69479 10.8603 6.69479 10.7704 6.97096L8.80762 13Z`,fill:`currentColor`})),Me=r(`IconZap`,()=>(0,N.jsx)(`path`,{d:`M19.5657 9H13.5C13.2239 9 13 8.77614 13 8.5V2.40139C13 1.90668 12.3584 1.71242 12.084 2.12404L4.01823 14.2226C3.79672 14.5549 4.03491 15 4.43426 15H10.5C10.7761 15 11 15.2239 11 15.5V21.5986C11 22.0933 11.6416 22.2876 11.916 21.876L19.9818 9.77735C20.2033 9.44507 19.9651 9 19.5657 9Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),B=e(a(),1),V=new Set([`exists`,`not_exists`]),H=new Set([`in`,`not_in`]),U=e=>`items`in e,Ne=0,W=()=>`condition-${++Ne}`,G=()=>({key:W(),field:``,operator:``}),Pe=e=>e+2<=3;function Fe(e){let t=e=>`conditions`in e?{key:W(),logic:e.operator,items:e.conditions.map(t)}:{key:W(),field:e.field,operator:e.operator,value:e.value};return{key:`root`,logic:e?.operator??`AND`,items:e?.conditions.map(t)??[]}}var Ie=e=>ae.some(t=>t===e);function Le(e){if(!e.field)return!1;if(V.has(e.operator))return!0;let{value:t}=e;return t===void 0?!1:Array.isArray(t)?t.length>0:typeof t!=`string`||t.trim()!==``}function K(e){let t=!1,n=e=>{if(U(e)){let t=e.items.map(n).filter(e=>e!==void 0);return t.length>0?{operator:e.logic,conditions:t}:void 0}let{operator:r}=e;if(!Ie(r)||!Le(e))t=!0;else return V.has(r)?{field:e.field,operator:r}:{field:e.field,operator:r,value:e.value}},r=e.items.map(n).filter(e=>e!==void 0);return{rule:r.length>0?{operator:e.logic,conditions:r}:null,incomplete:t}}function q(e,t,n){if(!V.has(t))return e.type===`boolean`?typeof n!=`boolean`||n:H.has(t)?Array.isArray(n)?n:n===void 0||n===``?[]:[n]:Array.isArray(n)?n[0]:n}var Re=r(`IconListAdd`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M4 6H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 12H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M15 15L21 15`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M18 12V18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 18H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),ze={"item.labels":ge,"item.title":je,"item.author":ee,"item.key":ye,"item.state":E,"item.assignees":fe,"item.pullRequest":D,"item.trusted":j,"pullRequest.trusted":j,"source.kind":D,"source.integration":A,"source.provider":A,"source.repository":be,"pullRequest.closesIssue":ve,"closedIssue.phase":Ae,"closedIssue.hasPullRequest":D,"event.type":Me,"event.reason":te},Be=re();function J(e,t){return e?.operatorLabels?.[t]??w.find(e=>e.id===t)?.label??t}function Y(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Ve({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let s=ie(n,r),[c,l]=(0,B.useState)(()=>Fe(t)),{rule:u,incomplete:d}=K(c),f=_e(u);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,N.jsx)(X,{role:`group`,"aria-label":e,group:c,depth:0,fields:s,emptyHint:i,onChange:e=>{l(e);let{rule:t,incomplete:n}=K(e);a(t,n)}}),d&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),f&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:f})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:c}){let l=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),u=e=>s({...n,items:[...n.items,e]}),d=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(z,{icon:(0,N.jsx)(g,{}),onClick:()=>u(G()),children:`Add condition`}),Pe(r)&&(0,N.jsx)(z,{icon:(0,N.jsx)(Re,{}),onClick:()=>u({key:W(),logic:n.logic===`AND`?`OR`:`AND`,items:[G()]}),children:`Add group`}),c&&(0,N.jsx)(Oe,{onClick:c,children:`Remove group`})]});if(n.items.length===0)return(0,N.jsx)(F,{role:e,"aria-label":t,children:(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{children:`Where`}),(0,N.jsxs)(R,{children:[d,o&&(0,N.jsx)(ke,{children:o})]})]})});let f=n.logic===`AND`?`and`:`or`,p=he(n.logic,a,n.items.filter(e=>!U(e)));return(0,N.jsxs)(F,{role:e,"aria-label":t,children:[n.items.map((e,t)=>(0,N.jsxs)(I,{children:[t===1?(0,N.jsx)(Te,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,N.jsx)(L,{children:t===0?`Where`:f}),U(e)?(0,N.jsx)(Ee,{depth:r,"aria-label":e.logic===`AND`?`All of these`:`Any of these`,children:(0,N.jsx)(X,{group:e,depth:r+1,fields:i,limits:p,onChange:e=>l(t,e.items.length>0?e:void 0),onRemove:()=>l(t,void 0)})}):(0,N.jsx)(He,{row:e,fields:i,limits:p.filter(t=>t!==e),onChange:e=>l(t,e),onRemove:()=>l(t,void 0)})]},e.key)),(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{}),(0,N.jsx)(R,{children:d})]})]})}function Z({id:e}){let t=ze[e]??E;return(0,N.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function He({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=Be.find(t=>t.id===e.field),s=a&&!t.some(e=>e.id===a.id)?[a,...t]:t,c=s.find(t=>t.id===e.field),l=c&&Ce(c,n),u=!!l&&ne(l.id)&&(!e.operator||e.operator===`exists`||e.operator===`not_exists`);return(0,N.jsxs)(R,{children:[(0,N.jsxs)(h,{value:e.field||null,onValueChange:t=>{let n=s.find(e=>e.id===t);if(!n)return;let i=n.operators?.[0]??`equals`;r({...e,field:n.id,operator:i,value:q(n,i,void 0)})},children:[(0,N.jsx)(m,{size:`sm`,"aria-label":`Field`,className:`w-fit max-w-full`,children:(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[l&&(0,N.jsx)(Z,{id:l.id}),(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`truncate`,children:l?.label??(e.field||`Choose a field`)})]})}),(0,N.jsx)(p,{children:s.map(e=>(0,N.jsx)(f,{value:e.id,children:(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(Z,{id:e.id}),e.label]})},e.id))})]}),l?.type===`boolean`&&(0,N.jsx)(Ue,{row:e,field:l,onChange:r}),l&&u&&(0,N.jsx)(We,{row:e,field:l,onChange:r}),l&&l.type!==`boolean`&&!u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(h,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:q(l,t,e.value)}),children:[(0,N.jsx)(m,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,children:J(l,e.operator)})}),(0,N.jsx)(p,{children:(l.operators??[]).map(e=>(0,N.jsx)(f,{value:e,children:J(l,e)},e))})]}),!V.has(e.operator)&&(0,N.jsx)(Ge,{row:e,field:l,onChange:r})]}),(0,N.jsx)(De,{"aria-label":`Remove condition`,onClick:i})]})}function Ue({row:e,field:t,onChange:n}){let r=Y(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],i=e.operator!==`not_equals`==(e.value!==!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsx)(O,{size:`sm`,"aria-label":t.label,value:String(i),onValueChange:t=>n({...e,operator:`equals`,value:t===`true`}),children:r.map(e=>(0,N.jsx)(k,{value:e.value,children:e.label},e.value))})]})}function We({row:e,field:t,onChange:n}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsxs)(O,{size:`sm`,"aria-label":t.label,value:e.operator===`not_exists`?`false`:`true`,onValueChange:t=>n({...e,operator:t===`true`?`exists`:`not_exists`,value:void 0}),children:[(0,N.jsx)(k,{value:`true`,children:`Yes`}),(0,N.jsx)(k,{value:`false`,children:`No`})]})]})}function Ge({row:e,field:t,onChange:n}){let r=Y(t),i=H.has(e.operator),a=w.find(t=>t.id===e.operator)?.freeText===!0;if(t.strict===!1&&!a){let a=Array.isArray(e.value)?e.value.map(String):e.value===void 0?[]:[String(e.value)];return(0,N.jsx)(qe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:T[t.id]??`Search or type a value`,onChange:t=>n({...e,value:i?t:t[0]})})}if(r&&i){let t=Array.isArray(e.value)?e.value.map(String):[];return(0,N.jsx)(Ke,{options:r.map(e=>({value:e.value,label:e.label??e.value})),values:t,onChange:t=>n({...e,value:t})})}if(r){let t=r.find(t=>t.value===String(e.value??``));return(0,N.jsxs)(h,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,N.jsx)(m,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,N.jsx)(p,{children:r.map(e=>(0,N.jsx)(f,{value:e.value,children:e.label},e.value))})]})}return(0,N.jsx)(Je,{row:e,field:t,many:i,onChange:n})}function Q(e){return e.length===0?`Choose values`:e.length>3?`${e.slice(0,2).join(`, `)} +${e.length-2}`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Ke({options:e,values:t,onChange:r}){let i=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),a=[...e,...i.filter(t=>!e.includes(t))],s=i.map(e=>e.label);return(0,N.jsxs)(x,{multiple:!0,autoHighlight:!0,items:a,value:i,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>r(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:s.join(`, `),className:`w-fit max-w-64`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,s.length===0&&`text-muted-foreground`),children:Q(s)})}),(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:`Search`}),(0,N.jsx)(_,{children:`No option found.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]})]})}function qe({options:e,values:t,many:r,placeholder:i,onChange:a}){let[s,c]=(0,B.useState)(``),l=s.trim(),u=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),d=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),f=[...e,...d.filter(t=>!e.includes(t)),...l&&!u(l)&&!t.includes(l)?[{value:l,label:`Use “${l}”`}]:[]],p=d.map(e=>e.value),m={autoHighlight:!0,items:f,inputValue:s,onInputValueChange:c,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},h=(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:i}),(0,N.jsx)(_,{children:`Type a value to use it.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]}),g=(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,p.length===0&&`text-muted-foreground`),children:p.length===0?i:Q(p)});return r?(0,N.jsxs)(x,{...m,multiple:!0,value:d,onValueChange:e=>a(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:p.join(`, `),className:`w-fit max-w-64`,children:g}),h]}):(0,N.jsxs)(x,{...m,value:d[0]??null,onValueChange:e=>e&&a([e.value]),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Value`,title:p[0],className:`w-fit max-w-64`,children:g}),h]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Je({row:e,field:t,many:n,onChange:r}){let[i,a]=(0,B.useState)(),o=i??$(e.value),s=()=>{if(i===void 0||(a(void 0),i===$(e.value)))return;if(n){let t=i.split(`,`).map(e=>e.trim());r({...e,value:t.filter(e=>e!==``)});return}if(t.type!==`number`){r({...e,value:i.trim()});return}let o=Number(i.trim());r({...e,value:i.trim()!==``&&Number.isFinite(o)?o:void 0})};return(0,N.jsx)(de,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:T[t.id]??(n?`Values, comma separated`:`Value`),value:o,className:`w-48`,onChange:e=>a(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&a(void 0)}})}export{we as n,Ve as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,f as r,i,k as a,n as o,s}from"./IconChevronRightMedium.es-BjSIsine.js";import{Kn as c,Pi as l,m as u,s as d}from"./Notice-BhWgws6f-kmCorboO.js";import{a as f,i as p,o as m,r as h}from"./request-jghBar6W.js";import{t as g}from"./IconPlusMedium.es-QmObHPf-.js";import{a as _,c as v,d as y,i as b,l as x,s as S,u as C}from"./combobox-parts-Bmj5kzrt-lle2E3sF.js";import{t as ee}from"./IconUser.es-8QnHQfy-.js";import{t as te}from"./IconCircleCheck.es-e9o_0ikv.js";import{D as ne,O as re,S as ie,b as w,x as T}from"./ruleLanes-B980Mi2c.js";import{m as ae}from"./useIntakeRoutes-CnY3Cu0c.js";import{t as oe}from"./createLucideIcon-B6gALBEh.js";import{a as E,r as D,t as se}from"./TrashIcon.es-DNb97Rim.js";import{d as ce,o as le,r as ue}from"./useLinearData-DMaNerAn.js";import{t as de}from"./input-DqReKX0A-De875Vkf.js";import{t as fe}from"./IconUserDuo.es-X0H45vYw.js";import{Dn as pe,Ln as O,Rn as k,gr as me,hr as he,wn as ge,yr as _e}from"./index-BP3ua7KI.js";import{t as ve}from"./IconMerged.es-BudaK6HC.js";import{t as ye}from"./IconHashtag.es-DPNqJOUe.js";import{t as A}from"./IconPlugin1.es-cRNReen7.js";import{t as j}from"./IconShieldCheck.es-vPJGxBAr.js";var M={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};M.node;var be=oe(M);function xe({factoryProjectId:e,repositories:t=[],bindings:n=[],linearProjects:r=[],linearTeams:i=[],jiraProjects:a=[]}){let o=t=>new Set(n.filter(n=>n.integrationId===t&&n.factoryProjectId===e).map(e=>e.sourceId)),s=o(`linear`),c=o(`jira`),l=[...t.map(e=>({value:e.slug,provider:e.provider??`github`})),...r.filter(e=>s.has(e.id)).flatMap(e=>e.teams.map(e=>({value:e.key,provider:`linear`}))),...i.filter(e=>s.has(ce(e))).map(e=>({value:e.key,provider:`linear`})),...a.filter(e=>c.has(e.id)).map(e=>({value:e.key,provider:`jira`}))],u=new Set;return l.filter(e=>{let t=`${e.provider}\0${e.value.toLowerCase()}`;return!u.has(t)&&(u.add(t),!0)})}var Se=e=>`provider`in e&&typeof e.provider==`string`;function Ce(e,t){if(!Array.isArray(e.suggestions))return e;let n=me(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Se(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}function we(e){let t=d(e),n=u(),r=t=>(n.data??[]).some(n=>n.integrationId===t&&n.factoryProjectId===e),i=ue(r(`linear`)),a=le(r(`linear`)),o=pe(r(`jira`));return xe({factoryProjectId:e,repositories:t.data?.repositories,bindings:n.data,linearProjects:i.data?.projects,linearTeams:a.data?.teams,jiraProjects:o.data})}var N=t(),P=`flex h-control-sm w-14 shrink-0 items-center`;function F({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-lines`,className:n(`flex flex-col gap-2`,e),...t})}function I({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line`,className:n(`flex items-start gap-2`,e),...t})}function L({className:e,children:t,...r}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:n(P,i({variant:`caption`,tone:`muted`}),e),...r,children:t})}function Te({value:e,onValueChange:t,"aria-label":n=`Match all or any`}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-logic`,className:P,children:(0,N.jsxs)(h,{value:e,onValueChange:e=>e&&t(e),children:[(0,N.jsx)(m,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,N.jsx)(`span`,{className:i({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,N.jsxs)(p,{children:[(0,N.jsx)(f,{value:`AND`,children:`and`}),(0,N.jsx)(f,{value:`OR`,children:`or`})]})]})})}function R({className:e,...t}){return(0,N.jsx)(`div`,{"data-slot":`rule-line-content`,className:n(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function Ee({depth:e,className:t,...r}){return(0,N.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:n(`flex min-w-0 flex-1 items-start gap-2 rounded-lg border border-border p-2`,e%2==0?`bg-fill-subtle`:`bg-card`,`[&>[data-slot=rule-lines]]:min-w-0 [&>[data-slot=rule-lines]]:flex-1`,t),...r})}function De({className:e,...t}){return(0,N.jsx)(l,{variant:`ghost`,size:`icon-sm`,className:n(`ml-auto`,e),...t,children:(0,N.jsx)(c,{})})}function Oe({className:e,children:t,...r}){return(0,N.jsxs)(l,{variant:`ghost`,size:`sm`,className:n(`ml-auto`,e),...r,children:[(0,N.jsx)(se,{}),t]})}function ke({className:e,...t}){return(0,N.jsx)(`span`,{"data-slot":`rule-line-hint`,className:n(i({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function z({icon:e,className:t,children:r,...a}){return(0,N.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:n(i({variant:`caption`,tone:`muted`}),`inline-flex h-control-sm items-center gap-1.5 rounded-full border border-dashed border-border px-3 hover:border-border-strong hover:text-foreground [&_svg]:size-icon-sm`,s,t),...a,children:[e,r]})}var Ae=r(`IconColumns3`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M18 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V6C20 4.89543 19.1046 4 18 4Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M9.33984 4V20`,stroke:`currentColor`,strokeWidth:`2`}),(0,N.jsx)(`path`,{d:`M14.6602 4V20`,stroke:`currentColor`,strokeWidth:`2`})]})),je=r(`IconFontStyle`,()=>(0,N.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M19.4639 19H20C20.5523 19 21 19.4477 21 20C21 20.5523 20.5523 21 20 21H14.5C13.9477 21 13.5 20.5523 13.5 20C13.5 19.4477 13.9477 19 14.5 19H15.2578L13.9551 15H8.15625L6.85449 19H7.5C8.05228 19 8.5 19.4477 8.5 20C8.5 20.5523 8.05228 21 7.5 21H4.5C3.94772 21 3.5 20.5523 3.5 20C3.5 19.4477 3.94772 19 4.5 19H4.75L9.29418 5.04203C9.69064 3.82426 10.8258 3 12.1065 3C13.3871 3 14.5223 3.82418 14.9188 5.04188L19.4639 19ZM8.80762 13H13.3037L11.3409 6.97096C11.251 6.69479 10.8603 6.69479 10.7704 6.97096L8.80762 13Z`,fill:`currentColor`})),Me=r(`IconZap`,()=>(0,N.jsx)(`path`,{d:`M19.5657 9H13.5C13.2239 9 13 8.77614 13 8.5V2.40139C13 1.90668 12.3584 1.71242 12.084 2.12404L4.01823 14.2226C3.79672 14.5549 4.03491 15 4.43426 15H10.5C10.7761 15 11 15.2239 11 15.5V21.5986C11 22.0933 11.6416 22.2876 11.916 21.876L19.9818 9.77735C20.2033 9.44507 19.9651 9 19.5657 9Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),B=e(a(),1),V=new Set([`exists`,`not_exists`]),H=new Set([`in`,`not_in`]),U=e=>`items`in e,Ne=0,W=()=>`condition-${++Ne}`,G=()=>({key:W(),field:``,operator:``}),Pe=e=>e+2<=3;function Fe(e){let t=e=>`conditions`in e?{key:W(),logic:e.operator,items:e.conditions.map(t)}:{key:W(),field:e.field,operator:e.operator,value:e.value};return{key:`root`,logic:e?.operator??`AND`,items:e?.conditions.map(t)??[]}}var Ie=e=>ae.some(t=>t===e);function Le(e){if(!e.field)return!1;if(V.has(e.operator))return!0;let{value:t}=e;return t===void 0?!1:Array.isArray(t)?t.length>0:typeof t!=`string`||t.trim()!==``}function K(e){let t=!1,n=e=>{if(U(e)){let t=e.items.map(n).filter(e=>e!==void 0);return t.length>0?{operator:e.logic,conditions:t}:void 0}let{operator:r}=e;if(!Ie(r)||!Le(e))t=!0;else return V.has(r)?{field:e.field,operator:r}:{field:e.field,operator:r,value:e.value}},r=e.items.map(n).filter(e=>e!==void 0);return{rule:r.length>0?{operator:e.logic,conditions:r}:null,incomplete:t}}function q(e,t,n){if(!V.has(t))return e.type===`boolean`?typeof n!=`boolean`||n:H.has(t)?Array.isArray(n)?n:n===void 0||n===``?[]:[n]:Array.isArray(n)?n[0]:n}var Re=r(`IconListAdd`,()=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`path`,{d:`M4 6H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 12H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M15 15L21 15`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M18 12V18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,N.jsx)(`path`,{d:`M4 18H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),ze={"item.labels":ge,"item.title":je,"item.author":ee,"item.key":ye,"item.state":E,"item.assignees":fe,"item.pullRequest":D,"item.trusted":j,"pullRequest.trusted":j,"source.kind":D,"source.integration":A,"source.provider":A,"source.repository":be,"pullRequest.closesIssue":ve,"closedIssue.phase":Ae,"closedIssue.hasPullRequest":D,"event.type":Me,"event.reason":te},Be=re();function J(e,t){return e?.operatorLabels?.[t]??w.find(e=>e.id===t)?.label??t}function Y(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Ve({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let s=ie(n,r),[c,l]=(0,B.useState)(()=>Fe(t)),{rule:u,incomplete:d}=K(c),f=_e(u);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,N.jsx)(X,{role:`group`,"aria-label":e,group:c,depth:0,fields:s,emptyHint:i,onChange:e=>{l(e);let{rule:t,incomplete:n}=K(e);a(t,n)}}),d&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),f&&(0,N.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:f})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:c}){let l=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),u=e=>s({...n,items:[...n.items,e]}),d=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(z,{icon:(0,N.jsx)(g,{}),onClick:()=>u(G()),children:`Add condition`}),Pe(r)&&(0,N.jsx)(z,{icon:(0,N.jsx)(Re,{}),onClick:()=>u({key:W(),logic:n.logic===`AND`?`OR`:`AND`,items:[G()]}),children:`Add group`}),c&&(0,N.jsx)(Oe,{onClick:c,children:`Remove group`})]});if(n.items.length===0)return(0,N.jsx)(F,{role:e,"aria-label":t,children:(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{children:`Where`}),(0,N.jsxs)(R,{children:[d,o&&(0,N.jsx)(ke,{children:o})]})]})});let f=n.logic===`AND`?`and`:`or`,p=he(n.logic,a,n.items.filter(e=>!U(e)));return(0,N.jsxs)(F,{role:e,"aria-label":t,children:[n.items.map((e,t)=>(0,N.jsxs)(I,{children:[t===1?(0,N.jsx)(Te,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,N.jsx)(L,{children:t===0?`Where`:f}),U(e)?(0,N.jsx)(Ee,{depth:r,"aria-label":e.logic===`AND`?`All of these`:`Any of these`,children:(0,N.jsx)(X,{group:e,depth:r+1,fields:i,limits:p,onChange:e=>l(t,e.items.length>0?e:void 0),onRemove:()=>l(t,void 0)})}):(0,N.jsx)(He,{row:e,fields:i,limits:p.filter(t=>t!==e),onChange:e=>l(t,e),onRemove:()=>l(t,void 0)})]},e.key)),(0,N.jsxs)(I,{children:[(0,N.jsx)(L,{}),(0,N.jsx)(R,{children:d})]})]})}function Z({id:e}){let t=ze[e]??E;return(0,N.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function He({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=Be.find(t=>t.id===e.field),s=a&&!t.some(e=>e.id===a.id)?[a,...t]:t,c=s.find(t=>t.id===e.field),l=c&&Ce(c,n),u=!!l&&ne(l.id)&&(!e.operator||e.operator===`exists`||e.operator===`not_exists`);return(0,N.jsxs)(R,{children:[(0,N.jsxs)(h,{value:e.field||null,onValueChange:t=>{let n=s.find(e=>e.id===t);if(!n)return;let i=n.operators?.[0]??`equals`;r({...e,field:n.id,operator:i,value:q(n,i,void 0)})},children:[(0,N.jsx)(m,{size:`sm`,"aria-label":`Field`,className:`w-fit max-w-full`,children:(0,N.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[l&&(0,N.jsx)(Z,{id:l.id}),(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`truncate`,children:l?.label??(e.field||`Choose a field`)})]})}),(0,N.jsx)(p,{children:s.map(e=>(0,N.jsx)(f,{value:e.id,children:(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(Z,{id:e.id}),e.label]})},e.id))})]}),l?.type===`boolean`&&(0,N.jsx)(Ue,{row:e,field:l,onChange:r}),l&&u&&(0,N.jsx)(We,{row:e,field:l,onChange:r}),l&&l.type!==`boolean`&&!u&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(h,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:q(l,t,e.value)}),children:[(0,N.jsx)(m,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,children:J(l,e.operator)})}),(0,N.jsx)(p,{children:(l.operators??[]).map(e=>(0,N.jsx)(f,{value:e,children:J(l,e)},e))})]}),!V.has(e.operator)&&(0,N.jsx)(Ge,{row:e,field:l,onChange:r})]}),(0,N.jsx)(De,{"aria-label":`Remove condition`,onClick:i})]})}function Ue({row:e,field:t,onChange:n}){let r=Y(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],i=e.operator!==`not_equals`==(e.value!==!1);return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsx)(O,{size:`sm`,"aria-label":t.label,value:String(i),onValueChange:t=>n({...e,operator:`equals`,value:t===`true`}),children:r.map(e=>(0,N.jsx)(k,{value:e.value,children:e.label},e.value))})]})}function We({row:e,field:t,onChange:n}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,N.jsxs)(O,{size:`sm`,"aria-label":t.label,value:e.operator===`not_exists`?`false`:`true`,onValueChange:t=>n({...e,operator:t===`true`?`exists`:`not_exists`,value:void 0}),children:[(0,N.jsx)(k,{value:`true`,children:`Yes`}),(0,N.jsx)(k,{value:`false`,children:`No`})]})]})}function Ge({row:e,field:t,onChange:n}){let r=Y(t),i=H.has(e.operator),a=w.find(t=>t.id===e.operator)?.freeText===!0;if(t.strict===!1&&!a){let a=Array.isArray(e.value)?e.value.map(String):e.value===void 0?[]:[String(e.value)];return(0,N.jsx)(qe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:T[t.id]??`Search or type a value`,onChange:t=>n({...e,value:i?t:t[0]})})}if(r&&i){let t=Array.isArray(e.value)?e.value.map(String):[];return(0,N.jsx)(Ke,{options:r.map(e=>({value:e.value,label:e.label??e.value})),values:t,onChange:t=>n({...e,value:t})})}if(r){let t=r.find(t=>t.value===String(e.value??``));return(0,N.jsxs)(h,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,N.jsx)(m,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,N.jsx)(p,{children:r.map(e=>(0,N.jsx)(f,{value:e.value,children:e.label},e.value))})]})}return(0,N.jsx)(Je,{row:e,field:t,many:i,onChange:n})}function Q(e){return e.length===0?`Choose values`:e.length>3?`${e.slice(0,2).join(`, `)} +${e.length-2}`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Ke({options:e,values:t,onChange:r}){let i=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),a=[...e,...i.filter(t=>!e.includes(t))],s=i.map(e=>e.label);return(0,N.jsxs)(x,{multiple:!0,autoHighlight:!0,items:a,value:i,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>r(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:s.join(`, `),className:`w-fit max-w-64`,children:(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,s.length===0&&`text-muted-foreground`),children:Q(s)})}),(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:`Search`}),(0,N.jsx)(_,{children:`No option found.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]})]})}function qe({options:e,values:t,many:r,placeholder:i,onChange:a}){let[s,c]=(0,B.useState)(``),l=s.trim(),u=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),d=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),f=[...e,...d.filter(t=>!e.includes(t)),...l&&!u(l)&&!t.includes(l)?[{value:l,label:`Use “${l}”`}]:[]],p=d.map(e=>e.value),m={autoHighlight:!0,items:f,inputValue:s,onInputValueChange:c,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},h=(0,N.jsxs)(b,{children:[(0,N.jsx)(C,{placeholder:i}),(0,N.jsx)(_,{children:`Type a value to use it.`}),(0,N.jsx)(v,{children:e=>(0,N.jsx)(S,{value:e,children:e.label},e.value)})]}),g=(0,N.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,p.length===0&&`text-muted-foreground`),children:p.length===0?i:Q(p)});return r?(0,N.jsxs)(x,{...m,multiple:!0,value:d,onValueChange:e=>a(e.map(e=>e.value)),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Values`,title:p.join(`, `),className:`w-fit max-w-64`,children:g}),h]}):(0,N.jsxs)(x,{...m,value:d[0]??null,onValueChange:e=>e&&a([e.value]),children:[(0,N.jsx)(y,{size:`sm`,"aria-label":`Value`,title:p[0],className:`w-fit max-w-64`,children:g}),h]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Je({row:e,field:t,many:n,onChange:r}){let[i,a]=(0,B.useState)(),o=i??$(e.value),s=()=>{if(i===void 0||(a(void 0),i===$(e.value)))return;if(n){let t=i.split(`,`).map(e=>e.trim());r({...e,value:t.filter(e=>e!==``)});return}if(t.type!==`number`){r({...e,value:i.trim()});return}let o=Number(i.trim());r({...e,value:i.trim()!==``&&Number.isFinite(o)?o:void 0})};return(0,N.jsx)(de,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:T[t.id]??(n?`Values, comma separated`:`Value`),value:o,className:`w-48`,onChange:e=>a(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&a(void 0)}})}export{we as n,Ve as t};