glimmervoid 0.48.3-next.340 → 0.48.3-next.342

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-vXFD9RJc.js} +1119 -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-DYqkOgqi.js} +1 -1
  28. package/dist/client/assets/benchmark-panel-DYqkOgqi.js.br +0 -0
  29. package/dist/client/assets/boards-view-B0DXAMm6.js +1 -0
  30. package/dist/client/assets/boards-view-B0DXAMm6.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-BkPrmEye.js} +1 -1
  34. package/dist/client/assets/community-panel-BkPrmEye.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--tq0YwrF.js} +1 -1
  38. package/dist/client/assets/dialogs--tq0YwrF.js.br +0 -0
  39. package/dist/client/assets/{doc-editor-ui-kU3-tIee.js → doc-editor-ui-BxhsD5YO.js} +1 -1
  40. package/dist/client/assets/doc-editor-ui-BxhsD5YO.js.br +0 -0
  41. package/dist/client/assets/{feature-hint-BRnqKQxw.js → feature-hint-BY0wrtdV.js} +1 -1
  42. package/dist/client/assets/feature-hint-BY0wrtdV.js.br +0 -0
  43. package/dist/client/assets/{first-run-checklist-BT95ccnI.js → first-run-checklist-CdLWggHA.js} +1 -1
  44. package/dist/client/assets/first-run-checklist-CdLWggHA.js.br +0 -0
  45. package/dist/client/assets/{hooks-panel-DtjlYpR7.js → hooks-panel-Bu7FKT_v.js} +1 -1
  46. package/dist/client/assets/hooks-panel-Bu7FKT_v.js.br +0 -0
  47. package/dist/client/assets/{index-DAhsDR4e.js → index-BmRHGHxg.js} +5 -5
  48. package/dist/client/assets/index-BmRHGHxg.js.br +0 -0
  49. package/dist/client/assets/{issues-panel-Dsy9fS6c.js → issues-panel-25AuiVli.js} +1 -1
  50. package/dist/client/assets/issues-panel-25AuiVli.js.br +0 -0
  51. package/dist/client/assets/{my-prs-panel-BmMGPNHO.js → my-prs-panel-Blaw49ML.js} +1 -1
  52. package/dist/client/assets/my-prs-panel-Blaw49ML.js.br +0 -0
  53. package/dist/client/assets/{nyan-cat-DwI-ROow.js → nyan-cat-80-_i1LK.js} +1 -1
  54. package/dist/client/assets/nyan-cat-80-_i1LK.js.br +0 -0
  55. package/dist/client/assets/{phone-shell-DtDlh-i4.js → phone-shell-DAK6zFs0.js} +1 -1
  56. package/dist/client/assets/phone-shell-DAK6zFs0.js.br +0 -0
  57. package/dist/client/assets/{plan-face-D4FztfLW.js → plan-face-CpxH8xlE.js} +1 -1
  58. package/dist/client/assets/plan-face-CpxH8xlE.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-BptdEPVp.js} +1 -1
  62. package/dist/client/assets/pr-queue-columns-BptdEPVp.js.br +0 -0
  63. package/dist/client/assets/{radar-panel-BnSOSvlP.js → radar-panel-CJagiEog.js} +1 -1
  64. package/dist/client/assets/radar-panel-CJagiEog.js.br +0 -0
  65. package/dist/client/assets/{repo-roots-adder-D7AEXdQg.js → repo-roots-adder-D7KvH4xV.js} +1 -1
  66. package/dist/client/assets/repo-roots-adder-D7KvH4xV.js.br +0 -0
  67. package/dist/client/assets/{resume-dialog-DsTCw_ZN.js → resume-dialog-p-5NQ3C-.js} +1 -1
  68. package/dist/client/assets/resume-dialog-p-5NQ3C-.js.br +0 -0
  69. package/dist/client/assets/{review-queue-panel-CzxQHXwJ.js → review-queue-panel-CHKbLp0B.js} +1 -1
  70. package/dist/client/assets/review-queue-panel-CHKbLp0B.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-CY0sxq05.js} +2 -2
  73. package/dist/client/assets/settings-panel-CY0sxq05.js.br +0 -0
  74. package/dist/client/assets/{shown-lightbox-Djgk_k2v.js → shown-lightbox-B3RMVZLg.js} +1 -1
  75. package/dist/client/assets/shown-lightbox-B3RMVZLg.js.br +0 -0
  76. package/dist/client/assets/{team-review-panel-CwALeLVh.js → team-review-panel-J2D83_qU.js} +1 -1
  77. package/dist/client/assets/team-review-panel-J2D83_qU.js.br +0 -0
  78. package/dist/client/assets/{trace-panel-BYJPOEv9.js → trace-panel-DdNChzUe.js} +1 -1
  79. package/dist/client/assets/trace-panel-DdNChzUe.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-B2MjX96A.js} +1 -1
  83. package/dist/client/assets/usage-panel-B2MjX96A.js.br +0 -0
  84. package/dist/client/assets/{your-day-tip-D8d8ZtJ8.js → your-day-tip-Dh1yRijf.js} +1 -1
  85. package/dist/client/assets/your-day-tip-Dh1yRijf.js.br +4 -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,1111 @@ 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 MAX_ROOM_ATTEMPTS = 4;
