mastra 1.40.2-alpha.1 → 1.40.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/commands/deploy/env-vars.d.ts +4 -0
  2. package/dist/commands/deploy/env-vars.d.ts.map +1 -1
  3. package/dist/commands/deploy-preflight.d.ts +4 -0
  4. package/dist/commands/deploy-preflight.d.ts.map +1 -1
  5. package/dist/commands/env/env-file.d.ts +3 -2
  6. package/dist/commands/env/env-file.d.ts.map +1 -1
  7. package/dist/commands/env/platform-api.d.ts +7 -0
  8. package/dist/commands/env/platform-api.d.ts.map +1 -1
  9. package/dist/commands/env/vars.d.ts +2 -1
  10. package/dist/commands/env/vars.d.ts.map +1 -1
  11. package/dist/commands/server/env.d.ts.map +1 -1
  12. package/dist/docs/SKILL.md +1 -1
  13. package/dist/docs/assets/SOURCE_MAP.json +4 -4
  14. package/dist/docs/references/reference-cli-mastra.md +1 -1
  15. package/dist/factory/assets/{BoardConfigPage-Vqw1_TFU.js → BoardConfigPage-Dan9VyhL.js} +1 -1
  16. package/dist/factory/assets/{BoardIntakePage-CaQLaK7k.js → BoardIntakePage-BYZy_ru_.js} +1 -1
  17. package/dist/factory/assets/{BoardRulesPage-5Es0qgwm.js → BoardRulesPage-CxNhQl3d.js} +1 -1
  18. package/dist/factory/assets/Breadcrumb.es-BpvMnN1l.js +1 -0
  19. package/dist/factory/assets/{ConditionRows-aX8GWrx7.js → ConditionRows-DJVG4EHd.js} +1 -1
  20. package/dist/factory/assets/{CreateFactoryPage-CezBBj8t.js → CreateFactoryPage-CoxfdoDW.js} +1 -1
  21. package/dist/factory/assets/{FactorySkillPage-DPu6Y1-N.js → FactorySkillPage-ix3Ct4E0.js} +1 -1
  22. package/dist/factory/assets/{FactorySkillsPage-Ciuo_gJj.js → FactorySkillsPage-SPaAjjue.js} +1 -1
  23. package/dist/factory/assets/{IconScript.es-CDAStRup.js → IconScript.es-BQPM-6BN.js} +1 -1
  24. package/dist/factory/assets/{KnowledgePage-BA5xaIgz.js → KnowledgePage-nfIFPgp6.js} +1 -1
  25. package/dist/factory/assets/{MastraGatewayBilling-CwhJ_Neo.js → MastraGatewayBilling-Bpx-h8Vt.js} +1 -1
  26. package/dist/factory/assets/{NewBoardPage-C6BgDnrT.js → NewBoardPage-VIlgPMpB.js} +1 -1
  27. package/dist/factory/assets/{NewPage-D4Z6SU0F.js → NewPage-BnMyEhkh.js} +1 -1
  28. package/dist/factory/assets/{OnboardingPage-BCWo7U7q.js → OnboardingPage-CHfAWT72.js} +1 -1
  29. package/dist/factory/assets/{ProviderBrandIcon-BbR_LLqz.js → ProviderBrandIcon-C7mph6N5.js} +1 -1
  30. package/dist/factory/assets/{RulesPage-DghHIx8T.js → RulesPage-Bm395CUB.js} +1 -1
  31. package/dist/factory/assets/{SessionLayout-Btl4DaPT.js → SessionLayout-BShjmacL.js} +2 -2
  32. package/dist/factory/assets/{SessionPage-DtEfYzr_.js → SessionPage-B9E-jG8M.js} +1 -1
  33. package/dist/factory/assets/SettingsPage-BKDcpSlF.js +3 -0
  34. package/dist/factory/assets/{SlackConnectionPage-pxpgeVUI.js → SlackConnectionPage-ChNhPiV-.js} +1 -1
  35. package/dist/factory/assets/{StackedDiffs-DPV11ubY.js → StackedDiffs-BFXdSF8w.js} +1 -1
  36. package/dist/factory/assets/{Tree-B90XgTY4-D2n1lBn3.js → Tree-B90XgTY4-cZ-SkEZr.js} +1 -1
  37. package/dist/factory/assets/index-Bi7K7czv.css +1 -0
  38. package/dist/factory/assets/{index-2FxPHkSg.js → index-CD4tM4nf.js} +2 -2
  39. package/dist/factory/assets/{useDraftModelGuards-CAbjns2Y.js → useDraftModelGuards-BwRi1qov.js} +1 -1
  40. package/dist/factory/assets/{workspaces-qqYlKq58.js → workspaces-CF_kIkTd.js} +1 -1
  41. package/dist/factory/index.html +2 -2
  42. package/dist/index.js +206 -168
  43. package/dist/index.js.map +1 -1
  44. package/dist/studio/assets/{index-RNMMtS6K.js → index-B4zG_u8m.js} +2 -2
  45. package/dist/studio/assets/{main-gPGey7ps.js → main-CEtWndOQ.js} +340 -340
  46. package/dist/studio/assets/style-CW1SmVpP.css +3 -0
  47. package/dist/studio/index.html +2 -2
  48. package/package.json +4 -4
  49. package/dist/factory/assets/Breadcrumb.es-BEIE9dke.js +0 -1
  50. package/dist/factory/assets/SettingsPage-Dt_sJDlH.js +0 -3
  51. package/dist/factory/assets/index-DdzQuBQn.css +0 -1
  52. package/dist/studio/assets/style-Cnx8czOF.css +0 -3
@@ -3,6 +3,10 @@
3
3
  * vars the CLI is about to send, returns the keys whose stored value would be
4
4
  * overwritten with a different value. Keys that are new, or whose value is
