mastra 1.40.1-alpha.2 → 1.40.1-alpha.3

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 (144) hide show
  1. package/dist/docs/SKILL.md +1 -1
  2. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  3. package/dist/factory/assets/{AlertDialog.es-m2GwqaQe.js → AlertDialog.es-CRAV1bgk.js} +1 -1
  4. package/dist/factory/assets/BoardConfigPage-D-WCrweQ.js +1 -0
  5. package/dist/factory/assets/BoardIcons-C0Z_7MKH.js +1 -0
  6. package/dist/factory/assets/BoardIntakePage-Dxnv1mb9.js +1 -0
  7. package/dist/factory/assets/BoardRulesPage-B1SfP3d1.js +1 -0
  8. package/dist/factory/assets/Breadcrumb.es-uNv7_2cQ.js +1 -0
  9. package/dist/factory/assets/{Card-D39faFV5-DGV7vLQ5.js → Card-D39faFV5-Cqy1nvNi.js} +1 -1
  10. package/dist/factory/assets/CodeBlock.es-CrOFghky.js +6 -0
  11. package/dist/factory/assets/{CodeEditor-AaW7HgY9-CDW12nEJ.js → CodeEditor-AaW7HgY9-CjZKkwJd.js} +1 -1
  12. package/dist/factory/assets/{Command.es-DQZoX6LN.js → Command.es-DVLsx9s1.js} +2 -2
  13. package/dist/factory/assets/{CompositeRoot-C6GQToPf.js → CompositeRoot-GT8aurLY.js} +1 -1
  14. package/dist/factory/assets/ConditionRows-CTCdJTDp.js +1 -0
  15. package/dist/factory/assets/CreateFactoryPage-B9WQVP2I.js +1 -0
  16. package/dist/factory/assets/DescriptionMarkdown-B2ihg8gR.js +1 -0
  17. package/dist/factory/assets/{FactorySkillPage-Cn7b7SxQ.js → FactorySkillPage-CS3lkZ9_.js} +2 -2
  18. package/dist/factory/assets/{FactorySkillsPage-6jz4NbVZ.js → FactorySkillsPage-C1FZvWte.js} +1 -1
  19. package/dist/factory/assets/Field.es-CaXwaCGT.js +1 -0
  20. package/dist/factory/assets/HoverCard.es-CbtJYu6d.js +1 -0
  21. package/dist/factory/assets/{HrefLink-B_YcI3fa.js → HrefLink--_RNppLy.js} +1 -1
  22. package/dist/factory/assets/IconArrowRight.es-B8AZJjlM.js +1 -0
  23. package/dist/factory/assets/{IconArrowRotateClockwise.es-DkOAEvUr.js → IconArrowRotateClockwise.es-4SyXOXYO.js} +1 -1
  24. package/dist/factory/assets/IconFormCircle.es-DASDokJW.js +1 -0
  25. package/dist/factory/assets/IconHand5Finger.es-B8Atsegj.js +1 -0
  26. package/dist/factory/assets/IconPlugin1.es-cRNReen7.js +1 -0
  27. package/dist/factory/assets/{IconScript.es-DFk5fubF.js → IconScript.es-DquD6yus.js} +1 -1
  28. package/dist/factory/assets/{Input-6I-Qqpre.js → Input-DhJAVsQb.js} +1 -1
  29. package/dist/factory/assets/InputNumber.es-CY2qYDqO.js +1 -0
  30. package/dist/factory/assets/KnowledgePage-B_vt21nZ.js +13 -0
  31. package/dist/factory/assets/{LoadErrorState-zp7tqBsa.js → LoadErrorState-CB-Vi72B.js} +1 -1
  32. package/dist/factory/assets/MarkdownRenderer-De9m5Xru-aK1mu_hc.js +85 -0
  33. package/dist/factory/assets/MastraGatewayBilling-4nRn6GVe.js +1 -0
  34. package/dist/factory/assets/NewBoardPage-DE6px8Cx.js +2 -0
  35. package/dist/factory/assets/NewPage-wM0jsWt5.js +1 -0
  36. package/dist/factory/assets/Notice-BhWgws6f-D26rmfPt.js +55 -0
  37. package/dist/factory/assets/{OnboardingPage-zdkQZaPw.js → OnboardingPage-B-_hxs4l.js} +1 -1
  38. package/dist/factory/assets/{ProviderBrandIcon-DiBXMn1F.js → ProviderBrandIcon-DC8OYNJH.js} +1 -1
  39. package/dist/factory/assets/RadioGroup-BlxomnWX.js +1 -0
  40. package/dist/factory/assets/{RadioGroup.es-CnNwDpty.js → RadioGroup.es-Brd0MEwi.js} +1 -1
  41. package/dist/factory/assets/{RootGuards-CwLuELS3.js → RootGuards-DS9XUgmB.js} +1 -1
  42. package/dist/factory/assets/{RulesPage-DNEkRJGr.js → RulesPage-oOFL7fc_.js} +1 -1
  43. package/dist/factory/assets/SearchInput.es-Hq6-9PoP.js +1 -0
  44. package/dist/factory/assets/SessionLayout-B7lP4AAV.js +4 -0
  45. package/dist/factory/assets/SessionPage-Ckk7H8AJ.js +1 -0
  46. package/dist/factory/assets/SessionSharingPopover-BmkoPxcV.js +1 -0
  47. package/dist/factory/assets/SettingsPage-CIVTHaoR.js +3 -0
  48. package/dist/factory/assets/{SettingsSubsection-C1yvQbJx.js → SettingsSubsection-CO08NR1O.js} +1 -1
  49. package/dist/factory/assets/Sidebar.es-etnaeLk8.js +1 -0
  50. package/dist/factory/assets/{SignInPage-DKrVbo4q.js → SignInPage-BvPG_UzC.js} +1 -1
  51. package/dist/factory/assets/SkeletonRows-Ct1odQMK.js +1 -0
  52. package/dist/factory/assets/{SkillBadges-CObnaKOu.js → SkillBadges-BFt5UQQL.js} +1 -1
  53. package/dist/factory/assets/{SlackConnectionPage-f_pUnRmJ.js → SlackConnectionPage-HJ_zftAm.js} +1 -1
  54. package/dist/factory/assets/{StackedDiffs-D5thPH3G.js → StackedDiffs-C57Cru0i.js} +3 -3
  55. package/dist/factory/assets/{ThinkingLevel.es-BkUQoXVi.js → ThinkingLevel.es-892uXWBi.js} +1 -1
  56. package/dist/factory/assets/TrashIcon.es-DNb97Rim.js +1 -0
  57. package/dist/factory/assets/{Tree-B90XgTY4-GZwE7YY8.js → Tree-B90XgTY4-Cyia4mk7.js} +1 -1
  58. package/dist/factory/assets/boardConfigPaths-Btimpi_r.js +1 -0
  59. package/dist/factory/assets/{buttons-group-DA_wORqQ-ZjnxyuCJ.js → buttons-group-DA_wORqQ-DlBf54ah.js} +1 -1
  60. package/dist/factory/assets/combobox-parts-Bmj5kzrt-PcITNZFp.js +1 -0
  61. package/dist/factory/assets/{copy-button-5PzdvEQI-BG6Brssj.js → copy-button-5PzdvEQI-NsU3f0kN.js} +1 -1
  62. package/dist/factory/assets/index-BTe7cRAB.js +125 -0
  63. package/dist/factory/assets/index-Clx8P1O6.css +1 -0
  64. package/dist/factory/assets/{input-DqReKX0A-BLQpswsN.js → input-DqReKX0A-DiwFSTOM.js} +3 -3
  65. package/dist/factory/assets/{input-group-CXvse9n7-DqHmMaZs.js → input-group-CXvse9n7-CQKMNpKI.js} +1 -1
  66. package/dist/factory/assets/{lib-jV8AO_7z.js → lib-BYybByKv.js} +1 -1
  67. package/dist/factory/assets/{onboardingFlow-B2qg3ui3.js → onboardingFlow-C-N13Rpo.js} +1 -1
  68. package/dist/factory/assets/overlays-B3sO28Cg.js +1 -0
  69. package/dist/factory/assets/popup-anchor.es-B4jCSTe8.js +1 -0
  70. package/dist/factory/assets/{relativeTime-BCpoZ9Eq.js → relativeTime-BIRQ0d5n.js} +1 -1
  71. package/dist/factory/assets/request-CHSXf6Q8.js +1 -0
  72. package/dist/factory/assets/ruleLanes-JkSFa1Sb.js +1 -0
  73. package/dist/factory/assets/settings-RVbY3OIo-BeOJx8jX.js +1 -0
  74. package/dist/factory/assets/settingsColumn-CrKuH8q1.js +1 -0
  75. package/dist/factory/assets/{spinner-B9ykw74u-D6KSetYc.js → spinner-B9ykw74u-CBIoiKrY.js} +1 -1
  76. package/dist/factory/assets/{useBoardCatalog-DkKng9eE.js → useBoardCatalog-CNf38nx9.js} +1 -1
  77. package/dist/factory/assets/useBoardEditor-B6kA7dRx.js +1 -0
  78. package/dist/factory/assets/useChatSessionContext-CKd4Tvdx.js +1 -0
  79. package/dist/factory/assets/useDraftModelGuards-BQTzlSm2.js +29 -0
  80. package/dist/factory/assets/{useFactoryDecisions-BEvhYFeI.js → useFactoryDecisions-VIc-8PNm.js} +1 -1
  81. package/dist/factory/assets/useGithubStatus-BWXnchFb.js +1 -0
  82. package/dist/factory/assets/useGlobalSearchControls-BPFKGcQt.js +1 -0
  83. package/dist/factory/assets/{useInfiniteQuery-B-H60PH-.js → useInfiniteQuery-DpoEFLM1.js} +1 -1
  84. package/dist/factory/assets/useIntakeRoutes-DiGrbexN.js +1 -0
  85. package/dist/factory/assets/useLinearData-COQiGtsh.js +1 -0
  86. package/dist/factory/assets/{useRouteSessionId-DLrXIVET.js → useRouteSessionId-O5C78HX2.js} +1 -1
  87. package/dist/factory/assets/useRowDrag-E2Ktgp3l.js +1 -0
  88. package/dist/factory/assets/{useSessionCard-pmRS64pe.js → useSessionCard-yQHQWK5F.js} +1 -1
  89. package/dist/factory/assets/{useSessionRepository-j9ahtVmE.js → useSessionRepository-D1CM8KJ1.js} +1 -1
  90. package/dist/factory/assets/{useSessionRows-DBIwBc12.js → useSessionRows-B3nMStmr.js} +1 -1
  91. package/dist/factory/assets/{useThreadWorkspacePath-CtzAyEql.js → useThreadWorkspacePath-D-6kMg6l.js} +1 -1
  92. package/dist/factory/assets/workspaces-D5RRfW43.js +2 -0
  93. package/dist/factory/index.html +59 -53
  94. package/dist/index.js +1 -1
  95. package/dist/studio/assets/{index-BvRP7JbU.js → index-C0SFTCHU.js} +2 -2
  96. package/dist/studio/assets/{main-CyhmAJ0d.js → main-CEXjbGJl.js} +15 -15
  97. package/dist/studio/index.html +1 -1
  98. package/package.json +4 -4
  99. package/dist/factory/assets/BoardConfigPage-CLMTRGF4.js +0 -1
  100. package/dist/factory/assets/BoardIcons-Dy0kQmDy.js +0 -1
  101. package/dist/factory/assets/BoardIntakePage-B8V1iUXX.js +0 -1
  102. package/dist/factory/assets/BoardRulesPage-CCZ08LuD.js +0 -1
  103. package/dist/factory/assets/Breadcrumb.es-LLQ8Ax-l.js +0 -1
  104. package/dist/factory/assets/CodeBlock.es-CcyBNUop.js +0 -4
  105. package/dist/factory/assets/ConditionRows--QT7_tMP.js +0 -1
  106. package/dist/factory/assets/CreateFactoryPage-C7DSVofP.js +0 -1
  107. package/dist/factory/assets/Field.es-CIBINxzQ.js +0 -1
  108. package/dist/factory/assets/IconArrowRight.es-DpwteWGp.js +0 -1
  109. package/dist/factory/assets/IconClipboard2.es-yelKDvfv.js +0 -1
  110. package/dist/factory/assets/IconFormCircle.es-BXCWep_k.js +0 -1
  111. package/dist/factory/assets/IconPlugin1.es-CTUTGqWZ.js +0 -1
  112. package/dist/factory/assets/IconRobot.es-CunHAP4r.js +0 -1
  113. package/dist/factory/assets/InputNumber.es-DkP7VgSf.js +0 -1
  114. package/dist/factory/assets/IntakeTesterDialog-v__dWdn3.js +0 -1
  115. package/dist/factory/assets/KnowledgePage-DEa-6V18.js +0 -13
  116. package/dist/factory/assets/MarkdownRenderer-De9m5Xru-BD4E9TYG.js +0 -85
  117. package/dist/factory/assets/MastraGatewayBilling-BR1sQ6rq.js +0 -1
  118. package/dist/factory/assets/NewBoardPage-DPtITFWl.js +0 -2
  119. package/dist/factory/assets/NewPage-CW6WRGYd.js +0 -1
  120. package/dist/factory/assets/Notice-BhWgws6f-Csn4zhYz.js +0 -55
  121. package/dist/factory/assets/RadioGroup-DStktMyS.js +0 -1
  122. package/dist/factory/assets/SearchInput.es-DZTecD6F.js +0 -1
  123. package/dist/factory/assets/SessionLayout-C4zweKte.js +0 -4
  124. package/dist/factory/assets/SessionPage-Ceaxt_3c.js +0 -1
  125. package/dist/factory/assets/SessionSharingPopover-nmNKWuHX.js +0 -1
  126. package/dist/factory/assets/SettingsPage-BZqBLBfO.js +0 -3
  127. package/dist/factory/assets/Sidebar.es-C9oh7x-Y.js +0 -1
  128. package/dist/factory/assets/board-events-CEgvdtZO.js +0 -1
  129. package/dist/factory/assets/boardConfigPaths-DK63vR9d.js +0 -1
  130. package/dist/factory/assets/conditionFields-TlU8dvSR.js +0 -1
  131. package/dist/factory/assets/factory-CCgecf7i.js +0 -1
  132. package/dist/factory/assets/highlight-DF-vd68d-B8-NxWBf.js +0 -3
  133. package/dist/factory/assets/icons-CTcV_3vc.js +0 -1
  134. package/dist/factory/assets/index-BBxbR8vz.css +0 -1
  135. package/dist/factory/assets/index-BZPAZhd_.js +0 -125
  136. package/dist/factory/assets/request-qUzOU__J.js +0 -1
  137. package/dist/factory/assets/settings-B7RMGKgf-D0NdBHnV.js +0 -1
  138. package/dist/factory/assets/settingsColumn-I0ztv9I1.js +0 -1
  139. package/dist/factory/assets/useBoardEditor-ny4lVZq1.js +0 -1
  140. package/dist/factory/assets/useChatSessionContext-Beg8geDq.js +0 -1
  141. package/dist/factory/assets/useDraftModelGuards-CxYpi8BJ.js +0 -29
  142. package/dist/factory/assets/useGlobalSearchControls-zbmBnHeV.js +0 -1
  143. package/dist/factory/assets/workspaces-C8riO6Zu.js +0 -2
  144. /package/dist/factory/assets/{IconPlugin1-CYlMQsMB.css → combobox-parts-Bmj5kzrt-CYlMQsMB.css} +0 -0
@@ -3,7 +3,7 @@ name: mastra
3
3
  description: Documentation for mastra. Use when working with mastra APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "mastra"
6
- version: "1.40.1-alpha.2"
6
+ version: "1.40.1-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.40.1-alpha.2",
2
+ "version": "1.40.1-alpha.3",
3
3
  "package": "mastra",
