mastra 1.40.2-alpha.5 → 1.40.2-alpha.6
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.
- package/dist/analytics-DcvNOF6c.js +0 -2
- package/dist/api-BkUGttRB.js +0 -2
- package/dist/client-CKs2N-Pd.js +0 -2
- package/dist/create-DlrSzNAx.js +0 -2
- package/dist/credentials-BV9JpjhI.js +0 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/factory/assets/{BoardConfigPage-BTr0jvLn.js → BoardConfigPage-D6MXB-5e.js} +1 -1
- package/dist/factory/assets/{BoardIntakePage-Da4JQ22k.js → BoardIntakePage-Bgmt_xi0.js} +1 -1
- package/dist/factory/assets/{BoardRulesPage-D6GkRTF9.js → BoardRulesPage-7z2gx492.js} +1 -1
- package/dist/factory/assets/{ConditionRows-CjF282lW.js → ConditionRows-EkFcLg06.js} +1 -1
- package/dist/factory/assets/{CreateFactoryPage-uaZNXgpz.js → CreateFactoryPage-CpCoY7SG.js} +1 -1
- package/dist/factory/assets/{FactorySkillPage-CZ7rCPjs.js → FactorySkillPage-5Gc2equn.js} +1 -1
- package/dist/factory/assets/{FactorySkillsPage-CblDbc1L.js → FactorySkillsPage-BYbovjqy.js} +1 -1
- package/dist/factory/assets/{IconScript.es-C6vqoVRi.js → IconScript.es-Bpq9XfIa.js} +1 -1
- package/dist/factory/assets/{KnowledgePage-H0Kk2JFY.js → KnowledgePage-TsgNTo8W.js} +1 -1
- package/dist/factory/assets/{MastraGatewayBilling-MzEHJrbM.js → MastraGatewayBilling-DJPEHZAK.js} +1 -1
- package/dist/factory/assets/{NewBoardPage-yGoOyI6L.js → NewBoardPage-BodHD8H8.js} +1 -1
- package/dist/factory/assets/{NewPage-Y_33RBKp.js → NewPage-DzoengAI.js} +1 -1
- package/dist/factory/assets/{OnboardingPage-B6KP-3qb.js → OnboardingPage-C4cH2Ucw.js} +1 -1
- package/dist/factory/assets/{ProviderBrandIcon-BAS6fqCy.js → ProviderBrandIcon-CdBRvNbA.js} +1 -1
- package/dist/factory/assets/{RulesPage-Cd7MrfxG.js → RulesPage-DLQAZVIA.js} +1 -1
- package/dist/factory/assets/{SessionLayout-DLMjS0Tm.js → SessionLayout-DcW2_NIr.js} +2 -2
- package/dist/factory/assets/{SessionPage-w0BtLrFz.js → SessionPage-DV9mReRe.js} +1 -1
- package/dist/factory/assets/{SettingsPage-a9BNUllJ.js → SettingsPage-CRTowo_E.js} +1 -1
- package/dist/factory/assets/{SignInPage-D2t5nF_G.js → SignInPage-BuZ1OFJf.js} +1 -1
- package/dist/factory/assets/{SlackConnectionPage-3gwHZ7ZK.js → SlackConnectionPage-BNQ6GOrm.js} +1 -1
- package/dist/factory/assets/{StackedDiffs-tFZn7pts.js → StackedDiffs-thBeypvG.js} +1 -1
- package/dist/factory/assets/{Tree-B90XgTY4-C8jhe9mH.js → Tree-B90XgTY4-CO90N5uT.js} +1 -1
- package/dist/factory/assets/{index-SGLMjvLV.js → index-DfNj4qTr.js} +2 -2
- package/dist/factory/assets/relative-time.es-Dgi2DC2E.js +1 -0
- package/dist/factory/assets/{useDraftModelGuards-D8vCJsuU.js → useDraftModelGuards-CVpGc7UY.js} +1 -1
- package/dist/factory/assets/{workspaces-GFWPtETj.js → workspaces-C47kKdw3.js} +1 -1
- package/dist/factory/index.html +1 -1
- package/dist/index.js +2 -4
- package/dist/orgs-U8xs5uGQ.js +0 -2
- package/dist/runtime-BmQZaJZI.js +0 -2
- package/dist/studio/assets/{index-DC_qaicL.js → index-WsPILIoi.js} +2 -2
- package/dist/studio/assets/{main-c04Pumjz.js → main-RtWN6k82.js} +75 -75
- package/dist/studio/index.html +1 -1
- package/package.json +7 -6
- package/dist/analytics/index.d.ts.map +0 -1
- package/dist/analytics-DcvNOF6c.js.map +0 -1
- package/dist/api-BkUGttRB.js.map +0 -1
- package/dist/client-CKs2N-Pd.js.map +0 -1
- package/dist/commands/actions/add-scorer.d.ts.map +0 -1
- package/dist/commands/actions/build-project.d.ts.map +0 -1
- package/dist/commands/actions/create-project.d.ts.map +0 -1
- package/dist/commands/actions/init-project.d.ts.map +0 -1
- package/dist/commands/actions/lint-project.d.ts.map +0 -1
- package/dist/commands/actions/list-scorers.d.ts.map +0 -1
- package/dist/commands/actions/migrate.d.ts.map +0 -1
- package/dist/commands/actions/start-dev-server.d.ts.map +0 -1
- package/dist/commands/actions/start-project.d.ts.map +0 -1
- package/dist/commands/actions/start-studio.d.ts.map +0 -1
- package/dist/commands/api/client.d.ts.map +0 -1
- package/dist/commands/api/errors.d.ts.map +0 -1
- package/dist/commands/api/factory-route-metadata.generated.d.ts.map +0 -1
- package/dist/commands/api/feedback-score-schemas.generated.d.ts.map +0 -1
- package/dist/commands/api/feedback-score-writes.d.ts.map +0 -1
- package/dist/commands/api/headers.d.ts.map +0 -1
- package/dist/commands/api/index.d.ts.map +0 -1
- package/dist/commands/api/input.d.ts.map +0 -1
- package/dist/commands/api/learning-route-metadata.d.ts.map +0 -1
- package/dist/commands/api/normalizers.d.ts.map +0 -1
- package/dist/commands/api/output.d.ts.map +0 -1
- package/dist/commands/api/response-normalizer.d.ts.map +0 -1
- package/dist/commands/api/route-metadata.generated.d.ts.map +0 -1
- package/dist/commands/api/schema.d.ts.map +0 -1
- package/dist/commands/api/target.d.ts.map +0 -1
- package/dist/commands/api/types.d.ts.map +0 -1
- package/dist/commands/auth/api.d.ts.map +0 -1
- package/dist/commands/auth/client.d.ts.map +0 -1
- package/dist/commands/auth/credentials.d.ts.map +0 -1
- package/dist/commands/auth/login.d.ts.map +0 -1
- package/dist/commands/auth/orgs.d.ts.map +0 -1
- package/dist/commands/auth/tokens.d.ts.map +0 -1
- package/dist/commands/auth/whoami.d.ts.map +0 -1
- package/dist/commands/build/BuildBundler.d.ts.map +0 -1
- package/dist/commands/build/build.d.ts.map +0 -1
- package/dist/commands/build/factory-ui-build.d.ts.map +0 -1
- package/dist/commands/build/guard-live-dev-server.d.ts.map +0 -1
- package/dist/commands/connect/api.d.ts.map +0 -1
- package/dist/commands/connect/connect.d.ts.map +0 -1
- package/dist/commands/connect/nango.d.ts.map +0 -1
- package/dist/commands/create/coding-agents.d.ts.map +0 -1
- package/dist/commands/create/command.d.ts.map +0 -1
- package/dist/commands/create/create.d.ts.map +0 -1
- package/dist/commands/create/provider-adapter.d.ts.map +0 -1
- package/dist/commands/create/utils.d.ts.map +0 -1
- package/dist/commands/create/version-resolver.d.ts.map +0 -1
- package/dist/commands/db/db.d.ts.map +0 -1
- package/dist/commands/db/index.d.ts.map +0 -1
- package/dist/commands/db/platform-api.d.ts.map +0 -1
- package/dist/commands/deploy/__fixtures__/poll-output.d.ts.map +0 -1
- package/dist/commands/deploy/auto-provision-database.d.ts.map +0 -1
- package/dist/commands/deploy/env-vars.d.ts.map +0 -1
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/validate-dir.d.ts.map +0 -1
- package/dist/commands/deploy-preflight.d.ts.map +0 -1
- package/dist/commands/deploy-suggestions.d.ts.map +0 -1
- package/dist/commands/dev/DevBundler.d.ts.map +0 -1
- package/dist/commands/dev/dev-lock.d.ts.map +0 -1
- package/dist/commands/dev/dev.d.ts.map +0 -1
- package/dist/commands/dev/env-state.d.ts.map +0 -1
- package/dist/commands/env/deploy-suggestions.d.ts.map +0 -1
- package/dist/commands/env/env-file.d.ts.map +0 -1
- package/dist/commands/env/env.d.ts.map +0 -1
- package/dist/commands/env/index.d.ts.map +0 -1
- package/dist/commands/env/platform-api.d.ts.map +0 -1
- package/dist/commands/env/resolve-project.d.ts.map +0 -1
- package/dist/commands/env/vars.d.ts.map +0 -1
- package/dist/commands/experiment/ExperimentBundler.d.ts.map +0 -1
- package/dist/commands/experiment/build.d.ts.map +0 -1
- package/dist/commands/experiment/runtime.d.ts.map +0 -1
- package/dist/commands/gateway/api.d.ts.map +0 -1
- package/dist/commands/gateway/credits.d.ts.map +0 -1
- package/dist/commands/init/init.d.ts.map +0 -1
- package/dist/commands/init/mcp-docs-server-install.d.ts.map +0 -1
- package/dist/commands/init/observability-provision.d.ts.map +0 -1
- package/dist/commands/init/skills-install.d.ts.map +0 -1
- package/dist/commands/init/utils.d.ts.map +0 -1
- package/dist/commands/lint/index.d.ts.map +0 -1
- package/dist/commands/lint/rules/index.d.ts.map +0 -1
- package/dist/commands/lint/rules/mastraCoreRule.d.ts.map +0 -1
- package/dist/commands/lint/rules/nextConfigRule.d.ts.map +0 -1
- package/dist/commands/lint/rules/tsConfigRule.d.ts.map +0 -1
- package/dist/commands/lint/rules/types.d.ts.map +0 -1
- package/dist/commands/migrate/MigrateBundler.d.ts.map +0 -1
- package/dist/commands/migrate/migrate-paths.d.ts.map +0 -1
- package/dist/commands/migrate/migrate.d.ts.map +0 -1
- package/dist/commands/scorers/add-new-scorer.d.ts.map +0 -1
- package/dist/commands/scorers/available-scorers.d.ts.map +0 -1
- package/dist/commands/scorers/file-utils.d.ts.map +0 -1
- package/dist/commands/scorers/list-all-scorers.d.ts.map +0 -1
- package/dist/commands/scorers/types.d.ts.map +0 -1
- package/dist/commands/server/deploy-suggestions.d.ts.map +0 -1
- package/dist/commands/server/deploy.d.ts.map +0 -1
- package/dist/commands/server/env.d.ts.map +0 -1
- package/dist/commands/server/lifecycle.d.ts.map +0 -1
- package/dist/commands/server/platform-api.d.ts.map +0 -1
- package/dist/commands/start/index.d.ts.map +0 -1
- package/dist/commands/start/start.d.ts.map +0 -1
- package/dist/commands/studio/deploy-list.d.ts.map +0 -1
- package/dist/commands/studio/deploy-logs.d.ts.map +0 -1
- package/dist/commands/studio/deploy-status.d.ts.map +0 -1
- package/dist/commands/studio/deploy-suggestions.d.ts.map +0 -1
- package/dist/commands/studio/deploy.d.ts.map +0 -1
- package/dist/commands/studio/index.d.ts.map +0 -1
- package/dist/commands/studio/platform-api.d.ts.map +0 -1
- package/dist/commands/studio/project-config.d.ts.map +0 -1
- package/dist/commands/studio/projects.d.ts.map +0 -1
- package/dist/commands/studio/studio.d.ts.map +0 -1
- package/dist/commands/traces/import/action.d.ts.map +0 -1
- package/dist/commands/traces/import/command.d.ts.map +0 -1
- package/dist/commands/traces/import/manifest.d.ts.map +0 -1
- package/dist/commands/traces/import/prepared-traces.d.ts.map +0 -1
- package/dist/commands/traces/import/provider.d.ts.map +0 -1
- package/dist/commands/traces/import/providers/langfuse/adapter.d.ts.map +0 -1
- package/dist/commands/traces/import/providers/langfuse/client.d.ts.map +0 -1
- package/dist/commands/traces/import/providers/langfuse/ids.d.ts.map +0 -1
- package/dist/commands/traces/import/providers/langfuse/reader.d.ts.map +0 -1
- package/dist/commands/traces/import/providers/langfuse/types.d.ts.map +0 -1
- package/dist/commands/traces/import/report.d.ts.map +0 -1
- package/dist/commands/traces/import/target.d.ts.map +0 -1
- package/dist/commands/traces/import/targets/mastra-platform.d.ts.map +0 -1
- package/dist/commands/traces/import/types.d.ts.map +0 -1
- package/dist/commands/traces/import/upload.d.ts.map +0 -1
- package/dist/commands/traces/import/validation.d.ts.map +0 -1
- package/dist/commands/traces/import/verification.d.ts.map +0 -1
- package/dist/commands/traces/import/verifier.d.ts.map +0 -1
- package/dist/commands/utils.d.ts.map +0 -1
- package/dist/commands/worker/WorkerBundler.d.ts.map +0 -1
- package/dist/commands/worker/build.d.ts.map +0 -1
- package/dist/commands/worker/dev.d.ts.map +0 -1
- package/dist/commands/worker/start.d.ts.map +0 -1
- package/dist/create-DlrSzNAx.js.map +0 -1
- package/dist/credentials-BV9JpjhI.js.map +0 -1
- package/dist/factory/assets/relative-time.es-CP_EVPHW.js +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/internal/auth.d.ts.map +0 -1
- package/dist/orgs-U8xs5uGQ.js.map +0 -1
- package/dist/runtime-BmQZaJZI.js.map +0 -1
- package/dist/services/service.deps.d.ts.map +0 -1
- package/dist/services/service.env.d.ts.map +0 -1
- package/dist/services/service.file.d.ts.map +0 -1
- package/dist/utils/check-peer-deps.d.ts.map +0 -1
- package/dist/utils/clack-bar.d.ts.map +0 -1
- package/dist/utils/clone-template.d.ts.map +0 -1
- package/dist/utils/deploy-bundle-size.d.ts.map +0 -1
- package/dist/utils/deploy-failure-output.d.ts.map +0 -1
- package/dist/utils/deploy-log-format.d.ts.map +0 -1
- package/dist/utils/deploy-upload.d.ts.map +0 -1
- package/dist/utils/detect-project-type.d.ts.map +0 -1
- package/dist/utils/dev-logger.d.ts.map +0 -1
- package/dist/utils/find-mastra-entry.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/mastra-packages.d.ts.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/platform-region.d.ts.map +0 -1
- package/dist/utils/polling.d.ts.map +0 -1
- package/dist/utils/run-build.d.ts.map +0 -1
- package/dist/utils/source-hash.d.ts.map +0 -1
- package/dist/utils/template-utils.d.ts.map +0 -1
- package/dist/utils/validate-presets.d.ts.map +0 -1
- package/dist/utils/workers-manifest-guard.d.ts.map +0 -1
|
@@ -1761,5 +1761,3 @@ var PosthogAnalytics = class PosthogAnalytics {
|
|
|
1761
1761
|
}
|
|
1762
1762
|
};
|
|
1763
1763
|
export { FileService as A, validateCreateOptionConflicts as B, readPackageName as C, writeCodeSample as D, writeClaudeMarkdown as E, getCreateMode as F, normalizeCreateCommandOptions as I, parseCreateLLMProvider as L, installMastraDocsMCPServer as M, CREATE_LLM_PROVIDERS as N, writeIndexFile as O, configureCreateCommand as P, parseCreateTimeout as R, interactivePrompt as S, writeAgentsMarkdown as T, validateProjectName as V, checkAndInstallCoreDeps as _, getPackageManager as a, createMastraDir as b, gitInit as c, parseLlmProvider as d, parseMcp as f, LLMProvider as g, COMPONENTS as h, setAnalytics as i, DepsService as j, writeObservabilityEnv as k, isGitInitialized as l, wrapAction as m, bucketApiHost as n, getSourceMapNodeArgs as o, shouldSkipDotenvLoading as p, getAnalytics as r, getVersionTag as s, PosthogAnalytics as t, parseComponents as u, checkForPkgJson as v, writeAPIKey as w, getAPIKey as x, createComponentsDir as y, selectMatchingDistTag as z };
|
|
1764
|
-
|
|
1765
|
-
//# sourceMappingURL=analytics-DcvNOF6c.js.map
|
package/dist/api-BkUGttRB.js
CHANGED
package/dist/client-CKs2N-Pd.js
CHANGED
|
@@ -132,5 +132,3 @@ function platformFetch(input, init) {
|
|
|
132
132
|
return authenticatedFetch(input, init);
|
|
133
133
|
}
|
|
134
134
|
export { createApiClient as a, setCurrentAuth as c, authHeaders as i, throwApiError as l, MASTRA_PROJECTS_URL as n, extractApiErrorDetail as o, MASTRA_STUDIO_URL as r, platformFetch as s, MASTRA_PLATFORM_API_URL as t };
|
|
135
|
-
|
|
136
|
-
//# sourceMappingURL=client-CKs2N-Pd.js.map
|
package/dist/create-DlrSzNAx.js
CHANGED
|
@@ -1545,5 +1545,3 @@ async function resolveTemplate(mode, template) {
|
|
|
1545
1545
|
return found;
|
|
1546
1546
|
}
|
|
1547
1547
|
export { runCreateCommand as a, isCreateCancelledError as i, create as n, installMastraSkills as o, getCreateCommandAnalyticsArgs as r, provisionObservabilityProject as s, CreateCancelledError as t };
|
|
1548
|
-
|
|
1549
|
-
//# sourceMappingURL=create-DlrSzNAx.js.map
|
|
@@ -384,5 +384,3 @@ async function validateOrgAccess(token, orgId) {
|
|
|
384
384
|
if (!(await fetchOrgs(token)).some((o) => o.id === orgId)) throw new Error(`No access to organization ${orgId}. Run: mastra auth orgs`);
|
|
385
385
|
}
|
|
386
386
|
export { isInteractive as a, openBrowser as c, tryRefreshToken as d, validateOrgAccess as f, getToken as i, saveCredentials as l, clearCredentials as n, loadCredentials as o, verifyToken as p, getCurrentOrgId as r, login as s, LoginCancelledError as t, setCurrentOrgId as u };
|
|
387
|
-
|
|
388
|
-
//# sourceMappingURL=credentials-BV9JpjhI.js.map
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-D9PSmzYq.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,Cr as a,Fr as o,Gn as s,Nr as c,O as l,Pr as u,Qn as d,Tr as f,Wn as p,Xn as m,Zn as h,_r as g,ar as _,br as v,dr as y,er as b,fr as x,gr as S,in as C,ir as w,k as T,mr as E,nn as ee,nr as D,pn as te,pr as O,rn as k,rr as A,sr as j,tn as M,tr as N,ur as P,wr as ne,xr as re}from"./index-SGLMjvLV.js";import{a as ie}from"./Sidebar.es-9pwBnu_Z.js";import{d as F,f as I,i as ae,t as L,u as R}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as oe,T as z,k as se,n as B,s as V,t as ce}from"./IconChevronRightMedium.es-BjSIsine.js";import{$n as H,Fi as le,Li as ue,Pi as de,Qr as fe,cr as pe,dr as me,n as U,ni as W,r as he,zt as ge}from"./GithubIcon.es-B1lB1Q-8.js";import{c as _e,o as ve,r as ye,s as be,t as xe}from"./useBoardEditor-Dm78Yoiu.js";import{i as Se,t as Ce}from"./SkillBadges-DbbPhC5O.js";import{a as G,c as we,f as Te,l as Ee,s as De}from"./boardConfigPaths-Btimpi_r.js";import{t as K}from"./AlertDialog.es-Z2cFKrup.js";import{t as q}from"./SettingsSubsection-DznON6FW.js";import{r as Oe}from"./CompositeItem-CD2x3KaL.js";import{n as ke}from"./useBoardCatalog-DZf1osB2.js";import{h as Ae,o as je}from"./useIntakeRoutes-BNBPe6sx.js";import{a as Me,d as Ne,t as Pe}from"./BoardIcons-DXB--WrY.js";import{i as Fe,n as Ie,r as Le,t as Re}from"./IconPencil.es-D_eBYY1c.js";import{r as ze}from"./overlays-B3sO28Cg.js";import{t as Be}from"./DescriptionMarkdown-CoP2xvHU.js";import{h as Ve,w as He,y as Ue}from"./ruleLanes-D9QkgLJm.js";import{k as We}from"./TabsRoot-C1o0G1CK.js";import{t as Ge}from"./CodeEditor-CfxlNg4f-D29InJfs.js";import{a as Ke,n as qe,r as Je,t as Ye}from"./Field.es-BmqB8MIv.js";import{t as Xe}from"./input-DqReKX0A-B4MUvQwj.js";import{a as Ze,n as Qe}from"./input-group-C2kg3je7-38FwKlyX.js";import{a as $e,i as et,n as tt,r as nt,t as rt}from"./InputNumber.es-BoS5sRR-.js";import{i as it,n as at,r as ot,t as st}from"./select-Bdt18YBg-DJqvU5Dv.js";import{E as ct}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";import{n as lt,t as ut}from"./ConditionRows-CjF282lW.js";import{n as dt}from"./IconUserDuo.es-0xR_m2_v.js";import{_t as ft}from"./useSessionRows-aTHnrKGG.js";import{t as pt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as mt}from"./TrashIcon.es-CLx-KWTg.js";import{n as ht,t as gt}from"./boardCatalog-y-s19dQU.js";import{t as _t}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as vt}from"./InlineText-vWKzGKx_.js";import{t as yt}from"./LoadErrorState-DVbqZ6DX.js";var J=e(se(),1),bt=`mx-auto w-full max-w-2xl`,xt=`[container-type:inline-size] h-full min-h-0 overflow-auto overscroll-x-contain [scrollbar-gutter:stable]`,St=`sticky left-0 w-[100cqw] px-4`,Y=oe();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:z(St,i),children:(0,Y.jsx)(`div`,{className:z(bt,n),children:r})}):(0,Y.jsx)(`div`,{className:z(bt,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?we(e,t,a):G(e,t,n.key),f=a?l:ze;return(0,Y.jsxs)(Ie,{children:[(0,Y.jsxs)(Fe,{delay:0,closeDelay:100,render:(0,Y.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`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(Ce,{skill:o})]}),s?(0,Y.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,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(d,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(Ie,{children:[(0,Y.jsx)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ve(e.length)}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(s,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:a,onAutoStart:o}){let s=ke(e),c=je(e),l=s.isPending||c.isPending,u=s.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>h(e,n)),g=c.data&&u?i(c.data.intakeRoutes,{key:t,initialPhase:u}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[a&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:a}),c.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,children:(0,Y.jsx)(U.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),g&&g.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:g.leaving,title:`Rules that send cards to other boards`,to:De(e,t,`leaving`),boardId:t,boards:s.data}),` `,g.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,Et),children:n.map(i=>{let a=Me(t,i.kind),c=g?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(H,{to:G(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(Pe,{stage:i.key,kind:a,decorative:!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(m,{boardId:t,phase:h(i,n),phases:f,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsx)(Oe,{className:`h-4 w-20`}):g?c.length>0?(0,Y.jsx)(Tt,{rules:c,title:`Rules that move cards into ${i.name}`,to:De(e,t,{into:i.key}),boardId:t,boards:s.data}):(0,Y.jsx)(d,{children:`No rule moves cards here`}):(0,Y.jsx)(d,{children:`Rules didn’t load`}),i.key===u&&(0,Y.jsx)(d,{children:`New cards start here`})]}),starts:(0,Y.jsx)(p,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:o&&(e=>o(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=Ue,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?a(s,n):v(s,p),_=e=>{m(e);let t=re(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Ye,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ke,{htmlFor:h,children:e}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,a(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(qe,{children:t}),p===void 0?r?(0,Y.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:He(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(ut,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,a(s,e))}})}):(0,Y.jsx)(M,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Je,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(Pe,{stage:t.key,kind:Me(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:z(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Y.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(dt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(ft,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(pt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:d}),(0,Y.jsx)(le,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ae,{children:[(0,Y.jsxs)(Ye,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(F,{children:e}),(0,Y.jsx)(qe,{children:t}),i,n&&(0,Y.jsx)(Je,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(L,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Ge,{"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:i,factoryId:a,boardId:o,disabled:s,rawRules:c,onChange:u,onRawRule:d,onUnfinished:f,onRemove:p}){let m=lt(a),h=e.kind===`working`,g=y(e,t),_=e.runner?.instructions??``,v=e.runner?.goal,x=v?.objective??``,C=e.tools??[],w=e.exitTool?.id??``,T=e.runner?.skill,E=T?r?.find(e=>e.name===T):void 0,ee=T!==void 0&&r!==void 0&&E===void 0,O=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));u({...e,runner:Object.keys(r).length>0?r:null})},k=e=>({text:c[e],onChange:t=>d(e,t)}),M=(0,Y.jsx)(jt,{phase:e,phases:t,next:g,required:new Set(n),boardId:o,disabled:s,onChange:t=>u({...e,nextPhases:t})}),P=p&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(W,{variant:`ghost`,icon:(0,Y.jsx)(mt,{}),onClick:p,children:[`Remove `,e.name]})});return h?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Ne,{}),title:`Starts`,children:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Start on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:s,onCheckedChange:t=>{u(S(e,t)),t||d(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoStartWhen`),onUnfinished:e=>f(`autoStartWhen`,e),onChange:t=>u({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ze,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(_.length,N)}`,error:_.length>1e3?`Too long to save.`:void 0,disabled:s,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:_,placeholder:`Tell the agent what to do, in Markdown`,disabled:s,onChange:e=>O({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(x.length,D)}`,error:x.length>2e3?`Too long to save.`:void 0,disabled:s,after:v&&(0,Y.jsxs)(Ye,{invalid:!j(v.maxRuns),disabled:s,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ke,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Y.jsx)(rt,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:v.maxRuns??null,disabled:s,onValueChange:e=>{let{maxRuns:t,...n}=v;O({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(nt,{size:`sm`,children:[(0,Y.jsx)($e,{placeholder:`Default`}),(0,Y.jsxs)(Qe,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(Ze,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(tt,{}),(0,Y.jsx)(et,{})]})]})})]}),!j(v.maxRuns)&&(0,Y.jsxs)(Je,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:x,placeholder:`Describe what done looks like`,disabled:s,onChange:e=>O({goal:e.trim()?{...v,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:b,disabled:s,onChange:e=>O({context:e.target.value})})}),(0,Y.jsx)(q,{title:`Skill`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(st,{value:T??Pt,disabled:s,onValueChange:e=>O({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(it,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:T??`No skill`})]})}),(0,Y.jsxs)(at,{children:[(0,Y.jsx)(ot,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ot,{value:e.name,children:e.name},e.name))]})]}),ee&&(0,Y.jsx)(We,{variant:`destructive`,children:`Not found`}),E?.error&&(0,Y.jsx)(We,{variant:`destructive`,children:`Failed to load`}),E&&(0,Y.jsx)(Ce,{skill:E}),E&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,icon:i?(0,Y.jsx)(Re,{}):(0,Y.jsx)(he,{}),"aria-label":`${i?`Edit`:`View`} ${E.name}`,className:`ml-auto`,render:(0,Y.jsx)(H,{to:we(a,o,E.name)}),children:i?`Edit`:`View`})]}),E?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,E.error]}):ee?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,T,` skill, so cards entering `,e.name,` fail to start.`]}):E?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:E.description})]})})}),(0,Y.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(L,{children:A.map(t=>(0,Y.jsx)(I,{label:t.label,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: ${t.label}`,checked:C.includes(t.id),disabled:s,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:C.includes(e));u({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ne,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} exit tool`,value:w,disabled:s,onChange:t=>{let n=t.target.value.trim();u({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||d(`autoApproveWhen`,void 0)}})}),w!==``&&(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Approve on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: approve ${w} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:s,onCheckedChange:t=>{u({...e,exitTool:{...e.exitTool,id:w,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||d(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoApproveWhen`),onUnfinished:e=>f(`autoApproveWhen`,e),onChange:t=>u({...e,exitTool:{...e.exitTool,id:w,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(te,{}),title:`Allowed moves`,children:M})]}),P]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(q,{title:`Allowed moves`,children:M}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:c}){let{board:u,canEdit:d}=i,{draft:f,rawRules:p,locked:m,setDraft:h,setRawRule:g,discard:v}=k(e.id,t,u),[y,b]=(0,J.useState)(0),C=()=>{v(),b(e=>e+1)},ee=me(),D=_e(e.id,t),te=fe(),A=!d||!u.editable,j=n?f.phases.find(e=>e.key===n):void 0,M=j&&`${j.key}:${u.revision??`code`}:${y}`,[N,P]=(0,J.useState)({page:M,fields:[]});N.page!==M&&P({page:M,fields:[]});let ne=N.page===M?N.fields:[],re=(e,t)=>P(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ie=!A&&(_(f,u)||Object.keys(p).length>0||ne.length>0),F=f.phases.filter(e=>x(e,p)||e===j&&ne.length>0),I=f.name.trim()===``,ae=D.error?.code===`revision_mismatch`,R=pe(({nextLocation:n})=>{let r=te.getQueryData(ge.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=Te(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=G(e.id,t),se;return se=n&&!j?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[u.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(W,{size:`sm`,render:(0,Y.jsx)(H,{to:oe}),children:`Back to general`})}):j?(0,Y.jsx)(Rt,{phase:j,phases:f.phases,requiredNextPhases:u.codeBehaviour?.[j.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:A||m,rawRules:{autoStartWhen:p[O(j.key,`autoStartWhen`)],autoApproveWhen:p[O(j.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{g(O(j.key,e),t),re(e,!1)},onUnfinished:re,onRemove:A||m||!w(f.phases,j.key,u.codeBehaviour)?void 0:()=>{for(let e of zt)g(O(j.key,e),void 0);h(e=>({...e,phases:E(e.phases,j.key)})),ee(oe)},onChange:e=>h(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},M):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:f.phases,skills:a,onAutoStart:A||m?void 0:(e,t)=>{h(n=>({...n,phases:n.phases.map(n=>n.key===e?S(n,t):n)})),t||g(O(e,`autoStartWhen`),void 0)},action:s&&!A?(0,Y.jsx)(T,{factoryId:e.id,boardId:t,board:u,disabled:m}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(q,{title:`Factory`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(H,{to:Ee(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(ce,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!j&&`w-max min-w-full`),children:[u.editable?!d&&(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!j&&u.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(U.Message,{children:u.problems.join(` `)})})}),se,ie&&(0,Y.jsxs)(X,{pinned:!j,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[ae&&(0,Y.jsx)(U,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(U.Button,{onClick:c,children:`Reload`}),children:(0,Y.jsx)(U.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),D.error&&!ae&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not saved. `,D.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:I?`Name the board to save.`:F.length>0?`Fix ${F.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:D.isPending,onClick:C,children:`Discard`}),(0,Y.jsx)(W,{size:`sm`,variant:`primary`,disabled:D.isPending||I||F.length>0,onClick:()=>D.mutate({name:f.name,description:f.description,phases:f.phases,expectedRevision:u.revision??0}),children:D.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(K,{open:R.state===`blocked`,onOpenChange:e=>!e&&R.reset?.(),children:(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Discard changes to `,u.name,`?`]}),(0,Y.jsx)(K.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Keep editing`}),(0,Y.jsx)(W,{variant:`destructive`,size:`md`,onClick:()=>{v(),R.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(mt,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(K.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(K.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Y.jsx)(le,{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:s,locked:c,setDraft:l,setRawRule:u,discard:d}=k(e,t,i),f=ke(e),p=me(),m=!a||!i.editable||c,h=be(e,t),_=ve(e,t,()=>{d();let n=ht(f.data??[]).find(e=>e.id!==t);p(n?gt(e,n.id):`/factories/${e}`,{replace:!0})}),v=!n&&a&&i.editable,y=v&&i.source!==`stored`,b=v&&i.source!==`builtin`,x=n?s.phases.find(e=>e.key===n):void 0;if(n&&!x)return null;let S=e=>l(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),C=e=>{x&&(u(O(x.key,`autoStartWhen`),void 0),u(O(x.key,`autoApproveWhen`),void 0),l(t=>({...t,phases:t.phases.map(n=>n.key===x.key?g(n,e,t.phases):n)})))},w=x?x.name:s.name,T=(x?x.description:s.description)??``,E=x!==void 0&&!m&&!P(s.phases,x.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(o,{children:[(0,Y.jsxs)(o.Title,{className:`gap-2.5`,children:[x&&(0,Y.jsx)(Pe,{stage:x.key,kind:Me(t,x.kind),decorative:!0}),(0,Y.jsx)(vt,{value:w,label:x?`Phase name`:`Board name`,required:!0,readOnly:m,variant:`heading`,tone:`ink`,onChange:e=>x?S({name:e}):l(t=>({...t,name:e}))})]}),x&&(0,Y.jsx)(o.Meta,{beside:!0,children:E?(0,Y.jsxs)(st,{value:x.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&C(t)},children:[(0,Y.jsx)(it,{size:`sm`,"aria-label":`Phase kind`,children:$[x.kind].label}),(0,Y.jsx)(at,{children:Ut.map(e=>(0,Y.jsx)(ot,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[x.kind].label,meaning:$[x.kind].meaning,children:(0,Y.jsx)(We,{children:$[x.kind].label})})}),(T||!m)&&(0,Y.jsx)(o.Description,{children:(0,Y.jsx)(vt,{value:T,label:x?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:m,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>x?S({description:e||null}):l(t=>({...t,description:e||null}))})}),(y||b)&&(0,Y.jsxs)(o.Action,{className:`gap-1`,children:[y&&(0,Y.jsx)(Ht,{name:i.name,pending:c,onReset:()=>h.mutate(i.revision??0)}),b&&(0,Y.jsx)(Vt,{name:i.name,pending:c,onDelete:()=>_.mutate(i.revision??0)})]})]}),h.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not reset. `,h.error.reasons]})}),_.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not deleted. `,_.error.reasons]})})]})}function Kt(){let e=f(),i=ee(),a=i?.boardId??``,o=i?.phaseKey,{isMobile:s,desktopState:l}=ie(),d=s||l===`collapsed`,p=ye(e.id,a),m=Se(e.id),h=p.data?.board,g=C(e.id,a,h),_=o?g?.phases.find(e=>e.key===o):void 0,v=G(e.id,a),y=c({breadcrumbs:d&&h?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:H,to:gt(e.id,a),children:g?.name||h.name}),o?(0,Y.jsx)(t,{as:H,to:v,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),_&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:_.name})]}):void 0}),b=p.isSuccess&&(!o||_)?(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:o,response:p.data},`${a}:${p.data.board.revision??`code`}`):void 0,x=p.isPending?(0,Y.jsx)(L,{children:(0,Y.jsx)(R,{label:`Loading board`,rows:3})}):p.isError&&p.error instanceof xe&&p.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):p.isError?(0,Y.jsx)(yt,{title:`Couldn’t load this board`,error:p.error,onRetry:()=>void p.refetch(),retrying:p.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:o,response:p.data,skills:m.data?.skills,skillsEditable:m.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void p.refetch()},`${a}:${p.data.board.revision??`code`}`);return o?(0,Y.jsx)(u,{variant:`settings`,header:b,...y,children:x}):(0,Y.jsx)(u,{variant:`page`,body:`fixed`,header:b&&(0,Y.jsx)(`div`,{className:z(`mx-auto w-full max-w-2xl`,`pb-3`),children:b}),...y,children:(0,Y.jsx)(`div`,{className:p.isSuccess?xt:z(bt,`px-4`),children:x})})}export{Kt as BoardConfigPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-D9PSmzYq.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,Cr as a,Fr as o,Gn as s,Nr as c,O as l,Pr as u,Qn as d,Tr as f,Wn as p,Xn as m,Zn as h,_r as g,ar as _,br as v,dr as y,er as b,fr as x,gr as S,in as C,ir as w,k as T,mr as E,nn as ee,nr as D,pn as te,pr as O,rn as k,rr as A,sr as j,tn as M,tr as N,ur as P,wr as ne,xr as re}from"./index-DfNj4qTr.js";import{a as ie}from"./Sidebar.es-9pwBnu_Z.js";import{d as F,f as I,i as ae,t as L,u as R}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as oe,T as z,k as se,n as B,s as V,t as ce}from"./IconChevronRightMedium.es-BjSIsine.js";import{$n as H,Fi as le,Li as ue,Pi as de,Qr as fe,cr as pe,dr as me,n as U,ni as W,r as he,zt as ge}from"./GithubIcon.es-B1lB1Q-8.js";import{c as _e,o as ve,r as ye,s as be,t as xe}from"./useBoardEditor-Dm78Yoiu.js";import{i as Se,t as Ce}from"./SkillBadges-DbbPhC5O.js";import{a as G,c as we,f as Te,l as Ee,s as De}from"./boardConfigPaths-Btimpi_r.js";import{t as K}from"./AlertDialog.es-Z2cFKrup.js";import{t as q}from"./SettingsSubsection-DznON6FW.js";import{r as Oe}from"./CompositeItem-CD2x3KaL.js";import{n as ke}from"./useBoardCatalog-DZf1osB2.js";import{h as Ae,o as je}from"./useIntakeRoutes-BNBPe6sx.js";import{a as Me,d as Ne,t as Pe}from"./BoardIcons-DXB--WrY.js";import{i as Fe,n as Ie,r as Le,t as Re}from"./IconPencil.es-D_eBYY1c.js";import{r as ze}from"./overlays-B3sO28Cg.js";import{t as Be}from"./DescriptionMarkdown-CoP2xvHU.js";import{h as Ve,w as He,y as Ue}from"./ruleLanes-D9QkgLJm.js";import{k as We}from"./TabsRoot-C1o0G1CK.js";import{t as Ge}from"./CodeEditor-CfxlNg4f-D29InJfs.js";import{a as Ke,n as qe,r as Je,t as Ye}from"./Field.es-BmqB8MIv.js";import{t as Xe}from"./input-DqReKX0A-B4MUvQwj.js";import{a as Ze,n as Qe}from"./input-group-C2kg3je7-38FwKlyX.js";import{a as $e,i as et,n as tt,r as nt,t as rt}from"./InputNumber.es-BoS5sRR-.js";import{i as it,n as at,r as ot,t as st}from"./select-Bdt18YBg-DJqvU5Dv.js";import{E as ct}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";import{n as lt,t as ut}from"./ConditionRows-EkFcLg06.js";import{n as dt}from"./IconUserDuo.es-0xR_m2_v.js";import{_t as ft}from"./useSessionRows-aTHnrKGG.js";import{t as pt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as mt}from"./TrashIcon.es-CLx-KWTg.js";import{n as ht,t as gt}from"./boardCatalog-y-s19dQU.js";import{t as _t}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as vt}from"./InlineText-vWKzGKx_.js";import{t as yt}from"./LoadErrorState-DVbqZ6DX.js";var J=e(se(),1),bt=`mx-auto w-full max-w-2xl`,xt=`[container-type:inline-size] h-full min-h-0 overflow-auto overscroll-x-contain [scrollbar-gutter:stable]`,St=`sticky left-0 w-[100cqw] px-4`,Y=oe();function X({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Y.jsx)(`div`,{className:z(St,i),children:(0,Y.jsx)(`div`,{className:z(bt,n),children:r})}):(0,Y.jsx)(`div`,{className:z(bt,i,n),children:r})}function Ct({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,s=a!==void 0&&r!==void 0&&o===void 0,c=s||o?.error!==void 0,u=a&&!s?we(e,t,a):G(e,t,n.key),f=a?l:ze;return(0,Y.jsxs)(Ie,{children:[(0,Y.jsxs)(Fe,{delay:0,closeDelay:100,render:(0,Y.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`,c&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Y.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),c&&(0,Y.jsx)(`span`,{className:`sr-only`,children:s?`, skill not found`:`, skill failed to load`})]}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(f,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Y.jsx)(Ce,{skill:o})]}),s?(0,Y.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,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Y.jsx)(d,{children:`Loading the skill…`}),o?.content.trim()&&(0,Y.jsx)(wt,{title:`Skill instructions`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Y.jsx)(wt,{title:`${n.name} adds`,children:(0,Y.jsx)(Be,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Y.jsx)(wt,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Y.jsx)(B,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function wt({title:e,children:t}){return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Y.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Tt({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Y.jsxs)(Ie,{children:[(0,Y.jsx)(Fe,{delay:0,closeDelay:100,render:(0,Y.jsx)(H,{to:n}),className:z(V,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ve(e.length)}),(0,Y.jsxs)(Le,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Y.jsx)(B,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Y.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Y.jsx)(s,{rule:e,boardId:r,boards:i},e.id))})]})]})}var Et=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Dt({factoryId:e,boardId:t,phases:n,skills:r,action:a,onAutoStart:o}){let s=ke(e),c=je(e),l=s.isPending||c.isPending,u=s.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>h(e,n)),g=c.data&&u?i(c.data.intakeRoutes,{key:t,initialPhase:u}):void 0;return(0,Y.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[a&&(0,Y.jsx)(X,{pinned:!0,className:`flex justify-end`,children:a}),c.isError&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,children:(0,Y.jsx)(U.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),g&&g.leaving.length>0&&(0,Y.jsx)(X,{pinned:!0,className:`mb-4`,children:(0,Y.jsxs)(B,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Y.jsx)(Tt,{rules:g.leaving,title:`Rules that send cards to other boards`,to:De(e,t,`leaving`),boardId:t,boards:s.data}),` `,g.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Y.jsx)(`ol`,{"aria-label":`Phases`,className:z(`mx-auto flex w-max`,Et),children:n.map(i=>{let a=Me(t,i.kind),c=g?.into.get(i.key)??[];return(0,Y.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Y.jsxs)(H,{to:G(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Y.jsx)(Pe,{stage:i.key,kind:a,decorative:!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Y.jsx)(`div`,{className:`px-3 py-3`,children:(0,Y.jsx)(m,{boardId:t,phase:h(i,n),phases:f,arrivals:(0,Y.jsxs)(Y.Fragment,{children:[l?(0,Y.jsx)(Oe,{className:`h-4 w-20`}):g?c.length>0?(0,Y.jsx)(Tt,{rules:c,title:`Rules that move cards into ${i.name}`,to:De(e,t,{into:i.key}),boardId:t,boards:s.data}):(0,Y.jsx)(d,{children:`No rule moves cards here`}):(0,Y.jsx)(d,{children:`Rules didn’t load`}),i.key===u&&(0,Y.jsx)(d,{children:`New cards start here`})]}),starts:(0,Y.jsx)(p,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:o&&(e=>o(i.key,e))}),agent:(0,Y.jsx)(Ct,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Ot=`Finish or remove unfinished conditions to save.`;function kt({label:e,description:t,rule:n,disabled:r,facts:i=Ue,options:o,schema:s,json:c,onChange:l,onUnfinished:u}){let[d,f]=(0,J.useState)(void 0),p=c?c.text:d,m=c?c.onChange:f,h=(0,J.useId)(),g=p===void 0?a(s,n):v(s,p),_=e=>{m(e);let t=re(s,e);`problem`in t?l(n??null,t.problem):l(t.rule,void 0)};return(0,Y.jsxs)(Ye,{invalid:g!==void 0,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(Ke,{htmlFor:h,children:e}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{p===void 0?m(n?JSON.stringify(n,null,2):``):(m(void 0),l(n??null,a(s,n)))},children:p===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Y.jsx)(qe,{children:t}),p===void 0?r?(0,Y.jsx)(B,{id:h,as:`p`,variant:`caption`,tone:`muted`,children:He(n,o)}):(0,Y.jsx)(`div`,{id:h,children:(0,Y.jsx)(ut,{label:e,rule:n,facts:i,options:o,onChange:(e,t)=>{u?.(t),t?l(n??null,Ot):l(e,a(s,e))}})}):(0,Y.jsx)(M,{id:h,"aria-label":`${e} JSON`,value:p,disabled:r,rows:6,onChange:e=>_(e.target.value)}),g&&(0,Y.jsx)(Je,{children:g})]})}var At=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function jt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Y.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Y.jsx)(Pe,{stage:t.key,kind:Me(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Y.jsxs)(`li`,{className:z(At,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:z(At,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,V),children:[(0,Y.jsx)(`span`,{className:z(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Y.jsx)(Mt,{children:t.name}),(0,Y.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Y.jsx)(dt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Y.jsx)(ft,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Y.jsx)(pt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Y.jsx)(`li`,{className:`min-w-0`,children:l?(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:d}),(0,Y.jsx)(le,{children:`Factory's code makes this move`})]}):d},t.key)})})}function Mt({children:e}){return(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`truncate`,children:e})}function Nt({label:e,children:t}){return(0,Y.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Z({icon:e,title:t,description:n,children:r}){let i=(0,J.useId)();return(0,Y.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Y.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Y.jsx)(B,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Pt=`__none__`,Ft=`sm:max-w-xs`,It=(e,t)=>e>=t-200?` ${e}/${t}`:``;function Q({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Y.jsxs)(ae,{children:[(0,Y.jsxs)(Ye,{invalid:!!n,disabled:r,children:[(0,Y.jsx)(F,{children:e}),(0,Y.jsx)(qe,{children:t}),i,n&&(0,Y.jsx)(Je,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Y.jsx)(L,{children:(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(Ge,{"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:i,factoryId:a,boardId:o,disabled:s,rawRules:c,onChange:u,onRawRule:d,onUnfinished:f,onRemove:p}){let m=lt(a),h=e.kind===`working`,g=y(e,t),_=e.runner?.instructions??``,v=e.runner?.goal,x=v?.objective??``,C=e.tools??[],w=e.exitTool?.id??``,T=e.runner?.skill,E=T?r?.find(e=>e.name===T):void 0,ee=T!==void 0&&r!==void 0&&E===void 0,O=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));u({...e,runner:Object.keys(r).length>0?r:null})},k=e=>({text:c[e],onChange:t=>d(e,t)}),M=(0,Y.jsx)(jt,{phase:e,phases:t,next:g,required:new Set(n),boardId:o,disabled:s,onChange:t=>u({...e,nextPhases:t})}),P=p&&(0,Y.jsx)(`div`,{children:(0,Y.jsxs)(W,{variant:`ghost`,icon:(0,Y.jsx)(mt,{}),onClick:p,children:[`Remove `,e.name]})});return h?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsxs)(Nt,{label:`How ${e.name} runs`,children:[(0,Y.jsx)(Z,{icon:(0,Y.jsx)(Ne,{}),title:`Starts`,children:(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Start on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:s,onCheckedChange:t=>{u(S(e,t)),t||d(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoStartWhen`),onUnfinished:e=>f(`autoStartWhen`,e),onChange:t=>u({...e,autoStartWhen:t})})})]})}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ze,{}),title:`Agent runs`,children:[(0,Y.jsx)(Q,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${It(_.length,N)}`,error:_.length>1e3?`Too long to save.`:void 0,disabled:s,children:(0,Y.jsx)(Lt,{label:`${e.name} instructions`,value:_,placeholder:`Tell the agent what to do, in Markdown`,disabled:s,onChange:e=>O({instructions:e})})}),(0,Y.jsx)(Q,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${It(x.length,D)}`,error:x.length>2e3?`Too long to save.`:void 0,disabled:s,after:v&&(0,Y.jsxs)(Ye,{invalid:!j(v.maxRuns),disabled:s,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(Ke,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Y.jsx)(rt,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:v.maxRuns??null,disabled:s,onValueChange:e=>{let{maxRuns:t,...n}=v;O({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Y.jsxs)(nt,{size:`sm`,children:[(0,Y.jsx)($e,{placeholder:`Default`}),(0,Y.jsxs)(Qe,{align:`inline-end`,variant:`flush`,children:[(0,Y.jsx)(Ze,{className:`mr-1`,children:`runs`}),(0,Y.jsx)(tt,{}),(0,Y.jsx)(et,{})]})]})})]}),!j(v.maxRuns)&&(0,Y.jsxs)(Je,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Y.jsx)(Lt,{label:`${e.name} goal`,value:x,placeholder:`Describe what done looks like`,disabled:s,onChange:e=>O({goal:e.trim()?{...v,objective:e}:void 0})})}),(0,Y.jsx)(Q,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:b,disabled:s,onChange:e=>O({context:e.target.value})})}),(0,Y.jsx)(q,{title:`Skill`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsxs)(st,{value:T??Pt,disabled:s,onValueChange:e=>O({skill:e===Pt?void 0:String(e)}),children:[(0,Y.jsx)(it,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(l,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Y.jsx)(`span`,{className:`truncate`,children:T??`No skill`})]})}),(0,Y.jsxs)(at,{children:[(0,Y.jsx)(ot,{value:Pt,children:`None`}),(r??[]).map(e=>(0,Y.jsx)(ot,{value:e.name,children:e.name},e.name))]})]}),ee&&(0,Y.jsx)(We,{variant:`destructive`,children:`Not found`}),E?.error&&(0,Y.jsx)(We,{variant:`destructive`,children:`Failed to load`}),E&&(0,Y.jsx)(Ce,{skill:E}),E&&(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,icon:i?(0,Y.jsx)(Re,{}):(0,Y.jsx)(he,{}),"aria-label":`${i?`Edit`:`View`} ${E.name}`,className:`ml-auto`,render:(0,Y.jsx)(H,{to:we(a,o,E.name)}),children:i?`Edit`:`View`})]}),E?.error?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,E.error]}):ee?(0,Y.jsxs)(B,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,T,` skill, so cards entering `,e.name,` fail to start.`]}):E?.description&&(0,Y.jsx)(B,{as:`p`,variant:`caption`,tone:`muted`,children:E.description})]})})}),(0,Y.jsx)(q,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Y.jsx)(L,{children:A.map(t=>(0,Y.jsx)(I,{label:t.label,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: ${t.label}`,checked:C.includes(t.id),disabled:s,onCheckedChange:n=>{let r=A.map(({id:e})=>e).filter(e=>e===t.id?n:C.includes(e));u({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Y.jsxs)(Z,{icon:(0,Y.jsx)(ne,{}),title:`Ends`,children:[(0,Y.jsx)(Q,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:s,children:(0,Y.jsx)(Xe,{className:Ft,"aria-label":`${e.name} exit tool`,value:w,disabled:s,onChange:t=>{let n=t.target.value.trim();u({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||d(`autoApproveWhen`,void 0)}})}),w!==``&&(0,Y.jsxs)(L,{children:[(0,Y.jsx)(I,{label:`Approve on its own`,disabled:s,children:(0,Y.jsx)(ct,{"aria-label":`${e.name}: approve ${w} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:s,onCheckedChange:t=>{u({...e,exitTool:{...e.exitTool,id:w,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||d(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Y.jsx)(`div`,{className:`px-4 py-3`,children:(0,Y.jsx)(kt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ae,options:{"source.repository":m},disabled:s,json:k(`autoApproveWhen`),onUnfinished:e=>f(`autoApproveWhen`,e),onChange:t=>u({...e,exitTool:{...e.exitTool,id:w,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Y.jsx)(Z,{icon:(0,Y.jsx)(te,{}),title:`Allowed moves`,children:M})]}),P]}):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(q,{title:`Allowed moves`,children:M}),P]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:o,sidebarHidden:s,onReload:c}){let{board:u,canEdit:d}=i,{draft:f,rawRules:p,locked:m,setDraft:h,setRawRule:g,discard:v}=k(e.id,t,u),[y,b]=(0,J.useState)(0),C=()=>{v(),b(e=>e+1)},ee=me(),D=_e(e.id,t),te=fe(),A=!d||!u.editable,j=n?f.phases.find(e=>e.key===n):void 0,M=j&&`${j.key}:${u.revision??`code`}:${y}`,[N,P]=(0,J.useState)({page:M,fields:[]});N.page!==M&&P({page:M,fields:[]});let ne=N.page===M?N.fields:[],re=(e,t)=>P(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),ie=!A&&(_(f,u)||Object.keys(p).length>0||ne.length>0),F=f.phases.filter(e=>x(e,p)||e===j&&ne.length>0),I=f.name.trim()===``,ae=D.error?.code===`revision_mismatch`,R=pe(({nextLocation:n})=>{let r=te.getQueryData(ge.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!ie||r===!1)return!1;let i=Te(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),oe=G(e.id,t),se;return se=n&&!j?(0,Y.jsx)(r,{titleSlot:(0,Y.jsxs)(`span`,{role:`alert`,children:[u.name,` has no such phase.`]}),actionSlot:(0,Y.jsx)(W,{size:`sm`,render:(0,Y.jsx)(H,{to:oe}),children:`Back to general`})}):j?(0,Y.jsx)(Rt,{phase:j,phases:f.phases,requiredNextPhases:u.codeBehaviour?.[j.key]?.requiredNextPhases??[],skills:a,skillsEditable:o,factoryId:e.id,boardId:t,disabled:A||m,rawRules:{autoStartWhen:p[O(j.key,`autoStartWhen`)],autoApproveWhen:p[O(j.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{g(O(j.key,e),t),re(e,!1)},onUnfinished:re,onRemove:A||m||!w(f.phases,j.key,u.codeBehaviour)?void 0:()=>{for(let e of zt)g(O(j.key,e),void 0);h(e=>({...e,phases:E(e.phases,j.key)})),ee(oe)},onChange:e=>h(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},M):(0,Y.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Y.jsx)(Dt,{factoryId:e.id,boardId:t,phases:f.phases,skills:a,onAutoStart:A||m?void 0:(e,t)=>{h(n=>({...n,phases:n.phases.map(n=>n.key===e?S(n,t):n)})),t||g(O(e,`autoStartWhen`),void 0)},action:s&&!A?(0,Y.jsx)(T,{factoryId:e.id,boardId:t,board:u,disabled:m}):void 0}),(0,Y.jsx)(X,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:s&&(0,Y.jsx)(q,{title:`Factory`,children:(0,Y.jsx)(L,{children:(0,Y.jsxs)(H,{to:Ee(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Y.jsx)(l,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Y.jsx)(B,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Y.jsx)(ce,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Y.jsxs)(`div`,{className:z(`flex flex-col gap-8 pb-4`,!j&&`w-max min-w-full`),children:[u.editable?!d&&(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Y.jsx)(X,{pinned:!j,children:(0,Y.jsx)(U,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!j&&u.problems.length>0&&(0,Y.jsx)(X,{pinned:!0,children:(0,Y.jsx)(U,{variant:`warning`,title:`This board has problems`,children:(0,Y.jsx)(U.Message,{children:u.problems.join(` `)})})}),se,ie&&(0,Y.jsxs)(X,{pinned:!j,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[ae&&(0,Y.jsx)(U,{variant:`warning`,title:`Someone else changed this board`,action:(0,Y.jsx)(U.Button,{onClick:c,children:`Reload`}),children:(0,Y.jsx)(U.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),D.error&&!ae&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not saved. `,D.error.reasons]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(B,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:I?`Name the board to save.`:F.length>0?`Fix ${F.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Y.jsx)(W,{size:`sm`,variant:`ghost`,disabled:D.isPending,onClick:C,children:`Discard`}),(0,Y.jsx)(W,{size:`sm`,variant:`primary`,disabled:D.isPending||I||F.length>0,onClick:()=>D.mutate({name:f.name,description:f.description,phases:f.phases,expectedRevision:u.revision??0}),children:D.isPending?`Saving…`:`Save`})]})]}),(0,Y.jsx)(K,{open:R.state===`blocked`,onOpenChange:e=>!e&&R.reset?.(),children:(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Discard changes to `,u.name,`?`]}),(0,Y.jsx)(K.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Keep editing`}),(0,Y.jsx)(W,{variant:`destructive`,size:`md`,onClick:()=>{v(),R.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(mt,{}),disabled:t,children:`Delete`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Delete `,e,`?`]}),(0,Y.jsx)(K.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Y.jsxs)(K,{children:[(0,Y.jsx)(K.Trigger,{render:(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,icon:(0,Y.jsx)(_t,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Y.jsxs)(K.Content,{children:[(0,Y.jsxs)(K.Header,{children:[(0,Y.jsxs)(K.Title,{children:[`Reset `,e,` to default?`]}),(0,Y.jsx)(K.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Y.jsxs)(K.Footer,{children:[(0,Y.jsx)(K.Cancel,{children:`Cancel`}),(0,Y.jsx)(K.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Y.jsxs)(de,{children:[(0,Y.jsx)(ue,{render:(0,Y.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:z(`inline-flex rounded-sm`,V),children:n})}),(0,Y.jsx)(le,{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:s,locked:c,setDraft:l,setRawRule:u,discard:d}=k(e,t,i),f=ke(e),p=me(),m=!a||!i.editable||c,h=be(e,t),_=ve(e,t,()=>{d();let n=ht(f.data??[]).find(e=>e.id!==t);p(n?gt(e,n.id):`/factories/${e}`,{replace:!0})}),v=!n&&a&&i.editable,y=v&&i.source!==`stored`,b=v&&i.source!==`builtin`,x=n?s.phases.find(e=>e.key===n):void 0;if(n&&!x)return null;let S=e=>l(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),C=e=>{x&&(u(O(x.key,`autoStartWhen`),void 0),u(O(x.key,`autoApproveWhen`),void 0),l(t=>({...t,phases:t.phases.map(n=>n.key===x.key?g(n,e,t.phases):n)})))},w=x?x.name:s.name,T=(x?x.description:s.description)??``,E=x!==void 0&&!m&&!P(s.phases,x.key,i.codeBehaviour);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(o,{children:[(0,Y.jsxs)(o.Title,{className:`gap-2.5`,children:[x&&(0,Y.jsx)(Pe,{stage:x.key,kind:Me(t,x.kind),decorative:!0}),(0,Y.jsx)(vt,{value:w,label:x?`Phase name`:`Board name`,required:!0,readOnly:m,variant:`heading`,tone:`ink`,onChange:e=>x?S({name:e}):l(t=>({...t,name:e}))})]}),x&&(0,Y.jsx)(o.Meta,{beside:!0,children:E?(0,Y.jsxs)(st,{value:x.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&C(t)},children:[(0,Y.jsx)(it,{size:`sm`,"aria-label":`Phase kind`,children:$[x.kind].label}),(0,Y.jsx)(at,{children:Ut.map(e=>(0,Y.jsx)(ot,{value:e,children:$[e].label},e))})]}):(0,Y.jsx)(Wt,{label:$[x.kind].label,meaning:$[x.kind].meaning,children:(0,Y.jsx)(We,{children:$[x.kind].label})})}),(T||!m)&&(0,Y.jsx)(o.Description,{children:(0,Y.jsx)(vt,{value:T,label:x?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:m,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>x?S({description:e||null}):l(t=>({...t,description:e||null}))})}),(y||b)&&(0,Y.jsxs)(o.Action,{className:`gap-1`,children:[y&&(0,Y.jsx)(Ht,{name:i.name,pending:c,onReset:()=>h.mutate(i.revision??0)}),b&&(0,Y.jsx)(Vt,{name:i.name,pending:c,onDelete:()=>_.mutate(i.revision??0)})]})]}),h.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not reset. `,h.error.reasons]})}),_.error&&(0,Y.jsx)(U,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Y.jsxs)(U.Message,{children:[`The board was not deleted. `,_.error.reasons]})})]})}function Kt(){let e=f(),i=ee(),a=i?.boardId??``,o=i?.phaseKey,{isMobile:s,desktopState:l}=ie(),d=s||l===`collapsed`,p=ye(e.id,a),m=Se(e.id),h=p.data?.board,g=C(e.id,a,h),_=o?g?.phases.find(e=>e.key===o):void 0,v=G(e.id,a),y=c({breadcrumbs:d&&h?(0,Y.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Y.jsx)(t,{as:H,to:gt(e.id,a),children:g?.name||h.name}),o?(0,Y.jsx)(t,{as:H,to:v,children:`Configure`}):(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),_&&(0,Y.jsx)(t,{as:`span`,isCurrent:!0,children:_.name})]}):void 0}),b=p.isSuccess&&(!o||_)?(0,Y.jsx)(Gt,{factoryId:e.id,boardId:a,phaseKey:o,response:p.data},`${a}:${p.data.board.revision??`code`}`):void 0,x=p.isPending?(0,Y.jsx)(L,{children:(0,Y.jsx)(R,{label:`Loading board`,rows:3})}):p.isError&&p.error instanceof xe&&p.error.code===`board_not_found`?(0,Y.jsx)(r,{variant:`fill`,titleSlot:(0,Y.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):p.isError?(0,Y.jsx)(yt,{title:`Couldn’t load this board`,error:p.error,onRetry:()=>void p.refetch(),retrying:p.isFetching}):(0,Y.jsx)(Bt,{factory:e,boardId:a,phaseKey:o,response:p.data,skills:m.data?.skills,skillsEditable:m.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void p.refetch()},`${a}:${p.data.board.revision??`code`}`);return o?(0,Y.jsx)(u,{variant:`settings`,header:b,...y,children:x}):(0,Y.jsx)(u,{variant:`page`,body:`fixed`,header:b&&(0,Y.jsx)(`div`,{className:z(`mx-auto w-full max-w-2xl`,`pb-3`),children:b}),...y,children:(0,Y.jsx)(`div`,{className:p.isSuccess?xt:z(bt,`px-4`),children:x})})}export{Kt as BoardConfigPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Fr as t,Nr as n,Pr as r,Tr as i,nn as a}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Fr as t,Nr as n,Pr as r,Tr as i,nn as a}from"./index-DfNj4qTr.js";import{n as o,t as s}from"./Breadcrumb.es-D9PSmzYq.js";import{a as c}from"./Sidebar.es-9pwBnu_Z.js";import{$n as l,n as u,ni as d}from"./GithubIcon.es-B1lB1Q-8.js";import{r as f}from"./useBoardEditor-Dm78Yoiu.js";import{a as p,n as m,s as h,t as g}from"./boardConfigPaths-Btimpi_r.js";import{k as _}from"./TabsRoot-C1o0G1CK.js";import{yt as v}from"./useSessionRows-aTHnrKGG.js";import{O as y,T as b,k as x,n as S}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as C,s as w,t as T,u as E}from"./settings-DTWGb7K_-PW2CFx0g.js";import{a as D,c as O,d as k,i as A,l as j,n as M,o as N,r as P,t as F,u as I}from"./useRowDrag-DQBjWerU.js";import{o as L}from"./useIntakeRoutes-BNBPe6sx.js";import{h as R,p as z}from"./ruleLanes-D9QkgLJm.js";import{s as B}from"./Field.es-BmqB8MIv.js";import{n as V}from"./useBoardCatalog-DZf1osB2.js";import{t as H}from"./SettingsSubsection-DznON6FW.js";import{s as U}from"./settingsSections-B0_LEh3l.js";var W=e(x(),1),G=y();function K({factoryId:e}){let t=A(e),n=D(e),r=new Map((V(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=>v.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>v.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,G.jsxs)(`section`,{id:m,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,G.jsx)(C,{media:(0,G.jsx)(w,{children:(0,G.jsx)(j,{})}),title:(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,G.jsx)(B,{"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,G.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,G.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,G.jsxs)(C,{title:t.url?(0,G.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,G.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,G.jsx)(`span`,{children:t.sourceKey}),(0,G.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,G.jsx)(`time`,{dateTime:t.decidedAt,children:q(t.decidedAt)})]}),children:[(0,G.jsx)(M,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,G.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function q(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var J=b(`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 Y({factoryId:e}){let t=P(e);return(0,G.jsx)(H,{id:g,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,G.jsx)(T,{children:(0,G.jsx)(E,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(u,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,G.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,G.jsx)(K,{factoryId:e})})]}):(0,G.jsx)(X,{factoryId:e,order:t.data},e)})}function X({factoryId:e,order:t}){let n=L(e),r=N(e),[i,a]=(0,W.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&$(i,o)?i:void 0,c=s??o,f=new Map(t.boards.map(e=>[e.boardKey,e.name])),p=s!==void 0&&s.some((e,t)=>e!==o[t]),m=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},g=F({min:0,max:c.length-1,onDrop:m}),_=()=>r.mutate(c,{onSuccess:()=>{a(void 0),v.success(`Intake order saved.`)},onError:e=>v.error(e.message)}),y=t.canEdit&&c.length>1,x=y&&!r.isPending;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(Q,{order:t,changed:p}),n.isError&&(0,G.jsx)(u,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,G.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,G.jsx)(T,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=g.drag?.from===r,a=f.get(t)??t;return(0,G.jsx)(C,{role:`listitem`,"data-drop":g.dropAt(r),style:i?{transform:`translateY(${g.drag?.offset??0}px)`}:void 0,onPointerDown:x?e=>g.onPointerDown(e,r):void 0,onKeyDown:x?e=>g.onKeyDown(e,r):void 0,className:b(`group/row`,J,i&&`z-10 opacity-90`),media:(0,G.jsxs)(w,{children:[(0,G.jsx)(S,{as:`span`,variant:`caption`,className:b(`tabular-nums`,y&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),y&&(0,G.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:b(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,G.jsx)(O,{className:`size-icon-md`})})]}),title:a,description:(0,G.jsx)(Z,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,G.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:[y&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!x||r===0,onClick:()=>m(r,r-1),children:(0,G.jsx)(I,{})}),(0,G.jsx)(d,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!x||r===c.length-1,onClick:()=>m(r,r+1),children:(0,G.jsx)(k,{})})]}),(0,G.jsx)(d,{size:`sm`,variant:`ghost`,render:(0,G.jsx)(l,{to:h(e,t)}),children:`Edit rules`})]})},t)})}),(0,G.jsx)(K,{factoryId:e})]}),t.canEdit&&p&&(0,G.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(d,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,G.jsx)(d,{size:`sm`,variant:`primary`,onClick:_,disabled:r.isPending,children:`Save order`})]})]})}function Z({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=z(e.filter(e=>e.target.boardKey===t));return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${R(n)} for new issues and pull requests`}),r&&(0,G.jsx)(_,{children:`Ends in catch-all`})]})}function Q({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,G.jsx)(u,{variant:`info`,children:(0,G.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,G.jsx)(`span`,{children:e},e))})})}function $(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function ee(){let e=i(),u=a()?.boardId??``,{isMobile:d,desktopState:m}=c(),h=d||m===`collapsed`,g=f(e.id,u).data?.board,_=n({breadcrumbs:h&&g?(0,G.jsxs)(s,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,G.jsx)(o,{as:l,to:p(e.id,u),children:g.name}),(0,G.jsx)(o,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,G.jsx)(r,{variant:`settings`,header:(0,G.jsxs)(t,{children:[(0,G.jsx)(t.Title,{children:`Routing`}),(0,G.jsx)(t.Description,{children:(0,G.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,G.jsx)(l,{to:U(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]}),..._,children:(0,G.jsx)(Y,{factoryId:e.id})})}export{ee as BoardIntakePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$n as t,Fr as n,Jn as r,Kn as i,Nr as a,Pr as o,Tr as s,Yn as c,nn as l,qn as u}from"./index-SGLMjvLV.js";import{n as d,t as f}from"./Breadcrumb.es-D9PSmzYq.js";import{a as p}from"./Sidebar.es-9pwBnu_Z.js";import{$n as m,At as h,Dt as ee,St as g,ir as _,jt as v,kt as y,n as b,ni as x,t as S,wt as C}from"./GithubIcon.es-B1lB1Q-8.js";import{r as w,t as T}from"./useBoardEditor-Dm78Yoiu.js";import{a as E,i as D,o as O,s as k,t as A}from"./boardConfigPaths-Btimpi_r.js";import{r as j}from"./CompositeItem-CD2x3KaL.js";import{yt as M}from"./useSessionRows-aTHnrKGG.js";import{d as N,n as te}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as P,T as F,k as I,n as L}from"./IconChevronRightMedium.es-BjSIsine.js";import{n as R}from"./useBoardCatalog-DZf1osB2.js";import{c as ne,d as re,l as z,n as B,r as ie,s as V,t as H,u as U}from"./useRowDrag-DQBjWerU.js";import{a as ae,d as oe,f as se,g as W,o as ce,r as G,s as le}from"./useIntakeRoutes-BNBPe6sx.js";import{C as ue,E as de,_ as fe,a as pe,c as K,d as me,f as he,g as ge,i as _e,l as q,m as ve,n as ye,o as be,s as xe,u as J,w as Se}from"./ruleLanes-D9QkgLJm.js";import{t as Y}from"./createLucideIcon-B6gALBEh.js";import{a as Ce,t as we}from"./BoardIcons-DXB--WrY.js";import{t as Te}from"./input-DqReKX0A-B4MUvQwj.js";import{n as Ee,t as De}from"./RadioGroup.es-Ws4_oCJe.js";import{n as Oe,t as ke}from"./ConditionRows-CjF282lW.js";import{i as X,k as Ae}from"./TabsRoot-C1o0G1CK.js";import{E as je}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";var Me={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Me.node;var Ne=Y(Me),Pe={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Pe.node;var Fe=Y(Pe),Ie={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ie.node;var Le=Y(Ie),Re={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`]};Re.node;var ze=Y(Re),Be={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`]};Be.node;var Ve=Y(Be),He={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};He.node;var Ue=Y(He),We={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`}]]};We.node;var Ge=Y(We),Ke={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`}]]};Ke.node;var qe=Y(Ke),Je={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Je.node;var Ye=Y(Je),Xe={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`]};Xe.node;var Ze=Y(Xe),Qe={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`]};Qe.node;var $e=Y(Qe),Z=e(I(),1),Q=P();function et({when:e,options:t,everything:n}){let r=ue(e,t);return!e||!r?(0,Q.jsx)(L,{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)(L,{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)(L,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)(tt,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)(tt,{children:t})]},n)})})}function tt({children:e}){return(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function nt({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let a=e.find(e=>e.id===n);if(!a)return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??a.initialPhase,s=a.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[a.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:i(a)}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(we,{stage:s.id,kind:Ce(a.id,s.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:u(a,o)??o})]})}function rt({factoryId:e,rules:t,board:n,boards:a}){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)(L,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(qe,{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 o=a.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(m,{to:k(e,t.target.boardKey),"aria-label":`${t.name}, on ${o?i(o):t.target.boardKey}`,className:F(`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)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:o?i(o):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(et,{when:t.when,options:r(o),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)(Ne,{"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)(nt,{boards:a,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function it({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)(L,{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)(L,{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)(m,{to:k(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Le,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(m,{to:O(e,t,A),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var at=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,ot=`border-border-focus bg-fill-hover`,st=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ct({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:F(at,`disabled:opacity-50`,e?ot:st),children:r})}function lt({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:F(at,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?ot:st,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Ee,{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 ut(){return(0,Q.jsx)(Ae,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(S,{"aria-hidden":`true`}),children:`GitHub only`})}var dt=120,ft=W(le),$=[{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 pt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function mt(e,t){if(t){let e=ft.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return se(e,t)??void 0}function ht(e,t,n){let r=`When ${e.map(e=>J(e).label.toLowerCase()).join(` or `)}${t?`, ${Se(t).charAt(0).toLowerCase()}${Se(t).slice(1)}`:``}, move to ${n}`;return r.length>dt?`${r.slice(0,119)}…`:r}function gt({factoryId:e,board:t,boards:n,initial:a,initialEvent:o,initialStep:s,readOnly:c,saving:l,error:d,onSave:f,onClose:p}){let m=Oe(e),[_,S]=(0,Z.useState)(()=>a?.on??(o?[o]:[])),[w,T]=(0,Z.useState)(()=>a?.when??null),[E,D]=(0,Z.useState)(()=>(a?.when?.conditions.length??0)>0),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(()=>a?.target.moveToBoardKey??t.id),[M,N]=(0,Z.useState)(()=>a?a.target.phaseKey??void 0:void 0),[te,P]=(0,Z.useState)(()=>a?.name),[I,R]=(0,Z.useState)(s),[ne,re]=(0,Z.useState)(0),z=ve(_),B=n.find(e=>e.id===A),ie=pt(B,z),V=ie.find(e=>e.id===(M??B?.initialPhase)),H=E?w:null,U=_.length?mt(_,H):void 0,ae=V&&B?`${i(B)} › ${u(B,V.id)}`:``,se=te??(V?ht(_,H,ae):``),W={trigger:_.length>0,conditions:_.length>0&&!(E&&O)&&!U,action:V!==void 0,review:se.trim().length>0},ce=!c&&W.trigger&&W.conditions&&W.action&&W.review,G=$.findIndex(e=>e.id===I),le=$[G]??$[0],ue=e=>{S(e),ve(e)&&A!==t.id&&(j(t.id),N(void 0))},fe=()=>{ce&&V&&f({name:se.trim(),on:_,when:H,target:{phaseKey:V.id,moveToBoardKey:A===t.id?null:A}})},pe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};T(H===null?{operator:`AND`,conditions:[e]}:H.operator===`AND`?{...H,conditions:[...H.conditions,e]}:{operator:`AND`,conditions:[H,e]}),D(!0),k(!1),re(e=>e+1)},K={trigger:_.length?_.map(e=>J(e).label).join(`, `):void 0,conditions:_.length?Se(H,r(t)):void 0,action:V?(0,Q.jsx)(nt,{boards:n,ownBoard:t.id,boardKey:A,phaseKey:V.id}):void 0,review:void 0};return(0,Q.jsx)(g,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(ee,{size:`xl`,children:[(0,Q.jsx)(h,{children:(0,Q.jsx)(v,{children:c?`Rule`:a?`Edit rule`:`Add rule`})}),(0,Q.jsx)(C,{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:()=>R(e.id),className:F(`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)(L,{as:`span`,variant:`meta`,className:F(`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)(Fe,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),K[e.id]&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:K[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":le.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(L,{as:`h3`,variant:`heading`,children:le.question}),I===`trigger`&&(0,Q.jsx)(yt,{value:_,disabled:c,onChange:ue}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(De,{"aria-label":`Which ones`,value:E?`matching`:`every`,disabled:c,onValueChange:e=>{D(e===`matching`),k(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(lt,{value:`every`,selected:!E,disabled:c,children:(0,Q.jsx)(_t,{title:z?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(lt,{value:`matching`,selected:E,disabled:c,children:(0,Q.jsx)(_t,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),E&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(ke,{label:`Conditions`,rule:w,facts:de(_),options:{...r(t),"source.repository":m},onChange:(e,t)=>{T(e),k(t)}},ne)}),U&&(0,Q.jsx)(b,{variant:`warning`,children:U}),!a?.outsiderPullRequestsGated&&oe(_,H)&&(0,Q.jsx)(b,{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.`}),!c&&(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[z?(0,Q.jsx)(L,{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)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(De,{"aria-label":`Board`,value:A,disabled:c,onValueChange:e=>{typeof e==`string`&&e!==A&&(j(e),N(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===A,disabled:c,children:(0,Q.jsxs)(L,{as:`span`,variant:`label`,tone:`ink`,children:[i(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(De,{"aria-label":`Phase`,value:V?.id??null,disabled:c,onValueChange:e=>typeof e==`string`&&N(e),className:`grid-cols-1 sm:grid-cols-2`,children:B&&ie.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===V?.id,disabled:c,onClick:()=>{N(e.id),R(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(we,{stage:e.id,kind:Ce(B.id,e.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,children:u(B,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)(L,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Te,{value:se,maxLength:dt,disabled:c,onChange:e=>P(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(L,{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)(vt,{label:`When`,children:K.trigger}),(0,Q.jsx)(vt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ve,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),K.conditions]})}),(0,Q.jsx)(vt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(Ne,{className:`size-icon-sm`,"aria-hidden":!0}),` `,K.action]})})]})]})]}),d&&(0,Q.jsx)(b,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(x,{variant:`ghost`,onClick:p,children:c?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),G>0&&(0,Q.jsx)(x,{variant:`default`,onClick:()=>R($[G-1].id),children:`Back`}),!c&&(I===`review`||a&&ce?(0,Q.jsx)(x,{variant:`primary`,disabled:!ce||l,onClick:fe,children:l?`Saving…`:a?`Save rule`:`Create rule`}):(0,Q.jsx)(x,{variant:`primary`,disabled:!W[I],onClick:()=>R($[G+1]?.id??`review`),children:`Continue`}))]})]})})}function _t({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function vt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,children:t})]})}function yt({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)(b,{variant:`info`,children:[`Also listens on “`,J(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ye.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{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=J(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ct,{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)(_t,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ut,{})})]},r)})})]},r.title))]})}function bt({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)(Ue,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{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)(x,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(m,{to:r}),children:`Show all`})]})}var xt=F(`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 St({event:e,rules:t,board:n,boards:r,phaseOptions:a,canEdit:o,skips:s,footer:c,incoming:l,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:ee,onUngate:g}){let _=J(e),v=_.icon,y=pe(t,e),b=K(e),S=be(e),C=H({min:0,max:t.length-1,onDrop:m}),w=o&&t.length>1&&!d,T=c??(t.length?`Otherwise, the card stays where it is`:l?`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":_.label,className:F(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!l&&`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)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`h3`,variant:`label`,tone:`ink`,children:_.label}),_.githubOnly&&(0,Q.jsx)(ut,{})]}),_.description&&(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:_.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((c,l)=>{if(d&&!d.has(c.id))return null;let p=ge(t,e,l),v=p>=0,T=!c.enabled||v,E=C.drag?.from===l,D=s?.get(c.id),O=r.find(e=>e.id===(c.target.moveToBoardKey??c.target.boardKey)),k=!he(c.name,[_.label,Se(c.when,a),O&&i(O),u(O,c.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":c.name,"data-drop":C.dropAt(l),style:E?{transform:`translateY(${C.drag?.offset??0}px)`}:void 0,onPointerDown:w?e=>C.onPointerDown(e,l):void 0,className:F(`group/rule flex flex-col`,xt,E&&`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 ${c.name}`,onClick:()=>f(c,`conditions`),onKeyDown:w?e=>C.onKeyDown(e,l):void 0,className:F(`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`,T?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(L,{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:F(w&&`pointer-fine:group-hover/rule:hidden`,E&&`hidden`),children:l+1}),w&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:F(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,E&&`flex`),children:(0,Q.jsx)(ne,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[k&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:c.name}),(0,Q.jsx)(et,{when:c.when,options:a,everything:S})]})]}),w&&(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)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:l===0,onClick:()=>m(l,l-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:l===t.length-1,onClick:()=>m(l,l+1),children:(0,Q.jsx)(re,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:F(`flex min-w-0 items-center`,T&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`h-px w-8 shrink-0`,T?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(Ne,{"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 ${c.name} moves the card`,onClick:()=>f(c,`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)(nt,{boards:r,ownBoard:n.id,boardKey:c.target.moveToBoardKey??c.target.boardKey,phaseKey:c.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(je,{"aria-label":`${c.name} on`,checked:c.enabled,onCheckedChange:e=>h(c,e)}),(0,Q.jsxs)(X,{children:[(0,Q.jsx)(X.Trigger,{render:(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${c.name}`,children:(0,Q.jsx)(ze,{})})}),(0,Q.jsx)(X.Content,{align:`end`,children:(0,Q.jsxs)(X.Item,{variant:`destructive`,onClick:()=>ee(c),children:[(0,Q.jsx)(Ze,{}),`Delete rule`]})})]})]})]})]}),T&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,S.toLowerCase(),`.`]}):`Off, skipped`}),c.problems.map(e=>(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),D&&(0,Q.jsx)(wt,{skips:D}),fe(c,e)&&(0,Q.jsxs)(L,{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:()=>g(c),className:`underline`,children:`Let outside authors match`})]}),me(c,e)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&xe(c)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:J(`work_item.created`).label}),l!==y&&!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)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},c.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(z,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),T]}),o&&(0,Q.jsx)(x,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(Ye,{}),onClick:p,children:`Add rule`})]})]}),l]})]})}function Ct(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function wt({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(L,{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)($e,{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: `,Ct(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 Tt=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function Et(e){return e instanceof T&&e.code!==void 0&&Tt.has(e.code)}function Dt(e){return Et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Ot({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(j,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(b,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(kt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(b,{variant:`warning`,children:`This board isn’t installed.`})}function kt({factoryId:e,board:n,boards:i}){let a=G(e,n.id),o=ce(e),s=ie(e),l=V(e),d=ae(e),[f,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),h=e=>{m.current=e,p(e)},[ee,g]=(0,Z.useState)(),v=a.data?.intakeRoutes??[],y=a.data?.canEdit??!1,x=r(n),S=(o.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===n.id&&e.target.boardKey!==n.id),C=new Map(l.data?.skipped.map(e=>[e.routeId,e])),[w]=_(),T=w.get(`into`)??void 0,E=w.has(D),O=E||T!==void 0,A=O&&o.data?t(o.data.intakeRoutes,{key:n.id,initialPhase:n.initialPhase}):void 0,P=A&&new Set((E?A.leaving:A.into.get(T??``)??[]).map(e=>e.id)),F=e=>!P||e.some(e=>P.has(e.id));if(a.isPending||O&&o.isPending)return(0,Q.jsx)(j,{className:`h-64 w-full`});if(a.isError)return(0,Q.jsx)(b,{variant:`destructive`,children:`This board’s rules didn’t load.`});let I=e=>d.mutateAsync(e).catch(e=>M.error(Dt(e))),L=(e,t,r)=>{let i=q(v,e).map(e=>e.id);I([{kind:`reorder`,boardKey:n.id,ids:c(v,i,t,r)}])},R=e=>{g(void 0),h(e)},ne=async e=>{let t=m.current,r=t?.rule,i=()=>t!==void 0&&m.current===t;g(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[t]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:n.id,...e.target}}}]);i()&&h(void 0),t&&await z(t,e.on).catch(e=>M.error(Dt(e)));return}i()&&h(void 0)}catch(e){if(!i())return;if(r&&Et(e))return re(r);g(Dt(e))}},re=async e=>{let t=m.current,n=(await a.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(h({...t,rule:n}),g(`Someone else changed this rule first. It now shows their version; make your change again.`)):(h(void 0),M.error(`Someone else deleted this rule first.`)))},z=async(e,t)=>{if(e.target.boardKey!==n.id)return;let r=(await a.refetch()).data?.intakeRoutes??[],i=r.map(e=>e.id),o=i.indexOf(e.id),s=t.flatMap(t=>{let n=q(r,t),a=n[ge(n,t,n.findIndex(t=>t.id===e.id))];return a?[i.indexOf(a.id)]:[]}),l=Math.min(...s);o<0||!(l<o)||await d.mutateAsync([{kind:`reorder`,boardKey:n.id,ids:c(r,i,o,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:_e(s.data?.boards,n.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.isError&&(0,Q.jsx)(b,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),O&&(0,Q.jsx)(bt,{count:P?.size,into:E||!T?`other boards`:u(n,T)??T,leaving:E,showAll:k(e,n.id)}),ye.filter(e=>e.events.some(e=>F([...q(v,e),...q(S,e)]))).map(t=>(0,Q.jsxs)(`section`,{"aria-label":t.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(N,{children:t.title}),t.events.some(K)?s.data&&(0,Q.jsx)(it,{factoryId:e,boardKey:n.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(te,{children:`Only cards already on this board; other boards never see them.`})]}),t.events.map(t=>{let r=K(t),a=q(v,t),o=q(S,t).filter(e=>!P||P.has(e.id));return F([...a,...o])?(0,Q.jsx)(St,{event:t,rules:a,board:n,boards:i,phaseOptions:x,canEdit:y,skips:C,footer:r?B:void 0,only:P,incoming:o.length?(0,Q.jsx)(rt,{factoryId:e,rules:o,board:n,boards:i}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:t,step:`conditions`}),onMove:(e,n)=>L(t,e,n),onToggle:(e,t)=>void I([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void I([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&M.success(`Deleted “${e.name}”`)),onUngate:e=>void I([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&M.success(`“${e.name}” now matches outside authors’ pull requests`))},t):null})]},t.title)),f&&(0,Q.jsx)(gt,{factoryId:e,board:n,boards:i,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!y,saving:d.isPending,error:ee,onSave:e=>void ne(e),onClose:()=>h(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}function At(){let e=s(),t=l()?.boardId??``,{isMobile:r,desktopState:i}=p(),c=r||i===`collapsed`,u=w(e.id,t).data?.board,h=a({breadcrumbs:c&&u?(0,Q.jsxs)(f,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(d,{as:m,to:E(e.id,t),children:u.name}),(0,Q.jsx)(d,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(o,{variant:`settings`,header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(n,{children:[(0,Q.jsx)(n.Title,{children:`Rules`}),(0,Q.jsx)(n.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...h,children:(0,Q.jsx)(Ot,{factoryId:e.id,boardId:t})})}export{At as BoardRulesPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$n as t,Fr as n,Jn as r,Kn as i,Nr as a,Pr as o,Tr as s,Yn as c,nn as l,qn as u}from"./index-DfNj4qTr.js";import{n as d,t as f}from"./Breadcrumb.es-D9PSmzYq.js";import{a as p}from"./Sidebar.es-9pwBnu_Z.js";import{$n as m,At as h,Dt as ee,St as g,ir as _,jt as v,kt as y,n as b,ni as x,t as S,wt as C}from"./GithubIcon.es-B1lB1Q-8.js";import{r as w,t as T}from"./useBoardEditor-Dm78Yoiu.js";import{a as E,i as D,o as O,s as k,t as A}from"./boardConfigPaths-Btimpi_r.js";import{r as j}from"./CompositeItem-CD2x3KaL.js";import{yt as M}from"./useSessionRows-aTHnrKGG.js";import{d as N,n as te}from"./settings-DTWGb7K_-PW2CFx0g.js";import{O as P,T as F,k as I,n as L}from"./IconChevronRightMedium.es-BjSIsine.js";import{n as R}from"./useBoardCatalog-DZf1osB2.js";import{c as ne,d as re,l as z,n as B,r as ie,s as V,t as H,u as U}from"./useRowDrag-DQBjWerU.js";import{a as ae,d as oe,f as se,g as W,o as ce,r as G,s as le}from"./useIntakeRoutes-BNBPe6sx.js";import{C as ue,E as de,_ as fe,a as pe,c as K,d as me,f as he,g as ge,i as _e,l as q,m as ve,n as ye,o as be,s as xe,u as J,w as Se}from"./ruleLanes-D9QkgLJm.js";import{t as Y}from"./createLucideIcon-B6gALBEh.js";import{a as Ce,t as we}from"./BoardIcons-DXB--WrY.js";import{t as Te}from"./input-DqReKX0A-B4MUvQwj.js";import{n as Ee,t as De}from"./RadioGroup.es-Ws4_oCJe.js";import{n as Oe,t as ke}from"./ConditionRows-EkFcLg06.js";import{i as X,k as Ae}from"./TabsRoot-C1o0G1CK.js";import{E as je}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";var Me={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Me.node;var Ne=Y(Me),Pe={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Pe.node;var Fe=Y(Pe),Ie={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Ie.node;var Le=Y(Ie),Re={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`]};Re.node;var ze=Y(Re),Be={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`]};Be.node;var Ve=Y(Be),He={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};He.node;var Ue=Y(He),We={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`}]]};We.node;var Ge=Y(We),Ke={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`}]]};Ke.node;var qe=Y(Ke),Je={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Je.node;var Ye=Y(Je),Xe={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`]};Xe.node;var Ze=Y(Xe),Qe={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`]};Qe.node;var $e=Y(Qe),Z=e(I(),1),Q=P();function et({when:e,options:t,everything:n}){let r=ue(e,t);return!e||!r?(0,Q.jsx)(L,{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)(L,{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)(L,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)(tt,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)(tt,{children:t})]},n)})})}function tt({children:e}){return(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function nt({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let a=e.find(e=>e.id===n);if(!a)return(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??a.initialPhase,s=a.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[a.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:i(a)}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(we,{stage:s.id,kind:Ce(a.id,s.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`truncate`,children:u(a,o)??o})]})}function rt({factoryId:e,rules:t,board:n,boards:a}){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)(L,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(qe,{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 o=a.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(m,{to:k(e,t.target.boardKey),"aria-label":`${t.name}, on ${o?i(o):t.target.boardKey}`,className:F(`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)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:o?i(o):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(et,{when:t.when,options:r(o),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)(Ne,{"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)(nt,{boards:a,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function it({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)(L,{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)(L,{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)(m,{to:k(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Le,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(m,{to:O(e,t,A),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var at=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,ot=`border-border-focus bg-fill-hover`,st=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ct({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:F(at,`disabled:opacity-50`,e?ot:st),children:r})}function lt({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:F(at,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?ot:st,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(Ee,{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 ut(){return(0,Q.jsx)(Ae,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(S,{"aria-hidden":`true`}),children:`GitHub only`})}var dt=120,ft=W(le),$=[{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 pt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function mt(e,t){if(t){let e=ft.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return se(e,t)??void 0}function ht(e,t,n){let r=`When ${e.map(e=>J(e).label.toLowerCase()).join(` or `)}${t?`, ${Se(t).charAt(0).toLowerCase()}${Se(t).slice(1)}`:``}, move to ${n}`;return r.length>dt?`${r.slice(0,119)}…`:r}function gt({factoryId:e,board:t,boards:n,initial:a,initialEvent:o,initialStep:s,readOnly:c,saving:l,error:d,onSave:f,onClose:p}){let m=Oe(e),[_,S]=(0,Z.useState)(()=>a?.on??(o?[o]:[])),[w,T]=(0,Z.useState)(()=>a?.when??null),[E,D]=(0,Z.useState)(()=>(a?.when?.conditions.length??0)>0),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(()=>a?.target.moveToBoardKey??t.id),[M,N]=(0,Z.useState)(()=>a?a.target.phaseKey??void 0:void 0),[te,P]=(0,Z.useState)(()=>a?.name),[I,R]=(0,Z.useState)(s),[ne,re]=(0,Z.useState)(0),z=ve(_),B=n.find(e=>e.id===A),ie=pt(B,z),V=ie.find(e=>e.id===(M??B?.initialPhase)),H=E?w:null,U=_.length?mt(_,H):void 0,ae=V&&B?`${i(B)} › ${u(B,V.id)}`:``,se=te??(V?ht(_,H,ae):``),W={trigger:_.length>0,conditions:_.length>0&&!(E&&O)&&!U,action:V!==void 0,review:se.trim().length>0},ce=!c&&W.trigger&&W.conditions&&W.action&&W.review,G=$.findIndex(e=>e.id===I),le=$[G]??$[0],ue=e=>{S(e),ve(e)&&A!==t.id&&(j(t.id),N(void 0))},fe=()=>{ce&&V&&f({name:se.trim(),on:_,when:H,target:{phaseKey:V.id,moveToBoardKey:A===t.id?null:A}})},pe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};T(H===null?{operator:`AND`,conditions:[e]}:H.operator===`AND`?{...H,conditions:[...H.conditions,e]}:{operator:`AND`,conditions:[H,e]}),D(!0),k(!1),re(e=>e+1)},K={trigger:_.length?_.map(e=>J(e).label).join(`, `):void 0,conditions:_.length?Se(H,r(t)):void 0,action:V?(0,Q.jsx)(nt,{boards:n,ownBoard:t.id,boardKey:A,phaseKey:V.id}):void 0,review:void 0};return(0,Q.jsx)(g,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(ee,{size:`xl`,children:[(0,Q.jsx)(h,{children:(0,Q.jsx)(v,{children:c?`Rule`:a?`Edit rule`:`Add rule`})}),(0,Q.jsx)(C,{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:()=>R(e.id),className:F(`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)(L,{as:`span`,variant:`meta`,className:F(`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)(Fe,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),K[e.id]&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:K[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":le.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(L,{as:`h3`,variant:`heading`,children:le.question}),I===`trigger`&&(0,Q.jsx)(yt,{value:_,disabled:c,onChange:ue}),I===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(De,{"aria-label":`Which ones`,value:E?`matching`:`every`,disabled:c,onValueChange:e=>{D(e===`matching`),k(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(lt,{value:`every`,selected:!E,disabled:c,children:(0,Q.jsx)(_t,{title:z?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(lt,{value:`matching`,selected:E,disabled:c,children:(0,Q.jsx)(_t,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),E&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(ke,{label:`Conditions`,rule:w,facts:de(_),options:{...r(t),"source.repository":m},onChange:(e,t)=>{T(e),k(t)}},ne)}),U&&(0,Q.jsx)(b,{variant:`warning`,children:U}),!a?.outsiderPullRequestsGated&&oe(_,H)&&(0,Q.jsx)(b,{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.`}),!c&&(0,Q.jsx)(`button`,{type:`button`,onClick:pe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),I===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[z?(0,Q.jsx)(L,{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)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(De,{"aria-label":`Board`,value:A,disabled:c,onValueChange:e=>{typeof e==`string`&&e!==A&&(j(e),N(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===A,disabled:c,children:(0,Q.jsxs)(L,{as:`span`,variant:`label`,tone:`ink`,children:[i(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(De,{"aria-label":`Phase`,value:V?.id??null,disabled:c,onValueChange:e=>typeof e==`string`&&N(e),className:`grid-cols-1 sm:grid-cols-2`,children:B&&ie.map(e=>(0,Q.jsx)(lt,{value:e.id,selected:e.id===V?.id,disabled:c,onClick:()=>{N(e.id),R(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(we,{stage:e.id,kind:Ce(B.id,e.kind),decorative:!0}),(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,children:u(B,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)(L,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Te,{value:se,maxLength:dt,disabled:c,onChange:e=>P(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(L,{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)(vt,{label:`When`,children:K.trigger}),(0,Q.jsx)(vt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Ve,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),K.conditions]})}),(0,Q.jsx)(vt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(Ne,{className:`size-icon-sm`,"aria-hidden":!0}),` `,K.action]})})]})]})]}),d&&(0,Q.jsx)(b,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(y,{children:[(0,Q.jsx)(x,{variant:`ghost`,onClick:p,children:c?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),G>0&&(0,Q.jsx)(x,{variant:`default`,onClick:()=>R($[G-1].id),children:`Back`}),!c&&(I===`review`||a&&ce?(0,Q.jsx)(x,{variant:`primary`,disabled:!ce||l,onClick:fe,children:l?`Saving…`:a?`Save rule`:`Create rule`}):(0,Q.jsx)(x,{variant:`primary`,disabled:!W[I],onClick:()=>R($[G+1]?.id??`review`),children:`Continue`}))]})]})})}function _t({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(L,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function vt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(L,{as:`span`,variant:`body-sm`,children:t})]})}function yt({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)(b,{variant:`info`,children:[`Also listens on “`,J(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),ye.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(L,{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=J(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ct,{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)(_t,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ut,{})})]},r)})})]},r.title))]})}function bt({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)(Ue,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{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)(x,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(m,{to:r}),children:`Show all`})]})}var xt=F(`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 St({event:e,rules:t,board:n,boards:r,phaseOptions:a,canEdit:o,skips:s,footer:c,incoming:l,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:ee,onUngate:g}){let _=J(e),v=_.icon,y=pe(t,e),b=K(e),S=be(e),C=H({min:0,max:t.length-1,onDrop:m}),w=o&&t.length>1&&!d,T=c??(t.length?`Otherwise, the card stays where it is`:l?`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":_.label,className:F(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!l&&`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)(v,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(L,{as:`h3`,variant:`label`,tone:`ink`,children:_.label}),_.githubOnly&&(0,Q.jsx)(ut,{})]}),_.description&&(0,Q.jsx)(L,{as:`p`,variant:`caption`,tone:`muted`,children:_.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${_.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((c,l)=>{if(d&&!d.has(c.id))return null;let p=ge(t,e,l),v=p>=0,T=!c.enabled||v,E=C.drag?.from===l,D=s?.get(c.id),O=r.find(e=>e.id===(c.target.moveToBoardKey??c.target.boardKey)),k=!he(c.name,[_.label,Se(c.when,a),O&&i(O),u(O,c.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":c.name,"data-drop":C.dropAt(l),style:E?{transform:`translateY(${C.drag?.offset??0}px)`}:void 0,onPointerDown:w?e=>C.onPointerDown(e,l):void 0,className:F(`group/rule flex flex-col`,xt,E&&`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 ${c.name}`,onClick:()=>f(c,`conditions`),onKeyDown:w?e=>C.onKeyDown(e,l):void 0,className:F(`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`,T?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(L,{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:F(w&&`pointer-fine:group-hover/rule:hidden`,E&&`hidden`),children:l+1}),w&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:F(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,E&&`flex`),children:(0,Q.jsx)(ne,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[k&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:c.name}),(0,Q.jsx)(et,{when:c.when,options:a,everything:S})]})]}),w&&(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)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:l===0,onClick:()=>m(l,l-1),children:(0,Q.jsx)(U,{})}),(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:l===t.length-1,onClick:()=>m(l,l+1),children:(0,Q.jsx)(re,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:F(`flex min-w-0 items-center`,T&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:F(`h-px w-8 shrink-0`,T?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(Ne,{"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 ${c.name} moves the card`,onClick:()=>f(c,`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)(nt,{boards:r,ownBoard:n.id,boardKey:c.target.moveToBoardKey??c.target.boardKey,phaseKey:c.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(je,{"aria-label":`${c.name} on`,checked:c.enabled,onCheckedChange:e=>h(c,e)}),(0,Q.jsxs)(X,{children:[(0,Q.jsx)(X.Trigger,{render:(0,Q.jsx)(x,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${c.name}`,children:(0,Q.jsx)(ze,{})})}),(0,Q.jsx)(X.Content,{align:`end`,children:(0,Q.jsxs)(X.Item,{variant:`destructive`,onClick:()=>ee(c),children:[(0,Q.jsx)(Ze,{}),`Delete rule`]})})]})]})]})]}),T&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:v?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,S.toLowerCase(),`.`]}):`Off, skipped`}),c.problems.map(e=>(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)($e,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),D&&(0,Q.jsx)(wt,{skips:D}),fe(c,e)&&(0,Q.jsxs)(L,{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:()=>g(c),className:`underline`,children:`Let outside authors match`})]}),me(c,e)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),b&&xe(c)&&(0,Q.jsx)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:J(`work_item.created`).label}),l!==y&&!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)(L,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},c.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[y<0&&(0,Q.jsxs)(L,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(z,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),T]}),o&&(0,Q.jsx)(x,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(Ye,{}),onClick:p,children:`Add rule`})]})]}),l]})]})}function Ct(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function wt({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(L,{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)($e,{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: `,Ct(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 Tt=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function Et(e){return e instanceof T&&e.code!==void 0&&Tt.has(e.code)}function Dt(e){return Et(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Ot({factoryId:e,boardId:t}){let n=R(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(j,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(b,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(kt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(b,{variant:`warning`,children:`This board isn’t installed.`})}function kt({factoryId:e,board:n,boards:i}){let a=G(e,n.id),o=ce(e),s=ie(e),l=V(e),d=ae(e),[f,p]=(0,Z.useState)(),m=(0,Z.useRef)(void 0),h=e=>{m.current=e,p(e)},[ee,g]=(0,Z.useState)(),v=a.data?.intakeRoutes??[],y=a.data?.canEdit??!1,x=r(n),S=(o.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===n.id&&e.target.boardKey!==n.id),C=new Map(l.data?.skipped.map(e=>[e.routeId,e])),[w]=_(),T=w.get(`into`)??void 0,E=w.has(D),O=E||T!==void 0,A=O&&o.data?t(o.data.intakeRoutes,{key:n.id,initialPhase:n.initialPhase}):void 0,P=A&&new Set((E?A.leaving:A.into.get(T??``)??[]).map(e=>e.id)),F=e=>!P||e.some(e=>P.has(e.id));if(a.isPending||O&&o.isPending)return(0,Q.jsx)(j,{className:`h-64 w-full`});if(a.isError)return(0,Q.jsx)(b,{variant:`destructive`,children:`This board’s rules didn’t load.`});let I=e=>d.mutateAsync(e).catch(e=>M.error(Dt(e))),L=(e,t,r)=>{let i=q(v,e).map(e=>e.id);I([{kind:`reorder`,boardKey:n.id,ids:c(v,i,t,r)}])},R=e=>{g(void 0),h(e)},ne=async e=>{let t=m.current,r=t?.rule,i=()=>t!==void 0&&m.current===t;g(void 0);try{if(r)await d.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[t]=await d.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:n.id,...e.target}}}]);i()&&h(void 0),t&&await z(t,e.on).catch(e=>M.error(Dt(e)));return}i()&&h(void 0)}catch(e){if(!i())return;if(r&&Et(e))return re(r);g(Dt(e))}},re=async e=>{let t=m.current,n=(await a.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&m.current===t&&(n?(h({...t,rule:n}),g(`Someone else changed this rule first. It now shows their version; make your change again.`)):(h(void 0),M.error(`Someone else deleted this rule first.`)))},z=async(e,t)=>{if(e.target.boardKey!==n.id)return;let r=(await a.refetch()).data?.intakeRoutes??[],i=r.map(e=>e.id),o=i.indexOf(e.id),s=t.flatMap(t=>{let n=q(r,t),a=n[ge(n,t,n.findIndex(t=>t.id===e.id))];return a?[i.indexOf(a.id)]:[]}),l=Math.min(...s);o<0||!(l<o)||await d.mutateAsync([{kind:`reorder`,boardKey:n.id,ids:c(r,i,o,l)}])},B=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:_e(s.data?.boards,n.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.isError&&(0,Q.jsx)(b,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),O&&(0,Q.jsx)(bt,{count:P?.size,into:E||!T?`other boards`:u(n,T)??T,leaving:E,showAll:k(e,n.id)}),ye.filter(e=>e.events.some(e=>F([...q(v,e),...q(S,e)]))).map(t=>(0,Q.jsxs)(`section`,{"aria-label":t.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(N,{children:t.title}),t.events.some(K)?s.data&&(0,Q.jsx)(it,{factoryId:e,boardKey:n.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(te,{children:`Only cards already on this board; other boards never see them.`})]}),t.events.map(t=>{let r=K(t),a=q(v,t),o=q(S,t).filter(e=>!P||P.has(e.id));return F([...a,...o])?(0,Q.jsx)(St,{event:t,rules:a,board:n,boards:i,phaseOptions:x,canEdit:y,skips:C,footer:r?B:void 0,only:P,incoming:o.length?(0,Q.jsx)(rt,{factoryId:e,rules:o,board:n,boards:i}):void 0,onEdit:(e,t)=>R({rule:e,step:t}),onAdd:()=>R({event:t,step:`conditions`}),onMove:(e,n)=>L(t,e,n),onToggle:(e,t)=>void I([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void I([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&M.success(`Deleted “${e.name}”`)),onUngate:e=>void I([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&M.success(`“${e.name}” now matches outside authors’ pull requests`))},t):null})]},t.title)),f&&(0,Q.jsx)(gt,{factoryId:e,board:n,boards:i,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!y,saving:d.isPending,error:ee,onSave:e=>void ne(e),onClose:()=>h(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}function At(){let e=s(),t=l()?.boardId??``,{isMobile:r,desktopState:i}=p(),c=r||i===`collapsed`,u=w(e.id,t).data?.board,h=a({breadcrumbs:c&&u?(0,Q.jsxs)(f,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(d,{as:m,to:E(e.id,t),children:u.name}),(0,Q.jsx)(d,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(o,{variant:`settings`,header:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(n,{children:[(0,Q.jsx)(n.Title,{children:`Rules`}),(0,Q.jsx)(n.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(B,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...h,children:(0,Q.jsx)(Ot,{factoryId:e.id,boardId:t})})}export{At as BoardRulesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,f as r,i,k as a,n as o,s}from"./IconChevronRightMedium.es-BjSIsine.js";import{c,h as l,ni as u,qn as d}from"./GithubIcon.es-B1lB1Q-8.js";import{i as f,n as p,r as m,t as h}from"./select-Bdt18YBg-DJqvU5Dv.js";import{J as g,q as _}from"./useSessionRows-aTHnrKGG.js";import{t as ee}from"./IconPlusMedium.es-QmObHPf-.js";import{a as v,c as y,d as b,i as x,l as S,s as C,u as w}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";import{t as te}from"./IconUser.es-8QnHQfy-.js";import{t as ne}from"./IconCircleCheck.es-e9o_0ikv.js";import{D as re,O as ie,S as ae,b as T,x as E}from"./ruleLanes-D9QkgLJm.js";import{m as oe}from"./useIntakeRoutes-BNBPe6sx.js";import{t as se}from"./createLucideIcon-B6gALBEh.js";import{t as ce}from"./TrashIcon.es-CLx-KWTg.js";import{t as le}from"./IconUserDuo.es-0xR_m2_v.js";import{t as ue}from"./input-DqReKX0A-B4MUvQwj.js";import{d as de,o as fe,r as pe}from"./useLinearData-XOkwHgla.js";import{Bn as D,En as me,Sr as he,kn as ge,vr as _e,yr as ve,zn as O}from"./index-SGLMjvLV.js";import{t as ye}from"./IconHashtag.es-DPNqJOUe.js";import{t as k}from"./IconPlugin1.es-cRNReen7.js";import{t as A}from"./IconShieldCheck.es-vPJGxBAr.js";var j={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};j.node;var be=se(j);function xe({factoryProjectId:e,repositories:t=[],bindings:n=[],linearProjects:r=[],linearTeams:i=[],jiraProjects:a=[]}){let o=t=>new Set(n.filter(n=>n.integrationId===t&&n.factoryProjectId===e).map(e=>e.sourceId)),s=o(`linear`),c=o(`jira`),l=[...t.map(e=>({value:e.slug,provider:e.provider??`github`})),...r.filter(e=>s.has(e.id)).flatMap(e=>e.teams.map(e=>({value:e.key,provider:`linear`}))),...i.filter(e=>s.has(de(e))).map(e=>({value:e.key,provider:`linear`})),...a.filter(e=>c.has(e.id)).map(e=>({value:e.key,provider:`jira`}))],u=new Set;return l.filter(e=>{let t=`${e.provider}\0${e.value.toLowerCase()}`;return!u.has(t)&&(u.add(t),!0)})}var Se=e=>`provider`in e&&typeof e.provider==`string`;function Ce(e,t){if(!Array.isArray(e.suggestions))return e;let n=ve(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Se(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}function we(e){let t=c(e),n=l(),r=t=>(n.data??[]).some(n=>n.integrationId===t&&n.factoryProjectId===e),i=pe(r(`linear`)),a=fe(r(`linear`)),o=ge(r(`jira`));return xe({factoryProjectId:e,repositories:t.data?.repositories,bindings:n.data,linearProjects:i.data?.projects,linearTeams:a.data?.teams,jiraProjects:o.data})}var M=t(),N=`flex h-control-sm w-14 shrink-0 items-center`;function P({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-lines`,className:n(`flex flex-col gap-2`,e),...t})}function F({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-line`,className:n(`flex items-start gap-2`,e),...t})}function I({className:e,children:t,...r}){return(0,M.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:n(N,i({variant:`caption`,tone:`muted`}),e),...r,children:t})}function Te({value:e,onValueChange:t,"aria-label":n=`Match all or any`}){return(0,M.jsx)(`div`,{"data-slot":`rule-line-logic`,className:N,children:(0,M.jsxs)(h,{value:e,onValueChange:e=>e&&t(e),children:[(0,M.jsx)(f,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,M.jsx)(`span`,{className:i({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,M.jsxs)(p,{children:[(0,M.jsx)(m,{value:`AND`,children:`and`}),(0,M.jsx)(m,{value:`OR`,children:`or`})]})]})})}function L({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-line-content`,className:n(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function Ee({depth:e,className:t,...r}){return(0,M.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:n(`flex min-w-0 flex-1 items-start gap-2 rounded-lg border border-border p-2`,e%2==0?`bg-fill-subtle`:`bg-card`,`[&>[data-slot=rule-lines]]:min-w-0 [&>[data-slot=rule-lines]]:flex-1`,t),...r})}function De({className:e,...t}){return(0,M.jsx)(u,{variant:`ghost`,size:`icon-sm`,className:n(`ml-auto`,e),...t,children:(0,M.jsx)(d,{})})}function Oe({className:e,children:t,...r}){return(0,M.jsxs)(u,{variant:`ghost`,size:`sm`,className:n(`ml-auto`,e),...r,children:[(0,M.jsx)(ce,{}),t]})}function ke({className:e,...t}){return(0,M.jsx)(`span`,{"data-slot":`rule-line-hint`,className:n(i({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function R({icon:e,className:t,children:r,...a}){return(0,M.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:n(i({variant:`caption`,tone:`muted`}),`inline-flex h-control-sm items-center gap-1.5 rounded-full border border-dashed border-border px-3 hover:border-border-strong hover:text-foreground [&_svg]:size-icon-sm`,s,t),...a,children:[e,r]})}var Ae=r(`IconColumns3`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`path`,{d:`M18 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V6C20 4.89543 19.1046 4 18 4Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M9.33984 4V20`,stroke:`currentColor`,strokeWidth:`2`}),(0,M.jsx)(`path`,{d:`M14.6602 4V20`,stroke:`currentColor`,strokeWidth:`2`})]})),je=r(`IconFontStyle`,()=>(0,M.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M19.4639 19H20C20.5523 19 21 19.4477 21 20C21 20.5523 20.5523 21 20 21H14.5C13.9477 21 13.5 20.5523 13.5 20C13.5 19.4477 13.9477 19 14.5 19H15.2578L13.9551 15H8.15625L6.85449 19H7.5C8.05228 19 8.5 19.4477 8.5 20C8.5 20.5523 8.05228 21 7.5 21H4.5C3.94772 21 3.5 20.5523 3.5 20C3.5 19.4477 3.94772 19 4.5 19H4.75L9.29418 5.04203C9.69064 3.82426 10.8258 3 12.1065 3C13.3871 3 14.5223 3.82418 14.9188 5.04188L19.4639 19ZM8.80762 13H13.3037L11.3409 6.97096C11.251 6.69479 10.8603 6.69479 10.7704 6.97096L8.80762 13Z`,fill:`currentColor`})),Me=r(`IconMerged`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M6 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M8 6H16C17.1046 6 18 6.89543 18 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),Ne=r(`IconZap`,()=>(0,M.jsx)(`path`,{d:`M19.5657 9H13.5C13.2239 9 13 8.77614 13 8.5V2.40139C13 1.90668 12.3584 1.71242 12.084 2.12404L4.01823 14.2226C3.79672 14.5549 4.03491 15 4.43426 15H10.5C10.7761 15 11 15.2239 11 15.5V21.5986C11 22.0933 11.6416 22.2876 11.916 21.876L19.9818 9.77735C20.2033 9.44507 19.9651 9 19.5657 9Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),z=e(a(),1),B=new Set([`exists`,`not_exists`]),V=new Set([`in`,`not_in`]),H=e=>`items`in e,Pe=0,U=()=>`condition-${++Pe}`,W=()=>({key:U(),field:``,operator:``}),Fe=e=>e+2<=3;function Ie(e){let t=e=>`conditions`in e?{key:U(),logic:e.operator,items:e.conditions.map(t)}:{key:U(),field:e.field,operator:e.operator,value:e.value};return{key:`root`,logic:e?.operator??`AND`,items:e?.conditions.map(t)??[]}}var Le=e=>oe.some(t=>t===e);function Re(e){if(!e.field)return!1;if(B.has(e.operator))return!0;let{value:t}=e;return t===void 0?!1:Array.isArray(t)?t.length>0:typeof t!=`string`||t.trim()!==``}function G(e){let t=!1,n=e=>{if(H(e)){let t=e.items.map(n).filter(e=>e!==void 0);return t.length>0?{operator:e.logic,conditions:t}:void 0}let{operator:r}=e;if(!Le(r)||!Re(e))t=!0;else return B.has(r)?{field:e.field,operator:r}:{field:e.field,operator:r,value:e.value}},r=e.items.map(n).filter(e=>e!==void 0);return{rule:r.length>0?{operator:e.logic,conditions:r}:null,incomplete:t}}function K(e,t,n){if(!B.has(t))return e.type===`boolean`?typeof n!=`boolean`||n:V.has(t)?Array.isArray(n)?n:n===void 0||n===``?[]:[n]:Array.isArray(n)?n[0]:n}var ze=r(`IconListAdd`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`path`,{d:`M4 6H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M4 12H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M15 15L21 15`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M18 12V18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M4 18H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),Be={"item.labels":me,"item.title":je,"item.author":te,"item.key":ye,"item.state":_,"item.assignees":le,"item.pullRequest":g,"item.trusted":A,"pullRequest.trusted":A,"source.kind":g,"source.integration":k,"source.provider":k,"source.repository":be,"pullRequest.closesIssue":Me,"closedIssue.phase":Ae,"closedIssue.hasPullRequest":g,"event.type":Ne,"event.reason":ne},Ve=ie();function q(e,t){return e?.operatorLabels?.[t]??T.find(e=>e.id===t)?.label??t}function J(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Y({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let s=ae(n,r),[c,l]=(0,z.useState)(()=>Ie(t)),{rule:u,incomplete:d}=G(c),f=he(u);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(X,{role:`group`,"aria-label":e,group:c,depth:0,fields:s,emptyHint:i,onChange:e=>{l(e);let{rule:t,incomplete:n}=G(e);a(t,n)}}),d&&(0,M.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),f&&(0,M.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:f})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:c}){let l=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),u=e=>s({...n,items:[...n.items,e]}),d=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(R,{icon:(0,M.jsx)(ee,{}),onClick:()=>u(W()),children:`Add condition`}),Fe(r)&&(0,M.jsx)(R,{icon:(0,M.jsx)(ze,{}),onClick:()=>u({key:U(),logic:n.logic===`AND`?`OR`:`AND`,items:[W()]}),children:`Add group`}),c&&(0,M.jsx)(Oe,{onClick:c,children:`Remove group`})]});if(n.items.length===0)return(0,M.jsx)(P,{role:e,"aria-label":t,children:(0,M.jsxs)(F,{children:[(0,M.jsx)(I,{children:`Where`}),(0,M.jsxs)(L,{children:[d,o&&(0,M.jsx)(ke,{children:o})]})]})});let f=n.logic===`AND`?`and`:`or`,p=_e(n.logic,a,n.items.filter(e=>!H(e)));return(0,M.jsxs)(P,{role:e,"aria-label":t,children:[n.items.map((e,t)=>(0,M.jsxs)(F,{children:[t===1?(0,M.jsx)(Te,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,M.jsx)(I,{children:t===0?`Where`:f}),H(e)?(0,M.jsx)(Ee,{depth:r,"aria-label":e.logic===`AND`?`All of these`:`Any of these`,children:(0,M.jsx)(X,{group:e,depth:r+1,fields:i,limits:p,onChange:e=>l(t,e.items.length>0?e:void 0),onRemove:()=>l(t,void 0)})}):(0,M.jsx)(He,{row:e,fields:i,limits:p.filter(t=>t!==e),onChange:e=>l(t,e),onRemove:()=>l(t,void 0)})]},e.key)),(0,M.jsxs)(F,{children:[(0,M.jsx)(I,{}),(0,M.jsx)(L,{children:d})]})]})}function Z({id:e}){let t=Be[e]??_;return(0,M.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function He({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=Ve.find(t=>t.id===e.field),s=a&&!t.some(e=>e.id===a.id)?[a,...t]:t,c=s.find(t=>t.id===e.field),l=c&&Ce(c,n),u=!!l&&re(l.id)&&(!e.operator||e.operator===`exists`||e.operator===`not_exists`);return(0,M.jsxs)(L,{children:[(0,M.jsxs)(h,{value:e.field||null,onValueChange:t=>{let n=s.find(e=>e.id===t);if(!n)return;let i=n.operators?.[0]??`equals`;r({...e,field:n.id,operator:i,value:K(n,i,void 0)})},children:[(0,M.jsx)(f,{size:`sm`,"aria-label":`Field`,className:`w-fit max-w-full`,children:(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[l&&(0,M.jsx)(Z,{id:l.id}),(0,M.jsx)(o,{as:`span`,variant:`caption`,className:`truncate`,children:l?.label??(e.field||`Choose a field`)})]})}),(0,M.jsx)(p,{children:s.map(e=>(0,M.jsx)(m,{value:e.id,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(Z,{id:e.id}),e.label]})},e.id))})]}),l?.type===`boolean`&&(0,M.jsx)(Ue,{row:e,field:l,onChange:r}),l&&u&&(0,M.jsx)(We,{row:e,field:l,onChange:r}),l&&l.type!==`boolean`&&!u&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(h,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:K(l,t,e.value)}),children:[(0,M.jsx)(f,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,children:q(l,e.operator)})}),(0,M.jsx)(p,{children:(l.operators??[]).map(e=>(0,M.jsx)(m,{value:e,children:q(l,e)},e))})]}),!B.has(e.operator)&&(0,M.jsx)(Ge,{row:e,field:l,onChange:r})]}),(0,M.jsx)(De,{"aria-label":`Remove condition`,onClick:i})]})}function Ue({row:e,field:t,onChange:n}){let r=J(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],i=e.operator!==`not_equals`==(e.value!==!1);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,M.jsx)(O,{size:`sm`,"aria-label":t.label,value:String(i),onValueChange:t=>n({...e,operator:`equals`,value:t===`true`}),children:r.map(e=>(0,M.jsx)(D,{value:e.value,children:e.label},e.value))})]})}function We({row:e,field:t,onChange:n}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,M.jsxs)(O,{size:`sm`,"aria-label":t.label,value:e.operator===`not_exists`?`false`:`true`,onValueChange:t=>n({...e,operator:t===`true`?`exists`:`not_exists`,value:void 0}),children:[(0,M.jsx)(D,{value:`true`,children:`Yes`}),(0,M.jsx)(D,{value:`false`,children:`No`})]})]})}function Ge({row:e,field:t,onChange:n}){let r=J(t),i=V.has(e.operator),a=T.find(t=>t.id===e.operator)?.freeText===!0;if(t.strict===!1&&!a){let a=Array.isArray(e.value)?e.value.map(String):e.value===void 0?[]:[String(e.value)];return(0,M.jsx)(qe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:E[t.id]??`Search or type a value`,onChange:t=>n({...e,value:i?t:t[0]})})}if(r&&i){let t=Array.isArray(e.value)?e.value.map(String):[];return(0,M.jsx)(Ke,{options:r.map(e=>({value:e.value,label:e.label??e.value})),values:t,onChange:t=>n({...e,value:t})})}if(r){let t=r.find(t=>t.value===String(e.value??``));return(0,M.jsxs)(h,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,M.jsx)(f,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,M.jsx)(p,{children:r.map(e=>(0,M.jsx)(m,{value:e.value,children:e.label},e.value))})]})}return(0,M.jsx)(Je,{row:e,field:t,many:i,onChange:n})}function Q(e){return e.length===0?`Choose values`:e.length>3?`${e.slice(0,2).join(`, `)} +${e.length-2}`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Ke({options:e,values:t,onChange:r}){let i=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),a=[...e,...i.filter(t=>!e.includes(t))],s=i.map(e=>e.label);return(0,M.jsxs)(S,{multiple:!0,autoHighlight:!0,items:a,value:i,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>r(e.map(e=>e.value)),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Values`,title:s.join(`, `),className:`w-fit max-w-64`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,s.length===0&&`text-muted-foreground`),children:Q(s)})}),(0,M.jsxs)(x,{children:[(0,M.jsx)(w,{placeholder:`Search`}),(0,M.jsx)(v,{children:`No option found.`}),(0,M.jsx)(y,{children:e=>(0,M.jsx)(C,{value:e,children:e.label},e.value)})]})]})}function qe({options:e,values:t,many:r,placeholder:i,onChange:a}){let[s,c]=(0,z.useState)(``),l=s.trim(),u=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),d=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),f=[...e,...d.filter(t=>!e.includes(t)),...l&&!u(l)&&!t.includes(l)?[{value:l,label:`Use “${l}”`}]:[]],p=d.map(e=>e.value),m={autoHighlight:!0,items:f,inputValue:s,onInputValueChange:c,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},h=(0,M.jsxs)(x,{children:[(0,M.jsx)(w,{placeholder:i}),(0,M.jsx)(v,{children:`Type a value to use it.`}),(0,M.jsx)(y,{children:e=>(0,M.jsx)(C,{value:e,children:e.label},e.value)})]}),g=(0,M.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,p.length===0&&`text-muted-foreground`),children:p.length===0?i:Q(p)});return r?(0,M.jsxs)(S,{...m,multiple:!0,value:d,onValueChange:e=>a(e.map(e=>e.value)),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Values`,title:p.join(`, `),className:`w-fit max-w-64`,children:g}),h]}):(0,M.jsxs)(S,{...m,value:d[0]??null,onValueChange:e=>e&&a([e.value]),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Value`,title:p[0],className:`w-fit max-w-64`,children:g}),h]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Je({row:e,field:t,many:n,onChange:r}){let[i,a]=(0,z.useState)(),o=i??$(e.value),s=()=>{if(i===void 0||(a(void 0),i===$(e.value)))return;if(n){let t=i.split(`,`).map(e=>e.trim());r({...e,value:t.filter(e=>e!==``)});return}if(t.type!==`number`){r({...e,value:i.trim()});return}let o=Number(i.trim());r({...e,value:i.trim()!==``&&Number.isFinite(o)?o:void 0})};return(0,M.jsx)(ue,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:E[t.id]??(n?`Values, comma separated`:`Value`),value:o,className:`w-48`,onChange:e=>a(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&a(void 0)}})}export{we as n,Y as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,f as r,i,k as a,n as o,s}from"./IconChevronRightMedium.es-BjSIsine.js";import{c,h as l,ni as u,qn as d}from"./GithubIcon.es-B1lB1Q-8.js";import{i as f,n as p,r as m,t as h}from"./select-Bdt18YBg-DJqvU5Dv.js";import{J as g,q as _}from"./useSessionRows-aTHnrKGG.js";import{t as ee}from"./IconPlusMedium.es-QmObHPf-.js";import{a as v,c as y,d as b,i as x,l as S,s as C,u as w}from"./combobox-parts-s-DJvMW4-CR5ZbuEq.js";import{t as te}from"./IconUser.es-8QnHQfy-.js";import{t as ne}from"./IconCircleCheck.es-e9o_0ikv.js";import{D as re,O as ie,S as ae,b as T,x as E}from"./ruleLanes-D9QkgLJm.js";import{m as oe}from"./useIntakeRoutes-BNBPe6sx.js";import{t as se}from"./createLucideIcon-B6gALBEh.js";import{t as ce}from"./TrashIcon.es-CLx-KWTg.js";import{t as le}from"./IconUserDuo.es-0xR_m2_v.js";import{t as ue}from"./input-DqReKX0A-B4MUvQwj.js";import{d as de,o as fe,r as pe}from"./useLinearData-XOkwHgla.js";import{Bn as D,En as me,Sr as he,kn as ge,vr as _e,yr as ve,zn as O}from"./index-DfNj4qTr.js";import{t as ye}from"./IconHashtag.es-DPNqJOUe.js";import{t as k}from"./IconPlugin1.es-cRNReen7.js";import{t as A}from"./IconShieldCheck.es-vPJGxBAr.js";var j={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};j.node;var be=se(j);function xe({factoryProjectId:e,repositories:t=[],bindings:n=[],linearProjects:r=[],linearTeams:i=[],jiraProjects:a=[]}){let o=t=>new Set(n.filter(n=>n.integrationId===t&&n.factoryProjectId===e).map(e=>e.sourceId)),s=o(`linear`),c=o(`jira`),l=[...t.map(e=>({value:e.slug,provider:e.provider??`github`})),...r.filter(e=>s.has(e.id)).flatMap(e=>e.teams.map(e=>({value:e.key,provider:`linear`}))),...i.filter(e=>s.has(de(e))).map(e=>({value:e.key,provider:`linear`})),...a.filter(e=>c.has(e.id)).map(e=>({value:e.key,provider:`jira`}))],u=new Set;return l.filter(e=>{let t=`${e.provider}\0${e.value.toLowerCase()}`;return!u.has(t)&&(u.add(t),!0)})}var Se=e=>`provider`in e&&typeof e.provider==`string`;function Ce(e,t){if(!Array.isArray(e.suggestions))return e;let n=ve(t),r=new Set;return{...e,suggestions:e.suggestions.filter(e=>{if(n&&Se(e)&&!n.has(e.provider))return!1;let t=e.value.toLowerCase();return!r.has(t)&&(r.add(t),!0)})}}function we(e){let t=c(e),n=l(),r=t=>(n.data??[]).some(n=>n.integrationId===t&&n.factoryProjectId===e),i=pe(r(`linear`)),a=fe(r(`linear`)),o=ge(r(`jira`));return xe({factoryProjectId:e,repositories:t.data?.repositories,bindings:n.data,linearProjects:i.data?.projects,linearTeams:a.data?.teams,jiraProjects:o.data})}var M=t(),N=`flex h-control-sm w-14 shrink-0 items-center`;function P({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-lines`,className:n(`flex flex-col gap-2`,e),...t})}function F({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-line`,className:n(`flex items-start gap-2`,e),...t})}function I({className:e,children:t,...r}){return(0,M.jsx)(`span`,{"data-slot":`rule-line-keyword`,"aria-hidden":t===void 0||void 0,className:n(N,i({variant:`caption`,tone:`muted`}),e),...r,children:t})}function Te({value:e,onValueChange:t,"aria-label":n=`Match all or any`}){return(0,M.jsx)(`div`,{"data-slot":`rule-line-logic`,className:N,children:(0,M.jsxs)(h,{value:e,onValueChange:e=>e&&t(e),children:[(0,M.jsx)(f,{size:`sm`,variant:`ghost`,"aria-label":n,className:`-ml-2 w-fit px-2`,children:(0,M.jsx)(`span`,{className:i({variant:`caption`,tone:`ink`}),children:e===`AND`?`and`:`or`})}),(0,M.jsxs)(p,{children:[(0,M.jsx)(m,{value:`AND`,children:`and`}),(0,M.jsx)(m,{value:`OR`,children:`or`})]})]})})}function L({className:e,...t}){return(0,M.jsx)(`div`,{"data-slot":`rule-line-content`,className:n(`flex min-h-control-sm min-w-0 flex-1 flex-wrap items-center gap-1.5`,e),...t})}function Ee({depth:e,className:t,...r}){return(0,M.jsx)(`div`,{role:`group`,"data-slot":`rule-line-group`,className:n(`flex min-w-0 flex-1 items-start gap-2 rounded-lg border border-border p-2`,e%2==0?`bg-fill-subtle`:`bg-card`,`[&>[data-slot=rule-lines]]:min-w-0 [&>[data-slot=rule-lines]]:flex-1`,t),...r})}function De({className:e,...t}){return(0,M.jsx)(u,{variant:`ghost`,size:`icon-sm`,className:n(`ml-auto`,e),...t,children:(0,M.jsx)(d,{})})}function Oe({className:e,children:t,...r}){return(0,M.jsxs)(u,{variant:`ghost`,size:`sm`,className:n(`ml-auto`,e),...r,children:[(0,M.jsx)(ce,{}),t]})}function ke({className:e,...t}){return(0,M.jsx)(`span`,{"data-slot":`rule-line-hint`,className:n(i({variant:`caption`,tone:`muted`}),`px-1`,e),...t})}function R({icon:e,className:t,children:r,...a}){return(0,M.jsxs)(`button`,{type:`button`,"data-slot":`rule-add-button`,className:n(i({variant:`caption`,tone:`muted`}),`inline-flex h-control-sm items-center gap-1.5 rounded-full border border-dashed border-border px-3 hover:border-border-strong hover:text-foreground [&_svg]:size-icon-sm`,s,t),...a,children:[e,r]})}var Ae=r(`IconColumns3`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`path`,{d:`M18 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V6C20 4.89543 19.1046 4 18 4Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M9.33984 4V20`,stroke:`currentColor`,strokeWidth:`2`}),(0,M.jsx)(`path`,{d:`M14.6602 4V20`,stroke:`currentColor`,strokeWidth:`2`})]})),je=r(`IconFontStyle`,()=>(0,M.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M19.4639 19H20C20.5523 19 21 19.4477 21 20C21 20.5523 20.5523 21 20 21H14.5C13.9477 21 13.5 20.5523 13.5 20C13.5 19.4477 13.9477 19 14.5 19H15.2578L13.9551 15H8.15625L6.85449 19H7.5C8.05228 19 8.5 19.4477 8.5 20C8.5 20.5523 8.05228 21 7.5 21H4.5C3.94772 21 3.5 20.5523 3.5 20C3.5 19.4477 3.94772 19 4.5 19H4.75L9.29418 5.04203C9.69064 3.82426 10.8258 3 12.1065 3C13.3871 3 14.5223 3.82418 14.9188 5.04188L19.4639 19ZM8.80762 13H13.3037L11.3409 6.97096C11.251 6.69479 10.8603 6.69479 10.7704 6.97096L8.80762 13Z`,fill:`currentColor`})),Me=r(`IconMerged`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M6 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M8 6H16C17.1046 6 18 6.89543 18 8V16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),Ne=r(`IconZap`,()=>(0,M.jsx)(`path`,{d:`M19.5657 9H13.5C13.2239 9 13 8.77614 13 8.5V2.40139C13 1.90668 12.3584 1.71242 12.084 2.12404L4.01823 14.2226C3.79672 14.5549 4.03491 15 4.43426 15H10.5C10.7761 15 11 15.2239 11 15.5V21.5986C11 22.0933 11.6416 22.2876 11.916 21.876L19.9818 9.77735C20.2033 9.44507 19.9651 9 19.5657 9Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),z=e(a(),1),B=new Set([`exists`,`not_exists`]),V=new Set([`in`,`not_in`]),H=e=>`items`in e,Pe=0,U=()=>`condition-${++Pe}`,W=()=>({key:U(),field:``,operator:``}),Fe=e=>e+2<=3;function Ie(e){let t=e=>`conditions`in e?{key:U(),logic:e.operator,items:e.conditions.map(t)}:{key:U(),field:e.field,operator:e.operator,value:e.value};return{key:`root`,logic:e?.operator??`AND`,items:e?.conditions.map(t)??[]}}var Le=e=>oe.some(t=>t===e);function Re(e){if(!e.field)return!1;if(B.has(e.operator))return!0;let{value:t}=e;return t===void 0?!1:Array.isArray(t)?t.length>0:typeof t!=`string`||t.trim()!==``}function G(e){let t=!1,n=e=>{if(H(e)){let t=e.items.map(n).filter(e=>e!==void 0);return t.length>0?{operator:e.logic,conditions:t}:void 0}let{operator:r}=e;if(!Le(r)||!Re(e))t=!0;else return B.has(r)?{field:e.field,operator:r}:{field:e.field,operator:r,value:e.value}},r=e.items.map(n).filter(e=>e!==void 0);return{rule:r.length>0?{operator:e.logic,conditions:r}:null,incomplete:t}}function K(e,t,n){if(!B.has(t))return e.type===`boolean`?typeof n!=`boolean`||n:V.has(t)?Array.isArray(n)?n:n===void 0||n===``?[]:[n]:Array.isArray(n)?n[0]:n}var ze=r(`IconListAdd`,()=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`path`,{d:`M4 6H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M4 12H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M15 15L21 15`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M18 12V18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,M.jsx)(`path`,{d:`M4 18H10`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),Be={"item.labels":me,"item.title":je,"item.author":te,"item.key":ye,"item.state":_,"item.assignees":le,"item.pullRequest":g,"item.trusted":A,"pullRequest.trusted":A,"source.kind":g,"source.integration":k,"source.provider":k,"source.repository":be,"pullRequest.closesIssue":Me,"closedIssue.phase":Ae,"closedIssue.hasPullRequest":g,"event.type":Ne,"event.reason":ne},Ve=ie();function q(e,t){return e?.operatorLabels?.[t]??T.find(e=>e.id===t)?.label??t}function J(e){return Array.isArray(e?.suggestions)&&e.suggestions.length>0?e.suggestions:void 0}function Y({label:e,rule:t,facts:n,options:r,emptyHint:i,onChange:a}){let s=ae(n,r),[c,l]=(0,z.useState)(()=>Ie(t)),{rule:u,incomplete:d}=G(c),f=he(u);return(0,M.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,M.jsx)(X,{role:`group`,"aria-label":e,group:c,depth:0,fields:s,emptyHint:i,onChange:e=>{l(e);let{rule:t,incomplete:n}=G(e);a(t,n)}}),d&&(0,M.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:`Finish or remove unfinished conditions to save.`}),f&&(0,M.jsx)(o,{as:`p`,variant:`caption`,tone:`muted`,children:f})]})}function X({role:e,"aria-label":t,group:n,depth:r,fields:i,limits:a=[],emptyHint:o,onChange:s,onRemove:c}){let l=(e,t)=>s({...n,items:t===void 0?n.items.filter((t,n)=>n!==e):n.items.with(e,t)}),u=e=>s({...n,items:[...n.items,e]}),d=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(R,{icon:(0,M.jsx)(ee,{}),onClick:()=>u(W()),children:`Add condition`}),Fe(r)&&(0,M.jsx)(R,{icon:(0,M.jsx)(ze,{}),onClick:()=>u({key:U(),logic:n.logic===`AND`?`OR`:`AND`,items:[W()]}),children:`Add group`}),c&&(0,M.jsx)(Oe,{onClick:c,children:`Remove group`})]});if(n.items.length===0)return(0,M.jsx)(P,{role:e,"aria-label":t,children:(0,M.jsxs)(F,{children:[(0,M.jsx)(I,{children:`Where`}),(0,M.jsxs)(L,{children:[d,o&&(0,M.jsx)(ke,{children:o})]})]})});let f=n.logic===`AND`?`and`:`or`,p=_e(n.logic,a,n.items.filter(e=>!H(e)));return(0,M.jsxs)(P,{role:e,"aria-label":t,children:[n.items.map((e,t)=>(0,M.jsxs)(F,{children:[t===1?(0,M.jsx)(Te,{value:n.logic,onValueChange:e=>s({...n,logic:e})}):(0,M.jsx)(I,{children:t===0?`Where`:f}),H(e)?(0,M.jsx)(Ee,{depth:r,"aria-label":e.logic===`AND`?`All of these`:`Any of these`,children:(0,M.jsx)(X,{group:e,depth:r+1,fields:i,limits:p,onChange:e=>l(t,e.items.length>0?e:void 0),onRemove:()=>l(t,void 0)})}):(0,M.jsx)(He,{row:e,fields:i,limits:p.filter(t=>t!==e),onChange:e=>l(t,e),onRemove:()=>l(t,void 0)})]},e.key)),(0,M.jsxs)(F,{children:[(0,M.jsx)(I,{}),(0,M.jsx)(L,{children:d})]})]})}function Z({id:e}){let t=Be[e]??_;return(0,M.jsx)(t,{"aria-hidden":`true`,className:`text-muted-foreground size-3.5 shrink-0`})}function He({row:e,fields:t,limits:n,onChange:r,onRemove:i}){let a=Ve.find(t=>t.id===e.field),s=a&&!t.some(e=>e.id===a.id)?[a,...t]:t,c=s.find(t=>t.id===e.field),l=c&&Ce(c,n),u=!!l&&re(l.id)&&(!e.operator||e.operator===`exists`||e.operator===`not_exists`);return(0,M.jsxs)(L,{children:[(0,M.jsxs)(h,{value:e.field||null,onValueChange:t=>{let n=s.find(e=>e.id===t);if(!n)return;let i=n.operators?.[0]??`equals`;r({...e,field:n.id,operator:i,value:K(n,i,void 0)})},children:[(0,M.jsx)(f,{size:`sm`,"aria-label":`Field`,className:`w-fit max-w-full`,children:(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[l&&(0,M.jsx)(Z,{id:l.id}),(0,M.jsx)(o,{as:`span`,variant:`caption`,className:`truncate`,children:l?.label??(e.field||`Choose a field`)})]})}),(0,M.jsx)(p,{children:s.map(e=>(0,M.jsx)(m,{value:e.id,children:(0,M.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(Z,{id:e.id}),e.label]})},e.id))})]}),l?.type===`boolean`&&(0,M.jsx)(Ue,{row:e,field:l,onChange:r}),l&&u&&(0,M.jsx)(We,{row:e,field:l,onChange:r}),l&&l.type!==`boolean`&&!u&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(h,{value:e.operator,onValueChange:t=>t&&r({...e,operator:t,value:K(l,t,e.value)}),children:[(0,M.jsx)(f,{size:`sm`,variant:`ghost`,"aria-label":`Operator`,className:`w-fit`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,children:q(l,e.operator)})}),(0,M.jsx)(p,{children:(l.operators??[]).map(e=>(0,M.jsx)(m,{value:e,children:q(l,e)},e))})]}),!B.has(e.operator)&&(0,M.jsx)(Ge,{row:e,field:l,onChange:r})]}),(0,M.jsx)(De,{"aria-label":`Remove condition`,onClick:i})]})}function Ue({row:e,field:t,onChange:n}){let r=J(t)??[{value:`true`,label:`Yes`},{value:`false`,label:`No`}],i=e.operator!==`not_equals`==(e.value!==!1);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,M.jsx)(O,{size:`sm`,"aria-label":t.label,value:String(i),onValueChange:t=>n({...e,operator:`equals`,value:t===`true`}),children:r.map(e=>(0,M.jsx)(D,{value:e.value,children:e.label},e.value))})]})}function We({row:e,field:t,onChange:n}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(o,{as:`span`,variant:`caption`,tone:`muted`,children:`is`}),(0,M.jsxs)(O,{size:`sm`,"aria-label":t.label,value:e.operator===`not_exists`?`false`:`true`,onValueChange:t=>n({...e,operator:t===`true`?`exists`:`not_exists`,value:void 0}),children:[(0,M.jsx)(D,{value:`true`,children:`Yes`}),(0,M.jsx)(D,{value:`false`,children:`No`})]})]})}function Ge({row:e,field:t,onChange:n}){let r=J(t),i=V.has(e.operator),a=T.find(t=>t.id===e.operator)?.freeText===!0;if(t.strict===!1&&!a){let a=Array.isArray(e.value)?e.value.map(String):e.value===void 0?[]:[String(e.value)];return(0,M.jsx)(qe,{options:(r??[]).map(e=>({value:e.value,label:e.label??e.value})),values:a,many:i,placeholder:E[t.id]??`Search or type a value`,onChange:t=>n({...e,value:i?t:t[0]})})}if(r&&i){let t=Array.isArray(e.value)?e.value.map(String):[];return(0,M.jsx)(Ke,{options:r.map(e=>({value:e.value,label:e.label??e.value})),values:t,onChange:t=>n({...e,value:t})})}if(r){let t=r.find(t=>t.value===String(e.value??``));return(0,M.jsxs)(h,{value:e.value===void 0?null:String(e.value),onValueChange:t=>t!==null&&n({...e,value:t}),children:[(0,M.jsx)(f,{size:`sm`,"aria-label":`Value`,className:`w-fit`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,className:`font-medium`,children:t?.label??(e.value===void 0?`Choose a value`:String(e.value))})}),(0,M.jsx)(p,{children:r.map(e=>(0,M.jsx)(m,{value:e.value,children:e.label},e.value))})]})}return(0,M.jsx)(Je,{row:e,field:t,many:i,onChange:n})}function Q(e){return e.length===0?`Choose values`:e.length>3?`${e.slice(0,2).join(`, `)} +${e.length-2}`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} or ${e.at(-1)}`}function Ke({options:e,values:t,onChange:r}){let i=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),a=[...e,...i.filter(t=>!e.includes(t))],s=i.map(e=>e.label);return(0,M.jsxs)(S,{multiple:!0,autoHighlight:!0,items:a,value:i,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>r(e.map(e=>e.value)),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Values`,title:s.join(`, `),className:`w-fit max-w-64`,children:(0,M.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,s.length===0&&`text-muted-foreground`),children:Q(s)})}),(0,M.jsxs)(x,{children:[(0,M.jsx)(w,{placeholder:`Search`}),(0,M.jsx)(v,{children:`No option found.`}),(0,M.jsx)(y,{children:e=>(0,M.jsx)(C,{value:e,children:e.label},e.value)})]})]})}function qe({options:e,values:t,many:r,placeholder:i,onChange:a}){let[s,c]=(0,z.useState)(``),l=s.trim(),u=t=>e.some(e=>e.value.toLowerCase()===t.toLowerCase()),d=t.map(t=>e.find(e=>e.value===t)??{value:t,label:t}),f=[...e,...d.filter(t=>!e.includes(t)),...l&&!u(l)&&!t.includes(l)?[{value:l,label:`Use “${l}”`}]:[]],p=d.map(e=>e.value),m={autoHighlight:!0,items:f,inputValue:s,onInputValueChange:c,itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value},h=(0,M.jsxs)(x,{children:[(0,M.jsx)(w,{placeholder:i}),(0,M.jsx)(v,{children:`Type a value to use it.`}),(0,M.jsx)(y,{children:e=>(0,M.jsx)(C,{value:e,children:e.label},e.value)})]}),g=(0,M.jsx)(o,{as:`span`,variant:`caption`,className:n(`font-medium`,p.length===0&&`text-muted-foreground`),children:p.length===0?i:Q(p)});return r?(0,M.jsxs)(S,{...m,multiple:!0,value:d,onValueChange:e=>a(e.map(e=>e.value)),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Values`,title:p.join(`, `),className:`w-fit max-w-64`,children:g}),h]}):(0,M.jsxs)(S,{...m,value:d[0]??null,onValueChange:e=>e&&a([e.value]),children:[(0,M.jsx)(b,{size:`sm`,"aria-label":`Value`,title:p[0],className:`w-fit max-w-64`,children:g}),h]})}function $(e){return Array.isArray(e)?e.join(`, `):e===void 0?``:String(e)}function Je({row:e,field:t,many:n,onChange:r}){let[i,a]=(0,z.useState)(),o=i??$(e.value),s=()=>{if(i===void 0||(a(void 0),i===$(e.value)))return;if(n){let t=i.split(`,`).map(e=>e.trim());r({...e,value:t.filter(e=>e!==``)});return}if(t.type!==`number`){r({...e,value:i.trim()});return}let o=Number(i.trim());r({...e,value:i.trim()!==``&&Number.isFinite(o)?o:void 0})};return(0,M.jsx)(ue,{size:`sm`,"aria-label":`Value`,type:t.type===`number`&&!n?`number`:`text`,placeholder:E[t.id]??(n?`Values, comma separated`:`Value`),value:o,className:`w-48`,onChange:e=>a(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&a(void 0)}})}export{we as n,Y as t};
|