orc-ai 0.1.37 → 0.1.41

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 (114) hide show
  1. package/README.md +37 -1
  2. package/dist/index.js +641 -584
  3. package/dist/skills/orc-platform/SKILL.md +7 -0
  4. package/dist/skills/orc-platform/references/execution.md +7 -1
  5. package/dist/skills/orc-platform/references/session-archive.md +199 -0
  6. package/dist/skills/orc-platform/scripts/sync-sessions.py +297 -0
  7. package/dist/web/assets/{Agents-BbR4Bppp.js → Agents-1lX_DRrR.js} +1 -1
  8. package/dist/web/assets/{Audit-BFK82hee.js → Audit-DnRP9Ivm.js} +1 -1
  9. package/dist/web/assets/{Dashboard-DJufUiXp.js → Dashboard-bT5SABu_.js} +1 -1
  10. package/dist/web/assets/{DocumentWorkspace-C6iWm8RY.js → DocumentWorkspace-BI4JWVsO.js} +1 -1
  11. package/dist/web/assets/{FileEditor-C5d4xs5E.js → FileEditor-Cb8uXr6e.js} +1 -1
  12. package/dist/web/assets/{JobWebhooks-DGM7EHVj.js → JobWebhooks-CYE2UA0V.js} +1 -1
  13. package/dist/web/assets/{Jobs-Cwhf6HrZ.js → Jobs-Fyd46CkI.js} +1 -1
  14. package/dist/web/assets/Knowledge-prZWODFP.js +28 -0
  15. package/dist/web/assets/{PackageCatalog-rlnJnlaQ.js → PackageCatalog-R8kcGP28.js} +4 -4
  16. package/dist/web/assets/{Pager-B53jtBdE.js → Pager-urh4-P2a.js} +1 -1
  17. package/dist/web/assets/{Rules-C5l03Rhx.js → Rules-if9ZzABl.js} +2 -2
  18. package/dist/web/assets/Sessions-AfC-wZoj.js +5 -0
  19. package/dist/web/assets/Settings-CNPE54fO.js +20 -0
  20. package/dist/web/assets/Skills-BJcE6uiQ.js +1 -0
  21. package/dist/web/assets/{SourceEditor-DW0vd3ce.js → SourceEditor-a2_IdCoT.js} +3 -3
  22. package/dist/web/assets/{Tasks-DEDs5HYJ.js → Tasks-COQCj4HF.js} +8 -13
  23. package/dist/web/assets/Terminals-D4K_u_ch.js +115 -0
  24. package/dist/web/assets/Terminals-DODPh4gr.css +1 -0
  25. package/dist/web/assets/{Webhooks-BopgoCAt.js → Webhooks-DvsCfbZY.js} +1 -1
  26. package/dist/web/assets/{abnfDiagram-VCTEODGH-99oetRq5.js → abnfDiagram-VCTEODGH-C1g9AmGT.js} +1 -1
  27. package/dist/web/assets/{arc-jz6C0oUp.js → arc-BX1-afFK.js} +1 -1
  28. package/dist/web/assets/{architectureDiagram-5GKGNRK7-CDnf-tTr.js → architectureDiagram-5GKGNRK7-DTDe767x.js} +3 -3
  29. package/dist/web/assets/{blockDiagram-I7D4REHJ-wUZULRmh.js → blockDiagram-I7D4REHJ-DJnvrUZM.js} +1 -1
  30. package/dist/web/assets/{c4Diagram-7LVT6UL2-BbTCN0gc.js → c4Diagram-7LVT6UL2-rpXv4dc9.js} +1 -1
  31. package/dist/web/assets/channel-DsRXlXQz.js +1 -0
  32. package/dist/web/assets/{chunk-2Q5K7J3B-DXQa_KS-.js → chunk-2Q5K7J3B-BEq6zYAO.js} +1 -1
  33. package/dist/web/assets/{chunk-5VM5RSS4-DKex8fM9.js → chunk-5VM5RSS4-kAS1IBM0.js} +1 -1
  34. package/dist/web/assets/{chunk-F27PBJKO-CV24Bpwp.js → chunk-F27PBJKO-BtG5IndH.js} +1 -1
  35. package/dist/web/assets/{chunk-IMKFNOWR-dgfQu6Cr.js → chunk-IMKFNOWR-C-NO8OSz.js} +1 -1
  36. package/dist/web/assets/{chunk-JWPE2WC7-rU75UmMf.js → chunk-JWPE2WC7-2IhqyMft.js} +1 -1
  37. package/dist/web/assets/{chunk-POPQ4Y6H-D05TMjhY.js → chunk-POPQ4Y6H-DmxK4niw.js} +1 -1
  38. package/dist/web/assets/{chunk-SVP7TREG-DCPR8a_3.js → chunk-SVP7TREG-BkVeMS09.js} +1 -1
  39. package/dist/web/assets/{chunk-TICWLB2K-14JxXrzn.js → chunk-TICWLB2K-DzlMwg1V.js} +1 -1
  40. package/dist/web/assets/{chunk-XXDRQBXY-CU-iUgTI.js → chunk-XXDRQBXY-ttUQmtBw.js} +1 -1
  41. package/dist/web/assets/classDiagram-ZZMXUADV-CZXMGXM8.js +1 -0
  42. package/dist/web/assets/classDiagram-v2-VYDZK3BY-CZXMGXM8.js +1 -0
  43. package/dist/web/assets/{cose-bilkent-JH36ORCC-DsK-Wgux.js → cose-bilkent-JH36ORCC-yhoqj6vM.js} +1 -1
  44. package/dist/web/assets/{cynefin-OW5HDTMX-CIbMF4yA.js → cynefin-OW5HDTMX-CQZuSJ5b.js} +1 -1
  45. package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-Dfa-crHB.js → cynefinDiagram-5FMLGOSQ-Dz-2nuEW.js} +1 -1
  46. package/dist/web/assets/{dagre-GXQ25YYZ-B4F2yY9x.js → dagre-GXQ25YYZ-DZJid-R_.js} +1 -1
  47. package/dist/web/assets/{diagram-S7CK7UJ4-f6czEOz8.js → diagram-S7CK7UJ4-DB-Uzpn6.js} +1 -1
  48. package/dist/web/assets/{diagram-UQ7AKVKN-Bzc5H6mj.js → diagram-UQ7AKVKN-BjIgjC39.js} +1 -1
  49. package/dist/web/assets/{diagram-VSXAHHWV-nchG2_is.js → diagram-VSXAHHWV-CjFlgbiX.js} +1 -1
  50. package/dist/web/assets/{diagram-VX7I27RA-DtoGnSm-.js → diagram-VX7I27RA-BlfR5PYu.js} +1 -1
  51. package/dist/web/assets/{diagram-Z3DM3KII-B5RB4-4l.js → diagram-Z3DM3KII-DL6_QJQh.js} +1 -1
  52. package/dist/web/assets/{download-CUHnwD4I.js → download-CK_EusLu.js} +1 -1
  53. package/dist/web/assets/{ebnfDiagram-PWID7BFC-474F-fnY.js → ebnfDiagram-PWID7BFC-BjdizMG0.js} +1 -1
  54. package/dist/web/assets/{erDiagram-RLTQ6QDP-DjcLWB7r.js → erDiagram-RLTQ6QDP-BxMzPgpM.js} +1 -1
  55. package/dist/web/assets/{flowDiagram-HODETNUW-ClrSnJZC.js → flowDiagram-HODETNUW-C-HgPS9G.js} +1 -1
  56. package/dist/web/assets/folder-open-Bcqha5Pu.js +16 -0
  57. package/dist/web/assets/{ganttDiagram-EL5Y4UJY-DvUWwHi6.js → ganttDiagram-EL5Y4UJY-BEx6HKx_.js} +4 -4
  58. package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-DzQUHPow.js → gitGraphDiagram-WWUBYQGX-D9yMgjsA.js} +1 -1
  59. package/dist/web/assets/{highlighted-body-KPVGNVTW-BwSphjF-.js → highlighted-body-KPVGNVTW-Cdq0W8LG.js} +1 -1
  60. package/dist/web/assets/index-BqQDBYwx.js +461 -0
  61. package/dist/web/assets/index-D1sNa9P-.css +1 -0
  62. package/dist/web/assets/{infoDiagram-27XIBGKW-BXiAYW5v.js → infoDiagram-27XIBGKW-e_LgGqFP.js} +1 -1
  63. package/dist/web/assets/{ishikawaDiagram-5VMMS53U-DtkPoBMd.js → ishikawaDiagram-5VMMS53U-jOCokdCr.js} +1 -1
  64. package/dist/web/assets/{journeyDiagram-3NMN7TZE-De55MHfN.js → journeyDiagram-3NMN7TZE-DfyXRW30.js} +1 -1
  65. package/dist/web/assets/{kanban-definition-UXKFOSKX-CMbmC8bh.js → kanban-definition-UXKFOSKX-D6Mgx6_N.js} +1 -1
  66. package/dist/web/assets/{layout-CMoc3Ymp.js → layout-BFQQ8SSL.js} +1 -1
  67. package/dist/web/assets/{linear-ByaFbiCi.js → linear-C251cMFR.js} +1 -1
  68. package/dist/web/assets/list-BnZDr6iH.js +6 -0
  69. package/dist/web/assets/mermaid-HWGCJPDP-DE8bnMel.js +609 -0
  70. package/dist/web/assets/{mindmap-definition-YA3MSWOX-DHpoB_3Z.js → mindmap-definition-YA3MSWOX-hX6YQE6d.js} +1 -1
  71. package/dist/web/assets/{pegDiagram-XKGWAZYB-DlUFQicu.js → pegDiagram-XKGWAZYB-DRRv8KEz.js} +1 -1
  72. package/dist/web/assets/{pencil-C7MeJi2-.js → pencil-ClEwbF1x.js} +1 -1
  73. package/dist/web/assets/{pieDiagram-E7YTZNPT-BTxNRrLy.js → pieDiagram-E7YTZNPT-DwRQy5kr.js} +1 -1
  74. package/dist/web/assets/{quadrantDiagram-AXDQQJYC-BXisK15b.js → quadrantDiagram-AXDQQJYC-u-NZRX9E.js} +1 -1
  75. package/dist/web/assets/{railroadDiagram-O6MQD6OU-Dep-5EOi.js → railroadDiagram-O6MQD6OU-DsGn0lJc.js} +1 -1
  76. package/dist/web/assets/{refresh-cw-Bwp-x39v.js → refresh-cw-BGtNOi70.js} +1 -1
  77. package/dist/web/assets/{requirementDiagram-BXWQKSXE-Dts4RxIL.js → requirementDiagram-BXWQKSXE-Bak7hmyH.js} +1 -1
  78. package/dist/web/assets/{sankeyDiagram-P5KCCOFB-B55oiprJ.js → sankeyDiagram-P5KCCOFB-Bx5Wxkio.js} +1 -1
  79. package/dist/web/assets/{save-F382q8r7.js → save-ChNqW56W.js} +1 -1
  80. package/dist/web/assets/{scroll-area-B2WVTNHY.js → scroll-area-YSA2ORI8.js} +1 -1
  81. package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-Dm8OZOYP.js → sequenceDiagram-WJ2MYXX4-CyWelz_H.js} +1 -1
  82. package/dist/web/assets/{sizeCapture-INFHLROL-CdGYDQGd.js → sizeCapture-INFHLROL-BCzEf-8B.js} +1 -1
  83. package/dist/web/assets/{stateDiagram-D77RDMKH-DzLl6piI.js → stateDiagram-D77RDMKH-BkqZfGYQ.js} +1 -1
  84. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-PLwI4Xlh.js +1 -0
  85. package/dist/web/assets/{swimlanes-42K2YHIH-C0y9oB16.js → swimlanes-42K2YHIH-BMYDAy8X.js} +1 -1
  86. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-BEGqjIIe.js +8 -0
  87. package/dist/web/assets/{timeline-definition-24CTP7MA-BcFnACv9.js → timeline-definition-24CTP7MA-BrGykZXB.js} +1 -1
  88. package/dist/web/assets/{upload-De21en-z.js → upload-waJ36Q68.js} +1 -1
  89. package/dist/web/assets/{useJobs-C4BQQWOR.js → useJobs-By4K4BjX.js} +1 -1
  90. package/dist/web/assets/{useKnowledge-Dlk6zbmi.js → useKnowledge-DMSoPz-b.js} +1 -1
  91. package/dist/web/assets/{useMemories-B0YNmRrw.js → useMemories-bv4XvbzQ.js} +1 -1
  92. package/dist/web/assets/useProjectScope-BvcpSOql.js +1 -0
  93. package/dist/web/assets/{vennDiagram-4TSXK5OY-Bn7Y7h5d.js → vennDiagram-4TSXK5OY-CkLSasvk.js} +1 -1
  94. package/dist/web/assets/{wardleyDiagram-VM6X3IG4-Bd7zbrPy.js → wardleyDiagram-VM6X3IG4-DfPte2eh.js} +1 -1
  95. package/dist/web/assets/{xychartDiagram-S5SC5T6Z-CyDYeK9G.js → xychartDiagram-S5SC5T6Z-ClFkeona.js} +1 -1
  96. package/dist/web/index.html +3 -3
  97. package/package.json +1 -1
  98. package/dist/web/assets/Knowledge-D5JF_DmG.js +0 -38
  99. package/dist/web/assets/Sessions-B1ES2jjN.js +0 -1
  100. package/dist/web/assets/Settings-DZTNnZp2.js +0 -12
  101. package/dist/web/assets/Skills-zUJSqzxy.js +0 -1
  102. package/dist/web/assets/Terminals-BbWYyHA3.css +0 -1
  103. package/dist/web/assets/Terminals-jLXfmfnA.js +0 -43
  104. package/dist/web/assets/channel-BMK2j5Xo.js +0 -1
  105. package/dist/web/assets/classDiagram-ZZMXUADV-C3CpsbeZ.js +0 -1
  106. package/dist/web/assets/classDiagram-v2-VYDZK3BY-C3CpsbeZ.js +0 -1
  107. package/dist/web/assets/folder-open-DqVAWgc5.js +0 -6
  108. package/dist/web/assets/index-2ojlkIJg.css +0 -1
  109. package/dist/web/assets/index-CRsafixF.js +0 -379
  110. package/dist/web/assets/mermaid-HWGCJPDP-BANMxb7n.js +0 -609
  111. package/dist/web/assets/schemas-Cwl03S4d.js +0 -57
  112. package/dist/web/assets/stateDiagram-v2-MP3YSRHH-Bd9-xfy5.js +0 -1
  113. package/dist/web/assets/swimlanesDiagram-VR7AAH4N-CY_HM0pG.js +0 -8
  114. package/dist/web/assets/useProjectScope-NKMBMTCk.js +0 -1
