@rudderhq/server 0.7.9 → 0.7.11

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 (131) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/routes/chats.d.ts.map +1 -1
  4. package/dist/routes/chats.js +22 -3
  5. package/dist/routes/chats.js.map +1 -1
  6. package/dist/routes/goals.d.ts.map +1 -1
  7. package/dist/routes/goals.js +58 -4
  8. package/dist/routes/goals.js.map +1 -1
  9. package/dist/routes/issues.mutations.d.ts.map +1 -1
  10. package/dist/routes/issues.mutations.js +3 -0
  11. package/dist/routes/issues.mutations.js.map +1 -1
  12. package/dist/services/agent-startup-context.d.ts +1 -1
  13. package/dist/services/agent-startup-context.d.ts.map +1 -1
  14. package/dist/services/agent-startup-context.js +11 -2
  15. package/dist/services/agent-startup-context.js.map +1 -1
  16. package/dist/services/chat-assistant.d.ts.map +1 -1
  17. package/dist/services/chat-assistant.js +11 -1
  18. package/dist/services/chat-assistant.js.map +1 -1
  19. package/dist/services/chats.d.ts +85 -0
  20. package/dist/services/chats.d.ts.map +1 -1
  21. package/dist/services/chats.js +36 -1
  22. package/dist/services/chats.js.map +1 -1
  23. package/dist/services/goals.d.ts +97 -5
  24. package/dist/services/goals.d.ts.map +1 -1
  25. package/dist/services/goals.js +239 -2
  26. package/dist/services/goals.js.map +1 -1
  27. package/dist/services/runtime-kernel/assignment-run-guardrail.d.ts +78 -23
  28. package/dist/services/runtime-kernel/assignment-run-guardrail.d.ts.map +1 -1
  29. package/dist/services/runtime-kernel/assignment-run-guardrail.js +225 -2
  30. package/dist/services/runtime-kernel/assignment-run-guardrail.js.map +1 -1
  31. package/dist/services/runtime-kernel/assignment-run-guardrail.test.js +103 -3
  32. package/dist/services/runtime-kernel/assignment-run-guardrail.test.js.map +1 -1
  33. package/dist/services/runtime-kernel/heartbeat.d.ts.map +1 -1
  34. package/dist/services/runtime-kernel/heartbeat.execute.d.ts.map +1 -1
  35. package/dist/services/runtime-kernel/heartbeat.execute.js +83 -13
  36. package/dist/services/runtime-kernel/heartbeat.execute.js.map +1 -1
  37. package/dist/services/runtime-kernel/heartbeat.js +44 -2
  38. package/dist/services/runtime-kernel/heartbeat.js.map +1 -1
  39. package/dist/services/runtime-kernel/heartbeat.wakeup.js +1 -1
  40. package/dist/services/runtime-kernel/heartbeat.wakeup.js.map +1 -1
  41. package/dist/services/workspace-backups.d.ts +1 -1
  42. package/dist/services/workspace-backups.d.ts.map +1 -1
  43. package/dist/services/workspace-backups.js +50 -17
  44. package/dist/services/workspace-backups.js.map +1 -1
  45. package/package.json +14 -14
  46. package/resources/bundled-skills/rudder-docs/references/cli-reference.md +9 -6
  47. package/skills/rudder-docs/references/cli-reference.md +9 -6
  48. package/ui-dist/assets/{LibraryLiveSurface-C0jsVm76.js → LibraryLiveSurface-De1p59PK.js} +1 -1
  49. package/ui-dist/assets/{abnfDiagram-VRR7QNED-U1mPal0M.js → abnfDiagram-VRR7QNED-BggxrEZR.js} +1 -1
  50. package/ui-dist/assets/{addon-fit-B18ohVaY.js → addon-fit-Cc1gOtSX.js} +1 -1
  51. package/ui-dist/assets/{arc-CYOWHL_W.js → arc-0kNrc9xt.js} +1 -1
  52. package/ui-dist/assets/{architectureDiagram-ZJ3FMSHR-CmiN5Erc.js → architectureDiagram-ZJ3FMSHR-BOCa-5ab.js} +1 -1
  53. package/ui-dist/assets/{blockDiagram-677ZJIJ3-Chl4uqNv.js → blockDiagram-677ZJIJ3-CQU5jcsO.js} +1 -1
  54. package/ui-dist/assets/{c4Diagram-LMCZKHZV-DSUkRSKu.js → c4Diagram-LMCZKHZV-ChgWIw5O.js} +1 -1
  55. package/ui-dist/assets/channel-eAoWqZqJ.js +1 -0
  56. package/ui-dist/assets/{chunk-2Q5K7J3B-DTJMcqWI.js → chunk-2Q5K7J3B-B4yrwesI.js} +1 -1
  57. package/ui-dist/assets/{chunk-32BRIVSS-zdmMVLnX.js → chunk-32BRIVSS-mhAeSMlR.js} +1 -1
  58. package/ui-dist/assets/{chunk-5VM5RSS4-D7CHEd8F.js → chunk-5VM5RSS4-BmS_u59G.js} +1 -1
  59. package/ui-dist/assets/{chunk-EX3LRPZG-BSlg__Tm.js → chunk-EX3LRPZG-DXoTKkLG.js} +1 -1
  60. package/ui-dist/assets/{chunk-JWPE2WC7-DZ-jdJNV.js → chunk-JWPE2WC7-Bj9myT03.js} +1 -1
  61. package/ui-dist/assets/{chunk-MOJQB5TN-BBqkM1ra.js → chunk-MOJQB5TN-OAoJna8Y.js} +1 -1
  62. package/ui-dist/assets/{chunk-RYQCIY6F-DcEtbyB7.js → chunk-RYQCIY6F-AGLA7TJn.js} +1 -1
  63. package/ui-dist/assets/{chunk-V7JOEXUC-DzXDmCLX.js → chunk-V7JOEXUC-YGM2tDK2.js} +1 -1
  64. package/ui-dist/assets/{chunk-VR4S4FIN-CY5XcPhT.js → chunk-VR4S4FIN-DqaZn9Ty.js} +1 -1
  65. package/ui-dist/assets/{chunk-XXDRQBXY-kROQNOzd.js → chunk-XXDRQBXY-Cpqn_8Bl.js} +1 -1
  66. package/ui-dist/assets/classDiagram-OUVF2IWQ-c94PI6yY.js +1 -0
  67. package/ui-dist/assets/classDiagram-v2-EOCWNBFH-c94PI6yY.js +1 -0
  68. package/ui-dist/assets/{cose-bilkent-JH36ORCC-CrnVyxOw.js → cose-bilkent-JH36ORCC-BVe-X26w.js} +1 -1
  69. package/ui-dist/assets/{cynefin-VYW2F7L2-LqXNJWXt.js → cynefin-VYW2F7L2-DlDrrBWp.js} +1 -1
  70. package/ui-dist/assets/{cynefinDiagram-TSTJHNR4-CuIowjom.js → cynefinDiagram-TSTJHNR4-BSHvFeGh.js} +1 -1
  71. package/ui-dist/assets/{dagre-VKFMJZFB-_JHXcILM.js → dagre-VKFMJZFB-tUm70k9h.js} +1 -1
  72. package/ui-dist/assets/{diagram-FQU43EPY-BsWNb9wJ.js → diagram-FQU43EPY-C5kjITq7.js} +1 -1
  73. package/ui-dist/assets/{diagram-G47NLZAW-NRzY78z7.js → diagram-G47NLZAW-BrbHgt8r.js} +1 -1
  74. package/ui-dist/assets/{diagram-NH7WQ7WH-D83JoKpS.js → diagram-NH7WQ7WH-DT7PdghT.js} +1 -1
  75. package/ui-dist/assets/{diagram-OA4YK3LP-CiQTkxEF.js → diagram-OA4YK3LP-wOjhRHRo.js} +1 -1
  76. package/ui-dist/assets/{diagram-WEI45ONY-zNOFqhj1.js → diagram-WEI45ONY-Dz9vtaDT.js} +1 -1
  77. package/ui-dist/assets/{ebnfDiagram-CCIWWBDH-l9X92AzX.js → ebnfDiagram-CCIWWBDH-BT5TzIA6.js} +1 -1
  78. package/ui-dist/assets/{erDiagram-Q63AITRT-CZ2xCVfq.js → erDiagram-Q63AITRT-DLCpoOEP.js} +1 -1
  79. package/ui-dist/assets/{flowDiagram-23GEKE2U-DsqDeyPl.js → flowDiagram-23GEKE2U-DfF2COjh.js} +1 -1
  80. package/ui-dist/assets/{ganttDiagram-NO4QXBWP-ZovCvOAJ.js → ganttDiagram-NO4QXBWP-1d0KDwQs.js} +1 -1
  81. package/ui-dist/assets/{gitGraphDiagram-IHSO6WYX-CqBEHQAs.js → gitGraphDiagram-IHSO6WYX-COLjS1ZR.js} +1 -1
  82. package/ui-dist/assets/{graph-ClsHEbyV.js → graph-B7fcgpw_.js} +1 -1
  83. package/ui-dist/assets/{index-BeOqvf7L.js → index-B6zSdXAR.js} +1 -1
  84. package/ui-dist/assets/{index-Dd7fnO2Z.js → index-BczgTMAn.js} +1 -1
  85. package/ui-dist/assets/{index-kq-WskyQ.js → index-CH8I9acP.js} +1 -1
  86. package/ui-dist/assets/{index-Cv5Jhfkz.js → index-CMNULCMJ.js} +1 -1
  87. package/ui-dist/assets/{index-BCGk5KQX.js → index-COLwjKBR.js} +1 -1
  88. package/ui-dist/assets/{index-BDk7B-iN.js → index-CTIfCQqR.js} +1 -1
  89. package/ui-dist/assets/{index-DfoLd51a.js → index-CXg1YCeI.js} +1 -1
  90. package/ui-dist/assets/{index-B1A7LikO.js → index-CZYXpHv4.js} +1 -1
  91. package/ui-dist/assets/{index-FPebsItp.js → index-CbqgXGcs.js} +1 -1
  92. package/ui-dist/assets/{index-CkFvrO-z.js → index-CgkYyYx9.js} +1 -1
  93. package/ui-dist/assets/{index-FgEEryl0.js → index-D27Bbc-x.js} +1 -1
  94. package/ui-dist/assets/{index-Cv6MlpIo.js → index-DTc5LpTU.js} +1 -1
  95. package/ui-dist/assets/{index-CxDxuCus.js → index-Denv6wuU.js} +1 -1
  96. package/ui-dist/assets/{index-BXtyqqSu.js → index-DttnaNlV.js} +534 -529
  97. package/ui-dist/assets/index-RSbihTRP.css +32 -0
  98. package/ui-dist/assets/{index-Cgo8Oik4.js → index-vtghjwab.js} +1 -1
  99. package/ui-dist/assets/{infoDiagram-FWYZ7A6U-DZJsMi0N.js → infoDiagram-FWYZ7A6U-Bg4YQUu2.js} +1 -1
  100. package/ui-dist/assets/{ishikawaDiagram-FXEZZL3T-7VX262KJ.js → ishikawaDiagram-FXEZZL3T-BtgUVI_I.js} +1 -1
  101. package/ui-dist/assets/{journeyDiagram-5HDEW3XC-W9pqd9nR.js → journeyDiagram-5HDEW3XC-BGHGjvN4.js} +1 -1
  102. package/ui-dist/assets/{kanban-definition-HUTT4EX6-eSHDQWV5.js → kanban-definition-HUTT4EX6-DekQSNo8.js} +1 -1
  103. package/ui-dist/assets/{layout-BxwzAdvW.js → layout-Bsw9hK6u.js} +1 -1
  104. package/ui-dist/assets/{linear-D6gDQD1r.js → linear-D8D1R-4C.js} +1 -1
  105. package/ui-dist/assets/{map-Dl8Tlr4E.js → map-BUIcuf4c.js} +1 -1
  106. package/ui-dist/assets/{mermaid.core-DqGHAs5q.js → mermaid.core-CYZMLemV.js} +4 -4
  107. package/ui-dist/assets/{mindmap-definition-LN4V7U3C-DlkWbxIe.js → mindmap-definition-LN4V7U3C-mjS9avIS.js} +1 -1
  108. package/ui-dist/assets/{pegDiagram-2B236MQR-Cc49Opte.js → pegDiagram-2B236MQR-Buziry9m.js} +1 -1
  109. package/ui-dist/assets/{pieDiagram-ENE6RG2P-Cso_iAzG.js → pieDiagram-ENE6RG2P-B_9BmFEg.js} +1 -1
  110. package/ui-dist/assets/{quadrantDiagram-ABIIQ3AL-FKJGDnHG.js → quadrantDiagram-ABIIQ3AL-BxFdUA8s.js} +1 -1
  111. package/ui-dist/assets/{railroadDiagram-RFXS5EU6-BqBQCfZ_.js → railroadDiagram-RFXS5EU6-pJh_afC-.js} +1 -1
  112. package/ui-dist/assets/{requirementDiagram-TGXJPOKE-CSkS2SPX.js → requirementDiagram-TGXJPOKE-BGgk3AxL.js} +1 -1
  113. package/ui-dist/assets/{sankeyDiagram-HTMAVEWB-CgnZO3lC.js → sankeyDiagram-HTMAVEWB-DdPKE4bs.js} +1 -1
  114. package/ui-dist/assets/{sequenceDiagram-DBY2YBRQ-DHtt0uuq.js → sequenceDiagram-DBY2YBRQ-xlik6FjZ.js} +1 -1
  115. package/ui-dist/assets/{sizeCapture-X5ZJPWSS-CApvjjgj.js → sizeCapture-X5ZJPWSS-D_zKAjvf.js} +1 -1
  116. package/ui-dist/assets/{stateDiagram-2N3HPSRC-DvJNOzm2.js → stateDiagram-2N3HPSRC-BGQP8giG.js} +1 -1
  117. package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-BMEtuB93.js +1 -0
  118. package/ui-dist/assets/{swimlanes-5IMT3BWC-DfQGr1Ph.js → swimlanes-5IMT3BWC-ZhE8oAxR.js} +2 -2
  119. package/ui-dist/assets/swimlanesDiagram-G3AALYLV-Bdh18WfM.js +8 -0
  120. package/ui-dist/assets/{timeline-definition-FHXFAJF6-BfEt2pSH.js → timeline-definition-FHXFAJF6-CUqfijnL.js} +1 -1
  121. package/ui-dist/assets/{vennDiagram-L72KCM5P-BwnjAS5O.js → vennDiagram-L72KCM5P-B_rqTUA0.js} +1 -1
  122. package/ui-dist/assets/{wardleyDiagram-EHGQE667-I4H5G4bu.js → wardleyDiagram-EHGQE667-BTvjybDi.js} +1 -1
  123. package/ui-dist/assets/{xterm-Bx_bzS86.js → xterm-CRpDYL2s.js} +1 -1
  124. package/ui-dist/assets/{xychartDiagram-FW5EYKEG-c9wafyO4.js → xychartDiagram-FW5EYKEG-ZBbwueZ5.js} +1 -1
  125. package/ui-dist/index.html +2 -2
  126. package/ui-dist/assets/channel-Dw8qUeMo.js +0 -1
  127. package/ui-dist/assets/classDiagram-OUVF2IWQ-BP_GJixo.js +0 -1
  128. package/ui-dist/assets/classDiagram-v2-EOCWNBFH-BP_GJixo.js +0 -1
  129. package/ui-dist/assets/index-WqUafwTi.css +0 -32
  130. package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-B_eJRf5W.js +0 -1
  131. package/ui-dist/assets/swimlanesDiagram-G3AALYLV-BrIPYwzL.js +0 -8