5
5
  * unchanged, are not reported (they aren't destructive overwrites).
6
+ *
7
+ * Incoming write-only secret placeholders are skipped because the platform
8
+ * keeps the stored value. A real value replacing a stored (hidden) secret is
9
+ * reported: the values can't be compared, so it may be an overwrite.
6
10
  */
7
11
  export declare function getOverwrittenEnvKeys(existing: Record<string, string> | null | undefined, incoming: Record<string, string>): string[];
8
12
  //# sourceMappingURL=env-vars.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-vars.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/env-vars.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,EAAE,CAKV"}
1
+ {"version":3,"file":"env-vars.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/env-vars.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC/B,MAAM,EAAE,CAKV"}
@@ -79,6 +79,10 @@ export declare function preflightBuildOutput(targetDir: string, envVars: Record<
79
79
  * project (request wins). Preflight should see this merged picture so vars
80
80
  * stored only on the platform don't produce false MISSING_ENV_VAR /
81
81
  * LOCAL_STORAGE_PATH alarms.
82
+ *
83
+ * A local write-only secret placeholder (written by older `env vars pull`)
84
+ * makes the platform keep the stored value, so it doesn't override here.
85
+ * Stored placeholders stay: the secret is set, its value just isn't readable.
82
86
  */
83
87
  export declare function mergePreflightEnvVars(stored: Record<string, string> | null | undefined, local: Record<string, string>): Record<string, string>;
84
88
  export type PreflightOutcome = 'ok' | 'blocked' | 'cancelled';
@@ -1 +1 @@
1
- {"version":3,"file":"deploy-preflight.d.ts","sourceRoot":"","sources":["../../src/commands/deploy-preflight.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAEhG;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,yBAAyB,CAAC;IAChC,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAmGD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,GAAE;IACP;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACrC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACnB,GACL,OAAO,CAAC,cAAc,EAAE,CAAC,CA+C3B;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,cAAc,EAAE,EACxB,OAAO,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAwC3B;AAmED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAgBrD;AA8GD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GACnC,OAAO,CAIT;AAwFD;;;;;;GAMG;AACH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBvF;AAED;;;;;GAKG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,YAAY,CAA0C,CAAC;AAErG,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAO7E"}
1
+ {"version":3,"file":"deploy-preflight.d.ts","sourceRoot":"","sources":["../../src/commands/deploy-preflight.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQzD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAEhG;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,yBAAyB,CAAC;IAChC,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,gBAAgB,CAAC;CAC5B;AAmGD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,OAAO,GAAE;IACP;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACrC;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACnB,GACL,OAAO,CAAC,cAAc,EAAE,CAAC,CA+C3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACjD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,cAAc,EAAE,EACxB,OAAO,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAwC3B;AAmED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAgBrD;AAgHD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GACnC,OAAO,CAIT;AAwFD;;;;;;GAMG;AACH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBvF;AAED;;;;;GAKG;AACH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,YAAY,CAA0C,CAAC;AAErG,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAO7E"}
@@ -2,12 +2,13 @@
2
2
  * Serialize env vars into `.env` file content, quoting/escaping values so the
3
3
  * file is safe to `source` and skipping keys that aren't valid shell
4
4
  * identifiers. Managed var names (platform-injected secrets whose values are
5
- * never exposed) are listed as comments so users know they exist without
6
- * round-tripping secrets into local files.
5
+ * never exposed) and write-only secret names are listed as comments so users
6
+ * know they exist without round-tripping secrets into local files.
7
7
  */
8
8
  export declare function serializeEnvFile(envVars: Record<string, string>, opts: {
9
9
  header: string;
10
10
  managedVarNames?: string[];
11
+ secretVarNames?: string[];
11
12
  }): {
12
13
  content: string;
13
14
  written: number;
@@ -1 +1 @@
1
- {"version":3,"file":"env-file.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GACnD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAoCvD"}
1
+ {"version":3,"file":"env-file.d.ts","sourceRoot":"","sources":["../../../src/commands/env/env-file.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC9E;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA4CvD"}
@@ -33,6 +33,13 @@ export interface Environment {
33
33
  createdAt: string;
34
34
  updatedAt: string;
35
35
  }
36
+ /**
37
+ * Value the platform returns in place of a write-only secret. Sending it back
38
+ * on a save keeps the stored secret. It is a sentinel, never a real value, so
39
+ * it must not be written to env files or shown to users.
40
+ */
41
+ export declare const SECRET_VALUE_PLACEHOLDER = "__mastra_secret__";
42
+ export declare function isSecretPlaceholder(value: string | undefined): boolean;
36
43
  export type EnvironmentDeployStatus = 'queued' | 'uploading' | 'starting' | 'building' | 'deploying' | 'running' | 'sleeping' | 'stopped' | 'failed' | 'crashed' | 'cancelled' | 'unknown';
37
44
  export interface EnvironmentDeploy {
38
45
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"platform-api.d.ts","sourceRoot":"","sources":["../../../src/commands/env/platform-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEvF,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,SAAS,GACT,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,uBAAuB,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAepF;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAepH;AAED,+EAA+E;AAC/E,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAG/G;AAED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAe9B;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF,OAAO,CAAC,WAAW,CAAC,CAkBtB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAarH;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,CAAC,CAqBhC;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAgBf"}
1
+ {"version":3,"file":"platform-api.d.ts","sourceRoot":"","sources":["../../../src/commands/env/platform-api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEvF,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEtE;AAED,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,GACV,WAAW,GACX,SAAS,GACT,UAAU,GACV,SAAS,GACT,QAAQ,GACR,SAAS,GACT,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,uBAAuB,CAAC;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAepF;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAepH;AAED,+EAA+E;AAC/E,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAG/G;AAED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAe9B;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF,OAAO,CAAC,WAAW,CAAC,CAkBtB;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAarH;AAED;;;;;;;;;GASG;AACH,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,qBAAqB,CAAC,CAqBhC;AAED;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -18,7 +18,8 @@ export declare function registerEnvVarsCommands(env: Command): void;
18
18
  * project row, so that is what gets pulled. Environment rows exist but
19
19
  * nothing reads their vars.
20
20
  *
21
- * Managed vars (platform-injected secrets) are listed as comments, names only.
21
+ * Managed vars (platform-injected secrets) and write-only secrets are listed
22
+ * as comments, names only.
22
23
  */
23
24
  export declare function envVarsPullAction(envArg: string | undefined, options: {
24
25
  project?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../../src/commands/env/vars.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,iFAAiF;AACjF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAW1D;AA8BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,OAAO,CAAC,IAAI,CAAC,CA6Cf"}
1
+ {"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../../src/commands/env/vars.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,iFAAiF;AACjF,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAW1D;AA8BD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D,OAAO,CAAC,IAAI,CAAC,CA4Df"}
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/commands/server/env.ts"],"names":[],"mappings":"AAaA,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAO5F;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,IAAI,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAMD,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB5D;AAMD,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAUvF;AAMD,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAe1E;AAMD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBA6B5E;AAMD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,iBAyBxG"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/commands/server/env.ts"],"names":[],"mappings":"AAcA,wBAAsB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAO5F;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3C,IAAI,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC,OAAO,CAAC,MAAM,CAAC,CAoBjB;AAMD,wBAAsB,aAAa,CAAC,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAoB5D;AAMD,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAUvF;AAMD,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBAe1E;AAMD,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,iBA6B5E;AAMD,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,iBAqCxG"}
@@ -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.2-alpha.1"
6
+ version: "1.40.2-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.2-alpha.1",
2
+ "version": "1.40.2-alpha.2",
3
3
  "package": "mastra",
4
4
  "exports": {
5
5
  "PosthogAnalytics": {
@@ -10,7 +10,7 @@
10
10
  "analytics": {
11
11
  "types": "dist/index.d.ts",
12
12
  "implementation": "dist/index.js",
13
- "line": 40155
13
+ "line": 40193
14
14
  },
15
15
  "create": {
16
16
  "types": "dist/commands/create/create.d.ts",
@@ -20,12 +20,12 @@
20
20
  "origin": {
21
21
  "types": "dist/index.d.ts",
22
22
  "implementation": "dist/index.js",
23
- "line": 40162
23
+ "line": 40200
24
24
  },
25
25
  "version": {
26
26
  "types": "dist/index.d.ts",
27
27
  "implementation": "dist/index.js",
28
- "line": 40154
28
+ "line": 40192
29
29
  },
30
30
  "answerRelevancyScorer": {
31
31
  "types": "dist/index.d.ts",
@@ -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/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.
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, and [secrets](https://mastra.ai/docs/mastra-platform/deploy/environments) on environments where secrets are write-only, are listed as comments (names only) because their values can't be read back. Config values are written in full.
492
492
 
493
493
  ```bash
494
494
  mastra env vars pull
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-BEIE9dke.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Cr as o,D as s,E as c,Hn as l,Jn as u,Mr as d,Qn as f,Sr as p,Un as m,Xn as h,Yn as g,Zn as _,ar as v,cr as y,dn as b,dr as x,en as S,er as ee,fr as C,hr as w,jr as T,lr as E,mr as te,nn as D,nr as O,rr as k,tn as ne,tr as A,ur as j,vr as M,xr as N,yr as P}from"./index-2FxPHkSg.js";import{A as F,a as re,j as I}from"./Sidebar.es-DSPzNNju.js";import{d as ie,f as L,r as ae,t as R,u as oe}from"./settings-DAvFqX1V-D4umTesm.js";import{O as se,T as z,k as ce,n as B,s as V,t as le}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as H}from"./lib-DkXXjRNC.js";import{c as ue,o as de,r as fe,s as pe,t as me}from"./useBoardEditor-DiWa4Lcl.js";import{i as he,t as ge}from"./SkillBadges-BN_VjOtf.js";import{a as U,c as _e,f as ve,l as ye,s as be}from"./boardConfigPaths-Btimpi_r.js";import{t as W}from"./AlertDialog.es-DDAl3sXA.js";import{$n as xe,Fi as G,ga as Se,ji as Ce,lr as we,ma as Te,n as K,pa as Ee,r as De,zt as Oe}from"./GithubIcon.es-BPBhMx2H.js";import{t as q}from"./SettingsSubsection-BGJrlda9.js";import{n as ke,r as J,t as Ae}from"./settingsColumn-CrKuH8q1.js";import{n as je}from"./useBoardCatalog-vK4woIAH.js";import{h as Me,o as Ne}from"./useIntakeRoutes-CdL4o1Vv.js";import{a as Pe,d as Fe,t as Ie}from"./BoardIcons-Cml_taka.js";import{i as Le,n as Re,r as ze,t as Be}from"./IconPencil.es-C5rZ8A6j.js";import{r as Ve}from"./overlays-B3sO28Cg.js";import{t as He}from"./DescriptionMarkdown-BH7uH0Yx.js";import{h as Ue,w as We,y as Ge}from"./ruleLanes-DEg70O95.js";import{t as Ke}from"./CodeEditor-DmElSGLM-BqTClSRY.js";import{a as qe,n as Je,r as Ye,t as Xe}from"./Field.es-BPlWASZ-.js";import{t as Ze}from"./input-DqReKX0A-BMaPtvZH.js";import{a as Qe,n as $e}from"./input-group-CXvse9n7-C3ds8HOQ.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./InputNumber.es-Dvj2CMW7.js";import{c as at,d as ot,et as st,l as ct,u as lt}from"./icons-C18D46Pv.js";import{E as ut}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";import{n as dt,t as ft}from"./ConditionRows-aX8GWrx7.js";import{t as pt}from"./IconLock.es-9mYeLe9c.js";import{t as mt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as ht}from"./TrashIcon.es-CLx-KWTg.js";import{t as Y}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as gt,t as _t}from"./boardCatalog-y-s19dQU.js";import{t as vt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as yt}from"./InlineText-vWKzGKx_.js";import{t as bt}from"./LoadErrorState-CtPpeSh8.js";var X=e(ce(),1),Z=se();function Q({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Z.jsx)(`div`,{className:z(ke,i),children:(0,Z.jsx)(`div`,{className:z(J,n),children:r})}):(0,Z.jsx)(`div`,{className:z(J,i,n),children:r})}function xt({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,l=s||o?.error!==void 0,u=a&&!s?_e(e,t,a):U(e,t,n.key),d=a?c:Ve;return(0,Z.jsxs)(Re,{children:[(0,Z.jsxs)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:u}),className:z(V,`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`,l&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),l&&(0,Z.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Z.jsxs)(ze,{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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Z.jsx)(ge,{skill:o})]}),s?(0,Z.jsxs)(B,{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,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Z.jsx)(h,{children:`Loading the skill…`}),o?.content.trim()&&(0,Z.jsx)(St,{title:`Skill instructions`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Z.jsx)(St,{title:`${n.name} adds`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Z.jsx)(St,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Z.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function St({title:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Z.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Ct({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ue(e.length)}),(0,Z.jsxs)(ze,{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,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Z.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Z.jsx)(m,{rule:e,boardId:r,boards:i},e.id))})]})]})}var wt=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Tt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=je(e),s=Ne(e),c=o.isPending||s.isPending,d=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>g(e,n)),p=s.data&&d?_(s.data.intakeRoutes,{key:t,initialPhase:d}):void 0;return(0,Z.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Z.jsx)(Q,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,children:(0,Z.jsx)(K.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),p&&p.leaving.length>0&&(0,Z.jsx)(Q,{pinned:!0,className:`mb-4`,children:(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Z.jsx)(Ct,{rules:p.leaving,title:`Rules that send cards to other boards`,to:be(e,t,`leaving`),boardId:t,boards:o.data}),` `,p.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Z.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,wt),children:n.map(i=>{let s=Pe(t,i.kind),m=p?.into.get(i.key)??[];return(0,Z.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,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Z.jsxs)(H,{to:U(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Z.jsx)(Ie,{stage:i.key,kind:s,decorative:!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Z.jsx)(`div`,{className:`px-3 py-3`,children:(0,Z.jsx)(u,{boardId:t,phase:g(i,n),phases:f,arrivals:(0,Z.jsxs)(Z.Fragment,{children:[c?(0,Z.jsx)(I,{className:`h-4 w-20`}):p?m.length>0?(0,Z.jsx)(Ct,{rules:m,title:`Rules that move cards into ${i.name}`,to:be(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Z.jsx)(h,{children:`No rule moves cards here`}):(0,Z.jsx)(h,{children:`Rules didn’t load`}),i.key===d&&(0,Z.jsx)(h,{children:`New cards start here`})]}),starts:(0,Z.jsx)(l,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Z.jsx)(xt,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Et=`Finish or remove unfinished conditions to save.`;function Dt({label:e,description:t,rule:n,disabled:r,facts:i=Ge,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,X.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,X.useId)(),g=p===void 0?N(s,n):M(s,p),_=e=>{m(e);let t=P(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Z.jsxs)(Xe,{invalid:g!==void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(qe,{htmlFor:h,children:e}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,N(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Z.jsx)(Je,{children:t}),p===void 0?r?(0,Z.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:We(n,o)}):(0,Z.jsx)(`div`,{id:h,children:(0,Z.jsx)(ft,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Et):l(e,N(s,e))}})}):(0,Z.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Z.jsx)(Ye,{children:g})]})}var Ot=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function kt({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,Z.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Z.jsx)(Ie,{stage:t.key,kind:Pe(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Z.jsxs)(`li`,{className:z(Ot,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Z.jsx)(At,{children:t.name}),(0,Z.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,Z.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:z(Ot,`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`,V),children:[(0,Z.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Z.jsx)(pt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Z.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Z.jsx)(mt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Z.jsx)(`li`,{className:`min-w-0`,children:l?(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:d}),(0,Z.jsx)(Te,{children:`Factory's code makes this move`})]}):d},t.key)})})}function At({children:e}){return(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function jt({label:e,children:t}){return(0,Z.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Mt({icon:e,title:t,description:n,children:r}){let i=(0,X.useId)();return(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Z.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Nt=`__none__`,Pt=`sm:max-w-xs`,Ft=(e,t)=>e>=t-200?` ${e}/${t}`:``;function It({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Z.jsxs)(ae,{children:[(0,Z.jsxs)(Xe,{invalid:!!n,disabled:r,children:[(0,Z.jsx)(ie,{children:e}),(0,Z.jsx)(Je,{children:t}),i,n&&(0,Z.jsx)(Ye,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Z.jsx)(R,{children:(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Ke,{"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:s,disabled:l,rawRules:u,onChange:d,onRawRule:m,onUnfinished:h,onRemove:g}){let _=dt(o),y=e.kind===`working`,x=E(e,t),S=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],D=e.exitTool?.id??``,O=e.runner?.skill,k=O?r?.find(e=>e.name===O):void 0,ne=O!==void 0&&r!==void 0&&k===void 0,j=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));d({...e,runner:Object.keys(r).length>0?r:null})},M=e=>({text:u[e],onChange:t=>m(e,t)}),N=(0,Z.jsx)(kt,{phase:e,phases:t,next:x,required:new Set(n),boardId:s,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=g&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(G,{variant:`ghost`,icon:(0,Z.jsx)(ht,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsxs)(jt,{label:`How ${e.name} runs`,children:[(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(Fe,{}),title:`Starts`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Start on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d(te(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(Ve,{}),title:`Agent runs`,children:[(0,Z.jsx)(It,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${Ft(S.length,i)}`,error:S.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,Z.jsx)(Lt,{label:`${e.name} instructions`,value:S,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,Z.jsx)(It,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${Ft(w.length,ee)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:l,after:C&&(0,Z.jsxs)(Xe,{invalid:!v(C.maxRuns),disabled:l,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(qe,{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,Z.jsx)(it,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=C;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Z.jsxs)(rt,{size:`sm`,children:[(0,Z.jsx)(et,{placeholder:`Default`}),(0,Z.jsxs)($e,{align:`inline-end`,variant:`flush`,children:[(0,Z.jsx)(Qe,{className:`mr-1`,children:`runs`}),(0,Z.jsx)(nt,{}),(0,Z.jsx)(tt,{})]})]})})]}),!v(C.maxRuns)&&(0,Z.jsxs)(Ye,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Z.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Z.jsx)(It,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:f,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,Z.jsx)(q,{title:`Skill`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(at,{value:O??Nt,disabled:l,onValueChange:e=>j({skill:e===Nt?void 0:String(e)}),children:[(0,Z.jsx)(ot,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(c,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:O??`No skill`})]})}),(0,Z.jsxs)(ct,{children:[(0,Z.jsx)(lt,{value:Nt,children:`None`}),(r??[]).map(e=>(0,Z.jsx)(lt,{value:e.name,children:e.name},e.name))]})]}),ne&&(0,Z.jsx)(F,{variant:`destructive`,children:`Not found`}),k?.error&&(0,Z.jsx)(F,{variant:`destructive`,children:`Failed to load`}),k&&(0,Z.jsx)(ge,{skill:k}),k&&(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,icon:a?(0,Z.jsx)(Be,{}):(0,Z.jsx)(De,{}),"aria-label":`${a?`Edit`:`View`} ${k.name}`,className:`ml-auto`,render:(0,Z.jsx)(H,{to:_e(o,s,k.name)}),children:a?`Edit`:`View`})]}),k?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,k.error]}):ne?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,O,` skill, so cards entering `,e.name,` fail to start.`]}):k?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:k.description})]})})}),(0,Z.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Z.jsx)(R,{children:A.map(t=>(0,Z.jsx)(L,{label:t.label,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:l,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(p,{}),title:`Ends`,children:[(0,Z.jsx)(It,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} exit tool`,value:D,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),D!==``&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Approve on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: approve ${D} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:D,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:D,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(b,{}),title:`Allowed moves`,children:N})]}),P]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=ne(e.id,t,d),[y,b]=(0,X.useState)(0),S=()=>{v(),b(e=>e+1)},ee=we(),w=ue(e.id,t),T=Ce(),E=!f||!d.editable,D=n?p.phases.find(e=>e.key===n):void 0,A=D&&`${D.key}:${d.revision??`code`}:${y}`,[M,N]=(0,X.useState)({page:A,fields:[]});M.page!==A&&N({page:A,fields:[]});let P=M.page===A?M.fields:[],F=(e,t)=>N(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),re=!E&&(k(p,d)||Object.keys(m).length>0||P.length>0),I=p.phases.filter(e=>j(e,m)||e===D&&P.length>0),ie=p.name.trim()===``,L=w.error?.code===`revision_mismatch`,ae=xe(({nextLocation:n})=>{let r=T.getQueryData(Oe.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!re||r===!1)return!1;let i=ve(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=U(e.id,t),se;return se=n&&!D?(0,Z.jsx)(r,{titleSlot:(0,Z.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Z.jsx)(G,{size:`sm`,render:(0,Z.jsx)(H,{to:oe}),children:`Back to general`})}):D?(0,Z.jsx)(Rt,{phase:D,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[D.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:E||h,rawRules:{autoStartWhen:m[x(D.key,`autoStartWhen`)],autoApproveWhen:m[x(D.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(x(D.key,e),t),F(e,!1)},onUnfinished:F,onRemove:E||h||!O(p.phases,D.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(x(D.key,e),void 0);g(e=>({...e,phases:C(e.phases,D.key)})),ee(oe)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},A):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Tt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:E||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?te(n,t):n)})),t||_(x(e,`autoStartWhen`),void 0)},action:l&&!E?(0,Z.jsx)(s,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Z.jsx)(Q,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:l&&(0,Z.jsx)(q,{title:`Factory`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(H,{to:ye(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,Z.jsx)(c,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Z.jsx)(le,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Z.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!D&&`w-max min-w-full`),children:[d.editable?!f&&(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!D&&d.problems.length>0&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,Z.jsx)(K.Message,{children:d.problems.join(` `)})})}),se,re&&(0,Z.jsxs)(Q,{pinned:!D,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[L&&(0,Z.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,Z.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,Z.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),w.error&&!L&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not saved. `,w.error.reasons]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:ie?`Name the board to save.`:I.length>0?`Fix ${I.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:w.isPending,onClick:S,children:`Discard`}),(0,Z.jsx)(G,{size:`sm`,variant:`primary`,disabled:w.isPending||ie||I.length>0,onClick:()=>w.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:w.isPending?`Saving…`:`Save`})]})]}),(0,Z.jsx)(W,{open:ae.state===`blocked`,onOpenChange:e=>!e&&ae.reset?.(),children:(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Z.jsx)(W.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Keep editing`}),(0,Z.jsx)(G,{variant:`destructive`,size:`md`,onClick:()=>{v(),ae.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(ht,{}),disabled:t,children:`Delete`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Delete `,e,`?`]}),(0,Z.jsx)(W.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(vt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Reset `,e,` to default?`]}),(0,Z.jsx)(W.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.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,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:(0,Z.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Z.jsx)(Te,{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}=ne(e,t,i),d=je(e),f=we(),p=!a||!i.editable||s,m=pe(e,t),h=de(e,t,()=>{u();let n=gt(d.data??[]).find(e=>e.id!==t);f(n?_t(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,b=n?o.phases.find(e=>e.key===n):void 0;if(n&&!b)return null;let S=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{b&&(l(x(b.key,`autoStartWhen`),void 0),l(x(b.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===b.key?w(n,e,t.phases):n)})))},C=b?b.name:o.name,T=(b?b.description:o.description)??``,E=b!==void 0&&!p&&!y(o.phases,b.key,i.codeBehaviour);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{children:[(0,Z.jsxs)(Y.Title,{className:`gap-2.5`,children:[b&&(0,Z.jsx)(Ie,{stage:b.key,kind:Pe(t,b.kind),decorative:!0}),(0,Z.jsx)(yt,{value:C,label:b?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>b?S({name:e}):c(t=>({...t,name:e}))})]}),b&&(0,Z.jsx)(Y.Meta,{beside:!0,children:E?(0,Z.jsxs)(at,{value:b.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Z.jsx)(ot,{size:`sm`,"aria-label":`Phase kind`,children:$[b.kind].label}),(0,Z.jsx)(ct,{children:Ut.map(e=>(0,Z.jsx)(lt,{value:e,children:$[e].label},e))})]}):(0,Z.jsx)(Wt,{label:$[b.kind].label,meaning:$[b.kind].meaning,children:(0,Z.jsx)(F,{children:$[b.kind].label})})}),(T||!p)&&(0,Z.jsx)(Y.Description,{children:(0,Z.jsx)(yt,{value:T,label:b?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>b?S({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Z.jsxs)(Y.Action,{className:`gap-1`,children:[_&&(0,Z.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Z.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=o(),i=S(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=re(),u=c||l===`collapsed`,f=fe(e.id,a),p=he(e.id),m=f.data?.board,h=D(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=U(e.id,a),v=T({breadcrumbs:u&&m?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:H,to:_t(e.id,a),children:h?.name||m.name}),s?(0,Z.jsx)(t,{as:H,to:_,children:`Configure`}):(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,Z.jsx)(`div`,{className:z(J,s?`pb-8`:`pb-3`),children:(0,Z.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:f.data},`${a}:${f.data.board.revision??`code`}`)}):void 0;return(0,Z.jsx)(d,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Z.jsx)(`div`,{className:s||!f.isSuccess?z(J,!s&&`px-4`):Ae,children:f.isPending?(0,Z.jsx)(R,{children:(0,Z.jsx)(oe,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof me&&f.error.code===`board_not_found`?(0,Z.jsx)(r,{variant:`fill`,titleSlot:(0,Z.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,Z.jsx)(bt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,Z.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void f.refetch()},`${a}:${f.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-BpvMnN1l.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,$t as a,Cr as o,D as s,E as c,Hn as l,Jn as u,Mr as d,Qn as f,Sr as p,Un as m,Xn as h,Yn as g,Zn as _,ar as v,cr as y,dn as b,dr as x,en as S,er as ee,fr as C,hr as w,jr as T,lr as E,mr as te,nn as D,nr as O,rr as k,tn as ne,tr as A,ur as j,vr as M,xr as N,yr as P}from"./index-CD4tM4nf.js";import{A as F,a as re,j as I}from"./Sidebar.es-DSPzNNju.js";import{d as ie,f as L,r as ae,t as R,u as oe}from"./settings-DAvFqX1V-D4umTesm.js";import{O as se,T as z,k as ce,n as B,s as V,t as le}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as H}from"./lib-DkXXjRNC.js";import{c as ue,o as de,r as fe,s as pe,t as me}from"./useBoardEditor-DiWa4Lcl.js";import{i as he,t as ge}from"./SkillBadges-BN_VjOtf.js";import{a as U,c as _e,f as ve,l as ye,s as be}from"./boardConfigPaths-Btimpi_r.js";import{t as W}from"./AlertDialog.es-DDAl3sXA.js";import{$n as xe,Fi as G,ga as Se,ji as Ce,lr as we,ma as Te,n as K,pa as Ee,r as De,zt as Oe}from"./GithubIcon.es-BPBhMx2H.js";import{t as q}from"./SettingsSubsection-BGJrlda9.js";import{n as ke,r as J,t as Ae}from"./settingsColumn-CrKuH8q1.js";import{n as je}from"./useBoardCatalog-vK4woIAH.js";import{h as Me,o as Ne}from"./useIntakeRoutes-CdL4o1Vv.js";import{a as Pe,d as Fe,t as Ie}from"./BoardIcons-Cml_taka.js";import{i as Le,n as Re,r as ze,t as Be}from"./IconPencil.es-C5rZ8A6j.js";import{r as Ve}from"./overlays-B3sO28Cg.js";import{t as He}from"./DescriptionMarkdown-BH7uH0Yx.js";import{h as Ue,w as We,y as Ge}from"./ruleLanes-DEg70O95.js";import{t as Ke}from"./CodeEditor-DmElSGLM-BqTClSRY.js";import{a as qe,n as Je,r as Ye,t as Xe}from"./Field.es-BPlWASZ-.js";import{t as Ze}from"./input-DqReKX0A-BMaPtvZH.js";import{a as Qe,n as $e}from"./input-group-CXvse9n7-C3ds8HOQ.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./InputNumber.es-Dvj2CMW7.js";import{c as at,d as ot,et as st,l as ct,u as lt}from"./icons-C18D46Pv.js";import{E as ut}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.js";import{n as dt,t as ft}from"./ConditionRows-DJVG4EHd.js";import{t as pt}from"./IconLock.es-9mYeLe9c.js";import{t as mt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as ht}from"./TrashIcon.es-CLx-KWTg.js";import{t as Y}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as gt,t as _t}from"./boardCatalog-y-s19dQU.js";import{t as vt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as yt}from"./InlineText-vWKzGKx_.js";import{t as bt}from"./LoadErrorState-CtPpeSh8.js";var X=e(ce(),1),Z=se();function Q({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Z.jsx)(`div`,{className:z(ke,i),children:(0,Z.jsx)(`div`,{className:z(J,n),children:r})}):(0,Z.jsx)(`div`,{className:z(J,i,n),children:r})}function xt({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,l=s||o?.error!==void 0,u=a&&!s?_e(e,t,a):U(e,t,n.key),d=a?c:Ve;return(0,Z.jsxs)(Re,{children:[(0,Z.jsxs)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:u}),className:z(V,`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`,l&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),l&&(0,Z.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Z.jsxs)(ze,{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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Z.jsx)(ge,{skill:o})]}),s?(0,Z.jsxs)(B,{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,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Z.jsx)(h,{children:`Loading the skill…`}),o?.content.trim()&&(0,Z.jsx)(St,{title:`Skill instructions`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Z.jsx)(St,{title:`${n.name} adds`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Z.jsx)(St,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Z.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function St({title:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Z.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Ct({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Z.jsxs)(Re,{children:[(0,Z.jsx)(Le,{delay:0,closeDelay:100,render:(0,Z.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ue(e.length)}),(0,Z.jsxs)(ze,{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,Z.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Z.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Z.jsx)(m,{rule:e,boardId:r,boards:i},e.id))})]})]})}var wt=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Tt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=je(e),s=Ne(e),c=o.isPending||s.isPending,d=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>g(e,n)),p=s.data&&d?_(s.data.intakeRoutes,{key:t,initialPhase:d}):void 0;return(0,Z.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Z.jsx)(Q,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,children:(0,Z.jsx)(K.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),p&&p.leaving.length>0&&(0,Z.jsx)(Q,{pinned:!0,className:`mb-4`,children:(0,Z.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Z.jsx)(Ct,{rules:p.leaving,title:`Rules that send cards to other boards`,to:be(e,t,`leaving`),boardId:t,boards:o.data}),` `,p.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Z.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,wt),children:n.map(i=>{let s=Pe(t,i.kind),m=p?.into.get(i.key)??[];return(0,Z.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,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Z.jsxs)(H,{to:U(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Z.jsx)(Ie,{stage:i.key,kind:s,decorative:!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Z.jsx)(`div`,{className:`px-3 py-3`,children:(0,Z.jsx)(u,{boardId:t,phase:g(i,n),phases:f,arrivals:(0,Z.jsxs)(Z.Fragment,{children:[c?(0,Z.jsx)(I,{className:`h-4 w-20`}):p?m.length>0?(0,Z.jsx)(Ct,{rules:m,title:`Rules that move cards into ${i.name}`,to:be(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Z.jsx)(h,{children:`No rule moves cards here`}):(0,Z.jsx)(h,{children:`Rules didn’t load`}),i.key===d&&(0,Z.jsx)(h,{children:`New cards start here`})]}),starts:(0,Z.jsx)(l,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Z.jsx)(xt,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Et=`Finish or remove unfinished conditions to save.`;function Dt({label:e,description:t,rule:n,disabled:r,facts:i=Ge,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,X.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,X.useId)(),g=p===void 0?N(s,n):M(s,p),_=e=>{m(e);let t=P(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Z.jsxs)(Xe,{invalid:g!==void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(qe,{htmlFor:h,children:e}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,N(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Z.jsx)(Je,{children:t}),p===void 0?r?(0,Z.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:We(n,o)}):(0,Z.jsx)(`div`,{id:h,children:(0,Z.jsx)(ft,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Et):l(e,N(s,e))}})}):(0,Z.jsx)(a,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Z.jsx)(Ye,{children:g})]})}var Ot=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function kt({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,Z.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Z.jsx)(Ie,{stage:t.key,kind:Pe(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Z.jsxs)(`li`,{className:z(Ot,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Z.jsx)(At,{children:t.name}),(0,Z.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,Z.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:z(Ot,`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`,V),children:[(0,Z.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Z.jsx)(pt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Z.jsx)(st,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Z.jsx)(mt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Z.jsx)(`li`,{className:`min-w-0`,children:l?(0,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:d}),(0,Z.jsx)(Te,{children:`Factory's code makes this move`})]}):d},t.key)})})}function At({children:e}){return(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function jt({label:e,children:t}){return(0,Z.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Mt({icon:e,title:t,description:n,children:r}){let i=(0,X.useId)();return(0,Z.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,Z.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,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Z.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Nt=`__none__`,Pt=`sm:max-w-xs`,Ft=(e,t)=>e>=t-200?` ${e}/${t}`:``;function It({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Z.jsxs)(ae,{children:[(0,Z.jsxs)(Xe,{invalid:!!n,disabled:r,children:[(0,Z.jsx)(ie,{children:e}),(0,Z.jsx)(Je,{children:t}),i,n&&(0,Z.jsx)(Ye,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Z.jsx)(R,{children:(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Ke,{"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:s,disabled:l,rawRules:u,onChange:d,onRawRule:m,onUnfinished:h,onRemove:g}){let _=dt(o),y=e.kind===`working`,x=E(e,t),S=e.runner?.instructions??``,C=e.runner?.goal,w=C?.objective??``,T=e.tools??[],D=e.exitTool?.id??``,O=e.runner?.skill,k=O?r?.find(e=>e.name===O):void 0,ne=O!==void 0&&r!==void 0&&k===void 0,j=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));d({...e,runner:Object.keys(r).length>0?r:null})},M=e=>({text:u[e],onChange:t=>m(e,t)}),N=(0,Z.jsx)(kt,{phase:e,phases:t,next:x,required:new Set(n),boardId:s,disabled:l,onChange:t=>d({...e,nextPhases:t})}),P=g&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(G,{variant:`ghost`,icon:(0,Z.jsx)(ht,{}),onClick:g,children:[`Remove `,e.name]})});return y?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsxs)(jt,{label:`How ${e.name} runs`,children:[(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(Fe,{}),title:`Starts`,children:(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Start on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{d(te(e,t)),t||m(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoStartWhen`),onUnfinished:e=>h(`autoStartWhen`,e),onChange:t=>d({...e,autoStartWhen:t})})})]})}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(Ve,{}),title:`Agent runs`,children:[(0,Z.jsx)(It,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${Ft(S.length,i)}`,error:S.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,Z.jsx)(Lt,{label:`${e.name} instructions`,value:S,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>j({instructions:e})})}),(0,Z.jsx)(It,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${Ft(w.length,ee)}`,error:w.length>2e3?`Too long to save.`:void 0,disabled:l,after:C&&(0,Z.jsxs)(Xe,{invalid:!v(C.maxRuns),disabled:l,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(qe,{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,Z.jsx)(it,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:C.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=C;j({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Z.jsxs)(rt,{size:`sm`,children:[(0,Z.jsx)(et,{placeholder:`Default`}),(0,Z.jsxs)($e,{align:`inline-end`,variant:`flush`,children:[(0,Z.jsx)(Qe,{className:`mr-1`,children:`runs`}),(0,Z.jsx)(nt,{}),(0,Z.jsx)(tt,{})]})]})})]}),!v(C.maxRuns)&&(0,Z.jsxs)(Ye,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Z.jsx)(Lt,{label:`${e.name} goal`,value:w,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>j({goal:e.trim()?{...C,objective:e}:void 0})})}),(0,Z.jsx)(It,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:f,disabled:l,onChange:e=>j({context:e.target.value})})}),(0,Z.jsx)(q,{title:`Skill`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(at,{value:O??Nt,disabled:l,onValueChange:e=>j({skill:e===Nt?void 0:String(e)}),children:[(0,Z.jsx)(ot,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(c,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:O??`No skill`})]})}),(0,Z.jsxs)(ct,{children:[(0,Z.jsx)(lt,{value:Nt,children:`None`}),(r??[]).map(e=>(0,Z.jsx)(lt,{value:e.name,children:e.name},e.name))]})]}),ne&&(0,Z.jsx)(F,{variant:`destructive`,children:`Not found`}),k?.error&&(0,Z.jsx)(F,{variant:`destructive`,children:`Failed to load`}),k&&(0,Z.jsx)(ge,{skill:k}),k&&(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,icon:a?(0,Z.jsx)(Be,{}):(0,Z.jsx)(De,{}),"aria-label":`${a?`Edit`:`View`} ${k.name}`,className:`ml-auto`,render:(0,Z.jsx)(H,{to:_e(o,s,k.name)}),children:a?`Edit`:`View`})]}),k?.error?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,k.error]}):ne?(0,Z.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,O,` skill, so cards entering `,e.name,` fail to start.`]}):k?.description&&(0,Z.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:k.description})]})})}),(0,Z.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Z.jsx)(R,{children:A.map(t=>(0,Z.jsx)(L,{label:t.label,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: ${t.label}`,checked:T.includes(t.id),disabled:l,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:T.includes(e));d({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(p,{}),title:`Ends`,children:[(0,Z.jsx)(It,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} exit tool`,value:D,disabled:l,onChange:t=>{let n=t.target.value.trim();d({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||m(`autoApproveWhen`,void 0)}})}),D!==``&&(0,Z.jsxs)(R,{children:[(0,Z.jsx)(L,{label:`Approve on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: approve ${D} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{d({...e,exitTool:{...e.exitTool,id:D,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||m(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Me,options:{"source.repository":_},disabled:l,json:M(`autoApproveWhen`),onUnfinished:e=>h(`autoApproveWhen`,e),onChange:t=>d({...e,exitTool:{...e.exitTool,id:D,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(b,{}),title:`Allowed moves`,children:N})]}),P]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(q,{title:`Allowed moves`,children:N}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=ne(e.id,t,d),[y,b]=(0,X.useState)(0),S=()=>{v(),b(e=>e+1)},ee=we(),w=ue(e.id,t),T=Ce(),E=!f||!d.editable,D=n?p.phases.find(e=>e.key===n):void 0,A=D&&`${D.key}:${d.revision??`code`}:${y}`,[M,N]=(0,X.useState)({page:A,fields:[]});M.page!==A&&N({page:A,fields:[]});let P=M.page===A?M.fields:[],F=(e,t)=>N(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),re=!E&&(k(p,d)||Object.keys(m).length>0||P.length>0),I=p.phases.filter(e=>j(e,m)||e===D&&P.length>0),ie=p.name.trim()===``,L=w.error?.code===`revision_mismatch`,ae=xe(({nextLocation:n})=>{let r=T.getQueryData(Oe.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!re||r===!1)return!1;let i=ve(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=U(e.id,t),se;return se=n&&!D?(0,Z.jsx)(r,{titleSlot:(0,Z.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Z.jsx)(G,{size:`sm`,render:(0,Z.jsx)(H,{to:oe}),children:`Back to general`})}):D?(0,Z.jsx)(Rt,{phase:D,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[D.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:E||h,rawRules:{autoStartWhen:m[x(D.key,`autoStartWhen`)],autoApproveWhen:m[x(D.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(x(D.key,e),t),F(e,!1)},onUnfinished:F,onRemove:E||h||!O(p.phases,D.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(x(D.key,e),void 0);g(e=>({...e,phases:C(e.phases,D.key)})),ee(oe)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},A):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Tt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:E||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?te(n,t):n)})),t||_(x(e,`autoStartWhen`),void 0)},action:l&&!E?(0,Z.jsx)(s,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Z.jsx)(Q,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:l&&(0,Z.jsx)(q,{title:`Factory`,children:(0,Z.jsx)(R,{children:(0,Z.jsxs)(H,{to:ye(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,Z.jsx)(c,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Z.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Z.jsx)(le,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Z.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!D&&`w-max min-w-full`),children:[d.editable?!f&&(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Z.jsx)(Q,{pinned:!D,children:(0,Z.jsx)(K,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!D&&d.problems.length>0&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(K,{variant:`warning`,title:`This board has problems`,children:(0,Z.jsx)(K.Message,{children:d.problems.join(` `)})})}),se,re&&(0,Z.jsxs)(Q,{pinned:!D,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[L&&(0,Z.jsx)(K,{variant:`warning`,title:`Someone else changed this board`,action:(0,Z.jsx)(K.Button,{onClick:u,children:`Reload`}),children:(0,Z.jsx)(K.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),w.error&&!L&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not saved. `,w.error.reasons]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:ie?`Name the board to save.`:I.length>0?`Fix ${I.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Z.jsx)(G,{size:`sm`,variant:`ghost`,disabled:w.isPending,onClick:S,children:`Discard`}),(0,Z.jsx)(G,{size:`sm`,variant:`primary`,disabled:w.isPending||ie||I.length>0,onClick:()=>w.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:w.isPending?`Saving…`:`Save`})]})]}),(0,Z.jsx)(W,{open:ae.state===`blocked`,onOpenChange:e=>!e&&ae.reset?.(),children:(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Z.jsx)(W.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Keep editing`}),(0,Z.jsx)(G,{variant:`destructive`,size:`md`,onClick:()=>{v(),ae.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(ht,{}),disabled:t,children:`Delete`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Delete `,e,`?`]}),(0,Z.jsx)(W.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Z.jsxs)(W,{children:[(0,Z.jsx)(W.Trigger,{render:(0,Z.jsx)(G,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(vt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Z.jsxs)(W.Content,{children:[(0,Z.jsxs)(W.Header,{children:[(0,Z.jsxs)(W.Title,{children:[`Reset `,e,` to default?`]}),(0,Z.jsx)(W.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Z.jsxs)(W.Footer,{children:[(0,Z.jsx)(W.Cancel,{children:`Cancel`}),(0,Z.jsx)(W.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,Z.jsxs)(Ee,{children:[(0,Z.jsx)(Se,{render:(0,Z.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Z.jsx)(Te,{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}=ne(e,t,i),d=je(e),f=we(),p=!a||!i.editable||s,m=pe(e,t),h=de(e,t,()=>{u();let n=gt(d.data??[]).find(e=>e.id!==t);f(n?_t(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,b=n?o.phases.find(e=>e.key===n):void 0;if(n&&!b)return null;let S=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{b&&(l(x(b.key,`autoStartWhen`),void 0),l(x(b.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===b.key?w(n,e,t.phases):n)})))},C=b?b.name:o.name,T=(b?b.description:o.description)??``,E=b!==void 0&&!p&&!y(o.phases,b.key,i.codeBehaviour);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{children:[(0,Z.jsxs)(Y.Title,{className:`gap-2.5`,children:[b&&(0,Z.jsx)(Ie,{stage:b.key,kind:Pe(t,b.kind),decorative:!0}),(0,Z.jsx)(yt,{value:C,label:b?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>b?S({name:e}):c(t=>({...t,name:e}))})]}),b&&(0,Z.jsx)(Y.Meta,{beside:!0,children:E?(0,Z.jsxs)(at,{value:b.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Z.jsx)(ot,{size:`sm`,"aria-label":`Phase kind`,children:$[b.kind].label}),(0,Z.jsx)(ct,{children:Ut.map(e=>(0,Z.jsx)(lt,{value:e,children:$[e].label},e))})]}):(0,Z.jsx)(Wt,{label:$[b.kind].label,meaning:$[b.kind].meaning,children:(0,Z.jsx)(F,{children:$[b.kind].label})})}),(T||!p)&&(0,Z.jsx)(Y.Description,{children:(0,Z.jsx)(yt,{value:T,label:b?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>b?S({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Z.jsxs)(Y.Action,{className:`gap-1`,children:[_&&(0,Z.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Z.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Z.jsx)(K,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(K.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=o(),i=S(),a=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=re(),u=c||l===`collapsed`,f=fe(e.id,a),p=he(e.id),m=f.data?.board,h=D(e.id,a,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=U(e.id,a),v=T({breadcrumbs:u&&m?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:H,to:_t(e.id,a),children:h?.name||m.name}),s?(0,Z.jsx)(t,{as:H,to:_,children:`Configure`}):(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,Z.jsx)(`div`,{className:z(J,s?`pb-8`:`pb-3`),children:(0,Z.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:s,response:f.data},`${a}:${f.data.board.revision??`code`}`)}):void 0;return(0,Z.jsx)(d,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Z.jsx)(`div`,{className:s||!f.isSuccess?z(J,!s&&`px-4`):Ae,children:f.isPending?(0,Z.jsx)(R,{children:(0,Z.jsx)(oe,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof me&&f.error.code===`board_not_found`?(0,Z.jsx)(r,{variant:`fill`,titleSlot:(0,Z.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,Z.jsx)(bt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,Z.jsx)(Bt,{factory:e,boardId:a,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:u,onReload:()=>void f.refetch()},`${a}:${f.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-BEIE9dke.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Mr as a,en as o,jr as s}from"./index-2FxPHkSg.js";import{A as c,a as l}from"./Sidebar.es-DSPzNNju.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-DkXXjRNC.js";import{r as h}from"./useBoardEditor-DiWa4Lcl.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{Fi as x,n as S}from"./GithubIcon.es-BPBhMx2H.js";import{tt as C}from"./icons-C18D46Pv.js";import{a as w,o as T,t as E,u as D}from"./settings-DAvFqX1V-D4umTesm.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-Bmj1hhAE.js";import{o as R}from"./useIntakeRoutes-CdL4o1Vv.js";import{h as z,p as B}from"./ruleLanes-DEg70O95.js";import{s as V}from"./Field.es-BPlWASZ-.js";import{n as H}from"./useBoardCatalog-vK4woIAH.js";import{t as U}from"./SettingsSubsection-BGJrlda9.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)(c,{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=i(),c=o()?.boardId??``,{isMobile:u,desktopState:f}=l(),p=u||f===`collapsed`,_=h(e.id,c).data?.board,v=s({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,c),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(a,{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-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Mr as a,en as o,jr as s}from"./index-CD4tM4nf.js";import{A as c,a as l}from"./Sidebar.es-DSPzNNju.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-DkXXjRNC.js";import{r as h}from"./useBoardEditor-DiWa4Lcl.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{Fi as x,n as S}from"./GithubIcon.es-BPBhMx2H.js";import{tt as C}from"./icons-C18D46Pv.js";import{a as w,o as T,t as E,u as D}from"./settings-DAvFqX1V-D4umTesm.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-Bmj1hhAE.js";import{o as R}from"./useIntakeRoutes-CdL4o1Vv.js";import{h as z,p as B}from"./ruleLanes-DEg70O95.js";import{s as V}from"./Field.es-BPlWASZ-.js";import{n as H}from"./useBoardCatalog-vK4woIAH.js";import{t as U}from"./SettingsSubsection-BGJrlda9.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)(c,{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=i(),c=o()?.boardId??``,{isMobile:u,desktopState:f}=l(),p=u||f===`collapsed`,_=h(e.id,c).data?.board,v=s({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,c),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(a,{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-BEIE9dke.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Gn as a,Kn as o,Mr as s,Wn as c,Zn as l,en as u,jr as d,qn as f}from"./index-2FxPHkSg.js";import{A as p,a as m,j as h,p as g}from"./Sidebar.es-DSPzNNju.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-DkXXjRNC.js";import{r as C,t as w}from"./useBoardEditor-DiWa4Lcl.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,Dt as j,Fi as M,St as N,jt as ee,kt as P,n as F,t as te,wt as ne}from"./GithubIcon.es-BPBhMx2H.js";import{tt as I}from"./icons-C18D46Pv.js";import{n as L}from"./useBoardCatalog-vK4woIAH.js";import{c as re,d as ie,l as R,n as z,r as ae,s as B,t as V,u as H}from"./useRowDrag-Bmj1hhAE.js";import{a as oe,d as se,f as U,g as W,o as G,r as K,s as ce}from"./useIntakeRoutes-CdL4o1Vv.js";import{C as le,E as ue,_ as de,a as fe,c as q,d as pe,f as me,g as he,i as ge,l as J,m as _e,n as ve,o as ye,s as be,u as Y,w as xe}from"./ruleLanes-DEg70O95.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as Se,t as Ce}from"./BoardIcons-Cml_taka.js";import{t as we}from"./input-DqReKX0A-BMaPtvZH.js";import{n as Te,t as Ee}from"./RadioGroup.es-CyxlfqIJ.js";import{n as De,t as Oe}from"./ConditionRows-aX8GWrx7.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.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=le(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 o=r??i.initialPhase,s=i.phases.find(e=>e.id===o);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:`›`})]}),s&&(0,Q.jsx)(Ce,{stage:s.id,kind:Se(i.id,s.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:a(i,o)??o})]})}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:o(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)(Te,{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)(p,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(te,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=W(ce),$=[{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 U(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${xe(t).charAt(0).toLowerCase()}${xe(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:s,readOnly:l,saving:u,error:d,onSave:f,onClose:p}){let m=De(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,te]=(0,Z.useState)(()=>r?.name),[I,L]=(0,Z.useState)(s),[re,ie]=(0,Z.useState)(0),R=_e(h),z=n.find(e=>e.id===T),ae=dt(z,R),B=ae.find(e=>e.id===(D??z?.initialPhase)),V=x?_:null,H=h.length?ft(h,V):void 0,oe=B&&z?`${c(z)} › ${a(z,B.id)}`:``,U=k??(B?pt(h,V,oe):``),W={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!H,action:B!==void 0,review:U.trim().length>0},G=!l&&W.trigger&&W.conditions&&W.action&&W.review,K=$.findIndex(e=>e.id===I),ce=$[K]??$[0],le=e=>{g(e),_e(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{G&&B&&f({name:U.trim(),on:h,when:V,target:{phaseKey:B.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(V===null?{operator:`AND`,conditions:[e]}:V.operator===`AND`?{...V,conditions:[...V.conditions,e]}:{operator:`AND`,conditions:[V,e]}),S(!0),w(!1),ie(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?xe(V,o(t)):void 0,action:B?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:B.id}):void 0,review:void 0};return(0,Q.jsx)(N,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(j,{size:`xl`,children:[(0,Q.jsx)(A,{children:(0,Q.jsx)(ee,{children:l?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(ne,{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=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>L(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`,I===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}),I===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:l,onChange:le}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Ee,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:l,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:l,children:(0,Q.jsx)(ht,{title:R?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:l,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)(Oe,{label:`Conditions`,rule:_,facts:ue(h),options:{...o(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},re)}),H&&(0,Q.jsx)(F,{variant:`warning`,children:H}),!r?.outsiderPullRequestsGated&&se(h,V)&&(0,Q.jsx)(F,{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.`}),!l&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R?(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)(Ee,{"aria-label":`Board`,value:T,disabled:l,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:l,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)(Ee,{"aria-label":`Phase`,value:B?.id??null,disabled:l,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:z&&ae.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===B?.id,disabled:l,onClick:()=>{O(e.id),L(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ce,{stage:e.id,kind:Se(z.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:a(z,e.id)})]})},e.id))})]})]}),I===`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)(we,{value:U,maxLength:lt,disabled:l,onChange:e=>te(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)(F,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(M,{variant:`ghost`,onClick:p,children:l?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(M,{variant:`default`,onClick:()=>L($[K-1].id),children:`Back`}),!l&&(I===`review`||r&&G?(0,Q.jsx)(M,{variant:`primary`,disabled:!G||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(M,{variant:`primary`,disabled:!W[I],onClick:()=>L($[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)(F,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ve.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)(M,{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:o,skips:s,footer:l,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=fe(t,e),w=q(e),T=ye(e),E=V({min:0,max:t.length-1,onDrop:m}),D=o&&t.length>1&&!d,O=l??(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((l,u)=>{if(d&&!d.has(l.id))return null;let p=he(t,e,u),S=p>=0,O=!l.enabled||S,k=E.drag?.from===u,A=s?.get(l.id),j=r.find(e=>e.id===(l.target.moveToBoardKey??l.target.boardKey)),N=!me(l.name,[x.label,xe(l.when,i),j&&c(j),a(j,l.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":l.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 ${l.name}`,onClick:()=>f(l,`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)(re,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:l.name}),(0,Q.jsx)(Qe,{when:l.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)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(H,{})}),(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(ie,{})})]})]}),(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 ${l.name} moves the card`,onClick:()=>f(l,`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:l.target.moveToBoardKey??l.target.boardKey,phaseKey:l.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${l.name} on`,checked:l.enabled,onCheckedChange:e=>h(l,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${l.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(l),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`}),l.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}),de(l,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).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(l),className:`underline`,children:`Let outside authors match`})]}),pe(l,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&&be(l)&&(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`})]})]},l.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)(R,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),o&&(0,Q.jsx)(M,{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=L(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(h,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(F,{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)(F,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=K(e,t.id),i=G(e),s=ae(e),c=B(e),u=oe(e),[d,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),g=e=>{m.current=e,p(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=o(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?l(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)),ee=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(h,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(F,{variant:`destructive`,children:`This board’s rules didn’t load.`});let P=e=>u.mutateAsync(e).catch(e=>I.error(Tt(e))),te=(e,n,r)=>{let i=J(y,e).map(e=>e.id);P([{kind:`reorder`,boardKey:t.id,ids:f(y,i,n,r)}])},ne=e=>{v(void 0),g(e)},L=async e=>{let n=m.current,r=n?.rule,i=()=>n!==void 0&&m.current===n;v(void 0);try{if(r)await u.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 u.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ie(n,e.on).catch(e=>I.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return re(r);v(Tt(e))}},re=async e=>{let t=m.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.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),I.error(`Someone else deleted this rule first.`)))},ie=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),o=a.indexOf(e.id),s=n.flatMap(t=>{let n=J(i,t),r=n[he(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),c=Math.min(...s);o<0||!(c<o)||await u.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:f(i,a,o,c)}])},R=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:ge(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(F,{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`:a(t,k)??k,leaving:A,showAll:O(e,t.id)}),ve.filter(e=>e.events.some(e=>ee([...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(q)?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=q(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return ee([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?R:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>ne({rule:e,step:t}),onAdd:()=>ne({event:r,step:`conditions`}),onMove:(e,t)=>te(r,e,t),onToggle:(e,t)=>void P([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void P([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&I.success(`Deleted “${e.name}”`)),onUngate:e=>void P([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&I.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),d&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:d.rule,initialEvent:d.event,initialStep:d.step,readOnly:!S,saving:u.isPending,error:_,onSave:e=>void L(e),onClose:()=>g(void 0)},d.rule?`${d.rule.id}:${d.rule.revision}`:`new-${d.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=i(),a=u()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,f=C(e.id,a).data?.board,p=d({breadcrumbs:l&&f?(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:f.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(s,{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)(z,{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-BpvMnN1l.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Gn as a,Kn as o,Mr as s,Wn as c,Zn as l,en as u,jr as d,qn as f}from"./index-CD4tM4nf.js";import{A as p,a as m,j as h,p as g}from"./Sidebar.es-DSPzNNju.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-DkXXjRNC.js";import{r as C,t as w}from"./useBoardEditor-DiWa4Lcl.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,Dt as j,Fi as M,St as N,jt as ee,kt as P,n as F,t as te,wt as ne}from"./GithubIcon.es-BPBhMx2H.js";import{tt as I}from"./icons-C18D46Pv.js";import{n as L}from"./useBoardCatalog-vK4woIAH.js";import{c as re,d as ie,l as R,n as z,r as ae,s as B,t as V,u as H}from"./useRowDrag-Bmj1hhAE.js";import{a as oe,d as se,f as U,g as W,o as G,r as K,s as ce}from"./useIntakeRoutes-CdL4o1Vv.js";import{C as le,E as ue,_ as de,a as fe,c as q,d as pe,f as me,g as he,i as ge,l as J,m as _e,n as ve,o as ye,s as be,u as Y,w as xe}from"./ruleLanes-DEg70O95.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as Se,t as Ce}from"./BoardIcons-Cml_taka.js";import{t as we}from"./input-DqReKX0A-BMaPtvZH.js";import{n as Te,t as Ee}from"./RadioGroup.es-CyxlfqIJ.js";import{n as De,t as Oe}from"./ConditionRows-DJVG4EHd.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-DzYjyBt5.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=le(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 o=r??i.initialPhase,s=i.phases.find(e=>e.id===o);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:`›`})]}),s&&(0,Q.jsx)(Ce,{stage:s.id,kind:Se(i.id,s.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:a(i,o)??o})]})}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:o(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)(Te,{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)(p,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(te,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=W(ce),$=[{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 U(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${xe(t).charAt(0).toLowerCase()}${xe(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:s,readOnly:l,saving:u,error:d,onSave:f,onClose:p}){let m=De(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,te]=(0,Z.useState)(()=>r?.name),[I,L]=(0,Z.useState)(s),[re,ie]=(0,Z.useState)(0),R=_e(h),z=n.find(e=>e.id===T),ae=dt(z,R),B=ae.find(e=>e.id===(D??z?.initialPhase)),V=x?_:null,H=h.length?ft(h,V):void 0,oe=B&&z?`${c(z)} › ${a(z,B.id)}`:``,U=k??(B?pt(h,V,oe):``),W={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!H,action:B!==void 0,review:U.trim().length>0},G=!l&&W.trigger&&W.conditions&&W.action&&W.review,K=$.findIndex(e=>e.id===I),ce=$[K]??$[0],le=e=>{g(e),_e(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{G&&B&&f({name:U.trim(),on:h,when:V,target:{phaseKey:B.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(V===null?{operator:`AND`,conditions:[e]}:V.operator===`AND`?{...V,conditions:[...V.conditions,e]}:{operator:`AND`,conditions:[V,e]}),S(!0),w(!1),ie(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?xe(V,o(t)):void 0,action:B?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:B.id}):void 0,review:void 0};return(0,Q.jsx)(N,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(j,{size:`xl`,children:[(0,Q.jsx)(A,{children:(0,Q.jsx)(ee,{children:l?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(ne,{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=>W[e.id]),r=W[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":I===e.id?`step`:void 0,onClick:()=>L(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`,I===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}),I===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:l,onChange:le}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Ee,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:l,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:l,children:(0,Q.jsx)(ht,{title:R?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:l,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)(Oe,{label:`Conditions`,rule:_,facts:ue(h),options:{...o(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},re)}),H&&(0,Q.jsx)(F,{variant:`warning`,children:H}),!r?.outsiderPullRequestsGated&&se(h,V)&&(0,Q.jsx)(F,{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.`}),!l&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[R?(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)(Ee,{"aria-label":`Board`,value:T,disabled:l,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:l,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)(Ee,{"aria-label":`Phase`,value:B?.id??null,disabled:l,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:z&&ae.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===B?.id,disabled:l,onClick:()=>{O(e.id),L(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ce,{stage:e.id,kind:Se(z.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:a(z,e.id)})]})},e.id))})]})]}),I===`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)(we,{value:U,maxLength:lt,disabled:l,onChange:e=>te(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)(F,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(P,{children:[(0,Q.jsx)(M,{variant:`ghost`,onClick:p,children:l?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(M,{variant:`default`,onClick:()=>L($[K-1].id),children:`Back`}),!l&&(I===`review`||r&&G?(0,Q.jsx)(M,{variant:`primary`,disabled:!G||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(M,{variant:`primary`,disabled:!W[I],onClick:()=>L($[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)(F,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ve.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)(M,{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:o,skips:s,footer:l,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=fe(t,e),w=q(e),T=ye(e),E=V({min:0,max:t.length-1,onDrop:m}),D=o&&t.length>1&&!d,O=l??(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((l,u)=>{if(d&&!d.has(l.id))return null;let p=he(t,e,u),S=p>=0,O=!l.enabled||S,k=E.drag?.from===u,A=s?.get(l.id),j=r.find(e=>e.id===(l.target.moveToBoardKey??l.target.boardKey)),N=!me(l.name,[x.label,xe(l.when,i),j&&c(j),a(j,l.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":l.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 ${l.name}`,onClick:()=>f(l,`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)(re,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:l.name}),(0,Q.jsx)(Qe,{when:l.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)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(H,{})}),(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(ie,{})})]})]}),(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 ${l.name} moves the card`,onClick:()=>f(l,`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:l.target.moveToBoardKey??l.target.boardKey,phaseKey:l.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${l.name} on`,checked:l.enabled,onCheckedChange:e=>h(l,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${l.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(l),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`}),l.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}),de(l,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).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(l),className:`underline`,children:`Let outside authors match`})]}),pe(l,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&&be(l)&&(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`})]})]},l.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)(R,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),o&&(0,Q.jsx)(M,{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=L(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(h,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(F,{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)(F,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=K(e,t.id),i=G(e),s=ae(e),c=B(e),u=oe(e),[d,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),g=e=>{m.current=e,p(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=o(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?l(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)),ee=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(h,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(F,{variant:`destructive`,children:`This board’s rules didn’t load.`});let P=e=>u.mutateAsync(e).catch(e=>I.error(Tt(e))),te=(e,n,r)=>{let i=J(y,e).map(e=>e.id);P([{kind:`reorder`,boardKey:t.id,ids:f(y,i,n,r)}])},ne=e=>{v(void 0),g(e)},L=async e=>{let n=m.current,r=n?.rule,i=()=>n!==void 0&&m.current===n;v(void 0);try{if(r)await u.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 u.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await ie(n,e.on).catch(e=>I.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return re(r);v(Tt(e))}},re=async e=>{let t=m.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.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),I.error(`Someone else deleted this rule first.`)))},ie=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),o=a.indexOf(e.id),s=n.flatMap(t=>{let n=J(i,t),r=n[he(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),c=Math.min(...s);o<0||!(c<o)||await u.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:f(i,a,o,c)}])},R=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:ge(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(F,{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`:a(t,k)??k,leaving:A,showAll:O(e,t.id)}),ve.filter(e=>e.events.some(e=>ee([...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(q)?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=q(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return ee([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?R:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>ne({rule:e,step:t}),onAdd:()=>ne({event:r,step:`conditions`}),onMove:(e,t)=>te(r,e,t),onToggle:(e,t)=>void P([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void P([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&I.success(`Deleted “${e.name}”`)),onUngate:e=>void P([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&I.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),d&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:d.rule,initialEvent:d.event,initialStep:d.step,readOnly:!S,saving:u.isPending,error:_,onSave:e=>void L(e),onClose:()=>g(void 0)},d.rule?`${d.rule.id}:${d.rule.revision}`:`new-${d.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=i(),a=u()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,f=C(e.id,a).data?.board,p=d({breadcrumbs:l&&f?(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:f.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(s,{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)(z,{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};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Jt as t,aa as n,da as r,qt as i}from"./GithubIcon.es-BPBhMx2H.js";import{O as a,T as o,k as s,o as c}from"./IconChevronRightMedium.es-BjSIsine.js";import{j as l}from"./Sidebar.es-DSPzNNju.js";import{t as u}from"./popup-anchor.es-B4jCSTe8.js";var d=e(s(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:o(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:s,href:l,isCurrent:m,action:g,switcher:_,icon:v,isLoading:y,children:b,...x})=>{let S=a||`span`,C=!(!_||!m&&(s||l)),w=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:w,className:o(`group flex h-control-sm min-w-0 items-center`,m?`shrink`:`shrink-0`,C&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(S,{"aria-current":m?`page`:void 0,className:o(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,n.sm,c,m?`max-w-xs cursor-default text-foreground`:C?o(t,`max-w-48`):o(i,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:s,href:l,...x,children:[v&&(0,f.jsx)(r,{className:o(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:v}),y?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:b})]}),_&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:o(`-ml-1 flex h-control-sm shrink-0 items-center`,C&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:w,children:_})}),g&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:g})]}),!m&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(r,{className:`text-placeholder`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};