glimmervoid 0.48.3-next.340 → 0.48.3-next.341

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/bin/glimmervoid.js +13 -13
  2. package/dist/chunks/{adapters-Cypnpb15.js → adapters-CqIiC4wy.js} +1 -1
  3. package/dist/chunks/{adapters-D3fvjFaD.js → adapters-D3A-v_38.js} +7 -7
  4. package/dist/chunks/{agent-api-cli-wZDMb0MI.js → agent-api-cli-CC5UBJ2s.js} +4 -4
  5. package/dist/chunks/{agent-api-cli-C8Lt6Lke.js → agent-api-cli-w8p3TM5U.js} +1 -1
  6. package/dist/chunks/{agent-api-core-DzpmMNi8.js → agent-api-core-B4dswEWq.js} +3 -3
  7. package/dist/chunks/{agent-setup-cli-LZVcT_BR.js → agent-setup-cli-BKmMokta.js} +1 -1
  8. package/dist/chunks/{build-channel-CuS5bnD6.js → build-channel-DzwSAk14.js} +2 -2
  9. package/dist/chunks/{config-BGRSF5X2.js → config-VQsMVZIQ.js} +1 -1
  10. package/dist/chunks/{config-store-D5RoJ_zB.js → config-store-CShBORR1.js} +2 -2
  11. package/dist/chunks/config-store-DEkwz-6k.js +1 -0
  12. package/dist/chunks/{grok-B2RMzXN-.js → grok-BKgSFzBi.js} +1 -1
  13. package/dist/chunks/kimi-Cm2sK8Tx.js +1 -0
  14. package/dist/chunks/{kimi-BUCUWtAv.js → kimi-D9tvTcda.js} +2 -2
  15. package/dist/chunks/{main-DVxf4JXV.js → main-Dnr3g9HH.js} +1079 -12
  16. package/dist/chunks/{pair-cli-CEnZQWHm.js → pair-cli-SoQE_iE3.js} +2 -2
  17. package/dist/chunks/{remote-config-Swfcj7a-.js → remote-config-CZtuA1zc.js} +1 -1
  18. package/dist/chunks/{session-Cc-HBJIZ.js → session-Disk6UCW.js} +4 -2
  19. package/dist/chunks/{session-routes-CyZVo7KV.js → session-routes-DgjC1v_s.js} +1 -1
  20. package/dist/chunks/{settings-cli-D8_UvDMg.js → settings-cli-DEH7vB4p.js} +5 -5
  21. package/dist/chunks/{settings-readout-core-CQKHLWc6.js → settings-readout-core-C9idkO4T.js} +2 -2
  22. package/dist/chunks/{shown-files-core-CWrkgcoQ.js → shown-files-core-CQXipC3W.js} +1 -1
  23. package/dist/chunks/{spawn-env-Bjy1iYqZ.js → spawn-env-DGiSmxnR.js} +1 -1
  24. package/dist/chunks/{ssh-sign-cli-C1dOd8_x.js → ssh-sign-cli-B2VR82P7.js} +2 -2
  25. package/dist/client/assets/{action-status-DEIpSTGp.js → action-status-DN2GDs7f.js} +1 -1
  26. package/dist/client/assets/action-status-DN2GDs7f.js.br +0 -0
  27. package/dist/client/assets/{benchmark-panel-QOMIw0lh.js → benchmark-panel-t4EmV6bx.js} +1 -1
  28. package/dist/client/assets/benchmark-panel-t4EmV6bx.js.br +0 -0
  29. package/dist/client/assets/boards-view-ytVHh3Z4.js +1 -0
  30. package/dist/client/assets/boards-view-ytVHh3Z4.js.br +0 -0
  31. package/dist/client/assets/{card-registry-DmMhE6ta.js → card-registry-BB1ieZuJ.js} +1 -1
  32. package/dist/client/assets/card-registry-BB1ieZuJ.js.br +0 -0
  33. package/dist/client/assets/{community-panel-Stn5Y97k.js → community-panel-CaetJ-BG.js} +1 -1
  34. package/dist/client/assets/community-panel-CaetJ-BG.js.br +0 -0
  35. package/dist/client/assets/{control-ws-B-xw3MKQ.js → control-ws-mJyFaLSl.js} +1 -1
  36. package/dist/client/assets/control-ws-mJyFaLSl.js.br +0 -0
  37. package/dist/client/assets/{dialogs-DYjh5jwU.js → dialogs-puj3Bp_f.js} +1 -1
  38. package/dist/client/assets/dialogs-puj3Bp_f.js.br +0 -0
  39. package/dist/client/assets/{doc-editor-ui-kU3-tIee.js → doc-editor-ui-JZH8p_Hm.js} +1 -1
  40. package/dist/client/assets/doc-editor-ui-JZH8p_Hm.js.br +0 -0
  41. package/dist/client/assets/{feature-hint-BRnqKQxw.js → feature-hint-C5m1g1qd.js} +1 -1
  42. package/dist/client/assets/feature-hint-C5m1g1qd.js.br +0 -0
  43. package/dist/client/assets/{first-run-checklist-BT95ccnI.js → first-run-checklist-BgFOqEsd.js} +1 -1
  44. package/dist/client/assets/first-run-checklist-BgFOqEsd.js.br +0 -0
  45. package/dist/client/assets/{hooks-panel-DtjlYpR7.js → hooks-panel-Arkbh8DS.js} +1 -1
  46. package/dist/client/assets/hooks-panel-Arkbh8DS.js.br +0 -0
  47. package/dist/client/assets/{index-DAhsDR4e.js → index-gL1yyqsW.js} +5 -5
  48. package/dist/client/assets/index-gL1yyqsW.js.br +0 -0
  49. package/dist/client/assets/{issues-panel-Dsy9fS6c.js → issues-panel-4gPWBl_r.js} +1 -1
  50. package/dist/client/assets/issues-panel-4gPWBl_r.js.br +0 -0
  51. package/dist/client/assets/{my-prs-panel-BmMGPNHO.js → my-prs-panel-BkA352q_.js} +1 -1
  52. package/dist/client/assets/my-prs-panel-BkA352q_.js.br +0 -0
  53. package/dist/client/assets/{nyan-cat-DwI-ROow.js → nyan-cat-BJVHKnaV.js} +1 -1
  54. package/dist/client/assets/nyan-cat-BJVHKnaV.js.br +0 -0
  55. package/dist/client/assets/{phone-shell-DtDlh-i4.js → phone-shell-CvsTbKXi.js} +1 -1
  56. package/dist/client/assets/phone-shell-CvsTbKXi.js.br +0 -0
  57. package/dist/client/assets/{plan-face-D4FztfLW.js → plan-face-CX-DhHew.js} +1 -1
  58. package/dist/client/assets/plan-face-CX-DhHew.js.br +0 -0
  59. package/dist/client/assets/{plan-render-CgMI21b0.js → plan-render-CZ0wGdfR.js} +1 -1
  60. package/dist/client/assets/plan-render-CZ0wGdfR.js.br +0 -0
  61. package/dist/client/assets/{pr-queue-columns-CoxxUe5o.js → pr-queue-columns-BcZSp_Se.js} +1 -1
  62. package/dist/client/assets/pr-queue-columns-BcZSp_Se.js.br +0 -0
  63. package/dist/client/assets/{radar-panel-BnSOSvlP.js → radar-panel-B-kWIWoZ.js} +1 -1
  64. package/dist/client/assets/radar-panel-B-kWIWoZ.js.br +0 -0
  65. package/dist/client/assets/{repo-roots-adder-D7AEXdQg.js → repo-roots-adder-CAkIthBt.js} +1 -1
  66. package/dist/client/assets/repo-roots-adder-CAkIthBt.js.br +0 -0
  67. package/dist/client/assets/{resume-dialog-DsTCw_ZN.js → resume-dialog-DO3ClIA7.js} +1 -1
  68. package/dist/client/assets/resume-dialog-DO3ClIA7.js.br +0 -0
  69. package/dist/client/assets/{review-queue-panel-CzxQHXwJ.js → review-queue-panel-C5CMrPEt.js} +1 -1
  70. package/dist/client/assets/review-queue-panel-C5CMrPEt.js.br +0 -0
  71. package/dist/client/assets/{session-tick-D5WnSMBa.js → session-tick-C8B6gywP.js} +1 -1
  72. package/dist/client/assets/{settings-panel-CnQC9-zc.js → settings-panel-DPGhQMPB.js} +2 -2
  73. package/dist/client/assets/settings-panel-DPGhQMPB.js.br +0 -0
  74. package/dist/client/assets/{shown-lightbox-Djgk_k2v.js → shown-lightbox-Bmf2lPup.js} +1 -1
  75. package/dist/client/assets/shown-lightbox-Bmf2lPup.js.br +0 -0
  76. package/dist/client/assets/{team-review-panel-CwALeLVh.js → team-review-panel-ClEjKxC2.js} +1 -1
  77. package/dist/client/assets/team-review-panel-ClEjKxC2.js.br +0 -0
  78. package/dist/client/assets/{trace-panel-BYJPOEv9.js → trace-panel-B7EO6WGF.js} +1 -1
  79. package/dist/client/assets/trace-panel-B7EO6WGF.js.br +0 -0
  80. package/dist/client/assets/updates-view-core-DiTFcS0H.js +1 -0
  81. package/dist/client/assets/updates-view-core-DiTFcS0H.js.br +0 -0
  82. package/dist/client/assets/{usage-panel-CQtThqK2.js → usage-panel-CJrhMOCs.js} +1 -1
  83. package/dist/client/assets/usage-panel-CJrhMOCs.js.br +0 -0
  84. package/dist/client/assets/{your-day-tip-D8d8ZtJ8.js → your-day-tip-BJmJf-BC.js} +1 -1
  85. package/dist/client/assets/your-day-tip-BJmJf-BC.js.br +3 -0
  86. package/dist/client/index.html +6 -6
  87. package/dist/client/index.html.br +0 -0
  88. package/dist/server/index.js +1 -1
  89. package/package.json +1 -1
  90. package/dist/chunks/config-store-CNX_oZTd.js +0 -1
  91. package/dist/chunks/kimi-ChLOeGKh.js +0 -1
  92. package/dist/client/assets/action-status-DEIpSTGp.js.br +0 -0
  93. package/dist/client/assets/benchmark-panel-QOMIw0lh.js.br +0 -0
  94. package/dist/client/assets/boards-view-bn14GkP3.js +0 -1
  95. package/dist/client/assets/boards-view-bn14GkP3.js.br +0 -0
  96. package/dist/client/assets/card-registry-DmMhE6ta.js.br +0 -5
  97. package/dist/client/assets/community-panel-Stn5Y97k.js.br +0 -0
  98. package/dist/client/assets/control-ws-B-xw3MKQ.js.br +0 -0
  99. package/dist/client/assets/dialogs-DYjh5jwU.js.br +0 -0
  100. package/dist/client/assets/doc-editor-ui-kU3-tIee.js.br +0 -0
  101. package/dist/client/assets/feature-hint-BRnqKQxw.js.br +0 -0
  102. package/dist/client/assets/first-run-checklist-BT95ccnI.js.br +0 -0
  103. package/dist/client/assets/hooks-panel-DtjlYpR7.js.br +0 -0
  104. package/dist/client/assets/index-DAhsDR4e.js.br +0 -0
  105. package/dist/client/assets/issues-panel-Dsy9fS6c.js.br +0 -0
  106. package/dist/client/assets/my-prs-panel-BmMGPNHO.js.br +0 -0
  107. package/dist/client/assets/nyan-cat-DwI-ROow.js.br +0 -0
  108. package/dist/client/assets/phone-shell-DtDlh-i4.js.br +0 -0
  109. package/dist/client/assets/plan-face-D4FztfLW.js.br +0 -0
  110. package/dist/client/assets/plan-render-CgMI21b0.js.br +0 -0
  111. package/dist/client/assets/pr-queue-columns-CoxxUe5o.js.br +0 -0
  112. package/dist/client/assets/radar-panel-BnSOSvlP.js.br +0 -0
  113. package/dist/client/assets/repo-roots-adder-D7AEXdQg.js.br +0 -0
  114. package/dist/client/assets/resume-dialog-DsTCw_ZN.js.br +0 -0
  115. package/dist/client/assets/review-queue-panel-CzxQHXwJ.js.br +0 -0
  116. package/dist/client/assets/settings-panel-CnQC9-zc.js.br +0 -0
  117. package/dist/client/assets/shown-lightbox-Djgk_k2v.js.br +0 -0
  118. package/dist/client/assets/team-review-panel-CwALeLVh.js.br +0 -0
  119. package/dist/client/assets/trace-panel-BYJPOEv9.js.br +0 -0
  120. package/dist/client/assets/updates-view-core-DcQGhSIg.js +0 -1
  121. package/dist/client/assets/updates-view-core-DcQGhSIg.js.br +0 -0
  122. package/dist/client/assets/usage-panel-CQtThqK2.js.br +0 -0
  123. package/dist/client/assets/your-day-tip-D8d8ZtJ8.js.br +0 -0