@@ -55,6 +55,7 @@ operating-practices guide for operating behavior:
55
55
  | `rudder_goal_list` | `rudder goal list [--lifecycle <draft|active|closed|all>] [--focus <true|false>] [--facet <facet>] [--limit <n>]` | Discover Goals owned by the authenticated Agent; defaults to active Goals and returns current progress, next step, and attention state. | no | required | required | no |
56
56
  | `rudder_goal_context` | `rudder goal context <goal-id>` | Read the owned Goal agreement and current operating context before acting: contract revision, criteria, boundaries, progress, next step, attention, proposals, and recent feedback. | no | no | required | no |
57
57
  | `rudder_goal_progress` | `rudder goal progress <goal-id> --summary <text> --evidence-refs <json> --idempotency-key <key>` | Record evidence-backed progress for a Goal owned by the authenticated Agent and attribute it to the current Run. | yes | no | required | required |
58
+ | `rudder_goal_checkpoint` | `rudder goal checkpoint <goal-id> --summary <text> --evidence-refs <json> --expected-plan-revision <n> --continuation <json> --idempotency-key <key>` | Atomically persist a Goal checkpoint, optional Plan revision, continuation, checkpoint activity, and eligible automatic continuation wake. | yes | no | required | required |
58
59
  | `rudder_goal_change_propose` | `rudder goal change propose <goal-id> --contract-revision <n> --after-contract <json> --rationale <text> --idempotency-key <key>` | Propose a reviewable change to the current Goal contract when evidence shows its outcome, criteria, boundaries, or deadlines should change. | yes | no | required | required |