4
4
  "exports": {
5
5
  "PosthogAnalytics": {
@@ -1 +1 @@
1
- import{Bt as e,Gt as t,Ht as n,It as r,Jt as i,Kt as a,Pi as o,Rt as s,Ut as c,Vt as l,Wt as u,qt as d,zt as f}from"./Notice-BhWgws6f-Csn4zhYz.js";import{O as p,T as m}from"./IconChevronRightMedium.es-BjSIsine.js";var h=p();function g(e){return(0,h.jsx)(r,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...t}){return(0,h.jsx)(l,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...t,role:`alertdialog`})}function v({children:t,...n}){return(0,h.jsx)(e,{render:(0,h.jsx)(o,{variant:`primary`,size:`md`,className:m(d,i.md),children:t}),...n})}g.Trigger=a,g.Content=_,g.Header=u,g.Footer=c,g.Body=s,g.Title=t,g.Description=n,g.Action=v,g.Cancel=f;export{g as t};
1
+ import{Bt as e,Gt as t,Ht as n,It as r,Jt as i,Kt as a,Pi as o,Rt as s,Ut as c,Vt as l,Wt as u,qt as d,zt as f}from"./Notice-BhWgws6f-D26rmfPt.js";import{O as p,T as m}from"./IconChevronRightMedium.es-BjSIsine.js";var h=p();function g(e){return(0,h.jsx)(r,{...e,modal:!0,disablePointerDismissal:!0})}function _({size:e=`sm`,...t}){return(0,h.jsx)(l,{"data-slot":`alert-dialog-content`,size:e,showCloseButton:!1,...t,role:`alertdialog`})}function v({children:t,...n}){return(0,h.jsx)(e,{render:(0,h.jsx)(o,{variant:`primary`,size:`md`,className:m(d,i.md),children:t}),...n})}g.Trigger=a,g.Content=_,g.Header=u,g.Footer=c,g.Body=s,g.Title=t,g.Description=n,g.Action=v,g.Cancel=f;export{g as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-uNv7_2cQ.js";import{t as r}from"./EmptyState-DJaZF543-Cw3WDQUb.js";import{$n as i,Cr as a,D as o,E as s,Hn as c,Jn as l,Mr as u,Qn as d,Sr as f,Un as p,Vn as m,Xn as h,Yn as g,Zn as _,ar as v,cr as y,dr as b,en as x,er as S,fn as ee,fr as C,hr as w,jr as T,lr as E,mr as te,nn as ne,nr as D,rn as O,rr as k,tn as A,tr as j,ur as M,vr as N,xr as P,yr as F}from"./index-BTe7cRAB.js";import{A as re,a as I,k as L}from"./Sidebar.es-etnaeLk8.js";import{d as ie,f as R,r as ae,t as z,u as oe}from"./settings-RVbY3OIo-BeOJx8jX.js";import{O as se,T as B,k as ce,n as V,s as H,t as le}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as U}from"./lib-BYybByKv.js";import{c as ue,o as de,r as fe,s as pe,t as me}from"./useBoardEditor-B6kA7dRx.js";import{i as he,t as ge}from"./SkillBadges-BFt5UQQL.js";import{a as W,c as _e,f as ve,l as ye,s as be}from"./boardConfigPaths-Btimpi_r.js";import{t as G}from"./AlertDialog.es-CRAV1bgk.js";import{$t as xe,Ai as Se,Pi as K,Qn as Ce,cr as we,fa as Te,ha as Ee,n as De,pa as Oe,t as q}from"./Notice-BhWgws6f-D26rmfPt.js";import{t as J}from"./SettingsSubsection-CO08NR1O.js";import{n as ke,r as Ae,t as je}from"./settingsColumn-CrKuH8q1.js";import{n as Me}from"./useBoardCatalog-CNf38nx9.js";import{h as Ne,o as Pe}from"./useIntakeRoutes-DiGrbexN.js";import{a as Fe,d as Ie,t as Le}from"./BoardIcons-C0Z_7MKH.js";import{n as Re,r as ze,t as Be}from"./HoverCard.es-CbtJYu6d.js";import{r as Ve}from"./overlays-B3sO28Cg.js";import{t as He}from"./DescriptionMarkdown-B2ihg8gR.js";import{h as Ue,w as We,y as Ge}from"./ruleLanes-JkSFa1Sb.js";import{t as Ke}from"./CodeEditor-AaW7HgY9-CjZKkwJd.js";import{a as qe,n as Je,r as Ye,t as Xe}from"./Field.es-CaXwaCGT.js";import{t as Ze}from"./input-DqReKX0A-DiwFSTOM.js";import{a as Qe,n as $e}from"./input-group-CXvse9n7-CQKMNpKI.js";import{a as et,i as tt,n as nt,r as rt,t as it}from"./InputNumber.es-CY2qYDqO.js";import{Y as at,a as ot,i as st,o as ct,r as lt}from"./request-CHSXf6Q8.js";import{E as ut}from"./combobox-parts-Bmj5kzrt-PcITNZFp.js";import{n as dt,t as ft}from"./ConditionRows-CTCdJTDp.js";import{t as pt}from"./IconLock.es-9mYeLe9c.js";import{t as mt}from"./IconPlusMedium.es-QmObHPf-.js";import{t as ht}from"./TrashIcon.es-DNb97Rim.js";import{t as Y}from"./page-header-Maytcmgh--oRyXaDt.js";import{n as gt,t as _t}from"./boardCatalog-y-s19dQU.js";import{t as vt}from"./IconArrowRotateCounterClockwise.es-DwgpnNS1.js";import{t as yt}from"./InlineText-vWKzGKx_.js";import{t as bt}from"./LoadErrorState-CB-Vi72B.js";var X=e(ce(),1),Z=se();function Q({pinned:e,sticky:t,className:n,children:r}){let i=t&&`sticky bottom-4 z-10`;return e?(0,Z.jsx)(`div`,{className:B(ke,i),children:(0,Z.jsx)(`div`,{className:B(Ae,n),children:r})}):(0,Z.jsx)(`div`,{className:B(Ae,i,n),children:r})}function xt({factoryId:e,boardId:t,phase:n,skills:r}){let i=n.runner;if(!i)return null;let a=i.skill,o=a?r?.find(e=>e.name===a):void 0,c=a!==void 0&&r!==void 0&&o===void 0,l=c||o?.error!==void 0,u=a&&!c?_e(e,t,a):W(e,t,n.key),d=a?s:Ve;return(0,Z.jsxs)(Be,{children:[(0,Z.jsxs)(ze,{delay:0,closeDelay:100,render:(0,Z.jsx)(U,{to:u}),className:B(H,`border-border bg-fill-subtle hover:bg-fill flex w-fit max-w-full min-w-0 items-center gap-1.5 rounded-md border px-1.5 py-0.5 transition-colors`,l&&`border-destructive-foreground text-destructive-foreground`),children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-icon-sm shrink-0 opacity-70`}),(0,Z.jsx)(`span`,{className:`truncate`,children:a??`Agent`}),l&&(0,Z.jsx)(`span`,{className:`sr-only`,children:c?`, skill not found`:`, skill failed to load`})]}),(0,Z.jsxs)(Re,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-96 max-w-[calc(100vw-2rem)] flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(V,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:a??`${n.name} agent`}),o&&(0,Z.jsx)(ge,{skill:o})]}),c?(0,Z.jsxs)(V,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,a,` skill, so cards entering `,n.name,` fail to start.`]}):o?.error?(0,Z.jsxs)(V,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,o.error]}):o?.description&&(0,Z.jsx)(V,{as:`p`,variant:`caption`,tone:`muted`,children:o.description}),a&&!r&&(0,Z.jsx)(h,{children:`Loading the skill…`}),o?.content.trim()&&(0,Z.jsx)(St,{title:`Skill instructions`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:o.content})}),i.instructions?.trim()&&(0,Z.jsx)(St,{title:`${n.name} adds`,children:(0,Z.jsx)(He,{titleLevel:`h3`,children:i.instructions})}),i.goal?.objective&&(0,Z.jsx)(St,{title:i.goal.maxRuns?`Goal, up to ${i.goal.maxRuns} runs`:`Goal`,children:(0,Z.jsx)(V,{as:`p`,variant:`body-sm`,className:`whitespace-pre-wrap`,children:i.goal.objective})}),(0,Z.jsxs)(V,{as:`p`,variant:`caption`,tone:`muted`,children:[`Session `,i.context||`work`,`, shared with phases that name it too.`]})]})]})}function St({title:e,children:t}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(V,{as:`span`,variant:`caption`,tone:`faint`,children:e}),(0,Z.jsx)(`div`,{className:`bg-fill-subtle max-h-56 overflow-y-auto rounded-md px-2.5 py-2`,children:t})]})}function Ct({rules:e,title:t,to:n,boardId:r,boards:i}){return(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(ze,{delay:0,closeDelay:100,render:(0,Z.jsx)(U,{to:n}),className:B(H,`w-fit rounded-sm underline decoration-dotted underline-offset-2`),children:Ue(e.length)}),(0,Z.jsxs)(Re,{side:`right`,align:`start`,sideOffset:8,collisionPadding:8,showArrow:!1,className:`flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2`,children:[(0,Z.jsx)(V,{as:`span`,variant:`caption`,tone:`faint`,children:t}),(0,Z.jsx)(`ul`,{"aria-label":t,className:`flex max-h-80 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,Z.jsx)(p,{rule:e,boardId:r,boards:i},e.id))})]})]})}var wt=`px-[max(0.75rem,calc((100cqw_-_42rem)/2_-_1.25rem))]`;function Tt({factoryId:e,boardId:t,phases:n,skills:r,action:i,onAutoStart:a}){let o=Me(e),s=Pe(e),u=o.isPending||s.isPending,d=o.data?.find(e=>e.id===t)?.initialPhase??n[0]?.key,f=n.map(e=>g(e,n)),p=s.data&&d?_(s.data.intakeRoutes,{key:t,initialPhase:d}):void 0;return(0,Z.jsxs)(`section`,{"aria-label":`Board map`,className:`flex flex-col gap-3`,children:[i&&(0,Z.jsx)(Q,{pinned:!0,className:`flex justify-end`,children:i}),s.isError&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(q,{variant:`warning`,children:(0,Z.jsx)(q.Message,{children:`Rules didn’t load, so the map doesn’t count them.`})})}),p&&p.leaving.length>0&&(0,Z.jsx)(Q,{pinned:!0,className:`mb-4`,children:(0,Z.jsxs)(V,{as:`p`,variant:`caption`,tone:`muted`,children:[(0,Z.jsx)(Ct,{rules:p.leaving,title:`Rules that send cards to other boards`,to:be(e,t,`leaving`),boardId:t,boards:o.data}),` `,p.leaving.length===1?`sends`:`send`,` cards from here to other boards.`]})}),(0,Z.jsx)(`ol`,{"aria-label":`Phases`,className:B(`mx-auto flex w-max`,wt),children:n.map(i=>{let s=Fe(t,i.kind),m=p?.into.get(i.key)??[];return(0,Z.jsxs)(`li`,{"aria-label":i.name,className:`before:via-border-strong relative flex w-64 shrink-0 flex-col px-2 not-first:before:absolute not-first:before:inset-y-0 not-first:before:left-0 not-first:before:w-px not-first:before:bg-linear-to-b not-first:before:from-transparent not-first:before:to-transparent`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 px-3 pt-3 pb-1`,children:(0,Z.jsxs)(U,{to:W(e,t,i.key),className:`flex min-w-0 items-center gap-2 hover:underline focus-visible:underline focus-visible:outline-hidden`,children:[(0,Z.jsx)(Le,{stage:i.key,kind:s,decorative:!0}),(0,Z.jsx)(V,{as:`span`,variant:`label`,tone:`ink`,className:`truncate`,children:i.name})]})}),(0,Z.jsx)(`div`,{className:`px-3 py-3`,children:(0,Z.jsx)(l,{boardId:t,phase:g(i,n),phases:f,arrivals:(0,Z.jsxs)(Z.Fragment,{children:[u?(0,Z.jsx)(re,{className:`h-4 w-20`}):p?m.length>0?(0,Z.jsx)(Ct,{rules:m,title:`Rules that move cards into ${i.name}`,to:be(e,t,{into:i.key}),boardId:t,boards:o.data}):(0,Z.jsx)(h,{children:`No rule moves cards here`}):(0,Z.jsx)(h,{children:`Rules didn’t load`}),i.key===d&&(0,Z.jsx)(h,{children:`New cards start here`})]}),starts:(0,Z.jsx)(c,{label:i.name,autoStart:i.autoStart??!1,autoStartWhen:i.autoStartWhen,onChange:a&&(e=>a(i.key,e))}),agent:(0,Z.jsx)(xt,{factoryId:e,boardId:t,phase:i,skills:r})})})]},i.key)})})]})}var Et=`Finish or remove unfinished conditions to save.`;function Dt({label:e,description:t,rule:n,disabled:r,facts:i=Ge,options:a,schema:o,json:s,onChange:c,onUnfinished:l}){let[u,d]=(0,X.useState)(void 0),f=s?s.text:u,p=s?s.onChange:d,m=(0,X.useId)(),h=f===void 0?P(o,n):N(o,f),g=e=>{p(e);let t=F(o,e);`problem`in t?c(n??null,t.problem):c(t.rule,void 0)};return(0,Z.jsxs)(Xe,{invalid:h!==void 0,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(qe,{htmlFor:m,children:e}),(0,Z.jsx)(K,{size:`sm`,variant:`ghost`,disabled:r,onClick:()=>{f===void 0?p(n?JSON.stringify(n,null,2):``):(p(void 0),c(n??null,P(o,n)))},children:f===void 0?`Edit as JSON`:`Edit as conditions`})]}),(0,Z.jsx)(Je,{children:t}),f===void 0?r?(0,Z.jsx)(V,{id:m,as:`p`,variant:`caption`,tone:`muted`,children:We(n,a)}):(0,Z.jsx)(`div`,{id:m,children:(0,Z.jsx)(ft,{label:e,rule:n,facts:i,options:a,onChange:(e,t)=>{l?.(t),t?c(n??null,Et):c(e,P(o,e))}})}):(0,Z.jsx)(x,{id:m,"aria-label":`${e} JSON`,value:f,disabled:r,rows:6,onChange:e=>g(e.target.value)}),h&&(0,Z.jsx)(Ye,{children:h})]})}var Ot=`inline-flex h-8 max-w-48 min-w-0 items-center gap-1.5 rounded-lg border px-2.5`;function kt({phase:e,phases:t,next:n,required:r,boardId:i,disabled:a,onChange:o}){let s=e=>o(n.includes(e)?n.filter(t=>t!==e):t.filter(t=>t.key===e||n.includes(t.key)).map(e=>e.key));return(0,Z.jsx)(`ul`,{"aria-label":`Allowed moves from ${e.name}`,className:`flex flex-wrap gap-1.5`,children:t.map(t=>{let o=(0,Z.jsx)(Le,{stage:t.key,kind:Fe(i,t.kind),decorative:!0});if(t.key===e.key)return(0,Z.jsxs)(`li`,{className:B(Ot,`border-border-strong bg-card shadow-raised dark:bg-muted`),children:[o,(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`sr-only`,children:`(this phase)`})]},t.key);let c=n.includes(t.key),l=c&&r.has(t.key),u=l||a,d=(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":c,"aria-label":l?`${t.name} (locked)`:void 0,"aria-disabled":u||void 0,onClick:u?void 0:()=>s(t.key),className:B(Ot,`group/move transition-colors`,c?`bg-fill text-foreground border-transparent`:`border-border text-muted-foreground border-dashed`,!u&&(c?`hover:bg-fill-hover`:`hover:text-foreground hover:border-border-strong`),u&&!l&&`cursor-default`,H),children:[(0,Z.jsx)(`span`,{className:B(`grid place-items-center`,!c&&`opacity-50`),children:o}),(0,Z.jsx)(At,{children:t.name}),(0,Z.jsx)(`span`,{className:`text-muted-foreground grid size-3.5 shrink-0 place-items-center`,children:l?(0,Z.jsx)(pt,{className:`size-icon-sm`,"aria-hidden":!0}):c?(0,Z.jsx)(at,{className:`size-icon-sm`,"aria-hidden":!0}):!a&&(0,Z.jsx)(mt,{className:`size-icon-sm invisible group-hover/move:visible group-focus-visible/move:visible`,"aria-hidden":!0})})]});return(0,Z.jsx)(`li`,{className:`min-w-0`,children:l?(0,Z.jsxs)(Te,{children:[(0,Z.jsx)(Ee,{render:d}),(0,Z.jsx)(Oe,{children:`Factory's code makes this move`})]}):d},t.key)})})}function At({children:e}){return(0,Z.jsx)(V,{as:`span`,variant:`label`,className:`truncate`,children:e})}function jt({label:e,children:t}){return(0,Z.jsx)(`ol`,{"aria-label":e,className:`flex flex-col`,children:t})}function Mt({icon:e,title:t,description:n,children:r}){let i=(0,X.useId)();return(0,Z.jsxs)(`li`,{"aria-labelledby":i,className:`before:bg-border relative grid grid-cols-[--spacing(7)_minmax(0,1fr)] gap-x-3 pb-8 before:absolute before:top-9 before:bottom-1 before:left-[calc(--spacing(3.5)-0.5px)] before:w-px last:pb-0 last:before:hidden`,children:[(0,Z.jsx)(`span`,{className:`border-border bg-card text-muted-foreground [&_svg]:size-icon-sm flex size-7 items-center justify-center rounded-full border`,children:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-h-7 flex-col justify-center`,children:[(0,Z.jsx)(V,{as:`h2`,id:i,variant:`subheading`,tone:`ink`,children:t}),n&&(0,Z.jsx)(V,{as:`p`,variant:`caption`,tone:`muted`,children:n})]}),r]})]})}var Nt=`__none__`,Pt=`sm:max-w-xs`,Ft=(e,t)=>e>=t-200?` ${e}/${t}`:``;function It({title:e,description:t,error:n,disabled:r,children:i,after:a}){return(0,Z.jsxs)(ae,{children:[(0,Z.jsxs)(Xe,{invalid:!!n,disabled:r,children:[(0,Z.jsx)(ie,{children:e}),(0,Z.jsx)(Je,{children:t}),i,n&&(0,Z.jsx)(Ye,{children:n})]}),a]})}function Lt({label:e,value:t,placeholder:n,disabled:r,onChange:i}){return(0,Z.jsx)(z,{children:(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Ke,{"aria-label":e,value:t,placeholder:n,editable:!r,onChange:i,language:`markdown`,font:`body`,variant:`inline`,lineNumbers:!1,showCopyButton:!1})})})}function Rt({phase:e,phases:t,requiredNextPhases:n,skills:r,skillsEditable:a,factoryId:o,boardId:c,disabled:l,rawRules:u,onChange:p,onRawRule:h,onUnfinished:g,onRemove:_}){let y=dt(o),b=e.kind===`working`,x=E(e,t),C=e.runner?.instructions??``,w=e.runner?.goal,T=w?.objective??``,ne=e.tools??[],D=e.exitTool?.id??``,O=e.runner?.skill,k=O?r?.find(e=>e.name===O):void 0,A=O!==void 0&&r!==void 0&&k===void 0,M=t=>{let n={...e.runner,...t},r=Object.fromEntries(Object.entries(n).filter(([,e])=>e!=null&&e!==``));p({...e,runner:Object.keys(r).length>0?r:null})},N=e=>({text:u[e],onChange:t=>h(e,t)}),P=(0,Z.jsx)(kt,{phase:e,phases:t,next:x,required:new Set(n),boardId:c,disabled:l,onChange:t=>p({...e,nextPhases:t})}),F=_&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(K,{variant:`ghost`,icon:(0,Z.jsx)(ht,{}),onClick:_,children:[`Remove `,e.name]})});return b?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsxs)(jt,{label:`How ${e.name} runs`,children:[(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(Ie,{}),title:`Starts`,children:(0,Z.jsxs)(z,{children:[(0,Z.jsx)(R,{label:`Start on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: start on its own`,checked:e.autoStart??!1,disabled:l,onCheckedChange:t=>{p(te(e,t)),t||h(`autoStartWhen`,void 0)}})}),e.autoStart&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: start only when`,description:`Leave empty to start every card on its own.`,rule:e.autoStartWhen,schema:Ne,options:{"source.repository":y},disabled:l,json:N(`autoStartWhen`),onUnfinished:e=>g(`autoStartWhen`,e),onChange:t=>p({...e,autoStartWhen:t})})})]})}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(Ve,{}),title:`Agent runs`,children:[(0,Z.jsx)(It,{title:`Instructions`,description:`Added to the agent's prompt when the phase starts.${Ft(C.length,i)}`,error:C.length>1e3?`Too long to save.`:void 0,disabled:l,children:(0,Z.jsx)(Lt,{label:`${e.name} instructions`,value:C,placeholder:`Tell the agent what to do, in Markdown`,disabled:l,onChange:e=>M({instructions:e})})}),(0,Z.jsx)(It,{title:`Goal`,description:`The agent keeps working until a judge finds this objective met. Leave empty for a single run.${Ft(T.length,S)}`,error:T.length>2e3?`Too long to save.`:void 0,disabled:l,after:w&&(0,Z.jsxs)(Xe,{invalid:!v(w.maxRuns),disabled:l,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(qe,{info:`After this many runs without meeting the goal, the card waits for a person. From 1 to 50; leave empty for Factory's default.`,children:`Pause goal after`}),(0,Z.jsx)(it,{className:`w-36`,min:1,max:50,allowOutOfRange:!0,value:w.maxRuns??null,disabled:l,onValueChange:e=>{let{maxRuns:t,...n}=w;M({goal:e===null?n:{...n,maxRuns:e}})},children:(0,Z.jsxs)(rt,{size:`sm`,children:[(0,Z.jsx)(et,{placeholder:`Default`}),(0,Z.jsxs)($e,{align:`inline-end`,variant:`flush`,children:[(0,Z.jsx)(Qe,{className:`mr-1`,children:`runs`}),(0,Z.jsx)(nt,{}),(0,Z.jsx)(tt,{})]})]})})]}),!v(w.maxRuns)&&(0,Z.jsxs)(Ye,{children:[`Use a whole number from 1 to `,50,`.`]})]}),children:(0,Z.jsx)(Lt,{label:`${e.name} goal`,value:T,placeholder:`Describe what done looks like`,disabled:l,onChange:e=>M({goal:e.trim()?{...w,objective:e}:void 0})})}),(0,Z.jsx)(It,{title:`Session`,description:`Phases with the same session share one agent session per card.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} session`,value:e.runner?.context??``,placeholder:d,disabled:l,onChange:e=>M({context:e.target.value})})}),(0,Z.jsx)(J,{title:`Skill`,children:(0,Z.jsx)(z,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(lt,{value:O??Nt,disabled:l,onValueChange:e=>M({skill:e===Nt?void 0:String(e)}),children:[(0,Z.jsx)(ct,{variant:`ghost`,size:`sm`,"aria-label":`${e.name} skill`,className:`-ml-2 w-fit`,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(s,{"aria-hidden":!0,className:`text-muted-foreground size-icon-md shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:O??`No skill`})]})}),(0,Z.jsxs)(st,{children:[(0,Z.jsx)(ot,{value:Nt,children:`None`}),(r??[]).map(e=>(0,Z.jsx)(ot,{value:e.name,children:e.name},e.name))]})]}),A&&(0,Z.jsx)(L,{variant:`destructive`,children:`Not found`}),k?.error&&(0,Z.jsx)(L,{variant:`destructive`,children:`Failed to load`}),k&&(0,Z.jsx)(ge,{skill:k}),k&&(0,Z.jsx)(K,{size:`sm`,variant:`ghost`,icon:a?(0,Z.jsx)(m,{}):(0,Z.jsx)(De,{}),"aria-label":`${a?`Edit`:`View`} ${k.name}`,className:`ml-auto`,render:(0,Z.jsx)(U,{to:_e(o,c,k.name)}),children:a?`Edit`:`View`})]}),k?.error?(0,Z.jsxs)(V,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`Agents can't load this skill: `,k.error]}):A?(0,Z.jsxs)(V,{as:`p`,variant:`caption`,role:`alert`,className:`text-destructive-foreground`,children:[`This factory has no `,O,` skill, so cards entering `,e.name,` fail to start.`]}):k?.description&&(0,Z.jsx)(V,{as:`p`,variant:`caption`,tone:`muted`,children:k.description})]})})}),(0,Z.jsx)(J,{title:`Factory tools`,description:`Given to the session that works the card in this phase.`,children:(0,Z.jsx)(z,{children:j.map(t=>(0,Z.jsx)(R,{label:t.label,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: ${t.label}`,checked:ne.includes(t.id),disabled:l,onCheckedChange:n=>{let r=j.map(({id:e})=>e).filter(e=>e===t.id?n:ne.includes(e));p({...e,tools:r.length>0?r:null})}})},t.id))})})]}),(0,Z.jsxs)(Mt,{icon:(0,Z.jsx)(f,{}),title:`Ends`,children:[(0,Z.jsx)(It,{title:`Exit tool`,description:`Ends the phase when it succeeds. Leave empty for none.`,disabled:l,children:(0,Z.jsx)(Ze,{className:Pt,"aria-label":`${e.name} exit tool`,value:D,disabled:l,onChange:t=>{let n=t.target.value.trim();p({...e,exitTool:n?{...e.exitTool,id:n}:null}),n||h(`autoApproveWhen`,void 0)}})}),D!==``&&(0,Z.jsxs)(z,{children:[(0,Z.jsx)(R,{label:`Approve on its own`,disabled:l,children:(0,Z.jsx)(ut,{"aria-label":`${e.name}: approve ${D} on its own`,checked:e.exitTool?.autoApprove??!1,disabled:l,onCheckedChange:t=>{p({...e,exitTool:{...e.exitTool,id:D,autoApprove:t,autoApproveWhen:t?e.exitTool?.autoApproveWhen:void 0}}),t||h(`autoApproveWhen`,void 0)}})}),e.exitTool?.autoApprove&&(0,Z.jsx)(`div`,{className:`px-4 py-3`,children:(0,Z.jsx)(Dt,{label:`${e.name}: approve only when`,description:`Leave empty to approve for every card.`,rule:e.exitTool.autoApproveWhen,schema:Ne,options:{"source.repository":y},disabled:l,json:N(`autoApproveWhen`),onUnfinished:e=>g(`autoApproveWhen`,e),onChange:t=>p({...e,exitTool:{...e.exitTool,id:D,autoApprove:!0,autoApproveWhen:t??void 0}})})})]})]}),(0,Z.jsx)(Mt,{icon:(0,Z.jsx)(ee,{}),title:`Allowed moves`,children:P})]}),F]}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(J,{title:`Allowed moves`,children:P}),F]})}var zt=[`autoStartWhen`,`autoApproveWhen`];function Bt({factory:e,boardId:t,phaseKey:n,response:i,skills:a,skillsEditable:c,sidebarHidden:l,onReload:u}){let{board:d,canEdit:f}=i,{draft:p,rawRules:m,locked:h,setDraft:g,setRawRule:_,discard:v}=ne(e.id,t,d),[y,x]=(0,X.useState)(0),S=()=>{v(),x(e=>e+1)},ee=we(),w=ue(e.id,t),T=Se(),E=!f||!d.editable,O=n?p.phases.find(e=>e.key===n):void 0,A=O&&`${O.key}:${d.revision??`code`}:${y}`,[j,N]=(0,X.useState)({page:A,fields:[]});j.page!==A&&N({page:A,fields:[]});let P=j.page===A?j.fields:[],F=(e,t)=>N(n=>{let r=n.fields.filter(t=>t!==e);return{...n,fields:t?[...r,e]:r}}),re=!E&&(k(p,d)||Object.keys(m).length>0||P.length>0),I=p.phases.filter(e=>M(e,m)||e===O&&P.length>0),L=p.name.trim()===``,ie=w.error?.code===`revision_mismatch`,R=Ce(({nextLocation:n})=>{let r=T.getQueryData(xe.boardCatalog(e.id))?.boards.some(e=>e.id===t);if(!re||r===!1)return!1;let i=ve(n.pathname);return i?.factoryId!==e.id||i.boardId!==t||i.skills===!0||i.rules===!0||i.intake===!0}),ae=W(e.id,t),oe;return oe=n&&!O?(0,Z.jsx)(r,{titleSlot:(0,Z.jsxs)(`span`,{role:`alert`,children:[d.name,` has no such phase.`]}),actionSlot:(0,Z.jsx)(K,{size:`sm`,render:(0,Z.jsx)(U,{to:ae}),children:`Back to general`})}):O?(0,Z.jsx)(Rt,{phase:O,phases:p.phases,requiredNextPhases:d.codeBehaviour?.[O.key]?.requiredNextPhases??[],skills:a,skillsEditable:c,factoryId:e.id,boardId:t,disabled:E||h,rawRules:{autoStartWhen:m[b(O.key,`autoStartWhen`)],autoApproveWhen:m[b(O.key,`autoApproveWhen`)]},onRawRule:(e,t)=>{_(b(O.key,e),t),F(e,!1)},onUnfinished:F,onRemove:E||h||!D(p.phases,O.key,d.codeBehaviour)?void 0:()=>{for(let e of zt)_(b(O.key,e),void 0);g(e=>({...e,phases:C(e.phases,O.key)})),ee(ae)},onChange:e=>g(t=>({...t,phases:t.phases.map(t=>t.key===e.key?e:t)}))},A):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,Z.jsx)(Tt,{factoryId:e.id,boardId:t,phases:p.phases,skills:a,onAutoStart:E||h?void 0:(e,t)=>{g(n=>({...n,phases:n.phases.map(n=>n.key===e?te(n,t):n)})),t||_(b(e,`autoStartWhen`),void 0)},action:l&&!E?(0,Z.jsx)(o,{factoryId:e.id,boardId:t,board:d,disabled:h}):void 0}),(0,Z.jsx)(Q,{pinned:!0,className:`flex flex-col gap-8 empty:hidden`,children:l&&(0,Z.jsx)(J,{title:`Factory`,children:(0,Z.jsx)(z,{children:(0,Z.jsxs)(U,{to:ye(e.id,t),className:`hover:bg-fill focus-visible:bg-fill flex items-center gap-3 px-4 py-3 focus-visible:outline-hidden`,children:[(0,Z.jsx)(s,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0}),(0,Z.jsx)(V,{as:`span`,variant:`label`,className:`min-w-0 flex-1 truncate`,children:`Skills`}),(0,Z.jsx)(le,{className:`text-muted-foreground size-icon-md`,"aria-hidden":!0})]})})})})]}),(0,Z.jsxs)(`div`,{className:B(`flex flex-col gap-8 pb-4`,!O&&`w-max min-w-full`),children:[d.editable?!f&&(0,Z.jsx)(Q,{pinned:!O,children:(0,Z.jsx)(q,{variant:`info`,children:`Only organization admins can change this board.`})}):(0,Z.jsx)(Q,{pinned:!O,children:(0,Z.jsx)(q,{variant:`info`,children:`This board is defined in code, so it can't be changed here.`})}),!O&&d.problems.length>0&&(0,Z.jsx)(Q,{pinned:!0,children:(0,Z.jsx)(q,{variant:`warning`,title:`This board has problems`,children:(0,Z.jsx)(q.Message,{children:d.problems.join(` `)})})}),oe,re&&(0,Z.jsxs)(Q,{pinned:!O,sticky:!0,className:`rounded-card bg-card shadow-overlay dark:bg-muted flex flex-col gap-3 p-3`,children:[ie&&(0,Z.jsx)(q,{variant:`warning`,title:`Someone else changed this board`,action:(0,Z.jsx)(q.Button,{onClick:u,children:`Reload`}),children:(0,Z.jsx)(q.Message,{children:`Reload to see their version. Your unsaved changes will be lost.`})}),w.error&&!ie&&(0,Z.jsx)(q,{variant:`destructive`,role:`alert`,children:(0,Z.jsxs)(q.Message,{children:[`The board was not saved. `,w.error.reasons]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(V,{variant:`body-sm`,tone:`muted`,className:`min-w-0 flex-1`,role:`status`,children:L?`Name the board to save.`:I.length>0?`Fix ${I.map(e=>e.name||e.key).join(`, `)} to save.`:`Unsaved changes`}),(0,Z.jsx)(K,{size:`sm`,variant:`ghost`,disabled:w.isPending,onClick:S,children:`Discard`}),(0,Z.jsx)(K,{size:`sm`,variant:`primary`,disabled:w.isPending||L||I.length>0,onClick:()=>w.mutate({name:p.name,description:p.description,phases:p.phases,expectedRevision:d.revision??0}),children:w.isPending?`Saving…`:`Save`})]})]}),(0,Z.jsx)(G,{open:R.state===`blocked`,onOpenChange:e=>!e&&R.reset?.(),children:(0,Z.jsxs)(G.Content,{children:[(0,Z.jsxs)(G.Header,{children:[(0,Z.jsxs)(G.Title,{children:[`Discard changes to `,d.name,`?`]}),(0,Z.jsx)(G.Description,{children:`Your unsaved changes to this board will be lost.`})]}),(0,Z.jsxs)(G.Footer,{children:[(0,Z.jsx)(G.Cancel,{children:`Keep editing`}),(0,Z.jsx)(K,{variant:`destructive`,size:`md`,onClick:()=>{v(),R.proceed?.()},children:`Discard`})]})]})})]})}function Vt({name:e,pending:t,onDelete:n}){return(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{render:(0,Z.jsx)(K,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(ht,{}),disabled:t,children:`Delete`})}),(0,Z.jsxs)(G.Content,{children:[(0,Z.jsxs)(G.Header,{children:[(0,Z.jsxs)(G.Title,{children:[`Delete `,e,`?`]}),(0,Z.jsx)(G.Description,{children:`The board and its phases are removed from this project. A board that still has cards can’t be deleted.`})]}),(0,Z.jsxs)(G.Footer,{children:[(0,Z.jsx)(G.Cancel,{children:`Cancel`}),(0,Z.jsx)(G.Action,{onClick:n,children:`Delete`})]})]})]})}function Ht({name:e,pending:t,onReset:n}){return(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{render:(0,Z.jsx)(K,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(vt,{}),tooltip:`Go back to Factory's version of this board`,tooltipPosition:`bottom`,disabled:t,children:`Reset`})}),(0,Z.jsxs)(G.Content,{children:[(0,Z.jsxs)(G.Header,{children:[(0,Z.jsxs)(G.Title,{children:[`Reset `,e,` to default?`]}),(0,Z.jsx)(G.Description,{children:`Every change made to this board's name and phases is replaced with Factory's version.`})]}),(0,Z.jsxs)(G.Footer,{children:[(0,Z.jsx)(G.Cancel,{children:`Cancel`}),(0,Z.jsx)(G.Action,{onClick:n,children:`Reset`})]})]})]})}var $={resting:{label:`Resting`,meaning:`No agent works here. Cards wait for a person or an event to move them.`},working:{label:`Working`,meaning:`An agent works on each card here, following the steps below.`},terminal:{label:`Terminal`,meaning:`Cards are finished here. Their agent sessions stop.`}},Ut=[`resting`,`working`,`terminal`];function Wt({label:e,meaning:t,children:n}){return(0,Z.jsxs)(Te,{children:[(0,Z.jsx)(Ee,{render:(0,Z.jsx)(`span`,{role:`img`,tabIndex:0,"aria-label":`${e}. ${t}`,className:B(`inline-flex rounded-sm`,H),children:n})}),(0,Z.jsx)(Oe,{side:`bottom`,className:`max-w-72`,children:t})]})}function Gt({factoryId:e,boardId:t,phaseKey:n,response:r}){let{board:i,canEdit:a}=r,{draft:o,locked:s,setDraft:c,setRawRule:l,discard:u}=ne(e,t,i),d=Me(e),f=we(),p=!a||!i.editable||s,m=pe(e,t),h=de(e,t,()=>{u();let n=gt(d.data??[]).find(e=>e.id!==t);f(n?_t(e,n.id):`/factories/${e}`,{replace:!0})}),g=!n&&a&&i.editable,_=g&&i.source!==`stored`,v=g&&i.source!==`builtin`,x=n?o.phases.find(e=>e.key===n):void 0;if(n&&!x)return null;let S=e=>c(t=>({...t,phases:t.phases.map(t=>t.key===n?{...t,...e}:t)})),ee=e=>{x&&(l(b(x.key,`autoStartWhen`),void 0),l(b(x.key,`autoApproveWhen`),void 0),c(t=>({...t,phases:t.phases.map(n=>n.key===x.key?w(n,e,t.phases):n)})))},C=x?x.name:o.name,T=(x?x.description:o.description)??``,E=x!==void 0&&!p&&!y(o.phases,x.key,i.codeBehaviour);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Y,{children:[(0,Z.jsxs)(Y.Title,{className:`gap-2.5`,children:[x&&(0,Z.jsx)(Le,{stage:x.key,kind:Fe(t,x.kind),decorative:!0}),(0,Z.jsx)(yt,{value:C,label:x?`Phase name`:`Board name`,required:!0,readOnly:p,variant:`heading`,tone:`ink`,onChange:e=>x?S({name:e}):c(t=>({...t,name:e}))})]}),x&&(0,Z.jsx)(Y.Meta,{beside:!0,children:E?(0,Z.jsxs)(lt,{value:x.kind,onValueChange:e=>{let t=Ut.find(t=>t===e);t&&ee(t)},children:[(0,Z.jsx)(ct,{size:`sm`,"aria-label":`Phase kind`,children:$[x.kind].label}),(0,Z.jsx)(st,{children:Ut.map(e=>(0,Z.jsx)(ot,{value:e,children:$[e].label},e))})]}):(0,Z.jsx)(Wt,{label:$[x.kind].label,meaning:$[x.kind].meaning,children:(0,Z.jsx)(L,{children:$[x.kind].label})})}),(T||!p)&&(0,Z.jsx)(Y.Description,{children:(0,Z.jsx)(yt,{value:T,label:x?`Phase description`:`Board description`,placeholder:`Add a description`,multiline:!0,readOnly:p,variant:`caption`,tone:`muted`,className:`zoom-safe-text w-full`,onChange:e=>x?S({description:e||null}):c(t=>({...t,description:e||null}))})}),(_||v)&&(0,Z.jsxs)(Y.Action,{className:`gap-1`,children:[_&&(0,Z.jsx)(Ht,{name:i.name,pending:s,onReset:()=>m.mutate(i.revision??0)}),v&&(0,Z.jsx)(Vt,{name:i.name,pending:s,onDelete:()=>h.mutate(i.revision??0)})]})]}),m.error&&(0,Z.jsx)(q,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(q.Message,{children:[`The board was not reset. `,m.error.reasons]})}),h.error&&(0,Z.jsx)(q,{variant:`destructive`,role:`alert`,className:`mt-4`,children:(0,Z.jsxs)(q.Message,{children:[`The board was not deleted. `,h.error.reasons]})})]})}function Kt(){let e=a(),i=A(),o=i?.boardId??``,s=i?.phaseKey,{isMobile:c,desktopState:l}=I(),d=c||l===`collapsed`,f=fe(e.id,o),p=he(e.id),m=f.data?.board,h=O(e.id,o,m),g=s?h?.phases.find(e=>e.key===s):void 0,_=W(e.id,o),v=T({breadcrumbs:d&&m?(0,Z.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(t,{as:U,to:_t(e.id,o),children:h?.name||m.name}),s?(0,Z.jsx)(t,{as:U,to:_,children:`Configure`}):(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:`Configure`}),g&&(0,Z.jsx)(t,{as:`span`,isCurrent:!0,children:g.name})]}):void 0}),y=f.isSuccess&&(!s||g)?(0,Z.jsx)(`div`,{className:B(Ae,s?`pb-8`:`pb-3`),children:(0,Z.jsx)(Gt,{factoryId:e.id,boardId:o,phaseKey:s,response:f.data},`${o}:${f.data.board.revision??`code`}`)}):void 0;return(0,Z.jsx)(u,{variant:s?`narrow`:`fit`,header:y,...v,children:(0,Z.jsx)(`div`,{className:s||!f.isSuccess?B(Ae,!s&&`px-4`):je,children:f.isPending?(0,Z.jsx)(z,{children:(0,Z.jsx)(oe,{label:`Loading board`,rows:3})}):f.isError&&f.error instanceof me&&f.error.code===`board_not_found`?(0,Z.jsx)(r,{variant:`fill`,titleSlot:(0,Z.jsx)(`span`,{role:`alert`,children:`Board unavailable: this board is not installed.`})}):f.isError?(0,Z.jsx)(bt,{title:`Couldn’t load this board`,error:f.error,onRetry:()=>void f.refetch(),retrying:f.isFetching}):(0,Z.jsx)(Bt,{factory:e,boardId:o,phaseKey:s,response:f.data,skills:p.data?.skills,skillsEditable:p.data?.canEdit??!1,sidebarHidden:d,onReload:()=>void f.refetch()},`${o}:${f.data.board.revision??`code`}`)})})}export{Kt as BoardConfigPage};
@@ -0,0 +1 @@
1
+ import{t as e}from"./GithubIcon.es-DGJTTitG.js";import{t}from"./LinearIcon.es-BnTumr4a.js";import{t as n}from"./SlackIcon.es-DCRKrg7l.js";import{O as r,T as i,f as a}from"./IconChevronRightMedium.es-BjSIsine.js";import{s as o}from"./useBoardCatalog-CNf38nx9.js";import{a as s,c,i as l,n as u,o as d,r as f}from"./TrashIcon.es-DNb97Rim.js";import{_ as p,g as m,h}from"./useLinearData-COQiGtsh.js";import{t as g}from"./IconCircleDashed.es-Chw6BTXK.js";import{t as _}from"./IconCircleX.es-3P8aywDS.js";import{S as v}from"./Sidebar.es-etnaeLk8.js";import{t as y}from"./IconCircleCheck.es-e9o_0ikv.js";var b=r();function x({size:e=16,className:t}){return(0,b.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,className:t,"aria-hidden":!0,children:(0,b.jsx)(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M8 14.67C11.68 14.67 14.67 11.68 14.67 8C14.67 4.32 11.68 1.33 8 1.33C4.32 1.33 1.33 4.32 1.33 8C1.33 11.68 4.32 14.67 8 14.67ZM9.14 5.53C8.88 5.27 8.46 5.27 8.2 5.53C7.93 5.79 7.93 6.21 8.2 6.47L9.06 7.33H5.33C4.97 7.33 4.67 7.63 4.67 8C4.67 8.37 4.97 8.67 5.33 8.67H9.06L8.2 9.53C7.93 9.79 7.93 10.21 8.2 10.47C8.46 10.73 8.88 10.73 9.14 10.47L11.14 8.47C11.4 8.21 11.4 7.79 11.14 7.53L9.14 5.53Z`,fill:`currentColor`})})}var S=a(`IconPlay`,()=>(0,b.jsx)(`path`,{d:`M20.245 10.2984L9.05099 3.38443C7.71854 2.56145 6 3.51992 6 5.08603V18.914C6 20.4801 7.71854 21.4385 9.05098 20.6156L20.245 13.7016C21.5104 12.9201 21.5104 11.0799 20.245 10.2984Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinejoin:`round`})),C=a(`IconHammer`,()=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`path`,{d:`M6.70694 14.7929C6.31641 15.1834 5.68325 15.1834 5.29272 14.7929L2.45696 11.9571C2.06643 11.5666 2.06643 10.9334 2.45696 10.5429L9.70694 3.29289C9.89447 3.10536 10.1488 3 10.414 3L14.0857 3C14.3509 3 14.6052 3.10536 14.7928 3.29289L15.7927 4.29286C16.1832 4.68338 16.1832 5.31655 15.7927 5.70707L6.70694 14.7929Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,b.jsx)(`path`,{d:`M9.5 12.5L16.3358 19.3358C17.1168 20.1168 18.3832 20.1168 19.1642 19.3358L19.3358 19.1642C20.1168 18.3832 20.1168 17.1168 19.3358 16.3358L12.5 9.5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]})),w={"github-issue":{icon:e,className:`text-foreground`},"github-pr":{icon:f,className:`text-muted-foreground`},"gitlab-issue":{icon:h,className:`text-badge-red-indicator`},"gitlab-pr":{icon:h,className:`text-badge-red-indicator`},"linear-issue":{icon:t,className:`text-badge-blue-indicator`},"jira-issue":{icon:p,className:`text-badge-blue-indicator`},"incidentio-follow-up":{icon:m,className:`text-badge-red-indicator`},"slack-thread":{icon:n,className:``},manual:{icon:s,className:`text-muted-foreground`}};function T({source:e,className:t}){let{icon:n,className:r}=w[e];return(0,b.jsx)(n,{"data-source":e,className:i(`size-4 shrink-0`,r,t),"aria-hidden":!0})}var E={Investigate:v,Build:C,"Prepare approval":u,Review:l};function D(e){let t=E[e]??S;return(0,b.jsx)(t,{"aria-hidden":!0})}var O={resting:`neutral`,working:`info`,terminal:`success`},k={neutral:{icon:`text-muted-foreground`,tint:`bg-fill-subtle`,strongTint:`bg-fill-strong`,gradientFrom:`from-fill-subtle`},orange:{icon:`text-(--orange-500) dark:text-(--orange-400)`,tint:`bg-badge-orange-subtle`,strongTint:`bg-badge-orange-strong`,gradientFrom:`from-badge-orange-subtle`},cyan:{icon:`text-(--cyan-500) dark:text-(--cyan-400)`,tint:`bg-badge-cyan-subtle`,strongTint:`bg-badge-cyan-strong`,gradientFrom:`from-badge-cyan-subtle`},info:{icon:`text-info-indicator`,tint:`bg-info-subtle`,strongTint:`bg-badge-blue-strong`,gradientFrom:`from-badge-blue-subtle`},green:{icon:`text-badge-green-indicator`,tint:`bg-badge-green-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},purple:{icon:`text-badge-purple-indicator`,tint:`bg-badge-purple-subtle`,strongTint:`bg-badge-purple-strong`,gradientFrom:`from-badge-purple-subtle`},success:{icon:`text-(--green-500) dark:text-(--green-400)`,tint:`bg-success-subtle`,strongTint:`bg-badge-green-strong`,gradientFrom:`from-badge-green-subtle`},destructive:{icon:`text-destructive-indicator`,tint:`bg-destructive-subtle`,strongTint:`bg-badge-red-strong`,gradientFrom:`from-badge-red-subtle`}};function A({source:e,className:t}){return(0,b.jsx)(`span`,{"aria-hidden":!0,style:{maskImage:`url(${e})`},className:i(`size-4 shrink-0 bg-current mask-center mask-no-repeat mask-contain`,t)})}var j=2.25,M=2*Math.PI*j;function N({progress:e,className:t}){return(0,b.jsxs)(`svg`,{width:16,height:16,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":!0,className:i(`shrink-0`,t),children:[(0,b.jsx)(`circle`,{cx:8,cy:8,r:6,stroke:`currentColor`,strokeWidth:1.5}),(0,b.jsx)(`circle`,{cx:8,cy:8,r:j,stroke:`currentColor`,strokeWidth:j*2,strokeDasharray:`${e*M} ${M}`,transform:`rotate(-90 8 8)`})]})}function P(e,t){return t?void 0:d(e)}function F(e,t){return e===`work`||e===`review`?void 0:t}function I(e,t){let n=o(e,t);return e&&n?F(e.id,n):void 0}function L(e,t){let n=P(e,t);return n?c(n):O[t??`resting`]}function R({stage:e,kind:t,className:n}){let r=i(`shrink-0`,n);switch(P(e,t)??t??`resting`){case`intake`:return(0,b.jsx)(x,{className:r});case`triage`:return(0,b.jsx)(A,{source:`/factory-stage-icons/triage.svg`,className:n});case`planning`:return(0,b.jsx)(N,{progress:.25,className:n});case`execute`:case`working`:return(0,b.jsx)(N,{progress:.5,className:n});case`review`:case`pr-review`:return(0,b.jsx)(A,{source:`/factory-stage-icons/review.svg`,className:n});case`done`:case`terminal`:return(0,b.jsx)(y,{"aria-hidden":!0,className:i(`size-icon-md`,r)});case`canceled`:return(0,b.jsx)(_,{"aria-hidden":!0,className:i(`size-icon-md`,r)});case`resting`:return(0,b.jsx)(g,{"aria-hidden":!0,className:i(`size-icon-md`,r)})}}function z(e,t){return k[L(e,t)].tint}function B(e,t){return i(`bg-fill-subtle dark:bg-card bg-linear-to-r to-transparent`,k[L(e,t)].gradientFrom)}function V(e,t){return k[L(e,t)].strongTint}function H(e,t){return k[L(e,t)].icon}var U=`opacity-30`;function W({stage:e,kind:t,decorative:n=!1}){let r=(0,b.jsx)(R,{stage:e,kind:t,className:k[L(e,t)].icon});return n||!t?r:(0,b.jsx)(`span`,{role:`img`,"aria-label":`${t} phase`,className:`inline-flex shrink-0`,children:r})}export{F as a,V as c,S as d,x as f,I as i,z as l,T as n,H as o,D as r,B as s,W as t,U as u};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-uNv7_2cQ.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Mr as a,jr as o,tn as s}from"./index-BTe7cRAB.js";import{a as c,k as l}from"./Sidebar.es-etnaeLk8.js";import{O as u,T as d,k as f,n as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{t as m}from"./lib-BYybByKv.js";import{r as h}from"./useBoardEditor-B6kA7dRx.js";import{a as g,n as _,s as v,t as y}from"./boardConfigPaths-Btimpi_r.js";import{r as b}from"./settingsColumn-CrKuH8q1.js";import{Pi as x,t as S}from"./Notice-BhWgws6f-D26rmfPt.js";import{X as C}from"./request-CHSXf6Q8.js";import{a as w,o as T,t as E,u as D}from"./settings-RVbY3OIo-BeOJx8jX.js";import{a as O,c as k,d as A,i as j,l as M,n as N,o as P,r as F,t as I,u as L}from"./useRowDrag-E2Ktgp3l.js";import{o as R}from"./useIntakeRoutes-DiGrbexN.js";import{h as z,p as B}from"./ruleLanes-JkSFa1Sb.js";import{s as V}from"./Field.es-CaXwaCGT.js";import{n as H}from"./useBoardCatalog-CNf38nx9.js";import{t as U}from"./SettingsSubsection-CO08NR1O.js";import{s as W}from"./settingsSections-B0_LEh3l.js";var G=e(f(),1),K=u();function q({factoryId:e}){let t=j(e),n=O(e),r=new Map((H(e).data??[]).map(e=>[e.id,e.name])),i=t.data?.pages??[],a=i.flatMap(e=>e.notRouted),o=i[0]?.canEdit??!1,s=e=>n.mutate(e.id,{onSuccess:t=>C.success(`Filing “${e.title}” on ${r.get(t.boardKey)??t.boardKey}.`),onError:e=>C.error(e.message)}),c=t.isPending?`Loading…`:t.isError?`Items not routed didn’t load.`:t.hasNextPage?`${a.length>0?`${a.length}+`:`More`} waiting for a board.`:a.length===0?`Every new issue and pull request found a board.`:`${a.length} waiting for a board.`;return(0,K.jsxs)(`section`,{id:_,"aria-label":`Not routed`,className:`flex scroll-mt-4 flex-col gap-3 px-3.5 pt-3 pb-3.5`,children:[(0,K.jsx)(w,{media:(0,K.jsx)(T,{children:(0,K.jsx)(M,{})}),title:(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[`Not routed`,(0,K.jsx)(V,{"aria-label":`When an item is not routed`,children:`A new issue or pull request ends up here when no board’s rules take it. Change a board’s rules, then route it again.`})]}),description:c}),(a.length>0||t.hasNextPage)&&(0,K.jsxs)(`ul`,{"aria-label":`Items not routed`,className:`ml-11 flex flex-col`,children:[a.map(t=>(0,K.jsx)(`li`,{className:`border-border border-t py-3`,children:(0,K.jsxs)(w,{title:t.url?(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`hover:underline`,children:t.title}):t.title,description:(0,K.jsxs)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1`,children:[t.sourceKey&&(0,K.jsx)(`span`,{children:t.sourceKey}),(0,K.jsx)(`span`,{children:t.reason??`No board’s rules match it.`}),(0,K.jsx)(`time`,{dateTime:t.decidedAt,children:J(t.decidedAt)})]}),children:[(0,K.jsx)(N,{factoryProjectId:e,itemId:t.id,label:`Why?`}),o&&(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>s(t),disabled:n.isPending&&n.variables===t.id,children:`Route again`})]})},t.id)),t.hasNextPage&&(0,K.jsx)(`li`,{className:`border-border flex justify-center border-t pt-3`,children:(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>void t.fetchNextPage(),disabled:t.isFetchingNextPage,children:t.isFetchingNextPage?`Loading…`:`Load more`})})]})]})}function J(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}var Y=d(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:top-0 data-[drop=before]:before:block data-[drop=after]:before:bottom-0 data-[drop=after]:before:block`);function X({factoryId:e}){let t=F(e);return(0,K.jsx)(U,{id:y,scope:`factory`,title:`Intake order`,description:`A new issue or pull request is offered to each board in this order. The first board whose rules take it keeps it.`,children:t.isPending?(0,K.jsx)(E,{children:(0,K.jsx)(D,{label:`Loading intake order`,variant:`item`,rows:3})}):t.isError?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(S,{variant:`destructive`,children:`The intake order didn’t load.`}),(0,K.jsx)(`div`,{className:`border-border rounded-xl border`,children:(0,K.jsx)(q,{factoryId:e})})]}):(0,K.jsx)(Z,{factoryId:e,order:t.data},e)})}function Z({factoryId:e,order:t}){let n=R(e),r=P(e),[i,a]=(0,G.useState)(),o=t.boards.map(e=>e.boardKey),s=i&&ee(i,o)?i:void 0,c=s??o,l=new Map(t.boards.map(e=>[e.boardKey,e.name])),u=s!==void 0&&s.some((e,t)=>e!==o[t]),f=(e,t)=>{let n=[...c],[r]=n.splice(e,1);r!==void 0&&(n.splice(t,0,r),a(n))},h=I({min:0,max:c.length-1,onDrop:f}),g=()=>r.mutate(c,{onSuccess:()=>{a(void 0),C.success(`Intake order saved.`)},onError:e=>C.error(e.message)}),_=t.canEdit&&c.length>1,y=_&&!r.isPending;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)($,{order:t,changed:u}),n.isError&&(0,K.jsx)(S,{variant:`warning`,children:`Rule counts didn’t load.`}),(0,K.jsxs)(`div`,{className:`border-border flex flex-col rounded-xl border`,children:[(0,K.jsx)(E,{role:`list`,"aria-label":`Intake order`,children:c.map((t,r)=>{let i=h.drag?.from===r,a=l.get(t)??t;return(0,K.jsx)(w,{role:`listitem`,"data-drop":h.dropAt(r),style:i?{transform:`translateY(${h.drag?.offset??0}px)`}:void 0,onPointerDown:y?e=>h.onPointerDown(e,r):void 0,onKeyDown:y?e=>h.onKeyDown(e,r):void 0,className:d(`group/row`,Y,i&&`z-10 opacity-90`),media:(0,K.jsxs)(T,{children:[(0,K.jsx)(p,{as:`span`,variant:`caption`,className:d(`tabular-nums`,_&&`pointer-fine:group-hover/row:hidden`,i&&`hidden`),children:r+1}),_&&(0,K.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:d(`text-icon3 hidden cursor-grab touch-none pointer-fine:group-hover/row:inline-flex`,i&&`inline-flex`),children:(0,K.jsx)(k,{className:`size-icon-md`})})]}),title:a,description:(0,K.jsx)(Q,{routes:n.data?.intakeRoutes,boardKey:t}),children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/row:opacity-100 pointer-fine:group-hover/row:opacity-100`,children:[_&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check earlier`,disabled:!y||r===0,onClick:()=>f(r,r-1),children:(0,K.jsx)(L,{})}),(0,K.jsx)(x,{size:`icon-sm`,variant:`ghost`,tooltip:`Check later`,disabled:!y||r===c.length-1,onClick:()=>f(r,r+1),children:(0,K.jsx)(A,{})})]}),(0,K.jsx)(x,{size:`sm`,variant:`ghost`,render:(0,K.jsx)(m,{to:v(e,t)}),children:`Edit rules`})]})},t)})}),(0,K.jsx)(q,{factoryId:e})]}),t.canEdit&&u&&(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(x,{size:`sm`,variant:`ghost`,onClick:()=>a(void 0),disabled:r.isPending,children:`Discard`}),(0,K.jsx)(x,{size:`sm`,variant:`primary`,onClick:g,disabled:r.isPending,children:`Save order`})]})]})}function Q({routes:e,boardKey:t}){if(!e)return null;let{count:n,catchesAll:r}=B(e.filter(e=>e.target.boardKey===t));return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`span`,{children:n===0?`No rules for new issues and pull requests`:`${z(n)} for new issues and pull requests`}),r&&(0,K.jsx)(l,{children:`Ends in catch-all`})]})}function $({order:e,changed:t}){let{compared:n,differing:r,notRouted:i}=e.comparison,a=[];if(e.origin===`derived`&&a.push(`Worked out from the old route list until someone saves an order.`),n>0){let e=i>0?`, ${i} of them Not routed`:``;a.push(r===0?`The last ${n} cards land on the same boards as with the old route list.`:`Of the last ${n} cards, ${r} would land on another board than with the old route list${e}.`)}return e.evaluator===`route-list`&&a.push(`Intake still files cards by the old route list.`),t&&a.push(`Not saved yet. The comparison is for the saved order.`),a.length===0?null:(0,K.jsx)(S,{variant:`info`,children:(0,K.jsx)(`span`,{className:`flex flex-col gap-1`,children:a.map(e=>(0,K.jsx)(`span`,{children:e},e))})})}function ee(e,t){let n=new Set(t);return e.length===t.length&&e.every(e=>n.has(e))}function te(){let e=i(),l=s()?.boardId??``,{isMobile:u,desktopState:f}=c(),p=u||f===`collapsed`,_=h(e.id,l).data?.board,v=o({breadcrumbs:p&&_?(0,K.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,K.jsx)(t,{as:m,to:g(e.id,l),children:_.name}),(0,K.jsx)(t,{as:`span`,isCurrent:!0,children:`Routing`})]}):void 0});return(0,K.jsx)(a,{variant:`narrow`,header:(0,K.jsx)(`div`,{className:d(b,`pb-8`),children:(0,K.jsxs)(r,{children:[(0,K.jsx)(r.Title,{children:`Routing`}),(0,K.jsx)(r.Description,{children:(0,K.jsxs)(`span`,{children:[`The order boards are offered new issues and pull requests. What comes in is chosen in`,` `,(0,K.jsx)(m,{to:W(e.id,`intake`),className:`underline`,children:`Settings → Work Intake`}),`.`]})})]})}),...v,children:(0,K.jsx)(`div`,{className:d(b,`flex flex-col gap-8`),children:(0,K.jsx)(X,{factoryId:e.id})})})}export{te as BoardIntakePage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./Breadcrumb.es-uNv7_2cQ.js";import{t as r}from"./page-header-Maytcmgh--oRyXaDt.js";import{Cr as i,Gn as a,Kn as o,Mr as s,Wn as c,Zn as l,jr as u,qn as d,tn as f}from"./index-BTe7cRAB.js";import{A as p,a as m,k as h,p as g}from"./Sidebar.es-etnaeLk8.js";import{O as _,T as v,k as y,n as b}from"./IconChevronRightMedium.es-BjSIsine.js";import{o as x,t as S}from"./lib-BYybByKv.js";import{r as C,t as w}from"./useBoardEditor-B6kA7dRx.js";import{a as T,i as E,o as D,s as O,t as k}from"./boardConfigPaths-Btimpi_r.js";import{Gt as A,It as j,Pi as M,Rt as N,Ut as ee,Vt as P,Wt as te,t as F}from"./Notice-BhWgws6f-D26rmfPt.js";import{X as I}from"./request-CHSXf6Q8.js";import{n as L}from"./useBoardCatalog-CNf38nx9.js";import{c as R,d as ne,l as re,n as z,r as B,s as ie,t as V,u as H}from"./useRowDrag-E2Ktgp3l.js";import{a as U,d as ae,f as oe,g as W,o as G,r as se,s as K}from"./useIntakeRoutes-DiGrbexN.js";import{C as ce,E as le,_ as ue,a as de,c as fe,d as q,f as pe,g as me,i as he,l as J,m as ge,n as _e,o as ve,s as ye,u as Y,w as be}from"./ruleLanes-JkSFa1Sb.js";import{t as X}from"./createLucideIcon-B6gALBEh.js";import{a as xe,t as Se}from"./BoardIcons-C0Z_7MKH.js";import{t as Ce}from"./input-DqReKX0A-DiwFSTOM.js";import{n as we,t as Te}from"./RadioGroup.es-Brd0MEwi.js";import{n as Ee,t as De}from"./ConditionRows-CTCdJTDp.js";import{t as Oe}from"./GithubIcon.es-DGJTTitG.js";import{E as ke}from"./combobox-parts-Bmj5kzrt-PcITNZFp.js";var Ae={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Ae.node;var je=X(Ae),Me={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};Me.node;var Ne=X(Me),Pe={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};Pe.node;var Fe=X(Pe),Ie={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};Ie.node;var Le=X(Ie),Re={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};Re.node;var ze=X(Re),Be={name:`list-filter`,size:24,node:[[`path`,{d:`M2 5h20`,key:`1fs1ex`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`path`,{d:`M9 19h6`,key:`456am0`}]]};Be.node;var Ve=X(Be),He={name:`list-ordered`,size:24,node:[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]};He.node;var Ue=X(He),We={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};We.node;var Ge=X(We),Ke={name:`plus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]};Ke.node;var qe=X(Ke),Je={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};Je.node;var Ye=X(Je),Xe={name:`triangle-alert`,size:24,node:[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`alert-triangle`]};Xe.node;var Ze=X(Xe),Z=e(y(),1),Q=_();function Qe({when:e,options:t,everything:n}){let r=ce(e,t);return!e||!r?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:n}):(0,Q.jsx)(`span`,{className:`flex flex-wrap items-center gap-1`,children:r.parts.map((t,n)=>{let i=e.conditions[n],a=i&&`conditions`in i?i:void 0;return(0,Q.jsxs)(`span`,{className:`contents`,children:[n>0&&(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:r.join}),a?(0,Q.jsxs)(`span`,{className:`border-border inline-flex max-w-full items-center gap-1 rounded-md border border-dashed px-1 py-0.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,children:a.operator===`OR`?`any of`:`all of`}),(0,Q.jsx)($e,{children:t.replace(/^\((.*)\)$/,`$1`)})]}):(0,Q.jsx)($e,{children:t})]},n)})})}function $e({children:e}){return(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`bg-fill max-w-full truncate rounded-sm px-1.5 py-0.5`,children:e})}function et({boards:e,ownBoard:t,boardKey:n,phaseKey:r}){let i=e.find(e=>e.id===n);if(!i)return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,children:[n,` (not installed)`]});let o=r??i.initialPhase,s=i.phases.find(e=>e.id===o);return(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[i.id!==t&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:c(i)}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`›`})]}),s&&(0,Q.jsx)(Se,{stage:s.id,kind:xe(i.id,s.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`truncate`,children:a(i,o)??o})]})}function tt({factoryId:e,rules:t,board:n,boards:r}){return(0,Q.jsxs)(`section`,{"aria-label":`From other boards`,className:`border-border mt-3 flex flex-col gap-1.5 border-t pt-3`,children:[(0,Q.jsxs)(b,{as:`h4`,variant:`meta`,tone:`muted`,className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ge,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),`From other boards`]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:t.map(t=>{let i=r.find(e=>e.id===t.target.boardKey);return(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(S,{to:O(e,t.target.boardKey),"aria-label":`${t.name}, on ${i?c(i):t.target.boardKey}`,className:v(`group flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,!t.enabled&&`opacity-50`),children:[(0,Q.jsxs)(`span`,{className:`border-border group-hover:border-border-hover flex w-full min-w-0 flex-col gap-1 rounded-lg border border-dashed px-3 py-2 sm:flex-1`,children:[(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:i?c(i):`${t.target.boardKey} (not installed)`}),(0,Q.jsx)(Qe,{when:t.when,options:o(i),everything:`Every card`})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 shrink-0 items-center`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`border-border-strong h-0 w-8 shrink-0 border-t border-dashed`}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex w-44 shrink-0 items-center px-3 py-2`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:n.id,phaseKey:t.target.phaseKey})})]}),!t.enabled&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,children:`Off`})]})},t.id)})})]})}function nt({factoryId:e,boardKey:t,order:n,evaluator:r}){let i=n.some(e=>e.boardKey===t);return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[r===`route-list`?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Intake still files new issues and pull requests by the old route list, not by board.`}):i?(0,Q.jsxs)(`ol`,{"aria-label":`Intake order`,className:`flex flex-wrap items-center gap-1`,children:[n.map(n=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsx)(`li`,{children:n.boardKey===t?(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,"aria-current":`step`,className:`bg-surface3 rounded-md px-2 py-0.5 font-medium`,children:n.name}):(0,Q.jsx)(S,{to:O(e,n.boardKey),className:`text-muted-foreground hover:text-foreground rounded-md px-2 py-0.5`,children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,children:n.name})})}),(0,Q.jsx)(Fe,{"aria-hidden":!0,className:`text-muted-foreground size-icon-xs shrink-0`})]},n.boardKey)),(0,Q.jsx)(`li`,{children:(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`px-2 py-0.5`,children:`Not routed`})})]}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Not in the intake order: new issues and pull requests never reach these rules.`}),(0,Q.jsxs)(S,{to:D(e,t,k),className:`text-muted-foreground hover:text-foreground flex items-center gap-1.5`,children:[(0,Q.jsx)(Ue,{className:`size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,className:`underline decoration-dotted underline-offset-2`,children:`Reorder`})]})]})}var rt=`flex w-full items-start gap-3 rounded-lg border p-3 text-left transition-colors`,it=`border-border-focus bg-fill-hover`,at=`border-border bg-fill-subtle hover:border-border-hover hover:bg-fill-hover`;function ot({selected:e,disabled:t,onClick:n,children:r}){return(0,Q.jsx)(`button`,{type:`button`,role:`checkbox`,"aria-checked":e,disabled:t,onClick:n,className:v(rt,`disabled:opacity-50`,e?it:at),children:r})}function st({value:e,selected:t,disabled:n,onClick:r,children:i}){let a=(0,Z.useId)();return(0,Q.jsxs)(`label`,{onClick:r,className:v(rt,`has-[[role=radio]:focus-visible]:outline-border-focus has-[[role=radio]:focus-visible]:outline-1 has-[[role=radio]:focus-visible]:outline-solid`,t?it:at,n?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsx)(we,{value:e,disabled:n,"aria-labelledby":a,className:`sr-only`}),(0,Q.jsx)(`span`,{id:a,className:`flex min-w-0 items-start gap-3`,children:i})]})}function ct(){return(0,Q.jsx)(h,{size:`xs`,variant:`neutral`,emphasis:`subtle`,icon:(0,Q.jsx)(Oe,{"aria-hidden":`true`}),children:`GitHub only`})}var lt=120,ut=W(K),$=[{id:`trigger`,title:`Trigger`,question:`What should this rule listen for?`},{id:`conditions`,title:`Only if`,question:`Which items should it apply to?`},{id:`action`,title:`Move to`,question:`Where should it go?`},{id:`review`,title:`Review`,question:`Name and check your rule`}];function dt(e,t){let n=e?.phases??[];return t?n.filter(e=>e.kind!==`terminal`):n}function ft(e,t){if(t){let e=ut.safeParse(t);if(!e.success)return e.error.issues[0]?.message}return oe(e,t)??void 0}function pt(e,t,n){let r=`When ${e.map(e=>Y(e).label.toLowerCase()).join(` or `)}${t?`, ${be(t).charAt(0).toLowerCase()}${be(t).slice(1)}`:``}, move to ${n}`;return r.length>lt?`${r.slice(0,119)}…`:r}function mt({factoryId:e,board:t,boards:n,initial:r,initialEvent:i,initialStep:s,readOnly:l,saving:u,error:d,onSave:f,onClose:p}){let m=Ee(e),[h,g]=(0,Z.useState)(()=>r?.on??(i?[i]:[])),[_,y]=(0,Z.useState)(()=>r?.when??null),[x,S]=(0,Z.useState)(()=>(r?.when?.conditions.length??0)>0),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(()=>r?.target.moveToBoardKey??t.id),[D,O]=(0,Z.useState)(()=>r?r.target.phaseKey??void 0:void 0),[k,I]=(0,Z.useState)(()=>r?.name),[L,R]=(0,Z.useState)(s),[ne,re]=(0,Z.useState)(0),z=ge(h),B=n.find(e=>e.id===T),ie=dt(B,z),V=ie.find(e=>e.id===(D??B?.initialPhase)),H=x?_:null,U=h.length?ft(h,H):void 0,oe=V&&B?`${c(B)} › ${a(B,V.id)}`:``,W=k??(V?pt(h,H,oe):``),G={trigger:h.length>0,conditions:h.length>0&&!(x&&C)&&!U,action:V!==void 0,review:W.trim().length>0},se=!l&&G.trigger&&G.conditions&&G.action&&G.review,K=$.findIndex(e=>e.id===L),ce=$[K]??$[0],ue=e=>{g(e),ge(e)&&T!==t.id&&(E(t.id),O(void 0))},de=()=>{se&&V&&f({name:W.trim(),on:h,when:H,target:{phaseKey:V.id,moveToBoardKey:T===t.id?null:T}})},fe=()=>{let e={field:`pullRequest.trusted`,operator:`equals`,value:!0};y(H===null?{operator:`AND`,conditions:[e]}:H.operator===`AND`?{...H,conditions:[...H.conditions,e]}:{operator:`AND`,conditions:[H,e]}),S(!0),w(!1),re(e=>e+1)},q={trigger:h.length?h.map(e=>Y(e).label).join(`, `):void 0,conditions:h.length?be(H,o(t)):void 0,action:V?(0,Q.jsx)(et,{boards:n,ownBoard:t.id,boardKey:T,phaseKey:V.id}):void 0,review:void 0};return(0,Q.jsx)(j,{open:!0,onOpenChange:e=>!e&&p(),children:(0,Q.jsxs)(P,{size:`xl`,children:[(0,Q.jsx)(te,{children:(0,Q.jsx)(A,{children:l?`Rule`:r?`Edit rule`:`Add rule`})}),(0,Q.jsx)(N,{children:(0,Q.jsxs)(`div`,{className:`grid min-h-105 grid-cols-1 gap-6 sm:grid-cols-[12rem_1fr]`,children:[(0,Q.jsx)(`nav`,{"aria-label":`Rule steps`,className:`sm:border-border flex gap-1 overflow-x-auto sm:flex-col sm:border-r sm:pr-4`,children:$.map((e,t)=>{let n=t===0||$.slice(0,t).every(e=>G[e.id]),r=G[e.id]&&e.id!==`review`;return(0,Q.jsxs)(`button`,{type:`button`,disabled:!n,"aria-current":L===e.id?`step`:void 0,onClick:()=>R(e.id),className:v(`flex shrink-0 items-start gap-2.5 rounded-lg px-2 py-2 text-left transition-colors disabled:opacity-40`,L===e.id?`bg-fill-hover`:`hover:bg-fill-subtle`),children:[(0,Q.jsx)(b,{as:`span`,variant:`meta`,className:v(`mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full border`,r?`border-transparent bg-fill-inverse text-background`:`border-border-strong`),children:r?(0,Q.jsx)(Ne,{className:`size-icon-xs`,"aria-hidden":!0}):t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e.title}),q[e.id]&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`hidden truncate sm:block`,children:q[e.id]})]})]},e.id)})}),(0,Q.jsxs)(`section`,{"aria-label":ce.title,className:`flex min-w-0 flex-col gap-4`,children:[(0,Q.jsx)(b,{as:`h3`,variant:`heading`,children:ce.question}),L===`trigger`&&(0,Q.jsx)(_t,{value:h,disabled:l,onChange:ue}),L===`conditions`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(Te,{"aria-label":`Which ones`,value:x?`matching`:`every`,disabled:l,onValueChange:e=>{S(e===`matching`),w(!1)},className:`grid-cols-1 sm:grid-cols-2`,children:[(0,Q.jsx)(st,{value:`every`,selected:!x,disabled:l,children:(0,Q.jsx)(ht,{title:z?`Every new one`:`Every card`,hint:`Run whenever this happens.`})}),(0,Q.jsx)(st,{value:`matching`,selected:x,disabled:l,children:(0,Q.jsx)(ht,{title:`Only ones that match`,hint:`Narrow it down by repository, label, author and more.`})})]}),x&&(0,Q.jsx)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-3`,children:(0,Q.jsx)(De,{label:`Conditions`,rule:_,facts:le(h),options:{...o(t),"source.repository":m},onChange:(e,t)=>{y(e),w(t)}},ne)}),U&&(0,Q.jsx)(F,{variant:`warning`,children:U}),!r?.outsiderPullRequestsGated&&ae(h,H)&&(0,Q.jsx)(F,{variant:`info`,children:(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,Q.jsx)(`span`,{children:`Also matches pull requests from outside authors.`}),!l&&(0,Q.jsx)(`button`,{type:`button`,onClick:fe,className:`shrink-0 underline`,children:`Add: Pull request trusted is yes`})]})})]}),L===`action`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[z?(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`An item with no card yet can only be filed on this board.`}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Board`}),(0,Q.jsx)(Te,{"aria-label":`Board`,value:T,disabled:l,onValueChange:e=>{typeof e==`string`&&e!==T&&(E(e),O(void 0))},className:`grid-cols-1 sm:grid-cols-3`,children:n.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===T,disabled:l,children:(0,Q.jsxs)(b,{as:`span`,variant:`label`,tone:`ink`,children:[c(e),e.id===t.id?` (this board)`:``]})},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:`Phase`}),(0,Q.jsx)(Te,{"aria-label":`Phase`,value:V?.id??null,disabled:l,onValueChange:e=>typeof e==`string`&&O(e),className:`grid-cols-1 sm:grid-cols-2`,children:B&&ie.map(e=>(0,Q.jsx)(st,{value:e.id,selected:e.id===V?.id,disabled:l,onClick:()=>{O(e.id),R(`review`)},children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Se,{stage:e.id,kind:xe(B.id,e.kind),decorative:!0}),(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,children:a(B,e.id)})]})},e.id))})]})]}),L===`review`&&(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`muted`,children:`Name`}),(0,Q.jsx)(Ce,{value:W,maxLength:lt,disabled:l,onChange:e=>I(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`border-border bg-fill-subtle rounded-xl border p-4`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,className:`mb-3 block`,children:`This rule reads as`}),(0,Q.jsxs)(`ol`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(gt,{label:`When`,children:q.trigger}),(0,Q.jsx)(gt,{label:`Only if`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(ze,{className:`text-muted-foreground size-icon-sm`,"aria-hidden":!0}),q.conditions]})}),(0,Q.jsx)(gt,{label:`Then`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`Move to `,(0,Q.jsx)(je,{className:`size-icon-sm`,"aria-hidden":!0}),` `,q.action]})})]})]})]}),d&&(0,Q.jsx)(F,{variant:`destructive`,role:`alert`,children:d})]})]})}),(0,Q.jsxs)(ee,{children:[(0,Q.jsx)(M,{variant:`ghost`,onClick:p,children:l?`Close`:`Cancel`}),(0,Q.jsx)(`div`,{className:`flex-1`}),K>0&&(0,Q.jsx)(M,{variant:`default`,onClick:()=>R($[K-1].id),children:`Back`}),!l&&(L===`review`||r&&se?(0,Q.jsx)(M,{variant:`primary`,disabled:!se||u,onClick:de,children:u?`Saving…`:r?`Save rule`:`Create rule`}):(0,Q.jsx)(M,{variant:`primary`,disabled:!G[L],onClick:()=>R($[K+1]?.id??`review`),children:`Continue`}))]})]})})}function ht({title:e,hint:t}){return(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(b,{as:`span`,variant:`label`,tone:`ink`,className:`block`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`block`,children:t})]})}function gt({label:e,children:t}){return(0,Q.jsxs)(`li`,{className:`grid grid-cols-[4.5rem_1fr] items-start gap-3`,children:[(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,tone:`muted`,children:e}),(0,Q.jsx)(b,{as:`span`,variant:`body-sm`,children:t})]})}function _t({value:e,disabled:t,onChange:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e.includes(`work_item.created`)&&(0,Q.jsxs)(F,{variant:`info`,children:[`Also listens on “`,Y(`work_item.created`).label,`”, which takes new issues and pull requests. Saving keeps it.`]}),_e.map(r=>(0,Q.jsxs)(`div`,{role:`group`,"aria-label":r.title,className:`flex flex-col gap-2`,children:[(0,Q.jsx)(b,{as:`span`,variant:`eyebrow`,tone:`muted`,children:r.title}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:r.events.map(r=>{let i=Y(r),a=i.icon,o=e.includes(r);return(0,Q.jsxs)(ot,{selected:o,disabled:t||o&&e.length===1,onClick:()=>n(o?e.filter(e=>e!==r):[...e,r]),children:[(0,Q.jsx)(a,{className:`text-badge-amber-indicator mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(ht,{title:i.label,hint:i.description}),i.githubOnly&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,Q.jsx)(ct,{})})]},r)})})]},r.title))]})}function vt({count:e,into:t,leaving:n,showAll:r}){let i=n?`sending cards to ${t}`:`moving cards into ${t}`;return(0,Q.jsxs)(`div`,{className:`border-border flex items-center gap-2 rounded-lg border px-3 py-2`,children:[(0,Q.jsx)(Ve,{className:`size-icon-md text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`p`,variant:`body-sm`,tone:e===void 0?`muted`:`ink`,className:`flex-1`,children:e===void 0?`Couldn’t pick out the rules ${i}, so every rule is shown.`:e===0?`No rule is ${i}.`:`Only the ${e===1?`rule`:`${e} rules`} ${i}.`}),(0,Q.jsx)(M,{size:`sm`,variant:`ghost`,render:(0,Q.jsx)(S,{to:r}),children:`Show all`})]})}var yt=v(`relative before:pointer-events-none before:absolute before:right-0 before:left-0 before:z-20 before:hidden before:h-0.5 before:rounded-full before:bg-border-focus`,`data-[drop=before]:before:-top-1 data-[drop=before]:before:block data-[drop=after]:before:-bottom-1 data-[drop=after]:before:block`);function bt({event:e,rules:t,board:n,boards:r,phaseOptions:i,canEdit:o,skips:s,footer:l,incoming:u,only:d,onEdit:f,onAdd:p,onMove:m,onToggle:h,onDelete:_,onUngate:y}){let x=Y(e),S=x.icon,C=de(t,e),w=fe(e),T=ve(e),E=V({min:0,max:t.length-1,onDrop:m}),D=o&&t.length>1&&!d,O=l??(t.length?`Otherwise, the card stays where it is`:u?`No rules: this board’s cards stay where they are`:`No rules: the card stays where it is`);return(0,Q.jsxs)(`section`,{"aria-label":x.label,className:v(`flex flex-col gap-3 rounded-xl border border-border bg-card p-4`,!t.length&&!u&&`opacity-60 focus-within:opacity-100 hover:opacity-100`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(S,{className:`text-badge-amber-indicator size-3.5 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(b,{as:`h3`,variant:`label`,tone:`ink`,children:x.label}),x.githubOnly&&(0,Q.jsx)(ct,{})]}),x.description&&(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:x.description})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsxs)(`ol`,{"aria-label":`${x.label} rules`,className:`flex min-w-0 flex-col`,children:[t.map((l,u)=>{if(d&&!d.has(l.id))return null;let p=me(t,e,u),S=p>=0,O=!l.enabled||S,k=E.drag?.from===u,A=s?.get(l.id),j=r.find(e=>e.id===(l.target.moveToBoardKey??l.target.boardKey)),N=!pe(l.name,[x.label,be(l.when,i),j&&c(j),a(j,l.target.phaseKey)].join(` `));return(0,Q.jsxs)(`li`,{"aria-label":l.name,"data-drop":E.dropAt(u),style:k?{transform:`translateY(${E.drag?.offset??0}px)`}:void 0,onPointerDown:D?e=>E.onPointerDown(e,u):void 0,className:v(`group/rule flex flex-col`,yt,k&&`z-10 opacity-90`),children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 sm:flex-1`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Edit conditions of ${l.name}`,onClick:()=>f(l,`conditions`),onKeyDown:D?e=>E.onKeyDown(e,u):void 0,className:v(`flex w-full items-start gap-2.5 rounded-lg border bg-fill-subtle px-3 py-2 text-left transition-colors hover:border-border-hover`,O?`border-dashed border-border opacity-50`:`border-border`),children:[(0,Q.jsxs)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`bg-fill mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full tabular-nums`,children:[(0,Q.jsx)(`span`,{className:v(D&&`pointer-fine:group-hover/rule:hidden`,k&&`hidden`),children:u+1}),D&&(0,Q.jsx)(`span`,{"data-grip":!0,"aria-hidden":!0,className:v(`hidden cursor-grab touch-none pointer-fine:group-hover/rule:flex`,k&&`flex`),children:(0,Q.jsx)(R,{className:`size-icon-sm`})})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[N&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`ink`,className:`truncate font-medium`,children:l.name}),(0,Q.jsx)(Qe,{when:l.when,options:i,everything:T})]})]}),D&&(0,Q.jsxs)(`div`,{className:`border-border bg-card absolute top-0 right-2 flex -translate-y-1/2 rounded-md border shadow-sm transition-opacity pointer-fine:opacity-0 pointer-fine:group-focus-within/rule:opacity-100 pointer-fine:group-hover/rule:opacity-100`,children:[(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check earlier`,disabled:u===0,onClick:()=>m(u,u-1),children:(0,Q.jsx)(H,{})}),(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`Check later`,disabled:u===t.length-1,onClick:()=>m(u,u+1),children:(0,Q.jsx)(ne,{})})]})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 sm:shrink-0`,children:[(0,Q.jsxs)(`div`,{className:v(`flex min-w-0 items-center`,O&&`opacity-40`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:v(`h-px w-8 shrink-0`,O?`border-t border-dashed border-border-strong`:`bg-muted-foreground`)}),(0,Q.jsx)(je,{"aria-hidden":!0,className:`text-muted-foreground size-icon-sm mr-2 -ml-1.5 shrink-0`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Edit where ${l.name} moves the card`,onClick:()=>f(l,`action`),className:`border-border bg-fill-subtle hover:border-border-hover flex w-44 shrink-0 rounded-lg border px-3 py-2 text-left`,children:(0,Q.jsx)(et,{boards:r,ownBoard:n.id,boardKey:l.target.moveToBoardKey??l.target.boardKey,phaseKey:l.target.phaseKey})})]}),o&&(0,Q.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[(0,Q.jsx)(ke,{"aria-label":`${l.name} on`,checked:l.enabled,onCheckedChange:e=>h(l,e)}),(0,Q.jsxs)(g,{children:[(0,Q.jsx)(g.Trigger,{render:(0,Q.jsx)(M,{variant:`ghost`,size:`icon-sm`,tooltip:`More for ${l.name}`,children:(0,Q.jsx)(Le,{})})}),(0,Q.jsx)(g.Content,{align:`end`,children:(0,Q.jsxs)(g.Item,{variant:`destructive`,onClick:()=>_(l),children:[(0,Q.jsx)(Ye,{}),`Delete rule`]})})]})]})]})]}),O&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:S?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs`,"aria-hidden":!0}),`Never reached: rule `,p+1,` above matches `,T.toLowerCase(),`.`]}):`Off, skipped`}),l.problems.map(e=>(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex items-center gap-1.5`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),e]},e)),A&&(0,Q.jsx)(St,{skips:A}),ue(l,e)&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[`Skips outside authors’ pull requests (older rule).`,o&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(l),className:`underline`,children:`Let outside authors match`})]}),q(l,e)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:`Moves cards only: files no new pull requests`}),w&&ye(l)&&(0,Q.jsx)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3`,children:Y(`work_item.created`).label}),u!==C&&!d&&(0,Q.jsxs)(`div`,{"aria-hidden":!0,className:`flex h-7 items-center pl-5.5`,children:[(0,Q.jsx)(`span`,{className:`bg-border-strong h-full w-px`}),(0,Q.jsx)(b,{as:`span`,variant:`meta`,tone:`muted`,className:`ml-2`,children:`no`})]})]},l.id)}),!d&&(0,Q.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[C<0&&(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`flex flex-1 items-center gap-2.5 px-3 py-1.5`,children:[(0,Q.jsx)(re,{className:`size-icon-md shrink-0`,"aria-hidden":!0}),O]}),o&&(0,Q.jsx)(M,{variant:`ghost`,size:`sm`,icon:(0,Q.jsx)(qe,{}),onClick:p,children:`Add rule`})]})]}),u]})]})}function xt(e){return e?.match(/was skipped: (.+?)\.?$/)?.[1]??e??`its target couldn’t take the card`}function St({skips:e}){let{count:t,latest:n}=e;return(0,Q.jsxs)(b,{as:`span`,variant:`caption`,tone:`muted`,className:`mt-1 ml-3 flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,Q.jsx)(Ze,{className:`text-warning-indicator size-icon-xs shrink-0`,"aria-hidden":!0}),(0,Q.jsxs)(`span`,{children:[`Skipped `,t===1?`once`:`${t} times`,` in the last 30 days: `,xt(n.reason),`.`]}),n.url?(0,Q.jsxs)(`a`,{href:n.url,target:`_blank`,rel:`noreferrer`,className:`underline`,children:[`Latest: `,n.title]}):(0,Q.jsxs)(`span`,{children:[`Latest: `,n.title]})]})}var Ct=new Set([`revision_mismatch`,`intake_route_set_mismatch`,`intake_route_not_found`]);function wt(e){return e instanceof w&&e.code!==void 0&&Ct.has(e.code)}function Tt(e){return wt(e)?`Someone else changed these rules first. They have been reloaded; try again.`:e instanceof Error?e.message:`The change didn’t save.`}function Et({factoryId:e,boardId:t}){let n=L(e),r=n.data?.find(e=>e.id===t);return n.isPending?(0,Q.jsx)(p,{className:`h-64 w-full`}):n.isError?(0,Q.jsx)(F,{variant:`destructive`,children:`Boards didn’t load.`}):r?(0,Q.jsx)(Dt,{factoryId:e,board:r,boards:n.data},`${e}:${r.id}`):(0,Q.jsx)(F,{variant:`warning`,children:`This board isn’t installed.`})}function Dt({factoryId:e,board:t,boards:n}){let r=se(e,t.id),i=G(e),s=B(e),c=ie(e),u=U(e),[f,m]=(0,Z.useState)(),h=(0,Z.useRef)(void 0),g=e=>{h.current=e,m(e)},[_,v]=(0,Z.useState)(),y=r.data?.intakeRoutes??[],S=r.data?.canEdit??!1,C=o(t),w=(i.data?.intakeRoutes??[]).filter(e=>e.target.moveToBoardKey===t.id&&e.target.boardKey!==t.id),T=new Map(c.data?.skipped.map(e=>[e.routeId,e])),[D]=x(),k=D.get(`into`)??void 0,A=D.has(E),j=A||k!==void 0,M=j&&i.data?l(i.data.intakeRoutes,{key:t.id,initialPhase:t.initialPhase}):void 0,N=M&&new Set((A?M.leaving:M.into.get(k??``)??[]).map(e=>e.id)),ee=e=>!N||e.some(e=>N.has(e.id));if(r.isPending||j&&i.isPending)return(0,Q.jsx)(p,{className:`h-64 w-full`});if(r.isError)return(0,Q.jsx)(F,{variant:`destructive`,children:`This board’s rules didn’t load.`});let P=e=>u.mutateAsync(e).catch(e=>I.error(Tt(e))),te=(e,n,r)=>{let i=J(y,e).map(e=>e.id);P([{kind:`reorder`,boardKey:t.id,ids:d(y,i,n,r)}])},L=e=>{v(void 0),g(e)},R=async e=>{let n=h.current,r=n?.rule,i=()=>n!==void 0&&h.current===n;v(void 0);try{if(r)await u.mutateAsync([{kind:`update`,id:r.id,patch:{name:e.name,on:e.on,when:e.when,target:{boardKey:r.target.boardKey,...e.target,joinClosedIssue:r.target.joinClosedIssue},expectedRevision:r.revision}}]);else{let[n]=await u.mutateAsync([{kind:`create`,route:{...e,target:{boardKey:t.id,...e.target}}}]);i()&&g(void 0),n&&await re(n,e.on).catch(e=>I.error(Tt(e)));return}i()&&g(void 0)}catch(e){if(!i())return;if(r&&wt(e))return ne(r);v(Tt(e))}},ne=async e=>{let t=h.current,n=(await r.refetch()).data?.intakeRoutes.find(t=>t.id===e.id);t&&h.current===t&&(n?(g({...t,rule:n}),v(`Someone else changed this rule first. It now shows their version; make your change again.`)):(g(void 0),I.error(`Someone else deleted this rule first.`)))},re=async(e,n)=>{if(e.target.boardKey!==t.id)return;let i=(await r.refetch()).data?.intakeRoutes??[],a=i.map(e=>e.id),o=a.indexOf(e.id),s=n.flatMap(t=>{let n=J(i,t),r=n[me(n,t,n.findIndex(t=>t.id===e.id))];return r?[a.indexOf(r.id)]:[]}),c=Math.min(...s);o<0||!(c<o)||await u.mutateAsync([{kind:`reorder`,boardKey:t.id,ids:d(i,a,o,c)}])},z=s.data?.evaluator===`route-list`?`Otherwise: the old route list decides`:he(s.data?.boards,t.id);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[i.isError&&(0,Q.jsx)(F,{variant:`warning`,children:`Rules on other boards that move cards here didn’t load, so they aren’t shown.`}),j&&(0,Q.jsx)(vt,{count:N?.size,into:A||!k?`other boards`:a(t,k)??k,leaving:A,showAll:O(e,t.id)}),_e.filter(e=>e.events.some(e=>ee([...J(y,e),...J(w,e)]))).map(r=>(0,Q.jsxs)(`section`,{"aria-label":r.title,className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(b,{as:`h2`,variant:`subheading`,tone:`ink`,children:r.title}),r.events.some(fe)?s.data&&(0,Q.jsx)(nt,{factoryId:e,boardKey:t.id,order:s.data.boards,evaluator:s.data.evaluator}):(0,Q.jsx)(b,{as:`p`,variant:`caption`,tone:`muted`,children:`Only cards already on this board; other boards never see them.`})]}),r.events.map(r=>{let i=fe(r),a=J(y,r),o=J(w,r).filter(e=>!N||N.has(e.id));return ee([...a,...o])?(0,Q.jsx)(bt,{event:r,rules:a,board:t,boards:n,phaseOptions:C,canEdit:S,skips:T,footer:i?z:void 0,only:N,incoming:o.length?(0,Q.jsx)(tt,{factoryId:e,rules:o,board:t,boards:n}):void 0,onEdit:(e,t)=>L({rule:e,step:t}),onAdd:()=>L({event:r,step:`conditions`}),onMove:(e,t)=>te(r,e,t),onToggle:(e,t)=>void P([{kind:`update`,id:e.id,patch:{enabled:t,expectedRevision:e.revision}}]),onDelete:e=>void P([{kind:`delete`,id:e.id,expectedRevision:e.revision}]).then(t=>t&&I.success(`Deleted “${e.name}”`)),onUngate:e=>void P([{kind:`update`,id:e.id,patch:{outsiderPullRequestsGated:!1,expectedRevision:e.revision}}]).then(t=>t&&I.success(`“${e.name}” now matches outside authors’ pull requests`))},r):null})]},r.title)),f&&(0,Q.jsx)(mt,{factoryId:e,board:t,boards:n,initial:f.rule,initialEvent:f.event,initialStep:f.step,readOnly:!S,saving:u.isPending,error:_,onSave:e=>void R(e),onClose:()=>g(void 0)},f.rule?`${f.rule.id}:${f.rule.revision}`:`new-${f.event}`)]})}var Ot=`mx-auto w-full max-w-3xl`;function kt(){let e=i(),a=f()?.boardId??``,{isMobile:o,desktopState:c}=m(),l=o||c===`collapsed`,d=C(e.id,a).data?.board,p=u({breadcrumbs:l&&d?(0,Q.jsxs)(n,{label:`Breadcrumb`,className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Q.jsx)(t,{as:S,to:T(e.id,a),children:d.name}),(0,Q.jsx)(t,{as:`span`,isCurrent:!0,children:`Rules`})]}):void 0});return(0,Q.jsx)(s,{variant:`narrow`,header:(0,Q.jsxs)(`div`,{className:v(Ot,`pb-8`),children:[(0,Q.jsxs)(r,{children:[(0,Q.jsx)(r.Title,{children:`Rules`}),(0,Q.jsx)(r.Description,{children:`What happens to issues and pull requests on this board. In each lane the first matching rule wins.`})]}),(0,Q.jsx)(`div`,{className:`mt-3`,children:(0,Q.jsx)(z,{factoryProjectId:e.id,label:`Test an issue or pull request`})})]}),...p,children:(0,Q.jsx)(`div`,{className:Ot,children:(0,Q.jsx)(Et,{factoryId:e.id,boardId:a})})})}export{kt as BoardRulesPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{cn as t,ia as n,sn as r,ua as i}from"./Notice-BhWgws6f-D26rmfPt.js";import{O as a,T as o,k as s,o as c}from"./IconChevronRightMedium.es-BjSIsine.js";import{A as l}from"./Sidebar.es-etnaeLk8.js";import{t as u}from"./popup-anchor.es-B4jCSTe8.js";var d=e(s(),1),f=a(),p=e=>(0,f.jsx)(`svg`,{width:`19.125`,height:`18`,viewBox:`-1.0625 -1 19.125 18`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,f.jsx)(`path`,{d:`M5.25684 12.6387L10.4003 3.36133H11.7432L6.5997 12.6387H5.25684Z`,fill:`currentColor`})}),m=({children:e,label:t,className:n,listClassName:r})=>(0,f.jsx)(`nav`,{"aria-label":t,className:n,children:(0,f.jsx)(`ol`,{className:o(`flex items-center gap-0.5`,r),children:e})}),h=e=>(0,f.jsx)(l,{className:`h-3 w-24`,...e}),g=({className:e,as:a,to:s,isCurrent:l,action:m,switcher:g,icon:_,isLoading:v,children:y,...b})=>{let x=a||`span`,S=!(!g||!l&&s),C=d.useRef(null);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`li`,{ref:C,className:o(`group flex h-control-sm min-w-0 items-center`,l?`shrink`:`shrink-0`,S&&`relative rounded-full has-[[data-slot=crumb-switcher]_[data-popup-open]]:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:hover:bg-fill-subtle has-[[data-slot=crumb-switcher]_button:enabled]:active:bg-fill`),children:[(0,f.jsxs)(x,{"aria-current":l?`page`:void 0,className:o(`inline-flex min-w-0 items-center gap-2 overflow-hidden rounded-full px-[.9em]`,n.sm,c,l?`max-w-xs cursor-default text-foreground`:S?o(t,`max-w-48`):o(r,`max-w-48 cursor-pointer hover:bg-fill-subtle active:bg-fill`),e),to:s,...b,children:[_&&(0,f.jsx)(i,{className:o(`ml-[-.3em] shrink-0 opacity-50 group-hover:opacity-100`,`transition-opacity duration-normal ease-out-custom`),children:_}),v?(0,f.jsx)(h,{}):(0,f.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:y})]}),g&&(0,f.jsx)(`span`,{"data-slot":`crumb-switcher`,className:o(`-ml-1 flex h-control-sm shrink-0 items-center`,S&&`[&_button]:bg-transparent! [&_button:enabled]:after:absolute [&_button:enabled]:after:inset-0 [&_button:enabled]:after:rounded-full`),children:(0,f.jsx)(u,{value:C,children:g})}),m&&(0,f.jsx)(`span`,{className:`-ml-1 flex h-control-sm shrink-0 items-center`,children:m})]}),!l&&(0,f.jsx)(`li`,{role:`separator`,className:`flex h-full items-center`,children:(0,f.jsx)(i,{className:`text-placeholder`,children:(0,f.jsx)(p,{})})})]})};export{g as n,m as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{dc as t,ea as n,fc as r,mc as i}from"./Notice-BhWgws6f-Csn4zhYz.js";import{O as a,T as o,c as s,k as c}from"./IconChevronRightMedium.es-BjSIsine.js";var l=e(c(),1),u=a(),d=i(o(t,`rounded-xl transition-all duration-normal ease-out-custom motion-reduce:transition-none`),{variants:{elevation:{flat:`shadow-none`,raised:``},interactive:{true:o(r,n,`cursor-pointer active:scale-99`),false:``}},compoundVariants:[{elevation:`flat`,interactive:!0,class:s}],defaultVariants:{elevation:`raised`,interactive:!1}}),f=l.forwardRef(({className:e,elevation:t,interactive:n,as:r,...i},a)=>{let s=r||(n?`button`:`div`);return(0,u.jsx)(s,{ref:a,type:s===`button`?`button`:void 0,className:o(d({elevation:t,interactive:n}),e),...i})});f.displayName=`Card`;function p({className:e,elevation:t,LinkComponent:n=`a`,...r}){return(0,u.jsx)(n,{className:o(d({elevation:t,interactive:!0}),e),...r})}var m=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`div`,{ref:n,className:o(`flex flex-col space-y-1.5 px-3 py-1`,e),...t}));m.displayName=`CardHeader`;var h=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`h3`,{ref:n,className:o(`text-subheading text-foreground`,e),...t}));h.displayName=`CardTitle`;var g=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`p`,{ref:n,className:o(`text-caption text-muted-foreground`,e),...t}));g.displayName=`CardDescription`;var _=i(``,{variants:{density:{default:`p-3`,compact:`p-2`}},defaultVariants:{density:`default`}}),v=l.forwardRef(({className:e,density:t,...n},r)=>(0,u.jsx)(`div`,{ref:r,className:o(_({density:t}),e),...n}));v.displayName=`CardContent`;var y=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`div`,{ref:n,className:o(`flex items-center p-3 pt-0`,e),...t}));y.displayName=`CardFooter`;var b=l.forwardRef(({className:e,as:t=`div`,...n},r)=>(0,u.jsx)(t,{ref:r,className:o(`divide-y divide-border overflow-hidden rounded-lg border border-border bg-sidebar *:p-3`,e),...n}));b.displayName=`CardInset`;export{v as n,p as r,f as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{ea as t,gc as n,mc as r,pc as i}from"./Notice-BhWgws6f-D26rmfPt.js";import{O as a,T as o,c as s,k as c}from"./IconChevronRightMedium.es-BjSIsine.js";var l=e(c(),1),u=a(),d=n(o(i,`rounded-xl transition-all duration-normal ease-out-custom motion-reduce:transition-none`),{variants:{elevation:{flat:`shadow-none`,raised:``},interactive:{true:o(r,t,`cursor-pointer active:scale-99`),false:``}},compoundVariants:[{elevation:`flat`,interactive:!0,class:s}],defaultVariants:{elevation:`raised`,interactive:!1}}),f=l.forwardRef(({className:e,elevation:t,interactive:n,as:r,...i},a)=>{let s=r||(n?`button`:`div`);return(0,u.jsx)(s,{ref:a,type:s===`button`?`button`:void 0,className:o(d({elevation:t,interactive:n}),e),...i})});f.displayName=`Card`;function p({className:e,elevation:t,LinkComponent:n=`a`,...r}){return(0,u.jsx)(n,{className:o(d({elevation:t,interactive:!0}),e),...r})}var m=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`div`,{ref:n,className:o(`flex flex-col space-y-1.5 px-3 py-1`,e),...t}));m.displayName=`CardHeader`;var h=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`h3`,{ref:n,className:o(`text-subheading text-foreground`,e),...t}));h.displayName=`CardTitle`;var g=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`p`,{ref:n,className:o(`text-caption text-muted-foreground`,e),...t}));g.displayName=`CardDescription`;var _=n(``,{variants:{density:{default:`p-3`,compact:`p-2`}},defaultVariants:{density:`default`}}),v=l.forwardRef(({className:e,density:t,...n},r)=>(0,u.jsx)(`div`,{ref:r,className:o(_({density:t}),e),...n}));v.displayName=`CardContent`;var y=l.forwardRef(({className:e,...t},n)=>(0,u.jsx)(`div`,{ref:n,className:o(`flex items-center p-3 pt-0`,e),...t}));y.displayName=`CardFooter`;var b=l.forwardRef(({className:e,as:t=`div`,...n},r)=>(0,u.jsx)(t,{ref:r,className:o(`divide-y divide-border overflow-hidden rounded-lg border border-border bg-sidebar *:p-3`,e),...n}));b.displayName=`CardInset`;export{v as n,p as r,f as t};
@@ -0,0 +1,6 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-Sr6WSEaV.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-6WNNvkM4.js","assets/dist-B5wMYzWI.js","assets/dist-D1JI_ikE.js","assets/dist-DtnqB3m_.js","assets/dist-CMX7_OjZ.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{O as t,T as n,b as r,d as i,f as a,k as o,m as s,o as c,s as l,u,v as d}from"./IconChevronRightMedium.es-BjSIsine.js";import{Ao as f,Bi as p,Bs as m,Fa as h,Is as g,Kn as _,Lo as v,Po as y,Ps as b,Ri as x,Rs as S,Sa as C,Ui as w,Us as T,Vs as E,Ws as D,ac as O,an as k,fa as A,gc as j,go as M,ha as N,hs as ee,ma as P,oc as te,os as ne,pa as F,ra as re,sn as ie,wn as ae}from"./Notice-BhWgws6f-D26rmfPt.js";import{a as I,i as L,o as R,r as z,s as oe}from"./request-CHSXf6Q8.js";import{c as B,l as V,p as H,s as se,v as ce}from"./Sidebar.es-etnaeLk8.js";import{n as le,t as ue}from"./CompositeRoot-GT8aurLY.js";import{t as de}from"./copy-button-5PzdvEQI-NsU3f0kN.js";import{n as fe}from"./index.module-D3qeux6j.js";import{a as U,i as pe,m as W,n as me}from"./dist-6WNNvkM4.js";import{t as G}from"./preload-helper-BLdHbfdN.js";var K=e(o(),1),q=t(),he=h();function ge(e){let t=S(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=T(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r;return(f(n)!==a||f(r)!==o)&&(n=a,r=o),{width:n,height:r}}var _e=K.createContext(void 0);function ve(){let e=K.useContext(_e);if(e===void 0)throw Error(O(65));return e}var ye=K.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:c=!0,style:l,...u}=e,{value:d,getTabPanelIdByValue:f,onValueChange:m,orientation:h,tabActivationDirection:_}=V(),{activateOnFocus:x,registerTabResizeObserverElement:S,tabsListElement:T}=ve(),{highlightedIndex:E,onHighlightedIndexChange:D}=w(),O=C(o),k=K.useMemo(()=>({disabled:r,id:O,value:a}),[r,O,a]),{compositeProps:A,compositeRef:j,index:M}=ce({metadata:k}),N=a===d,P=K.useRef(!1),F=K.useRef(null),re=v(e=>{F.current?.(),F.current=e?S(e):null});te(()=>{if(P.current){P.current=!1;return}if(!(N&&M>-1&&E!==M))return;let e=T;if(e!=null){let t=b(y(e));if(t&&g(e,t))return}r||D(M)},[N,M,E,D,r,T]);let{getButtonProps:ie,buttonRef:ae}=p({disabled:r,native:c,focusableWhenDisabled:!0}),I=f(a),L=K.useRef(!1),R=K.useRef(!1);function z(e){m(a,ee(ne,e.nativeEvent,void 0,{activationDirection:`none`}))}function oe(e){N||r||z(e)}function H(e){N||r||x&&(!L.current||R.current)&&z(e)}function se(e){if(N||r)return;L.current=!0,R.current=e.button===0;let t=y(e.currentTarget);function n(){L.current=!1,R.current=!1,t.removeEventListener(`pointerup`,n),t.removeEventListener(`pointercancel`,n)}t.addEventListener(`pointerup`,n),t.addEventListener(`pointercancel`,n)}return s(`button`,e,{state:{disabled:r,active:N,orientation:h,tabActivationDirection:_},ref:[t,ae,j,re],props:[A,{role:`tab`,"aria-controls":I,"aria-selected":N,id:O,onClick:oe,onFocus:H,onPointerDown:se,[le]:N?``:void 0,onKeyDownCapture(){P.current=!0}},u,ie],stateAttributesMapping:B})}),be=()=>()=>{},xe=()=>!0,Se=()=>!1;function Ce(){return(0,he.useSyncExternalStore)(be,xe,Se)}function we(){let[e,t]=K.useState(!1);return K.useEffect(()=>{t(!0)},[]),e}var Te=d(18)?Ce:we;function Ee(){return!Te()}function De(e){let{script:t}=e,{nonce:n}=k();return Ee()?(0,q.jsx)(`script`,{nonce:n,dangerouslySetInnerHTML:{__html:t},suppressHydrationWarning:!0}):null}var Oe=`--active-tab-left`,ke=`--active-tab-right`,Ae=`--active-tab-top`,je=`--active-tab-bottom`,Me=`--active-tab-width`,Ne=`--active-tab-height`,Pe,Fe={...B,activeTabPosition:()=>null,activeTabSize:()=>null},Ie=2,Le=K.forwardRef(function(e,t){let{className:n,render:r,renderBeforeHydration:i=!1,style:a,...o}=e,{getTabElementBySelectedValue:c,orientation:l,tabActivationDirection:u,value:d}=V(),{tabsListElement:f,registerIndicatorUpdateListener:p}=ve(),m=M();K.useEffect(()=>p(m),[p,m]);let h=0,g=0,_=0,v=0,y=0,b=0,x=!1;if(d!=null&&f!=null){let e=c(d);if(e!=null){x=!0;let{width:t,height:n}=ge(e),{width:r,height:i}=ge(f),a=e.getBoundingClientRect(),o=f.getBoundingClientRect(),s=r>0?o.width/r:1,c=i>0?o.height/i:1,l=Re(e,f);h=l.left,_=l.top;let u=(a.left-o.left)/s+f.scrollLeft-f.clientLeft,d=(a.top-o.top)/c+f.scrollTop-f.clientTop,p=Be(e);Math.abs(u-p.x-h)<=Ie&&Math.abs(d-p.y-_)<=Ie&&(h=u,_=d),y=t,b=n,g=f.scrollWidth-h-y,v=f.scrollHeight-_-b}}let S=x?{left:h,right:g,top:_,bottom:v}:null,C=x?{width:y,height:b}:null,w=x?{[Oe]:`${h}px`,[ke]:`${g}px`,[Ae]:`${_}px`,[je]:`${v}px`,[Me]:`${y}px`,[Ne]:`${b}px`}:void 0,T=s(`span`,e,{state:{orientation:l,activeTabPosition:S,activeTabSize:C,tabActivationDirection:u},ref:t,props:[{role:`presentation`,style:w,hidden:!(x&&y>0&&b>0)},o,{suppressHydrationWarning:!0}],stateAttributesMapping:Fe});return d==null?null:(0,q.jsxs)(K.Fragment,{children:[T,i&&(Pe||=(0,q.jsx)(De,{script:``}))]})});function Re(e,t){let n=ze(e),r=ze(t),i=n.left-r.left-t.clientLeft,a=n.top-r.top-t.clientTop,o=m(e);for(;T(o)&&o!==t&&!D(o);)i-=o.scrollLeft,a-=o.scrollTop,o=m(o);return{left:i,top:a}}function ze(e){let t=0,n=0,r=e;for(;r!=null;){t+=r.offsetLeft,n+=r.offsetTop;let e=r.offsetParent;e!=null&&(t+=e.clientLeft,n+=e.clientTop),r=e}return{left:t,top:n}}function Be(e){let t=E(e).getComputedStyle(e),{x:n,y:r}=ae(e,t),i=n,a=r,{translate:o}=t;if(o&&o!==`none`){let t=o.split(` `);i+=Ve(t[0],e.offsetWidth),a+=Ve(t[1],e.offsetHeight)}return{x:i,y:a}}function Ve(e,t){if(!e)return 0;let n=parseFloat(e);return Number.isFinite(n)?e.endsWith(`%`)?n/100*t:n:0}var He=K.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:i,loopFocus:a=!0,render:o,style:s,...c}=e,{orientation:l,setTabMap:u,tabActivationDirection:d}=V(),[f,p]=K.useState(0),[m,h]=K.useState(null),g=K.useRef(new Set),_=K.useRef(new Set),y=K.useRef(null);te(()=>{if(typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{g.current.forEach(e=>{e()})});return y.current=e,m&&e.observe(m),_.current.forEach(t=>{e.observe(t)}),()=>{e.disconnect(),y.current=null}},[m]);let b=v(e=>(g.current.add(e),()=>{g.current.delete(e)})),x=v(e=>(_.current.add(e),y.current?.observe(e),()=>{_.current.delete(e),y.current?.unobserve(e)})),S={orientation:l,tabActivationDirection:d},C={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},w=K.useMemo(()=>({activateOnFocus:n,registerIndicatorUpdateListener:b,registerTabResizeObserverElement:x,tabsListElement:m}),[n,b,x,m]);return(0,q.jsx)(_e.Provider,{value:w,children:(0,q.jsx)(ue,{render:o,className:i,style:s,state:S,refs:[t,h],props:[C,c],stateAttributesMapping:B,highlightedIndex:f,enableHomeAndEndKeys:!0,loopFocus:a,orientation:l,onHighlightedIndexChange:p,onMapChange:u,disabledIndices:r})})}),Ue=a(`IconArrowInbox`,()=>(0,q.jsx)(`path`,{d:`M20 15V18C20 19.1046 19.1046 20 18 20H6C4.89543 20 4 19.1046 4 18V15M12 14.5V4M12 14.5L8.5 11M12 14.5L15.5 11`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})),J=(0,K.createContext)(null),We=(0,K.createContext)(null),Ge=j(`relative flex items-center text-body`,{variants:{variant:{pill:`w-fit gap-1 rounded-full bg-fill-subtle p-1`,"pill-ghost":`w-fit gap-0.5 rounded-full`}},defaultVariants:{variant:`pill`}});function Ke(e,t){return e===`pill`?t?`h-[calc(100%-0.5rem)]`:`h-[calc(100%-0.25rem)]`:`h-full`}var qe=({children:e,className:t,variant:r,size:a=`md`,sticky:o,style:s})=>{let c=r??`pill`,l=(0,K.useContext)(J),d=(0,K.useRef)(null),f=(0,K.useRef)(new Map),p=(0,K.useRef)(new Map),m=(0,K.useRef)(l?.value),[h,g]=(0,K.useState)(null),[v,y]=(0,K.useState)([]),b=(0,K.useCallback)(e=>{y(t=>{let n=t.find(t=>t.value===e.value);return n&&n.element===e.element&&n.width===e.width&&n.label===e.label&&n.disabled===e.disabled&&n.onClick===e.onClick&&n.onClose===e.onClose?t:(n?t.map(t=>t.value===e.value?e:t):[...t,e]).sort((e,t)=>e.element===t.element?0:e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)})},[]),x=(0,K.useCallback)(e=>y(t=>t.filter(t=>t.value!==e)),[]),S=l?.appearance===`contained`,C=c===`pill`&&!S,w=Ke(c,S);(0,K.useLayoutEffect)(()=>{let e=d.current;if(!e||!S)return;let t=()=>g(e.clientWidth);if(t(),!(`ResizeObserver`in globalThis))return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[S]);let T=S?4:0,E=S?30:0,D=(0,K.useMemo)(()=>{let e=new Set;if(!S||h===null||v.reduce((e,t)=>e+t.width,0)+T*Math.max(v.length-1,0)+E<=h)return e;let t=h-E-48,n=v.find(e=>e.value===l?.value);n&&(t-=n.width+T);let r=!1;for(let i of v)i!==n&&(r||i.width+T>t?(r=!0,e.add(i.value)):t-=i.width+T);return e},[S,h,v,T,E,l?.value]),O=v.filter(e=>D.has(e.value)),k=v.filter(e=>!D.has(e.value)).reduce((e,t)=>e+t.width+T,S?4:0),j=v.filter(e=>!D.has(e.value)&&e.onClose),M=(0,K.useMemo)(()=>({variant:c,size:a,hiddenValues:D,register:b,unregister:x}),[c,a,D,b,x]);return(0,K.useLayoutEffect)(()=>{let e=new Map(p.current),t=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;for(let n of v){if(D.has(n.value))continue;let r=n.element.offsetLeft,i=p.current.get(n.value),a=f.current.get(n.value);a&&(a.style.left=`${r}px`,a.style.top=`${n.element.offsetTop}px`,a.style.width=`${n.element.offsetWidth}px`,a.style.height=`${n.element.offsetHeight}px`);let o=i===void 0?0:i-r,s=n.value!==l?.value&&Math.abs(o)<=32;!t&&s&&o!==0&&`animate`in n.element&&n.element.animate([{transform:`translateX(${o}px)`},{transform:`translateX(0)`}],{duration:180,easing:`cubic-bezier(0.32, 0.72, 0, 1)`}),e.set(n.value,r)}for(let t of e.keys())v.some(e=>e.value===t)||e.delete(t);p.current=e},[D,v,l?.value]),(0,K.useLayoutEffect)(()=>{let e=m.current;m.current=l?.value;let t=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;if(!S||e===l?.value||t)return;let n=d.current?.querySelector(`[data-slot="tabs-indicator"]`);n&&`animate`in n&&n.animate([{opacity:.72,scale:`0.97`},{opacity:1,scale:`1`}],{duration:140,easing:`cubic-bezier(0.32, 0.72, 0, 1)`})},[S,l?.value]),(0,q.jsx)(We.Provider,{value:M,children:(0,q.jsx)(P,{delay:200,children:(0,q.jsxs)(`div`,{ref:d,"data-slot":`tabs-list-scroll`,className:n(`relative w-full overflow-x-auto`,o&&`sticky top-0 z-10 bg-background`),children:[(0,q.jsxs)(He,{"data-slot":`tabs-list`,"data-overflow":O.length>0||void 0,"data-variant":c,"data-size":a,className:n(`group/tabs-list`,Ge({variant:c}),C&&n(re[a],`items-stretch p-0.5`),t),style:s,children:[e,(0,q.jsx)(Le,{className:n(`absolute top-1/2 left-0 z-0 rounded-full bg-[var(--tab-indicator-color,var(--fill-hover))]`,w,`w-[var(--active-tab-width)]`,`transition-[width,transform] duration-200 ease-in-out motion-reduce:transition-none`),"data-slot":`tabs-indicator`,style:{transform:`translateY(var(--tabs-indicator-y, -50%)) translateX(var(--active-tab-left))`}})]}),(0,q.jsx)(`div`,{"data-slot":`tabs-close-actions`,children:j.map(e=>(0,q.jsx)(`div`,{ref:t=>{t?f.current.set(e.value,t):f.current.delete(e.value)},"data-slot":`tab-close-item`,"data-visible":l?.value===e.value||void 0,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(N,{render:(0,q.jsx)(`button`,{type:`button`,tabIndex:l?.value===e.value?0:-1,"data-slot":`tab-close`,onClick:e.onClose,className:n(`rounded p-0.5 hover:bg-fill-hover hover:text-destructive-foreground`,u.colors)}),children:[(0,q.jsxs)(`span`,{className:`sr-only`,children:[`Close `,e.label]}),(0,q.jsx)(_,{"aria-hidden":`true`,className:`size-icon-xs`})]}),(0,q.jsxs)(F,{children:[`Close `,e.label]})]})},e.value))}),O.length>0&&(0,q.jsx)(`div`,{"data-slot":`tabs-overflow`,style:{transform:`translateX(${k}px)`},className:`tabs-overflow`,children:(0,q.jsxs)(H,{children:[(0,q.jsxs)(H.Trigger,{"aria-label":`${O.length} more tabs`,variant:`ghost`,size:`sm`,className:`tabular-nums`,children:[`+`,O.length,(0,q.jsx)(i,{"aria-hidden":`true`,className:`size-icon-xs`})]}),(0,q.jsx)(H.Content,{children:O.map((e,t)=>(0,q.jsxs)(K.Fragment,{children:[(0,q.jsx)(H.Item,{"data-slot":`tabs-overflow-tab`,disabled:e.disabled,className:e.onClose?`pr-9`:void 0,style:{gridArea:`${t+1} / 1`},onClick:()=>{l?.select(e.value),e.onClick?.()},children:e.label}),e.onClose?(0,q.jsxs)(A,{children:[(0,q.jsxs)(N,{render:(0,q.jsx)(H.Item,{"data-slot":`tabs-overflow-close`,className:`pointer-events-none z-10 m-1 size-6 self-center justify-self-end p-0 opacity-0 hover:text-destructive-foreground data-[highlighted]:text-destructive-foreground`,style:{gridArea:`${t+1} / 1`},onClick:e.onClose}),children:[(0,q.jsxs)(`span`,{className:`sr-only`,children:[`Close `,e.label]}),(0,q.jsx)(_,{"aria-hidden":`true`,className:`size-icon-xs`})]}),(0,q.jsxs)(F,{side:`right`,children:[`Close `,e.label]})]}):null]},e.value))})]})})]})})})},Je=({children:e,defaultTab:t,value:r,onValueChange:i,appearance:a=`default`,frame:o=`inset`,className:s,...c})=>{let[l,u]=(0,K.useState)(t),d=r??l,f=e=>{u(e),i?.(e)};return(0,q.jsx)(J.Provider,{value:{appearance:a,value:d,select:f},children:(0,q.jsx)(se,{defaultValue:t,value:d,onValueChange:f,"data-slot":`tabs`,"data-appearance":a,"data-frame":o,className:n(`group/tabs`,a==="default"?`overflow-y-auto`:`w-full min-w-0`,s),...c,children:e})})},Ye=({children:e,value:t,onClick:r,onClose:i,disabled:a,disabledTooltip:o,tooltip:s,attention:u=!1,className:d})=>{let f=(0,K.useContext)(We),p=(0,K.useRef)(null),m=f?.register,h=f?.unregister,g=f?.hiddenValues.has(t)??!1;(0,K.useEffect)(()=>{let n=p.current;if(!n||!m)return;let o=()=>m({value:t,label:e,disabled:a??!1,width:n.getBoundingClientRect().width,element:n,onClick:r,onClose:i});if(o(),!(`ResizeObserver`in globalThis))return;let s=new ResizeObserver(o);return s.observe(n),()=>s.disconnect()},[m,t,e,a,r,i]),(0,K.useEffect)(()=>()=>h?.(t),[h,t]);let _=f?.size??`md`,v=f?.variant===`pill-ghost`?n(x({variant:`ghost`,size:_}),`relative z-10 whitespace-nowrap`,`data-[active]:text-foreground`,`aria-disabled:cursor-not-allowed aria-disabled:opacity-50`,`data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`,d):n(`text-label`,ie,u&&`relative`,`flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap outline-none`,c,l,`data-[active]:text-foreground`,`disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-muted-foreground`,`aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:hover:text-muted-foreground`,`data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:hover:text-muted-foreground`,d),y=(0,q.jsxs)(ye,{ref:p,render:(0,q.jsx)(`div`,{}),nativeButton:!1,"data-overflowed":g||void 0,"aria-hidden":g||void 0,value:t,disabled:a||g,"data-slot":`tab`,"data-base-ui-swipe-ignore":``,"data-closable":i?``:void 0,className:v,onClick:r,children:[e,u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`tab-attention`}),(0,q.jsx)(`span`,{className:`sr-only`,children:` Needs attention`})]})]});return a&&o?(0,q.jsxs)(A,{children:[(0,q.jsx)(N,{render:(0,q.jsx)(`span`,{tabIndex:0,className:`inline-flex`}),children:y}),(0,q.jsx)(F,{children:o})]}):s&&!a?(0,q.jsxs)(A,{children:[(0,q.jsx)(N,{render:y}),(0,q.jsx)(F,{children:s})]}):y},Y={js:`javascript`,javascript:`javascript`,mjs:`javascript`,cjs:`javascript`,node:`javascript`,ts:`typescript`,typescript:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,jsx:`jsx`,json:`json`,json5:`json`,md:`markdown`,markdown:`markdown`,py:`python`,python:`python`,sh:`bash`,bash:`bash`,shell:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,diff:`diff`,patch:`diff`,css:`css`,scss:`css`,html:`html`,htm:`html`,xml:`xml`,svg:`xml`,sql:`sql`};async function X(e){let[{StreamLanguage:t},n]=await Promise.all([G(()=>import(`./dist-Sr6WSEaV.js`).then(e=>e.h),__vite__mapDeps([0,1,2])),e]);return t.define(n).parser}async function Z(e){let{javascript:t}=await G(async()=>{let{javascript:e}=await import(`./dist-B5wMYzWI.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([3,1,4,2,0]));return t(e).language.parser}var Xe={javascript:()=>Z({}),jsx:()=>Z({jsx:!0}),typescript:()=>Z({typescript:!0}),tsx:()=>Z({jsx:!0,typescript:!0}),json:()=>G(()=>import(`./dist-DtnqB3m_.js`).then(e=>e.t).then(e=>e.jsonLanguage.parser),__vite__mapDeps([5,1,4,2,0])),markdown:()=>G(()=>import(`./dist-CMX7_OjZ.js`).then(e=>e.t).then(e=>e.markdownLanguage.parser),__vite__mapDeps([6,1,0,2,3,4])),bash:()=>X(G(()=>import(`./shell-DwuoZtxw.js`).then(e=>e.shell),[])),python:()=>X(G(()=>import(`./python-DIWH3FmR.js`).then(e=>e.python),[])),yaml:()=>X(G(()=>import(`./yaml-BEzOWJ7L.js`).then(e=>e.yaml),[])),diff:()=>X(G(()=>import(`./diff-ChtP43wD.js`).then(e=>e.diff),[])),css:()=>X(G(()=>import(`./css-CIHhKeSF.js`).then(e=>e.css),[])),html:()=>X(G(()=>import(`./xml-aKzObEic.js`).then(e=>e.html),[])),xml:()=>X(G(()=>import(`./xml-aKzObEic.js`).then(e=>e.xml),[])),sql:()=>X(G(()=>import(`./sql-DrH7SW3s.js`).then(e=>e.standardSQL),[]))},Q=new Map;function Ze(e){let t=Q.get(e);return t||(t=Xe[e](),t.catch(()=>Q.delete(e)),Q.set(e,t)),t}var Qe=pe([{tag:[U.comment,U.bracket],class:`syntax-comment`},{tag:[U.string,U.meta,U.regexp,U.name,U.quote,U.standard(U.tagName)],class:`syntax-string`},{tag:[U.atom,U.bool,U.special(U.variableName)],class:`syntax-literal`},{tag:[U.keyword,U.operator,U.tagName,U.deleted],class:`syntax-keyword`},{tag:[U.function(U.propertyName),U.propertyName,U.variableName,U.number],class:`syntax-name`},{tag:[U.definition(U.variableName),U.function(U.variableName),U.className,U.attributeName,U.url],class:`syntax-definition`},{tag:U.link,class:`syntax-link`},{tag:U.heading,class:`syntax-heading`},{tag:U.emphasis,class:`syntax-emphasis`},{tag:U.strong,class:`syntax-strong`},{tag:U.strikethrough,class:`syntax-strike`},{tag:U.invalid,class:`syntax-invalid`}]);function $e(e,t){if(!t||!e.startsWith(t.code))return;let n=t.code.length;return W.applyChanges(W.addTree(t.tree),[{fromA:n,toA:n,fromB:n,toB:e.length}])}async function et(e,t,n){let r=Y[t?.toLowerCase()];if(!r)return null;let i=(await Ze(r)).parse(e,$e(e,n)),a=[],o=[a],s=(e,t)=>{e.split(`
3
+ `).forEach((e,n)=>{n>0&&o.push(a=[]),e&&a.push(t?{content:e,className:t}:{content:e})})},c=0;return me(i,Qe,(t,n,r)=>{t>c&&s(e.slice(c,t)),s(e.slice(t,n),r),c=n}),c<e.length&&s(e.slice(c)),{code:e,tokens:o,tree:i}}function tt(e){let t=e?.split(`.`).pop()?.toLowerCase();return t?Y[t]:void 0}var nt=75;function rt(e,t){let[n,r]=(0,K.useState)(null),i=(0,K.useRef)(null),[a,o]=fe(e,nt,{leading:!0,maxWait:nt});return(0,K.useEffect)(()=>()=>o.cancel(),[o]),(0,K.useEffect)(()=>{if(!t)return;let e=!1,n=i.current?.lang===t?i.current:void 0;return et(a,t,n).then(n=>{!e&&n?.tokens.length&&(i.current={...n,lang:t},r(i.current))}).catch(()=>{}),()=>{e=!0}},[a,t]),t?n:null}function it(e,t,n){return!e||e.lang!==n?null:t.startsWith(e.code)?e:null}var $=K.memo(function({code:e,lang:t,lineClassName:n,...r}){let i=it(rt(e,t),e,t);if(!i){if(!n)return(0,q.jsx)(`pre`,{...r,children:e});let t=e.split(`
4
+ `);return(0,q.jsx)(`pre`,{...r,children:t.map((e,r)=>(0,q.jsxs)(K.Fragment,{children:[(0,q.jsx)(`span`,{"data-line":r,className:n(r,e),children:e}),r!==t.length-1&&`
5
+ `]},r))})}let a=e.slice(i.code.length),o=0;return(0,q.jsx)(`pre`,{...r,children:(0,q.jsxs)(`code`,{className:`font-[inherit]`,children:[i.tokens.map((e,t)=>{let r=o,a=r,s=e.map(e=>{let t=a;return a+=e.content.length,(0,q.jsx)(`span`,{className:e.className,children:e.content},t)});return o=a+1,(0,q.jsxs)(K.Fragment,{children:[n?(0,q.jsx)(`span`,{"data-line":t,className:n(t,e.map(e=>e.content).join(``)),children:s}):(0,q.jsx)(`span`,{children:s}),t!==i.tokens.length-1&&`
6
+ `]},r)}),a]})})});function at({code:e,options:t,value:r,onValueChange:i,selector:a=`select`,fileName:o,lang:s,overflow:c=`wrap`,copyMessage:l,copyTooltip:d,actions:f,className:p}){let m=t&&t.length>0,h=m&&a===`tabs`,g=m&&a===`select`,_=t?.[0],v=r??_?.value;return(0,q.jsxs)(`figure`,{className:n(`group relative flex w-full flex-col overflow-hidden rounded-2xl border border-border bg-background [contain:inline-size]`,p),children:[h&&_&&(0,q.jsx)(Je,{defaultTab:_.value,value:v,onValueChange:i??(()=>{}),children:(0,q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,q.jsx)(qe,{children:t.map(e=>(0,q.jsx)(Ye,{value:e.value,children:e.label},e.value))})}),f&&(0,q.jsx)(`div`,{className:`flex shrink-0 items-center border-b border-border pr-2 pl-3`,children:f})]})}),g&&t&&(0,q.jsxs)(`div`,{className:`flex items-center border-b border-border px-2 py-1.5`,children:[(0,q.jsxs)(z,{value:v,onValueChange:i,children:[(0,q.jsx)(R,{size:`sm`,variant:`ghost`,className:`w-auto`,children:(0,q.jsx)(oe,{})}),(0,q.jsx)(L,{children:t.map(e=>(0,q.jsx)(I,{value:e.value,children:e.label},e.value))})]}),f&&(0,q.jsx)(`div`,{className:`ml-auto flex items-center`,children:f})]}),!m&&o&&(0,q.jsxs)(`div`,{className:`flex items-center border-b border-border px-4 py-2`,children:[(0,q.jsx)(`figcaption`,{className:`font-mono text-caption text-muted-foreground`,children:o}),f&&(0,q.jsx)(`div`,{className:`ml-auto flex items-center`,children:f})]}),!m&&!o&&f&&(0,q.jsx)(`div`,{className:`flex items-center justify-end border-b border-border px-2 py-1.5`,children:f}),(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)($,{code:e,lang:s,className:n(`px-4 py-3 font-mono text-caption text-foreground`,c===`scroll`?`overflow-x-auto whitespace-pre`:`break-all whitespace-pre-wrap`)}),(0,q.jsx)(de,{content:e,copyMessage:l,tooltip:d,className:n(`absolute top-2 right-2 opacity-100 group-focus-within:opacity-100 group-hover:opacity-100 pointer-fine:opacity-0`,u.opacity)})]})]})}export{Qe as a,Je as c,tt as i,J as l,$ as n,Ye as o,rt as r,qe as s,at as t,Ue as u};
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-B5wMYzWI.js","assets/rolldown-runtime-XKyaHtl9.js","assets/dist-D1JI_ikE.js","assets/dist-6WNNvkM4.js","assets/dist-Sr6WSEaV.js","assets/dist-DtnqB3m_.js","assets/dist-CMX7_OjZ.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ft as t,Ki as n,Pi as r,Xi as i,mc as a}from"./Notice-BhWgws6f-Csn4zhYz.js";import{r as o}from"./highlight-DF-vd68d-B8-NxWBf.js";import{t as s}from"./copy-button-5PzdvEQI-BG6Brssj.js";import{t as c}from"./IconCodeBrackets.es-o1byTuto.js";import{t as l}from"./preload-helper-BLdHbfdN.js";import{X as u}from"./request-qUzOU__J.js";import{O as d,T as f,k as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{n as m}from"./dist-DtnqB3m_.js";import{n as ee,r as te}from"./dist-CMX7_OjZ.js";import{$ as ne,B as re,C as h,Ct as ie,D as g,Dt as _,E as v,Et as y,F as b,H as x,I as ae,J as oe,K as S,L as C,M as w,N as T,P as se,R as E,S as D,St as O,T as ce,Tt as k,U as le,V as ue,W as A,X as j,Y as de,Z as fe,_ as pe,a as M,at as N,bt as me,c as he,ct as ge,dt as P,et as F,f as _e,ft as ve,gt as ye,j as be,k as xe,l as Se,lt as I,mt as Ce,n as we,nt as Te,o as Ee,ot as De,q as Oe,rt as ke,st as Ae,t as je,tt as Me,ut as L,vt as R,wt as Ne,xt as Pe,y as Fe,yt as Ie,z as Le}from"./dist-Sr6WSEaV.js";import{a as z,c as Re}from"./dist-6WNNvkM4.js";import{c as ze,d as Be,l as Ve,u as He}from"./dist-B5wMYzWI.js";var Ue,We=()=>Ue??=Promise.all([l(()=>import(`./standalone-YobQElH8.js`),[]),l(()=>import(`./babel-BaOs8qJH.js`),[]),l(()=>import(`./estree-Cw-tQG5d.js`),[])]).catch(e=>{throw Ue=void 0,e}),Ge=async e=>{let[t,n,r]=await We();return await t.format(e,{semi:!1,parser:`json`,printWidth:80,tabWidth:2,plugins:[n,r]})},B=e(p()),V=d();function Ke(){return Ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ke.apply(null,arguments)}function qe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Je=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=$e(e.state,n.from);return r.line?Xe(e):r.block?Qe(e):!1};function Ye(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Xe=Ye(it,0),Ze=Ye(rt,0),Qe=Ye((e,t)=>rt(e,t,nt(t)),0);function $e(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var et=50;function tt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-et,r),o=e.sliceDoc(i,i+et),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+et),d=e.sliceDoc(i-et,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function nt(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function rt(e,t,n=t.selection.ranges){let r=n.map(e=>$e(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>tt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function it(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=$e(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var at=De.define(),ot=De.define(),st=ve.define(),ct=ve.define({combine(e){return Ne(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),lt=Ie.define({create(){return Et.empty},update(e,t){let n=t.state.facet(ct),r=t.annotation(at);if(r){let i=H.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?gt(o,o.length,n.minDepth,i):xt(o,t.startState.selection),new Et(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ot);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Pe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=H.fromTransaction(t),o=t.annotation(Pe.time),s=t.annotation(Pe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Et(e.done.map(H.fromJSON),e.undone.map(H.fromJSON))}});function ut(e={}){return[lt,ct.of(e),b.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ft:e.inputType==`historyRedo`?pt:null;return n?(e.preventDefault(),n(t)):!1}})]}function dt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(lt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ft=dt(0,!1),pt=dt(1,!1),mt=dt(0,!0),ht=dt(1,!0),H=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&ge.fromJSON(t.changes),[],t.mapped&&Ae.fromJSON(t.mapped),t.startSelection&&L.fromJSON(t.startSelection),t.selectionsAfter.map(L.fromJSON))}static fromTransaction(t,n){let r=U;for(let e of t.startState.facet(st)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,U)}static selection(t){return new e(void 0,U,void 0,void 0,t)}};function gt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function _t(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function vt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function yt(e,t){return e.length?t.length?e.concat(t):e:t}var U=[],bt=200;function xt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),gt(e,e.length-1,1e9,n.setSelAfter(r)))}return[H.selection([t])]}function St(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ct(e,t){if(!e.length)return e;let n=e.length,r=U;for(;n;){let i=wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[H.selection(r)]:U}function wt(e,t,n){let r=yt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):U,n);if(!e.changes)return H.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new H(i,R.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Tt=/^(input\.type|delete)($|\.)/,Et=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Tt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,_t(s.changes,t.changes))||r==`input.type.compose`)?gt(o,o.length-1,i.minDepth,new H(t.changes.compose(s.changes),yt(R.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,U)):gt(o,o.length,i.minDepth,t),new e(o,U,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:U;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&vt(a[a.length-1],t)?this:new e(xt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ct(this.done,t),Ct(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:at.of({side:e,rest:St(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?U:r.slice(0,r.length-1);return i.mapped&&(n=Ct(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:at.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Et.empty=new Et(U,U);var Dt=[{key:`Mod-z`,run:ft,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:pt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:pt,preventDefault:!0},{key:`Mod-u`,run:mt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ht,preventDefault:!0}];function W(e,t){return L.create(e.ranges.map(t),e.mainIndex)}function G(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function K({state:e,dispatch:t},n){let r=W(e.selection,n);return!r.eq(e.selection,!0)&&(t(G(e,r)),!0)}function Ot(e,t){return L.cursor(t?e.to:e.from)}function kt(e,t){return K(e,n=>n.empty?e.moveByChar(n,t):Ot(n,t))}function q(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var At=e=>kt(e,!q(e)),jt=e=>kt(e,q(e));function Mt(e,t){return K(e,n=>n.empty?e.moveByGroup(n,t):Ot(n,t))}var Nt=e=>Mt(e,!q(e)),Pt=e=>Mt(e,q(e));typeof Intl<`u`&&Intl.Segmenter;function Ft(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function It(e,t,n){let r=w(e).resolveInner(t.head),i=n?Re.closedBy:Re.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ft(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?xe(e,r.from,1):xe(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,L.cursor(s,n?-1:1)}var Lt=e=>K(e,t=>It(e.state,t,!q(e))),Rt=e=>K(e,t=>It(e.state,t,q(e)));function zt(e,t){return K(e,n=>{if(!n.empty)return Ot(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Bt=e=>zt(e,!1),Vt=e=>zt(e,!0);function Ht(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(b.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Ut(e,t){let n=Ht(e),{state:r}=e,i=W(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Ot(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=b.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(G(r,i),{effects:a}),!0}var Wt=e=>Ut(e,!1),Gt=e=>Ut(e,!0);function J(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=L.cursor(r.from+n))}return i}var Kt=e=>K(e,t=>J(e,t,!0)),qt=e=>K(e,t=>J(e,t,!1)),Jt=e=>K(e,t=>J(e,t,!q(e))),Yt=e=>K(e,t=>J(e,t,q(e))),Xt=e=>K(e,t=>e.moveToLineBoundary(t,!1,!1)),Zt=e=>K(e,t=>e.moveToLineBoundary(t,!0,!1));function Qt(e,t,n){let r=!1,i=W(e.selection,t=>{let i=xe(e,t.head,-1)||xe(e,t.head,1)||t.head>0&&xe(e,t.head-1,1)||t.head<e.doc.length&&xe(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?L.range(t.anchor,a):L.cursor(a)});return r?(t(G(e,i)),!0):!1}var $t=({state:e,dispatch:t})=>Qt(e,t,!1);function Y(e,t,n){let r=W(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=L.range(e.head,e.anchor));let r=n(e);return L.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(G(e.state,r)),!0)}function en(e,t){return Y(e,t,n=>e.moveByChar(n,t))}var tn=e=>en(e,!q(e)),nn=e=>en(e,q(e));function rn(e,t){return Y(e,t,n=>e.moveByGroup(n,t))}var an=e=>rn(e,!q(e)),on=e=>rn(e,q(e)),sn=e=>{let t=!q(e);return Y(e,t,n=>It(e.state,n,t))},cn=e=>{let t=q(e);return Y(e,t,n=>It(e.state,n,t))};function ln(e,t){return Y(e,t,n=>e.moveVertically(n,t))}var un=e=>ln(e,!1),dn=e=>ln(e,!0);function fn(e,t){return Y(e,t,n=>e.moveVertically(n,t,Ht(e).height))}var pn=e=>fn(e,!1),mn=e=>fn(e,!0),hn=e=>Y(e,!0,t=>J(e,t,!0)),gn=e=>Y(e,!1,t=>J(e,t,!1)),_n=e=>{let t=!q(e);return Y(e,t,n=>J(e,n,t))},vn=e=>{let t=q(e);return Y(e,t,n=>J(e,n,t))},yn=e=>Y(e,!1,t=>L.cursor(e.lineBlockAt(t.head).from)),bn=e=>Y(e,!0,t=>L.cursor(e.lineBlockAt(t.head).to)),xn=({state:e,dispatch:t})=>(t(G(e,{anchor:0})),!0),Sn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.doc.length})),!0),Cn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.selection.main.anchor,head:0})),!0),wn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Tn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),En=({state:e,dispatch:t})=>{let n=Gn(e).map(({from:t,to:n})=>L.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:L.create(n),userEvent:`select`})),!0},Dn=({state:e,dispatch:t})=>{let n=W(e.selection,t=>{let n=w(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return L.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(G(e,n)),!0)};function On(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(G(n,L.create(i,i.length-1))),!0)}var kn=e=>On(e,!1),An=e=>On(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=L.create([n.main]):n.main.empty||(r=L.create([L.cursor(n.main.head)])),r?(t(G(e,r)),!0):!1};function Mn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Nn(e,o,!1)):o>i&&(n=`delete.forward`,o=Nn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Nn(e,i,!1),a=Nn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:L.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?b.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Nn(e,t,n){if(e instanceof b)for(let r of e.state.facet(b.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Pn=(e,t,n)=>Mn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=k(s,a.tabSize)%D(a)||D(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=y(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=y(o.text,c-o.from,!1,!1)+o.from);return c}),Fn=e=>Pn(e,!1,!0),In=e=>Pn(e,!0,!1),Ln=(e,t)=>Mn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=y(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Rn=e=>Ln(e,!1),zn=e=>Ln(e,!0),Bn=e=>Mn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Vn=e=>Mn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Hn=e=>Mn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Un=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:me.of([``,``])},range:L.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Wn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:y(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:y(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:L.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Gn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Kn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Gn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(L.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(L.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:L.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0);function Yn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Gn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Xn=({state:e,dispatch:t})=>Yn(e,t,!1),Zn=({state:e,dispatch:t})=>Yn(e,t,!0),Qn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Gn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=W(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function $n(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=w(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Re.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var er=nr(!1),tr=nr(!0);function nr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&$n(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new we(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=h(s,r);for(c??=k(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,v(t,c)];return o&&l.push(v(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:me.of(l)},range:L.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function rr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:L.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var ir=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new we(e,{overrideIndentation:e=>n[e]??-1}),i=rr(e,(t,i,a)=>{let o=h(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=v(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},ar=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(rr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(g)})}),{userEvent:`input.indent`})),!0),or=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(rr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=k(r,e.tabSize),a=0,o=v(e,Math.max(0,i-D(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),sr=e=>(e.setTabFocusMode(),!0),cr=[{key:`Ctrl-b`,run:At,shift:tn,preventDefault:!0},{key:`Ctrl-f`,run:jt,shift:nn},{key:`Ctrl-p`,run:Bt,shift:un},{key:`Ctrl-n`,run:Vt,shift:dn},{key:`Ctrl-a`,run:Xt,shift:yn},{key:`Ctrl-e`,run:Zt,shift:bn},{key:`Ctrl-d`,run:In},{key:`Ctrl-h`,run:Fn},{key:`Ctrl-k`,run:Bn},{key:`Ctrl-Alt-h`,run:Rn},{key:`Ctrl-o`,run:Un},{key:`Ctrl-t`,run:Wn},{key:`Ctrl-v`,run:Gt}],lr=[{key:`ArrowLeft`,run:At,shift:tn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Nt,shift:an,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Jt,shift:_n,preventDefault:!0},{key:`ArrowRight`,run:jt,shift:nn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Pt,shift:on,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Yt,shift:vn,preventDefault:!0},{key:`ArrowUp`,run:Bt,shift:un,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:xn,shift:Cn},{mac:`Ctrl-ArrowUp`,run:Wt,shift:pn},{key:`ArrowDown`,run:Vt,shift:dn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Sn,shift:wn},{mac:`Ctrl-ArrowDown`,run:Gt,shift:mn},{key:`PageUp`,run:Wt,shift:pn},{key:`PageDown`,run:Gt,shift:mn},{key:`Home`,run:qt,shift:gn,preventDefault:!0},{key:`Mod-Home`,run:xn,shift:Cn},{key:`End`,run:Kt,shift:hn,preventDefault:!0},{key:`Mod-End`,run:Sn,shift:wn},{key:`Enter`,run:er,shift:er},{key:`Mod-a`,run:Tn},{key:`Backspace`,run:Fn,shift:Fn,preventDefault:!0},{key:`Delete`,run:In,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Rn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:zn,preventDefault:!0},{mac:`Mod-Backspace`,run:Vn,preventDefault:!0},{mac:`Mod-Delete`,run:Hn,preventDefault:!0}].concat(cr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),ur=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Lt,shift:sn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Rt,shift:cn},{key:`Alt-ArrowUp`,run:qn},{key:`Shift-Alt-ArrowUp`,run:Xn},{key:`Alt-ArrowDown`,run:Jn},{key:`Shift-Alt-ArrowDown`,run:Zn},{key:`Mod-Alt-ArrowUp`,run:kn},{key:`Mod-Alt-ArrowDown`,run:An},{key:`Escape`,run:jn},{key:`Mod-Enter`,run:tr},{key:`Alt-l`,mac:`Ctrl-l`,run:En},{key:`Mod-i`,run:Dn,preventDefault:!0},{key:`Mod-[`,run:or},{key:`Mod-]`,run:ar},{key:`Mod-Alt-\\`,run:ir},{key:`Shift-Mod-k`,run:Qn},{key:`Shift-Mod-\\`,run:$t},{key:`Mod-/`,run:Je},{key:`Alt-A`,mac:`Ctrl-A`,run:Ze},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:sr}].concat(lr),dr={key:`Tab`,run:ar,shift:or},fr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,pr=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(fr(e)):fr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return O(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=_(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ie(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(pr.prototype[Symbol.iterator]=function(){return this});var mr={from:-1,to:-1,match:/.*/.exec(``),precise:!0},hr=`gm`+(/x/.unicode==null?``:`u`),gr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=mr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new yr(e,t,n,r,i);this.re=new RegExp(t,hr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=xr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=xr(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},_r=new WeakMap,vr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=_r.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return _r.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),_r.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},yr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=mr,this.matchPos=xr(e,r),this.re=new RegExp(t,hr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=vr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=xr(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=vr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(gr.prototype[Symbol.iterator]=yr.prototype[Symbol.iterator]=function(){return this});function br(e){try{return new RegExp(e,hr),!0}catch{return!1}}function xr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Sr=e=>{let t=le(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=Te(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=L.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,b.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Cr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},wr=ve.define({combine(e){return Ne(e,Cr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Tr(e){let t=[jr,Ar];return e&&t.push(wr.of(e)),t}var Er=T.mark({class:`cm-selectionMatch`}),Dr=T.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Or(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=I.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=I.Word)}function kr(e,t,n,r){return e(t.sliceDoc(n,n+1))==I.Word&&e(t.sliceDoc(r-1,r))==I.Word}var Ar=C.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(wr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return T.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return T.none;let e=n.wordAt(i.head);if(!e)return T.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return T.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Or(o,n,i.from,i.to)&&kr(o,n,i.from,i.to)))return T.none}else if(a=n.sliceDoc(i.from,i.to),!a)return T.none}let s=[];for(let r of e.visibleRanges){let e=new pr(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Or(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Dr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Er.range(r,a)),s.length>t.maxMatches))return T.none}}return T.set(s)}},{decorations:e=>e.decorations}),jr=b.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Mr=({state:e,dispatch:t})=>{let{selection:n}=e,r=L.create(n.ranges.map(t=>e.wordAt(t.head)||L.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Nr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new pr(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new pr(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Pr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Mr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Nr(e,r);return i?(t(e.update({selection:e.selection.addRange(L.range(i.from,i.to),!1),effects:b.scrollIntoView(i.to)})),!0):!1},Fr=ve.define({combine(e){return Ne(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new mi(e),scrollToMatch:e=>b.scrollIntoView(e)})}}),Ir=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||br(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{Ft as t,Ki as n,Pi as r,Xi as i,gc as a}from"./Notice-BhWgws6f-D26rmfPt.js";import{a as o}from"./CodeBlock.es-CrOFghky.js";import{t as s}from"./copy-button-5PzdvEQI-NsU3f0kN.js";import{t as c}from"./IconCodeBrackets.es-o1byTuto.js";import{t as l}from"./preload-helper-BLdHbfdN.js";import{X as u}from"./request-CHSXf6Q8.js";import{O as d,T as f,k as p}from"./IconChevronRightMedium.es-BjSIsine.js";import{n as m}from"./dist-DtnqB3m_.js";import{n as ee,r as te}from"./dist-CMX7_OjZ.js";import{$ as ne,B as re,C as h,Ct as ie,D as g,Dt as _,E as v,Et as y,F as b,H as x,I as ae,J as oe,K as S,L as C,M as w,N as T,P as se,R as E,S as D,St as O,T as ce,Tt as k,U as le,V as ue,W as A,X as j,Y as de,Z as fe,_ as pe,a as M,at as N,bt as me,c as he,ct as ge,dt as P,et as F,f as _e,ft as ve,gt as ye,j as be,k as xe,l as Se,lt as I,mt as Ce,n as we,nt as Te,o as Ee,ot as De,q as Oe,rt as ke,st as Ae,t as je,tt as Me,ut as L,vt as R,wt as Ne,xt as Pe,y as Fe,yt as Ie,z as Le}from"./dist-Sr6WSEaV.js";import{a as z,c as Re}from"./dist-6WNNvkM4.js";import{c as ze,d as Be,l as Ve,u as He}from"./dist-B5wMYzWI.js";var Ue,We=()=>Ue??=Promise.all([l(()=>import(`./standalone-YobQElH8.js`),[]),l(()=>import(`./babel-BaOs8qJH.js`),[]),l(()=>import(`./estree-Cw-tQG5d.js`),[])]).catch(e=>{throw Ue=void 0,e}),Ge=async e=>{let[t,n,r]=await We();return await t.format(e,{semi:!1,parser:`json`,printWidth:80,tabWidth:2,plugins:[n,r]})},B=e(p()),V=d();function Ke(){return Ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ke.apply(null,arguments)}function qe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Je=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=$e(e.state,n.from);return r.line?Xe(e):r.block?Qe(e):!1};function Ye(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Xe=Ye(it,0),Ze=Ye(rt,0),Qe=Ye((e,t)=>rt(e,t,nt(t)),0);function $e(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var et=50;function tt(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-et,r),o=e.sliceDoc(i,i+et),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+et),d=e.sliceDoc(i-et,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function nt(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function rt(e,t,n=t.selection.ranges){let r=n.map(e=>$e(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>tt(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function it(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=$e(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var at=De.define(),ot=De.define(),st=ve.define(),ct=ve.define({combine(e){return Ne(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),lt=Ie.define({create(){return Et.empty},update(e,t){let n=t.state.facet(ct),r=t.annotation(at);if(r){let i=H.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?gt(o,o.length,n.minDepth,i):xt(o,t.startState.selection),new Et(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(ot);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Pe.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=H.fromTransaction(t),o=t.annotation(Pe.time),s=t.annotation(Pe.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Et(e.done.map(H.fromJSON),e.undone.map(H.fromJSON))}});function ut(e={}){return[lt,ct.of(e),b.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?ft:e.inputType==`historyRedo`?pt:null;return n?(e.preventDefault(),n(t)):!1}})]}function dt(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(lt,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var ft=dt(0,!1),pt=dt(1,!1),mt=dt(0,!0),ht=dt(1,!0),H=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&ge.fromJSON(t.changes),[],t.mapped&&Ae.fromJSON(t.mapped),t.startSelection&&L.fromJSON(t.startSelection),t.selectionsAfter.map(L.fromJSON))}static fromTransaction(t,n){let r=U;for(let e of t.startState.facet(st)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,U)}static selection(t){return new e(void 0,U,void 0,void 0,t)}};function gt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function _t(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function vt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function yt(e,t){return e.length?t.length?e.concat(t):e:t}var U=[],bt=200;function xt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-bt));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),gt(e,e.length-1,1e9,n.setSelAfter(r)))}return[H.selection([t])]}function St(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Ct(e,t){if(!e.length)return e;let n=e.length,r=U;for(;n;){let i=wt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[H.selection(r)]:U}function wt(e,t,n){let r=yt(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):U,n);if(!e.changes)return H.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new H(i,R.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Tt=/^(input\.type|delete)($|\.)/,Et=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Tt.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,_t(s.changes,t.changes))||r==`input.type.compose`)?gt(o,o.length-1,i.minDepth,new H(t.changes.compose(s.changes),yt(R.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,U)):gt(o,o.length,i.minDepth,t),new e(o,U,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:U;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&vt(a[a.length-1],t)?this:new e(xt(this.done,t),this.undone,n,r)}addMapping(t){return new e(Ct(this.done,t),Ct(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:at.of({side:e,rest:St(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?U:r.slice(0,r.length-1);return i.mapped&&(n=Ct(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:at.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Et.empty=new Et(U,U);var Dt=[{key:`Mod-z`,run:ft,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:pt,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:pt,preventDefault:!0},{key:`Mod-u`,run:mt,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:ht,preventDefault:!0}];function W(e,t){return L.create(e.ranges.map(t),e.mainIndex)}function G(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function K({state:e,dispatch:t},n){let r=W(e.selection,n);return!r.eq(e.selection,!0)&&(t(G(e,r)),!0)}function Ot(e,t){return L.cursor(t?e.to:e.from)}function kt(e,t){return K(e,n=>n.empty?e.moveByChar(n,t):Ot(n,t))}function q(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var At=e=>kt(e,!q(e)),jt=e=>kt(e,q(e));function Mt(e,t){return K(e,n=>n.empty?e.moveByGroup(n,t):Ot(n,t))}var Nt=e=>Mt(e,!q(e)),Pt=e=>Mt(e,q(e));typeof Intl<`u`&&Intl.Segmenter;function Ft(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function It(e,t,n){let r=w(e).resolveInner(t.head),i=n?Re.closedBy:Re.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Ft(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?xe(e,r.from,1):xe(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,L.cursor(s,n?-1:1)}var Lt=e=>K(e,t=>It(e.state,t,!q(e))),Rt=e=>K(e,t=>It(e.state,t,q(e)));function zt(e,t){return K(e,n=>{if(!n.empty)return Ot(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Bt=e=>zt(e,!1),Vt=e=>zt(e,!0);function Ht(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(b.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Ut(e,t){let n=Ht(e),{state:r}=e,i=W(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Ot(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=b.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(G(r,i),{effects:a}),!0}var Wt=e=>Ut(e,!1),Gt=e=>Ut(e,!0);function J(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=L.cursor(r.from+n))}return i}var Kt=e=>K(e,t=>J(e,t,!0)),qt=e=>K(e,t=>J(e,t,!1)),Jt=e=>K(e,t=>J(e,t,!q(e))),Yt=e=>K(e,t=>J(e,t,q(e))),Xt=e=>K(e,t=>e.moveToLineBoundary(t,!1,!1)),Zt=e=>K(e,t=>e.moveToLineBoundary(t,!0,!1));function Qt(e,t,n){let r=!1,i=W(e.selection,t=>{let i=xe(e,t.head,-1)||xe(e,t.head,1)||t.head>0&&xe(e,t.head-1,1)||t.head<e.doc.length&&xe(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?L.range(t.anchor,a):L.cursor(a)});return r?(t(G(e,i)),!0):!1}var $t=({state:e,dispatch:t})=>Qt(e,t,!1);function Y(e,t,n){let r=W(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=L.range(e.head,e.anchor));let r=n(e);return L.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(G(e.state,r)),!0)}function en(e,t){return Y(e,t,n=>e.moveByChar(n,t))}var tn=e=>en(e,!q(e)),nn=e=>en(e,q(e));function rn(e,t){return Y(e,t,n=>e.moveByGroup(n,t))}var an=e=>rn(e,!q(e)),on=e=>rn(e,q(e)),sn=e=>{let t=!q(e);return Y(e,t,n=>It(e.state,n,t))},cn=e=>{let t=q(e);return Y(e,t,n=>It(e.state,n,t))};function ln(e,t){return Y(e,t,n=>e.moveVertically(n,t))}var un=e=>ln(e,!1),dn=e=>ln(e,!0);function fn(e,t){return Y(e,t,n=>e.moveVertically(n,t,Ht(e).height))}var pn=e=>fn(e,!1),mn=e=>fn(e,!0),hn=e=>Y(e,!0,t=>J(e,t,!0)),gn=e=>Y(e,!1,t=>J(e,t,!1)),_n=e=>{let t=!q(e);return Y(e,t,n=>J(e,n,t))},vn=e=>{let t=q(e);return Y(e,t,n=>J(e,n,t))},yn=e=>Y(e,!1,t=>L.cursor(e.lineBlockAt(t.head).from)),bn=e=>Y(e,!0,t=>L.cursor(e.lineBlockAt(t.head).to)),xn=({state:e,dispatch:t})=>(t(G(e,{anchor:0})),!0),Sn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.doc.length})),!0),Cn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.selection.main.anchor,head:0})),!0),wn=({state:e,dispatch:t})=>(t(G(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Tn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),En=({state:e,dispatch:t})=>{let n=Gn(e).map(({from:t,to:n})=>L.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:L.create(n),userEvent:`select`})),!0},Dn=({state:e,dispatch:t})=>{let n=W(e.selection,t=>{let n=w(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return L.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(G(e,n)),!0)};function On(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(G(n,L.create(i,i.length-1))),!0)}var kn=e=>On(e,!1),An=e=>On(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=L.create([n.main]):n.main.empty||(r=L.create([L.cursor(n.main.head)])),r?(t(G(e,r)),!0):!1};function Mn(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Nn(e,o,!1)):o>i&&(n=`delete.forward`,o=Nn(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Nn(e,i,!1),a=Nn(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:L.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?b.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Nn(e,t,n){if(e instanceof b)for(let r of e.state.facet(b.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Pn=(e,t,n)=>Mn(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=k(s,a.tabSize)%D(a)||D(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=y(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=y(o.text,c-o.from,!1,!1)+o.from);return c}),Fn=e=>Pn(e,!1,!0),In=e=>Pn(e,!0,!1),Ln=(e,t)=>Mn(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=y(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Rn=e=>Ln(e,!1),zn=e=>Ln(e,!0),Bn=e=>Mn(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Vn=e=>Mn(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Hn=e=>Mn(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Un=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:me.of([``,``])},range:L.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Wn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:y(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:y(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:L.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Gn(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Kn(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Gn(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(L.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(L.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:L.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var qn=({state:e,dispatch:t})=>Kn(e,t,!1),Jn=({state:e,dispatch:t})=>Kn(e,t,!0);function Yn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Gn(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Xn=({state:e,dispatch:t})=>Yn(e,t,!1),Zn=({state:e,dispatch:t})=>Yn(e,t,!0),Qn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Gn(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=W(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function $n(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=w(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Re.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var er=nr(!1),tr=nr(!0);function nr(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&$n(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new we(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=h(s,r);for(c??=k(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,v(t,c)];return o&&l.push(v(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:me.of(l)},range:L.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function rr(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:L.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var ir=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new we(e,{overrideIndentation:e=>n[e]??-1}),i=rr(e,(t,i,a)=>{let o=h(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=v(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},ar=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(rr(e,(t,n)=>{n.push({from:t.from,insert:e.facet(g)})}),{userEvent:`input.indent`})),!0),or=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(rr(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=k(r,e.tabSize),a=0,o=v(e,Math.max(0,i-D(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),sr=e=>(e.setTabFocusMode(),!0),cr=[{key:`Ctrl-b`,run:At,shift:tn,preventDefault:!0},{key:`Ctrl-f`,run:jt,shift:nn},{key:`Ctrl-p`,run:Bt,shift:un},{key:`Ctrl-n`,run:Vt,shift:dn},{key:`Ctrl-a`,run:Xt,shift:yn},{key:`Ctrl-e`,run:Zt,shift:bn},{key:`Ctrl-d`,run:In},{key:`Ctrl-h`,run:Fn},{key:`Ctrl-k`,run:Bn},{key:`Ctrl-Alt-h`,run:Rn},{key:`Ctrl-o`,run:Un},{key:`Ctrl-t`,run:Wn},{key:`Ctrl-v`,run:Gt}],lr=[{key:`ArrowLeft`,run:At,shift:tn,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Nt,shift:an,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:Jt,shift:_n,preventDefault:!0},{key:`ArrowRight`,run:jt,shift:nn,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Pt,shift:on,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Yt,shift:vn,preventDefault:!0},{key:`ArrowUp`,run:Bt,shift:un,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:xn,shift:Cn},{mac:`Ctrl-ArrowUp`,run:Wt,shift:pn},{key:`ArrowDown`,run:Vt,shift:dn,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Sn,shift:wn},{mac:`Ctrl-ArrowDown`,run:Gt,shift:mn},{key:`PageUp`,run:Wt,shift:pn},{key:`PageDown`,run:Gt,shift:mn},{key:`Home`,run:qt,shift:gn,preventDefault:!0},{key:`Mod-Home`,run:xn,shift:Cn},{key:`End`,run:Kt,shift:hn,preventDefault:!0},{key:`Mod-End`,run:Sn,shift:wn},{key:`Enter`,run:er,shift:er},{key:`Mod-a`,run:Tn},{key:`Backspace`,run:Fn,shift:Fn,preventDefault:!0},{key:`Delete`,run:In,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Rn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:zn,preventDefault:!0},{mac:`Mod-Backspace`,run:Vn,preventDefault:!0},{mac:`Mod-Delete`,run:Hn,preventDefault:!0}].concat(cr.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),ur=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:Lt,shift:sn},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Rt,shift:cn},{key:`Alt-ArrowUp`,run:qn},{key:`Shift-Alt-ArrowUp`,run:Xn},{key:`Alt-ArrowDown`,run:Jn},{key:`Shift-Alt-ArrowDown`,run:Zn},{key:`Mod-Alt-ArrowUp`,run:kn},{key:`Mod-Alt-ArrowDown`,run:An},{key:`Escape`,run:jn},{key:`Mod-Enter`,run:tr},{key:`Alt-l`,mac:`Ctrl-l`,run:En},{key:`Mod-i`,run:Dn,preventDefault:!0},{key:`Mod-[`,run:or},{key:`Mod-]`,run:ar},{key:`Mod-Alt-\\`,run:ir},{key:`Shift-Mod-k`,run:Qn},{key:`Shift-Mod-\\`,run:$t},{key:`Mod-/`,run:Je},{key:`Alt-A`,mac:`Ctrl-A`,run:Ze},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:sr}].concat(lr),dr={key:`Tab`,run:ar,shift:or},fr=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,pr=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(fr(e)):fr,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return O(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=_(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ie(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(pr.prototype[Symbol.iterator]=function(){return this});var mr={from:-1,to:-1,match:/.*/.exec(``),precise:!0},hr=`gm`+(/x/.unicode==null?``:`u`),gr=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=mr,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new yr(e,t,n,r,i);this.re=new RegExp(t,hr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=xr(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=xr(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},_r=new WeakMap,vr=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=_r.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return _r.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),_r.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},yr=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=mr,this.matchPos=xr(e,r),this.re=new RegExp(t,hr+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=vr.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=xr(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=vr.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(gr.prototype[Symbol.iterator]=yr.prototype[Symbol.iterator]=function(){return this});function br(e){try{return new RegExp(e,hr),!0}catch{return!1}}function xr(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Sr=e=>{let t=le(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=Te(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=L.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,b.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Cr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},wr=ve.define({combine(e){return Ne(e,Cr,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Tr(e){let t=[jr,Ar];return e&&t.push(wr.of(e)),t}var Er=T.mark({class:`cm-selectionMatch`}),Dr=T.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Or(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=I.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=I.Word)}function kr(e,t,n,r){return e(t.sliceDoc(n,n+1))==I.Word&&e(t.sliceDoc(r-1,r))==I.Word}var Ar=C.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(wr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return T.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return T.none;let e=n.wordAt(i.head);if(!e)return T.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return T.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Or(o,n,i.from,i.to)&&kr(o,n,i.from,i.to)))return T.none}else if(a=n.sliceDoc(i.from,i.to),!a)return T.none}let s=[];for(let r of e.visibleRanges){let e=new pr(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Or(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Dr.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Er.range(r,a)),s.length>t.maxMatches))return T.none}}return T.set(s)}},{decorations:e=>e.decorations}),jr=b.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Mr=({state:e,dispatch:t})=>{let{selection:n}=e,r=L.create(n.ranges.map(t=>e.wordAt(t.head)||L.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Nr(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new pr(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new pr(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Pr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Mr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Nr(e,r);return i?(t(e.update({selection:e.selection.addRange(L.range(i.from,i.to),!1),effects:b.scrollIntoView(i.to)})),!0):!1},Fr=ve.define({combine(e){return Ne(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new mi(e),scrollToMatch:e=>b.scrollIntoView(e)})}}),Ir=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||br(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
3
3
  `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new qr(this):new Vr(this)}getCursor(e,t=0,n){let r=e.doc?e:P.create({doc:e});return n??=r.doc.length,this.regexp?Ur(this,r,t,n):zr(this,r,t,n)}},Lr=class{constructor(e){this.spec=e}};function Rr(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function zr(e,t,n,r){let i;return e.wholeWord&&(i=Br(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Rr(e.test,t,i)),new pr(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Br(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(Wr(i,n-a))!=I.Word||t(Gr(i,n-a))!=I.Word)&&(t(Gr(i,r-a))!=I.Word||t(Wr(i,r-a))!=I.Word))}var Vr=class extends Lr{constructor(e){super(e)}nextMatch(e,t,n){let r=zr(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=zr(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=zr(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=zr(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=zr(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Hr(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function Ur(e,t,n,r){let i;return e.wholeWord&&(i=Kr(t.charCategorizer(t.selection.main.head))),e.test&&(i=Hr(e.test,t,i)),new gr(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function Wr(e,t){return e.slice(y(e,t,!1),t)}function Gr(e,t){return e.slice(t,y(e,t))}function Kr(e){return(t,n,r)=>!r[0].length||(e(Wr(r.input,r.index))!=I.Word||e(Gr(r.input,r.index))!=I.Word)&&(e(Gr(r.input,r.index+r[0].length))!=I.Word||e(Wr(r.input,r.index+r[0].length))!=I.Word)}var qr=class extends Lr{nextMatch(e,t,n){let r=Ur(this.spec,e,n,e.doc.length).next();return r.done&&(r=Ur(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=Ur(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=Ur(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Ur(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},Jr=R.define(),Yr=R.define(),X=Ie.define({create(e){return new Xr(ci(e).create(),null)},update(e,t){for(let n of t.effects)n.is(Jr)?e=new Xr(n.value.create(),e.panel):n.is(Yr)&&(e=new Xr(e.query,n.value?si:null));return e},provide:e=>ke.from(e,e=>e.panel)}),Xr=class{constructor(e,t){this.query=e,this.panel=t}},Zr=T.mark({class:`cm-searchMatch`}),Qr=T.mark({class:`cm-searchMatch cm-searchMatch-selected`}),$r=C.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(X))}update(e){let t=e.state.field(X);(t!=e.startState.field(X)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return T.none;let{view:n}=this,r=new ye;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Qr:Zr)})}return r.finish()}},{decorations:e=>e.decorations});function ei(e){return t=>{let n=t.state.field(X,!1);return n&&n.query.spec.valid?e(t,n):di(t)}}var ti=ei((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=L.single(r.from,r.to),a=e.state.facet(Fr);return e.dispatch({selection:i,effects:[_i(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),ui(e),!0}),ni=ei((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=L.single(i.from,i.to),o=e.state.facet(Fr);return e.dispatch({selection:a,effects:[_i(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),ui(e),!0}),ri=ei((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:L.create(n.map(e=>L.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),ii=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new pr(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(L.range(t.value.from,t.value.to))}return t(e.update({selection:L.create(a,o),userEvent:`select.search.matches`})),!0},ai=ei((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(b.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=L.single(o.from,o.to).map(d),u.push(_i(e,o)),u.push(n.facet(Fr).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),oi=ei((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:b.announce.of(r),userEvent:`input.replace.all`}),!0});function si(e){return e.state.facet(Fr).createPanel(e)}function ci(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Fr);return new Ir({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function li(e){let t=A(e,si);return t&&t.dom.querySelector(`[main-field]`)}function ui(e){let t=li(e);t&&t==e.root.activeElement&&t.select()}var di=e=>{let t=e.state.field(X,!1);if(t&&t.panel){let n=li(e);if(n&&n!=e.root.activeElement){let r=ci(e.state,t.query.spec);r.valid&&e.dispatch({effects:Jr.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Yr.of(!0),t?Jr.of(ci(e.state,t.query.spec)):R.appendConfig.of(yi)]});return!0},fi=e=>{let t=e.state.field(X,!1);if(!t||!t.panel)return!1;let n=A(e,si);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Yr.of(!1)}),!0},pi=[{key:`Mod-f`,run:di,scope:`editor search-panel`},{key:`F3`,run:ti,shift:ni,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:ti,shift:ni,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:fi,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:ii},{key:`Mod-Alt-g`,run:Sr},{key:`Mod-d`,run:Pr,preventDefault:!0}],mi=class{constructor(e){this.view=e;let t=this.query=e.state.field(X).query.spec;this.commit=this.commit.bind(this),this.searchField=N(`input`,{value:t.search,placeholder:Z(e,`Find`),"aria-label":Z(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=N(`input`,{value:t.replace,placeholder:Z(e,`Replace`),"aria-label":Z(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=N(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=N(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=N(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return N(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=N(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>ti(e),[Z(e,`next`)]),n(`prev`,()=>ni(e),[Z(e,`previous`)]),n(`select`,()=>ri(e),[Z(e,`all`)]),N(`label`,null,[this.caseField,Z(e,`match case`)]),N(`label`,null,[this.reField,Z(e,`regexp`)]),N(`label`,null,[this.wordField,Z(e,`by word`)]),...e.state.readOnly?[]:[N(`br`),this.replaceField,n(`replace`,()=>ai(e),[Z(e,`replace`)]),n(`replaceAll`,()=>oi(e),[Z(e,`replace all`)])],N(`button`,{name:`close`,onclick:()=>fi(e),"aria-label":Z(e,`close`),type:`button`},[`×`])])}commit(){let e=new Ir({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Jr.of(e)}))}keydown(e){Me(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ni:ti)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ai(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(Jr)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Fr).top}};function Z(e,t){return e.state.phrase(t)}var hi=30,gi=/[\s\.,:;?!]/;function _i(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-hi),o=Math.min(i,n+hi),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<hi;e++)if(!gi.test(s[e+1])&&gi.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-hi;e--)if(!gi.test(s[e-1])&&gi.test(s[e])){s=s.slice(0,e);break}}return b.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var vi=b.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),yi=[X,Ce.low($r),vi],bi=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},xi=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Ni).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new ye,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Wi(s);if(i)o.add(n,n,T.widget({widget:new Li(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,T.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Q(f))}};function Q(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new bi(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new bi(r.from,n,r.diagnostic)}}),r}function Si(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Ni).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(wi))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Ci(e,t){return e.field($,!1)?t:t.concat(R.appendConfig.of(Ki))}var wi=R.define(),Ti=R.define(),Ei=R.define(),$=Ie.define({create(){return new xi(T.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Q(n,e.selected.diagnostic,i)||Q(n,null,i)}!n.size&&i&&t.state.facet(Ni).autoPanel&&(i=null),e=new xi(n,i,r)}for(let n of t.effects)if(n.is(wi)){let r=t.state.facet(Ni).autoPanel?n.value.length?zi.open:null:e.panel;e=xi.init(n.value,r,t.state)}else n.is(Ti)?e=new xi(e.diagnostics,n.value?zi.open:null,e.selected):n.is(Ei)&&(e=new xi(e.diagnostics,e.panel,n.value));return e},provide:e=>[ke.from(e,e=>e.panel),b.decorations.from(e,e=>e.diagnostics)]}),Di=T.mark({class:`cm-lintRange cm-lintRange-active`});function Oi(e,t,n){let{diagnostics:r}=e.state.field($),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Ni).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:!0,create(){return{dom:ki(e,i)}}}:null}function ki(e,t){return N(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Ii(e,t,!1)))}var Ai=e=>{let t=e.state.field($,!1);t&&t.panel||e.dispatch({effects:Ci(e.state,[Ti.of(!0)])});let n=A(e,zi.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},ji=e=>{let t=e.state.field($,!1);return!t||!t.panel?!1:(e.dispatch({effects:Ti.of(!1)}),!0)},Mi=[{key:`Mod-Shift-m`,run:Ai,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field($,!1);if(!t)return!1;let n=e.state.selection.main,r=Q(t.diagnostics,null,n.to+1);return!r&&(r=Q(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),Le(e,r.from,1,{tooltip:Gi,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],Ni=ve.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Ne(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Pi,tooltipFilter:Pi,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function Pi(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Fi(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Ii(e,t,n){let r=n?Fi(t.actions):[];return N(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},N(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Q(e.state.field($).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),N(`u`,s.slice(c,c+1)),s.slice(c+1)],u=n.markClass?` `+n.markClass:``;return N(`button`,{type:`button`,class:`cm-diagnosticAction`+u,onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&N(`div`,{class:`cm-diagnosticSource`},t.source))}var Li=class extends E{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return N(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Ri=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Ii(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},zi=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)ji(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=Fi(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Q(this.view.state.field($).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=N(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=N(`div`,{class:`cm-panel-lint`},this.list,N(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>ji(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field($).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field($),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Ri(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Ri(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Q(this.view.state.field($).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:Ei.of(t)})}static open(t){return new e(t)}};function Bi(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function Vi(e){return Bi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Hi=b.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:Vi(`#f11`)},".cm-lintRange-warning":{backgroundImage:Vi(`orange`)},".cm-lintRange-info":{backgroundImage:Vi(`#999`)},".cm-lintRange-hint":{backgroundImage:Vi(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function Ui(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Wi(e){let t=`hint`,n=1;for(let r of e){let e=Ui(r.severity);e>n&&(n=e,t=r.severity)}return t}var Gi=de(Oi,{hideOn:Si}),Ki=[$,b.decorations.compute([$],e=>{let{selected:t,panel:n}=e.field($);return!t||!n||t.from==t.to?T.none:T.set([Di.range(t.from,t.to)])}),Gi,Hi],qi=function(e){e===void 0&&(e={});var t=e.crosshairCursor,n=t!==void 0&&t,r=[];e.closeBracketsKeymap!==!1&&(r=r.concat(He)),e.defaultKeymap!==!1&&(r=r.concat(ur)),e.searchKeymap!==!1&&(r=r.concat(pi)),e.historyKeymap!==!1&&(r=r.concat(Dt)),e.foldKeymap!==!1&&(r=r.concat(Fe)),e.completionKeymap!==!1&&(r=r.concat(Be)),e.lintKeymap!==!1&&(r=r.concat(Mi));var i=[];return e.lineNumbers!==!1&&i.push(fe()),e.highlightActiveLineGutter!==!1&&i.push(Oe()),e.highlightSpecialChars!==!1&&i.push(oe()),e.history!==!1&&i.push(ut()),e.foldGutter!==!1&&i.push(pe()),e.drawSelection!==!1&&i.push(ue()),e.dropCursor!==!1&&i.push(x()),e.allowMultipleSelections!==!1&&i.push(P.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(ce()),e.syntaxHighlighting!==!1&&i.push(be(_e,{fallback:!0})),e.bracketMatching!==!1&&i.push(Se()),e.closeBrackets!==!1&&i.push(Ve()),e.autocompletion!==!1&&i.push(ze()),e.rectangularSelection!==!1&&i.push(F()),n!==!1&&i.push(re()),e.highlightActiveLine!==!1&&i.push(S()),e.highlightSelectionMatches!==!1&&i.push(Tr()),e.tabSize&&typeof e.tabSize==`number`&&i.push(g.of(` `.repeat(e.tabSize))),i.concat([j.of(r.flat())]).filter(Boolean)},Ji=`#e5c07b`,Yi=`#e06c75`,Xi=`#56b6c2`,Zi=`#ffffff`,Qi=`#abb2bf`,$i=`#7d8799`,ea=`#61afef`,ta=`#98c379`,na=`#d19a66`,ra=`#c678dd`,ia=`#21252b`,aa=`#2c313a`,oa=`#282c34`,sa=`#353a42`,ca=`#3E4451`,la=`#528bff`,ua=b.theme({"&":{color:Qi,backgroundColor:oa},".cm-content":{caretColor:la},".cm-cursor, .cm-dropCursor":{borderLeftColor:la},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ca},".cm-panels":{backgroundColor:ia,color:Qi},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:oa,color:$i,border:`none`},".cm-activeLineGutter":{backgroundColor:aa},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:sa},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:sa,borderBottomColor:sa},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:aa,color:Qi}}},{dark:!0}),da=je.define([{tag:z.keyword,color:ra},{tag:[z.name,z.deleted,z.character,z.propertyName,z.macroName],color:Yi},{tag:[z.function(z.variableName),z.labelName],color:ea},{tag:[z.color,z.constant(z.name),z.standard(z.name)],color:na},{tag:[z.definition(z.name),z.separator],color:Qi},{tag:[z.typeName,z.className,z.number,z.changed,z.annotation,z.modifier,z.self,z.namespace],color:Ji},{tag:[z.operator,z.operatorKeyword,z.url,z.escape,z.regexp,z.link,z.special(z.string)],color:Xi},{tag:[z.meta,z.comment],color:$i},{tag:z.strong,fontWeight:`bold`},{tag:z.emphasis,fontStyle:`italic`},{tag:z.strikethrough,textDecoration:`line-through`},{tag:z.link,color:$i,textDecoration:`underline`},{tag:z.heading,fontWeight:`bold`,color:Yi},{tag:[z.atom,z.bool,z.special(z.variableName)],color:na},{tag:[z.processingInstruction,z.string,z.inserted],color:ta},{tag:z.invalid,color:Zi}]),fa=[ua,be(da)],pa=b.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),ma=function(e){e===void 0&&(e={});var t=e,n=t.indentWithTab,r=n===void 0||n,i=t.editable,a=i===void 0||i,o=t.readOnly,s=o!==void 0&&o,c=t.theme,l=c===void 0?`light`:c,u=t.placeholder,d=u===void 0?``:u,f=t.basicSetup,p=f===void 0||f,m=[];switch(r&&m.unshift(j.of([dr])),p&&(typeof p==`boolean`?m.unshift(qi()):m.unshift(qi(p))),d&&m.unshift(ne(d)),l){case`light`:m.push(pa);break;case`dark`:m.push(fa);break;case`none`:break;default:m.push(l)}return a===!1&&m.push(b.editable.of(!1)),s&&m.push(P.readOnly.of(!0)),[...m]},ha=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),ga=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},_a=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},va=null,ya=()=>typeof window>`u`?new _a:(va||=new _a,va),ba=b.theme({"& .cm-scroller":{height:`100% !important`}}),xa=null,Sa=null;function Ca(e,t,n,r,i,a){if(!e&&!t&&!n&&!r&&!i&&!a)return null;var o=JSON.stringify({height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a});return o===xa||(xa=o,Sa=b.theme({"&":{height:e,minHeight:t,maxHeight:n,width:r,minWidth:i,maxWidth:a}})),Sa}var wa=De.define(),Ta=200,Ea=[];function Da(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onStatistics,a=e.onCreateEditor,o=e.onUpdate,s=e.extensions,c=s===void 0?Ea:s,l=e.autoFocus,u=e.theme,d=u===void 0?`light`:u,f=e.height,p=f===void 0?null:f,m=e.minHeight,ee=m===void 0?null:m,te=e.maxHeight,ne=te===void 0?null:te,re=e.width,h=re===void 0?null:re,ie=e.minWidth,g=ie===void 0?null:ie,_=e.maxWidth,v=_===void 0?null:_,y=e.placeholder,x=y===void 0?``:y,ae=e.editable,oe=ae===void 0||ae,S=e.readOnly,C=S!==void 0&&S,w=e.indentWithTab,T=w===void 0||w,se=e.basicSetup,E=se===void 0||se,D=e.root,O=e.initialState,ce=(0,B.useState)(),k=ce[0],le=ce[1],ue=(0,B.useState)(),A=ue[0],j=ue[1],de=(0,B.useState)(),fe=de[0],pe=de[1],M=(0,B.useState)(()=>({current:null}))[0],N=(0,B.useState)(()=>({current:null}))[0],me=Ca(p,ee,ne,h,g,v),he=b.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(wa))&&(M.current?M.current.reset():(M.current=new ga(()=>{if(N.current){var e=N.current;N.current=null,e()}M.current=null},Ta),ya().add(M.current)),r(e.state.doc.toString(),e)),i&&i(ha(e))}),ge=ma({theme:d,editable:oe,readOnly:C,placeholder:x,indentWithTab:T,basicSetup:E}),F=[he,...me?[me]:[],ba,...ge];return o&&typeof o==`function`&&F.push(b.updateListener.of(o)),F=F.concat(c),(0,B.useLayoutEffect)(()=>{if(k&&!fe){var e={doc:t,selection:n,extensions:F},r=O?P.fromJSON(O.json,e,O.fields):P.create(e);if(pe(r),!A){var i=new b({state:r,parent:k,root:D});j(i),a&&a(i,r)}}return()=>{A&&(pe(void 0),j(void 0))}},[k,fe]),(0,B.useEffect)(()=>{e.container&&le(e.container)},[e.container]),(0,B.useEffect)(()=>()=>{A&&(A.destroy(),j(void 0)),M.current&&=(M.current.cancel(),null)},[A]),(0,B.useEffect)(()=>{l&&A&&A.focus()},[l,A]),(0,B.useEffect)(()=>{A&&A.dispatch({effects:R.reconfigure.of(F)})},[d,c,p,ee,ne,h,g,v,x,oe,C,T,E,r,o]),(0,B.useEffect)(()=>{if(t!==void 0){var e=A?A.state.doc.toString():``;if(A&&t!==e){var n=M.current&&!M.current.isDone,r=()=>{A&&t!==A.state.doc.toString()&&A.dispatch({changes:{from:0,to:A.state.doc.toString().length,insert:t||``},annotations:[wa.of(!0)]})};n?N.current=r:r()}}},[t,A]),{state:fe,setState:pe,view:A,setView:j,container:k,setContainer:le}}var Oa=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],ka=(0,B.forwardRef)((e,t)=>{var n=e.className,r=e.value,i=r===void 0?``:r,a=e.selection,o=e.extensions,s=o===void 0?[]:o,c=e.onChange,l=e.onStatistics,u=e.onCreateEditor,d=e.onUpdate,f=e.autoFocus,p=e.theme,m=p===void 0?`light`:p,ee=e.height,te=e.minHeight,ne=e.maxHeight,re=e.width,h=e.minWidth,ie=e.maxWidth,g=e.basicSetup,_=e.placeholder,v=e.indentWithTab,y=e.editable,b=e.readOnly,x=e.root,ae=e.initialState,oe=qe(e,Oa),S=(0,B.useRef)(null),C=Da({root:x,value:i,autoFocus:f,theme:m,height:ee,minHeight:te,maxHeight:ne,width:re,minWidth:h,maxWidth:ie,basicSetup:g,placeholder:_,indentWithTab:v,editable:y,readOnly:b,selection:a,onChange:c,onStatistics:l,onCreateEditor:u,onUpdate:d,extensions:s,initialState:ae}),w=C.state,T=C.view,se=C.container,E=C.setContainer;(0,B.useImperativeHandle)(t,()=>({editor:S.current,state:w,view:T}),[S,se,w,T]);var D=(0,B.useCallback)(e=>{S.current=e,E(e)},[E]);if(typeof i!=`string`)throw Error(`value must be typeof string but got `+typeof i);var O=typeof m==`string`?`cm-theme-`+m:`cm-theme`;return(0,V.jsx)(`div`,Ke({ref:D,className:``+O+(n?` `+n:``)},oe))});ka.displayName=`CodeMirror`;function Aa(e){return new Ee(he.define(e))}var ja=[M.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return l(()=>import(`./dist-B5wMYzWI.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([0,1,2,3,4]))}}),M.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return l(()=>import(`./dist-DtnqB3m_.js`).then(e=>e.t).then(e=>e.json()),__vite__mapDeps([5,1,2,3,4]))}}),M.of({name:`JSX`,extensions:[`jsx`],load(){return l(()=>import(`./dist-B5wMYzWI.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([0,1,2,3,4]))}}),M.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return l(()=>import(`./dist-CMX7_OjZ.js`).then(e=>e.t).then(e=>e.markdown()),__vite__mapDeps([6,1,4,3,0,2]))}}),M.of({name:`TSX`,extensions:[`tsx`],load(){return l(()=>import(`./dist-B5wMYzWI.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0,typescript:!0})),__vite__mapDeps([0,1,2,3,4]))}}),M.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return l(()=>import(`./dist-B5wMYzWI.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([0,1,2,3,4]))}}),M.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return l(()=>import(`./shell-DwuoZtxw.js`).then(e=>Aa(e.shell)),[])}})],Ma=b.theme({".cm-foldGutter .cm-gutterElement":{display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`0 4px`},".cm-fold-marker":{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`12px`,height:`12px`,boxSizing:`border-box`,border:`1px solid var(--border)`,borderRadius:`2px`,color:`var(--muted-foreground)`,fontSize:`var(--text-caption)`,lineHeight:`1`,cursor:`pointer`,userSelect:`none`},".cm-fold-marker:hover":{background:`var(--fill-hover)`,color:`var(--foreground)`},".cm-foldPlaceholder":{background:`var(--fill-hover)`,border:`1px solid var(--border)`,color:`var(--muted-foreground)`,borderRadius:`2px`,padding:`0 4px`,margin:`0 2px`}}),Na=[pe({markerDOM:e=>{let t=document.createElement(`span`);return t.className=`cm-fold-marker`,t.dataset.state=e?`open`:`closed`,t.title=e?`Fold`:`Unfold`,t.textContent=e?`−`:`+`,t}}),Ma];function Pa(e,t=5){if(!e?.properties)return[];let n=[];function r(e,i,a){if(a>t)return;let o=Array.isArray(e.type)?e.type.join(` | `):e.type;if(n.push({path:i,label:i,description:e.description??e.title,type:o}),e.properties)for(let[t,n]of Object.entries(e.properties))r(n,`${i}.${t}`,a+1);if(e.items?.properties)for(let[t,n]of Object.entries(e.items.properties))r(n,`${i}[].${t}`,a+1)}for(let[t,n]of Object.entries(e.properties))r(n,t,1);return n}function Fa(e){let t=Pa(e);return ze({override:[Ia(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function Ia(e){return t=>{let n=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!n)return null;let r=n[1]??``,i=t.pos-r.length,a=r?e.filter(e=>e.path.toLowerCase().startsWith(r.toLowerCase())):e;return a.length===0?null:{from:i,options:a.map(e=>({label:e.path,displayLabel:e.path,detail:e.type,info:e.description,apply:(e,t,n,r)=>{let i=r+(e.state.sliceDoc(r).match(/^[a-zA-Z0-9_.\[\]]*/)?.[0].length??0),a=e.state.sliceDoc(i,i+2)===`}}`,o=a?i:r,s=a?t.label:`${t.label}}}`;e.dispatch({changes:{from:n,to:o,insert:s},selection:{anchor:n+s.length}})}})),validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}var La=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,Ra=T.mark({class:`cm-variable-highlight`}),za=new ae({regexp:La,decoration:()=>Ra}),Ba=C.fromClass(class{decorations;constructor(e){this.decorations=za.createDeco(e)}update(e){this.decorations=za.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations});function Va(e){return[b.theme({"&":{backgroundColor:`transparent`,color:`var(--foreground)`,fontSize:`var(--text-body-sm)`},"&.cm-editor .cm-scroller":{fontFamily:`var(--font-${e})`},".cm-gutters":{backgroundColor:`transparent`,color:`var(--placeholder)`,borderRight:`none`},".cm-content":{color:`var(--foreground)`,caretColor:`var(--foreground)`},".cm-activeLine":{backgroundColor:`transparent`},".cm-lineNumbers .cm-gutterElement":{color:`var(--placeholder)`},".cm-activeLineGutter":{backgroundColor:`transparent`,color:`var(--muted-foreground)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--foreground)`},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:`var(--info-edge) !important`},".cm-tooltip-autocomplete":{backgroundColor:`var(--background)`,border:`1px solid var(--border)`,borderRadius:`6px`,boxShadow:`var(--elevation-overlay)`},".cm-tooltip-autocomplete > ul":{fontFamily:`var(--font-mono)`},".cm-completionLabel":{color:`var(--foreground)`},".cm-completionDetail":{color:`var(--muted-foreground)`,fontSize:`var(--text-caption)`,marginLeft:`auto`,paddingLeft:`12px`},".cm-completionInfo":{backgroundColor:`var(--background)`,border:`1px solid var(--border)`,color:`var(--muted-foreground)`,padding:`8px 12px`},".cm-completionIcon":{display:`none`},"ul.cm-completionList li[aria-selected]":{backgroundColor:`var(--fill-hover)`,color:`var(--foreground)`},".cm-line .cm-variable-highlight":{color:`var(--warning-foreground) !important`,fontWeight:`500`}}),be(o)]}var Ha=(e=`mono`)=>(0,B.useMemo)(()=>Va(e),[e]),Ua=a(f(`relative overflow-hidden font-mono outline-hidden focus-within:outline-hidden focus:outline-hidden`,`transition-colors duration-normal ease-out-custom`),{variants:{variant:{default:f(i,`rounded-md p-1`,n),embedded:`rounded-none border-none bg-transparent p-0`,inline:`rounded-none border-none bg-transparent p-0`}},defaultVariants:{variant:`default`}}),Wa=[Ce.highest(b.editorAttributes.of({style:`outline: none`})),Ce.highest(b.theme({"&":{outline:`none`},"&.cm-focused":{outline:`none`},".cm-scroller":{outline:`none`},".cm-content":{outline:`none`},".cm-content:focus":{outline:`none`}}))],Ga=b.theme({".cm-content":{padding:`0`,minHeight:`3lh`},".cm-line":{padding:`0`}}),Ka=(0,B.forwardRef)(({data:e,value:n,onChange:i,showCopyButton:a=!0,showFormatButton:o=!1,className:l,language:d=`json`,font:p=`mono`,highlightVariables:ne=!1,placeholder:re,schema:h,autoFocus:ie,lineNumbers:g=!0,lineWrapping:_=!0,editable:v,extensions:y,variant:x,id:ae,"aria-label":oe,"aria-labelledby":S,"aria-describedby":C,"aria-invalid":w,...T},se)=>{let E=t({"aria-label":oe}),D=oe??`Code editor`,O=ae??E.id,ce=S??E[`aria-labelledby`],k=C??E[`aria-describedby`],le=w??E[`aria-invalid`],ue=Ha(p),A=e?JSON.stringify(e,null,2):n??``,j=o&&d===`json`&&v!==!1&&!!i,de=async()=>{try{i?.((await Ge(A)).trimEnd())}catch{u.error(`Can’t format: the JSON is invalid`)}},fe=(0,B.useMemo)(()=>{let e={"aria-label":D,class:`zoom-safe-text`};O&&(e.id=O),ce&&(e[`aria-labelledby`]=ce),k&&(e[`aria-describedby`]=k),le!==void 0&&(e[`aria-invalid`]=String(le));let t=[...Wa,b.contentAttributes.of(e),x===`inline`?Ga:Na];return _&&t.push(b.lineWrapping),d===`json`?t.push(m):d===`markdown`&&t.push(ee({base:te,codeLanguages:ja})),ne&&d===`markdown`&&t.push(Ba),h&&d===`markdown`&&t.push(Fa(h)),v===!1&&t.push(P.readOnly.of(!0)),y&&t.push(...y),t},[y,x,d,ne,h,v,_,O,D,ce,k,le]);return(0,V.jsxs)(`div`,{className:f(Ua({variant:x}),l),...T,children:[(a||j)&&(0,V.jsxs)(`div`,{className:`absolute top-2 right-2 z-20 flex gap-1`,children:[j&&(0,V.jsx)(r,{type:`button`,size:`icon-sm`,tooltip:`Format JSON`,"aria-label":`Format JSON`,onClick:de,children:(0,V.jsx)(c,{})}),a&&(0,V.jsx)(s,{content:A})]}),(0,V.jsx)(ka,{ref:se,value:A,theme:ue,extensions:fe,onChange:i,editable:v,"aria-label":D,placeholder:re,height:`100%`,style:{height:`100%`},autoFocus:ie,basicSetup:{lineNumbers:g,foldGutter:!1}})]})});export{Ka as t};