@@ -2,11 +2,11 @@ import { a as showHomeAsTilde, i as sanitizeOneLine, n as requireExecutableSpawn
2
2
  import { a as isMissingFileError, r as errorMessage, t as errorCode } from "./text-DoirglWV.js";
3
3
  import { a as packageRoot, c as caseFoldedPathKey, d as safePathSegment, f as sanitizeWorktreeName, i as clientDir, l as equalsIgnoringCaseOnWindows, n as bundled, o as relayPath, r as cliPath, s as resolvePackageBin, t as assetRoot, u as isPathInside } from "./runtime-paths-D_ZjJLE0.js";
4
4
  import { n as glimmervoidHomeDir, r as isOperatorHomeUnderTest, t as decideConfigPath } from "./config-path-core-DUWk0Lui.js";
5
- import { $ as MyPrAutoRebase, $t as NODE_ID_RE, A as SIGN_URL_ENV, At as ReviewComment, Bt as TeamReviewStateEntry, Ct as FindingSeverity, D as SESSION_NAME_PATTERN, Dt as PostingPlan, Et as PostedReviewEvent, F as ShownFile, Ft as ReviewVerdict, G as Frame, Gt as canApproveAfterComment, H as BoardRecord, Ht as TeamReviewThreadCommentsResponse, It as TeamReviewActionRequest, J as WHITEBOARD_LIMITS, Jt as hasStandingViewerApproval, K as Note, Kt as decisionAsIfApprovalRequired, L as SshSignRequest, Mt as ReviewFinding, Nt as ReviewResult, O as SESSION_NAME_RULE_TEXT, Ot as PrDetail, Pt as ReviewThreadId, Q as MyPr, Qt as GH_SEGMENT, Rt as TeamReviewCompareFiles, S as ConversationQuestion, St as EarlierReview, T as SESSION_DOC_BODY_CAP_BYTES, Tt as GithubReviewState, Ut as TeamReviewThreadResult, Vt as TeamReviewStatus, W as Box, Wt as TeamReviewThreadsRepository, X as Wire, Xt as HEX_SHA_RE, Z as LinkedPr, Zt as shortSha, _ as COHERENCE_HOOKS_INACTIVE, at as MyPrMergeMethod, b as CONVERSATION_TOOL_RESULT_HOOK_EVENT, bt as CommitSha, cn as MERGEABLE_LIVE_STATES, ct as MyPrMergeStateResponse, en as REPO_SLUG_RE, et as MyPrCheckContext, ft as MyPrThreadNode, ht as MyPrsState, i as ASK_USER_QUESTION_TOOL_NAME, it as MyPrLaneEntry, j as SSH_SIGN_BODY_CAP_BYTES, jt as ReviewDraft, k as SHOWN_FILE_CAP_BYTES, ln as RESTARTABLE_STATES, lt as MyPrMergeWhenReadyRequest, mt as MyPrsSnapshot, nt as MyPrKeepMergeableRequest, on as BADGE_LABELS, ot as MyPrMergeRequest, pt as MyPrThreadsResponse, r as AGENT_URL_ENV, sn as KILLABLE_STATES, tn as repoParts, tt as MyPrCheckContextsResponse, un as STATES, v as CONVERSATION_APPROVAL_SUMMARY_MAX_CHARS, xt as DECIDING_REVIEW_STATES, y as CONVERSATION_PERMISSION_HOOK_EVENT, z as TaskTitle, zt as TeamReviewResolveResponse } from "./session-Cc-HBJIZ.js";
5
+ import { $ as MyPrAutoRebase, $t as NODE_ID_RE, A as SIGN_URL_ENV, At as ReviewComment, Bt as TeamReviewStateEntry, Ct as FindingSeverity, D as SESSION_NAME_PATTERN, Dt as PostingPlan, Et as PostedReviewEvent, F as ShownFile, Ft as ReviewVerdict, G as Frame, Gt as canApproveAfterComment, H as BoardRecord, Ht as TeamReviewThreadCommentsResponse, It as TeamReviewActionRequest, J as WHITEBOARD_LIMITS, Jt as hasStandingViewerApproval, K as Note, Kt as decisionAsIfApprovalRequired, L as SshSignRequest, Mt as ReviewFinding, Nt as ReviewResult, O as SESSION_NAME_RULE_TEXT, Ot as PrDetail, Pt as ReviewThreadId, Q as MyPr, Qt as GH_SEGMENT, Rt as TeamReviewCompareFiles, S as ConversationQuestion, St as EarlierReview, T as SESSION_DOC_BODY_CAP_BYTES, Tt as GithubReviewState, Ut as TeamReviewThreadResult, Vt as TeamReviewStatus, W as Box, Wt as TeamReviewThreadsRepository, X as Wire, Xt as HEX_SHA_RE, Z as LinkedPr, Zt as shortSha, _ as COHERENCE_HOOKS_INACTIVE, at as MyPrMergeMethod, b as CONVERSATION_TOOL_RESULT_HOOK_EVENT, bt as CommitSha, cn as MERGEABLE_LIVE_STATES, ct as MyPrMergeStateResponse, en as REPO_SLUG_RE, et as MyPrCheckContext, ft as MyPrThreadNode, ht as MyPrsState, i as ASK_USER_QUESTION_TOOL_NAME, it as MyPrLaneEntry, j as SSH_SIGN_BODY_CAP_BYTES, jt as ReviewDraft, k as SHOWN_FILE_CAP_BYTES, ln as RESTARTABLE_STATES, lt as MyPrMergeWhenReadyRequest, mt as MyPrsSnapshot, nt as MyPrKeepMergeableRequest, on as BADGE_LABELS, ot as MyPrMergeRequest, pt as MyPrThreadsResponse, r as AGENT_URL_ENV, sn as KILLABLE_STATES, tn as repoParts, tt as MyPrCheckContextsResponse, un as STATES, v as CONVERSATION_APPROVAL_SUMMARY_MAX_CHARS, xt as DECIDING_REVIEW_STATES, y as CONVERSATION_PERMISSION_HOOK_EVENT, z as TaskTitle, zt as TeamReviewResolveResponse } from "./session-Disk6UCW.js";
6
6
  import { c as spawn, i as execFileSync, n as execFile, r as execFileAsync, s as refuseLaunchesOf, t as assertLaunchable } from "./child-process-safe-BCOoKfxG.js";
7
- import { $t as IssuesStatus, A as HINT_VIEW_BY_FEATURE, At as UpdateJournal, B as MergedPrListing, Bt as PLAN_HOOK_OUTPUT_MAX_CHARS, Ct as CommunityItem, D as pullRequestKeyFromReference, Dt as SKILL_NAME_RE, Et as DISCORD_CHANNEL_NAME_RE, F as BenchmarkJudgement, Ft as CoherenceJournalOutput, G as GithubPrLightSearchNode, Gt as parseExitPlanModeHookPayload, H as PrCheckoutCaseInput, Ht as PLAN_TOOL_NAME, I as BenchmarkRun, It as ChangeMap, J as WorkflowCommentBody, Jt as GithubIssueResponse, K as GithubPrsFrame, Kt as planTitle, L as BenchmarkStatus, Lt as changeMapFactId, M as BenchmarkActionRequest, Mt as MAX_RAW_LINE_CHARS, N as BenchmarkCase, Nt as TraceCheckpoint, O as FeatureHintState, P as BenchmarkId, Pt as TraceRecord, Qt as IssuesState, R as BenchmarkSuite, Rt as PLAN_BODY_CAP_BYTES, St as CommunityDraft, Tt as CommunityVerdict, U as GithubPrDetailNode, Ut as PlanDecision, V as MinedPrReviewData, Vt as PLAN_RESULT_HOOK_EVENT, W as GithubPrKey, Wt as PlanRevision, X as WorkflowsSettings, Xt as IssueUpdate, Y as WorkflowLabelName, Yt as IssueKey, Z as WorkflowsState, Zt as IssuesSearchResponse, _ as CLIENT_LOG_TEXT_MAX_CHARS, a as ConfigUpdate, c as SHELL_AGENT_ID, en as issuePullRequestStateFromGithub, f as USAGE_COST_MODES, gt as USAGE_INTEGER_RANGES, h as CHANGES_POLL_INTERVAL_MS, jt as SessionSetup, k as HINT_FEATURES, p as USAGE_VENDOR_KEYS, q as comparablePrKey, qt as GithubIssuePullRequestsRepository, r as BrowserConfig, rt as KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE, s as RUNTIME_CONFIG_SCALAR_KEYS, u as configIssueMessage, v as CONTROL_FRAME_MAX_BYTES, wt as CommunityState, x as GithubTeam, xt as CommunityActionRequest, y as ClientMessage, z as CommitComparison, zt as PLAN_HOOK_EVENT } from "./config-BGRSF5X2.js";
8
- import { A as parseRefinedSessionName, B as resumePromptFor, C as decideTaskTitleRefinement, D as extractPromptTaskTitle, E as extractOscTaskTitle, F as AUTO_CONTINUE_PROMPT, G as isAutoNameOf, H as claudeProjectsDir, I as RESUME_ID_RE, K as nextSuggestedName, L as isConversationReplacedAtStartup, M as resolveRefocusTaskTitle, N as resolveTaskTitle, O as isSelfWakePrompt, P as seedTaskTitleSources, R as pickAutoResume, S as cleanTaskPrompt, T as extractHookTaskTitle, U as listRepoConversations, V as shouldAdoptReportedResumeId, W as listRepoWorktreePaths, _ as projectReviewDetail, a as checkAgentReply, b as buildTaskTitleRefinementPrompt, c as deriveChildSessionName, d as describePushLanding, f as describeRoleRefusal, g as projectMyPrs, h as parseAgentVerb, j as parseRefinedTaskTitle, k as isSubstantivePrompt, l as describeChildEndNote, n as REFUSAL_REASON, o as decideAgentRequest, p as describeUnpushedCloseRefusal, s as decideSpawnAllowance, u as describeKeptChildAttention, v as projectReviews, w as extractAiTitle, x as chooseRefinedSessionName, y as buildPersistedTaskTitle, z as resolveResumeTarget } from "./agent-api-core-DzpmMNi8.js";
9
- import { a as permitsHelpCommand, o as supervisionLine, r as describeSessionLimits } from "./session-routes-CyZVo7KV.js";
7
+ import { $t as IssuesStatus, A as HINT_VIEW_BY_FEATURE, At as UpdateJournal, B as MergedPrListing, Bt as PLAN_HOOK_OUTPUT_MAX_CHARS, Ct as CommunityItem, D as pullRequestKeyFromReference, Dt as SKILL_NAME_RE, Et as DISCORD_CHANNEL_NAME_RE, F as BenchmarkJudgement, Ft as CoherenceJournalOutput, G as GithubPrLightSearchNode, Gt as parseExitPlanModeHookPayload, H as PrCheckoutCaseInput, Ht as PLAN_TOOL_NAME, I as BenchmarkRun, It as ChangeMap, J as WorkflowCommentBody, Jt as GithubIssueResponse, K as GithubPrsFrame, Kt as planTitle, L as BenchmarkStatus, Lt as changeMapFactId, M as BenchmarkActionRequest, Mt as MAX_RAW_LINE_CHARS, N as BenchmarkCase, Nt as TraceCheckpoint, O as FeatureHintState, P as BenchmarkId, Pt as TraceRecord, Qt as IssuesState, R as BenchmarkSuite, Rt as PLAN_BODY_CAP_BYTES, St as CommunityDraft, Tt as CommunityVerdict, U as GithubPrDetailNode, Ut as PlanDecision, V as MinedPrReviewData, Vt as PLAN_RESULT_HOOK_EVENT, W as GithubPrKey, Wt as PlanRevision, X as WorkflowsSettings, Xt as IssueUpdate, Y as WorkflowLabelName, Yt as IssueKey, Z as WorkflowsState, Zt as IssuesSearchResponse, _ as CLIENT_LOG_TEXT_MAX_CHARS, a as ConfigUpdate, c as SHELL_AGENT_ID, en as issuePullRequestStateFromGithub, f as USAGE_COST_MODES, gt as USAGE_INTEGER_RANGES, h as CHANGES_POLL_INTERVAL_MS, jt as SessionSetup, k as HINT_FEATURES, p as USAGE_VENDOR_KEYS, q as comparablePrKey, qt as GithubIssuePullRequestsRepository, r as BrowserConfig, rt as KEEP_MERGEABLE_TIMEOUT_MINUTES_RANGE, s as RUNTIME_CONFIG_SCALAR_KEYS, u as configIssueMessage, v as CONTROL_FRAME_MAX_BYTES, wt as CommunityState, x as GithubTeam, xt as CommunityActionRequest, y as ClientMessage, z as CommitComparison, zt as PLAN_HOOK_EVENT } from "./config-VQsMVZIQ.js";
8
+ import { A as parseRefinedSessionName, B as resumePromptFor, C as decideTaskTitleRefinement, D as extractPromptTaskTitle, E as extractOscTaskTitle, F as AUTO_CONTINUE_PROMPT, G as isAutoNameOf, H as claudeProjectsDir, I as RESUME_ID_RE, K as nextSuggestedName, L as isConversationReplacedAtStartup, M as resolveRefocusTaskTitle, N as resolveTaskTitle, O as isSelfWakePrompt, P as seedTaskTitleSources, R as pickAutoResume, S as cleanTaskPrompt, T as extractHookTaskTitle, U as listRepoConversations, V as shouldAdoptReportedResumeId, W as listRepoWorktreePaths, _ as projectReviewDetail, a as checkAgentReply, b as buildTaskTitleRefinementPrompt, c as deriveChildSessionName, d as describePushLanding, f as describeRoleRefusal, g as projectMyPrs, h as parseAgentVerb, j as parseRefinedTaskTitle, k as isSubstantivePrompt, l as describeChildEndNote, n as REFUSAL_REASON, o as decideAgentRequest, p as describeUnpushedCloseRefusal, s as decideSpawnAllowance, u as describeKeptChildAttention, v as projectReviews, w as extractAiTitle, x as chooseRefinedSessionName, y as buildPersistedTaskTitle, z as resolveResumeTarget } from "./agent-api-core-B4dswEWq.js";
9
+ import { a as permitsHelpCommand, o as supervisionLine, r as describeSessionLimits } from "./session-routes-DgjC1v_s.js";
10
10
  import { a as rawTextOr, i as positiveNumberOr, n as isRecord, o as textOr, r as numberOr, t as coercedNumberOr } from "./coerce-oz_Z_6E7.js";
11
11
  import { i as parseCommandLine, n as warnWhenGitIsTooOld } from "./git-version-xS1GFU8P.js";
12
12
  import { t as HOOK_URL_ENV } from "./hook-relay-core-DA_bz2KA.js";
@@ -14,18 +14,18 @@ import { r as refocusReplyFor, t as promptContextReplyOf } from "./refocus-core-
14
14
  import { n as parseJsonRecord, t as parseJsonOrNull } from "./json-core-If8h-Qgy.js";
15
15
  import { a as saneYoloFiles } from "./sane-yolo-BjUkqIoH.js";
16
16
  import { r as knownWriteHookInput } from "./posthog-read-gate-core-CeSY56AB.js";
17
- import { a as readPageTitle, i as filesAfterRetention, n as decideShownKind, o as shownMimeForFilename, r as describeOverCap, t as SHOWN_SNIFF_BYTES } from "./shown-files-core-CWrkgcoQ.js";
17
+ import { a as readPageTitle, i as filesAfterRetention, n as decideShownKind, o as shownMimeForFilename, r as describeOverCap, t as SHOWN_SNIFF_BYTES } from "./shown-files-core-CQXipC3W.js";
18
18
  import { n as shellQuote } from "./hook-command-core-qTNK-xMF.js";
19
19
  import { C as parseCgroupBytes, D as DEFAULT_MAX_MS, E as DEFAULT_BASE_MS, O as nextBackoffMs, S as memoryReserveBytes, T as parseMemAvailableBytes, _ as createSpawnGate, a as jsonStateLoadError, b as cgroupLimitBytes, c as loadedJsonValue, d as writeJsonAtomicSync, g as createSerialQueue, h as createMemoryAdmission, i as createJsonStateWriter, m as createKeyedSerialQueue, n as appendJsonLines, o as loadJsonStateFile, p as writeTextAtomicSync, r as createJsonStateStore, s as loadJsonStateFileSync, t as appendJsonLine, u as writeJsonAtomic, v as isQueueAdmissionTimeout, w as parseCgroupV2Path, x as headroomFromReadings, y as cgroupAncestorPaths } from "./json-file-AKRVPqG1.js";
20
- import { $ as stableConfigKey, B as buildPersonProperties, F as TELEMETRY_FLAGS_URL, G as decideRemoteTelemetryState, H as claudeAccountUuidOf, I as adapterBucket, J as nodeMajorVersion, K as decideTelemetryConsent, L as buildAiGenerationEvents, M as isExperimentalSetting, N as FIRST_RUN_NOTICE, P as TELEMETRY_BATCH_URL, R as buildBrowserExceptionProperties, U as codexUserIdOf, V as classifySessionExit, W as decideIsDevInstall, X as resolveProjectToken, Y as parsePosthogReleaseId, _ as settingsBlockSpecFor, a as ensureProjectIds, at as sessionIdFromBranch, ct as canonicalizePath, f as DEFAULT_TIMER_FNS, g as mergeSettingsBlock, i as createConfigStore, it as planWorktreeGc, k as valueAtPath, lt as comparableDirectoryPath, n as DEFAULT_CONFIG, nt as matchedPrefix, o as generateProjectId, ot as usablePrefixes, p as unrefTimer, q as exceptionFingerprint, rt as planBranchGc, s as glimmervoidHomeDir$1, st as worktreeIntegrationTips, t as ABORT_CONFIG_SAVE, tt as DEFAULT_BRANCH_GC_PREFIXES, ut as isSameDirectoryPath, v as validateSettingsBlock, y as SETTINGS_INDEX, z as buildExceptionProperties } from "./config-store-D5RoJ_zB.js";
21
- import { _ as TelemetryState, a as DEEP_HISTORY_SCROLLBACK_LINES, c as describeDataAttach, d as DashboardTelemetryReport, h as TELEMETRY_EVENT_SCHEMAS, i as HookEnvelope, l as parseDataAttach, m as PendingCrashReport, r as HTTP_URL_RE, s as LOGGED_FAST_CLOSE_COUNTS, u as parseDataClientMessage } from "./build-channel-CuS5bnD6.js";
22
- import { i as resolveArgvCommandMatches } from "./kimi-BUCUWtAv.js";
23
- import { $ as grokHomes, A as decideUploadType, B as containmentRefusalReason, C as parseRegistryLatest, Ct as shouldReplace, D as openContainedFile, Dt as claudeCode, E as shortSha$1, Et as HOOK_TOOLS, F as planUploadRetention, G as codexFallbackRoots, H as planContiguousRead, I as MAX_TRANSCRIPT_READ_BYTES, J as codexSessionIdFromPath, K as codexHomes, L as TRACE_TAIL_SCAN_BYTES, M as framePathPaste, N as imageMimeForUploadFilename, O as MAX_UPLOAD_BYTES, P as isSafePathSegment, Q as expandTilde, R as committedOffsetFromTraceTailOrNull, S as parseRegistryDeprecation, St as parseUsageLine, T as pickNewestPublished, Tt as vendorUsageEntry, U as resumeOffsetFrom, V as isOversizedPartialLine, W as withCommittedOffset, X as decideFileRead, Y as continuationDelayMs, Z as dedupeCodexFiles, _ as decideInstallFlavor, _t as foldReplacementIntoGenerationRollup, a as describeAgentResolvability, at as scopedClaudeRoots, b as normalizeSha, bt as mergeGenerationRollups, c as isKnownAgentId, ct as shouldPersistWarehouse, d as resolveAdapter, dt as parseKimiUsageLine, et as isUsageFile, f as setCustomAgents, ft as addEntryToTotals, g as NODE_PTY_INSTALL_SCRIPT_FLAG, gt as foldEntryIntoGenerationRollup, h as requestCodexAppServer, ht as expandAdvisorIterations, i as customAgentFingerprint, it as resolveProjectsDirs, j as exceedsUploadCap, k as buildUploadFilename, l as listAgentIds, lt as splitLines, m as readHostCodexVersion, mt as emptyTotals, n as cachedAgentResolvability, nt as passOutcome, o as getAdapter, ot as sessionsRootCandidates, p as codex, pt as dedupKeys, q as codexRootCandidates, r as commandFor, rt as projectDirCandidates, s as hookProfileOf, st as shouldEvaluateDespiteIoFailures, t as DEFAULT_AGENT_ID$1, tt as kimiHomes, u as resetCommandCache, ut as kimiDedupIdentity, v as decideUpdateStatus, vt as identityFromRelPath, w as parseResolvedSha, wt as totalTokensOf$1, x as normalizeUpdateChannel, xt as parseJsonLine, y as isCheckFresh, yt as isWithinGenerationRecencyWindow, z as completeLineBytes } from "./adapters-D3fvjFaD.js";
20
+ import { $ as stableConfigKey, B as buildPersonProperties, F as TELEMETRY_FLAGS_URL, G as decideRemoteTelemetryState, H as claudeAccountUuidOf, I as adapterBucket, J as nodeMajorVersion, K as decideTelemetryConsent, L as buildAiGenerationEvents, M as isExperimentalSetting, N as FIRST_RUN_NOTICE, P as TELEMETRY_BATCH_URL, R as buildBrowserExceptionProperties, U as codexUserIdOf, V as classifySessionExit, W as decideIsDevInstall, X as resolveProjectToken, Y as parsePosthogReleaseId, _ as settingsBlockSpecFor, a as ensureProjectIds, at as sessionIdFromBranch, ct as canonicalizePath, f as DEFAULT_TIMER_FNS, g as mergeSettingsBlock, i as createConfigStore, it as planWorktreeGc, k as valueAtPath, lt as comparableDirectoryPath, n as DEFAULT_CONFIG, nt as matchedPrefix, o as generateProjectId, ot as usablePrefixes, p as unrefTimer, q as exceptionFingerprint, rt as planBranchGc, s as glimmervoidHomeDir$1, st as worktreeIntegrationTips, t as ABORT_CONFIG_SAVE, tt as DEFAULT_BRANCH_GC_PREFIXES, ut as isSameDirectoryPath, v as validateSettingsBlock, y as SETTINGS_INDEX, z as buildExceptionProperties } from "./config-store-CShBORR1.js";
21
+ import { _ as TelemetryState, a as DEEP_HISTORY_SCROLLBACK_LINES, c as describeDataAttach, d as DashboardTelemetryReport, h as TELEMETRY_EVENT_SCHEMAS, i as HookEnvelope, l as parseDataAttach, m as PendingCrashReport, r as HTTP_URL_RE, s as LOGGED_FAST_CLOSE_COUNTS, u as parseDataClientMessage } from "./build-channel-DzwSAk14.js";
22
+ import { i as resolveArgvCommandMatches } from "./kimi-D9tvTcda.js";
23
+ import { $ as grokHomes, A as decideUploadType, B as containmentRefusalReason, C as parseRegistryLatest, Ct as shouldReplace, D as openContainedFile, Dt as claudeCode, E as shortSha$1, Et as HOOK_TOOLS, F as planUploadRetention, G as codexFallbackRoots, H as planContiguousRead, I as MAX_TRANSCRIPT_READ_BYTES, J as codexSessionIdFromPath, K as codexHomes, L as TRACE_TAIL_SCAN_BYTES, M as framePathPaste, N as imageMimeForUploadFilename, O as MAX_UPLOAD_BYTES, P as isSafePathSegment, Q as expandTilde, R as committedOffsetFromTraceTailOrNull, S as parseRegistryDeprecation, St as parseUsageLine, T as pickNewestPublished, Tt as vendorUsageEntry, U as resumeOffsetFrom, V as isOversizedPartialLine, W as withCommittedOffset, X as decideFileRead, Y as continuationDelayMs, Z as dedupeCodexFiles, _ as decideInstallFlavor, _t as foldReplacementIntoGenerationRollup, a as describeAgentResolvability, at as scopedClaudeRoots, b as normalizeSha, bt as mergeGenerationRollups, c as isKnownAgentId, ct as shouldPersistWarehouse, d as resolveAdapter, dt as parseKimiUsageLine, et as isUsageFile, f as setCustomAgents, ft as addEntryToTotals, g as NODE_PTY_INSTALL_SCRIPT_FLAG, gt as foldEntryIntoGenerationRollup, h as requestCodexAppServer, ht as expandAdvisorIterations, i as customAgentFingerprint, it as resolveProjectsDirs, j as exceedsUploadCap, k as buildUploadFilename, l as listAgentIds, lt as splitLines, m as readHostCodexVersion, mt as emptyTotals, n as cachedAgentResolvability, nt as passOutcome, o as getAdapter, ot as sessionsRootCandidates, p as codex, pt as dedupKeys, q as codexRootCandidates, r as commandFor, rt as projectDirCandidates, s as hookProfileOf, st as shouldEvaluateDespiteIoFailures, t as DEFAULT_AGENT_ID$1, tt as kimiHomes, u as resetCommandCache, ut as kimiDedupIdentity, v as decideUpdateStatus, vt as identityFromRelPath, w as parseResolvedSha, wt as totalTokensOf$1, x as normalizeUpdateChannel, xt as parseJsonLine, y as isCheckFresh, yt as isWithinGenerationRecencyWindow, z as completeLineBytes } from "./adapters-D3A-v_38.js";
24
24
  import { c as CODEX_HOME_PROFILE, l as KIMI_HOME_PROFILE } from "./agent-home-core-DgW3orTE.js";
25
25
  import { d as releaseSessionLock, f as sessionIdOfLockFile, l as releaseUnheldAgentHomeSecrets, n as generatedAgentHomePath, p as trashSessionTempFolderOnceUnheld, s as realAgentHome, u as createHeldSessionTempFolder } from "./agent-home-BzANIIVe.js";
26
26
  import { a as formatSshPublicKey, c as orderAgentSockets, i as commitSigningShimText, l as parseSshPublicKey, n as NO_AGENT_HOLDS_KEY, o as isForwardedAgentDirName, r as agentListsKey, s as isSignableGitObject, t as COMMIT_SIGNING_SHIM_NAME } from "./ssh-signing-core-CRhVVWNW.js";
27
- import { a as configSiblingPath, c as defaultPairingsPath, d as decideDeviceAuth, f as deviceNameFromUserAgent, l as defaultSeenPath, n as normalizeRemoteConfig, o as createPairingsStore, p as hashSecret, r as validateRemoteConfig, s as createSeenStore, t as decideBindHost, u as DEFAULT_DEVICE_MAX_AGE_MS } from "./remote-config-Swfcj7a-.js";
28
- import { n as configFileViewOf, u as readSettingsForAgent } from "./settings-readout-core-CQKHLWc6.js";
27
+ import { a as configSiblingPath, c as defaultPairingsPath, d as decideDeviceAuth, f as deviceNameFromUserAgent, l as defaultSeenPath, n as normalizeRemoteConfig, o as createPairingsStore, p as hashSecret, r as validateRemoteConfig, s as createSeenStore, t as decideBindHost, u as DEFAULT_DEVICE_MAX_AGE_MS } from "./remote-config-CZtuA1zc.js";
28
+ import { n as configFileViewOf, u as readSettingsForAgent } from "./settings-readout-core-C9idkO4T.js";
29
29
  import { createRequire } from "node:module";
30
30
  import fs, { readFileSync } from "node:fs";
31
31
  import path, { join, resolve } from "node:path";
@@ -4084,6 +4084,1071 @@ function createBoard({ id, title, nowMs }) {
4084
4084
  };
4085
4085
  }