4124
+ var LABEL_SLIDE_FRACTIONS = [
4125
+ .5,
4126
+ .35,
4127
+ .65,
4128
+ .2,
4129
+ .8
4130
+ ];
4131
+ var LANE_HEX_BY_COLOR = Object.freeze({
4132
+ blue: "#60a5fa",
4133
+ green: "#4ade80",
4134
+ orange: "#fb923c",
4135
+ pink: "#f472b6",
4136
+ cyan: "#22d3ee",
4137
+ yellow: "#facc15"
4138
+ });
4139
+ function wrapText(text, charsPerLine) {
4140
+ const words = text.split(/\s+/).filter(Boolean);
4141
+ const lines = [];
4142
+ let current = "";
4143
+ for (const word of words) {
4144
+ const pieces = word.match(new RegExp(`.{1,${charsPerLine}}`, "g")) ?? [word];
4145
+ for (const piece of pieces) {
4146
+ const candidate = current ? `${current} ${piece}` : piece;
4147
+ if (candidate.length <= charsPerLine) {
4148
+ current = candidate;
4149
+ continue;
4150
+ }
4151
+ lines.push(current);
4152
+ current = piece;
4153
+ }
4154
+ }
4155
+ if (current) lines.push(current);
4156
+ return lines.length > 0 ? lines : [""];
4157
+ }
4158
+ function laneOf(board, box) {
4159
+ const lane = board.lanes.find((candidate) => candidate.id === box.lane);
4160
+ if (!lane) return null;
4161
+ return {
4162
+ label: lane.label || lane.id,
4163
+ hex: LANE_HEX_BY_COLOR[lane.color]
4164
+ };
4165
+ }
4166
+ function boxShape(board, box) {
4167
+ const titleLines = wrapText(box.title, TITLE_CHARS_PER_LINE);
4168
+ const bodyLines = box.lines.flatMap((line) => wrapText(line.text, BODY_CHARS_PER_LINE - (line.muted ? 2 : 0)).map((text) => ({
4169
+ text,
4170
+ muted: line.muted
4171
+ })));
4172
+ const lane = laneOf(board, box);
4173
+ return {
4174
+ titleLines,
4175
+ bodyLines,
4176
+ lane,
4177
+ height: 24 + titleLines.length * TITLE_LINE_HEIGHT + bodyLines.length * BODY_LINE_HEIGHT + (lane ? 26 : 0)
4178
+ };
4179
+ }
4180
+ function elementsOfKind(board, kind) {
4181
+ return Object.values(board.elements).filter((element) => element.kind === kind);
4182
+ }
4183
+ function noteShape(note) {
4184
+ const lines = wrapText(note.text, NOTE_CHARS_PER_LINE);
4185
+ return {
4186
+ lines,
4187
+ height: 24 + (lines.length + 1) * NOTE_LINE_HEIGHT
4188
+ };
4189
+ }
4190
+ function noteStackHeightByBoxId(board) {
4191
+ const stackHeightByBoxId = /* @__PURE__ */ new Map();
4192
+ for (const note of elementsOfKind(board, "note")) {
4193
+ const stackedSoFar = stackHeightByBoxId.get(note.on);
4194
+ const noteHeight = noteShape(note).height;
4195
+ stackHeightByBoxId.set(note.on, stackedSoFar === void 0 ? noteHeight : stackedSoFar + NOTE_GAP + noteHeight);
4196
+ }
4197
+ return stackHeightByBoxId;
4198
+ }
4199
+ function columnTitleLines(board) {
4200
+ return board.columns.map((column) => column.title ? wrapText(column.title, COLUMN_TITLE_CHARS_PER_LINE) : []);
4201
+ }
4202
+ function headerExtraHeight(titleLinesByColumn) {
4203
+ return (Math.max(1, ...titleLinesByColumn.map((lines) => lines.length)) - 1) * COLUMN_TITLE_LINE_HEIGHT;
4204
+ }
4205
+ function groupedBy(items, keyOf) {
4206
+ const groups = /* @__PURE__ */ new Map();
4207
+ for (const item of items) {
4208
+ const key = keyOf(item);
4209
+ const group = groups.get(key);
4210
+ if (group) {
4211
+ group.push(item);
4212
+ continue;
4213
+ }
4214
+ groups.set(key, [item]);
4215
+ }
4216
+ return groups;
4217
+ }
4218
+ function gapReservesOf(board, stackHeightByBoxId) {
4219
+ const flowBoxes = elementsOfKind(board, "box").filter((box) => !box.at);
4220
+ const notedColumnIds = new Set(flowBoxes.filter((box) => stackHeightByBoxId.has(box.id)).map((box) => box.column));
4221
+ const framedBoxIds = new Set(elementsOfKind(board, "frame").flatMap((frame) => frame.contains));
4222
+ const framedColumnIds = new Set(flowBoxes.filter((box) => framedBoxIds.has(box.id)).map((box) => box.column));
4223
+ const sideReserve = (columnId) => CHANNEL_PAD + (columnId !== void 0 && framedColumnIds.has(columnId) ? FRAME_PADDING : 0);
4224
+ return board.columns.map((column, index) => {
4225
+ const isNoted = notedColumnIds.has(column.id);
4226
+ return {
4227
+ left: isNoted ? 156 : sideReserve(column.id),
4228
+ right: sideReserve(board.columns[index + 1]?.id),
4229
+ minimumWidth: isNoted ? Math.max(COLUMN_GAP, 186) : COLUMN_GAP
4230
+ };
4231
+ });
4232
+ }
4233
+ function gapWidthsOf(reserves, tracksByGap, labelWidthByGap) {
4234
+ return reserves.map((reserve, index) => {
4235
+ const tracks = tracksByGap[index] ?? 0;
4236
+ const labelWidth = labelWidthByGap[index] ?? 0;
4237
+ const trackNeed = tracks > 0 ? reserve.left + reserve.right + (tracks + 1) * TRACK_SPACING : 0;
4238
+ const labelNeed = labelWidth > 0 ? reserve.left + reserve.right + labelWidth + 20 : 0;
4239
+ return Math.max(reserve.minimumWidth, trackNeed, labelNeed);
4240
+ });
4241
+ }
4242
+ function columnLeftEdgesOf(board, gapWidths) {
4243
+ const columnLeftEdges = [];
4244
+ let nextX = MARGIN;
4245
+ for (const [index] of board.columns.entries()) {
4246
+ columnLeftEdges.push(nextX);
4247
+ nextX += COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
4248
+ }
4249
+ return columnLeftEdges;
4250
+ }
4251
+ function channelGapsOf(columnLeftEdges, gapWidths, reserves) {
4252
+ return columnLeftEdges.map((leftEdge, index) => {
4253
+ const reserve = reserves[index] ?? {
4254
+ left: CHANNEL_PAD,
4255
+ right: CHANNEL_PAD,
4256
+ minimumWidth: COLUMN_GAP
4257
+ };
4258
+ const gapRight = leftEdge + COLUMN_WIDTH + (gapWidths[index] ?? COLUMN_GAP);
4259
+ return {
4260
+ left: leftEdge + COLUMN_WIDTH + reserve.left,
4261
+ right: gapRight - reserve.right
4262
+ };
4263
+ });
4264
+ }
4265
+ function columnIndexOf(board, box, laidOut, columnLeftEdges) {
4266
+ if (!box.at) return Math.max(0, board.columns.findIndex((column) => column.id === box.column));
4267
+ const centerX = laidOut.x + laidOut.width / 2;
4268
+ const lastLeftOfCenter = columnLeftEdges.findLastIndex((leftEdge) => leftEdge <= centerX);
4269
+ return Math.max(0, lastLeftOfCenter);
4270
+ }
4271
+ function frameIdByBoxId(board) {
4272
+ const frameIds = /* @__PURE__ */ new Map();
4273
+ for (const frame of elementsOfKind(board, "frame")) for (const boxId of frame.contains) if (!frameIds.has(boxId)) frameIds.set(boxId, frame.id);
4274
+ return frameIds;
4275
+ }
4276
+ function frameClearance(previousFrameId, nextFrameId) {
4277
+ if (previousFrameId === nextFrameId) return 0;
4278
+ return (previousFrameId ? FRAME_PADDING : 0) + (nextFrameId ? 44 : 0);
4279
+ }
4280
+ function layoutBoxes(board, columnLeftEdges, boxesTop, stackHeightByBoxId) {
4281
+ const boxesById = /* @__PURE__ */ new Map();
4282
+ const nextYByColumnId = /* @__PURE__ */ new Map();
4283
+ const lastFrameIdByColumnId = /* @__PURE__ */ new Map();
4284
+ const frameIds = frameIdByBoxId(board);
4285
+ const boxes = elementsOfKind(board, "box").map((box, index) => ({
4286
+ box,
4287
+ index
4288
+ })).sort((left, right) => left.box.order - right.box.order || left.index - right.index);
4289
+ for (const { box } of boxes) {
4290
+ const columnIndex = Math.max(0, board.columns.findIndex((column) => column.id === box.column));
4291
+ const shape = boxShape(board, box);
4292
+ const frameId = frameIds.get(box.id) ?? null;
4293
+ const flowY = (nextYByColumnId.get(box.column) ?? boxesTop) + frameClearance(lastFrameIdByColumnId.get(box.column) ?? null, frameId);
4294
+ const position = box.at ?? {
4295
+ x: columnLeftEdges[columnIndex] ?? MARGIN,
4296
+ y: flowY
4297
+ };
4298
+ if (!box.at) {
4299
+ const noteStackBottom = (stackHeightByBoxId.get(box.id) ?? 0) - NOTE_RISE;
4300
+ nextYByColumnId.set(box.column, flowY + Math.max(shape.height, noteStackBottom) + BOX_GAP);
4301
+ lastFrameIdByColumnId.set(box.column, frameId);
4302
+ }
4303
+ boxesById.set(box.id, {
4304
+ kind: "box",
4305
+ id: box.id,
4306
+ x: position.x,
4307
+ y: position.y,
4308
+ width: COLUMN_WIDTH,
4309
+ height: shape.height,
4310
+ titleLines: shape.titleLines,
4311
+ bodyLines: shape.bodyLines,
4312
+ lane: shape.lane,
4313
+ isGhost: box.ghost
4314
+ });
4315
+ }
4316
+ return boxesById;
4317
+ }
4318
+ function unionOf(rects) {
4319
+ if (rects.length === 0) return null;
4320
+ const left = Math.min(...rects.map((rect) => rect.x));
4321
+ const top = Math.min(...rects.map((rect) => rect.y));
4322
+ const right = Math.max(...rects.map((rect) => rect.x + rect.width));
4323
+ const bottom = Math.max(...rects.map((rect) => rect.y + rect.height));
4324
+ return {
4325
+ x: left,
4326
+ y: top,
4327
+ width: right - left,
4328
+ height: bottom - top
4329
+ };
4330
+ }
4331
+ function layoutFrames(board, boxesById) {
4332
+ return elementsOfKind(board, "frame").flatMap((frame) => {
4333
+ const around = unionOf(frame.contains.flatMap((id) => boxesById.get(id) ?? []));
4334
+ if (!around) return [];
4335
+ return [{
4336
+ kind: "frame",
4337
+ id: frame.id,
4338
+ title: frame.title,
4339
+ x: around.x - FRAME_PADDING,
4340
+ y: around.y - FRAME_PADDING - FRAME_TITLE_HEIGHT,
4341
+ width: around.width + 36,
4342
+ height: around.height + 36 + FRAME_TITLE_HEIGHT
4343
+ }];
4344
+ });
4345
+ }
4346
+ function isSideways(side) {
4347
+ return side === "left" || side === "right";
4348
+ }
4349
+ function centerOf(rect) {
4350
+ return {
4351
+ x: rect.x + rect.width / 2,
4352
+ y: rect.y + rect.height / 2
4353
+ };
4354
+ }
4355
+ function hasBoxBetweenInColumn(from, to, columnIndex, input) {
4356
+ const upper = from.y < to.y ? from : to;
4357
+ const lower = upper === from ? to : from;
4358
+ 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);
4359
+ }
4360
+ function shapeOf(from, to, input) {
4361
+ const fromColumn = input.columnIndexByBoxId.get(from.id) ?? 0;
4362
+ const toColumn = input.columnIndexByBoxId.get(to.id) ?? 0;
4363
+ if (fromColumn === toColumn) {
4364
+ if (from.id !== to.id && !hasBoxBetweenInColumn(from, to, fromColumn, input)) {
4365
+ const isDownward = to.y > from.y;
4366
+ return {
4367
+ shape: "straight",
4368
+ exitSide: isDownward ? "bottom" : "top",
4369
+ entrySide: isDownward ? "top" : "bottom",
4370
+ sourceGap: -1,
4371
+ targetGap: -1
4372
+ };
4373
+ }
4374
+ return {
4375
+ shape: "channel",
4376
+ exitSide: "right",
4377
+ entrySide: "right",
4378
+ sourceGap: fromColumn,
4379
+ targetGap: fromColumn
4380
+ };
4381
+ }
4382
+ if (toColumn > fromColumn) return {
4383
+ shape: toColumn === fromColumn + 1 ? "channel" : "long",
4384
+ exitSide: "right",
4385
+ entrySide: "left",
4386
+ sourceGap: fromColumn,
4387
+ targetGap: toColumn - 1
4388
+ };
4389
+ return {
4390
+ shape: toColumn === fromColumn - 1 ? "channel" : "long",
4391
+ exitSide: "left",
4392
+ entrySide: "right",
4393
+ sourceGap: fromColumn - 1,
4394
+ targetGap: toColumn
4395
+ };
4396
+ }
4397
+ function planWires(input) {
4398
+ const plans = input.wires.flatMap((wire) => {
4399
+ const from = input.boxesById.get(wire.from);
4400
+ const to = input.boxesById.get(wire.to);
4401
+ if (!from || !to) return [];
4402
+ const strokeHex = wire.tone === "lane" ? from.lane?.hex ?? null : null;
4403
+ const origin = centerOf(from);
4404
+ return [{
4405
+ wire,
4406
+ from,
4407
+ to,
4408
+ strokeHex,
4409
+ styleKey: `${wire.dashed}|${wire.tone}|${strokeHex}`,
4410
+ ...shapeOf(from, to, input),
4411
+ busKey: null,
4412
+ start: origin,
4413
+ end: centerOf(to),
4414
+ crossingY: origin.y
4415
+ }];
4416
+ });
4417
+ const memberCountByBusKey = /* @__PURE__ */ new Map();
4418
+ const busKeyOf = (plan) => `${plan.to.id}|${plan.entrySide}|${plan.styleKey}`;
4419
+ for (const plan of plans) {
4420
+ if (plan.shape === "straight") continue;
4421
+ memberCountByBusKey.set(busKeyOf(plan), (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) + 1);
4422
+ }
4423
+ for (const plan of plans) if (plan.shape !== "straight" && (memberCountByBusKey.get(busKeyOf(plan)) ?? 0) > 1) plan.busKey = busKeyOf(plan);
4424
+ return plans;
4425
+ }
4426
+ function portPositions(box, side, count) {
4427
+ const indexes = Array.from({ length: count }, (_, index) => index);
4428
+ if (isSideways(side)) {
4429
+ const x = side === "left" ? box.x : box.x + box.width;
4430
+ const spacing = Math.min(PORT_SPACING, (box.height - 16) / Math.max(count - 1, 1));
4431
+ const centeredFirstY = box.y + Math.min(box.height / 2, 40) - (count - 1) * spacing / 2;
4432
+ const firstY = Math.max(box.y + PORT_INSET, Math.min(centeredFirstY, box.y + box.height - PORT_INSET - (count - 1) * spacing));
4433
+ return indexes.map((index) => ({
4434
+ x,
4435
+ y: Math.round(firstY + index * spacing)
4436
+ }));
4437
+ }
4438
+ const y = side === "top" ? box.y : box.y + box.height;
4439
+ const firstX = box.x + box.width / 2 - (count - 1) * PORT_SPACING / 2;
4440
+ return indexes.map((index) => ({
4441
+ x: Math.round(firstX + index * PORT_SPACING),
4442
+ y
4443
+ }));
4444
+ }
4445
+ function portRequestsBySide(plans) {
4446
+ return groupedBy(plans.flatMap((plan) => [{
4447
+ box: plan.from,
4448
+ side: plan.exitSide,
4449
+ groupKey: `exit|${plan.styleKey}`,
4450
+ wireId: plan.wire.id,
4451
+ farPoint: centerOf(plan.to),
4452
+ assign: (point) => {
4453
+ plan.start = point;
4454
+ }
4455
+ }, {
4456
+ box: plan.to,
4457
+ side: plan.entrySide,
4458
+ groupKey: plan.busKey ? `bus|${plan.busKey}` : `entry|${plan.wire.id}`,
4459
+ wireId: plan.wire.id,
4460
+ farPoint: centerOf(plan.from),
4461
+ assign: (point) => {
4462
+ plan.end = point;
4463
+ }
4464
+ }]), (request) => `${request.box.id}|${request.side}`);
4465
+ }
4466
+ function defaultPortOrders(requestsBySide) {
4467
+ return new Map([...requestsBySide.entries()].map(([sideKey, sideRequests]) => {
4468
+ return [sideKey, [...groupedBy(sideRequests, (request) => request.groupKey).entries()].map(([groupKey, members]) => ({
4469
+ groupKey,
4470
+ firstWireId: members.map((member) => member.wireId).sort()[0] ?? groupKey,
4471
+ farCoordinate: members.reduce((sum, member) => sum + (isSideways(member.side) ? member.farPoint.y : member.farPoint.x), 0) / members.length
4472
+ })).sort((left, right) => left.farCoordinate - right.farCoordinate || left.firstWireId.localeCompare(right.firstWireId) || left.groupKey.localeCompare(right.groupKey)).map((group) => group.groupKey)];
4473
+ }));
4474
+ }
4475
+ function assignPorts(requestsBySide, groupOrderBySide) {
4476
+ for (const [sideKey, sideRequests] of requestsBySide) {
4477
+ const first = sideRequests[0];
4478
+ const groupOrder = groupOrderBySide.get(sideKey) ?? [];
4479
+ if (!first) continue;
4480
+ const positions = portPositions(first.box, first.side, groupOrder.length);
4481
+ for (const request of sideRequests) {
4482
+ const position = positions[groupOrder.indexOf(request.groupKey)];
4483
+ if (position) request.assign(position);
4484
+ }
4485
+ }
4486
+ }
4487
+ function crossedSpanOf(plan, gaps) {
4488
+ const sourceGap = gaps[plan.sourceGap] ?? {
4489
+ left: plan.start.x,
4490
+ right: plan.start.x
4491
+ };
4492
+ const targetGap = gaps[plan.targetGap] ?? {
4493
+ left: plan.end.x,
4494
+ right: plan.end.x
4495
+ };
4496
+ return {
4497
+ left: Math.min(sourceGap.left, targetGap.left),
4498
+ right: Math.max(sourceGap.right, targetGap.right)
4499
+ };
4500
+ }
4501
+ function blockersAcross(plan, span, input) {
4502
+ 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);
4503
+ }
4504
+ function isClearRowAt(y, blockers) {
4505
+ return !blockers.some((rect) => y > rect.y - GUTTER_CLEARANCE && y < rect.y + rect.height + GUTTER_CLEARANCE);
4506
+ }
4507
+ function gutterIntervalsBetween(blockers) {
4508
+ const blocked = blockers.map((rect) => ({
4509
+ top: rect.y - GUTTER_CLEARANCE,
4510
+ bottom: rect.y + rect.height + GUTTER_CLEARANCE
4511
+ })).sort((left, right) => left.top - right.top);
4512
+ const merged = [];
4513
+ for (const interval of blocked) {
4514
+ const last = merged.at(-1);
4515
+ if (last && interval.top <= last.bottom) {
4516
+ last.bottom = Math.max(last.bottom, interval.bottom);
4517
+ continue;
4518
+ }
4519
+ merged.push({ ...interval });
4520
+ }
4521
+ return merged.slice(1).flatMap((interval, index) => {
4522
+ const above = merged[index];
4523
+ if (!above || interval.top - above.bottom < MIN_GUTTER_HEIGHT) return [];
4524
+ return [{
4525
+ top: above.bottom,
4526
+ bottom: interval.top
4527
+ }];
4528
+ });
4529
+ }
4530
+ function overlapsSpan(first, second) {
4531
+ return first.left < second.right && second.left < first.right;
4532
+ }
4533
+ function stackedTracks(items, overlaps) {
4534
+ const tracks = [];
4535
+ items.forEach((item, index) => {
4536
+ const earlierTracks = items.slice(0, index).flatMap((earlier, earlierIndex) => overlaps(item, earlier) ? [tracks[earlierIndex] ?? 0] : []);
4537
+ tracks.push(earlierTracks.length > 0 ? Math.max(...earlierTracks) + 1 : 0);
4538
+ });
4539
+ return tracks;
4540
+ }
4541
+ function assignCrossings(plans, input) {
4542
+ const claims = [];
4543
+ const topBandPlans = [];
4544
+ for (const plan of plans) {
4545
+ if (plan.shape !== "long") continue;
4546
+ const span = crossedSpanOf(plan, input.gaps);
4547
+ const blockers = blockersAcross(plan, span, input);
4548
+ const clearPortY = [plan.start.y, plan.end.y].find((y) => isClearRowAt(y, blockers));
4549
+ if (clearPortY !== void 0) {
4550
+ plan.crossingY = clearPortY;
4551
+ continue;
4552
+ }
4553
+ const middleY = (plan.start.y + plan.end.y) / 2;
4554
+ const nearestGutter = gutterIntervalsBetween(blockers).sort((left, right) => Math.abs((left.top + left.bottom) / 2 - middleY) - Math.abs((right.top + right.bottom) / 2 - middleY))[0];
4555
+ if (nearestGutter) {
4556
+ claims.push({
4557
+ plan,
4558
+ interval: nearestGutter,
4559
+ span
4560
+ });
4561
+ continue;
4562
+ }
4563
+ topBandPlans.push({
4564
+ plan,
4565
+ span
4566
+ });
4567
+ }
4568
+ const claimsByInterval = groupedBy(claims, (claim) => `${Math.round(claim.interval.top)}|${Math.round(claim.interval.bottom)}`);
4569
+ for (const intervalClaims of claimsByInterval.values()) {
4570
+ const ordered = [...intervalClaims].sort((left, right) => left.plan.start.y - right.plan.start.y || left.plan.wire.id.localeCompare(right.plan.wire.id));
4571
+ const tracks = stackedTracks(ordered, (first, second) => overlapsSpan(first.span, second.span));
4572
+ const interval = ordered[0]?.interval ?? {
4573
+ top: 0,
4574
+ bottom: 0
4575
+ };
4576
+ const height = interval.bottom - interval.top;
4577
+ const capacity = Math.max(1, Math.floor(height / MIN_GUTTER_TRACK_SPACING) - 1);
4578
+ const trackCount = Math.min(capacity, Math.max(...tracks) + 1);
4579
+ ordered.forEach((claim, index) => {
4580
+ const track = tracks[index] ?? 0;
4581
+ if (track >= capacity) {
4582
+ topBandPlans.push({
4583
+ plan: claim.plan,
4584
+ span: claim.span
4585
+ });
4586
+ return;
4587
+ }
4588
+ claim.plan.crossingY = Math.round(interval.top + height * (track + 1) / (trackCount + 1));
4589
+ });
4590
+ }
4591
+ 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));
4592
+ const topTracks = stackedTracks(outermostFirst, (first, second) => overlapsSpan(first.span, second.span)).map((track) => outermostFirst.length - 1 - track);
4593
+ outermostFirst.forEach(({ plan }, index) => {
4594
+ plan.crossingY = input.topBandBottom - (topTracks[index] ?? 0) * TOP_TRACK_SPACING;
4595
+ });
4596
+ return topBandPlans.length > 0 ? Math.max(...topTracks) + 1 : 0;
4597
+ }
4598
+ function attachmentSideFor(gap, columnIndex) {
4599
+ return columnIndex <= gap ? "left" : "right";
4600
+ }
4601
+ function newRun(key, gap) {
4602
+ return {
4603
+ key,
4604
+ gap,
4605
+ top: Infinity,
4606
+ bottom: -Infinity,
4607
+ leftYs: [],
4608
+ rightYs: [],
4609
+ track: -1,
4610
+ x: 0
4611
+ };
4612
+ }
4613
+ function attach(run, side, y) {
4614
+ (side === "left" ? run.leftYs : run.rightYs).push(y);
4615
+ run.top = Math.min(run.top, y);
4616
+ run.bottom = Math.max(run.bottom, y);
4617
+ }
4618
+ function targetRunKey(plan) {
4619
+ return plan.busKey ? `bus|${plan.busKey}` : `wire|${plan.wire.id}|target`;
4620
+ }
4621
+ function buildRuns(plans, input) {
4622
+ const runsByKey = /* @__PURE__ */ new Map();
4623
+ const runFor = (key, gap) => {
4624
+ const existing = runsByKey.get(key);
4625
+ if (existing) return existing;
4626
+ const created = newRun(key, gap);
4627
+ runsByKey.set(key, created);
4628
+ return created;
4629
+ };
4630
+ const enteredRunKeys = /* @__PURE__ */ new Set();
4631
+ for (const plan of plans) {
4632
+ if (plan.shape === "straight") continue;
4633
+ const fromColumn = input.columnIndexByBoxId.get(plan.from.id) ?? 0;
4634
+ const toColumn = input.columnIndexByBoxId.get(plan.to.id) ?? 0;
4635
+ const isForward = plan.exitSide === "right" && plan.entrySide === "left";
4636
+ const targetRun = runFor(targetRunKey(plan), plan.targetGap);
4637
+ if (plan.shape === "channel") attach(targetRun, attachmentSideFor(plan.targetGap, fromColumn), plan.start.y);
4638
+ if (plan.shape === "long") {
4639
+ const sourceRun = runFor(`wire|${plan.wire.id}|source`, plan.sourceGap);
4640
+ attach(sourceRun, attachmentSideFor(plan.sourceGap, fromColumn), plan.start.y);
4641
+ attach(sourceRun, isForward ? "right" : "left", plan.crossingY);
4642
+ attach(targetRun, isForward ? "left" : "right", plan.crossingY);
4643
+ }
4644
+ if (enteredRunKeys.has(targetRun.key)) continue;
4645
+ enteredRunKeys.add(targetRun.key);
4646
+ attach(targetRun, attachmentSideFor(plan.targetGap, toColumn), plan.end.y);
4647
+ }
4648
+ return runsByKey;
4649
+ }
4650
+ function countInside(ys, run) {
4651
+ return ys.filter((y) => y > run.top && y < run.bottom).length;
4652
+ }
4653
+ function crossingsWhenLeftOf(leftRun, rightRun) {
4654
+ return countInside(rightRun.leftYs, leftRun) + countInside(leftRun.rightYs, rightRun);
4655
+ }
4656
+ function placeTracks(runsByKey, gaps) {
4657
+ const tracksByGap = gaps.map(() => 0);
4658
+ const runsByGap = groupedBy([...runsByKey.values()].filter((run) => run.bottom > run.top), (run) => run.gap);
4659
+ for (const [gapIndex, gapRuns] of runsByGap) {
4660
+ const ordered = [...gapRuns].sort((first, second) => crossingsWhenLeftOf(first, second) - crossingsWhenLeftOf(second, first) || first.top - second.top || first.key.localeCompare(second.key));
4661
+ const tracks = stackedTracks(ordered, (first, second) => first.top < second.bottom + RUN_CLEARANCE && second.top < first.bottom + RUN_CLEARANCE);
4662
+ const trackCount = Math.max(...tracks) + 1;
4663
+ tracksByGap[gapIndex] = trackCount;
4664
+ const gap = gaps[gapIndex] ?? {
4665
+ left: 0,
4666
+ right: 0
4667
+ };
4668
+ ordered.forEach((run, index) => {
4669
+ run.track = tracks[index] ?? 0;
4670
+ run.x = Math.round(gap.left + (gap.right - gap.left) * (run.track + 1) / (trackCount + 1));
4671
+ });
4672
+ }
4673
+ for (const run of runsByKey.values()) {
4674
+ if (run.track >= 0) continue;
4675
+ const gap = gaps[run.gap] ?? {
4676
+ left: 0,
4677
+ right: 0
4678
+ };
4679
+ run.x = Math.round((gap.left + gap.right) / 2);
4680
+ }
4681
+ return tracksByGap;
4682
+ }
4683
+ function withoutBends(points) {
4684
+ const distinct = points.filter((point, index) => {
4685
+ const previous = points[index - 1];
4686
+ return !previous || previous.x !== point.x || previous.y !== point.y;
4687
+ });
4688
+ return distinct.filter((point, index) => {
4689
+ const previous = distinct[index - 1];
4690
+ const next = distinct[index + 1];
4691
+ if (!previous || !next) return true;
4692
+ return !(previous.x === point.x && point.x === next.x || previous.y === point.y && point.y === next.y);
4693
+ });
4694
+ }
4695
+ function segmentsOf(points) {
4696
+ return points.slice(1).flatMap((point, index) => {
4697
+ const previous = points[index];
4698
+ return previous ? [{
4699
+ from: previous,
4700
+ to: point
4701
+ }] : [];
4702
+ });
4703
+ }
4704
+ function straightPoints(plan) {
4705
+ if (plan.start.x === plan.end.x) return [plan.start, plan.end];
4706
+ const middleY = Math.round((plan.start.y + plan.end.y) / 2);
4707
+ return [
4708
+ plan.start,
4709
+ {
4710
+ x: plan.start.x,
4711
+ y: middleY
4712
+ },
4713
+ {
4714
+ x: plan.end.x,
4715
+ y: middleY
4716
+ },
4717
+ plan.end
4718
+ ];
4719
+ }
4720
+ function routedPoints(plan, runsByKey) {
4721
+ if (plan.shape === "straight") return straightPoints(plan);
4722
+ const targetX = runsByKey.get(targetRunKey(plan))?.x ?? plan.end.x;
4723
+ const arrivalY = plan.shape === "long" ? plan.crossingY : plan.start.y;
4724
+ const sourceX = runsByKey.get(`wire|${plan.wire.id}|source`)?.x ?? targetX;
4725
+ const approach = plan.shape === "long" ? [
4726
+ plan.start,
4727
+ {
4728
+ x: sourceX,
4729
+ y: plan.start.y
4730
+ },
4731
+ {
4732
+ x: sourceX,
4733
+ y: arrivalY
4734
+ },
4735
+ {
4736
+ x: targetX,
4737
+ y: arrivalY
4738
+ }
4739
+ ] : [plan.start, {
4740
+ x: targetX,
4741
+ y: arrivalY
4742
+ }];
4743
+ if (plan.busKey) return approach;
4744
+ return [
4745
+ ...approach,
4746
+ {
4747
+ x: targetX,
4748
+ y: plan.end.y
4749
+ },
4750
+ plan.end
4751
+ ];
4752
+ }
4753
+ function pathOf(points) {
4754
+ return points.map((point, index) => `${index === 0 ? "M" : "L"} ${point.x} ${point.y}`).join(" ");
4755
+ }
4756
+ function drawWires(plans, runsByKey) {
4757
+ const leadIdByBusKey = /* @__PURE__ */ new Map();
4758
+ 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);
4759
+ return plans.map((plan) => {
4760
+ const points = withoutBends(routedPoints(plan, runsByKey));
4761
+ const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
4762
+ const isLead = plan.busKey !== null && leadIdByBusKey.get(plan.busKey) === plan.wire.id;
4763
+ const trunk = trunkRun && isLead ? [{
4764
+ from: {
4765
+ x: trunkRun.x,
4766
+ y: trunkRun.top
4767
+ },
4768
+ to: {
4769
+ x: trunkRun.x,
4770
+ y: trunkRun.bottom
4771
+ }
4772
+ }, {
4773
+ from: {
4774
+ x: trunkRun.x,
4775
+ y: plan.end.y
4776
+ },
4777
+ to: plan.end
4778
+ }].filter((segment) => segment.from.x !== segment.to.x || segment.from.y !== segment.to.y) : [];
4779
+ return {
4780
+ plan,
4781
+ points,
4782
+ trunk,
4783
+ segments: [...segmentsOf(points), ...trunk]
4784
+ };
4785
+ });
4786
+ }
4787
+ function isHorizontal(segment) {
4788
+ return segment.from.y === segment.to.y;
4789
+ }
4790
+ function segmentHitsRect(segment, rect) {
4791
+ const right = rect.x + rect.width;
4792
+ const bottom = rect.y + rect.height;
4793
+ if (isHorizontal(segment)) {
4794
+ const y = segment.from.y;
4795
+ 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;
4796
+ }
4797
+ const x = segment.from.x;
4798
+ 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;
4799
+ }
4800
+ function rectsOverlap(first, second) {
4801
+ 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;
4802
+ }
4803
+ function labelWidthOf(label) {
4804
+ return Math.ceil(label.length * LABEL_CHAR_WIDTH);
4805
+ }
4806
+ function labelBoundsAt(baseline, width) {
4807
+ return {
4808
+ x: baseline.x - width / 2,
4809
+ y: baseline.y - LABEL_ASCENT,
4810
+ width,
4811
+ height: 13
4812
+ };
4813
+ }
4814
+ function segmentLength(segment) {
4815
+ return Math.abs(segment.from.x - segment.to.x) + Math.abs(segment.from.y - segment.to.y);
4816
+ }
4817
+ function labelCandidates(segments, width) {
4818
+ const byLength = [...segments].sort((left, right) => segmentLength(right) - segmentLength(left));
4819
+ return [...segments.slice(0, 1), ...byLength].flatMap((segment) => [...LABEL_SLIDE_FRACTIONS.flatMap((fraction) => {
4820
+ const x = segment.from.x + (segment.to.x - segment.from.x) * fraction;
4821
+ const y = segment.from.y + (segment.to.y - segment.from.y) * fraction;
4822
+ if (isHorizontal(segment)) return [{
4823
+ x,
4824
+ y: y - LABEL_GAP
4825
+ }, {
4826
+ x,
4827
+ y: y + LABEL_GAP + LABEL_ASCENT
4828
+ }];
4829
+ return [{
4830
+ x: x + LABEL_GAP + width / 2,
4831
+ y: y + LABEL_ASCENT / 2
4832
+ }, {
4833
+ x: x - LABEL_GAP - width / 2,
4834
+ y: y + LABEL_ASCENT / 2
4835
+ }];
4836
+ }), ...flushLabelCandidates(segment, width)]);
4837
+ }
4838
+ function flushLabelCandidates(segment, width) {
4839
+ if (!isHorizontal(segment)) return [];
4840
+ const y = segment.from.y;
4841
+ 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) => [{
4842
+ x,
4843
+ y: y - LABEL_GAP
4844
+ }, {
4845
+ x,
4846
+ y: y + LABEL_GAP + LABEL_ASCENT
4847
+ }]);
4848
+ }
4849
+ function inflated(rect, by) {
4850
+ return {
4851
+ x: rect.x - by,
4852
+ y: rect.y - by,
4853
+ width: rect.width + by * 2,
4854
+ height: rect.height + by * 2
4855
+ };
4856
+ }
4857
+ function placeLabels(drawn, input, warnings) {
4858
+ const placedById = /* @__PURE__ */ new Map();
4859
+ const allSegments = drawn.flatMap((wire) => wire.segments);
4860
+ const solids = [...input.boxesById.values(), ...input.obstacles];
4861
+ for (const wire of drawn) {
4862
+ const label = wire.plan.wire.label;
4863
+ if (!label) continue;
4864
+ const width = labelWidthOf(label);
4865
+ const candidates = labelCandidates(wire.segments, width);
4866
+ const isClear = (baseline) => {
4867
+ const bounds = labelBoundsAt(baseline, width);
4868
+ if (bounds.y < input.contentTop) return false;
4869
+ const padded = inflated(bounds, LABEL_CLEARANCE);
4870
+ if (allSegments.some((segment) => segmentHitsRect(segment, padded))) return false;
4871
+ if (solids.some((rect) => rectsOverlap(bounds, rect))) return false;
4872
+ return ![...placedById.values()].some((placed) => rectsOverlap(bounds, placed.bounds));
4873
+ };
4874
+ const clearSpot = candidates.find(isClear);
4875
+ const at = clearSpot ?? candidates[0] ?? centerOf(wire.plan.from);
4876
+ if (!clearSpot) warnings.push(`wire ${wire.plan.wire.id} label "${label}" has no clear spot`);
4877
+ placedById.set(wire.plan.wire.id, {
4878
+ at: {
4879
+ x: Math.round(at.x),
4880
+ y: Math.round(at.y)
4881
+ },
4882
+ bounds: labelBoundsAt(at, width)
4883
+ });
4884
+ }
4885
+ return placedById;
4886
+ }
4887
+ function isStrictlyBetween(value, first, second) {
4888
+ return value > Math.min(first, second) + .5 && value < Math.max(first, second) - .5;
4889
+ }
4890
+ function segmentsCross(first, second) {
4891
+ if (isHorizontal(first) === isHorizontal(second)) return false;
4892
+ const horizontal = isHorizontal(first) ? first : second;
4893
+ const vertical = horizontal === first ? second : first;
4894
+ return isStrictlyBetween(vertical.from.x, horizontal.from.x, horizontal.to.x) && isStrictlyBetween(horizontal.from.y, vertical.from.y, vertical.to.y);
4895
+ }
4896
+ function segmentsOverlap(first, second) {
4897
+ if (isHorizontal(first) !== isHorizontal(second)) return false;
4898
+ const isAlongX = isHorizontal(first);
4899
+ const lineOf = (segment) => isAlongX ? segment.from.y : segment.from.x;
4900
+ const startOf = (segment) => Math.min(isAlongX ? segment.from.x : segment.from.y, isAlongX ? segment.to.x : segment.to.y);
4901
+ const endOf = (segment) => Math.max(isAlongX ? segment.from.x : segment.from.y, isAlongX ? segment.to.x : segment.to.y);
4902
+ return lineOf(first) === lineOf(second) && Math.min(endOf(first), endOf(second)) - Math.max(startOf(first), startOf(second)) > 1;
4903
+ }
4904
+ function isSharedFanOut(first, second) {
4905
+ return first.plan.styleKey === second.plan.styleKey && first.plan.start.x === second.plan.start.x && first.plan.start.y === second.plan.start.y;
4906
+ }
4907
+ function findCrossings(drawn) {
4908
+ return drawn.flatMap((first, index) => drawn.slice(index + 1).flatMap((second) => {
4909
+ if (first.plan.busKey !== null && first.plan.busKey === second.plan.busKey) return [];
4910
+ const pairs = first.segments.flatMap((firstSegment) => second.segments.map((secondSegment) => [firstSegment, secondSegment]));
4911
+ if (pairs.some(([firstSegment, secondSegment]) => segmentsCross(firstSegment, secondSegment))) return [`wire ${first.plan.wire.id} crosses wire ${second.plan.wire.id}`];
4912
+ if (isSharedFanOut(first, second)) return [];
4913
+ return pairs.some(([firstSegment, secondSegment]) => segmentsOverlap(firstSegment, secondSegment)) ? [`wire ${first.plan.wire.id} overlaps wire ${second.plan.wire.id}`] : [];
4914
+ }));
4915
+ }
4916
+ function findBoxCrossings(drawn, input) {
4917
+ const boxes = [...input.boxesById.values()];
4918
+ return drawn.flatMap((wire) => boxes.flatMap((box) => {
4919
+ if (box.id === wire.plan.from.id || box.id === wire.plan.to.id) return [];
4920
+ const inset = inflated(box, -2);
4921
+ return wire.segments.some((segment) => segmentHitsRect(segment, inset)) ? [`wire ${wire.plan.wire.id} runs through box ${box.id}`] : [];
4922
+ }));
4923
+ }
4924
+ function cappedWarnings(warnings) {
4925
+ if (warnings.length <= WHITEBOARD_LIMITS.layoutWarnings) return [...warnings];
4926
+ const shown = warnings.slice(0, WHITEBOARD_LIMITS.layoutWarnings - 1);
4927
+ return [...shown, `and ${warnings.length - shown.length} more`];
4928
+ }
4929
+ function labelWidthsByGap(plans, gaps) {
4930
+ const widths = gaps.map(() => 0);
4931
+ for (const plan of plans) {
4932
+ if (!plan.wire.label || plan.shape !== "channel") continue;
4933
+ widths[plan.targetGap] = Math.max(widths[plan.targetGap] ?? 0, labelWidthOf(plan.wire.label));
4934
+ }
4935
+ return widths;
4936
+ }
4937
+ function extentOf(drawn, labelRects) {
4938
+ return unionOf([...drawn.flatMap((wire) => wire.segments.flatMap((segment) => [segment.from, segment.to])).map((point) => ({
4939
+ x: point.x,
4940
+ y: point.y,
4941
+ width: 0,
4942
+ height: 0
4943
+ })), ...labelRects]);
4944
+ }
4945
+ function routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide) {
4946
+ assignPorts(requestsBySide, groupOrderBySide);
4947
+ const topTrackCount = assignCrossings(plans, input);
4948
+ const runsByKey = buildRuns(plans, input);
4949
+ const tracksByGap = placeTracks(runsByKey, input.gaps);
4950
+ const drawn = drawWires(plans, runsByKey);
4951
+ return {
4952
+ runsByKey,
4953
+ tracksByGap,
4954
+ topTrackCount,
4955
+ drawn,
4956
+ crossingCost: findBoxCrossings(drawn, input).length * BOX_CROSSING_COST + findCrossings(drawn).length
4957
+ };
4958
+ }
4959
+ function swapNeighbors(order, index) {
4960
+ const left = order[index];
4961
+ const right = order[index + 1];
4962
+ if (left === void 0 || right === void 0) return;
4963
+ order[index] = right;
4964
+ order[index + 1] = left;
4965
+ }
4966
+ function routeWithFewestCrossings(plans, input) {
4967
+ const requestsBySide = portRequestsBySide(plans);
4968
+ const groupOrderBySide = defaultPortOrders(requestsBySide);
4969
+ let bestCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
4970
+ const canSearchPortOrders = plans.length <= MAX_WIRES_FOR_PORT_SEARCH;
4971
+ for (const groupOrder of groupOrderBySide.values()) for (let index = 0; canSearchPortOrders && bestCost > 0 && index + 1 < groupOrder.length; index += 1) {
4972
+ swapNeighbors(groupOrder, index);
4973
+ const trialCost = routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide).crossingCost;
4974
+ if (trialCost < bestCost) {
4975
+ bestCost = trialCost;
4976
+ continue;
4977
+ }
4978
+ swapNeighbors(groupOrder, index);
4979
+ }
4980
+ return routeWithPortOrder(plans, input, requestsBySide, groupOrderBySide);
4981
+ }
4982
+ function routeWires(input) {
4983
+ const plans = planWires(input);
4984
+ const { runsByKey, tracksByGap, topTrackCount, drawn } = routeWithFewestCrossings(plans, input);
4985
+ const labelWarnings = [];
4986
+ const labelById = placeLabels(drawn, input, labelWarnings);
4987
+ const wires = drawn.map(({ plan, points, trunk }) => {
4988
+ const lastPoint = points.at(-1) ?? plan.end;
4989
+ const trunkRun = plan.busKey ? runsByKey.get(targetRunKey(plan)) : void 0;
4990
+ const isTrunkLead = trunk.length > 0;
4991
+ const isTJoin = trunkRun !== void 0 && lastPoint.y > trunkRun.top && lastPoint.y < trunkRun.bottom;
4992
+ return {
4993
+ kind: "wire",
4994
+ id: plan.wire.id,
4995
+ path: [pathOf(points), ...trunk.map((segment) => pathOf([segment.from, segment.to]))].join(" "),
4996
+ start: plan.start,
4997
+ end: isTrunkLead || !plan.busKey ? plan.end : lastPoint,
4998
+ label: plan.wire.label,
4999
+ labelAt: labelById.get(plan.wire.id)?.at ?? centerOf(plan.from),
5000
+ isDashed: plan.wire.dashed,
5001
+ strokeHex: plan.strokeHex,
5002
+ tone: plan.wire.tone,
5003
+ hasArrowhead: plan.busKey === null || isTrunkLead,
5004
+ joinAt: isTJoin ? lastPoint : null
5005
+ };
5006
+ });
5007
+ const labelRects = [...labelById.values()].map((placed) => placed.bounds);
5008
+ return {
5009
+ wires,
5010
+ tracksByGap,
5011
+ topTrackCount,
5012
+ labelWidthByGap: labelWidthsByGap(plans, input.gaps),
5013
+ warnings: cappedWarnings([
5014
+ ...findBoxCrossings(drawn, input),
5015
+ ...findCrossings(drawn),
5016
+ ...labelWarnings
5017
+ ]),
5018
+ extent: extentOf(drawn, labelRects)
5019
+ };
5020
+ }
5021
+ function noteByline(note) {
5022
+ if (note.resolvedBy) return `resolved by ${note.resolvedBy}`;
5023
+ return note.author ? `from ${note.author}` : "";
5024
+ }
5025
+ function layoutNotes(board, boxesById) {
5026
+ const nextYByBoxId = /* @__PURE__ */ new Map();
5027
+ return elementsOfKind(board, "note").flatMap((note) => {
5028
+ const target = boxesById.get(note.on);
5029
+ if (!target) return [];
5030
+ const { lines, height } = noteShape(note);
5031
+ const y = nextYByBoxId.get(note.on) ?? target.y - NOTE_RISE;
5032
+ nextYByBoxId.set(note.on, y + height + NOTE_GAP);
5033
+ return [{
5034
+ kind: "note",
5035
+ id: note.id,
5036
+ x: target.x + target.width - NOTE_OVERLAP,
5037
+ y,
5038
+ width: NOTE_WIDTH,
5039
+ height,
5040
+ lines,
5041
+ byline: noteByline(note),
5042
+ isResolved: note.resolvedBy !== null
5043
+ }];
5044
+ });
5045
+ }
5046
+ function boundsOf(elements, wireExtent, columnLeftEdges, boxesTop) {
5047
+ const rects = elements.flatMap((element) => element.kind === "wire" ? [] : [element]);
5048
+ const columnsRight = (columnLeftEdges.at(-1) ?? MARGIN) + COLUMN_WIDTH;
5049
+ const around = unionOf([
5050
+ ...rects,
5051
+ ...wireExtent ? [wireExtent] : [],
5052
+ {
5053
+ x: 0,
5054
+ y: 0,
5055
+ width: columnsRight,
5056
+ height: boxesTop
5057
+ }
5058
+ ]);
5059
+ if (!around) return {
5060
+ x: 0,
5061
+ y: 0,
5062
+ width: columnsRight + MARGIN,
5063
+ height: 80
5064
+ };
5065
+ return {
5066
+ x: Math.min(0, around.x - MARGIN),
5067
+ y: Math.min(0, around.y - MARGIN),
5068
+ width: around.width + 80,
5069
+ height: around.height + 80
5070
+ };
5071
+ }
5072
+ function placeAndRoute(board, placement) {
5073
+ const columnLeftEdges = columnLeftEdgesOf(board, placement.gapWidths);
5074
+ const boxesById = layoutBoxes(board, columnLeftEdges, placement.boxesTop, placement.stackHeightByBoxId);
5075
+ const frames = layoutFrames(board, boxesById);
5076
+ const notes = layoutNotes(board, boxesById);
5077
+ const columnIndexByBoxId = new Map(elementsOfKind(board, "box").flatMap((box) => {
5078
+ const laidOut = boxesById.get(box.id);
5079
+ return laidOut ? [[box.id, columnIndexOf(board, box, laidOut, columnLeftEdges)]] : [];
5080
+ }));
5081
+ return {
5082
+ columnLeftEdges,
5083
+ boxesById,
5084
+ frames,
5085
+ notes,
5086
+ routing: routeWires({
5087
+ wires: elementsOfKind(board, "wire"),
5088
+ boxesById,
5089
+ columnIndexByBoxId,
5090
+ obstacles: [...notes, ...frames.map((frame) => ({
5091
+ x: frame.x,
5092
+ y: frame.y,
5093
+ width: frame.width,
5094
+ height: FRAME_TITLE_HEIGHT
5095
+ }))],
5096
+ gaps: channelGapsOf(columnLeftEdges, placement.gapWidths, placement.reserves),
5097
+ topBandBottom: placement.boxesTop - TOP_BAND_PAD,
5098
+ contentTop: placement.contentTop
5099
+ })
5100
+ };
5101
+ }
5102
+ function maxByIndex(first, second) {
5103
+ return Array.from({ length: Math.max(first.length, second.length) }, (_, index) => Math.max(first[index] ?? 0, second[index] ?? 0));
5104
+ }
5105
+ function placeWithReservedRoom(board, draftRouting, room) {
5106
+ let reservedTracksByGap = draftRouting.tracksByGap;
5107
+ let reservedTopTracks = draftRouting.topTrackCount;
5108
+ for (let attempt = 1;; attempt += 1) {
5109
+ const gapWidths = gapWidthsOf(room.reserves, reservedTracksByGap, draftRouting.labelWidthByGap);
5110
+ const boxesTop = room.headerBoxesTop + topBandHeight(reservedTopTracks);
5111
+ const placed = placeAndRoute(board, {
5112
+ gapWidths,
5113
+ reserves: room.reserves,
5114
+ boxesTop,
5115
+ contentTop: room.contentTop,
5116
+ stackHeightByBoxId: room.stackHeightByBoxId
5117
+ });
5118
+ const needsMoreTop = placed.routing.topTrackCount > reservedTopTracks;
5119
+ const needsMoreTracks = placed.routing.tracksByGap.some((tracks, index) => tracks > (reservedTracksByGap[index] ?? 0));
5120
+ if (attempt >= MAX_ROOM_ATTEMPTS || !needsMoreTop && !needsMoreTracks) return {
5121
+ placed,
5122
+ boxesTop
5123
+ };
5124
+ reservedTopTracks = Math.max(reservedTopTracks, placed.routing.topTrackCount);
5125
+ reservedTracksByGap = maxByIndex(reservedTracksByGap, placed.routing.tracksByGap);
5126
+ }
5127
+ }
5128
+ function topBandHeight(topTrackCount) {
5129
+ return topTrackCount > 0 ? topTrackCount * TOP_TRACK_SPACING + TOP_BAND_PAD : 0;
5130
+ }
5131
+ function layoutBoard(board) {
5132
+ const stackHeightByBoxId = noteStackHeightByBoxId(board);
5133
+ const titleLinesByColumn = columnTitleLines(board);
5134
+ const extraHeaderHeight = headerExtraHeight(titleLinesByColumn);
5135
+ const ruleY = 66 + extraHeaderHeight;
5136
+ const headerBoxesTop = 84 + extraHeaderHeight;
5137
+ const reserves = gapReservesOf(board, stackHeightByBoxId);
5138
+ const { placed, boxesTop } = placeWithReservedRoom(board, placeAndRoute(board, {
5139
+ gapWidths: gapWidthsOf(reserves, [], []),
5140
+ reserves,
5141
+ boxesTop: headerBoxesTop,
5142
+ contentTop: ruleY,
5143
+ stackHeightByBoxId
5144
+ }).routing, {
5145
+ reserves,
5146
+ headerBoxesTop,
5147
+ contentTop: ruleY,
5148
+ stackHeightByBoxId
5149
+ });
5150
+ const { columnLeftEdges } = placed;
5151
+ const elements = [
5152
+ ...placed.frames,
5153
+ ...placed.routing.wires,
5154
+ ...placed.boxesById.values(),
5155
+ ...placed.notes
5156
+ ];
5157
+ const contentBounds = boundsOf(elements, placed.routing.extent, columnLeftEdges, boxesTop);
5158
+ const legendTop = contentBounds.y + contentBounds.height;
5159
+ const legend = board.lanes.map((lane, index) => ({
5160
+ label: lane.label || lane.id,
5161
+ hex: LANE_HEX_BY_COLOR[lane.color],
5162
+ x: MARGIN,
5163
+ y: legendTop + index * LEGEND_ROW_HEIGHT
5164
+ }));
5165
+ const captionTop = legendTop + legend.length * LEGEND_ROW_HEIGHT + (legend.length > 0 ? 12 : 0);
5166
+ const caption = board.caption ? {
5167
+ text: board.caption,
5168
+ x: MARGIN,
5169
+ y: captionTop
5170
+ } : null;
5171
+ const extraHeight = legend.length * LEGEND_ROW_HEIGHT + (caption ? 30 : 0) + (legend.length > 0 ? 12 : 0);
5172
+ return {
5173
+ columns: board.columns.map((column, index) => ({
5174
+ id: column.id,
5175
+ titleLines: titleLinesByColumn[index] ?? [],
5176
+ titleBaselineY: 56,
5177
+ ruleY,
5178
+ x: columnLeftEdges[index] ?? MARGIN,
5179
+ width: COLUMN_WIDTH
5180
+ })),
5181
+ elements,
5182
+ legend,
5183
+ caption,
5184
+ bounds: {
5185
+ ...contentBounds,
5186
+ height: contentBounds.height + extraHeight
5187
+ },
5188
+ warnings: placed.routing.warnings
5189
+ };
5190
+ }
5191
+ //#endregion
4087
5192
  //#region server/core/whiteboard-store-core.ts
4088
5193
  function lowestCursor(record) {
4089
5194
  const cursors = Object.values(record.cursorBySessionId);
@@ -4418,6 +5523,7 @@ function createWhiteboardWiring({ boardsRoot, broadcastControl = () => {}, now =
4418
5523
  updatedAt: next.board.updatedAt,
4419
5524
  ops: [...ops]
4420
5525
  };
5526
+ const { warnings } = layoutBoard(next.board);
4421
5527
  return {
4422
5528
  ok: true,
4423
5529
  record: next,
@@ -4425,7 +5531,8 @@ function createWhiteboardWiring({ boardsRoot, broadcastControl = () => {}, now =
4425
5531
  status: 200,
4426
5532
  body: {
4427
5533
  ok: true,
4428
- version: next.board.version
5534
+ version: next.board.version,
5535
+ ...warnings.length > 0 ? { warnings } : {}
4429
5536
  }
4430
5537
  },
4431
5538
  patch