@@ -0,0 +1,20 @@
1
+ import{r as m,j as e,G as re,c as M,d as _,c1 as V,Y as g,Z as y,ah as K,B as w,Q as ie,am as oe,an as A,ao as F,ap as T,aq as D,ar as C,a7 as de,a as J,b as le,c2 as ce,c3 as me,c4 as he,ag as ue,c5 as xe,c6 as ge,E as pe,bE as fe,a9 as G,c7 as O,V as be,c8 as Y,c9 as q}from"./index-BqQDBYwx.js";import{u as ve,a as je,b as ye,c as Ne}from"./useKnowledge-DMSoPz-b.js";import{D as ke}from"./download-CK_EusLu.js";import{S as X}from"./save-ChNqW56W.js";var _e=Object.defineProperty,ee=(t,n)=>_e(t,"name",{value:n,configurable:!0}),z={Horizontal:"horizontal",Vertical:"vertical"},W=z.Horizontal,we=Object.values(z),te=m.forwardRef(ee(function(n,h){const{decorative:c,orientation:s=W,...x}=n,p=se(s)?s:W,b=p===z.Vertical?p:void 0,v=c?{role:"none"}:{"aria-orientation":b,role:"separator"};return e.jsx(re.div,{"data-orientation":p,...v,...x,ref:h})},"Separator"));function se(t){return we.includes(t)}ee(se,"isValidOrientation");/**
2
+ * @license lucide-react v1.27.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Se=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ce=M("circle-check-big",Se);/**
7
+ * @license lucide-react v1.27.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Ee=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],Re=M("plug",Ee);/**
12
+ * @license lucide-react v1.27.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Pe=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Oe=M("rotate-cw",Pe);function Ie(){const[t,n]=m.useState(null),[h,c]=m.useState(""),[s,x]=m.useState(""),[p,b]=m.useState(!1);m.useEffect(()=>{let o=!1;return _.settings.get().then(d=>{if(o)return;const f=V.parse(d.chat??{});n(f),c(f.models.map(u=>`${u.agent}: ${u.id}`).join(`
17
+ `))}).catch(d=>{o||x(d.message)}),()=>{o=!0}},[]);async function v(){if(t){b(!0),x("");try{const o=h.split(`
18
+ `).filter(f=>f.trim()).map(f=>{const u=f.match(/^([a-z][a-z0-9-]*):\s*(.+)$/i);if(!u)throw new Error("Use agent: model-id on each model line.");return{agent:u[1]??"",id:u[2]??""}}),d=V.parse({...t,models:o});await _.settings.save({chat:d}),n(d),window.dispatchEvent(new Event("orc-chat-settings-changed")),x("Chat defaults saved. They apply to new conversations on every device.")}catch(o){x(o instanceof Error?o.message:"Chat settings could not be saved.")}finally{b(!1)}}}return e.jsxs("section",{"aria-labelledby":"chat-settings-title",className:"space-y-4","data-testid":"chat-settings",children:[e.jsxs("div",{children:[e.jsx("h2",{id:"chat-settings-title",className:"text-base font-medium",children:"Chat"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Defaults for new conversations. Existing chats keep their configuration. Credentials stay on the execution host."})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-default-agent",children:"Default agent"}),e.jsx(y,{id:"chat-default-agent","data-testid":"chat-default-agent",value:t.agent,onChange:o=>n({...t,agent:o.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-default-model",children:"Default model"}),e.jsx(y,{id:"chat-default-model","data-testid":"chat-default-model",value:t.model,placeholder:"Agent default",onChange:o=>n({...t,model:o.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-model-catalog",children:"Model picker choices"}),e.jsx(K,{id:"chat-model-catalog","data-testid":"chat-model-catalog",value:h,onChange:o=>c(o.target.value),placeholder:`codex: your-model-id
19
+ claude: your-model-id`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"One agent: model-id per line. Use model IDs supported by your installed agent and account."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-system-prompt",children:"Instructions"}),e.jsx(K,{id:"chat-system-prompt","data-testid":"chat-system-prompt",rows:6,value:t.system,onChange:o=>n({...t,system:o.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Claude appends these to its coding system prompt. Codex and other agents receive them as turn instructions. Workspace rules remain enforced."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"chat-mcp",children:"Tools connection"}),e.jsxs("select",{id:"chat-mcp","data-testid":"chat-mcp",className:"min-h-11 w-full rounded-md border border-control-border bg-background px-3 text-base sm:text-sm",value:t.mcp,onChange:o=>n({...t,mcp:o.target.value}),children:[e.jsx("option",{value:"orc",children:"Connect ORC MCP (Claude and Codex)"}),e.jsx("option",{value:"native",children:"Use the agent’s host configuration"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The ORC connection uses server credentials internally. Host configuration may include other MCP servers; this setting does not disable them. Protected workspaces may also require ORC tools."})]}),e.jsxs("label",{className:"flex min-h-11 items-start gap-3 py-2 text-sm",children:[e.jsx("input",{"data-testid":"chat-auto-approve",type:"checkbox",checked:t.autoApprove,onChange:o=>n({...t,autoApprove:o.target.checked}),className:"mt-1 size-4"}),e.jsxs("span",{children:["Allow agent actions automatically",e.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:"Off: Claude asks in chat; Codex runs with a read-only sandbox; other agents use their native permission policy. On: Claude bypasses permission prompts; Codex can write in its workspace. ORC rules still apply."})]})]}),e.jsx(w,{"data-testid":"chat-settings-save",disabled:p,onClick:()=>void v(),children:p?"Saving…":"Save chat defaults"})]}),s&&e.jsx("p",{role:"status","data-testid":"chat-settings-feedback",className:"break-words text-sm text-muted-foreground",children:s})]})}const E=m.forwardRef(({className:t,orientation:n="horizontal",decorative:h=!0,...c},s)=>e.jsx(te,{ref:s,decorative:h,orientation:n,className:ie("shrink-0 bg-surface-bright ",n==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...c}));E.displayName=te.displayName;const P=1024*1024;function Q(t){return t===null?"":t>=1024*P?`${(t/1024/P).toFixed(1)} GB`:`${Math.round(t/P)} MB`}function Ae(t){return{session_embeddings:t.session_embeddings??!1,parser:t.parser,docling_enabled:t.docling_enabled,parser_timeout_secs:String(t.parser_timeout_secs),max_upload_mb:String(Math.round(t.max_upload_bytes/P)),usage_retention_days:String(t.usage_retention_days),provider:t.embedding.provider,base_url:t.embedding.base_url??"",model:t.embedding.model??"",dimensions:t.embedding.dimensions?String(t.embedding.dimensions):"",api_key:"",clear_key:!1}}const Fe={none:"Keyword search only. Add an embedding provider for semantic and hybrid search.",ollama:"Local embeddings from Ollama, for example nomic-embed-text at http://localhost:11434.",openai:"OpenAI or any OpenAI-compatible endpoint, for example text-embedding-3-small."};function Te(){var L,$,H,U;const t=ve(),n=je(),h=ye(),c=Ne(),[s,x]=m.useState(null),[p,b]=m.useState(null),[v,o]=m.useState(!1),[d,f]=m.useState(!1),[u,k]=m.useState(!1);if(m.useEffect(()=>{t.data&&x(Ae(t.data))},[t.data]),t.error)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-1 text-base font-medium",children:"Knowledge"}),e.jsx("p",{role:"alert",className:"text-sm text-error",children:t.error.message})]});if(!s||!t.data)return null;const j=t.data,N=a=>j.env_overrides.includes(`ORC_KNOWLEDGE_${a}`),l=a=>{o(!1),x({...s,...a})},i=(L=n.data)==null?void 0:L.parsers.find(a=>a.id==="docling"),r=($=n.data)==null?void 0:$.docling;async function S(a){f(!0),b(null);try{return await a(),await c(),!0}catch(R){return b(R instanceof Error?R.message:"Request failed"),!1}finally{f(!1)}}async function ae(a){if(a.preventDefault(),!s)return;const R=B=>B.trim()?Number(B):null,ne={session_embeddings:s.session_embeddings,parser:s.parser,docling_enabled:s.docling_enabled,parser_timeout_secs:Number(s.parser_timeout_secs),max_upload_bytes:Number(s.max_upload_mb)*P,usage_retention_days:Number(s.usage_retention_days),embedding:{provider:s.provider,base_url:s.base_url.trim()||null,model:s.model.trim()||null,dimensions:R(s.dimensions),...s.clear_key?{api_key:null}:s.api_key?{api_key:s.api_key}:{}}};await S(()=>_.kb.updateSettings(ne))&&o(!0)}return e.jsxs("section",{"data-testid":"settings-knowledge","aria-labelledby":"settings-knowledge-title",children:[e.jsx("h2",{id:"settings-knowledge-title",className:"mb-1 text-base font-medium text-on-surface",children:"Knowledge"}),e.jsxs("p",{className:"mb-4 text-sm text-muted-foreground",children:["How ORC parses uploads and searches knowledge bases. Saved on the server in"," ",e.jsx("code",{className:"text-primary",children:"~/.orc/config.json"}),"; files live in"," ",e.jsx("code",{className:"break-all text-primary",children:j.root}),"."]}),e.jsx(E,{className:"mb-4 bg-outline-variant"}),j.env_overrides.length>0&&e.jsxs("p",{className:"mb-4 text-sm text-warning","data-testid":"settings-knowledge-env",children:["Set by environment, these win over saved values: ",j.env_overrides.join(", ")]}),e.jsxs("form",{onSubmit:ae,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Parsers"}),(H=n.data)==null?void 0:H.parsers.map(a=>e.jsxs("div",{"data-testid":`settings-parser-${a.id}`,className:"rounded-md border border-outline-variant p-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:a.label}),e.jsxs("span",{className:"text-xs text-outline",children:[a.installed?`v${a.version}`:"not installed",a.size_bytes?` · ${Q(a.size_bytes)}${a.installed?"":" download"}`:""]})]}),e.jsx("p",{className:"mt-1 text-outline",children:a.description}),e.jsxs("p",{className:"mt-1 text-xs text-outline",children:["Formats: ",a.capabilities.formats.join(", ")]}),a.detail&&e.jsx("p",{className:"mt-1 text-xs text-outline",children:a.detail}),a.id==="docling"&&e.jsxs("div",{className:"mt-3 space-y-2",children:[(r==null?void 0:r.state)==="installing"&&e.jsxs("div",{role:"status","data-testid":"settings-docling-progress",className:"text-xs text-outline",children:[r.step,e.jsx("pre",{className:"mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap font-mono",children:r.log.slice(-8).join(`
20
+ `)})]}),(r==null?void 0:r.state)==="failed"&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:r.error}),a.installed?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-docling-enabled",checked:s.docling_enabled,onChange:R=>l({docling_enabled:R.target.checked})}),"Use automatically for PDFs and images"]}),e.jsxs(w,{type:"button",size:"sm",variant:"ghost",className:"text-error","data-testid":"settings-docling-remove",onClick:()=>k(!0),children:[e.jsx(oe,{size:14}),"Remove"]})]}):e.jsxs(w,{type:"button",size:"sm",variant:"outline","data-testid":"settings-docling-install",disabled:d||(r==null?void 0:r.state)==="installing",onClick:()=>S(()=>_.kb.installDocling()),children:[e.jsx(ke,{size:14}),(r==null?void 0:r.state)==="installing"?"Installing…":`Install Docling (${Q((i==null?void 0:i.size_bytes)??null)||"about 2 GB"})`]})]})]},a.id)),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-kb-parser",className:"text-sm text-muted-foreground",children:"Default parser"}),e.jsxs(A,{value:s.parser,onValueChange:a=>l({parser:a}),disabled:N("PARSER"),children:[e.jsx(F,{id:"settings-kb-parser","data-testid":"settings-kb-parser",children:e.jsx(T,{})}),e.jsxs(D,{children:[e.jsx(C,{value:"auto",children:"Automatic: Docling for PDFs and images when enabled"}),(U=n.data)==null?void 0:U.parsers.map(a=>e.jsx(C,{value:a.id,disabled:!a.installed,children:a.label},a.id))]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Knowledge bases can override it. Changing parsers applies to new uploads; reparse a document to apply it to existing ones."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-timeout",className:"text-sm text-muted-foreground",children:"Parse timeout (s)"}),e.jsx(y,{id:"settings-kb-timeout",type:"number",min:10,value:s.parser_timeout_secs,onChange:a=>l({parser_timeout_secs:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-max-upload",className:"text-sm text-muted-foreground",children:"Max upload (MB)"}),e.jsx(y,{id:"settings-kb-max-upload",type:"number",min:1,value:s.max_upload_mb,onChange:a=>l({max_upload_mb:a.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-retention",className:"text-sm text-muted-foreground",children:"Read log (days)"}),e.jsx(y,{id:"settings-kb-retention",type:"number",min:1,value:s.usage_retention_days,onChange:a=>l({usage_retention_days:a.target.value})})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Semantic search"}),e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-session-embeddings",checked:s.session_embeddings,onChange:a=>l({session_embeddings:a.target.checked})}),e.jsxs("span",{children:["Search coding sessions with embeddings",e.jsx("span",{className:"block text-xs text-outline",children:"Uses the provider below for session passages. Keyword search and transcript reading remain available when off. Enabling sends session text to this provider and indexes discovered project sessions."})]})]}),h.data&&e.jsxs("p",{className:"text-xs text-outline","data-testid":"settings-embedding-status",children:[h.data.embedding.ready?`Ready · ${h.data.embedding.model} · ${h.data.embedding.vector_backend}`:h.data.embedding.detail??"Not configured",h.data.embedding.pending_chunks?` · ${h.data.embedding.pending_chunks} passages waiting`:""]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-provider",className:"text-sm text-muted-foreground",children:"Embedding provider"}),e.jsxs(A,{value:s.provider,onValueChange:a=>l({provider:a}),disabled:N("EMBEDDING_PROVIDER"),children:[e.jsx(F,{id:"settings-kb-provider","data-testid":"settings-kb-provider",children:e.jsx(T,{})}),e.jsxs(D,{children:[e.jsx(C,{value:"none",children:"None"}),e.jsx(C,{value:"ollama",children:"Ollama"}),e.jsx(C,{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:Fe[s.provider]})]}),s.provider!=="none"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-model",className:"text-sm text-muted-foreground",children:"Model"}),e.jsx(y,{id:"settings-kb-model","data-testid":"settings-kb-model",value:s.model,disabled:N("EMBEDDING_MODEL"),onChange:a=>l({model:a.target.value}),placeholder:s.provider==="ollama"?"nomic-embed-text":"text-embedding-3-small"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-dimensions",className:"text-sm text-muted-foreground",children:"Dimensions"}),e.jsx(y,{id:"settings-kb-dimensions",type:"number",value:s.dimensions,onChange:a=>l({dimensions:a.target.value}),placeholder:"Model default"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-base-url",className:"text-sm text-muted-foreground",children:"Base URL"}),e.jsx(y,{id:"settings-kb-base-url","data-testid":"settings-kb-base-url",value:s.base_url,disabled:N("EMBEDDING_URL"),onChange:a=>l({base_url:a.target.value}),placeholder:s.provider==="ollama"?"http://localhost:11434":"https://api.openai.com/v1"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(g,{htmlFor:"settings-kb-api-key",className:"text-sm text-muted-foreground",children:s.provider==="ollama"?"Token (hosted or proxied Ollama)":"API key"}),e.jsx(y,{id:"settings-kb-api-key",type:"password",autoComplete:"off","data-testid":"settings-kb-api-key",value:s.api_key,disabled:s.clear_key||N("EMBEDDING_API_KEY"),onChange:a=>l({api_key:a.target.value}),placeholder:j.embedding.api_key_set?"Saved. Type to replace":"Not set"}),j.embedding.api_key_set&&e.jsxs("label",{className:"flex items-center gap-2 text-xs text-outline",children:[e.jsx("input",{type:"checkbox","data-testid":"settings-kb-api-key-clear",checked:s.clear_key,onChange:a=>l({clear_key:a.target.checked,api_key:""})}),"Remove the saved key"]}),e.jsxs("p",{className:"text-xs text-outline",children:["Stored encrypted with the key in ",e.jsx("code",{children:"~/.orc/secret.key"})," and never sent back to the browser. Sent as a bearer token to the base URL."]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Changing the model re-embeds every passage in the background; keyword search keeps working meanwhile."})]})]}),p&&e.jsx("p",{role:"alert","data-testid":"settings-knowledge-error",className:"text-sm text-error",children:p}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(w,{type:"submit","data-testid":"settings-knowledge-save",disabled:d,children:"Save knowledge settings"}),v&&e.jsx("span",{role:"status",className:"text-sm text-muted-foreground",children:"Saved"})]})]}),e.jsx(de,{open:u,title:"Remove Docling",description:"Deletes the Docling runtime and models from this machine. Documents it parsed keep their text; reparse them to use the basic parser.",confirmLabel:"Remove",isPending:d,onCancel:()=>k(!1),onConfirm:async()=>{k(!1),await S(()=>_.kb.uninstallDocling())}})]})}function De(){const t=J();return le({mutationFn:async()=>{const n=await _.system.restart(),h=Date.now()+6e4;for(;Date.now()<h;){await new Promise(c=>setTimeout(c,500));try{if((await _.health.check(AbortSignal.timeout(2e3))).instance_id!==n.instance_id)return}catch(c){if(c instanceof ce&&c.status===401)throw c}}throw new Error("ORC has not reconnected yet. Check the server and try again when it is online.")},onSuccess:()=>t.invalidateQueries()})}function Me(){const{data:t}=me(),n=De();return e.jsxs("section",{"aria-labelledby":"server-title",children:[e.jsx("h2",{id:"server-title",className:"mb-1 text-base font-medium",children:"ORC server"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Restart ORC to reload server and host information. This closes active terminals and may interrupt running work. Your settings are kept, and this dashboard reconnects automatically. Switching hosts applies to new actions without a restart."}),e.jsx(E,{className:"mb-4"}),e.jsxs(w,{variant:"outline","data-testid":"settings-restart",disabled:!(t!=null&&t.restart_supported)||n.isPending,onClick:()=>n.mutate(),children:[e.jsx(Oe,{className:n.isPending?"mr-2 size-4 animate-spin":"mr-2 size-4"}),n.isPending?"Restarting and reconnecting…":"Restart ORC server"]}),t&&!t.restart_supported&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"This server does not support restart from the dashboard."}),n.isPending&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"Waiting for ORC to restart…"}),n.isSuccess&&e.jsx("p",{role:"status","data-testid":"settings-restart-status",className:"mt-2 text-sm text-muted-foreground",children:"ORC restarted. Reconnected."}),n.isError&&e.jsx("p",{role:"alert","data-testid":"settings-restart-error",className:"mt-2 text-sm text-error",children:n.error.message})]})}const I="__local__";function Z(t){return t?t instanceof Error?t.message:String(t):null}function ze(){var i;const{data:t,error:n,refetch:h}=he(),{data:c}=ue(),s=xe(),x=ge(),[p,b]=m.useState(I),[v,o]=m.useState("");if(m.useEffect(()=>{t&&(b(t.host??I),o(t.remote_port===null?"":String(t.remote_port)))},[t]),n)return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-semibold",children:"Execution host"}),e.jsx(pe,{message:n.message,onRetry:()=>void h()})]});if(!t)return e.jsx("p",{role:"status","data-testid":"page-loading",className:"text-sm text-muted-foreground",children:"Loading execution host…"});const d=p===I?null:p,f=t.host&&!t.hosts.includes(t.host)?[t.host,...t.hosts]:t.hosts,u=Number(v),k=v.trim()===""||Number.isInteger(u)&&u>=1&&u<=65535,j=t.locked||!t.supported,N=c==null?void 0:c.backends.find(r=>r.name==="claude"),l=((i=x.data)==null?void 0:i.host)===d?x.data:void 0;return e.jsxs("section",{"data-testid":"ssh-settings",children:[e.jsx("h2",{className:"font-headline font-semibold text-base text-on-surface mb-1",children:"Execution host"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Run every agent, terminal, git and file action on a host from"," ",e.jsx("code",{className:"text-primary",children:"~/.ssh/config"}),". Agents there reach orc through a reverse tunnel on the remote port. Terminals already open keep their host."]}),e.jsx(E,{className:"bg-surface-highest mb-4"}),e.jsxs("div",{className:"space-y-4",children:[t.locked&&e.jsx("p",{"data-testid":"ssh-locked",className:"font-body text-sm text-tertiary",children:"Fixed by ORC_SSH_HOST in orc's environment."}),!t.supported&&e.jsx("p",{"data-testid":"ssh-unsupported",className:"font-body text-sm text-error",children:t.unsupported_reason}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-host",className:"font-label text-sm text-muted-foreground",children:"Host"}),e.jsxs(A,{value:p,onValueChange:b,disabled:j,children:[e.jsx(F,{id:"ssh-host","aria-label":"Execution host","data-testid":"ssh-host-picker",className:"bg-surface-highest border-control-border text-on-surface font-body text-sm",children:e.jsx(T,{})}),e.jsxs(D,{className:"bg-surface-highest border-outline-variant max-h-72",children:[e.jsx(C,{value:I,"data-testid":"ssh-host-option-local",className:"font-label text-sm",children:"Local (this machine)"}),f.map(r=>e.jsx(C,{value:r,"data-testid":`ssh-host-option-${r}`,className:"font-label text-sm",children:r},r))]})]}),f.length===0&&e.jsx("p",{"data-testid":"page-empty",className:"font-body text-sm text-muted-foreground",children:"No Host entries found in ~/.ssh/config on the machine running orc."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"ssh-remote-port",className:"font-label text-sm text-muted-foreground",children:"Tunnel port override"}),e.jsx(y,{id:"ssh-remote-port","aria-invalid":!!(d&&!k),"data-testid":"ssh-remote-port",value:v,placeholder:"Automatic",onChange:r=>o(r.target.value),disabled:j||!d,inputMode:"numeric",className:"bg-surface-highest border-outline-variant text-on-surface font-body text-sm"}),d&&!k&&e.jsx("p",{className:"text-sm text-error",children:"Enter a remote port from 1 to 65535."}),e.jsx("p",{className:"font-body text-sm text-muted-foreground",children:"Leave empty to let SSH choose an available port automatically."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(w,{"data-testid":"ssh-save",disabled:j||d!==null&&!k||s.isPending,onClick:()=>s.mutate({host:d,remotePort:d&&v.trim()?u:null}),className:"font-label text-sm bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(X,{size:12,className:"mr-1.5"})," Use Host"]}),e.jsxs(w,{"data-testid":"ssh-test",variant:"ghost",disabled:!d||!t.supported||x.isPending,onClick:()=>d&&x.mutate(d),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:[e.jsx(Re,{size:12,className:"mr-1.5"})," ",x.isPending?"Testing…":"Test"]})]}),Z(s.error??x.error)&&e.jsx("p",{"data-testid":"ssh-error",className:"font-body text-sm text-error",children:Z(s.error??x.error)}),l&&e.jsx("div",{"data-testid":"ssh-test-result",className:"font-body text-sm space-y-1",children:l.ok?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-secondary",children:["Connected to ",l.host," (",l.os,", ",l.shell,")"]}),e.jsx("p",{className:"text-muted-foreground",children:Object.entries(l.binaries).map(([r,S])=>`${S?"●":"○"} ${r}`).join(" ")}),l.binaries.claude&&l.claude_logged_in===!1&&e.jsxs("p",{className:l.api_key_forwarded?"text-muted-foreground":"text-error",children:["claude is not logged in on ",l.host,"."," ",l.api_key_forwarded?"ANTHROPIC_API_KEY from orc's environment will be forwarded.":"Set ANTHROPIC_API_KEY in orc's environment or run claude login there."]})]}):e.jsx("p",{className:"text-error",children:l.error})}),t.host&&N&&!N.available&&e.jsxs("p",{"data-testid":"ssh-claude-error",className:"font-body text-sm text-error",children:["claude backend: ",N.error]})]})]})}function Be(){const{theme:t}=fe(),[n,h]=m.useState(G),[c,s]=m.useState(()=>localStorage.getItem(O)??""),[x,p]=m.useState(!1),[b,v]=m.useState(""),[o,d]=m.useState(""),[f,u]=m.useState(!1),k=J(),j=async()=>{d(""),u(!0);try{const i=n.trim();if(i&&!i.startsWith("/")&&!/^https?:\/\//i.test(i))throw new Error("Use a relative API path or an http(s) server URL.");const r=await _.settings.save({theme:t,terminal_font:c.trim()});Y(r.theme??t),s(r.terminal_font??""),r.terminal_font?localStorage.setItem(O,r.terminal_font):localStorage.removeItem(O);const S=(i||"/api")!==G();localStorage.setItem("orc_api_url",i||"/api"),S&&window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!0),v("Workspace preferences saved on the server. API address saved in this browser."),setTimeout(()=>p(!1),2e3)}catch(i){d(i instanceof Error?i.message:"Browser settings could not be saved.")}finally{u(!1)}},N=async()=>{d(""),u(!0);try{const i=await _.settings.save({terminal_font:""});localStorage.removeItem("orc_api_url"),localStorage.setItem(O,i.terminal_font??""),h("/api"),s(i.terminal_font??""),window.dispatchEvent(new Event(q)),k.invalidateQueries(),p(!1),v("Connection and terminal font restored to their defaults. Appearance and execution host were kept.")}catch(i){d(i instanceof Error?i.message:"Browser settings could not be reset.")}finally{u(!1)}};async function l(i){d(""),u(!0);try{const r=await _.settings.save({theme:i});Y(r.theme??i)}catch(r){d(r instanceof Error?r.message:"Appearance could not be saved.")}finally{u(!1)}}return e.jsxs("div",{children:[e.jsx(be,{title:"Settings"}),e.jsxs("div",{className:"max-w-lg space-y-8",children:[e.jsxs("section",{"aria-labelledby":"appearance-title",children:[e.jsx("h2",{id:"appearance-title",className:"mb-1 text-base font-medium",children:"Appearance"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:"Choose a workspace theme. Your choice is saved on the server immediately."}),e.jsx("fieldset",{className:"flex flex-wrap gap-2","aria-label":"Theme",children:["dark","light"].map(i=>e.jsx(w,{variant:t===i?"secondary":"outline","aria-pressed":t===i,"data-testid":`settings-theme-${i}`,disabled:f,onClick:()=>void l(i),children:i==="dark"?"Dark":"Light"},i))})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"API connection"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground mb-4",children:["Connect this workspace to an ORC server. The default"," ",e.jsx("code",{className:"text-primary",children:"/api"})," uses the current server or the configured development proxy."]}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-api-url",className:"font-label text-sm text-muted-foreground",children:"API base URL"}),e.jsx(y,{id:"settings-api-url","data-testid":"settings-api-url",value:n,onChange:i=>h(i.target.value),placeholder:"/api or http://localhost:7700",className:"bg-background text-on-surface font-body text-sm"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Use ",e.jsx("code",{children:"/api"})," (dev proxy) or a direct URL when CORS is enabled."]})]})})]}),e.jsx(ze,{}),e.jsx(Me,{}),e.jsx(Ie,{}),e.jsx(Te,{}),e.jsxs("section",{children:[e.jsx("h2",{className:"font-headline font-medium text-base text-on-surface mb-1",children:"Terminal"}),e.jsx("p",{className:"font-body text-sm text-muted-foreground mb-4",children:"Prompt and agent status icons need a Nerd Font installed on this machine. Common ones are tried automatically; set the exact family name if your icons show as empty boxes. Applies to terminals opened after saving."}),e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(g,{htmlFor:"settings-terminal-font",className:"font-label text-sm text-muted-foreground",children:"Terminal font family"}),e.jsx(y,{id:"settings-terminal-font",value:c,onChange:i=>s(i.target.value),placeholder:"e.g. MesloLGS NF",className:"bg-background text-on-surface font-body text-sm"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 pt-2",children:[e.jsx(w,{"data-testid":"settings-save",disabled:f,onClick:()=>void j(),className:"font-label text-sm ",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"mr-1.5"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{size:12,className:"mr-1.5"})," Save settings"]})}),e.jsx(w,{variant:"ghost",disabled:f,onClick:()=>void N(),className:"font-label text-sm text-muted-foreground hover:text-on-surface",children:"Reset to defaults"})]}),o&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:o}),b&&!o&&e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:b}),e.jsxs("section",{children:[e.jsx(E,{className:"bg-outline-variant mb-4"}),e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:"Storage"}),e.jsxs("p",{className:"font-body text-sm text-muted-foreground",children:["Workspace preferences and SSH selection are persisted in the server's"," ",e.jsx("code",{children:"~/.orc/config.json"}),". The API address and optionally remembered login are stored in this browser."]})]})]})]})}export{Be as default};
@@ -0,0 +1 @@
1
+ import{j as e,aG as ie,r as v,a as K,u as F,b as I,d as S,a8 as E,U as $,W as A,X as T,B as b,as as H,Y as P,Z as D,$ as O,a0 as le,E as J,V as ne,ak as re,aC as oe,S as ee,af as ce,T as de,s as ue,t as G,v as R,w as me,x as _,a2 as xe,a3 as he,a4 as pe,a5 as ge,a6 as fe,ac as M,k as te,M as je}from"./index-BqQDBYwx.js";import{D as be,c as W}from"./DocumentWorkspace-BI4JWVsO.js";import{u as ye}from"./useProjectScope-BvcpSOql.js";import{r as ve}from"./primitive-files-BwTyowra.js";import{D as Y}from"./download-CK_EusLu.js";function ke({files:a,selected:i,onSelect:x,testId:h="document-file-tab",entryTestId:c}){return e.jsxs("nav",{"aria-label":"Document files",className:"min-w-0 space-y-2","data-testid":"document-tabs",children:[e.jsx("div",{role:"tablist","aria-label":"Open a file",className:"flex max-w-full gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-surface-highest p-1",children:a.map((n,t)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":n===i,"data-testid":t===0&&c?c:h,"data-file-name":n,title:n,tabIndex:n===i?0:-1,onKeyDown:o=>{var y,p;if(!["ArrowRight","ArrowLeft","Home","End"].includes(o.key))return;o.preventDefault();let f=t;if(o.key==="ArrowRight"&&(f=(t+1)%a.length),o.key==="ArrowLeft"&&(f=(t+a.length-1)%a.length),o.key==="Home"&&(f=0),o.key==="End"&&(f=a.length-1),x(a[f])===!1)return;const l=(y=o.currentTarget.parentElement)==null?void 0:y.querySelectorAll('[role="tab"]');(p=l==null?void 0:l[f])==null||p.focus()},onClick:()=>x(n),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${n===i?"bg-surface-highest text-on-surface":"text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:[e.jsx(ie,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"max-w-[180px] truncate",children:n.split("/").pop()})]},n))}),e.jsxs("label",{className:"flex min-w-0 items-center gap-2 text-sm text-outline sm:hidden",children:["File",e.jsx("select",{"aria-label":"Choose document file","data-testid":"document-file-picker",value:i,onChange:n=>x(n.target.value),className:"min-h-11 min-w-0 flex-1 rounded border border-control-border bg-surface px-2 text-on-surface",children:a.map(n=>e.jsx("option",{value:n,children:n},n))})]})]})}const X={new:"",installed:"Already in ORC",conflict:"Name taken in ORC (different content)",changed:"Changed since import",invalid:"Invalid"},q=a=>`${a.agent}/${a.name}`;function Ne({onClose:a}){var y,p,w;const[i,x]=v.useState([]),h=K(),c=F({queryKey:["skills","local-agents"],queryFn:S.skills.localAgents}),n=I({mutationFn:S.skills.importLocal,onSuccess:async g=>{x([]),await h.invalidateQueries({queryKey:["skills"]}),g.skipped.length||a()}}),t=n.isPending,o=((y=c.data)==null?void 0:y.agents)??[],s=new Set(i.map(g=>g.split("/")[1])),f=(g,k)=>x(k?[...i,q(g)]:i.filter(m=>m!==q(g))),l=g=>{const k=[...i],m=new Set(s);for(const N of g)N.status!=="new"||m.has(N.name)||(k.push(q(N)),m.add(N.name));x(k)};return e.jsx(E,{open:!0,onOpenChange:g=>!g&&!t&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from local agents"})}),e.jsx("p",{className:"text-xs text-outline",children:"Copies skills from agent folders such as ~/.claude/skills and ~/.codex/skills into ORC. The originals are not changed."}),c.isLoading&&e.jsx("p",{role:"status",children:"Scanning agent folders…"}),c.data&&!o.length&&e.jsx("p",{role:"status",children:"No local agent skill folders found."}),e.jsx("div",{className:"max-h-[55vh] overflow-y-auto space-y-4",children:o.map(g=>{const k=g.skills.filter(m=>m.status==="new");return e.jsxs("section",{"data-testid":"local-agent","data-agent":g.id,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:g.label}),e.jsx("p",{className:"text-xs text-outline",children:g.dir})]}),e.jsxs(b,{size:"sm",variant:"outline","data-testid":"local-agent-select-all",disabled:t||!k.length,onClick:()=>l(g.skills),children:["Select all new (",k.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:g.skills.map(m=>{const N=i.includes(q(m)),r=!N&&s.has(m.name);return e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"local-skill","data-skill-name":m.name,children:[e.jsx("input",{type:"checkbox","data-testid":"local-skill-select",checked:N,disabled:t||m.status!=="new"||r,onChange:d=>f(m,d.target.checked)}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:m.name}),X[m.status]&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:X[m.status]}),e.jsx("span",{className:"block text-xs text-outline",children:m.error??m.description}),m.extra_fields.length>0&&e.jsxs("span",{className:"block text-xs text-outline","data-testid":"local-skill-extra-fields",children:["Extra fields: ",m.extra_fields.join(", ")]}),m.also_in.length>0&&e.jsxs("span",{className:"block text-xs text-outline",children:["Also in ",m.also_in.join(", ")]})]})]},q(m))})})]},g.id)})}),(p=n.data)==null?void 0:p.skipped.map(g=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:["Skipped ",g.name,": ",g.reason]},`${g.agent}/${g.name}`)),(c.error||n.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(w=c.error||n.error)==null?void 0:w.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:t,onClick:a,children:"Close"}),e.jsx(b,{"data-testid":"local-skill-import-submit",disabled:t||!i.length,onClick:()=>n.mutate(i.map(g=>{const[k="",m=""]=g.split("/");return{agent:k,name:m}})),children:n.isPending?"Importing…":`Import selected${i.length?` (${i.length})`:""}`})]})]})})}function Se({onClose:a}){var f;const[i,x]=v.useState(""),[h,c]=v.useState([]),n=K(),t=I({mutationFn:S.skills.discover,onSuccess:()=>c([])}),o=I({mutationFn:S.skills.import,onSuccess:async()=>{await n.invalidateQueries({queryKey:["skills"]}),a()}}),s=t.isPending||o.isPending;return e.jsx(E,{open:!0,onOpenChange:l=>!l&&!s&&a(),children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(A,{children:e.jsx(T,{children:"Import from GitHub"})}),e.jsxs("form",{className:"space-y-4",onSubmit:l=>{l.preventDefault(),t.mutate(i.trim())},children:[e.jsx(P,{htmlFor:"skill-repository",children:"Repository or skills.sh link"}),e.jsx(D,{id:"skill-repository","data-testid":"skill-repository-input",value:i,disabled:s,onChange:l=>{x(l.target.value),t.reset(),o.reset(),c([])},placeholder:"https://github.com/vercel-labs/agent-skills",autoFocus:!0}),e.jsx("p",{className:"text-xs text-outline",children:"GitHub repositories, owner/repo, skill-folder URLs and skills.sh links. Private repositories use gh login on the execution host (local or SSH), or ORC_GITHUB_TOKEN on the ORC server. Supporting files are included."}),e.jsx(b,{type:"submit","data-testid":"skill-discover",disabled:s||!i.trim(),children:t.isPending?"Discovering…":"Discover skills"})]}),t.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-outline",children:[t.data.skills.length," skills found · ",t.data.commit.slice(0,8)]}),!t.data.skills.length&&e.jsx("p",{role:"status",children:"No valid skills found in this source."}),e.jsx("div",{className:"max-h-[45vh] overflow-y-auto space-y-2",children:t.data.skills.map(l=>e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"remote-skill","data-skill-name":l.name,children:[e.jsx("input",{type:"checkbox","data-testid":"remote-skill-select",checked:h.includes(l.path),disabled:s||l.installed||!h.includes(l.path)&&h.length>=16,onChange:y=>c(y.target.checked?[...h,l.path]:h.filter(p=>p!==l.path))}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:l.name}),l.installed&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:"Already installed"}),e.jsx("span",{className:"block text-xs text-outline",children:l.description}),e.jsx("span",{className:"block text-xs text-outline",children:l.path||"Repository root"})]})]},l.path))}),t.data.issues.map(l=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[l.path,": ",l.error]},l.path))]}),(t.error||o.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(f=t.error||o.error)==null?void 0:f.message}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:s,onClick:a,children:"Cancel"}),e.jsx(b,{"data-testid":"skill-import-submit",disabled:s||!t.data||!h.length,onClick:()=>t.data&&o.mutate({source:i.trim(),commit:t.data.commit,paths:h}),children:o.isPending?"Importing…":`Import selected${h.length?` (${h.length})`:""}`})]})]})})}function we({name:a,scope:i,mutation:x}){var s,f;const h=K(),[c,n]=v.useState(""),t=F({queryKey:["skill-history",a,i],queryFn:()=>S.skills.history(a,i)}),o=I({mutationFn:l=>{if(!x)throw new Error("No active instruction edit");return S.skills.revert(a,{project_id:x.project_id,change_id:l,expected_change_id:x.id,reason:c.trim()})},onSuccess:()=>{h.invalidateQueries({queryKey:["skill"]}),h.invalidateQueries({queryKey:["skills"]}),h.invalidateQueries({queryKey:["skill-history"]}),n("")}});return!((s=t.data)!=null&&s.changes.length)&&!t.error?null:e.jsxs("section",{"data-testid":"skill-history-panel",className:"mb-5 space-y-3",children:[x&&e.jsxs("p",{"data-testid":"skill-mutated-label",className:"text-xs text-primary",children:["Mutated · ",x.project_id?"Project":"Global"," ·"," ",new Date(x.updated_at*1e3).toLocaleString()," · ",x.author]}),e.jsx("h3",{className:"text-sm font-medium",children:"Instruction history"}),e.jsx(D,{"data-testid":"skill-revert-reason","aria-label":"Reason for reverting instructions",value:c,onChange:l=>n(l.target.value),placeholder:"Reason for reverting..."}),t.error&&e.jsx("p",{role:"alert",children:t.error.message}),o.error&&e.jsx("p",{role:"alert",children:o.error.message}),(f=t.data)==null?void 0:f.changes.map(l=>e.jsxs("details",{"data-testid":"skill-history-change",className:"border-b border-outline-variant p-3",children:[e.jsxs("summary",{className:"text-xs cursor-pointer",children:[l.action," · ",l.reason," · ",l.author]}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"Before"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.previous_raw}),e.jsx("p",{className:"text-xs text-outline mt-2",children:"After"}),e.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:l.raw}),e.jsx(b,{"data-testid":"skill-revert-change",size:"sm",variant:"outline",disabled:!c.trim()||o.isPending,onClick:()=>o.mutate(l.id),children:"Restore instructions before this change"})]},l.id))]})}function Ce({name:a}){const i=K(),[x,h]=v.useState(!1),c=F({queryKey:["skill-origin",a],queryFn:()=>S.skills.origin(a)}),n=I({mutationFn:s=>S.skills.sync(a,s),onSuccess:async s=>{h(!1),s.applied&&await Promise.all([i.invalidateQueries({queryKey:["skill",a]}),i.invalidateQueries({queryKey:["skills"]}),i.invalidateQueries({queryKey:["skill-origin",a]})])}});if(c.error)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:c.error.message});if(!c.data)return null;const t=n.data,o=t&&!t.applied&&t.conflicts.length>0;return e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Imported from"," ",e.jsx("a",{className:"text-primary underline",href:`https://github.com/${c.data.repository}/tree/${encodeURIComponent(c.data.ref==="HEAD"?c.data.commit:c.data.ref)}/${c.data.path}`,target:"_blank",rel:"noreferrer",children:c.data.repository})," ","· ",c.data.commit.slice(0,8)]}),e.jsx(b,{"data-testid":"skill-sync",variant:"outline",size:"sm",disabled:n.isPending,onClick:()=>n.mutate({}),children:n.isPending?"Syncing…":"Sync from GitHub"}),(t==null?void 0:t.applied)&&e.jsx("p",{role:"status","data-testid":"skill-sync-status",className:"text-xs",children:t.changed.length?`Synced ${t.changed.length} files. Local edits preserved outside confirmed conflicts.`:"Up to date. Local edits preserved."}),o&&e.jsxs("div",{"data-testid":"skill-sync-conflicts",className:"space-y-2",children:[e.jsx("p",{role:"alert",className:"text-sm",children:"Sync paused. Both you and GitHub changed these files:"}),e.jsx("ul",{className:"text-xs space-y-1",children:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsx(b,{"data-testid":"skill-sync-review-override",variant:"outline",size:"sm",onClick:()=>h(!0),children:"Review override"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n.error.message}),e.jsx(E,{open:x,onOpenChange:s=>!n.isPending&&h(s),children:e.jsxs($,{children:[e.jsx(A,{children:e.jsx(T,{children:"Replace conflicting local edits?"})}),e.jsxs("p",{className:"text-sm",children:["GitHub's version at ",t==null?void 0:t.commit.slice(0,8)," will replace or remove these files. Your other local edits will be kept. The current skill folder will be backed up."]}),e.jsx("ul",{className:"text-sm space-y-1",children:t==null?void 0:t.conflicts.map(s=>e.jsx("li",{children:s},s))}),e.jsxs(H,{children:[e.jsx(b,{variant:"ghost",disabled:n.isPending,onClick:()=>h(!1),children:"Keep local edits"}),e.jsx(b,{"data-testid":"skill-sync-confirm-override",disabled:n.isPending,onClick:()=>t&&n.mutate({override:!0,expectedCommit:t.commit,expectedRevision:t.revision}),children:n.isPending?"Syncing…":"Replace listed files"})]})]})})]})}function Le(a){return F({queryKey:["skills",a],queryFn:()=>S.skills.list(a)})}function Ie(){return F({queryKey:["skill-visibility"],queryFn:()=>S.skills.visibility()})}function Ke(){const a=K();return I({mutationFn:i=>S.skills.setVisibility(i),onSuccess:i=>{a.setQueryData(["skill-visibility"],i),a.invalidateQueries({queryKey:["skills"]})}})}function Z(a,i,x={}){return F({queryKey:["skill",a,i,x],queryFn:()=>S.skills.get(a,i,x),enabled:!!a})}function De(){const a=K();return I({mutationFn:i=>S.skills.create(i),onSuccess:()=>a.invalidateQueries({queryKey:["skills"]})})}const Fe=[{value:"all",label:"All"},{value:"builtin",label:"Built-in"},{value:"user",label:"User"}],se={builtin:"text-muted-foreground",user:"text-muted-foreground"};function Te({projectId:a}){var B,U;const i=ye(a),x=i==="all"||i==="unassigned"?{scope:"global"}:{project_id:i},[h,c]=O("skillQuery",""),[n,t]=v.useState(h),[o,s]=O("source","all",["all","builtin","user"]);v.useEffect(()=>t(h),[h]);const{selectedId:f,openDetail:l,closeDetail:y}=le("/skills","skillName"),[p,w]=v.useState(!1),[g,k]=v.useState(!1),[m,N]=v.useState(!1),r=Ie(),d=Ke(),{data:j,isLoading:C,error:z,refetch:ae}=Le({...x,q:h||void 0,source:o==="all"?void 0:o,include_hidden:!0}),Q=j==null?void 0:j.skills;return z?e.jsx(J,{message:z.message,onRetry:()=>ae()}):e.jsxs("div",{children:[e.jsx(ne,{title:"Skills",meta:`${(Q??[]).length} skills`,action:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(b,{"data-testid":"import-skill-button",size:"sm",variant:"outline",onClick:()=>k(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from GitHub"]}),e.jsxs(b,{"data-testid":"import-local-skills-button",size:"sm",variant:"outline",onClick:()=>N(!0),children:[e.jsx(Y,{size:12,className:"mr-1"})," Import from agents"]}),e.jsxs(b,{"data-testid":"new-skill-button",size:"sm",onClick:()=>w(!0),className:"font-label text-sm ",children:[e.jsx(re,{size:12,className:"mr-1"})," New skill"]})]})}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:["Skill folders follow the"," ",e.jsx("a",{className:"text-primary underline",href:"https://agentskills.io/specification",target:"_blank",rel:"noreferrer",children:"Agent Skills specification"}),"."]}),e.jsx("p",{className:"mb-4 text-sm leading-relaxed text-muted-foreground",children:"Built-in visibility applies to agent discovery across this installation. Hidden skills remain readable by name and available to flows. Authored overrides stay visible."}),(r.error||d.error)&&e.jsx("p",{role:"alert",className:"text-destructive text-xs mb-2",children:(B=r.error||d.error)==null?void 0:B.message}),(U=j==null?void 0:j.broken)==null?void 0:U.map(u=>e.jsxs("p",{role:"alert",className:"text-destructive text-xs mb-2",children:[u.path,": ",u.error]},u.path)),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex shrink-0 flex-wrap gap-1.5",children:Fe.map(u=>e.jsx("button",{type:"button",onClick:()=>s(u.value),"data-testid":`skill-source-${u.value}`,"aria-pressed":o===u.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${o===u.value?"bg-surface-highest text-on-surface border-transparent":"bg-transparent border-transparent text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:u.label},u.value))}),e.jsxs("div",{className:"relative min-w-[160px] flex-1",children:[e.jsx(oe,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(D,{"aria-label":"Search skills",value:n,onChange:u=>t(u.target.value),onKeyDown:u=>u.key==="Enter"&&c(u.currentTarget.value),placeholder:"Search skills...",className:"pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground"})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>c(n),className:"font-label text-sm ",children:"Search"})]}),C?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((u,L)=>e.jsx(ee,{className:"h-10 w-full bg-surface-highest"},L))}):(Q??[]).length===0?e.jsx(ce,{message:h?"No skills match your search":"No skills found"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(de,{children:[e.jsx(ue,{children:e.jsxs(G,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Name"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(R,{className:"font-label text-sm text-muted-foreground w-24",children:"Source"}),e.jsx(R,{className:"text-xs text-muted-foreground",children:"Agent discovery"})]})}),e.jsx(me,{children:(Q??[]).map(u=>e.jsxs(G,{"data-testid":"skill-row","data-skill-name":u.name,className:"border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer",onClick:()=>l(u.name),children:[e.jsxs(_,{className:"font-body text-sm font-medium text-on-surface",children:[e.jsx("button",{type:"button",className:"min-h-11 text-left hover:text-primary",onClick:L=>{L.stopPropagation(),l(u.name)},children:u.name}),u.mutation&&e.jsx("span",{className:"ml-2 text-primary text-xs",children:"Mutated"})]}),e.jsx(_,{className:"font-body text-sm text-muted-foreground max-w-md truncate",children:u.description||"—"}),e.jsx(_,{children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[u.source]}`,children:u.source})}),e.jsx(_,{onClick:L=>L.stopPropagation(),children:u.source==="builtin"&&!u.mutation?e.jsx("button",{type:"button",role:"switch","aria-label":`${u.name} visible to agents`,"aria-checked":!u.discovery_hidden,"data-testid":`skill-visibility-${u.name}`,disabled:!r.data||d.isPending,className:"text-xs text-primary disabled:opacity-50",onClick:()=>{var V;const L=new Set(((V=r.data)==null?void 0:V.hidden_builtins)??[]);L.has(u.name)?L.delete(u.name):L.add(u.name),d.mutate([...L])},children:u.discovery_hidden?"Hidden — show":"Visible — hide"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:u.mutation?"Visible (override)":"Visible"})})]},u.name))})]})}),e.jsx(qe,{scope:x,skillName:f,open:!!f,onClose:y},f),p&&e.jsx(Re,{open:p,onClose:()=>w(!1)}),g&&e.jsx(Se,{onClose:()=>k(!1)}),m&&e.jsx(Ne,{onClose:()=>N(!1)})]})}function qe({skillName:a,scope:i,open:x,onClose:h}){const{data:c,isLoading:n,error:t,refetch:o}=Z(a,void 0,i),s=c,[f,l]=O("skillFile","SKILL.md"),y=Z(a,f??"SKILL.md",i),p=y.data,w=K(),[g,k]=v.useState(!1),m=`skill:${i.project_id??"global"}:${a}:${f??"SKILL.md"}`;function N(d){return(d??"SKILL.md")===(f??"SKILL.md")?!0:W(m)?(l(d??"SKILL.md"),!0):!1}const r=s?e.jsx(ke,{files:["SKILL.md",...(s.files??[]).map(d=>d.name)],selected:f??"SKILL.md",onSelect:d=>N(d==="SKILL.md"?void 0:d),testId:"skill-file",entryTestId:"skill-show-entry"}):null;return e.jsx(xe,{open:x,onOpenChange:d=>!d&&W(m)&&h(),children:e.jsxs(he,{className:"w-screen max-w-full sm:w-[1120px] sm:max-w-[96vw]",children:[e.jsxs(pe,{children:[e.jsx(ge,{children:(s==null?void 0:s.name)??"Skill Details"}),(s==null?void 0:s.description)&&e.jsx("p",{className:"font-body text-sm text-muted-foreground mt-1",children:s.description})]}),e.jsx(fe,{children:e.jsxs(e.Fragment,{children:[a&&s&&e.jsx(we,{name:a,scope:i,mutation:s.mutation}),a&&s&&e.jsx(Ce,{name:a}),t?e.jsx(J,{message:t.message,onRetry:()=>void o()}):n||!s?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((d,j)=>e.jsx(ee,{className:"h-8 w-full bg-surface-highest"},j))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(M,{label:"Source",children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${se[s.source]}`,children:s.source})}),e.jsx(M,{label:"Path",children:e.jsx("code",{className:"font-mono text-sm text-muted-foreground break-all",children:s.path})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:f??"SKILL.md"}),e.jsxs("div",{className:"overflow-hidden",children:[(p==null?void 0:p.encoding)==="base64"&&e.jsx("div",{className:"p-3",children:r}),y.error?e.jsx("p",{role:"alert",children:y.error.message}):y.isLoading?e.jsx("p",{children:"Loading..."}):(p==null?void 0:p.encoding)==="base64"?e.jsx(te,{path:f??"SKILL.md",value:(p==null?void 0:p.content)??"",readOnly:!0,hidePreview:!0,height:400,testId:"skill-file-content"}):e.jsx(be,{documentId:m,expanded:g,onExpandedChange:k,navigation:r,path:f??"SKILL.md",content:(p==null?void 0:p.content)??"",testId:"skill-file-content",onSave:s.source==="user"&&(p==null?void 0:p.encoding)==="utf8"?async(d,j)=>{const C=f??"SKILL.md";return s.mutation&&C==="SKILL.md"?await S.skills.updateInstructions(s.name,{project_id:i.project_id??null,content:d,expected_content:j,reason:"Manual instruction edit",author:"human"}):await S.skills.editFile(s.name,{path:C,content:d,expectedContent:j}),await w.invalidateQueries({queryKey:["skill",s.name]}),await w.invalidateQueries({queryKey:["skills"]}),await w.invalidateQueries({queryKey:["skill-history",s.name]}),d}:void 0},m),(p==null?void 0:p.encoding)==="base64"&&e.jsx("p",{className:"p-4 text-xs text-muted-foreground",children:"Binary asset shown as base64 (read-only)."})]})]})]})]})})]})})}function Re({open:a,onClose:i}){var N;const[x,h]=v.useState(""),[c,n]=v.useState(""),t=De(),[o,s]=v.useState([]),[f,l]=v.useState(),[y,p]=v.useState(!1),w=!!(x||c||o.length);v.useEffect(()=>{if(!w)return;function r(d){d.preventDefault(),d.returnValue=""}return window.addEventListener("beforeunload",r),()=>window.removeEventListener("beforeunload",r)},[w]);function g(){t.isPending||y||(!w||window.confirm("Discard this unsaved skill?"))&&i()}async function k(r){if(r!=null&&r.length){p(!0),l(void 0);try{const d=(await ve(r)).map(C=>({...C,encoding:C.encoding??"utf8",id:crypto.randomUUID()})),j=d.find(C=>C.path==="SKILL.md");if(!j)throw new Error("Choose a skill folder containing SKILL.md");if(j.encoding!=="utf8")throw new Error("SKILL.md must be UTF-8 text");n(j.content),h(r[0].webkitRelativePath.split("/")[0]),s(d.filter(C=>C!==j))}catch(d){l(d.message)}finally{p(!1)}}}const m=()=>{!x.trim()||!c.trim()||t.isPending||y||o.some(r=>!r.path.trim())||t.mutate({name:x.trim(),content:c.trim(),files:o.map(({path:r,content:d,encoding:j})=>({path:r,content:d,encoding:j}))},{onSuccess:i})};return e.jsx(E,{open:a,onOpenChange:r=>!r&&g(),children:e.jsxs($,{className:"bg-surface border-outline-variant w-[calc(100%_-_1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto",children:[e.jsx(A,{children:e.jsx(T,{className:"font-headline text-base text-on-surface",children:"New skill"})}),e.jsxs("form",{onSubmit:r=>{r.preventDefault(),m()},className:"space-y-3 mt-2",children:[e.jsx(P,{htmlFor:"skill-folder-input",children:"Import skill folder"}),e.jsx(D,{id:"skill-folder-input","data-testid":"skill-folder-input",type:"file",multiple:!0,webkitdirectory:"",onChange:r=>void k(r.target.files)}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{className:"font-label text-sm text-muted-foreground",children:"Name *"}),e.jsx(D,{"aria-label":"Name","data-testid":"skill-name-input",value:x,onChange:r=>h(r.target.value),placeholder:"my-skill",className:"bg-background text-on-surface font-body text-sm",autoFocus:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(P,{className:"font-label text-sm text-muted-foreground",children:"SKILL.md *"}),e.jsx(je,{testId:"skill-content-input",path:"SKILL.md",value:c,onChange:n,onSave:m})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(b,{"data-testid":"skill-add-file",type:"button",variant:"outline",onClick:()=>s([...o,{id:crypto.randomUUID(),path:"",content:"",encoding:"utf8"}]),children:"Add file"}),o.map(r=>e.jsxs("div",{"data-testid":"skill-supporting-file",className:"space-y-2 border border-outline-variant p-3",children:[e.jsx(D,{"data-testid":"skill-file-path-input","aria-label":"File path",placeholder:"references/guide.md or scripts/check.py",value:r.path,onChange:d=>s(o.map(j=>j.id===r.id?{...j,path:d.target.value}:j))}),e.jsx(te,{testId:"skill-file-content-input",path:r.path||"supporting.txt",readOnly:r.encoding==="base64",label:`Content of ${r.path||"supporting file"}`,value:r.content,height:180,onChange:d=>s(o.map(j=>j.id===r.id?{...j,content:d}:j))}),r.encoding==="base64"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Binary asset (base64)"}),e.jsx(b,{type:"button",variant:"ghost",onClick:()=>s(o.filter(d=>d.id!==r.id)),children:"Remove file"})]},r.id))]}),(f||t.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f??((N=t.error)==null?void 0:N.message)}),e.jsxs(H,{children:[e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:g,className:"font-label text-sm text-muted-foreground",children:"Cancel"}),e.jsx(b,{"data-testid":"skill-submit",type:"submit",size:"sm",disabled:y||t.isPending||!x.trim()||!c.trim()||o.some(r=>!r.path.trim()),className:"font-label text-sm ",children:t.isPending?"Creating...":"Create"})]})]})]})})}export{Te as default};
@@ -1,10 +1,10 @@
1
- import{c as Fn,aG as x,aH as g,aI as He,aJ as Re,aK as ce,aL as ve,aM as Et,aN as Tt,aO as pe,aP as N,aQ as Wn,aR as Nn,aS as Ge,aT as qn,aU as je,aV as It,aW as Je,aX as J,aY as H,aZ as Fe,a_ as We,a$ as $n,b0 as Ke,b1 as Vn,b2 as zn,b3 as Pt,b4 as Ot,b5 as Ft,b6 as M,b7 as Un,b8 as Hn,b9 as oe,ba as Wt,bb as T,bc as Gn,bd as S,be as jn,bf as Nt,bg as Jn,bh as f,bi as Kn,bj as _n,bk as Qn,bl as Yn,bm as Zn,bn as Xn,bo as er,bp as tr,bq as nr,br as rr,bs as or,bt as ir,bu as sr,bv as lr,bw as cr,bx as ar,by as qt,bz as ur,bA as hr,bB as fr,bC as dr,bD as mr,r as v,bE as ne,i as Ee,bF as ct,bG as gr,j as E,aB as pr,ab as yr}from"./index-CRsafixF.js";/**
1
+ import{c as Fn,aH as x,aI as g,aJ as Ue,aK as Re,aL as ce,aM as ve,aN as Et,aO as Tt,aP as pe,aQ as N,aR as Wn,aS as Nn,aT as Ge,aU as qn,aV as je,aW as It,aX as Je,aY as J,aZ as U,a_ as Fe,a$ as We,b0 as $n,b1 as Ke,b2 as Vn,b3 as zn,b4 as Pt,b5 as Ot,b6 as Ft,b7 as M,b8 as Hn,b9 as Un,ba as oe,bb as Wt,bc as T,bd as Gn,be as S,bf as jn,bg as Nt,bh as Jn,bi as f,bj as Kn,bk as _n,bl as Qn,bm as Yn,bn as Zn,bo as Xn,bp as er,bq as tr,br as nr,bs as rr,bt as or,bu as ir,bv as sr,bw as lr,bx as cr,by as ar,bz as qt,bA as ur,bB as hr,bC as fr,bD as dr,bE as mr,r as v,bF as ne,i as Ee,bG as ct,bH as gr,j as E,aC as pr,ab as yr}from"./index-BqQDBYwx.js";/**
2
2
  * @license lucide-react v1.27.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const xr=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],br=Fn("text-wrap",xr),kr=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Qe(t.state,n.from);return r.line?Sr(t):r.block?vr(t):!1};function _e(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=t(e,n);return o?(r(n.update(o)),!0):!1}}const Sr=_e(Lr,0),Cr=_e($t,0),vr=_e((t,e)=>$t(t,e,Ar(e)),0);function Qe(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const re=50;function Mr(t,{open:e,close:n},r,o){let i=t.sliceDoc(r-re,r),s=t.sliceDoc(o,o+re),l=/\s*$/.exec(i)[0].length,c=/^\s*/.exec(s)[0].length,a=i.length-l;if(i.slice(a-e.length,a)==e&&s.slice(c,c+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:o+c,margin:c&&1}};let u,h;o-r<=2*re?u=h=t.sliceDoc(r,o):(u=t.sliceDoc(r,r+re),h=t.sliceDoc(o-re,o));let d=/^\s*/.exec(u)[0].length,y=/\s*$/.exec(h)[0].length,m=h.length-y-n.length;return u.slice(d,d+e.length)==e&&h.slice(m,m+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:o-y-n.length,margin:/\s/.test(h.charAt(m-1))?1:0}}:null}function Ar(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),o=n.to<=r.to?r:t.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>r.from?e[i].to=o.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return e}function $t(t,e,n=e.selection.ranges){let r=n.map(i=>Qe(e,i.from).block);if(!r.every(i=>i))return null;let o=n.map((i,s)=>Mr(e,r[s],i.from,i.to));if(t!=2&&!o.every(i=>i))return{changes:e.changes(n.map((i,s)=>o[s]?[]:[{from:i.from,insert:r[s].open+" "},{from:i.to,insert:" "+r[s].close}]))};if(t!=1&&o.some(i=>i)){let i=[];for(let s=0,l;s<o.length;s++)if(l=o[s]){let c=r[s],{open:a,close:u}=l;i.push({from:a.pos-c.open.length,to:a.pos+a.margin},{from:u.pos-u.margin,to:u.pos+c.close.length})}return{changes:i}}return null}function Lr(t,e,n=e.selection.ranges){let r=[],o=-1;e:for(let{from:i,to:s}of n){let l=r.length,c=1e9,a;for(let u=i;u<=s;){let h=e.doc.lineAt(u);if(a==null&&(a=Qe(e,h.from).line,!a))continue e;if(h.from>o&&(i==s||s>h.from)){o=h.from;let d=/^\s*/.exec(h.text)[0].length,y=d==h.length,m=h.text.slice(d,d+a.length)==a?d:-1;d<h.text.length&&d<c&&(c=d),r.push({line:h,comment:m,token:a,indent:d,empty:y,single:!1})}u=h.to+1}if(c<1e9)for(let u=l;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=c);r.length==l+1&&(r[l].single=!0)}if(t!=2&&r.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:c,indent:a,empty:u,single:h}of r)(h||!u)&&i.push({from:l.from+a,insert:c+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&r.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:l,token:c}of r)if(l>=0){let a=s.from+l,u=a+c.length;s.text[u-s.from]==" "&&u++,i.push({from:a,to:u})}return{changes:i}}return null}const Ne=Ge.define(),Br=Ge.define(),Dr=ce.define(),Vt=ce.define({combine(t){return ve(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,o)=>e(r,o)||n(r,o)})}}),zt=He.define({create(){return W.empty},update(t,e){let n=e.state.facet(Vt),r=e.annotation(Ne);if(r){let c=L.fromTransaction(e,r.selection),a=r.side,u=a==0?t.undone:t.done;return c?u=ye(u,u.length,n.minDepth,c):u=Gt(u,e.startState.selection),new W(a==0?r.rest:u,a==0?u:r.rest)}let o=e.annotation(Br);if((o=="full"||o=="before")&&(t=t.isolate()),e.annotation(Re.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=L.fromTransaction(e),s=e.annotation(Re.time),l=e.annotation(Re.userEvent);return i?t=t.addChanges(i,s,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,s,l,n.newGroupDelay)),(o=="full"||o=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new W(t.done.map(L.fromJSON),t.undone.map(L.fromJSON))}});function wr(t={}){return[zt,Vt.of(t),x.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?Ut:e.inputType=="historyRedo"?qe:null;return r?(e.preventDefault(),r(n)):!1}})]}function Me(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let o=n.field(zt,!1);if(!o)return!1;let i=o.pop(t,n,e);return i?(r(i),!0):!1}}const Ut=Me(0,!1),qe=Me(1,!1),Rr=Me(0,!0),Er=Me(1,!0);class L{constructor(e,n,r,o,i){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new L(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new L(e.changes&&Wn.fromJSON(e.changes),[],e.mapped&&Nn.fromJSON(e.mapped),e.startSelection&&g.fromJSON(e.startSelection),e.selectionsAfter.map(g.fromJSON))}static fromTransaction(e,n){let r=I;for(let o of e.startState.facet(Dr)){let i=o(e);i.length&&(r=r.concat(i))}return!r.length&&e.changes.empty?null:new L(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,I)}static selection(e){return new L(void 0,I,void 0,void 0,e)}}function ye(t,e,n,r){let o=e+1>n+20?e-n-1:0,i=t.slice(o,e);return i.push(r),i}function Tr(t,e){let n=[],r=!1;return t.iterChangedRanges((o,i)=>n.push(o,i)),e.iterChangedRanges((o,i,s,l)=>{for(let c=0;c<n.length;){let a=n[c++],u=n[c++];l>=a&&s<=u&&(r=!0)}}),r}function Ir(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function Ht(t,e){return t.length?e.length?t.concat(e):t:e}const I=[],Pr=200;function Gt(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Pr));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),ye(t,t.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([e])]}function Or(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Te(t,e){if(!t.length)return t;let n=t.length,r=I;for(;n;){let o=Fr(t[n-1],e,r);if(o.changes&&!o.changes.empty||o.effects.length){let i=t.slice(0,n);return i[n-1]=o,i}else e=o.mapped,n--,r=o.selectionsAfter}return r.length?[L.selection(r)]:I}function Fr(t,e,n){let r=Ht(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):I,n);if(!t.changes)return L.selection(r);let o=t.changes.map(e),i=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(i):i;return new L(o,N.mapEffects(t.effects,e),s,t.startSelection.map(i),r)}const Wr=/^(input\.type|delete)($|\.)/;class W{constructor(e,n,r=0,o=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=o}isolate(){return this.prevTime?new W(this.done,this.undone):this}addChanges(e,n,r,o,i){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||Wr.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,Tr(l.changes,e.changes))||r=="input.type.compose")?s=ye(s,s.length-1,o.minDepth,new L(e.changes.compose(l.changes),Ht(N.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,I)):s=ye(s,s.length,o.minDepth,e),new W(s,I,n,r)}addSelection(e,n,r,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:I;return i.length>0&&n-this.prevTime<o&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Ir(i[i.length-1],e)?this:new W(Gt(this.done,e),this.undone,n,r)}addMapping(e){return new W(Te(this.done,e),Te(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(r&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Ne.of({side:e,rest:Or(o),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let l=o.length==1?I:o.slice(0,o.length-1);return i.mapped&&(l=Te(l,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Ne.of({side:e,rest:l,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}W.empty=new W(I,I);const Nr=[{key:"Mod-z",run:Ut,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:qe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:qe,preventDefault:!0},{key:"Mod-u",run:Rr,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Er,preventDefault:!0}];function Q(t,e){return g.create(t.ranges.map(e),t.mainIndex)}function O(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function F({state:t,dispatch:e},n){let r=Q(t.selection,n);return r.eq(t.selection,!0)?!1:(e(O(t,r)),!0)}function Ae(t,e){return g.cursor(e?t.to:t.from)}function jt(t,e){return F(t,n=>n.empty?t.moveByChar(n,e):Ae(n,e))}function A(t){return t.textDirectionAt(t.state.selection.main.head)==qn.LTR}const Jt=t=>jt(t,!A(t)),Kt=t=>jt(t,A(t));function _t(t,e){return F(t,n=>n.empty?t.moveByGroup(n,e):Ae(n,e))}const qr=t=>_t(t,!A(t)),$r=t=>_t(t,A(t));function Vr(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Le(t,e,n){let r=Je(t).resolveInner(e.head),o=n?Fe.closedBy:Fe.openedBy;for(let c=e.head;;){let a=n?r.childAfter(c):r.childBefore(c);if(!a)break;Vr(t,a,o)?r=a:c=n?a.to:a.from}let i=r.type.prop(o),s,l;return i&&(s=n?J(t,r.from,1):J(t,r.to,-1))&&s.matched?l=n?s.end.to:s.end.from:l=n?r.to:r.from,g.cursor(l,n?-1:1)}const zr=t=>F(t,e=>Le(t.state,e,!A(t))),Ur=t=>F(t,e=>Le(t.state,e,A(t)));function Qt(t,e){return F(t,n=>{if(!n.empty)return Ae(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const Yt=t=>Qt(t,!1),Zt=t=>Qt(t,!0);function Xt(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,o;if(e){for(let i of t.state.facet(x.scrollMargins)){let s=i(t);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}o=t.scrollDOM.clientHeight-n-r}else o=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,o-5)}}function en(t,e){let n=Xt(t),{state:r}=t,o=Q(r.selection,s=>s.empty?t.moveVertically(s,e,n.height):Ae(s,e));if(o.eq(r.selection))return!1;let i;if(n.selfScroll){let s=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),c=l.top+n.marginTop,a=l.bottom-n.marginBottom;s&&s.top>c&&s.bottom<a&&(i=x.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-c}))}return t.dispatch(O(r,o),{effects:i}),!0}const at=t=>en(t,!1),$e=t=>en(t,!0);function V(t,e,n){let r=t.lineBlockAt(e.head),o=t.moveToLineBoundary(e,n);if(o.head==e.head&&o.head!=(n?r.to:r.from)&&(o=t.moveToLineBoundary(e,n,!1)),!n&&o.head==r.from&&r.length){let i=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;i&&e.head!=r.from+i&&(o=g.cursor(r.from+i))}return o}const Hr=t=>F(t,e=>V(t,e,!0)),Gr=t=>F(t,e=>V(t,e,!1)),jr=t=>F(t,e=>V(t,e,!A(t))),Jr=t=>F(t,e=>V(t,e,A(t))),Kr=t=>F(t,e=>t.moveToLineBoundary(e,!1,!1)),_r=t=>F(t,e=>t.moveToLineBoundary(e,!0,!1));function Qr(t,e,n){let r=!1,o=Q(t.selection,i=>{let s=J(t,i.head,-1)||J(t,i.head,1)||i.head>0&&J(t,i.head-1,1)||i.head<t.doc.length&&J(t,i.head+1,-1);if(!s||!s.end)return i;r=!0;let l=s.start.from==i.head?s.end.to:s.end.from;return g.cursor(l)});return r?(e(O(t,o)),!0):!1}const Yr=({state:t,dispatch:e})=>Qr(t,e);function P(t,e,n){let r=Q(t.state.selection,o=>{o.undirectional&&o.head>=o.anchor!=e&&(o=g.range(o.head,o.anchor));let i=n(o);return g.range(o.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(O(t.state,r)),!0)}function tn(t,e){return P(t,e,n=>t.moveByChar(n,e))}const nn=t=>tn(t,!A(t)),rn=t=>tn(t,A(t));function on(t,e){return P(t,e,n=>t.moveByGroup(n,e))}const Zr=t=>on(t,!A(t)),Xr=t=>on(t,A(t)),eo=t=>{let e=!A(t);return P(t,e,n=>Le(t.state,n,e))},to=t=>{let e=A(t);return P(t,e,n=>Le(t.state,n,e))};function sn(t,e){return P(t,e,n=>t.moveVertically(n,e))}const ln=t=>sn(t,!1),cn=t=>sn(t,!0);function an(t,e){return P(t,e,n=>t.moveVertically(n,e,Xt(t).height))}const ut=t=>an(t,!1),ht=t=>an(t,!0),no=t=>P(t,!0,e=>V(t,e,!0)),ro=t=>P(t,!1,e=>V(t,e,!1)),oo=t=>{let e=!A(t);return P(t,e,n=>V(t,n,e))},io=t=>{let e=A(t);return P(t,e,n=>V(t,n,e))},so=t=>P(t,!1,e=>g.cursor(t.lineBlockAt(e.head).from)),lo=t=>P(t,!0,e=>g.cursor(t.lineBlockAt(e.head).to)),ft=({state:t,dispatch:e})=>(e(O(t,{anchor:0})),!0),dt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.doc.length})),!0),mt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.selection.main.anchor,head:0})),!0),gt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),co=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ao=({state:t,dispatch:e})=>{let n=Be(t).map(({from:r,to:o})=>g.undirectionalRange(r,Math.min(o+1,t.doc.length)));return e(t.update({selection:g.create(n),userEvent:"select"})),!0},uo=({state:t,dispatch:e})=>{let n=Q(t.selection,r=>{let o=Je(t),i=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:l}=s;if((l.from<r.from&&l.to>=r.to||l.to>r.to&&l.from<=r.from)&&s.next)return g.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(O(t,n)),!0)};function un(t,e){let{state:n}=t,r=n.selection,o=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(e?s.to<t.state.doc.length:s.from>0)for(let l=i;;){let c=t.moveVertically(l,e);if(c.head<s.from||c.head>s.to){o.some(a=>a.head==c.head)||o.push(c);break}else{if(c.head==l.head)break;l=c}}}return o.length==r.ranges.length?!1:(t.dispatch(O(n,g.create(o,o.length-1))),!0)}const ho=t=>un(t,!1),fo=t=>un(t,!0),mo=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=g.create([n.main]):n.main.empty||(r=g.create([g.cursor(n.main.head)])),r?(e(O(t,r)),!0):!1};function ae(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,o=r.changeByRange(i=>{let{from:s,to:l}=i;if(s==l){let c=e(i);c<s?(n="delete.backward",c=he(t,c,!1)):c>s&&(n="delete.forward",c=he(t,c,!0)),s=Math.min(s,c),l=Math.max(l,c)}else s=he(t,s,!1),l=he(t,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:g.cursor(s,s<i.head?-1:1)}});return o.changes.empty?!1:(t.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?x.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function he(t,e,n){if(t instanceof x)for(let r of t.state.facet(x.atomicRanges).map(o=>o(t)))r.between(e,e,(o,i)=>{o<e&&i>e&&(e=n?i:o)});return e}const hn=(t,e,n)=>ae(t,r=>{let o=r.from,{state:i}=t,s=i.doc.lineAt(o),l,c;if(n&&!e&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(l=s.text.slice(0,o-s.from))){if(l[l.length-1]==" ")return o-1;let a=je(l,i.tabSize),u=a%We(i)||We(i);for(let h=0;h<u&&l[l.length-1-h]==" ";h++)o--;c=o}else c=H(s.text,o-s.from,e,e)+s.from,c==o&&s.number!=(e?i.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(c-s.from,o-s.from))&&(c=H(s.text,c-s.from,!1,!1)+s.from);return c}),Ve=t=>hn(t,!1,!0),fn=t=>hn(t,!0,!1),dn=(t,e)=>ae(t,n=>{let r=n.head,{state:o}=t,i=o.doc.lineAt(r),s=o.charCategorizer(r);for(let l=null;;){if(r==(e?i.to:i.from)){r==n.head&&i.number!=(e?o.doc.lines:1)&&(r+=e?1:-1);break}let c=H(i.text,r-i.from,e)+i.from,a=i.text.slice(Math.min(r,c)-i.from,Math.max(r,c)-i.from),u=s(a);if(l!=null&&u!=l)break;(a!=" "||r!=n.head)&&(l=u),r=c}return r}),mn=t=>dn(t,!1),go=t=>dn(t,!0),po=t=>ae(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),yo=t=>ae(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),xo=t=>ae(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),bo=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:It.of(["",""])},range:g.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},ko=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let o=r.from,i=t.doc.lineAt(o),s=o==i.from?o-1:H(i.text,o-i.from,!1)+i.from,l=o==i.to?o+1:H(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:l,insert:t.doc.slice(o,l).append(t.doc.slice(s,o))},range:g.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Be(t){let e=[],n=-1;for(let r of t.selection.ranges){let o=t.doc.lineAt(r.from),i=t.doc.lineAt(r.to);if(!r.empty&&r.to==i.from&&(i=t.doc.lineAt(r.to-1)),n>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(r)}else e.push({from:o.from,to:i.to,ranges:[r]});n=i.number+1}return e}function gn(t,e,n){if(t.readOnly)return!1;let r=[],o=[];for(let i of Be(t)){if(n?i.to==t.doc.length:i.from==0)continue;let s=t.doc.lineAt(n?i.to+1:i.from-1),l=s.length+1;if(n){r.push({from:i.to,to:s.to},{from:i.from,insert:s.text+t.lineBreak});for(let c of i.ranges)o.push(g.range(Math.min(t.doc.length,c.anchor+l),Math.min(t.doc.length,c.head+l)))}else{r.push({from:s.from,to:i.from},{from:i.to,insert:t.lineBreak+s.text});for(let c of i.ranges)o.push(g.range(c.anchor-l,c.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:g.create(o,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const So=({state:t,dispatch:e})=>gn(t,e,!1),Co=({state:t,dispatch:e})=>gn(t,e,!0);function pn(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of Be(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let o=t.changes(r);return e(t.update({changes:o,selection:t.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vo=({state:t,dispatch:e})=>pn(t,e,!1),Mo=({state:t,dispatch:e})=>pn(t,e,!0),Ao=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Be(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),r=Q(e.selection,o=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(o.head),l=t.coordsAtPos(o.head,o.assoc||1);l&&(i=s.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(o,!0,i)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Lo(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Je(t).resolveInner(e),r=n.childBefore(e),o=n.childAfter(e),i;return r&&o&&r.to<=e&&o.from>=e&&(i=r.type.prop(Fe.closedBy))&&i.indexOf(o.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(r.to,o.from))?{from:r.to,to:o.from}:null}const pt=yn(!1),Bo=yn(!0);function yn(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(o=>{let{from:i,to:s}=o,l=e.doc.lineAt(i),c=!t&&i==s&&Lo(e,i);t&&(i=s=(s<=l.to?l:e.doc.lineAt(s)).to);let a=new Et(e,{simulateBreak:i,simulateDoubleBreak:!!c}),u=Tt(a,i);for(u==null&&(u=je(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));s<l.to&&/\s/.test(l.text[s-l.from]);)s++;c?{from:i,to:s}=c:i>l.from&&i<l.from+100&&!/\S/.test(l.text.slice(0,i))&&(i=l.from);let h=["",pe(e,u)];return c&&h.push(pe(e,a.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:It.of(h)},range:g.cursor(i+1+h[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ye(t,e){let n=-1;return t.changeByRange(r=>{let o=[];for(let s=r.from;s<=r.to;){let l=t.doc.lineAt(s);l.number>n&&(r.empty||r.to>l.from)&&(e(l,o,r),n=l.number),s=l.to+1}let i=t.changes(o);return{changes:o,range:g.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}const Do=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Et(t,{overrideIndentation:i=>{let s=n[i];return s??-1}}),o=Ye(t,(i,s,l)=>{let c=Tt(r,i.from);if(c==null)return;/\S/.test(i.text)||(c=0);let a=/^\s*/.exec(i.text)[0],u=pe(t,c);(a!=u||l.from<i.from+a.length)&&(n[i.from]=c,s.push({from:i.from,to:i.from+a.length,insert:u}))});return o.changes.empty||e(t.update(o,{userEvent:"indent"})),!0},xn=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Ye(t,(n,r)=>{r.push({from:n.from,insert:t.facet($n)})}),{userEvent:"input.indent"})),!0),bn=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Ye(t,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let i=je(o,t.tabSize),s=0,l=pe(t,Math.max(0,i-We(t)));for(;s<o.length&&s<l.length&&o.charCodeAt(s)==l.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+o.length,insert:l.slice(s)})}),{userEvent:"delete.dedent"})),!0),wo=t=>(t.setTabFocusMode(),!0),Ro=[{key:"Ctrl-b",run:Jt,shift:nn,preventDefault:!0},{key:"Ctrl-f",run:Kt,shift:rn},{key:"Ctrl-p",run:Yt,shift:ln},{key:"Ctrl-n",run:Zt,shift:cn},{key:"Ctrl-a",run:Kr,shift:so},{key:"Ctrl-e",run:_r,shift:lo},{key:"Ctrl-d",run:fn},{key:"Ctrl-h",run:Ve},{key:"Ctrl-k",run:po},{key:"Ctrl-Alt-h",run:mn},{key:"Ctrl-o",run:bo},{key:"Ctrl-t",run:ko},{key:"Ctrl-v",run:$e}],Eo=[{key:"ArrowLeft",run:Jt,shift:nn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qr,shift:Zr,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:jr,shift:oo,preventDefault:!0},{key:"ArrowRight",run:Kt,shift:rn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$r,shift:Xr,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Jr,shift:io,preventDefault:!0},{key:"ArrowUp",run:Yt,shift:ln,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ft,shift:mt},{mac:"Ctrl-ArrowUp",run:at,shift:ut},{key:"ArrowDown",run:Zt,shift:cn,preventDefault:!0},{mac:"Cmd-ArrowDown",run:dt,shift:gt},{mac:"Ctrl-ArrowDown",run:$e,shift:ht},{key:"PageUp",run:at,shift:ut},{key:"PageDown",run:$e,shift:ht},{key:"Home",run:Gr,shift:ro,preventDefault:!0},{key:"Mod-Home",run:ft,shift:mt},{key:"End",run:Hr,shift:no,preventDefault:!0},{key:"Mod-End",run:dt,shift:gt},{key:"Enter",run:pt,shift:pt},{key:"Mod-a",run:co},{key:"Backspace",run:Ve,shift:Ve,preventDefault:!0},{key:"Delete",run:fn,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mn,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:go,preventDefault:!0},{mac:"Mod-Backspace",run:yo,preventDefault:!0},{mac:"Mod-Delete",run:xo,preventDefault:!0}].concat(Ro.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),To=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:zr,shift:eo},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Ur,shift:to},{key:"Alt-ArrowUp",run:So},{key:"Shift-Alt-ArrowUp",run:vo},{key:"Alt-ArrowDown",run:Co},{key:"Shift-Alt-ArrowDown",run:Mo},{key:"Mod-Alt-ArrowUp",run:ho},{key:"Mod-Alt-ArrowDown",run:fo},{key:"Escape",run:mo},{key:"Mod-Enter",run:Bo},{key:"Alt-l",mac:"Ctrl-l",run:ao},{key:"Mod-i",run:uo,preventDefault:!0},{key:"Mod-[",run:bn},{key:"Mod-]",run:xn},{key:"Mod-Alt-\\",run:Do},{key:"Shift-Mod-k",run:Ao},{key:"Shift-Mod-\\",run:Yr},{key:"Mod-/",run:kr},{key:"Alt-A",mac:"Ctrl-A",run:Cr},{key:"Ctrl-m",mac:"Shift-Alt-m",run:wo}].concat(Eo),Io={key:"Tab",run:xn,shift:bn},yt=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class _{constructor(e,n,r=0,o=e.length,i,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,o),this.bufferStart=r,this.normalize=i?l=>i(yt(l)):yt,this.query=this.normalize(n)}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 Un(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 n=Gn(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Hn(e);let o=this.normalize(n);if(o.length)for(let i=0,s=r,l=!0;;i++){let c=o.charCodeAt(i),a=this.match(c,s,l,this.bufferPos+this.bufferStart,i==o.length-1);if(a)return this.value=a,this;if(i==o.length-1)break;l&&i<n.length&&n.charCodeAt(i)==c?s++:l=!1}}}match(e,n,r,o,i){let s=null;for(let l=0;l<this.matches.length;){let c=this.matches[l],a=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?s={from:c.from,to:o,precise:i&&c.precise}:(c.index++,a=!0)),a?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:n,to:o,precise:r&&i}:this.matches.push({from:n,index:1,precise:r})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(_.prototype[Symbol.iterator]=function(){return this});const kn={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ze="gm"+(/x/.unicode==null?"":"u");class Sn{constructor(e,n,r,o=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=kn,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Cn(e,n,r,o,i);this.re=new RegExp(n,Ze+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=e.iter();let s=e.lineAt(o);this.curLineStart=s.from,this.matchPos=xe(e,o),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 n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,o=r+n[0].length;if(this.matchPos=xe(this.text,o+(r==o?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<o||r>this.value.to)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,precise:!0,match:n},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}}}const Ie=new WeakMap;class K{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let o=Ie.get(e);if(!o||o.from>=r||o.to<=n){let l=new K(n,e.sliceString(n,r));return Ie.set(e,l),l}if(o.from==n&&o.to==r)return o;let{text:i,from:s}=o;return s>n&&(i=e.sliceString(n,s)+i,s=n),o.to<r&&(i+=e.sliceString(o.to,r)),Ie.set(e,new K(s,i)),new K(n,i.slice(n-s,r-s))}}class Cn{constructor(e,n,r,o,i){this.text=e,this.to=i,this.done=!1,this.value=kn,this.matchPos=xe(e,o),this.re=new RegExp(n,Ze+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=K.get(e,o,this.chunkEnd(o+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,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,o=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,precise:!0,match:n},this.matchPos=xe(this.text,o+(r==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=K.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Sn.prototype[Symbol.iterator]=Cn.prototype[Symbol.iterator]=function(){return this});function Po(t){try{return new RegExp(t,Ze),!0}catch{return!1}}function xe(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const Oo=t=>{let e=Vn(t,"cm-goto-line");if(e){let s=e.dom.querySelector("input[type=text]");return s&&s.select(),!0}let{state:n}=t,r=String(n.doc.lineAt(t.state.selection.main.head).number),{close:o,result:i}=zn(t,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return i.then(s=>{let l=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!l){t.dispatch({effects:o});return}let c=n.doc.lineAt(n.selection.main.head),[,a,u,h,d]=l,y=h?+h.slice(1):0,m=u?+u:c.number;if(u&&d){let B=m/100;a&&(B=B*(a=="-"?-1:1)+c.number/n.doc.lines),m=Math.round(n.doc.lines*B)}else u&&a&&(m=m*(a=="-"?-1:1)+c.number);let C=n.doc.line(Math.max(1,Math.min(n.doc.lines,m))),k=g.cursor(C.from+Math.max(0,Math.min(y,C.length)));t.dispatch({effects:[o,x.scrollIntoView(k.from,{y:"center"})],selection:k})}),!0},Fo={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Wo=ce.define({combine(t){return ve(t,Fo,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function No(t){return[Uo,zo]}const qo=M.mark({class:"cm-selectionMatch"}),$o=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function xt(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=T.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=T.Word)}function Vo(t,e,n,r){return t(e.sliceDoc(n,n+1))==T.Word&&t(e.sliceDoc(r-1,r))==T.Word}const zo=Ft.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Wo),{state:n}=t,r=n.selection;if(r.ranges.length>1)return M.none;let o=r.main,i,s=null;if(o.empty){if(!e.highlightWordAroundCursor)return M.none;let c=n.wordAt(o.head);if(!c)return M.none;s=n.charCategorizer(o.head),i=n.sliceDoc(c.from,c.to)}else{let c=o.to-o.from;if(c<e.minSelectionLength||c>200)return M.none;if(e.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(xt(s,n,o.from,o.to)&&Vo(s,n,o.from,o.to)))return M.none}else if(i=n.sliceDoc(o.from,o.to),!i)return M.none}let l=[];for(let c of t.visibleRanges){let a=new _(n.doc,i,c.from,c.to);for(;!a.next().done;){let{from:u,to:h}=a.value;if((!s||xt(s,n,u,h))&&(o.empty&&u<=o.from&&h>=o.to?l.push($o.range(u,h)):(u>=o.to||h<=o.from)&&l.push(qo.range(u,h)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:t=>t.decorations}),Uo=x.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Ho=({state:t,dispatch:e})=>{let{selection:n}=t,r=g.create(n.ranges.map(o=>t.wordAt(o.head)||g.cursor(o.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function Go(t,e){let{main:n,ranges:r}=t.selection,o=t.wordAt(n.head),i=o&&o.from==n.from&&o.to==n.to;for(let s=!1,l=new _(t.doc,e,r[r.length-1].to);;)if(l.next(),l.done){if(s)return null;l=new _(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some(c=>c.from==l.value.from))continue;if(i){let c=t.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const jo=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(i=>i.from===i.to))return Ho({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(i=>t.sliceDoc(i.from,i.to)!=r))return!1;let o=Go(t,r);return o?(e(t.update({selection:t.selection.addRange(g.range(o.from,o.to),!1),effects:x.scrollIntoView(o.to)})),!0):!1},Y=ce.define({combine(t){return ve(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>x.scrollIntoView(e)})}});class vn{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||Po(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,(n,r)=>r=="n"?`
7
- `:r=="r"?"\r":r=="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 Zo(this):new _o(this)}getCursor(e,n=0,r){let o=e.doc?e:oe.create({doc:e});return r==null&&(r=o.doc.length),this.regexp?j(this,o,n,r):G(this,o,n,r)}}class Mn{constructor(e){this.spec=e}}function Jo(t,e,n){return(r,o,i,s)=>{if(n&&!n(r,o,i,s))return!1;let l=r>=s&&o<=s+i.length?i.slice(r-s,o-s):e.doc.sliceString(r,o);return t(l,e,r,o)}}function G(t,e,n,r){let o;return t.wholeWord&&(o=Ko(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(o=Jo(t.test,e,o)),new _(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),o)}function Ko(t,e){return(n,r,o,i)=>((i>n||i+o.length<r)&&(i=Math.max(0,n-2),o=t.sliceString(i,Math.min(t.length,r+2))),(e(be(o,n-i))!=T.Word||e(ke(o,n-i))!=T.Word)&&(e(ke(o,r-i))!=T.Word||e(be(o,r-i))!=T.Word))}class _o extends Mn{constructor(e){super(e)}nextMatch(e,n,r){let o=G(this.spec,e,r,e.doc.length).nextOverlapping();if(o.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);o=G(this.spec,e,0,i).nextOverlapping()}return o.done||o.value.from==n&&o.value.to==r?null:o.value}prevMatchInRange(e,n,r){for(let o=r;;){let i=Math.max(n,o-1e4-this.spec.unquoted.length),s=G(this.spec,e,i,o),l=null;for(;!s.nextOverlapping().done;)l=s.value;if(l)return l;if(i==n)return null;o-=1e4}}prevMatch(e,n,r){let o=this.prevMatchInRange(e,0,n);return o||(o=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),o&&(o.from!=n||o.to!=r)?o:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=G(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=G(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}function Qo(t,e,n){return(r,o,i)=>(!n||n(r,o,i))&&t(i[0],e,r,o)}function j(t,e,n,r){let o;return t.wholeWord&&(o=Yo(e.charCategorizer(e.selection.main.head))),t.test&&(o=Qo(t.test,e,o)),new Sn(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:o},n,r)}function be(t,e){return t.slice(H(t,e,!1),e)}function ke(t,e){return t.slice(e,H(t,e))}function Yo(t){return(e,n,r)=>!r[0].length||(t(be(r.input,r.index))!=T.Word||t(ke(r.input,r.index))!=T.Word)&&(t(ke(r.input,r.index+r[0].length))!=T.Word||t(be(r.input,r.index+r[0].length))!=T.Word)}class Zo extends Mn{nextMatch(e,n,r){let o=j(this.spec,e,r,e.doc.length).next();return o.done&&(o=j(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,r){for(let o=1;;o++){let i=Math.max(n,r-o*1e4),s=j(this.spec,e,i,r),l=null;for(;!s.next().done;)l=s.value;if(l&&(i==n||l.from>i+10))return l;if(i==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let o=r.length;o>0;o--){let i=+r.slice(0,o);if(i>0&&i<e.match.length)return e.match[i]+r.slice(o)}return n})}matchAll(e,n){let r=j(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=j(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}const ie=N.define(),Xe=N.define(),q=He.define({create(t){return new Pe(ze(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ie)?t=new Pe(n.value.create(),t.panel):n.is(Xe)&&(t=new Pe(t.query,n.value?et:null));return t},provide:t=>Pt.from(t,e=>e.panel)});class Pe{constructor(e,n){this.query=e,this.panel=n}}const Xo=M.mark({class:"cm-searchMatch"}),ei=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ti=Ft.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(q))}update(t){let e=t.state.field(q);(e!=t.startState.field(q)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return M.none;let{view:n}=this,r=new Wt;for(let o=0,i=n.visibleRanges,s=i.length;o<s;o++){let{from:l,to:c}=i[o];for(;o<s-1&&c>i[o+1].from-500;)c=i[++o].to;t.highlight(n.state,l,c,(a,u)=>{let h=n.state.selection.ranges.some(d=>d.from==a&&d.to==u);r.add(a,u,h?ei:Xo)})}return r.finish()}},{decorations:t=>t.decorations});function ue(t){return e=>{let n=e.state.field(q,!1);return n&&n.query.spec.valid?t(e,n):tt(e)}}const Se=ue((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let o=g.single(r.from,r.to),i=t.state.facet(Y);return t.dispatch({selection:o,effects:[nt(t,r),i.scrollToMatch(o.main,t)],userEvent:"select.search"}),Ln(t),!0}),Ce=ue((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,o=e.prevMatch(n,r,r);if(!o)return!1;let i=g.single(o.from,o.to),s=t.state.facet(Y);return t.dispatch({selection:i,effects:[nt(t,o),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),Ln(t),!0}),ni=ue((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:g.create(n.map(r=>g.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),ri=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,i=[],s=0;for(let l=new _(t.doc,t.sliceDoc(r,o));!l.next().done;){if(i.length>1e3)return!1;l.value.from==r&&(s=i.length),i.push(g.range(l.value.from,l.value.to))}return e(t.update({selection:g.create(i,s),userEvent:"select.search.matches"})),!0},bt=ue((t,{query:e})=>{let{state:n}=t,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let i=e.nextMatch(n,r,r);if(!i)return!1;let s=i,l=[],c,a,u=[];s.precise?s.from==r&&s.to==o&&(a=n.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(n,s.from,s.to),u.push(x.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):s=e.nextMatch(n,s.from,s.to);let h=t.state.changes(l);return s&&(c=g.single(s.from,s.to).map(h),u.push(nt(t,s)),u.push(n.facet(Y).scrollToMatch(c.main,t))),t.dispatch({changes:h,selection:c,effects:u,userEvent:"input.replace"}),!0}),oi=ue((t,{query:e})=>{if(t.state.readOnly)return!1;let n=[];for(let o of e.matchAll(t.state,1e9)){let{from:i,to:s,precise:l}=o;l&&n.push({from:i,to:s,insert:e.getReplacement(o)})}if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:x.announce.of(r),userEvent:"input.replace.all"}),!0});function et(t){return t.state.facet(Y).createPanel(t)}function ze(t,e){var n,r,o,i,s;let l=t.selection.main,c=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!c)return e;let a=t.facet(Y);return new vn({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:a.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:a.caseSensitive,literal:(o=e==null?void 0:e.literal)!==null&&o!==void 0?o:a.literal,regexp:(i=e==null?void 0:e.regexp)!==null&&i!==void 0?i:a.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:a.wholeWord})}function An(t){let e=Ke(t,et);return e&&e.dom.querySelector("[main-field]")}function Ln(t){let e=An(t);e&&e==t.root.activeElement&&e.select()}const tt=t=>{let e=t.state.field(q,!1);if(e&&e.panel){let n=An(t);if(n&&n!=t.root.activeElement){let r=ze(t.state,e.query.spec);r.valid&&t.dispatch({effects:ie.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[Xe.of(!0),e?ie.of(ze(t.state,e.query.spec)):N.appendConfig.of(ci)]});return!0},Bn=t=>{let e=t.state.field(q,!1);if(!e||!e.panel)return!1;let n=Ke(t,et);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Xe.of(!1)}),!0},ii=[{key:"Mod-f",run:tt,scope:"editor search-panel"},{key:"F3",run:Se,shift:Ce,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Se,shift:Ce,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Bn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ri},{key:"Mod-Alt-g",run:Oo},{key:"Mod-d",run:jo,preventDefault:!0}];class si{constructor(e){this.view=e;let n=this.query=e.state.field(q).query.spec;this.commit=this.commit.bind(this),this.searchField=S("input",{value:n.search,placeholder:w(e,"Find"),"aria-label":w(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=S("input",{value:n.replace,placeholder:w(e,"Replace"),"aria-label":w(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=S("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=S("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=S("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(o,i,s){return S("button",{class:"cm-button",name:o,onclick:i,type:"button"},s)}this.dom=S("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,r("next",()=>Se(e),[w(e,"next")]),r("prev",()=>Ce(e),[w(e,"previous")]),r("select",()=>ni(e),[w(e,"all")]),S("label",null,[this.caseField,w(e,"match case")]),S("label",null,[this.reField,w(e,"regexp")]),S("label",null,[this.wordField,w(e,"by word")]),...e.state.readOnly?[]:[S("br"),this.replaceField,r("replace",()=>bt(e),[w(e,"replace")]),r("replaceAll",()=>oi(e),[w(e,"replace all")])],S("button",{name:"close",onclick:()=>Bn(e),"aria-label":w(e,"close"),type:"button"},["×"])])}commit(){let e=new vn({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:ie.of(e)}))}keydown(e){jn(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ce:Se)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),bt(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(ie)&&!r.value.eq(this.query)&&this.setQuery(r.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(Y).top}}function w(t,e){return t.state.phrase(e)}const fe=30,de=/[\s\.,:;?!]/;function nt(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),o=t.state.doc.lineAt(n).to,i=Math.max(r.from,e-fe),s=Math.min(o,n+fe),l=t.state.sliceDoc(i,s);if(i!=r.from){for(let c=0;c<fe;c++)if(!de.test(l[c+1])&&de.test(l[c])){l=l.slice(c);break}}if(s!=o){for(let c=l.length-1;c>l.length-fe;c--)if(!de.test(l[c-1])&&de.test(l[c])){l=l.slice(0,c);break}}return x.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${r.number}.`)}const li=x.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"}}),ci=[q,Ot.low(ti),li],ai="#e5c07b",kt="#e06c75",ui="#56b6c2",hi="#ffffff",ge="#abb2bf",Ue="#7d8799",fi="#61afef",di="#98c379",St="#d19a66",mi="#c678dd",gi="#21252b",Ct="#2c313a",vt="#282c34",Oe="#353a42",pi="#3E4451",Mt="#528bff",yi=x.theme({"&":{color:ge,backgroundColor:vt},".cm-content":{caretColor:Mt},".cm-cursor, .cm-dropCursor":{borderLeftColor:Mt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:pi},".cm-panels":{backgroundColor:gi,color:ge},".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:vt,color:Ue,border:"none"},".cm-activeLineGutter":{backgroundColor:Ct},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Oe},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Oe,borderBottomColor:Oe},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ct,color:ge}}},{dark:!0}),xi=Jn.define([{tag:f.keyword,color:mi},{tag:[f.name,f.deleted,f.character,f.propertyName,f.macroName],color:kt},{tag:[f.function(f.variableName),f.labelName],color:fi},{tag:[f.color,f.constant(f.name),f.standard(f.name)],color:St},{tag:[f.definition(f.name),f.separator],color:ge},{tag:[f.typeName,f.className,f.number,f.changed,f.annotation,f.modifier,f.self,f.namespace],color:ai},{tag:[f.operator,f.operatorKeyword,f.url,f.escape,f.regexp,f.link,f.special(f.string)],color:ui},{tag:[f.meta,f.comment],color:Ue},{tag:f.strong,fontWeight:"bold"},{tag:f.emphasis,fontStyle:"italic"},{tag:f.strikethrough,textDecoration:"line-through"},{tag:f.link,color:Ue,textDecoration:"underline"},{tag:f.heading,fontWeight:"bold",color:kt},{tag:[f.atom,f.bool,f.special(f.variableName)],color:St},{tag:[f.processingInstruction,f.string,f.inserted],color:di},{tag:f.invalid,color:hi}]),At=[yi,Nt(xi)];class Lt{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class U{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let o=r.facet(se).markerFilter;o&&(e=o(e,r));let i=e.slice().sort((y,m)=>y.from-m.from||y.to-m.to),s=new Wt,l=[],c=0,a=r.doc.iter(),u=0,h=r.doc.length;for(let y=0;;){let m=y==i.length?null:i[y];if(!m&&!l.length)break;let C,k;if(l.length)C=c,k=l.reduce((b,D)=>Math.min(b,D.to),m&&m.from>C?m.from:1e8);else{if(C=m.from,C>h)break;k=m.to,l.push(m),y++}for(;y<i.length;){let b=i[y];if(b.from==C&&(b.to>b.from||b.to==C))l.push(b),y++,k=Math.min(b.to,k);else{k=Math.min(b.from,k);break}}k=Math.min(k,h);let B=!1;if(l.some(b=>b.from==C&&(b.to==k||k==h))&&(B=C==k,!B&&k-C<10)){let b=C-(u+a.value.length);b>0&&(a.next(b),u=C);for(let D=C;;){if(D>=k){B=!0;break}if(!a.lineBreak&&u+a.value.length>D)break;D=u+a.value.length,u+=a.value.length,a.next()}}let Z=Ei(l);if(B)s.add(C,C,M.widget({widget:new Bi(Z),diagnostics:l.slice()}));else{let b=l.reduce((D,X)=>X.markClass?D+" "+X.markClass:D,"");s.add(C,k,M.mark({class:"cm-lintRange cm-lintRange-"+Z+b,diagnostics:l.slice(),inclusiveEnd:l.some(D=>D.to>k)}))}if(c=k,c==h)break;for(let b=0;b<l.length;b++)l[b].to<=c&&l.splice(b--,1)}let d=s.finish();return new U(d,n,$(d))}}function $(t,e=null,n=0){let r=null;return t.between(n,1e9,(o,i,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!r)r=new Lt(o,i,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Lt(r.from,i,r.diagnostic)}}),r}function bi(t,e){let n=e.pos,r=e.end||n,o=t.state.facet(se).hideOn(t,n,r);if(o!=null)return o;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(Dn))||t.changes.touchesRange(i.from,Math.max(i.to,r)))}function ki(t,e){return t.field(R,!1)?e:e.concat(N.appendConfig.of(Ti))}const Dn=N.define(),rt=N.define(),wn=N.define(),R=He.define({create(){return new U(M.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,o=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=$(n,t.selected.diagnostic,i)||$(n,null,i)}!n.size&&o&&e.state.facet(se).autoPanel&&(o=null),t=new U(n,o,r)}for(let n of e.effects)if(n.is(Dn)){let r=e.state.facet(se).autoPanel?n.value.length?le.open:null:t.panel;t=U.init(n.value,r,e.state)}else n.is(rt)?t=new U(t.diagnostics,n.value?le.open:null,t.selected):n.is(wn)&&(t=new U(t.diagnostics,t.panel,n.value));return t},provide:t=>[Pt.from(t,e=>e.panel),x.decorations.from(t,e=>e.diagnostics)]}),Si=M.mark({class:"cm-lintRange cm-lintRange-active"});function Ci(t,e,n){let{diagnostics:r}=t.state.field(R),o,i=-1,s=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(c,a,{spec:u})=>{if(e>=c&&e<=a&&(c==a||(e>c||n>0)&&(e<a||n<0)))return o=u.diagnostics,i=c,s=a,!1});let l=t.state.facet(se).tooltipFilter;return o&&l&&(o=l(o,t.state)),o?{pos:i,end:s,above:!0,create(){return{dom:vi(t,o)}}}:null}function vi(t,e){return S("ul",{class:"cm-tooltip-lint"},e.map(n=>En(t,n,!1)))}const Mi=t=>{let e=t.state.field(R,!1);(!e||!e.panel)&&t.dispatch({effects:ki(t.state,[rt.of(!0)])});let n=Ke(t,le.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Bt=t=>{let e=t.state.field(R,!1);return!e||!e.panel?!1:(t.dispatch({effects:rt.of(!1)}),!0)},Ai=t=>{let e=t.state.field(R,!1);if(!e)return!1;let n=t.state.selection.main,r=$(e.diagnostics,null,n.to+1);return!r&&(r=$(e.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),Kn(t,r.from,1,{tooltip:Tn,until:o=>o.docChanged||o.newSelection.main.head<r.from||o.newSelection.main.head>r.to}),!0)},Li=[{key:"Mod-Shift-m",run:Mi,preventDefault:!0},{key:"F8",run:Ai}],se=ce.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...ve(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Dt,tooltipFilter:Dt,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,o,i)=>e(r,o,i)||n(r,o,i):e:n,autoPanel:(e,n)=>e||n})}}});function Dt(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function Rn(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let o=n[r];if(/[a-zA-Z]/.test(o)&&!e.some(i=>i.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function En(t,e,n){var r;let o=n?Rn(e.actions):[];return S("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},S("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((i,s)=>{let l=!1,c=y=>{if(y.preventDefault(),l)return;l=!0;let m=$(t.state.field(R).diagnostics,e);m&&i.apply(t,m.from,m.to)},{name:a}=i,u=o[s]?a.indexOf(o[s]):-1,h=u<0?a:[a.slice(0,u),S("u",a.slice(u,u+1)),a.slice(u+1)],d=i.markClass?" "+i.markClass:"";return S("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:c,onmousedown:c,"aria-label":` Action: ${a}${u<0?"":` (access key "${o[s]})"`}.`},h)}),e.source&&S("div",{class:"cm-diagnosticSource"},e.source))}class Bi extends Qn{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return S("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class wt{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=En(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class le{constructor(e){this.view=e,this.items=[];let n=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)Bt(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],s=Rn(i.actions);for(let l=0;l<s.length;l++)if(s[l].toUpperCase().charCodeAt(0)==o.keyCode){let c=$(this.view.state.field(R).diagnostics,i);c&&i.actions[l].apply(e,c.from,c.to)}}else return;o.preventDefault()}},r=o=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(o.target)&&this.moveSelection(i)};this.list=S("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=S("div",{class:"cm-panel-lint"},this.list,S("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Bt(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(R).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(R),r=0,o=!1,i=null,s=new Set;for(e.between(0,this.view.state.doc.length,(l,c,{spec:a})=>{for(let u of a.diagnostics){if(s.has(u))continue;s.add(u);let h=-1,d;for(let y=r;y<this.items.length;y++)if(this.items[y].diagnostic==u){h=y;break}h<0?(d=new wt(this.view,u),this.items.splice(r,0,d),o=!0):(d=this.items[h],h>r&&(this.items.splice(r,h-r),o=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),i=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new wt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!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:l,panel:c})=>{let a=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/a:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(R),r=$(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:wn.of(r)})}static open(e){return new le(e)}}function Di(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function me(t){return Di(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const wi=x.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:me("#f11")},".cm-lintRange-warning":{backgroundImage:me("orange")},".cm-lintRange-info":{backgroundImage:me("#999")},".cm-lintRange-hint":{backgroundImage:me("#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 Ri(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Ei(t){let e="hint",n=1;for(let r of t){let o=Ri(r.severity);o>n&&(n=o,e=r.severity)}return e}const Tn=_n(Ci,{hideOn:bi}),Ti=[R,x.decorations.compute([R],t=>{let{selected:e,panel:n}=t.field(R);return!e||!n||e.from==e.to?M.none:M.set([Si.range(e.from,e.to)])}),Tn,wi],Ii=[Yn(),Zn(),Xn(),wr(),er(),tr(),nr(),oe.allowMultipleSelections.of(!0),rr(),Nt(dr,{fallback:!0}),or(),ir(),sr(),lr(),cr(),ar(),No(),qt.of([...ur,...To,...ii,...Nr,...hr,...fr,...Li])],Rt=Ge.define();function Oi({path:t,value:e,onChange:n,onSave:r,readOnly:o=!1,height:i=320,testId:s="code-editor-input",id:l,label:c,placeholder:a,hidePreview:u=!1,defaultWrap:h=!1}){const{theme:d}=mr(),y=v.useRef(null),m=v.useRef(null),C=v.useRef({path:t,value:e,readOnly:o,testId:s,id:l,label:c,placeholder:a,defaultWrap:h,theme:d}),k=v.useRef(n);k.current=n;const B=v.useRef(r);B.current=r;const Z=v.useRef(e.includes(`\r
6
+ */const xr=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],br=Fn("text-wrap",xr),kr=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Qe(t.state,n.from);return r.line?Sr(t):r.block?vr(t):!1};function _e(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=t(e,n);return o?(r(n.update(o)),!0):!1}}const Sr=_e(Lr,0),Cr=_e($t,0),vr=_e((t,e)=>$t(t,e,Ar(e)),0);function Qe(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const re=50;function Mr(t,{open:e,close:n},r,o){let i=t.sliceDoc(r-re,r),s=t.sliceDoc(o,o+re),l=/\s*$/.exec(i)[0].length,c=/^\s*/.exec(s)[0].length,a=i.length-l;if(i.slice(a-e.length,a)==e&&s.slice(c,c+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:o+c,margin:c&&1}};let u,h;o-r<=2*re?u=h=t.sliceDoc(r,o):(u=t.sliceDoc(r,r+re),h=t.sliceDoc(o-re,o));let d=/^\s*/.exec(u)[0].length,y=/\s*$/.exec(h)[0].length,m=h.length-y-n.length;return u.slice(d,d+e.length)==e&&h.slice(m,m+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(u.charAt(d+e.length))?1:0},close:{pos:o-y-n.length,margin:/\s/.test(h.charAt(m-1))?1:0}}:null}function Ar(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),o=n.to<=r.to?r:t.doc.lineAt(n.to);o.from>r.from&&o.from==n.to&&(o=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let i=e.length-1;i>=0&&e[i].to>r.from?e[i].to=o.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return e}function $t(t,e,n=e.selection.ranges){let r=n.map(i=>Qe(e,i.from).block);if(!r.every(i=>i))return null;let o=n.map((i,s)=>Mr(e,r[s],i.from,i.to));if(t!=2&&!o.every(i=>i))return{changes:e.changes(n.map((i,s)=>o[s]?[]:[{from:i.from,insert:r[s].open+" "},{from:i.to,insert:" "+r[s].close}]))};if(t!=1&&o.some(i=>i)){let i=[];for(let s=0,l;s<o.length;s++)if(l=o[s]){let c=r[s],{open:a,close:u}=l;i.push({from:a.pos-c.open.length,to:a.pos+a.margin},{from:u.pos-u.margin,to:u.pos+c.close.length})}return{changes:i}}return null}function Lr(t,e,n=e.selection.ranges){let r=[],o=-1;e:for(let{from:i,to:s}of n){let l=r.length,c=1e9,a;for(let u=i;u<=s;){let h=e.doc.lineAt(u);if(a==null&&(a=Qe(e,h.from).line,!a))continue e;if(h.from>o&&(i==s||s>h.from)){o=h.from;let d=/^\s*/.exec(h.text)[0].length,y=d==h.length,m=h.text.slice(d,d+a.length)==a?d:-1;d<h.text.length&&d<c&&(c=d),r.push({line:h,comment:m,token:a,indent:d,empty:y,single:!1})}u=h.to+1}if(c<1e9)for(let u=l;u<r.length;u++)r[u].indent<r[u].line.text.length&&(r[u].indent=c);r.length==l+1&&(r[l].single=!0)}if(t!=2&&r.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:l,token:c,indent:a,empty:u,single:h}of r)(h||!u)&&i.push({from:l.from+a,insert:c+" "});let s=e.changes(i);return{changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&r.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:l,token:c}of r)if(l>=0){let a=s.from+l,u=a+c.length;s.text[u-s.from]==" "&&u++,i.push({from:a,to:u})}return{changes:i}}return null}const Ne=Ge.define(),Br=Ge.define(),Dr=ce.define(),Vt=ce.define({combine(t){return ve(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,o)=>e(r,o)||n(r,o)})}}),zt=Ue.define({create(){return W.empty},update(t,e){let n=e.state.facet(Vt),r=e.annotation(Ne);if(r){let c=L.fromTransaction(e,r.selection),a=r.side,u=a==0?t.undone:t.done;return c?u=ye(u,u.length,n.minDepth,c):u=Gt(u,e.startState.selection),new W(a==0?r.rest:u,a==0?u:r.rest)}let o=e.annotation(Br);if((o=="full"||o=="before")&&(t=t.isolate()),e.annotation(Re.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let i=L.fromTransaction(e),s=e.annotation(Re.time),l=e.annotation(Re.userEvent);return i?t=t.addChanges(i,s,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,s,l,n.newGroupDelay)),(o=="full"||o=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new W(t.done.map(L.fromJSON),t.undone.map(L.fromJSON))}});function wr(t={}){return[zt,Vt.of(t),x.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?Ht:e.inputType=="historyRedo"?qe:null;return r?(e.preventDefault(),r(n)):!1}})]}function Me(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let o=n.field(zt,!1);if(!o)return!1;let i=o.pop(t,n,e);return i?(r(i),!0):!1}}const Ht=Me(0,!1),qe=Me(1,!1),Rr=Me(0,!0),Er=Me(1,!0);class L{constructor(e,n,r,o,i){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=o,this.selectionsAfter=i}setSelAfter(e){return new L(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(o=>o.toJSON())}}static fromJSON(e){return new L(e.changes&&Wn.fromJSON(e.changes),[],e.mapped&&Nn.fromJSON(e.mapped),e.startSelection&&g.fromJSON(e.startSelection),e.selectionsAfter.map(g.fromJSON))}static fromTransaction(e,n){let r=I;for(let o of e.startState.facet(Dr)){let i=o(e);i.length&&(r=r.concat(i))}return!r.length&&e.changes.empty?null:new L(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,I)}static selection(e){return new L(void 0,I,void 0,void 0,e)}}function ye(t,e,n,r){let o=e+1>n+20?e-n-1:0,i=t.slice(o,e);return i.push(r),i}function Tr(t,e){let n=[],r=!1;return t.iterChangedRanges((o,i)=>n.push(o,i)),e.iterChangedRanges((o,i,s,l)=>{for(let c=0;c<n.length;){let a=n[c++],u=n[c++];l>=a&&s<=u&&(r=!0)}}),r}function Ir(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function Ut(t,e){return t.length?e.length?t.concat(e):t:e}const I=[],Pr=200;function Gt(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Pr));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),ye(t,t.length-1,1e9,n.setSelAfter(r)))}else return[L.selection([e])]}function Or(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Te(t,e){if(!t.length)return t;let n=t.length,r=I;for(;n;){let o=Fr(t[n-1],e,r);if(o.changes&&!o.changes.empty||o.effects.length){let i=t.slice(0,n);return i[n-1]=o,i}else e=o.mapped,n--,r=o.selectionsAfter}return r.length?[L.selection(r)]:I}function Fr(t,e,n){let r=Ut(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):I,n);if(!t.changes)return L.selection(r);let o=t.changes.map(e),i=e.mapDesc(t.changes,!0),s=t.mapped?t.mapped.composeDesc(i):i;return new L(o,N.mapEffects(t.effects,e),s,t.startSelection.map(i),r)}const Wr=/^(input\.type|delete)($|\.)/;class W{constructor(e,n,r=0,o=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=o}isolate(){return this.prevTime?new W(this.done,this.undone):this}addChanges(e,n,r,o,i){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||Wr.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<o.newGroupDelay&&o.joinToEvent(i,Tr(l.changes,e.changes))||r=="input.type.compose")?s=ye(s,s.length-1,o.minDepth,new L(e.changes.compose(l.changes),Ut(N.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,I)):s=ye(s,s.length,o.minDepth,e),new W(s,I,n,r)}addSelection(e,n,r,o){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:I;return i.length>0&&n-this.prevTime<o&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Ir(i[i.length-1],e)?this:new W(Gt(this.done,e),this.undone,n,r)}addMapping(e){return new W(Te(this.done,e),Te(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,r){let o=e==0?this.done:this.undone;if(o.length==0)return null;let i=o[o.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(r&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Ne.of({side:e,rest:Or(o),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let l=o.length==1?I:o.slice(0,o.length-1);return i.mapped&&(l=Te(l,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Ne.of({side:e,rest:l,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}W.empty=new W(I,I);const Nr=[{key:"Mod-z",run:Ht,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:qe,preventDefault:!0},{linux:"Ctrl-Shift-z",run:qe,preventDefault:!0},{key:"Mod-u",run:Rr,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Er,preventDefault:!0}];function Q(t,e){return g.create(t.ranges.map(e),t.mainIndex)}function O(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function F({state:t,dispatch:e},n){let r=Q(t.selection,n);return r.eq(t.selection,!0)?!1:(e(O(t,r)),!0)}function Ae(t,e){return g.cursor(e?t.to:t.from)}function jt(t,e){return F(t,n=>n.empty?t.moveByChar(n,e):Ae(n,e))}function A(t){return t.textDirectionAt(t.state.selection.main.head)==qn.LTR}const Jt=t=>jt(t,!A(t)),Kt=t=>jt(t,A(t));function _t(t,e){return F(t,n=>n.empty?t.moveByGroup(n,e):Ae(n,e))}const qr=t=>_t(t,!A(t)),$r=t=>_t(t,A(t));function Vr(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Le(t,e,n){let r=Je(t).resolveInner(e.head),o=n?Fe.closedBy:Fe.openedBy;for(let c=e.head;;){let a=n?r.childAfter(c):r.childBefore(c);if(!a)break;Vr(t,a,o)?r=a:c=n?a.to:a.from}let i=r.type.prop(o),s,l;return i&&(s=n?J(t,r.from,1):J(t,r.to,-1))&&s.matched?l=n?s.end.to:s.end.from:l=n?r.to:r.from,g.cursor(l,n?-1:1)}const zr=t=>F(t,e=>Le(t.state,e,!A(t))),Hr=t=>F(t,e=>Le(t.state,e,A(t)));function Qt(t,e){return F(t,n=>{if(!n.empty)return Ae(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const Yt=t=>Qt(t,!1),Zt=t=>Qt(t,!0);function Xt(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,r=0,o;if(e){for(let i of t.state.facet(x.scrollMargins)){let s=i(t);s!=null&&s.top&&(n=Math.max(s==null?void 0:s.top,n)),s!=null&&s.bottom&&(r=Math.max(s==null?void 0:s.bottom,r))}o=t.scrollDOM.clientHeight-n-r}else o=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:e,height:Math.max(t.defaultLineHeight,o-5)}}function en(t,e){let n=Xt(t),{state:r}=t,o=Q(r.selection,s=>s.empty?t.moveVertically(s,e,n.height):Ae(s,e));if(o.eq(r.selection))return!1;let i;if(n.selfScroll){let s=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),c=l.top+n.marginTop,a=l.bottom-n.marginBottom;s&&s.top>c&&s.bottom<a&&(i=x.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-c}))}return t.dispatch(O(r,o),{effects:i}),!0}const at=t=>en(t,!1),$e=t=>en(t,!0);function V(t,e,n){let r=t.lineBlockAt(e.head),o=t.moveToLineBoundary(e,n);if(o.head==e.head&&o.head!=(n?r.to:r.from)&&(o=t.moveToLineBoundary(e,n,!1)),!n&&o.head==r.from&&r.length){let i=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;i&&e.head!=r.from+i&&(o=g.cursor(r.from+i))}return o}const Ur=t=>F(t,e=>V(t,e,!0)),Gr=t=>F(t,e=>V(t,e,!1)),jr=t=>F(t,e=>V(t,e,!A(t))),Jr=t=>F(t,e=>V(t,e,A(t))),Kr=t=>F(t,e=>t.moveToLineBoundary(e,!1,!1)),_r=t=>F(t,e=>t.moveToLineBoundary(e,!0,!1));function Qr(t,e,n){let r=!1,o=Q(t.selection,i=>{let s=J(t,i.head,-1)||J(t,i.head,1)||i.head>0&&J(t,i.head-1,1)||i.head<t.doc.length&&J(t,i.head+1,-1);if(!s||!s.end)return i;r=!0;let l=s.start.from==i.head?s.end.to:s.end.from;return g.cursor(l)});return r?(e(O(t,o)),!0):!1}const Yr=({state:t,dispatch:e})=>Qr(t,e);function P(t,e,n){let r=Q(t.state.selection,o=>{o.undirectional&&o.head>=o.anchor!=e&&(o=g.range(o.head,o.anchor));let i=n(o);return g.range(o.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(O(t.state,r)),!0)}function tn(t,e){return P(t,e,n=>t.moveByChar(n,e))}const nn=t=>tn(t,!A(t)),rn=t=>tn(t,A(t));function on(t,e){return P(t,e,n=>t.moveByGroup(n,e))}const Zr=t=>on(t,!A(t)),Xr=t=>on(t,A(t)),eo=t=>{let e=!A(t);return P(t,e,n=>Le(t.state,n,e))},to=t=>{let e=A(t);return P(t,e,n=>Le(t.state,n,e))};function sn(t,e){return P(t,e,n=>t.moveVertically(n,e))}const ln=t=>sn(t,!1),cn=t=>sn(t,!0);function an(t,e){return P(t,e,n=>t.moveVertically(n,e,Xt(t).height))}const ut=t=>an(t,!1),ht=t=>an(t,!0),no=t=>P(t,!0,e=>V(t,e,!0)),ro=t=>P(t,!1,e=>V(t,e,!1)),oo=t=>{let e=!A(t);return P(t,e,n=>V(t,n,e))},io=t=>{let e=A(t);return P(t,e,n=>V(t,n,e))},so=t=>P(t,!1,e=>g.cursor(t.lineBlockAt(e.head).from)),lo=t=>P(t,!0,e=>g.cursor(t.lineBlockAt(e.head).to)),ft=({state:t,dispatch:e})=>(e(O(t,{anchor:0})),!0),dt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.doc.length})),!0),mt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.selection.main.anchor,head:0})),!0),gt=({state:t,dispatch:e})=>(e(O(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),co=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),ao=({state:t,dispatch:e})=>{let n=Be(t).map(({from:r,to:o})=>g.undirectionalRange(r,Math.min(o+1,t.doc.length)));return e(t.update({selection:g.create(n),userEvent:"select"})),!0},uo=({state:t,dispatch:e})=>{let n=Q(t.selection,r=>{let o=Je(t),i=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:l}=s;if((l.from<r.from&&l.to>=r.to||l.to>r.to&&l.from<=r.from)&&s.next)return g.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(O(t,n)),!0)};function un(t,e){let{state:n}=t,r=n.selection,o=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(e?s.to<t.state.doc.length:s.from>0)for(let l=i;;){let c=t.moveVertically(l,e);if(c.head<s.from||c.head>s.to){o.some(a=>a.head==c.head)||o.push(c);break}else{if(c.head==l.head)break;l=c}}}return o.length==r.ranges.length?!1:(t.dispatch(O(n,g.create(o,o.length-1))),!0)}const ho=t=>un(t,!1),fo=t=>un(t,!0),mo=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=g.create([n.main]):n.main.empty||(r=g.create([g.cursor(n.main.head)])),r?(e(O(t,r)),!0):!1};function ae(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,o=r.changeByRange(i=>{let{from:s,to:l}=i;if(s==l){let c=e(i);c<s?(n="delete.backward",c=he(t,c,!1)):c>s&&(n="delete.forward",c=he(t,c,!0)),s=Math.min(s,c),l=Math.max(l,c)}else s=he(t,s,!1),l=he(t,l,!0);return s==l?{range:i}:{changes:{from:s,to:l},range:g.cursor(s,s<i.head?-1:1)}});return o.changes.empty?!1:(t.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?x.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function he(t,e,n){if(t instanceof x)for(let r of t.state.facet(x.atomicRanges).map(o=>o(t)))r.between(e,e,(o,i)=>{o<e&&i>e&&(e=n?i:o)});return e}const hn=(t,e,n)=>ae(t,r=>{let o=r.from,{state:i}=t,s=i.doc.lineAt(o),l,c;if(n&&!e&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(l=s.text.slice(0,o-s.from))){if(l[l.length-1]==" ")return o-1;let a=je(l,i.tabSize),u=a%We(i)||We(i);for(let h=0;h<u&&l[l.length-1-h]==" ";h++)o--;c=o}else c=U(s.text,o-s.from,e,e)+s.from,c==o&&s.number!=(e?i.doc.lines:1)?c+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(c-s.from,o-s.from))&&(c=U(s.text,c-s.from,!1,!1)+s.from);return c}),Ve=t=>hn(t,!1,!0),fn=t=>hn(t,!0,!1),dn=(t,e)=>ae(t,n=>{let r=n.head,{state:o}=t,i=o.doc.lineAt(r),s=o.charCategorizer(r);for(let l=null;;){if(r==(e?i.to:i.from)){r==n.head&&i.number!=(e?o.doc.lines:1)&&(r+=e?1:-1);break}let c=U(i.text,r-i.from,e)+i.from,a=i.text.slice(Math.min(r,c)-i.from,Math.max(r,c)-i.from),u=s(a);if(l!=null&&u!=l)break;(a!=" "||r!=n.head)&&(l=u),r=c}return r}),mn=t=>dn(t,!1),go=t=>dn(t,!0),po=t=>ae(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),yo=t=>ae(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),xo=t=>ae(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),bo=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:It.of(["",""])},range:g.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},ko=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let o=r.from,i=t.doc.lineAt(o),s=o==i.from?o-1:U(i.text,o-i.from,!1)+i.from,l=o==i.to?o+1:U(i.text,o-i.from,!0)+i.from;return{changes:{from:s,to:l,insert:t.doc.slice(o,l).append(t.doc.slice(s,o))},range:g.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Be(t){let e=[],n=-1;for(let r of t.selection.ranges){let o=t.doc.lineAt(r.from),i=t.doc.lineAt(r.to);if(!r.empty&&r.to==i.from&&(i=t.doc.lineAt(r.to-1)),n>=o.number){let s=e[e.length-1];s.to=i.to,s.ranges.push(r)}else e.push({from:o.from,to:i.to,ranges:[r]});n=i.number+1}return e}function gn(t,e,n){if(t.readOnly)return!1;let r=[],o=[];for(let i of Be(t)){if(n?i.to==t.doc.length:i.from==0)continue;let s=t.doc.lineAt(n?i.to+1:i.from-1),l=s.length+1;if(n){r.push({from:i.to,to:s.to},{from:i.from,insert:s.text+t.lineBreak});for(let c of i.ranges)o.push(g.range(Math.min(t.doc.length,c.anchor+l),Math.min(t.doc.length,c.head+l)))}else{r.push({from:s.from,to:i.from},{from:i.to,insert:t.lineBreak+s.text});for(let c of i.ranges)o.push(g.range(c.anchor-l,c.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:g.create(o,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const So=({state:t,dispatch:e})=>gn(t,e,!1),Co=({state:t,dispatch:e})=>gn(t,e,!0);function pn(t,e,n){if(t.readOnly)return!1;let r=[];for(let i of Be(t))n?r.push({from:i.from,insert:t.doc.slice(i.from,i.to)+t.lineBreak}):r.push({from:i.to,insert:t.lineBreak+t.doc.slice(i.from,i.to)});let o=t.changes(r);return e(t.update({changes:o,selection:t.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const vo=({state:t,dispatch:e})=>pn(t,e,!1),Mo=({state:t,dispatch:e})=>pn(t,e,!0),Ao=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Be(e).map(({from:o,to:i})=>(o>0?o--:i<e.doc.length&&i++,{from:o,to:i}))),r=Q(e.selection,o=>{let i;if(t.lineWrapping){let s=t.lineBlockAt(o.head),l=t.coordsAtPos(o.head,o.assoc||1);l&&(i=s.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(o,!0,i)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Lo(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Je(t).resolveInner(e),r=n.childBefore(e),o=n.childAfter(e),i;return r&&o&&r.to<=e&&o.from>=e&&(i=r.type.prop(Fe.closedBy))&&i.indexOf(o.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(r.to,o.from))?{from:r.to,to:o.from}:null}const pt=yn(!1),Bo=yn(!0);function yn(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(o=>{let{from:i,to:s}=o,l=e.doc.lineAt(i),c=!t&&i==s&&Lo(e,i);t&&(i=s=(s<=l.to?l:e.doc.lineAt(s)).to);let a=new Et(e,{simulateBreak:i,simulateDoubleBreak:!!c}),u=Tt(a,i);for(u==null&&(u=je(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));s<l.to&&/\s/.test(l.text[s-l.from]);)s++;c?{from:i,to:s}=c:i>l.from&&i<l.from+100&&!/\S/.test(l.text.slice(0,i))&&(i=l.from);let h=["",pe(e,u)];return c&&h.push(pe(e,a.lineIndent(l.from,-1))),{changes:{from:i,to:s,insert:It.of(h)},range:g.cursor(i+1+h[1].length)}});return n(e.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ye(t,e){let n=-1;return t.changeByRange(r=>{let o=[];for(let s=r.from;s<=r.to;){let l=t.doc.lineAt(s);l.number>n&&(r.empty||r.to>l.from)&&(e(l,o,r),n=l.number),s=l.to+1}let i=t.changes(o);return{changes:o,range:g.range(i.mapPos(r.anchor,1),i.mapPos(r.head,1))}})}const Do=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Et(t,{overrideIndentation:i=>{let s=n[i];return s??-1}}),o=Ye(t,(i,s,l)=>{let c=Tt(r,i.from);if(c==null)return;/\S/.test(i.text)||(c=0);let a=/^\s*/.exec(i.text)[0],u=pe(t,c);(a!=u||l.from<i.from+a.length)&&(n[i.from]=c,s.push({from:i.from,to:i.from+a.length,insert:u}))});return o.changes.empty||e(t.update(o,{userEvent:"indent"})),!0},xn=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Ye(t,(n,r)=>{r.push({from:n.from,insert:t.facet($n)})}),{userEvent:"input.indent"})),!0),bn=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Ye(t,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let i=je(o,t.tabSize),s=0,l=pe(t,Math.max(0,i-We(t)));for(;s<o.length&&s<l.length&&o.charCodeAt(s)==l.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+o.length,insert:l.slice(s)})}),{userEvent:"delete.dedent"})),!0),wo=t=>(t.setTabFocusMode(),!0),Ro=[{key:"Ctrl-b",run:Jt,shift:nn,preventDefault:!0},{key:"Ctrl-f",run:Kt,shift:rn},{key:"Ctrl-p",run:Yt,shift:ln},{key:"Ctrl-n",run:Zt,shift:cn},{key:"Ctrl-a",run:Kr,shift:so},{key:"Ctrl-e",run:_r,shift:lo},{key:"Ctrl-d",run:fn},{key:"Ctrl-h",run:Ve},{key:"Ctrl-k",run:po},{key:"Ctrl-Alt-h",run:mn},{key:"Ctrl-o",run:bo},{key:"Ctrl-t",run:ko},{key:"Ctrl-v",run:$e}],Eo=[{key:"ArrowLeft",run:Jt,shift:nn,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:qr,shift:Zr,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:jr,shift:oo,preventDefault:!0},{key:"ArrowRight",run:Kt,shift:rn,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:$r,shift:Xr,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Jr,shift:io,preventDefault:!0},{key:"ArrowUp",run:Yt,shift:ln,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ft,shift:mt},{mac:"Ctrl-ArrowUp",run:at,shift:ut},{key:"ArrowDown",run:Zt,shift:cn,preventDefault:!0},{mac:"Cmd-ArrowDown",run:dt,shift:gt},{mac:"Ctrl-ArrowDown",run:$e,shift:ht},{key:"PageUp",run:at,shift:ut},{key:"PageDown",run:$e,shift:ht},{key:"Home",run:Gr,shift:ro,preventDefault:!0},{key:"Mod-Home",run:ft,shift:mt},{key:"End",run:Ur,shift:no,preventDefault:!0},{key:"Mod-End",run:dt,shift:gt},{key:"Enter",run:pt,shift:pt},{key:"Mod-a",run:co},{key:"Backspace",run:Ve,shift:Ve,preventDefault:!0},{key:"Delete",run:fn,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:mn,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:go,preventDefault:!0},{mac:"Mod-Backspace",run:yo,preventDefault:!0},{mac:"Mod-Delete",run:xo,preventDefault:!0}].concat(Ro.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),To=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:zr,shift:eo},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Hr,shift:to},{key:"Alt-ArrowUp",run:So},{key:"Shift-Alt-ArrowUp",run:vo},{key:"Alt-ArrowDown",run:Co},{key:"Shift-Alt-ArrowDown",run:Mo},{key:"Mod-Alt-ArrowUp",run:ho},{key:"Mod-Alt-ArrowDown",run:fo},{key:"Escape",run:mo},{key:"Mod-Enter",run:Bo},{key:"Alt-l",mac:"Ctrl-l",run:ao},{key:"Mod-i",run:uo,preventDefault:!0},{key:"Mod-[",run:bn},{key:"Mod-]",run:xn},{key:"Mod-Alt-\\",run:Do},{key:"Shift-Mod-k",run:Ao},{key:"Shift-Mod-\\",run:Yr},{key:"Mod-/",run:kr},{key:"Alt-A",mac:"Ctrl-A",run:Cr},{key:"Ctrl-m",mac:"Shift-Alt-m",run:wo}].concat(Eo),Io={key:"Tab",run:xn,shift:bn},yt=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class _{constructor(e,n,r=0,o=e.length,i,s){this.test=s,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(r,o),this.bufferStart=r,this.normalize=i?l=>i(yt(l)):yt,this.query=this.normalize(n)}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 Hn(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 n=Gn(e),r=this.bufferStart+this.bufferPos;this.bufferPos+=Un(e);let o=this.normalize(n);if(o.length)for(let i=0,s=r,l=!0;;i++){let c=o.charCodeAt(i),a=this.match(c,s,l,this.bufferPos+this.bufferStart,i==o.length-1);if(a)return this.value=a,this;if(i==o.length-1)break;l&&i<n.length&&n.charCodeAt(i)==c?s++:l=!1}}}match(e,n,r,o,i){let s=null;for(let l=0;l<this.matches.length;){let c=this.matches[l],a=!1;this.query.charCodeAt(c.index)==e&&(c.index==this.query.length-1?s={from:c.from,to:o,precise:i&&c.precise}:(c.index++,a=!0)),a?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?s={from:n,to:o,precise:r&&i}:this.matches.push({from:n,index:1,precise:r})),s&&this.test&&!this.test(s.from,s.to,this.buffer,this.bufferStart)&&(s=null),s}}typeof Symbol<"u"&&(_.prototype[Symbol.iterator]=function(){return this});const kn={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ze="gm"+(/x/.unicode==null?"":"u");class Sn{constructor(e,n,r,o=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=kn,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Cn(e,n,r,o,i);this.re=new RegExp(n,Ze+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.iter=e.iter();let s=e.lineAt(o);this.curLineStart=s.from,this.matchPos=xe(e,o),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 n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,o=r+n[0].length;if(this.matchPos=xe(this.text,o+(r==o?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<o||r>this.value.to)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,precise:!0,match:n},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}}}const Ie=new WeakMap;class K{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,r){let o=Ie.get(e);if(!o||o.from>=r||o.to<=n){let l=new K(n,e.sliceString(n,r));return Ie.set(e,l),l}if(o.from==n&&o.to==r)return o;let{text:i,from:s}=o;return s>n&&(i=e.sliceString(n,s)+i,s=n),o.to<r&&(i+=e.sliceString(o.to,r)),Ie.set(e,new K(s,i)),new K(n,i.slice(n-s,r-s))}}class Cn{constructor(e,n,r,o,i){this.text=e,this.to=i,this.done=!1,this.value=kn,this.matchPos=xe(e,o),this.re=new RegExp(n,Ze+(r!=null&&r.ignoreCase?"i":"")),this.test=r==null?void 0:r.test,this.flat=K.get(e,o,this.chunkEnd(o+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,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,o=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,o,n)))return this.value={from:r,to:o,precise:!0,match:n},this.matchPos=xe(this.text,o+(r==o?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=K.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Sn.prototype[Symbol.iterator]=Cn.prototype[Symbol.iterator]=function(){return this});function Po(t){try{return new RegExp(t,Ze),!0}catch{return!1}}function xe(t,e){if(e>=t.length)return e;let n=t.lineAt(e),r;for(;e<n.to&&(r=n.text.charCodeAt(e-n.from))>=56320&&r<57344;)e++;return e}const Oo=t=>{let e=Vn(t,"cm-goto-line");if(e){let s=e.dom.querySelector("input[type=text]");return s&&s.select(),!0}let{state:n}=t,r=String(n.doc.lineAt(t.state.selection.main.head).number),{close:o,result:i}=zn(t,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return i.then(s=>{let l=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!l){t.dispatch({effects:o});return}let c=n.doc.lineAt(n.selection.main.head),[,a,u,h,d]=l,y=h?+h.slice(1):0,m=u?+u:c.number;if(u&&d){let B=m/100;a&&(B=B*(a=="-"?-1:1)+c.number/n.doc.lines),m=Math.round(n.doc.lines*B)}else u&&a&&(m=m*(a=="-"?-1:1)+c.number);let C=n.doc.line(Math.max(1,Math.min(n.doc.lines,m))),k=g.cursor(C.from+Math.max(0,Math.min(y,C.length)));t.dispatch({effects:[o,x.scrollIntoView(k.from,{y:"center"})],selection:k})}),!0},Fo={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Wo=ce.define({combine(t){return ve(t,Fo,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function No(t){return[Ho,zo]}const qo=M.mark({class:"cm-selectionMatch"}),$o=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function xt(t,e,n,r){return(n==0||t(e.sliceDoc(n-1,n))!=T.Word)&&(r==e.doc.length||t(e.sliceDoc(r,r+1))!=T.Word)}function Vo(t,e,n,r){return t(e.sliceDoc(n,n+1))==T.Word&&t(e.sliceDoc(r-1,r))==T.Word}const zo=Ft.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(Wo),{state:n}=t,r=n.selection;if(r.ranges.length>1)return M.none;let o=r.main,i,s=null;if(o.empty){if(!e.highlightWordAroundCursor)return M.none;let c=n.wordAt(o.head);if(!c)return M.none;s=n.charCategorizer(o.head),i=n.sliceDoc(c.from,c.to)}else{let c=o.to-o.from;if(c<e.minSelectionLength||c>200)return M.none;if(e.wholeWords){if(i=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(xt(s,n,o.from,o.to)&&Vo(s,n,o.from,o.to)))return M.none}else if(i=n.sliceDoc(o.from,o.to),!i)return M.none}let l=[];for(let c of t.visibleRanges){let a=new _(n.doc,i,c.from,c.to);for(;!a.next().done;){let{from:u,to:h}=a.value;if((!s||xt(s,n,u,h))&&(o.empty&&u<=o.from&&h>=o.to?l.push($o.range(u,h)):(u>=o.to||h<=o.from)&&l.push(qo.range(u,h)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:t=>t.decorations}),Ho=x.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Uo=({state:t,dispatch:e})=>{let{selection:n}=t,r=g.create(n.ranges.map(o=>t.wordAt(o.head)||g.cursor(o.head)),n.mainIndex);return r.eq(n)?!1:(e(t.update({selection:r})),!0)};function Go(t,e){let{main:n,ranges:r}=t.selection,o=t.wordAt(n.head),i=o&&o.from==n.from&&o.to==n.to;for(let s=!1,l=new _(t.doc,e,r[r.length-1].to);;)if(l.next(),l.done){if(s)return null;l=new _(t.doc,e,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some(c=>c.from==l.value.from))continue;if(i){let c=t.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const jo=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(i=>i.from===i.to))return Uo({state:t,dispatch:e});let r=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(i=>t.sliceDoc(i.from,i.to)!=r))return!1;let o=Go(t,r);return o?(e(t.update({selection:t.selection.addRange(g.range(o.from,o.to),!1),effects:x.scrollIntoView(o.to)})),!0):!1},Y=ce.define({combine(t){return ve(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new si(e),scrollToMatch:e=>x.scrollIntoView(e)})}});class vn{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||Po(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,(n,r)=>r=="n"?`
7
+ `:r=="r"?"\r":r=="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 Zo(this):new _o(this)}getCursor(e,n=0,r){let o=e.doc?e:oe.create({doc:e});return r==null&&(r=o.doc.length),this.regexp?j(this,o,n,r):G(this,o,n,r)}}class Mn{constructor(e){this.spec=e}}function Jo(t,e,n){return(r,o,i,s)=>{if(n&&!n(r,o,i,s))return!1;let l=r>=s&&o<=s+i.length?i.slice(r-s,o-s):e.doc.sliceString(r,o);return t(l,e,r,o)}}function G(t,e,n,r){let o;return t.wholeWord&&(o=Ko(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(o=Jo(t.test,e,o)),new _(e.doc,t.unquoted,n,r,t.caseSensitive?void 0:i=>i.toLowerCase(),o)}function Ko(t,e){return(n,r,o,i)=>((i>n||i+o.length<r)&&(i=Math.max(0,n-2),o=t.sliceString(i,Math.min(t.length,r+2))),(e(be(o,n-i))!=T.Word||e(ke(o,n-i))!=T.Word)&&(e(ke(o,r-i))!=T.Word||e(be(o,r-i))!=T.Word))}class _o extends Mn{constructor(e){super(e)}nextMatch(e,n,r){let o=G(this.spec,e,r,e.doc.length).nextOverlapping();if(o.done){let i=Math.min(e.doc.length,n+this.spec.unquoted.length);o=G(this.spec,e,0,i).nextOverlapping()}return o.done||o.value.from==n&&o.value.to==r?null:o.value}prevMatchInRange(e,n,r){for(let o=r;;){let i=Math.max(n,o-1e4-this.spec.unquoted.length),s=G(this.spec,e,i,o),l=null;for(;!s.nextOverlapping().done;)l=s.value;if(l)return l;if(i==n)return null;o-=1e4}}prevMatch(e,n,r){let o=this.prevMatchInRange(e,0,n);return o||(o=this.prevMatchInRange(e,Math.max(0,r-this.spec.unquoted.length),e.doc.length)),o&&(o.from!=n||o.to!=r)?o:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let r=G(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=G(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}function Qo(t,e,n){return(r,o,i)=>(!n||n(r,o,i))&&t(i[0],e,r,o)}function j(t,e,n,r){let o;return t.wholeWord&&(o=Yo(e.charCategorizer(e.selection.main.head))),t.test&&(o=Qo(t.test,e,o)),new Sn(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:o},n,r)}function be(t,e){return t.slice(U(t,e,!1),e)}function ke(t,e){return t.slice(e,U(t,e))}function Yo(t){return(e,n,r)=>!r[0].length||(t(be(r.input,r.index))!=T.Word||t(ke(r.input,r.index))!=T.Word)&&(t(ke(r.input,r.index+r[0].length))!=T.Word||t(be(r.input,r.index+r[0].length))!=T.Word)}class Zo extends Mn{nextMatch(e,n,r){let o=j(this.spec,e,r,e.doc.length).next();return o.done&&(o=j(this.spec,e,0,n).next()),o.done?null:o.value}prevMatchInRange(e,n,r){for(let o=1;;o++){let i=Math.max(n,r-o*1e4),s=j(this.spec,e,i,r),l=null;for(;!s.next().done;)l=s.value;if(l&&(i==n||l.from>i+10))return l;if(i==n)return null}}prevMatch(e,n,r){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,r,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return e.match[0];if(r=="$")return"$";for(let o=r.length;o>0;o--){let i=+r.slice(0,o);if(i>0&&i<e.match.length)return e.match[i]+r.slice(o)}return n})}matchAll(e,n){let r=j(this.spec,e,0,e.doc.length),o=[];for(;!r.next().done;){if(o.length>=n)return null;o.push(r.value)}return o}highlight(e,n,r,o){let i=j(this.spec,e,Math.max(0,n-250),Math.min(r+250,e.doc.length));for(;!i.next().done;)o(i.value.from,i.value.to)}}const ie=N.define(),Xe=N.define(),q=Ue.define({create(t){return new Pe(ze(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ie)?t=new Pe(n.value.create(),t.panel):n.is(Xe)&&(t=new Pe(t.query,n.value?et:null));return t},provide:t=>Pt.from(t,e=>e.panel)});class Pe{constructor(e,n){this.query=e,this.panel=n}}const Xo=M.mark({class:"cm-searchMatch"}),ei=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),ti=Ft.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(q))}update(t){let e=t.state.field(q);(e!=t.startState.field(q)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return M.none;let{view:n}=this,r=new Wt;for(let o=0,i=n.visibleRanges,s=i.length;o<s;o++){let{from:l,to:c}=i[o];for(;o<s-1&&c>i[o+1].from-500;)c=i[++o].to;t.highlight(n.state,l,c,(a,u)=>{let h=n.state.selection.ranges.some(d=>d.from==a&&d.to==u);r.add(a,u,h?ei:Xo)})}return r.finish()}},{decorations:t=>t.decorations});function ue(t){return e=>{let n=e.state.field(q,!1);return n&&n.query.spec.valid?t(e,n):tt(e)}}const Se=ue((t,{query:e})=>{let{to:n}=t.state.selection.main,r=e.nextMatch(t.state,n,n);if(!r)return!1;let o=g.single(r.from,r.to),i=t.state.facet(Y);return t.dispatch({selection:o,effects:[nt(t,r),i.scrollToMatch(o.main,t)],userEvent:"select.search"}),Ln(t),!0}),Ce=ue((t,{query:e})=>{let{state:n}=t,{from:r}=n.selection.main,o=e.prevMatch(n,r,r);if(!o)return!1;let i=g.single(o.from,o.to),s=t.state.facet(Y);return t.dispatch({selection:i,effects:[nt(t,o),s.scrollToMatch(i.main,t)],userEvent:"select.search"}),Ln(t),!0}),ni=ue((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:g.create(n.map(r=>g.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),ri=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,i=[],s=0;for(let l=new _(t.doc,t.sliceDoc(r,o));!l.next().done;){if(i.length>1e3)return!1;l.value.from==r&&(s=i.length),i.push(g.range(l.value.from,l.value.to))}return e(t.update({selection:g.create(i,s),userEvent:"select.search.matches"})),!0},bt=ue((t,{query:e})=>{let{state:n}=t,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let i=e.nextMatch(n,r,r);if(!i)return!1;let s=i,l=[],c,a,u=[];s.precise?s.from==r&&s.to==o&&(a=n.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:a}),s=e.nextMatch(n,s.from,s.to),u.push(x.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):s=e.nextMatch(n,s.from,s.to);let h=t.state.changes(l);return s&&(c=g.single(s.from,s.to).map(h),u.push(nt(t,s)),u.push(n.facet(Y).scrollToMatch(c.main,t))),t.dispatch({changes:h,selection:c,effects:u,userEvent:"input.replace"}),!0}),oi=ue((t,{query:e})=>{if(t.state.readOnly)return!1;let n=[];for(let o of e.matchAll(t.state,1e9)){let{from:i,to:s,precise:l}=o;l&&n.push({from:i,to:s,insert:e.getReplacement(o)})}if(!n.length)return!1;let r=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:x.announce.of(r),userEvent:"input.replace.all"}),!0});function et(t){return t.state.facet(Y).createPanel(t)}function ze(t,e){var n,r,o,i,s;let l=t.selection.main,c=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!c)return e;let a=t.facet(Y);return new vn({search:((n=e==null?void 0:e.literal)!==null&&n!==void 0?n:a.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=e==null?void 0:e.caseSensitive)!==null&&r!==void 0?r:a.caseSensitive,literal:(o=e==null?void 0:e.literal)!==null&&o!==void 0?o:a.literal,regexp:(i=e==null?void 0:e.regexp)!==null&&i!==void 0?i:a.regexp,wholeWord:(s=e==null?void 0:e.wholeWord)!==null&&s!==void 0?s:a.wholeWord})}function An(t){let e=Ke(t,et);return e&&e.dom.querySelector("[main-field]")}function Ln(t){let e=An(t);e&&e==t.root.activeElement&&e.select()}const tt=t=>{let e=t.state.field(q,!1);if(e&&e.panel){let n=An(t);if(n&&n!=t.root.activeElement){let r=ze(t.state,e.query.spec);r.valid&&t.dispatch({effects:ie.of(r)}),n.focus(),n.select()}}else t.dispatch({effects:[Xe.of(!0),e?ie.of(ze(t.state,e.query.spec)):N.appendConfig.of(ci)]});return!0},Bn=t=>{let e=t.state.field(q,!1);if(!e||!e.panel)return!1;let n=Ke(t,et);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Xe.of(!1)}),!0},ii=[{key:"Mod-f",run:tt,scope:"editor search-panel"},{key:"F3",run:Se,shift:Ce,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Se,shift:Ce,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Bn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:ri},{key:"Mod-Alt-g",run:Oo},{key:"Mod-d",run:jo,preventDefault:!0}];class si{constructor(e){this.view=e;let n=this.query=e.state.field(q).query.spec;this.commit=this.commit.bind(this),this.searchField=S("input",{value:n.search,placeholder:w(e,"Find"),"aria-label":w(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=S("input",{value:n.replace,placeholder:w(e,"Replace"),"aria-label":w(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=S("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=S("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=S("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(o,i,s){return S("button",{class:"cm-button",name:o,onclick:i,type:"button"},s)}this.dom=S("div",{onkeydown:o=>this.keydown(o),class:"cm-search"},[this.searchField,r("next",()=>Se(e),[w(e,"next")]),r("prev",()=>Ce(e),[w(e,"previous")]),r("select",()=>ni(e),[w(e,"all")]),S("label",null,[this.caseField,w(e,"match case")]),S("label",null,[this.reField,w(e,"regexp")]),S("label",null,[this.wordField,w(e,"by word")]),...e.state.readOnly?[]:[S("br"),this.replaceField,r("replace",()=>bt(e),[w(e,"replace")]),r("replaceAll",()=>oi(e),[w(e,"replace all")])],S("button",{name:"close",onclick:()=>Bn(e),"aria-label":w(e,"close"),type:"button"},["×"])])}commit(){let e=new vn({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:ie.of(e)}))}keydown(e){jn(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Ce:Se)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),bt(this.view))}update(e){for(let n of e.transactions)for(let r of n.effects)r.is(ie)&&!r.value.eq(this.query)&&this.setQuery(r.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(Y).top}}function w(t,e){return t.state.phrase(e)}const fe=30,de=/[\s\.,:;?!]/;function nt(t,{from:e,to:n}){let r=t.state.doc.lineAt(e),o=t.state.doc.lineAt(n).to,i=Math.max(r.from,e-fe),s=Math.min(o,n+fe),l=t.state.sliceDoc(i,s);if(i!=r.from){for(let c=0;c<fe;c++)if(!de.test(l[c+1])&&de.test(l[c])){l=l.slice(c);break}}if(s!=o){for(let c=l.length-1;c>l.length-fe;c--)if(!de.test(l[c-1])&&de.test(l[c])){l=l.slice(0,c);break}}return x.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${r.number}.`)}const li=x.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"}}),ci=[q,Ot.low(ti),li],ai="#e5c07b",kt="#e06c75",ui="#56b6c2",hi="#ffffff",ge="#abb2bf",He="#7d8799",fi="#61afef",di="#98c379",St="#d19a66",mi="#c678dd",gi="#21252b",Ct="#2c313a",vt="#282c34",Oe="#353a42",pi="#3E4451",Mt="#528bff",yi=x.theme({"&":{color:ge,backgroundColor:vt},".cm-content":{caretColor:Mt},".cm-cursor, .cm-dropCursor":{borderLeftColor:Mt},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:pi},".cm-panels":{backgroundColor:gi,color:ge},".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:vt,color:He,border:"none"},".cm-activeLineGutter":{backgroundColor:Ct},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Oe},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Oe,borderBottomColor:Oe},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ct,color:ge}}},{dark:!0}),xi=Jn.define([{tag:f.keyword,color:mi},{tag:[f.name,f.deleted,f.character,f.propertyName,f.macroName],color:kt},{tag:[f.function(f.variableName),f.labelName],color:fi},{tag:[f.color,f.constant(f.name),f.standard(f.name)],color:St},{tag:[f.definition(f.name),f.separator],color:ge},{tag:[f.typeName,f.className,f.number,f.changed,f.annotation,f.modifier,f.self,f.namespace],color:ai},{tag:[f.operator,f.operatorKeyword,f.url,f.escape,f.regexp,f.link,f.special(f.string)],color:ui},{tag:[f.meta,f.comment],color:He},{tag:f.strong,fontWeight:"bold"},{tag:f.emphasis,fontStyle:"italic"},{tag:f.strikethrough,textDecoration:"line-through"},{tag:f.link,color:He,textDecoration:"underline"},{tag:f.heading,fontWeight:"bold",color:kt},{tag:[f.atom,f.bool,f.special(f.variableName)],color:St},{tag:[f.processingInstruction,f.string,f.inserted],color:di},{tag:f.invalid,color:hi}]),At=[yi,Nt(xi)];class Lt{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class H{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let o=r.facet(se).markerFilter;o&&(e=o(e,r));let i=e.slice().sort((y,m)=>y.from-m.from||y.to-m.to),s=new Wt,l=[],c=0,a=r.doc.iter(),u=0,h=r.doc.length;for(let y=0;;){let m=y==i.length?null:i[y];if(!m&&!l.length)break;let C,k;if(l.length)C=c,k=l.reduce((b,D)=>Math.min(b,D.to),m&&m.from>C?m.from:1e8);else{if(C=m.from,C>h)break;k=m.to,l.push(m),y++}for(;y<i.length;){let b=i[y];if(b.from==C&&(b.to>b.from||b.to==C))l.push(b),y++,k=Math.min(b.to,k);else{k=Math.min(b.from,k);break}}k=Math.min(k,h);let B=!1;if(l.some(b=>b.from==C&&(b.to==k||k==h))&&(B=C==k,!B&&k-C<10)){let b=C-(u+a.value.length);b>0&&(a.next(b),u=C);for(let D=C;;){if(D>=k){B=!0;break}if(!a.lineBreak&&u+a.value.length>D)break;D=u+a.value.length,u+=a.value.length,a.next()}}let Z=Ei(l);if(B)s.add(C,C,M.widget({widget:new Bi(Z),diagnostics:l.slice()}));else{let b=l.reduce((D,X)=>X.markClass?D+" "+X.markClass:D,"");s.add(C,k,M.mark({class:"cm-lintRange cm-lintRange-"+Z+b,diagnostics:l.slice(),inclusiveEnd:l.some(D=>D.to>k)}))}if(c=k,c==h)break;for(let b=0;b<l.length;b++)l[b].to<=c&&l.splice(b--,1)}let d=s.finish();return new H(d,n,$(d))}}function $(t,e=null,n=0){let r=null;return t.between(n,1e9,(o,i,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!r)r=new Lt(o,i,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new Lt(r.from,i,r.diagnostic)}}),r}function bi(t,e){let n=e.pos,r=e.end||n,o=t.state.facet(se).hideOn(t,n,r);if(o!=null)return o;let i=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(Dn))||t.changes.touchesRange(i.from,Math.max(i.to,r)))}function ki(t,e){return t.field(R,!1)?e:e.concat(N.appendConfig.of(Ti))}const Dn=N.define(),rt=N.define(),wn=N.define(),R=Ue.define({create(){return new H(M.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,o=t.panel;if(t.selected){let i=e.changes.mapPos(t.selected.from,1);r=$(n,t.selected.diagnostic,i)||$(n,null,i)}!n.size&&o&&e.state.facet(se).autoPanel&&(o=null),t=new H(n,o,r)}for(let n of e.effects)if(n.is(Dn)){let r=e.state.facet(se).autoPanel?n.value.length?le.open:null:t.panel;t=H.init(n.value,r,e.state)}else n.is(rt)?t=new H(t.diagnostics,n.value?le.open:null,t.selected):n.is(wn)&&(t=new H(t.diagnostics,t.panel,n.value));return t},provide:t=>[Pt.from(t,e=>e.panel),x.decorations.from(t,e=>e.diagnostics)]}),Si=M.mark({class:"cm-lintRange cm-lintRange-active"});function Ci(t,e,n){let{diagnostics:r}=t.state.field(R),o,i=-1,s=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(c,a,{spec:u})=>{if(e>=c&&e<=a&&(c==a||(e>c||n>0)&&(e<a||n<0)))return o=u.diagnostics,i=c,s=a,!1});let l=t.state.facet(se).tooltipFilter;return o&&l&&(o=l(o,t.state)),o?{pos:i,end:s,above:!0,create(){return{dom:vi(t,o)}}}:null}function vi(t,e){return S("ul",{class:"cm-tooltip-lint"},e.map(n=>En(t,n,!1)))}const Mi=t=>{let e=t.state.field(R,!1);(!e||!e.panel)&&t.dispatch({effects:ki(t.state,[rt.of(!0)])});let n=Ke(t,le.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},Bt=t=>{let e=t.state.field(R,!1);return!e||!e.panel?!1:(t.dispatch({effects:rt.of(!1)}),!0)},Ai=t=>{let e=t.state.field(R,!1);if(!e)return!1;let n=t.state.selection.main,r=$(e.diagnostics,null,n.to+1);return!r&&(r=$(e.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(t.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),Kn(t,r.from,1,{tooltip:Tn,until:o=>o.docChanged||o.newSelection.main.head<r.from||o.newSelection.main.head>r.to}),!0)},Li=[{key:"Mod-Shift-m",run:Mi,preventDefault:!0},{key:"F8",run:Ai}],se=ce.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...ve(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Dt,tooltipFilter:Dt,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,o,i)=>e(r,o,i)||n(r,o,i):e:n,autoPanel:(e,n)=>e||n})}}});function Dt(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function Rn(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;r<n.length;r++){let o=n[r];if(/[a-zA-Z]/.test(o)&&!e.some(i=>i.toLowerCase()==o.toLowerCase())){e.push(o);continue e}}e.push("")}return e}function En(t,e,n){var r;let o=n?Rn(e.actions):[];return S("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},S("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((i,s)=>{let l=!1,c=y=>{if(y.preventDefault(),l)return;l=!0;let m=$(t.state.field(R).diagnostics,e);m&&i.apply(t,m.from,m.to)},{name:a}=i,u=o[s]?a.indexOf(o[s]):-1,h=u<0?a:[a.slice(0,u),S("u",a.slice(u,u+1)),a.slice(u+1)],d=i.markClass?" "+i.markClass:"";return S("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:c,onmousedown:c,"aria-label":` Action: ${a}${u<0?"":` (access key "${o[s]})"`}.`},h)}),e.source&&S("div",{class:"cm-diagnosticSource"},e.source))}class Bi extends Qn{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return S("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class wt{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=En(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class le{constructor(e){this.view=e,this.items=[];let n=o=>{if(!(o.ctrlKey||o.altKey||o.metaKey)){if(o.keyCode==27)Bt(this.view),this.view.focus();else if(o.keyCode==38||o.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(o.keyCode==40||o.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(o.keyCode==36)this.moveSelection(0);else if(o.keyCode==35)this.moveSelection(this.items.length-1);else if(o.keyCode==13)this.view.focus();else if(o.keyCode>=65&&o.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:i}=this.items[this.selectedIndex],s=Rn(i.actions);for(let l=0;l<s.length;l++)if(s[l].toUpperCase().charCodeAt(0)==o.keyCode){let c=$(this.view.state.field(R).diagnostics,i);c&&i.actions[l].apply(e,c.from,c.to)}}else return;o.preventDefault()}},r=o=>{for(let i=0;i<this.items.length;i++)this.items[i].dom.contains(o.target)&&this.moveSelection(i)};this.list=S("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=S("div",{class:"cm-panel-lint"},this.list,S("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Bt(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(R).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(R),r=0,o=!1,i=null,s=new Set;for(e.between(0,this.view.state.doc.length,(l,c,{spec:a})=>{for(let u of a.diagnostics){if(s.has(u))continue;s.add(u);let h=-1,d;for(let y=r;y<this.items.length;y++)if(this.items[y].diagnostic==u){h=y;break}h<0?(d=new wt(this.view,u),this.items.splice(r,0,d),o=!0):(d=this.items[h],h>r&&(this.items.splice(r,h-r),o=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),i=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)o=!0,this.items.pop();this.items.length==0&&(this.items.push(new wt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),o=!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:l,panel:c})=>{let a=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/a:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/a)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),o&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(R),r=$(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:wn.of(r)})}static open(e){return new le(e)}}function Di(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function me(t){return Di(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const wi=x.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:me("#f11")},".cm-lintRange-warning":{backgroundImage:me("orange")},".cm-lintRange-info":{backgroundImage:me("#999")},".cm-lintRange-hint":{backgroundImage:me("#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 Ri(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Ei(t){let e="hint",n=1;for(let r of t){let o=Ri(r.severity);o>n&&(n=o,e=r.severity)}return e}const Tn=_n(Ci,{hideOn:bi}),Ti=[R,x.decorations.compute([R],t=>{let{selected:e,panel:n}=t.field(R);return!e||!n||e.from==e.to?M.none:M.set([Si.range(e.from,e.to)])}),Tn,wi],Ii=[Yn(),Zn(),Xn(),wr(),er(),tr(),nr(),oe.allowMultipleSelections.of(!0),rr(),Nt(dr,{fallback:!0}),or(),ir(),sr(),lr(),cr(),ar(),No(),qt.of([...ur,...To,...ii,...Nr,...hr,...fr,...Li])],Rt=Ge.define();function Oi({path:t,value:e,onChange:n,onSave:r,readOnly:o=!1,height:i=320,testId:s="code-editor-input",id:l,label:c,placeholder:a,hidePreview:u=!1,defaultWrap:h=!1}){const{theme:d}=mr(),y=v.useRef(null),m=v.useRef(null),C=v.useRef({path:t,value:e,readOnly:o,testId:s,id:l,label:c,placeholder:a,defaultWrap:h,theme:d}),k=v.useRef(n);k.current=n;const B=v.useRef(r);B.current=r;const Z=v.useRef(e.includes(`\r
8
8
  `)?`\r
9
9
  `:`
10
10
  `),b=v.useRef(new ne),D=v.useRef(new ne),X=v.useRef(new ne),ot=v.useRef(new ne),it=v.useRef(new ne),[De,In]=v.useState(h||Ee(t)),[ee,we]=v.useState(!1),[st,Pn]=v.useState(e.split(/\r?\n/).length);return v.useEffect(()=>{if(!y.current)return;const p=C.current,te=new x({parent:y.current,state:oe.create({doc:p.value,extensions:[Ii,D.current.of(p.theme==="dark"?At:[]),b.current.of(ct(p.path)),X.current.of([oe.readOnly.of(p.readOnly),x.editable.of(!p.readOnly)]),ot.current.of(x.contentAttributes.of({"aria-label":p.label??`Edit ${p.path}`,"data-testid":p.testId,...p.id?{id:p.id}:{}})),p.placeholder?gr(p.placeholder):[],qt.of([{key:"Mod-s",run:()=>{var z;return(z=B.current)==null||z.call(B),!0}},Io]),it.current.of(p.defaultWrap||Ee(p.path)?x.lineWrapping:[]),Ot.highest(x.theme({"&":{height:"100%",backgroundColor:"rgb(var(--background))",color:"rgb(var(--foreground))",fontSize:"14px"},"@media (max-width: 640px)":{"&":{fontSize:"16px"}},".cm-scroller":{overflow:"auto",fontFamily:'"IBM Plex Mono", Consolas, monospace'},".cm-gutters":{backgroundColor:"rgb(var(--surface-low))",color:"rgb(var(--muted-foreground))",borderRight:"1px solid rgb(var(--border))"},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:"rgb(var(--surface-highest) / 0.4)"},".cm-cursor":{borderLeftColor:"rgb(var(--foreground))"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"rgb(var(--primary) / 0.25)"},".cm-panels, .cm-tooltip":{backgroundColor:"rgb(var(--surface-high))",color:"rgb(var(--foreground))"},".cm-textfield, .cm-button":{background:"rgb(var(--background))",color:"rgb(var(--foreground))",border:"1px solid rgb(var(--control-border))"},".cm-textfield:focus-visible, .cm-button:focus-visible":{outline:"2px solid rgb(var(--focus))",outlineOffset:"3px"},".cm-placeholder":{color:"rgb(var(--muted-foreground))"},".cm-content":{padding:"12px 0"},".cm-line":{padding:"0 12px"}})),x.updateListener.of(z=>{var lt;z.docChanged&&(Pn(z.state.doc.lines),!z.transactions.some(On=>On.annotation(Rt))&&((lt=k.current)==null||lt.call(k,z.state.doc.toString().replace(/\n/g,Z.current))))})]})});return m.current=te,()=>{m.current=null,te.destroy()}},[]),v.useEffect(()=>{var p;(p=m.current)==null||p.dispatch({effects:D.current.reconfigure(d==="dark"?At:[])})},[d]),v.useEffect(()=>{var p;(p=m.current)==null||p.dispatch({effects:b.current.reconfigure(ct(t))}),we(!1)},[t]),v.useEffect(()=>{var p;(p=m.current)==null||p.dispatch({effects:X.current.reconfigure([oe.readOnly.of(o),x.editable.of(!o)])})},[o]),v.useEffect(()=>{var p;(p=m.current)==null||p.dispatch({effects:ot.current.reconfigure(x.contentAttributes.of({"aria-label":c??`Edit ${t}`,"data-testid":s,...l?{id:l}:{}}))})},[l,c,t,s]),v.useEffect(()=>{const p=m.current;p&&(Z.current=e.includes(`\r