4086
4086
  //#endregion
4087
+ //#region shared/whiteboard-layout-core.ts
4088
+ var MARGIN = 40;
4089
+ var COLUMN_WIDTH = 220;
4090
+ var COLUMN_GAP = 90;
4091
+ var BOX_GAP = 30;
4092
+ var TITLE_LINE_HEIGHT = 20;
4093
+ var BODY_LINE_HEIGHT = 18;
4094
+ var TITLE_CHARS_PER_LINE = 20;
4095
+ var BODY_CHARS_PER_LINE = 26;
4096
+ var FRAME_PADDING = 18;
4097
+ var FRAME_TITLE_HEIGHT = 26;
4098
+ var NOTE_WIDTH = 170;
4099
+ var NOTE_CHARS_PER_LINE = 21;
4100
+ var NOTE_LINE_HEIGHT = 17;
4101
+ var NOTE_GAP = 10;
4102
+ var LEGEND_ROW_HEIGHT = 22;
4103
+ var COLUMN_TITLE_CHARS_PER_LINE = 24;
4104
+ var COLUMN_TITLE_LINE_HEIGHT = 16;
4105
+ var NOTE_OVERLAP = 24;
4106
+ var NOTE_RISE = 8;
4107
+ var CHANNEL_PAD = 10;
4108
+ var TRACK_SPACING = 14;
4109
+ var RUN_CLEARANCE = 4;
4110
+ var PORT_SPACING = 14;
4111
+ var PORT_INSET = 8;
4112
+ var GUTTER_CLEARANCE = 6;
4113
+ var MIN_GUTTER_HEIGHT = 4;
4114
+ var MIN_GUTTER_TRACK_SPACING = 6;
4115
+ var TOP_TRACK_SPACING = 12;
4116
+ var TOP_BAND_PAD = 10;
4117
+ var LABEL_CHAR_WIDTH = 6.6;
4118
+ var LABEL_GAP = 5;
4119
+ var LABEL_ASCENT = 10;
4120
+ var LABEL_CLEARANCE = 2;
4121
+ var BOX_CROSSING_COST = 100;
4122
+ var MAX_WIRES_FOR_PORT_SEARCH = 120;
4123
+ var LABEL_SLIDE_FRACTIONS = [
4124
+ .5,
4125
+ .35,
4126
+ .65,
4127
+ .2,
4128
+ .8
4129
+ ];
4130
+ var LANE_HEX_BY_COLOR = Object.freeze({
4131
+ blue: "#60a5fa",
4132
+ green: "#4ade80",
4133
+ orange: "#fb923c",
4134
+ pink: "#f472b6",
4135
+ cyan: "#22d3ee",
4136
+ yellow: "#facc15"
4137
+ });
4138
+ function wrapText(text, charsPerLine) {
4139
+ const words = text.split(/\s+/).filter(Boolean);
4140
+ const lines = [];
4141
+ let current = "";
4142
+ for (const word of words) {
4143
+ const pieces = word.match(new RegExp(`.{1,${charsPerLine}}`, "g")) ?? [word];
4144
+ for (const piece of pieces) {
4145
+ const candidate = current ? `${current} ${piece}` : piece;
4146
+ if (candidate.length <= charsPerLine) {
4147
+ current = candidate;
4148
+ continue;
4149
+ }
4150
+ lines.push(current);
4151
+ current = piece;
4152
+ }
4153
+ }
4154
+ if (current) lines.push(current);
4155
+ return lines.length > 0 ? lines : [""];
4156
+ }
4157
+ function laneOf(board, box) {
4158
+ const lane = board.lanes.find((candidate) => candidate.id === box.lane);
4159
+ if (!lane) return null;
4160
+ return {
4161
+ label: lane.label || lane.id,
4162
+ hex: LANE_HEX_BY_COLOR[lane.color]
4163
+ };
4164
+ }
4165
+ function boxShape(board, box) {
4166
+ const titleLines = wrapText(box.title, TITLE_CHARS_PER_LINE);
4167
+ const bodyLines = box.lines.flatMap((line) => wrapText(line.text, BODY_CHARS_PER_LINE - (line.muted ? 2 : 0)).map((text) => ({
4168
+ text,
4169
+ muted: line.muted
4170
+ })));
4171
+ const lane = laneOf(board, box);
4172
+ return {
4173
+ titleLines,
4174
+ bodyLines,
4175
+ lane,
4176
+ height: 24 + titleLines.length * TITLE_LINE_HEIGHT + bodyLines.length * BODY_LINE_HEIGHT + (lane ? 26 : 0)
4177
+ };
4178
+ }
4179
+ function elementsOfKind(board, kind) {
4180
+ return Object.values(board.elements).filter((element) => element.kind === kind);
4181
+ }
4182
+ function noteShape(note) {
4183
+ const lines = wrapText(note.text, NOTE_CHARS_PER_LINE);
4184
+ return {
4185
+ lines,
4186
+ height: 24 + (lines.length + 1) * NOTE_LINE_HEIGHT
4187
+ };
4188
+ }
4189
+ function noteStackHeightByBoxId(board) {
4190
+ const stackHeightByBoxId = /* @__PURE__ */ new Map();
4191
+ for (const note of elementsOfKind(board, "note")) {
4192
+ const stackedSoFar = stackHeightByBoxId.get(note.on);
4193
+ const noteHeight = noteShape(note).height;
4194
+ stackHeightByBoxId.set(note.on, stackedSoFar === void 0 ? noteHeight : stackedSoFar + NOTE_GAP + noteHeight);
4195
+ }
4196
+ return stackHeightByBoxId;
4197
+ }
4198
+ function columnTitleLines(board) {
4199
+ return board.columns.map((column) => column.title ? wrapText(column.title, COLUMN_TITLE_CHARS_PER_LINE) : []);
4200
+ }
4201
+ function headerExtraHeight(titleLinesByColumn) {
4202
+ return (Math.max(1, ...titleLinesByColumn.map((lines) => lines.length)) - 1) * COLUMN_TITLE_LINE_HEIGHT;
4203
+ }
4204
+ function groupedBy(items, keyOf) {
4205
+ const groups = /* @__PURE__ */ new Map();
4206
+ for (const item of items) {
4207
+ const key = keyOf(item);
4208
+ const group = groups.get(key);
4209
+ if (group) {
4210
+ group.push(item);
4211
+ continue;
4212
+ }
4213
+ groups.set(key, [item]);
4214
+ }
4215
+ return groups;
4216
+ }
4217
+ function gapReservesOf(board, stackHeightByBoxId) {
4218
+ const flowBoxes = elementsOfKind(board, "box").filter((box) => !box.at);
4219
+ const notedColumnIds = new Set(flowBoxes.filter((box) => stackHeightByBoxId.has(box.id)).map((box) => box.column));
4220
+ const framedBoxIds = new Set(elementsOfKind(board, "frame").flatMap((frame) => frame.contains));
4221
+ const framedColumnIds = new Set(flowBoxes.filter((box) => framedBoxIds.has(box.id)).map((box) => box.column));
4222
+ const sideReserve = (columnId) => CHANNEL_PAD + (columnId !== void 0 && framedColumnIds.has(columnId) ? FRAME_PADDING : 0);
4223
+ return board.columns.map((column, index) => {
4224
+ const isNoted = notedColumnIds.has(column.id);
4225
+ return {
4226
+ left: isNoted ? 156 : sideReserve(column.id),
4227
+ right: sideReserve(board.columns[index + 1]?.id),
4228
+ minimumWidth: isNoted ? Math.max(COLUMN_GAP, 186) : COLUMN_GAP
4229
+ };
4230
+ });
4231
+ }
4232
+ function gapWidthsOf(reserves, tracksByGap, labelWidthByGap) {
4233
+ return reserves.map((reserve, index) => {
4234
+ const tracks = tracksByGap[index] ?? 0;
4235
+ const labelWidth = labelWidthByGap[index] ?? 0;
4236
+ const trackNeed = tracks > 0 ? reserve.left + reserve.right + (tracks + 1) * TRACK_SPACING : 0;
4237
+ const labelNeed = labelWidth > 0 ? reserve.left + reserve.right + labelWidth + 20 : 0;
4238
+ return Math.max(reserve.minimumWidth, trackNeed, labelNeed);
4239
+ });
4240
+ }
4241
+ function columnLeftEdgesOf(board, gapWidths) {
4242
+ const columnLeftEdges = [];
4243
+ let nextX = MARGIN;
4244
+ for (const [index] of board.columns.entries()) {
4245
+ columnLeftEdges.push(nextX);
4246
+ nextX += COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
4247
+ }
4248
+ return columnLeftEdges;
4249
+ }
4250
+ function channelGapsOf(columnLeftEdges, gapWidths, reserves) {
4251
+ return columnLeftEdges.map((leftEdge, index) => {
4252
+ const reserve = reserves[index] ?? {
4253
+ left: CHANNEL_PAD,
4254
+ right: CHANNEL_PAD,
4255
+ minimumWidth: COLUMN_GAP
4256
+ };
4257
+ const gapRight = leftEdge + COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
4258
+ return {
4259
+ left: leftEdge + COLUMN_WIDTH + reserve.left,
4260
+ right: gapRight - reserve.right
4261
+ };
4262
+ });
4263
+ }
4264
+ function columnIndexOf(board, box, laidOut, columnLeftEdges) {
4265
+ if (!box.at) return Math.max(0, board.columns.findIndex((column) => column.id === box.column));
4266
+ const centerX = laidOut.x + laidOut.width / 2;
4267
+ const lastLeftOfCenter = columnLeftEdges.findLastIndex((leftEdge) => leftEdge <= centerX);
4268
+ return Math.max(0, lastLeftOfCenter);
4269
+ }
4270
+ function frameIdByBoxId(board) {
4271
+ const frameIds = /* @__PURE__ */ new Map();
4272
+ for (const frame of elementsOfKind(board, "frame")) for (const boxId of frame.contains) if (!frameIds.has(boxId)) frameIds.set(boxId, frame.id);
4273
+ return frameIds;
4274
+ }
4275
+ function frameClearance(previousFrameId, nextFrameId) {
4276
+ if (previousFrameId === nextFrameId) return 0;
4277
+ return (previousFrameId ? FRAME_PADDING : 0) + (nextFrameId ? 44 : 0);
4278
+ }
4279
+ function layoutBoxes(board, columnLeftEdges, boxesTop, stackHeightByBoxId) {
4280
+ const boxesById = /* @__PURE__ */ new Map();
4281
+ const nextYByColumnId = /* @__PURE__ */ new Map();
4282
+ const lastFrameIdByColumnId = /* @__PURE__ */ new Map();
4283
+ const frameIds = frameIdByBoxId(board);
4284
+ const boxes = elementsOfKind(board, "box").map((box, index) => ({
4285
+ box,
4286
+ index
4287
+ })).sort((left, right) => left.box.order - right.box.order || left.index - right.index);
4288
+ for (const { box } of boxes) {
4289
+ const columnIndex = Math.max(0, board.columns.findIndex((column) => column.id === box.column));
4290
+ const shape = boxShape(board, box);
4291
+ const frameId = frameIds.get(box.id) ?? null;
4292
+ const flowY = (nextYByColumnId.get(box.column) ?? boxesTop) + frameClearance(lastFrameIdByColumnId.get(box.column) ?? null, frameId);
4293
+ const position = box.at ?? {
4294
+ x: columnLeftEdges[columnIndex] ?? MARGIN,
4295
+ y: flowY
4296
+ };
4297
+ if (!box.at) {
4298
+ const noteStackBottom = (stackHeightByBoxId.get(box.id) ?? 0) - NOTE_RISE;
4299
+ nextYByColumnId.set(box.column, flowY + Math.max(shape.height, noteStackBottom) + BOX_GAP);
4300
+ lastFrameIdByColumnId.set(box.column, frameId);
4301
+ }
4302
+ boxesById.set(box.id, {
4303
+ kind: "box",
4304
+ id: box.id,
4305
+ x: position.x,
4306
+ y: position.y,
4307
+ width: COLUMN_WIDTH,
4308
+ height: shape.height,
4309
+ titleLines: shape.titleLines,
4310
+ bodyLines: shape.bodyLines,
4311
+ lane: shape.lane,
4312
+ isGhost: box.ghost
4313
+ });
4314
+ }
4315
+ return boxesById;
4316
+ }
4317
+ function unionOf(rects) {
4318
+ if (rects.length === 0) return null;
4319
+ const left = Math.min(...rects.map((rect) => rect.x));
4320
+ const top = Math.min(...rects.map((rect) => rect.y));
4321
+ const right = Math.max(...rects.map((rect) => rect.x + rect.width));
4322
+ const bottom = Math.max(...rects.map((rect) => rect.y + rect.height));
4323
+ return {
4324
+ x: left,
4325
+ y: top,
4326
+ width: right - left,
4327
+ height: bottom - top
4328
+ };
4329
+ }
4330
+ function layoutFrames(board, boxesById) {
4331
+ return elementsOfKind(board, "frame").flatMap((frame) => {
4332
+ const around = unionOf(frame.contains.flatMap((id) => boxesById.get(id) ?? []));
4333
+ if (!around) return [];
4334
+ return [{
4335
+ kind: "frame",
4336
+ id: frame.id,
4337
+ title: frame.title,
4338
+ x: around.x - FRAME_PADDING,
4339
+ y: around.y - FRAME_PADDING - FRAME_TITLE_HEIGHT,
4340
+ width: around.width + 36,
4341
+ height: around.height + 36 + FRAME_TITLE_HEIGHT
4342
+ }];
4343
+ });
4344
+ }
4345
+ function isSideways(side) {
4346
+ return side === "left" || side === "right";
4347
+ }
4348
+ function centerOf(rect) {
4349
+ return {
4350
+ x: rect.x + rect.width / 2,
4351
+ y: rect.y + rect.height / 2
4352
+ };
4353
+ }
4354
+ function hasBoxBetweenInColumn(from, to, columnIndex, input) {
4355
+ const upper = from.y < to.y ? from : to;
4356
+ const lower = upper === from ? to : from;
4357
+ return [...input.boxesById.values()].some((box) => box.id !== from.id && box.id !== to.id && input.columnIndexByBoxId.get(box.id) === columnIndex && box.y < lower.y && box.y + box.height > upper.y + upper.height);
4358
+ }
4359
+ function shapeOf(from, to, input) {
4360
+ const fromColumn = input.columnIndexByBoxId.get(from.id) ?? 0;
4361
+ const toColumn = input.columnIndexByBoxId.get(to.id) ?? 0;
4362
+ if (fromColumn === toColumn) {
4363
+ if (from.id !== to.id && !hasBoxBetweenInColumn(from, to, fromColumn, input)) {
4364
+ const isDownward = to.y > from.y;
4365
+ return {
4366
+ shape: "straight",
4367
+ exitSide: isDownward ? "bottom" : "top",
4368
+ entrySide: isDownward ? "top" : "bottom",
4369
+ sourceGap: -1,
4370
+ targetGap: -1
4371
+ };
4372
+ }
4373
+ return {
4374
+ shape: "channel",
4375
+ exitSide: "right",
4376
+ entrySide: "right",
4377
+ sourceGap: fromColumn,
4378
+ targetGap: fromColumn
4379
+ };
4380
+ }
4381
+ if (toColumn > fromColumn) return {
4382
+ shape: toColumn === fromColumn + 1 ? "channel" : "long",
4383
+ exitSide: "right",
4384
+ entrySide: "left",
4385
+ sourceGap: fromColumn,
4386
+ targetGap: toColumn - 1
4387
+ };
4388
+ return {
4389
+ shape: toColumn === fromColumn - 1 ? "channel" : "long",
4390
+ exitSide: "left",
4391
+ entrySide: "right",
4392
+ sourceGap: fromColumn - 1,
4393
+ targetGap: toColumn
4394
+ };
4395
+ }
4396
+ function planWires(input) {
4397
+ const plans = input.wires.flatMap((wire) => {
4398
+ const from = input.boxesById.get(wire.from);
4399
+ const to = input.boxesById.get(wire.to);
4400
+ if (!from || !to) return [];
4401
+ const strokeHex = wire.tone === "lane" ? from.lane?.hex ?? null : null;
4402
+ const origin = centerOf(from);
4403
+ return [{
4404
+ wire,
4405
+ from,
4406
+ to,
4407
+ strokeHex,
4408
+ styleKey: `${wire.dashed}|${wire.tone}|${strokeHex}`,
4409
+ ...shapeOf(from, to, input),
4410
+ busKey: null,
4411
+ start: origin,
4412
+ end: centerOf(to),
4413
+ crossingY: origin.y
4414
+ }];
4415
+ });
4416
+ const memberCountByBusKey = /* @__PURE__ */ new Map();
4417
+ const busKeyOf = (plan) => `${plan.to.id}|${plan.entrySide}|${plan.styleKey}`;
4418
+ for (const plan of plans) {
4419
+ if (plan.shape === "straight") continue;
4420
+ memberCountByBusKey.set(busKeyOf(plan), (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) + 1);
4421
+ }
4422
+ for (const plan of plans) if (plan.shape !== "straight" && (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) > 1) plan.busKey = busKeyOf(plan);
4423
+ return plans;
4424
+ }
4425
+ function portPositions(box, side, count) {
4426
+ const indexes = Array.from({ length: count }, (_, index) => index);
4427
+ if (isSideways(side)) {
4428
+ const x = side === "left" ? box.x : box.x + box.width;
4429
+ const spacing = Math.min(PORT_SPACING, (box.height - 16) / Math.max(count - 1, 1));
4430
+ const centeredFirstY = box.y + Math.min(box.height / 2, 40) - (count - 1) * spacing / 2;
4431
+ const firstY = Math.max(box.y + PORT_INSET, Math.min(centeredFirstY, box.y + box.height - PORT_INSET - (count - 1) * spacing));
4432
+ return indexes.map((index) => ({
4433
+ x,
4434
+ y: Math.round(firstY + index * spacing)
4435
+ }));
4436
+ }
4437
+ const y = side === "top" ? box.y : box.y + box.height;
4438
+ const firstX = box.x + box.width / 2 - (count - 1) * PORT_SPACING / 2;
4439
+ return indexes.map((index) => ({
4440
+ x: Math.round(firstX + index * PORT_SPACING),
4441
+ y
4442
+ }));
4443
+ }
4444
+ function portRequestsBySide(plans) {
4445
+ return groupedBy(plans.flatMap((plan) => [{
4446
+ box: plan.from,
4447
+ side: plan.exitSide,
4448
+ groupKey: `exit|${plan.styleKey}`,
4449
+ farPoint: centerOf(plan.to),
4450
+ assign: (point) => {
4451
+ plan.start = point;
4452
+ }
4453
+ }, {
4454
+ box: plan.to,
4455
+ side: plan.entrySide,
4456
+ groupKey: plan.busKey ? `bus|${plan.busKey}` : `entry|${plan.wire.id}`,
4457
+ farPoint: centerOf(plan.from),
4458
+ assign: (point) => {
4459
+ plan.end = point;
4460
+ }
4461
+ }]), (request) => `${request.box.id}|${request.side}`);
4462
+ }
4463
+ function defaultPortOrders(requestsBySide) {
4464
+ return new Map([...requestsBySide.entries()].map(([sideKey, sideRequests]) => {
4465
+ return [sideKey, [...groupedBy(sideRequests, (request) => request.groupKey).entries()].map(([groupKey, members]) => ({
4466
+ groupKey,
4467
+ farCoordinate: members.reduce((sum, member) => sum + (isSideways(member.side) ? member.farPoint.y : member.farPoint.x), 0) / members.length
4468
+ })).sort((left, right) => left.farCoordinate - right.farCoordinate || left.groupKey.localeCompare(right.groupKey)).map((group) => group.groupKey)];
4469
+ }));
4470
+ }
4471
+ function assignPorts(requestsBySide, groupOrderBySide) {
4472
+ for (const [sideKey, sideRequests] of requestsBySide) {
4473
+ const first = sideRequests[0];
4474
+ const groupOrder = groupOrderBySide.get(sideKey) ?? [];
4475
+ if (!first) continue;
4476
+ const positions = portPositions(first.box, first.side, groupOrder.length);
4477
+ for (const request of sideRequests) {
4478
+ const position = positions[groupOrder.indexOf(request.groupKey)];
4479
+ if (position) request.assign(position);
4480
+ }
4481
+ }
4482
+ }
4483
+ function crossedSpanOf(plan, gaps) {
4484
+ const sourceGap = gaps[plan.sourceGap] ?? {
4485
+ left: plan.start.x,
4486
+ right: plan.start.x
4487
+ };
4488
+ const targetGap = gaps[plan.targetGap] ?? {
4489
+ left: plan.end.x,
4490
+ right: plan.end.x
4491
+ };
4492
+ return {
4493
+ left: Math.min(sourceGap.left, targetGap.left),
4494
+ right: Math.max(sourceGap.right, targetGap.right)
4495
+ };
4496
+ }
4497
+ function blockersAcross(plan, span, input) {
4498
+ return [...[...input.boxesById.values()].filter((box) => box.id !== plan.from.id && box.id !== plan.to.id), ...input.obstacles].filter((rect) => rect.x < span.right && rect.x + rect.width > span.left);
4499
+ }
4500
+ function isClearRowAt(y, blockers) {
4501
+ return !blockers.some((rect) => y > rect.y - GUTTER_CLEARANCE && y < rect.y + rect.height + GUTTER_CLEARANCE);
4502
+ }
4503
+ function gutterIntervalsBetween(blockers) {
4504
+ const blocked = blockers.map((rect) => ({
4505
+ top: rect.y - GUTTER_CLEARANCE,
4506
+ bottom: rect.y + rect.height + GUTTER_CLEARANCE
4507
+ })).sort((left, right) => left.top - right.top);
4508
+ const merged = [];
4509
+ for (const interval of blocked) {
4510
+ const last = merged.at(-1);
4511
+ if (last && interval.top <= last.bottom) {
4512
+ last.bottom = Math.max(last.bottom, interval.bottom);
4513
+ continue;
4514
+ }
4515
+ merged.push({ ...interval });
4516
+ }
4517
+ return merged.slice(1).flatMap((interval, index) => {
4518
+ const above = merged[index];
4519
+ if (!above || interval.top - above.bottom < MIN_GUTTER_HEIGHT) return [];
4520
+ return [{
4521
+ top: above.bottom,
4522
+ bottom: interval.top
4523
+ }];
4524
+ });
4525
+ }
4526
+ function overlapsSpan(first, second) {
4527
+ return first.left < second.right && second.left < first.right;
4528
+ }
4529
+ function stackedTracks(items, overlaps) {
4530
+ const tracks = [];
4531
+ items.forEach((item, index) => {
4532
+ const earlierTracks = items.slice(0, index).flatMap((earlier, earlierIndex) => overlaps(item, earlier) ? [tracks[earlierIndex] ?? 0] : []);
4533
+ tracks.push(earlierTracks.length > 0 ? Math.max(...earlierTracks) + 1 : 0);
4534
+ });
4535
+ return tracks;
4536
+ }
4537
+ function assignCrossings(plans, input) {
4538
+ const claims = [];
4539
+ const topBandPlans = [];
4540
+ for (const plan of plans) {
4541
+ if (plan.shape !== "long") continue;
4542
+ const span = crossedSpanOf(plan, input.gaps);
4543
+ const blockers = blockersAcross(plan, span, input);
4544
+ const clearPortY = [plan.start.y, plan.end.y].find((y) => isClearRowAt(y, blockers));
4545
+ if (clearPortY !== void 0) {
4546
+ plan.crossingY = clearPortY;
4547
+ continue;
4548
+ }
4549
+ const middleY = (plan.start.y + plan.end.y) / 2;
4550
+ const nearestGutter = gutterIntervalsBetween(blockers).sort((left, right) => Math.abs((left.top + left.bottom) / 2 - middleY) - Math.abs((right.top + right.bottom) / 2 - middleY))[0];
4551
+ if (nearestGutter) {
4552
+ claims.push({
4553
+ plan,
4554
+ interval: nearestGutter,
4555
+ span
4556
+ });
4557
+ continue;
4558
+ }
4559
+ topBandPlans.push({
4560
+ plan,
4561
+ span
4562
+ });
4563
+ }
4564
+ const claimsByInterval = groupedBy(claims, (claim) => `${Math.round(claim.interval.top)}|${Math.round(claim.interval.bottom)}`);
4565
+ for (const intervalClaims of claimsByInterval.values()) {
4566
+ const ordered = [...intervalClaims].sort((left, right) => left.plan.start.y - right.plan.start.y || left.plan.wire.id.localeCompare(right.plan.wire.id));
4567
+ const tracks = stackedTracks(ordered, (first, second) => overlapsSpan(first.span, second.span));
4568
+ const interval = ordered[0]?.interval ?? {
4569
+ top: 0,
4570
+ bottom: 0
4571
+ };
4572
+ const height = interval.bottom - interval.top;
4573
+ const capacity = Math.max(1, Math.floor(height / MIN_GUTTER_TRACK_SPACING) - 1);
4574
+ const trackCount = Math.min(capacity, Math.max(...tracks) + 1);
4575
+ ordered.forEach((claim, index) => {
4576
+ const track = tracks[index] ?? 0;
4577
+ if (track >= capacity) {
4578
+ topBandPlans.push({
4579
+ plan: claim.plan,
4580
+ span: claim.span
4581
+ });
4582
+ return;
4583
+ }
4584
+ claim.plan.crossingY = Math.round(interval.top + height * (track + 1) / (trackCount + 1));
4585
+ });
4586
+ }
4587
+ const outermostFirst = [...topBandPlans].sort((left, right) => right.span.right - right.span.left - (left.span.right - left.span.left) || left.plan.wire.id.localeCompare(right.plan.wire.id));
4588
+ const topTracks = stackedTracks(outermostFirst, (first, second) => overlapsSpan(first.span, second.span)).map((track) => outermostFirst.length - 1 - track);
4589
+ outermostFirst.forEach(({ plan }, index) => {
4590
+ plan.crossingY = input.topBandBottom - (topTracks[index] ?? 0) * TOP_TRACK_SPACING;
4591
+ });
4592
+ return topBandPlans.length > 0 ? Math.max(...topTracks) + 1 : 0;
4593
+ }
4594
+ function attachmentSideFor(gap, columnIndex) {
4595
+ return columnIndex <= gap ? "left" : "right";
4596
+ }
4597
+ function newRun(key, gap) {
4598
+ return {
4599
+ key,
4600
+ gap,
4601
+ top: Infinity,
4602
+ bottom: -Infinity,
4603
+ leftYs: [],
4604
+ rightYs: [],
4605
+ track: -1,
4606
+ x: 0
4607
+ };
4608
+ }
4609
+ function attach(run, side, y) {
4610
+ (side === "left" ? run.leftYs : run.rightYs).push(y);
4611
+ run.top = Math.min(run.top, y);
4612
+ run.bottom = Math.max(run.bottom, y);
4613
+ }
4614
+ function targetRunKey(plan) {
4615
+ return plan.busKey ? `bus|${plan.busKey}` : `wire|${plan.wire.id}|target`;
4616
+ }
4617
+ function buildRuns(plans, input) {
4618
+ const runsByKey = /* @__PURE__ */ new Map();
4619
+ const runFor = (key, gap) => {
4620
+ const existing = runsByKey.get(key);
4621
+ if (existing) return existing;
4622
+ const created = newRun(key, gap);
4623
+ runsByKey.set(key, created);
4624
+ return created;
4625
+ };
4626
+ const enteredRunKeys = /* @__PURE__ */ new Set();
4627
+ for (const plan of plans) {
4628
+ if (plan.shape === "straight") continue;
4629
+ const fromColumn = input.columnIndexByBoxId.get(plan.from.id) ?? 0;
4630
+ const toColumn = input.columnIndexByBoxId.get(plan.to.id) ?? 0;
4631
+ const isForward = plan.exitSide === "right" && plan.entrySide === "left";
4632
+ const targetRun = runFor(targetRunKey(plan), plan.targetGap);
4633
+ if (plan.shape === "channel") attach(targetRun, attachmentSideFor(plan.targetGap, fromColumn), plan.start.y);
4634
+ if (plan.shape === "long") {
4635
+ const sourceRun = runFor(`wire|${plan.wire.id}|source`, plan.sourceGap);
4636
+ attach(sourceRun, attachmentSideFor(plan.sourceGap, fromColumn), plan.start.y);
4637
+ attach(sourceRun, isForward ? "right" : "left", plan.crossingY);
4638
+ attach(targetRun, isForward ? "left" : "right", plan.crossingY);
4639
+ }
4640
+ if (enteredRunKeys.has(targetRun.key)) continue;
4641
+ enteredRunKeys.add(targetRun.key);
4642
+ attach(targetRun, attachmentSideFor(plan.targetGap, toColumn), plan.end.y);
4643
+ }
4644
+ return runsByKey;
4645
+ }
4646
+ function countInside(ys, run) {
4647
+ return ys.filter((y) => y > run.top && y < run.bottom).length;
4648
+ }
4649
+ function crossingsWhenLeftOf(leftRun, rightRun) {
4650
+ return countInside(rightRun.leftYs, leftRun) + countInside(leftRun.rightYs, rightRun);
4651
+ }
4652
+ function placeTracks(runsByKey, gaps) {
4653
+ const tracksByGap = gaps.map(() => 0);
4654
+ const runsByGap = groupedBy([...runsByKey.values()].filter((run) => run.bottom > run.top), (run) => run.gap);
4655
+ for (const [gapIndex, gapRuns] of runsByGap) {
4656
+ const ordered = [...gapRuns].sort((first, second) => crossingsWhenLeftOf(first, second) - crossingsWhenLeftOf(second, first) || first.top - second.top || first.key.localeCompare(second.key));
4657
+ const tracks = stackedTracks(ordered, (first, second) => first.top < second.bottom + RUN_CLEARANCE && second.top < first.bottom + RUN_CLEARANCE);
4658
+ const trackCount = Math.max(...tracks) + 1;
4659
+ tracksByGap[gapIndex] = trackCount;
4660
+ const gap = gaps[gapIndex] ?? {
4661
+ left: 0,
4662
+ right: 0
4663
+ };
4664
+ ordered.forEach((run, index) => {
4665
+ run.track = tracks[index] ?? 0;
4666
+ run.x = Math.round(gap.left + (gap.right - gap.left) * (run.track + 1) / (trackCount + 1));
4667
+ });
4668
+ }
4669
+ for (const run of runsByKey.values()) {
4670
+ if (run.track >= 0) continue;
4671
+ const gap = gaps[run.gap] ?? {
4672
+ left: 0,
4673
+ right: 0
4674
+ };
4675
+ run.x = Math.round((gap.left + gap.right) / 2);
4676
+ }
4677
+ return tracksByGap;
4678
+ }
4679
+ function withoutBends(points) {
4680
+ const distinct = points.filter((point, index) => {
4681
+ const previous = points[index - 1];
4682
+ return !previous || previous.x !== point.x || previous.y !== point.y;
4683
+ });
4684
+ return distinct.filter((point, index) => {
4685
+ const previous = distinct[index - 1];
4686
+ const next = distinct[index + 1];
4687
+ if (!previous || !next) return true;
4688
+ return !(previous.x === point.x && point.x === next.x || previous.y === point.y && point.y === next.y);
4689
+ });
4690
+ }
4691
+ function segmentsOf(points) {
4692
+ return points.slice(1).flatMap((point, index) => {
4693
+ const previous = points[index];
4694
+ return previous ? [{
4695
+ from: previous,
4696
+ to: point
4697
+ }] : [];
4698
+ });
4699
+ }
4700
+ function straightPoints(plan) {
4701
+ if (plan.start.x === plan.end.x) return [plan.start, plan.end];
4702
+ const middleY = Math.round((plan.start.y + plan.end.y) / 2);
4703
+ return [
4704
+ plan.start,
4705
+ {
4706
+ x: plan.start.x,
4707
+ y: middleY
4708
+ },
4709
+ {
4710
+ x: plan.end.x,
4711
+ y: middleY
4712
+ },
4713
+ plan.end
4714
+ ];
4715
+ }
4716
+ function routedPoints(plan, runsByKey) {
4717
+ if (plan.shape === "straight") return straightPoints(plan);
4718
+ const targetX = runsByKey.get(targetRunKey(plan))?.x ?? plan.end.x;
4719
+ const arrivalY = plan.shape === "long" ? plan.crossingY : plan.start.y;
4720
+ const sourceX = runsByKey.get(`wire|${plan.wire.id}|source`)?.x ?? targetX;
4721
+ const approach = plan.shape === "long" ? [
4722
+ plan.start,
4723
+ {
4724
+ x: sourceX,
4725
+ y: plan.start.y
4726
+ },
4727
+ {
4728
+ x: sourceX,
4729
+ y: arrivalY
4730
+ },
4731
+ {
4732
+ x: targetX,
4733
+ y: arrivalY
4734
+ }
4735
+ ] : [plan.start, {
4736
+ x: targetX,
4737
+ y: arrivalY
4738
+ }];
4739
+ if (plan.busKey) return approach;
4740
+ return [
4741
+ ...approach,
4742
+ {
4743
+ x: targetX,
4744
+ y: plan.end.y
4745
+ },
4746
+ plan.end
4747
+ ];
4748
+ }
4749
+ function pathOf(points) {
4750
+ return points.map((point, index) => `${index === 0 ? "M" : "L"} ${point.x} ${point.y}`).join(" ");
4751
+ }
4752
+ function drawWires(plans, runsByKey) {
4753
+ const leadIdByBusKey = /* @__PURE__ */ new Map();
4754
+ for (const plan of [...plans].sort((left, right) => left.wire.id.localeCompare(right.wire.id))) if (plan.busKey && !leadIdByBusKey.has(plan.busKey)) leadIdByBusKey.set(plan.busKey, plan.wire.id);
4755
+ return plans.map((plan) => {
4756
+ const points = withoutBends(routedPoints(plan, runsByKey));
4757
+ const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
4758
+ const isLead = plan.busKey !== null && leadIdByBusKey.get(plan.busKey) === plan.wire.id;
4759
+ const trunk = trunkRun && isLead ? [{
4760
+ from: {
4761
+ x: trunkRun.x,
4762
+ y: trunkRun.top
4763
+ },
4764
+ to: {
4765
+ x: trunkRun.x,
4766
+ y: trunkRun.bottom
4767
+ }
4768
+ }, {
4769
+ from: {
4770
+ x: trunkRun.x,
4771
+ y: plan.end.y
4772
+ },
4773
+ to: plan.end
4774
+ }].filter((segment) => segment.from.x !== segment.to.x || segment.from.y !== segment.to.y) : [];
4775
+ return {
4776
+ plan,
4777
+ points,
4778
+ trunk,
4779
+ segments: [...segmentsOf(points), ...trunk]
4780
+ };
4781
+ });
4782
+ }
4783
+ function isHorizontal(segment) {
4784
+ return segment.from.y === segment.to.y;
4785
+ }
4786
+ function segmentHitsRect(segment, rect) {
4787
+ const right = rect.x + rect.width;
4788
+ const bottom = rect.y + rect.height;
4789
+ if (isHorizontal(segment)) {
4790
+ const y = segment.from.y;
4791
+ return rect.y < y && y < bottom && Math.min(segment.from.x, segment.to.x) < right && Math.max(segment.from.x, segment.to.x) > rect.x;
4792
+ }
4793
+ const x = segment.from.x;
4794
+ return rect.x < x && x < right && Math.min(segment.from.y, segment.to.y) < bottom && Math.max(segment.from.y, segment.to.y) > rect.y;
4795
+ }
4796
+ function rectsOverlap(first, second) {
4797
+ return first.x < second.x + second.width && second.x < first.x + first.width && first.y < second.y + second.height && second.y < first.y + first.height;
4798
+ }
4799
+ function labelWidthOf(label) {
4800
+ return Math.ceil(label.length * LABEL_CHAR_WIDTH);
4801
+ }
4802
+ function labelBoundsAt(baseline, width) {
4803
+ return {
4804
+ x: baseline.x - width / 2,
4805
+ y: baseline.y - LABEL_ASCENT,
4806
+ width,
4807
+ height: 13
4808
+ };
4809
+ }
4810
+ function segmentLength(segment) {
4811
+ return Math.abs(segment.from.x - segment.to.x) + Math.abs(segment.from.y - segment.to.y);
4812
+ }
4813
+ function labelCandidates(segments, width) {
4814
+ const byLength = [...segments].sort((left, right) => segmentLength(right) - segmentLength(left));
4815
+ return [...segments.slice(0, 1), ...byLength].flatMap((segment) => [...LABEL_SLIDE_FRACTIONS.flatMap((fraction) => {
4816
+ const x = segment.from.x + (segment.to.x - segment.from.x) * fraction;
4817
+ const y = segment.from.y + (segment.to.y - segment.from.y) * fraction;
4818
+ if (isHorizontal(segment)) return [{
4819
+ x,
4820
+ y: y - LABEL_GAP
4821
+ }, {
4822
+ x,
4823
+ y: y + LABEL_GAP + LABEL_ASCENT
4824
+ }];
4825
+ return [{
4826
+ x: x + LABEL_GAP + width / 2,
4827
+ y: y + LABEL_ASCENT / 2
4828
+ }, {
4829
+ x: x - LABEL_GAP - width / 2,
4830
+ y: y + LABEL_ASCENT / 2
4831
+ }];
4832
+ }), ...flushLabelCandidates(segment, width)]);
4833
+ }
4834
+ function flushLabelCandidates(segment, width) {
4835
+ if (!isHorizontal(segment)) return [];
4836
+ const y = segment.from.y;
4837
+ return [Math.min(segment.from.x, segment.to.x) + LABEL_GAP + width / 2, Math.max(segment.from.x, segment.to.x) - LABEL_GAP - width / 2].flatMap((x) => [{
4838
+ x,
4839
+ y: y - LABEL_GAP
4840
+ }, {
4841
+ x,
4842
+ y: y + LABEL_GAP + LABEL_ASCENT
4843
+ }]);
4844
+ }
4845
+ function inflated(rect, by) {
4846
+ return {
4847
+ x: rect.x - by,
4848
+ y: rect.y - by,
4849
+ width: rect.width + by * 2,
4850
+ height: rect.height + by * 2
4851
+ };
4852
+ }
4853
+ function placeLabels(drawn, input, warnings) {
4854
+ const placedById = /* @__PURE__ */ new Map();
4855
+ const allSegments = drawn.flatMap((wire) => wire.segments);
4856
+ const solids = [...input.boxesById.values(), ...input.obstacles];
4857
+ for (const wire of drawn) {
4858
+ const label = wire.plan.wire.label;
4859
+ if (!label) continue;
4860
+ const width = labelWidthOf(label);
4861
+ const candidates = labelCandidates(wire.segments, width);
4862
+ const isClear = (baseline) => {
4863
+ const bounds = labelBoundsAt(baseline, width);
4864
+ if (bounds.y < input.contentTop) return false;
4865
+ const padded = inflated(bounds, LABEL_CLEARANCE);
4866
+ if (allSegments.some((segment) => segmentHitsRect(segment, padded))) return false;
4867
+ if (solids.some((rect) => rectsOverlap(bounds, rect))) return false;
4868
+ return ![...placedById.values()].some((placed) => rectsOverlap(bounds, placed.bounds));
4869
+ };
4870
+ const clearSpot = candidates.find(isClear);
4871
+ const at = clearSpot ?? candidates[0] ?? centerOf(wire.plan.from);
4872
+ if (!clearSpot) warnings.push(`wire ${wire.plan.wire.id} label "${label}" has no clear spot`);
4873
+ placedById.set(wire.plan.wire.id, {
4874
+ at: {
4875
+ x: Math.round(at.x),
4876
+ y: Math.round(at.y)
4877
+ },
4878
+ bounds: labelBoundsAt(at, width)
4879
+ });
4880
+ }
4881
+ return placedById;
4882
+ }
4883
+ function isStrictlyBetween(value, first, second) {
4884
+ return value > Math.min(first, second) + .5 && value < Math.max(first, second) - .5;
4885
+ }
4886
+ function segmentsCross(first, second) {
4887
+ if (isHorizontal(first) === isHorizontal(second)) return false;
4888
+ const horizontal = isHorizontal(first) ? first : second;
4889
+ const vertical = horizontal === first ? second : first;
4890
+ return isStrictlyBetween(vertical.from.x, horizontal.from.x, horizontal.to.x) && isStrictlyBetween(horizontal.from.y, vertical.from.y, vertical.to.y);
4891
+ }
4892
+ function findCrossings(drawn) {
4893
+ return drawn.flatMap((first, index) => drawn.slice(index + 1).flatMap((second) => {
4894
+ if (first.plan.busKey !== null && first.plan.busKey === second.plan.busKey) return [];
4895
+ return first.segments.some((firstSegment) => second.segments.some((secondSegment) => segmentsCross(firstSegment, secondSegment))) ? [`wire ${first.plan.wire.id} crosses wire ${second.plan.wire.id}`] : [];
4896
+ }));
4897
+ }
4898
+ function findBoxCrossings(drawn, input) {
4899
+ const boxes = [...input.boxesById.values()];
4900
+ return drawn.flatMap((wire) => boxes.flatMap((box) => {
4901
+ if (box.id === wire.plan.from.id || box.id === wire.plan.to.id) return [];
4902
+ const inset = inflated(box, -2);
4903
+ return wire.segments.some((segment) => segmentHitsRect(segment, inset)) ? [`wire ${wire.plan.wire.id} runs through box ${box.id}`] : [];
4904
+ }));
4905
+ }
4906
+ function cappedWarnings(warnings) {
4907
+ if (warnings.length <= WHITEBOARD_LIMITS.layoutWarnings) return [...warnings];
4908
+ const shown = warnings.slice(0, WHITEBOARD_LIMITS.layoutWarnings - 1);
4909
+ return [...shown, `and ${warnings.length - shown.length} more`];
4910
+ }
4911
+ function labelWidthsByGap(plans, gaps) {
4912
+ const widths = gaps.map(() => 0);
4913
+ for (const plan of plans) {
4914
+ if (!plan.wire.label || plan.shape !== "channel") continue;
4915
+ widths[plan.targetGap] = Math.max(widths[plan.targetGap] ?? 0, labelWidthOf(plan.wire.label));
4916
+ }
4917
+ return widths;
4918
+ }
4919
+ function extentOf(drawn, labelRects) {
4920
+ return unionOf([...drawn.flatMap((wire) => wire.segments.flatMap((segment) => [segment.from, segment.to])).map((point) => ({
4921
+ x: point.x,
4922
+ y: point.y,
4923
+ width: 0,
4924
+ height: 0
4925
+ })), ...labelRects]);
4926
+ }
4927
+ function routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide) {
4928
+ assignPorts(requestsBySide, groupOrderBySide);
4929
+ const topTrackCount = assignCrossings(plans, input);
4930
+ const runsByKey = buildRuns(plans, input);
4931
+ const tracksByGap = placeTracks(runsByKey, input.gaps);
4932
+ const drawn = drawWires(plans, runsByKey);
4933
+ return {
4934
+ runsByKey,
4935
+ tracksByGap,
4936
+ topTrackCount,
4937
+ drawn,
4938
+ crossingCost: findBoxCrossings(drawn, input).length * BOX_CROSSING_COST + findCrossings(drawn).length
4939
+ };
4940
+ }
4941
+ function swapNeighbors(order, index) {
4942
+ const left = order[index];
4943
+ const right = order[index + 1];
4944
+ if (left === void 0 || right === void 0) return;
4945
+ order[index] = right;
4946
+ order[index + 1] = left;
4947
+ }
4948
+ function routeWithFewestCrossings(plans, input) {
4949
+ const requestsBySide = portRequestsBySide(plans);
4950
+ const groupOrderBySide = defaultPortOrders(requestsBySide);
4951
+ let bestCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
4952
+ const canSearchPortOrders = plans.length <= MAX_WIRES_FOR_PORT_SEARCH;
4953
+ for (const groupOrder of groupOrderBySide.values()) for (let index = 0; canSearchPortOrders && bestCost > 0 && index + 1 < groupOrder.length; index += 1) {
4954
+ swapNeighbors(groupOrder, index);
4955
+ const trialCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
4956
+ if (trialCost < bestCost) {
4957
+ bestCost = trialCost;
4958
+ continue;
4959
+ }
4960
+ swapNeighbors(groupOrder, index);
4961
+ }
4962
+ return routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide);
4963
+ }
4964
+ function routeWires(input) {
4965
+ const plans = planWires(input);
4966
+ const { runsByKey, tracksByGap, topTrackCount, drawn } = routeWithFewestCrossings(plans, input);
4967
+ const labelWarnings = [];
4968
+ const labelById = placeLabels(drawn, input, labelWarnings);
4969
+ const wires = drawn.map(({ plan, points, trunk }) => {
4970
+ const lastPoint = points.at(-1) ?? plan.end;
4971
+ const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
4972
+ const isTrunkLead = trunk.length > 0;
4973
+ const isTJoin = trunkRun !== void 0 && lastPoint.y > trunkRun.top && lastPoint.y < trunkRun.bottom;
4974
+ return {
4975
+ kind: "wire",
4976
+ id: plan.wire.id,
4977
+ path: [pathOf(points), ...trunk.map((segment) => pathOf([segment.from, segment.to]))].join(" "),
4978
+ start: plan.start,
4979
+ end: isTrunkLead || !plan.busKey ? plan.end : lastPoint,
4980
+ label: plan.wire.label,
4981
+ labelAt: labelById.get(plan.wire.id)?.at ?? centerOf(plan.from),
4982
+ isDashed: plan.wire.dashed,
4983
+ strokeHex: plan.strokeHex,
4984
+ tone: plan.wire.tone,
4985
+ hasArrowhead: plan.busKey === null || isTrunkLead,
4986
+ joinAt: isTJoin ? lastPoint : null
4987
+ };
4988
+ });
4989
+ const labelRects = [...labelById.values()].map((placed) => placed.bounds);
4990
+ return {
4991
+ wires,
4992
+ tracksByGap,
4993
+ topTrackCount,
4994
+ labelWidthByGap: labelWidthsByGap(plans, input.gaps),
4995
+ warnings: cappedWarnings([
4996
+ ...findBoxCrossings(drawn, input),
4997
+ ...findCrossings(drawn),
4998
+ ...labelWarnings
4999
+ ]),
5000
+ extent: extentOf(drawn, labelRects)
5001
+ };
5002
+ }
5003
+ function noteByline(note) {
5004
+ if (note.resolvedBy) return `resolved by ${note.resolvedBy}`;
5005
+ return note.author ? `from ${note.author}` : "";
5006
+ }
5007
+ function layoutNotes(board, boxesById) {
5008
+ const nextYByBoxId = /* @__PURE__ */ new Map();
5009
+ return elementsOfKind(board, "note").flatMap((note) => {
5010
+ const target = boxesById.get(note.on);
5011
+ if (!target) return [];
5012
+ const { lines, height } = noteShape(note);
5013
+ const y = nextYByBoxId.get(note.on) ?? target.y - NOTE_RISE;
5014
+ nextYByBoxId.set(note.on, y + height + NOTE_GAP);
5015
+ return [{
5016
+ kind: "note",
5017
+ id: note.id,
5018
+ x: target.x + target.width - NOTE_OVERLAP,
5019
+ y,
5020
+ width: NOTE_WIDTH,
5021
+ height,
5022
+ lines,
5023
+ byline: noteByline(note),
5024
+ isResolved: note.resolvedBy !== null
5025
+ }];
5026
+ });
5027
+ }
5028
+ function boundsOf(elements, wireExtent, columnLeftEdges, boxesTop) {
5029
+ const rects = elements.flatMap((element) => element.kind === "wire" ? [] : [element]);
5030
+ const columnsRight = (columnLeftEdges.at(-1) ?? MARGIN) + COLUMN_WIDTH;
5031
+ const around = unionOf([
5032
+ ...rects,
5033
+ ...wireExtent ? [wireExtent] : [],
5034
+ {
5035
+ x: 0,
5036
+ y: 0,
5037
+ width: columnsRight,
5038
+ height: boxesTop
5039
+ }
5040
+ ]);
5041
+ if (!around) return {
5042
+ x: 0,
5043
+ y: 0,
5044
+ width: columnsRight + MARGIN,
5045
+ height: 80
5046
+ };
5047
+ return {
5048
+ x: Math.min(0, around.x - MARGIN),
5049
+ y: Math.min(0, around.y - MARGIN),
5050
+ width: around.width + 80,
5051
+ height: around.height + 80
5052
+ };
5053
+ }
5054
+ function placeAndRoute(board, placement) {
5055
+ const columnLeftEdges = columnLeftEdgesOf(board, placement.gapWidths);
5056
+ const boxesById = layoutBoxes(board, columnLeftEdges, placement.boxesTop, placement.stackHeightByBoxId);
5057
+ const frames = layoutFrames(board, boxesById);
5058
+ const notes = layoutNotes(board, boxesById);
5059
+ const columnIndexByBoxId = new Map(elementsOfKind(board, "box").flatMap((box) => {
5060
+ const laidOut = boxesById.get(box.id);
5061
+ return laidOut ? [[box.id, columnIndexOf(board, box, laidOut, columnLeftEdges)]] : [];
5062
+ }));
5063
+ return {
5064
+ columnLeftEdges,
5065
+ boxesById,
5066
+ frames,
5067
+ notes,
5068
+ routing: routeWires({
5069
+ wires: elementsOfKind(board, "wire"),
5070
+ boxesById,
5071
+ columnIndexByBoxId,
5072
+ obstacles: [...notes, ...frames.map((frame) => ({
5073
+ x: frame.x,
5074
+ y: frame.y,
5075
+ width: frame.width,
5076
+ height: FRAME_TITLE_HEIGHT
5077
+ }))],
5078
+ gaps: channelGapsOf(columnLeftEdges, placement.gapWidths, placement.reserves),
5079
+ topBandBottom: placement.boxesTop - TOP_BAND_PAD,
5080
+ contentTop: placement.contentTop
5081
+ })
5082
+ };
5083
+ }
5084
+ function topBandHeight(topTrackCount) {
5085
+ return topTrackCount > 0 ? topTrackCount * TOP_TRACK_SPACING + TOP_BAND_PAD : 0;
5086
+ }
5087
+ function layoutBoard(board) {
5088
+ const stackHeightByBoxId = noteStackHeightByBoxId(board);
5089
+ const titleLinesByColumn = columnTitleLines(board);
5090
+ const extraHeaderHeight = headerExtraHeight(titleLinesByColumn);
5091
+ const ruleY = 66 + extraHeaderHeight;
5092
+ const headerBoxesTop = 84 + extraHeaderHeight;
5093
+ const reserves = gapReservesOf(board, stackHeightByBoxId);
5094
+ const draft = placeAndRoute(board, {
5095
+ gapWidths: gapWidthsOf(reserves, [], []),
5096
+ reserves,
5097
+ boxesTop: headerBoxesTop,
5098
+ contentTop: ruleY,
5099
+ stackHeightByBoxId
5100
+ });
5101
+ const gapWidths = gapWidthsOf(reserves, draft.routing.tracksByGap, draft.routing.labelWidthByGap);
5102
+ const boxesTop = headerBoxesTop + topBandHeight(draft.routing.topTrackCount);
5103
+ const placed = placeAndRoute(board, {
5104
+ gapWidths,
5105
+ reserves,
5106
+ boxesTop,
5107
+ contentTop: ruleY,
5108
+ stackHeightByBoxId
5109
+ });
5110
+ const { columnLeftEdges } = placed;
5111
+ const elements = [
5112
+ ...placed.frames,
5113
+ ...placed.routing.wires,
5114
+ ...placed.boxesById.values(),
5115
+ ...placed.notes
5116
+ ];
5117
+ const contentBounds = boundsOf(elements, placed.routing.extent, columnLeftEdges, boxesTop);
5118
+ const legendTop = contentBounds.y + contentBounds.height;
5119
+ const legend = board.lanes.map((lane, index) => ({
5120
+ label: lane.label || lane.id,
5121
+ hex: LANE_HEX_BY_COLOR[lane.color],
5122
+ x: MARGIN,
5123
+ y: legendTop + index * LEGEND_ROW_HEIGHT
5124
+ }));
5125
+ const captionTop = legendTop + legend.length * LEGEND_ROW_HEIGHT + (legend.length > 0 ? 12 : 0);
5126
+ const caption = board.caption ? {
5127
+ text: board.caption,
5128
+ x: MARGIN,
5129
+ y: captionTop
5130
+ } : null;
5131
+ const extraHeight = legend.length * LEGEND_ROW_HEIGHT + (caption ? 30 : 0) + (legend.length > 0 ? 12 : 0);
5132
+ return {
5133
+ columns: board.columns.map((column, index) => ({
5134
+ id: column.id,
5135
+ titleLines: titleLinesByColumn[index] ?? [],
5136
+ titleBaselineY: 56,
5137
+ ruleY,
5138
+ x: columnLeftEdges[index] ?? MARGIN,
5139
+ width: COLUMN_WIDTH
5140
+ })),
5141
+ elements,
5142
+ legend,
5143
+ caption,
5144
+ bounds: {
5145
+ ...contentBounds,
5146
+ height: contentBounds.height + extraHeight
5147
+ },
5148
+ warnings: placed.routing.warnings
5149
+ };
5150
+ }
5151
+ //#endregion
4087
5152
  //#region server/core/whiteboard-store-core.ts
4088
5153
  function lowestCursor(record) {
4089
5154
  const cursors = Object.values(record.cursorBySessionId);
@@ -4418,6 +5483,7 @@ function createWhiteboardWiring({ boardsRoot, broadcastControl = () => {}, now =
4418
5483
  updatedAt: next.board.updatedAt,
4419
5484
  ops: [...ops]
4420
5485
  };
5486
+ const { warnings } = layoutBoard(next.board);
4421
5487
  return {
4422
5488
  ok: true,
4423
5489
  record: next,
@@ -4425,7 +5491,8 @@ function createWhiteboardWiring({ boardsRoot, broadcastControl = () => {}, now =
4425
5491
  status: 200,
4426
5492
  body: {
4427
5493
  ok: true,
4428
- version: next.board.version
5494
+ version: next.board.version,
5495
+ ...warnings.length > 0 ? { warnings } : {}
4429
5496
  }
4430
5497
  },
4431
5498
  patch