59
60
  | `rudder_goal_result_propose` | `rudder goal result propose <goal-id> --contract-revision <n> --criteria <json> --evidence-refs <json> --risk-summary <text> --idempotency-key <key>` | Submit an evidence-backed Goal result for mandatory human acceptance without closing the Goal. | yes | no | required | required |
60
61
  | `rudder_issue_get` | `rudder issue get <issue>` | Read a full issue by UUID or identifier. | no | no | no | no |
@@ -129,13 +130,13 @@ operating-practices guide for operating behavior:
129
130
  | `rudder_automation_run` | `rudder automation run <automation-id>` | Trigger a manual automation run. | yes | no | no | attached when available |
130
131
  | `rudder_chat_list` | `rudder chat list --org-id <id>` | List chat conversations without dumping full message history. | no | required | no | no |
131
132
  | `rudder_chat_search` | `rudder chat search <query> --org-id <id>` | Search chats with bounded snippets and optional scope filtering. | no | required | no | no |
132
- | `rudder_chat_get` | `rudder chat get <chat-id>` | Read one chat conversation record. | no | no | no | no |
133
- | `rudder_chat_messages` | `rudder chat messages <chat-id> [--limit <n>] [--cursor <cursor>] [--include-transcript]` | Read bounded chat messages with page cursors; transcript output is omitted unless requested. | no | no | no | no |
134
- | `rudder_chat_transcript` | `rudder chat transcript <chat-id> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]` | Read paginated chat messages with assistant transcript entries clipped in human output. | no | no | no | no |
135
- | `rudder_chat_read` | `rudder chat read <chat-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]` | Read a bounded recent-message snapshot for one chat with page cursors. | no | no | no | no |
133
+ | `rudder_chat_get` | `rudder chat get <chat-id-or-cht-ref>` | Read one chat conversation record. | no | no | no | no |
134
+ | `rudder_chat_messages` | `rudder chat messages <chat-id-or-cht-ref> [--limit <n>] [--cursor <cursor>] [--include-transcript]` | Read bounded chat messages with page cursors; transcript output is omitted unless requested. | no | no | no | no |
135
+ | `rudder_chat_transcript` | `rudder chat transcript <chat-id-or-cht-ref> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]` | Read paginated chat messages with assistant transcript entries clipped in human output. | no | no | no | no |
136
+ | `rudder_chat_read` | `rudder chat read <chat-id-or-cht-ref> [--turn-limit <n>] [--cursor <cursor>] [--include-output]` | Read a bounded recent-message snapshot for one chat with page cursors. | no | no | no | no |
136
137
  | `rudder_chat_create` | `rudder chat create --org-id <id> --body <text>` | Create a chat conversation with its first message. | yes | required | no | attached when available |
137
- | `rudder_chat_send` | `rudder chat send <chat-id> --body <text>` | Send an agent-authored message directly to the operator in a chat. | yes | no | required | attached when available |
138
- | `rudder_chat_archive` | `rudder chat archive <chat-id>` | Archive a chat conversation without deleting it. | yes | no | no | attached when available |
138
+ | `rudder_chat_send` | `rudder chat send <chat-id-or-cht-ref> --body <text>` | Send an agent-authored message directly to the operator in a chat. | yes | no | required | attached when available |
139
+ | `rudder_chat_archive` | `rudder chat archive <chat-id-or-cht-ref>` | Archive a chat conversation without deleting it. | yes | no | no | attached when available |
139
140
  | `rudder_runs_list` | `rudder runs list --org-id <id> [--used-skill <skill>] [--loaded-skill <skill>] [--cursor <cursor>] [--full]` | List lightweight run summaries with stable pagination and filters; use --full only for legacy full-row compatibility. | no | required | no | no |
140
141
  | `rudder_runs_by_skill` | `rudder runs by-skill <skill> --org-id <id> [--evidence <used-or-loaded>] [--cursor <cursor>] [--full]` | Build a paginated skill evidence packet from lightweight run summaries; use --full only for legacy full-row compatibility. | no | required | no | no |
141
142
  | `rudder_runs_get` | `rudder runs get <run-id> [--full]` | Read one bounded run summary; use --full only from a direct trusted CLI for raw detail. | no | no | no | no |
@@ -158,6 +159,8 @@ Issue comment and close-out commands accept comment bodies only from files or st
158
159
 
159
160
  Issue comment responses include `shortRef` when available. `rudder issue comments get <issue> <comment-id-or-cmt-ref>` accepts a full comment UUID or `cmt_<uuid-prefix>`, and `rudder issue comments list <issue> --after <comment-id-or-cmt-ref>` accepts the same forms for the pagination anchor. Use the full UUID when a short ref is ambiguous within the issue.
160
161
 
162
+ Chat conversation responses include `shortRef` when available. Chat read and mutation commands accept the organization-scoped `cht_<uuid-prefix>` value or the full conversation UUID. Human-readable `chat list` and `chat search` output prefers `shortRef`; `--json` retains both `id` and `shortRef`, and `--full-ids` preserves the durable UUID value in `id`. Use the full UUID when a short ref is ambiguous.
163
+
161
164
  `--image` may be repeated. The CLI uploads each local PNG/JPEG/WebP/GIF as an issue attachment and appends Markdown image links to the comment text before sending it.
162
165
 
163
166
  ## Renderable Library CLI Output
@@ -1 +1 @@
1
- import{u as z,a as ee,b as re,r as l,c as Q,q as D,i as H,d as $,w as te,j as e,W as ne,T as ae,F as I,e as se,M as oe,f as ie,g as le,C as Z,h as ce,k as ue,l as de,m as fe,n as me,o as he,s as B,p as A,t as M,v as xe,x as G,y as ye,z as be,A as J,B as pe,R as ve,D as we}from"./index-BXtyqqSu.js";const U="This file changed while you were editing it.";function ke(b){return b.split("/").filter(Boolean).at(-1)??b}function ge(b){return!(b.truncated||b.previewKind!=="text"||b.content===null)}function je(b){return/\.(?:md|markdown|mdown|mdx)$/i.test(b.filePath)}function Fe({annotationConversationId:b,file:E,organizationId:t,sourceToolbar:K}){const n=me(),s=E.filePath,v=E.content??"",C=l.useRef(he(t,s,v)).current,u=l.useRef(!0),m=l.useRef(C.baseContent),P=l.useRef(v),d=l.useRef(C.content),w=l.useRef(null),L=l.useRef(!1),i=l.useRef(C.conflicted),y=l.useRef(0),[x,g]=l.useState(C.content),[_,h]=l.useState(C.conflicted?"error":C.content===v?"saved":"saving"),[R,c]=l.useState(C.conflicted?U:null),S=l.useRef(null),[N,a]=l.useState(null),j=je(E);d.current=x,P.current=v,l.useEffect(()=>(u.current=!0,()=>{u.current=!1,B(t,s,m.current,d.current)}),[s,t]),l.useEffect(()=>{if(v!==m.current){if(v===d.current){m.current=v,i.current=!1,h("saved"),c(null),A(t,s);return}if(d.current===m.current){m.current=v,d.current=v,g(v),i.current=!1,h("saved"),c(null),A(t,s);return}w.current=null,y.current+=1,i.current=!0,h("error"),c(U),B(t,s,m.current,d.current)}},[s,t,v]);const W=l.useCallback((o,r)=>{const f=o.content??r;m.current=f,P.current=f,i.current=!1,n.setQueryData(D.organizations.workspaceFile(t,s),o),B(t,s,f,d.current),d.current!==f&&(w.current=d.current),u.current&&(c(null),h(d.current===f?"saved":"saving"))},[s,t,n]),O=l.useCallback(async()=>{if(!L.current){L.current=!0;try{for(;w.current!==null;){const o=w.current,r=y.current;if(w.current=null,i.current)return;if(o!==m.current){u.current&&(h("saving"),c(null));try{const f=await M.updateWorkspaceFile(t,s,{content:o,expectedContent:m.current});if(r!==y.current)continue;W(f,o)}catch(f){if(r!==y.current)continue;let p=null;try{p=await M.readWorkspaceFile(t,s)}catch{}if(r!==y.current)continue;if(p&&(P.current=p.content??"",n.setQueryData(D.organizations.workspaceFile(t,s),p)),(p==null?void 0:p.content)===o){W(p,o);continue}p&&p.content!==m.current&&(w.current=null,i.current=!0,B(t,s,m.current,d.current)),u.current&&(h("error"),c(i.current?U:f instanceof Error?f.message:"Could not save this file."));return}}}u.current&&h(d.current===m.current?"saved":"saving")}finally{L.current=!1,w.current!==null&&!i.current&&O()}}},[W,s,t,n]),T=l.useCallback(o=>{w.current=o,O()},[O]);l.useEffect(()=>{if(B(t,s,m.current,x),i.current)return;if(x===m.current){h(L.current||w.current!==null?"saving":"saved");return}const o=window.setTimeout(()=>T(x),700);return()=>window.clearTimeout(o)},[x,T,s,t]);const q=()=>{const o=P.current;y.current+=1,m.current=o,d.current=o,w.current=null,i.current=!1,g(o),h("saved"),c(null),A(t,s)},F=()=>{y.current+=1,m.current=P.current,i.current=!1,h("saving"),c(null),T(d.current)},k=j?xe(x):{frontmatter:null,separator:"",body:x};return e.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden","data-testid":j?"library-live-surface-markdown-editor":"library-live-surface-text-editor",children:[K,e.jsx("div",{ref:S,className:J("min-h-0 flex-1",j?"scrollbar-auto-hide overflow-y-auto px-6 py-6":"overflow-hidden"),children:j?e.jsxs(e.Fragment,{children:[k.frontmatter!==null?e.jsxs("details",{className:"group mb-6 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-page)]","data-chat-annotation-ignore":!0,"data-testid":"library-live-surface-frontmatter-editor",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:"Frontmatter"}),e.jsx(Z,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),e.jsx("textarea",{value:k.frontmatter,onChange:o=>{const r=G(o.currentTarget.value,k.separator,k.body);d.current=r,g(r),h(i.current?"error":"saving"),i.current||c(null)},spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-[color:var(--border-soft)] bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,e.jsx(ye,{engine:"codemirror",documentIdentity:`library-file:${s}`,value:k.body,onChange:o=>{const r=G(k.frontmatter,k.separator,o);d.current=r,g(r),h(i.current?"error":"saving"),i.current||c(null)},bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-readable-document mx-auto min-h-[420px] w-full max-w-[880px] text-[15px] leading-7 text-foreground"},s)]}):e.jsx(be,{"data-testid":"library-live-surface-text-source-editor",annotationSource:{surface:"workspace_file",sourceFilePath:s},ariaLabel:`${s} source editor`,filePath:s,value:x,onChange:o=>{d.current=o,g(o),h(i.current?"error":"saving"),i.current||c(null)},onSelectionChange:a})}),e.jsx(pe,{containerRef:S,conversationId:b,explicitSelection:j?void 0:N,saved:_==="saved"&&!i.current&&x===m.current,source:x,sourceIdentity:{surface:"workspace_file",sourceFilePath:s,sourceLibraryEntryId:E.libraryEntryId},sourceRenderMode:j?"markdown":"text",renderedSource:j?k.body:x,renderedSourceOffset:j?x.length-k.body.length:0}),e.jsxs("div",{className:J("flex min-h-10 shrink-0 items-center gap-2 border-t border-border/70 px-4 text-xs",_==="error"?"text-destructive":"text-muted-foreground"),role:_==="error"?"alert":"status",children:[e.jsx("span",{children:_==="saved"?"Saved":_==="saving"?"Saving…":R??"Save failed"}),i.current?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:F,children:"Keep mine"}),e.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:q,children:"Use latest"})]}):_==="error"?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 font-medium text-foreground underline underline-offset-2",onClick:()=>T(d.current),children:[e.jsx(ve,{className:"h-3 w-3","aria-hidden":!0}),"Retry"]}):null]})]})}function X(b){return e.jsx("div",{className:"m-auto max-w-sm px-6 py-10 text-center text-sm leading-6 text-muted-foreground","data-testid":"library-live-surface-unavailable",role:"status",children:b})}function Pe({active:b,annotationConversationId:E=null,organizationId:t,surface:K,target:n,onOpenTarget:s}){var k,o;const{pushToast:v}=z(),V=ee(),C=re(),u=fe(),[m,P]=l.useState([]),[d,w]=l.useState(null),[L,i]=l.useState("preview"),y=n.kind==="library_entry"?n:null,x=n.kind==="library_document"?n:null,g=n.kind==="library_directory"?n:null,_=n.kind==="library_file"?n.filePath:(y==null?void 0:y.path)??null,h=Q({queryKey:D.organizations.libraryEntry(t,(y==null?void 0:y.entryId)??"__none__"),queryFn:()=>M.getLibraryEntry(t,y.entryId),enabled:!!y,refetchOnWindowFocus:!1}),R=_??(((k=h.data)==null?void 0:k.status)==="active"?h.data.currentPath:null),c=Q({queryKey:D.organizations.workspaceFile(t,R??""),queryFn:()=>M.readWorkspaceFile(t,R),enabled:(n.kind==="library_file"||n.kind==="library_entry")&&!!R,refetchOnWindowFocus:!1}),S=Q({queryKey:D.organizations.libraryDocument(t,(x==null?void 0:x.documentId)??"__none__"),queryFn:()=>M.getLibraryDocument(t,x.documentId),enabled:!!x,refetchOnWindowFocus:!1}),N=Q({queryKey:D.organizations.workspaceFiles(t,(g==null?void 0:g.directoryPath)??""),queryFn:()=>M.listWorkspaceFiles(t,g.directoryPath),enabled:!!g,refetchOnWindowFocus:!1}),a=c.data,j=a?H(a)||$(a):!1;l.useEffect(()=>{i("preview")},[R]);const W=te(m,{canOpenFile:!!(a!=null&&a.rootPath&&typeof(u==null?void 0:u.openWorkspaceFileInIde)=="function"),canOpenLocation:!!(a!=null&&a.rootPath&&typeof(u==null?void 0:u.openWorkspaceFileLocation)=="function")});l.useEffect(()=>{let r=!1;if(!(a!=null&&a.rootPath)||typeof(u==null?void 0:u.listWorkspaceLaunchTargets)!="function"){P([]);return}return u.listWorkspaceLaunchTargets().then(f=>{r||P(f)}).catch(()=>{r||P([])}),()=>{r=!0}},[u,a==null?void 0:a.rootPath]);const O=async r=>{var f;if(!(!(a!=null&&a.rootPath)||!u)){w(r.id);try{we(r)?await u.openWorkspaceFileInIde(a.rootPath,a.filePath,r.id):await((f=u.openWorkspaceFileLocation)==null?void 0:f.call(u,a.rootPath,a.filePath,r.id)),v({title:`Opened in ${r.label}`,tone:"success"})}catch(p){v({title:`Could not open in ${r.label}`,body:p instanceof Error?p.message:"Try another app.",tone:"error"})}finally{w(null)}}},T=!!(n.kind==="library_entry"&&h.isPending||(n.kind==="library_file"||n.kind==="library_entry")&&R&&c.isPending||n.kind==="library_document"&&S.isPending||n.kind==="library_directory"&&N.isPending),q=n.kind==="library_entry"?h.error??c.error:n.kind==="library_file"?c.error:n.kind==="library_document"?S.error:N.error;let F;return T?F=e.jsx("div",{className:"m-auto text-sm text-muted-foreground","data-testid":"library-live-surface-loading",children:"Loading Library item…"}):q?F=e.jsx("div",{className:"m-auto max-w-sm px-6 py-10 text-center text-sm leading-6 text-destructive","data-testid":"library-live-surface-error",role:"alert",children:q instanceof Error?q.message:"Could not open this Library item."}):n.kind==="library_entry"&&!R?F=X(((o=h.data)==null?void 0:o.status)==="deleted"?"This Library entry was deleted.":"This Library entry is unavailable on its original path."):(n.kind==="library_file"||n.kind==="library_entry")&&c.data?F=ge(c.data)&&(!j||L==="source")?e.jsx(Fe,{annotationConversationId:E,file:c.data,organizationId:t,sourceToolbar:H(c.data)?e.jsx(ne,{viewMode:"source",onViewModeChange:i,testIdPrefix:"library-live-surface"}):$(c.data)?e.jsx("div",{className:"flex h-10 shrink-0 items-center justify-end border-b border-border px-3",children:e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>i("preview"),"aria-label":"Show table",children:[e.jsx(ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Show table"]})}):void 0},c.data.filePath):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden","data-testid":"library-live-surface-file-preview",children:[$(c.data)?e.jsx("div",{className:"flex h-10 shrink-0 items-center justify-end border-b border-border px-3",children:e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>i("source"),"aria-label":"Show source",children:[e.jsx(I,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Show source"]})}):null,e.jsx(se,{file:c.data,organizationId:t,mode:L,onModeChange:i,testIdPrefix:"library-live-surface"})]}):n.kind==="library_document"&&S.data?F=e.jsx("article",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-8 py-8","data-testid":"library-live-surface-document",children:e.jsx(oe,{className:"rudder-library-document-editor rudder-readable-document mx-auto w-full max-w-[880px] text-[15px] leading-7 text-foreground",children:S.data.body})}):n.kind==="library_directory"&&N.data?F=e.jsxs("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto p-3","data-testid":"library-live-surface-directory",children:[e.jsxs("div",{className:"mb-3 px-2",children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:N.data.directoryPath||"Library root"}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[N.data.entries.length," item",N.data.entries.length===1?"":"s"]})]}),e.jsx("ul",{className:"space-y-0.5 border-t border-border/70 pt-2",children:N.data.entries.map(r=>{var Y;const f=((Y=r.displayLabel)==null?void 0:Y.trim())||r.name,p=r.isDirectory?ie:/\.(?:md|markdown|mdx|txt)$/i.test(r.path)?le:I;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-[color:var(--surface-active)] hover:text-foreground",onClick:()=>s(r.isDirectory?{kind:"library_directory",directoryPath:r.path,label:f}:r.libraryEntryId?{kind:"library_entry",entryId:r.libraryEntryId,label:f,path:r.path}:{kind:"library_file",filePath:r.path,label:f||ke(r.path)}),children:[e.jsx(p,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),r.isDirectory?e.jsx(Z,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]})},r.path)})})]}):F=X("This Library item is unavailable."),e.jsxs("section",{"aria-hidden":!b,className:"flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-[color:var(--surface-panel)]","data-active":b?"true":"false","data-surface":K,"data-target-kind":n.kind,"data-testid":"library-live-surface",children:[a&&W.length>0?e.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-border/70 px-4","data-testid":"library-live-surface-file-toolbar",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:a.filePath}),e.jsx("div",{"data-testid":"library-live-surface-file-open-selector",children:e.jsx(ce,{targets:W,openingTargetId:d,onOpenTarget:r=>void O(r),onOpenInLibrary:()=>C(ue(`/library?path=${encodeURIComponent(a.filePath)}`,de(V.pathname))),testId:"library-live-surface-file-open-menu"})})]}):null,F]})}export{Pe as LibraryLiveSurface};
1
+ import{u as z,a as ee,b as re,r as l,c as Q,q as D,i as H,d as $,w as te,j as e,W as ne,T as ae,F as I,e as se,M as oe,f as ie,g as le,C as Z,h as ce,k as ue,l as de,m as fe,n as me,o as he,s as B,p as A,t as M,v as xe,x as G,y as ye,z as be,A as J,B as pe,R as ve,D as we}from"./index-DttnaNlV.js";const U="This file changed while you were editing it.";function ke(b){return b.split("/").filter(Boolean).at(-1)??b}function ge(b){return!(b.truncated||b.previewKind!=="text"||b.content===null)}function je(b){return/\.(?:md|markdown|mdown|mdx)$/i.test(b.filePath)}function Fe({annotationConversationId:b,file:E,organizationId:t,sourceToolbar:K}){const n=me(),s=E.filePath,v=E.content??"",C=l.useRef(he(t,s,v)).current,u=l.useRef(!0),m=l.useRef(C.baseContent),P=l.useRef(v),d=l.useRef(C.content),w=l.useRef(null),L=l.useRef(!1),i=l.useRef(C.conflicted),y=l.useRef(0),[x,g]=l.useState(C.content),[_,h]=l.useState(C.conflicted?"error":C.content===v?"saved":"saving"),[R,c]=l.useState(C.conflicted?U:null),S=l.useRef(null),[N,a]=l.useState(null),j=je(E);d.current=x,P.current=v,l.useEffect(()=>(u.current=!0,()=>{u.current=!1,B(t,s,m.current,d.current)}),[s,t]),l.useEffect(()=>{if(v!==m.current){if(v===d.current){m.current=v,i.current=!1,h("saved"),c(null),A(t,s);return}if(d.current===m.current){m.current=v,d.current=v,g(v),i.current=!1,h("saved"),c(null),A(t,s);return}w.current=null,y.current+=1,i.current=!0,h("error"),c(U),B(t,s,m.current,d.current)}},[s,t,v]);const W=l.useCallback((o,r)=>{const f=o.content??r;m.current=f,P.current=f,i.current=!1,n.setQueryData(D.organizations.workspaceFile(t,s),o),B(t,s,f,d.current),d.current!==f&&(w.current=d.current),u.current&&(c(null),h(d.current===f?"saved":"saving"))},[s,t,n]),O=l.useCallback(async()=>{if(!L.current){L.current=!0;try{for(;w.current!==null;){const o=w.current,r=y.current;if(w.current=null,i.current)return;if(o!==m.current){u.current&&(h("saving"),c(null));try{const f=await M.updateWorkspaceFile(t,s,{content:o,expectedContent:m.current});if(r!==y.current)continue;W(f,o)}catch(f){if(r!==y.current)continue;let p=null;try{p=await M.readWorkspaceFile(t,s)}catch{}if(r!==y.current)continue;if(p&&(P.current=p.content??"",n.setQueryData(D.organizations.workspaceFile(t,s),p)),(p==null?void 0:p.content)===o){W(p,o);continue}p&&p.content!==m.current&&(w.current=null,i.current=!0,B(t,s,m.current,d.current)),u.current&&(h("error"),c(i.current?U:f instanceof Error?f.message:"Could not save this file."));return}}}u.current&&h(d.current===m.current?"saved":"saving")}finally{L.current=!1,w.current!==null&&!i.current&&O()}}},[W,s,t,n]),T=l.useCallback(o=>{w.current=o,O()},[O]);l.useEffect(()=>{if(B(t,s,m.current,x),i.current)return;if(x===m.current){h(L.current||w.current!==null?"saving":"saved");return}const o=window.setTimeout(()=>T(x),700);return()=>window.clearTimeout(o)},[x,T,s,t]);const q=()=>{const o=P.current;y.current+=1,m.current=o,d.current=o,w.current=null,i.current=!1,g(o),h("saved"),c(null),A(t,s)},F=()=>{y.current+=1,m.current=P.current,i.current=!1,h("saving"),c(null),T(d.current)},k=j?xe(x):{frontmatter:null,separator:"",body:x};return e.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden","data-testid":j?"library-live-surface-markdown-editor":"library-live-surface-text-editor",children:[K,e.jsx("div",{ref:S,className:J("min-h-0 flex-1",j?"scrollbar-auto-hide overflow-y-auto px-6 py-6":"overflow-hidden"),children:j?e.jsxs(e.Fragment,{children:[k.frontmatter!==null?e.jsxs("details",{className:"group mb-6 rounded-md border border-[color:var(--border-soft)] bg-[color:var(--surface-page)]","data-chat-annotation-ignore":!0,"data-testid":"library-live-surface-frontmatter-editor",children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2 text-xs font-medium text-muted-foreground outline-none transition-colors hover:text-foreground [&::-webkit-details-marker]:hidden",children:[e.jsx("span",{children:"Frontmatter"}),e.jsx(Z,{className:"h-3.5 w-3.5 transition-transform group-open:rotate-90"})]}),e.jsx("textarea",{value:k.frontmatter,onChange:o=>{const r=G(o.currentTarget.value,k.separator,k.body);d.current=r,g(r),h(i.current?"error":"saving"),i.current||c(null)},spellCheck:!1,className:"block min-h-28 w-full resize-y border-t border-[color:var(--border-soft)] bg-transparent px-3 py-2 font-mono text-xs leading-5 text-foreground outline-none","aria-label":"Frontmatter"})]}):null,e.jsx(ye,{engine:"codemirror",documentIdentity:`library-file:${s}`,value:k.body,onChange:o=>{const r=G(k.frontmatter,k.separator,o);d.current=r,g(r),h(i.current?"error":"saving"),i.current||c(null)},bordered:!1,placeholder:"Write in Markdown...",contentClassName:"rudder-library-document-editor rudder-readable-document mx-auto min-h-[420px] w-full max-w-[880px] text-[15px] leading-7 text-foreground"},s)]}):e.jsx(be,{"data-testid":"library-live-surface-text-source-editor",annotationSource:{surface:"workspace_file",sourceFilePath:s},ariaLabel:`${s} source editor`,filePath:s,value:x,onChange:o=>{d.current=o,g(o),h(i.current?"error":"saving"),i.current||c(null)},onSelectionChange:a})}),e.jsx(pe,{containerRef:S,conversationId:b,explicitSelection:j?void 0:N,saved:_==="saved"&&!i.current&&x===m.current,source:x,sourceIdentity:{surface:"workspace_file",sourceFilePath:s,sourceLibraryEntryId:E.libraryEntryId},sourceRenderMode:j?"markdown":"text",renderedSource:j?k.body:x,renderedSourceOffset:j?x.length-k.body.length:0}),e.jsxs("div",{className:J("flex min-h-10 shrink-0 items-center gap-2 border-t border-border/70 px-4 text-xs",_==="error"?"text-destructive":"text-muted-foreground"),role:_==="error"?"alert":"status",children:[e.jsx("span",{children:_==="saved"?"Saved":_==="saving"?"Saving…":R??"Save failed"}),i.current?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:F,children:"Keep mine"}),e.jsx("button",{type:"button",className:"font-medium text-foreground underline underline-offset-2",onClick:q,children:"Use latest"})]}):_==="error"?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 font-medium text-foreground underline underline-offset-2",onClick:()=>T(d.current),children:[e.jsx(ve,{className:"h-3 w-3","aria-hidden":!0}),"Retry"]}):null]})]})}function X(b){return e.jsx("div",{className:"m-auto max-w-sm px-6 py-10 text-center text-sm leading-6 text-muted-foreground","data-testid":"library-live-surface-unavailable",role:"status",children:b})}function Pe({active:b,annotationConversationId:E=null,organizationId:t,surface:K,target:n,onOpenTarget:s}){var k,o;const{pushToast:v}=z(),V=ee(),C=re(),u=fe(),[m,P]=l.useState([]),[d,w]=l.useState(null),[L,i]=l.useState("preview"),y=n.kind==="library_entry"?n:null,x=n.kind==="library_document"?n:null,g=n.kind==="library_directory"?n:null,_=n.kind==="library_file"?n.filePath:(y==null?void 0:y.path)??null,h=Q({queryKey:D.organizations.libraryEntry(t,(y==null?void 0:y.entryId)??"__none__"),queryFn:()=>M.getLibraryEntry(t,y.entryId),enabled:!!y,refetchOnWindowFocus:!1}),R=_??(((k=h.data)==null?void 0:k.status)==="active"?h.data.currentPath:null),c=Q({queryKey:D.organizations.workspaceFile(t,R??""),queryFn:()=>M.readWorkspaceFile(t,R),enabled:(n.kind==="library_file"||n.kind==="library_entry")&&!!R,refetchOnWindowFocus:!1}),S=Q({queryKey:D.organizations.libraryDocument(t,(x==null?void 0:x.documentId)??"__none__"),queryFn:()=>M.getLibraryDocument(t,x.documentId),enabled:!!x,refetchOnWindowFocus:!1}),N=Q({queryKey:D.organizations.workspaceFiles(t,(g==null?void 0:g.directoryPath)??""),queryFn:()=>M.listWorkspaceFiles(t,g.directoryPath),enabled:!!g,refetchOnWindowFocus:!1}),a=c.data,j=a?H(a)||$(a):!1;l.useEffect(()=>{i("preview")},[R]);const W=te(m,{canOpenFile:!!(a!=null&&a.rootPath&&typeof(u==null?void 0:u.openWorkspaceFileInIde)=="function"),canOpenLocation:!!(a!=null&&a.rootPath&&typeof(u==null?void 0:u.openWorkspaceFileLocation)=="function")});l.useEffect(()=>{let r=!1;if(!(a!=null&&a.rootPath)||typeof(u==null?void 0:u.listWorkspaceLaunchTargets)!="function"){P([]);return}return u.listWorkspaceLaunchTargets().then(f=>{r||P(f)}).catch(()=>{r||P([])}),()=>{r=!0}},[u,a==null?void 0:a.rootPath]);const O=async r=>{var f;if(!(!(a!=null&&a.rootPath)||!u)){w(r.id);try{we(r)?await u.openWorkspaceFileInIde(a.rootPath,a.filePath,r.id):await((f=u.openWorkspaceFileLocation)==null?void 0:f.call(u,a.rootPath,a.filePath,r.id)),v({title:`Opened in ${r.label}`,tone:"success"})}catch(p){v({title:`Could not open in ${r.label}`,body:p instanceof Error?p.message:"Try another app.",tone:"error"})}finally{w(null)}}},T=!!(n.kind==="library_entry"&&h.isPending||(n.kind==="library_file"||n.kind==="library_entry")&&R&&c.isPending||n.kind==="library_document"&&S.isPending||n.kind==="library_directory"&&N.isPending),q=n.kind==="library_entry"?h.error??c.error:n.kind==="library_file"?c.error:n.kind==="library_document"?S.error:N.error;let F;return T?F=e.jsx("div",{className:"m-auto text-sm text-muted-foreground","data-testid":"library-live-surface-loading",children:"Loading Library item…"}):q?F=e.jsx("div",{className:"m-auto max-w-sm px-6 py-10 text-center text-sm leading-6 text-destructive","data-testid":"library-live-surface-error",role:"alert",children:q instanceof Error?q.message:"Could not open this Library item."}):n.kind==="library_entry"&&!R?F=X(((o=h.data)==null?void 0:o.status)==="deleted"?"This Library entry was deleted.":"This Library entry is unavailable on its original path."):(n.kind==="library_file"||n.kind==="library_entry")&&c.data?F=ge(c.data)&&(!j||L==="source")?e.jsx(Fe,{annotationConversationId:E,file:c.data,organizationId:t,sourceToolbar:H(c.data)?e.jsx(ne,{viewMode:"source",onViewModeChange:i,testIdPrefix:"library-live-surface"}):$(c.data)?e.jsx("div",{className:"flex h-10 shrink-0 items-center justify-end border-b border-border px-3",children:e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>i("preview"),"aria-label":"Show table",children:[e.jsx(ae,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Show table"]})}):void 0},c.data.filePath):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden","data-testid":"library-live-surface-file-preview",children:[$(c.data)?e.jsx("div",{className:"flex h-10 shrink-0 items-center justify-end border-b border-border px-3",children:e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>i("source"),"aria-label":"Show source",children:[e.jsx(I,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Show source"]})}):null,e.jsx(se,{file:c.data,organizationId:t,mode:L,onModeChange:i,testIdPrefix:"library-live-surface"})]}):n.kind==="library_document"&&S.data?F=e.jsx("article",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto px-8 py-8","data-testid":"library-live-surface-document",children:e.jsx(oe,{className:"rudder-library-document-editor rudder-readable-document mx-auto w-full max-w-[880px] text-[15px] leading-7 text-foreground",children:S.data.body})}):n.kind==="library_directory"&&N.data?F=e.jsxs("div",{className:"scrollbar-auto-hide min-h-0 flex-1 overflow-y-auto p-3","data-testid":"library-live-surface-directory",children:[e.jsxs("div",{className:"mb-3 px-2",children:[e.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:N.data.directoryPath||"Library root"}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[N.data.entries.length," item",N.data.entries.length===1?"":"s"]})]}),e.jsx("ul",{className:"space-y-0.5 border-t border-border/70 pt-2",children:N.data.entries.map(r=>{var Y;const f=((Y=r.displayLabel)==null?void 0:Y.trim())||r.name,p=r.isDirectory?ie:/\.(?:md|markdown|mdx|txt)$/i.test(r.path)?le:I;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-[color:var(--surface-active)] hover:text-foreground",onClick:()=>s(r.isDirectory?{kind:"library_directory",directoryPath:r.path,label:f}:r.libraryEntryId?{kind:"library_entry",entryId:r.libraryEntryId,label:f,path:r.path}:{kind:"library_file",filePath:r.path,label:f||ke(r.path)}),children:[e.jsx(p,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:f}),r.isDirectory?e.jsx(Z,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":!0}):null]})},r.path)})})]}):F=X("This Library item is unavailable."),e.jsxs("section",{"aria-hidden":!b,className:"flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden bg-[color:var(--surface-panel)]","data-active":b?"true":"false","data-surface":K,"data-target-kind":n.kind,"data-testid":"library-live-surface",children:[a&&W.length>0?e.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-border/70 px-4","data-testid":"library-live-surface-file-toolbar",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:a.filePath}),e.jsx("div",{"data-testid":"library-live-surface-file-open-selector",children:e.jsx(ce,{targets:W,openingTargetId:d,onOpenTarget:r=>void O(r),onOpenInLibrary:()=>C(ue(`/library?path=${encodeURIComponent(a.filePath)}`,de(V.pathname))),testId:"library-live-surface-file-open-menu"})})]}):null,F]})}export{Pe as LibraryLiveSurface};
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-BBqkM1ra.js";import{p as f}from"./chunk-JWPE2WC7-DZ-jdJNV.js";import{_ as n,l as o}from"./mermaid.core-DqGHAs5q.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-LqXNJWXt.js";import"./index-BXtyqqSu.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-OAoJna8Y.js";import{p as f}from"./chunk-JWPE2WC7-Bj9myT03.js";import{_ as n,l as o}from"./mermaid.core-CYZMLemV.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-DlDrrBWp.js";import"./index-DttnaNlV.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{aa as g}from"./index-BXtyqqSu.js";function _(i,s){for(var o=0;o<s.length;o++){const t=s[o];if(typeof t!="string"&&!Array.isArray(t)){for(const e in t)if(e!=="default"&&!(e in i)){const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var a={exports:{}},d;function y(){return d||(d=1,(function(i,s){(function(o,t){i.exports=t()})(self,(()=>(()=>{var o={};return(()=>{var t=o;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const r=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,r=e._renderService.dimensions;if(r.css.cell.width===0||r.css.cell.height===0)return;const c=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),m=parseInt(l.getPropertyValue("height")),u=Math.max(0,parseInt(l.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),h=m-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),f=u-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-c;return{cols:Math.max(2,Math.floor(f/r.css.cell.width)),rows:Math.max(1,Math.floor(h/r.css.cell.height))}}}})(),o})()))})(a)),a.exports}var p=y();const w=g(p),x=_({__proto__:null,default:w},[p]);export{x as a};
1
+ import{aa as g}from"./index-DttnaNlV.js";function _(i,s){for(var o=0;o<s.length;o++){const t=s[o];if(typeof t!="string"&&!Array.isArray(t)){for(const e in t)if(e!=="default"&&!(e in i)){const r=Object.getOwnPropertyDescriptor(t,e);r&&Object.defineProperty(i,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var a={exports:{}},d;function y(){return d||(d=1,(function(i,s){(function(o,t){i.exports=t()})(self,(()=>(()=>{var o={};return(()=>{var t=o;Object.defineProperty(t,"__esModule",{value:!0}),t.FitAddon=void 0,t.FitAddon=class{activate(e){this._terminal=e}dispose(){}fit(){const e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;const r=this._terminal._core;this._terminal.rows===e.rows&&this._terminal.cols===e.cols||(r._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const e=this._terminal._core,r=e._renderService.dimensions;if(r.css.cell.width===0||r.css.cell.height===0)return;const c=this._terminal.options.scrollback===0?0:e.viewport.scrollBarWidth,l=window.getComputedStyle(this._terminal.element.parentElement),m=parseInt(l.getPropertyValue("height")),u=Math.max(0,parseInt(l.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),h=m-(parseInt(n.getPropertyValue("padding-top"))+parseInt(n.getPropertyValue("padding-bottom"))),f=u-(parseInt(n.getPropertyValue("padding-right"))+parseInt(n.getPropertyValue("padding-left")))-c;return{cols:Math.max(2,Math.floor(f/r.css.cell.width)),rows:Math.max(1,Math.floor(h/r.css.cell.height))}}}})(),o})()))})(a)),a.exports}var p=y();const w=g(p),x=_({__proto__:null,default:w},[p]);export{x as a};
@@ -1 +1 @@
1
- import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-DqGHAs5q.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};
1
+ import{G as ln,H as un,I as N,J as I,K as J,L as an,M as y,N as tn,O as j,P as _,Q as rn,R as o,S as on,T as sn,V as fn}from"./mermaid.core-CYZMLemV.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,q,O,v,R,K,u){var D=q-l,i=O-h,n=K-v,d=u-R,a=d*D-n*i;if(!(a*a<y))return a=(n*(h-R)-d*(l-v))/a,[l+a*D,h+a*i]}function W(l,h,q,O,v,R,K){var u=l-q,D=h-O,i=(K?R:-R)/j(u*u+D*D),n=i*D,d=-i*u,a=l+n,s=h+d,f=q+n,c=O+d,L=(a+f)/2,t=(s+c)/2,m=f-a,g=c-s,A=m*m+g*g,T=v-R,P=a*c-f*s,E=(g<0?-1:1)*j(on(0,T*T*A-P*P)),G=(P*g-m*E)/A,H=(-P*m-g*E)/A,w=(P*g+m*E)/A,p=(-P*m+g*E)/A,x=G-L,e=H-t,r=w-L,M=p-t;return x*x+e*e>r*r+M*M&&(G=w,H=p),{cx:G,cy:H,x01:-n,y01:-d,x11:G*(v/T-1),y11:H*(v/T-1)}}function hn(){var l=cn,h=yn,q=J(0),O=null,v=gn,R=dn,K=mn,u=null,D=ln(i);function i(){var n,d,a=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=R.apply(this,arguments)-an,L=rn(c-f),t=c>f;if(u||(u=n=D()),s<a&&(d=s,s=a,a=d),!(s>y))u.moveTo(0,0);else if(L>tn-y)u.moveTo(s*N(f),s*I(f)),u.arc(0,0,s,f,c,!t),a>y&&(u.moveTo(a*N(c),a*I(c)),u.arc(0,0,a,c,f,t));else{var m=f,g=c,A=f,T=c,P=L,E=L,G=K.apply(this,arguments)/2,H=G>y&&(O?+O.apply(this,arguments):j(a*a+s*s)),w=_(rn(s-a)/2,+q.apply(this,arguments)),p=w,x=w,e,r;if(H>y){var M=sn(H/a*I(G)),z=sn(H/s*I(G));(P-=M*2)>y?(M*=t?1:-1,A+=M,T-=M):(P=0,A=T=(f+c)/2),(E-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(E=0,m=g=(f+c)/2)}var Q=s*N(m),V=s*I(m),B=a*N(T),C=a*I(T);if(w>y){var F=s*N(g),U=s*I(g),X=a*N(A),Y=a*I(A),S;if(L<un)if(S=pn(Q,V,X,Y,F,U,B,C)){var Z=Q-S[0],$=V-S[1],k=F-S[0],b=U-S[1],nn=1/I(fn((Z*k+$*b)/(j(Z*Z+$*$)*j(k*k+b*b)))/2),en=j(S[0]*S[0]+S[1]*S[1]);p=_(w,(a-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}E>y?x>y?(e=W(X,Y,Q,V,s,x,t),r=W(F,U,B,C,s,x,t),u.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),u.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(u.moveTo(Q,V),u.arc(0,0,s,m,g,!t)):u.moveTo(Q,V),!(a>y)||!(P>y)?u.lineTo(B,C):p>y?(e=W(B,C,F,U,a,-p,t),r=W(Q,V,X,Y,a,-p,t),u.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(u.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),u.arc(0,0,a,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),u.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):u.arc(0,0,a,T,A,t)}if(u.closePath(),n)return u=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-un/2;return[N(d)*n,I(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:J(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:J(+n),i):h},i.cornerRadius=function(n){return arguments.length?(q=typeof n=="function"?n:J(+n),i):q},i.padRadius=function(n){return arguments.length?(O=n==null?null:typeof n=="function"?n:J(+n),i):O},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:J(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:J(+n),i):R},i.padAngle=function(n){return arguments.length?(K=typeof n=="function"?n:J(+n),i):K},i.context=function(n){return arguments.length?(u=n??null,i):u},i}export{hn as d};