orc-ai 0.1.47 → 0.1.49
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.
- package/README.md +2 -2
- package/dist/index.js +568 -521
- package/dist/skills/orc-platform/references/setup.md +2 -2
- package/dist/web/apple-touch-icon.png +0 -0
- package/dist/web/assets/{Agents-DD4xAdLQ.js → Agents-C8dJX8px.js} +3 -3
- package/dist/web/assets/{Attention-V6qCS20I.js → Attention-BHYo8Lwr.js} +2 -2
- package/dist/web/assets/{Audit-bBVclx9F.js → Audit-CS_DZkbJ.js} +1 -1
- package/dist/web/assets/ConfirmDialog-CrSa87VF.js +1 -0
- package/dist/web/assets/Dashboard-V813oIhq.js +1 -0
- package/dist/web/assets/{DocumentWorkspace-PsD0kzUF.js → DocumentWorkspace-CNyVQTjg.js} +1 -1
- package/dist/web/assets/EmptyState-Ctm7L70B.js +1 -0
- package/dist/web/assets/ErrorState-BPTepwiG.js +1 -0
- package/dist/web/assets/{FileEditor-RVlQIVWn.js → FileEditor-Dh29_xCL.js} +1 -1
- package/dist/web/assets/JobWebhooks-TvAY8p1V.js +1 -0
- package/dist/web/assets/{Jobs-DjI_YMAA.js → Jobs-C5ggSs2T.js} +3 -3
- package/dist/web/assets/{Knowledge-DMAOn0iH.js → Knowledge-BpiN3iVE.js} +3 -3
- package/dist/web/assets/{PackageCatalog-X1ZZB-P7.js → PackageCatalog-B1U3vfhW.js} +5 -5
- package/dist/web/assets/{Pager-CMh30dp4.js → Pager-ClYYU9et.js} +1 -1
- package/dist/web/assets/PriorityBadge-BW-A50LE.js +1 -0
- package/dist/web/assets/Projects-DRao5Qpk.js +3 -0
- package/dist/web/assets/ResumeActions-DHTOr6GQ.js +11 -0
- package/dist/web/assets/{Rules-BNiDiUnr.js → Rules-DGKsAbTf.js} +2 -2
- package/dist/web/assets/{Sessions-N3CCkXrg.js → Sessions-CWHU6sYy.js} +3 -3
- package/dist/web/assets/Settings-yW1S2q4F.js +30 -0
- package/dist/web/assets/Skills-BwdXE5nT.js +16 -0
- package/dist/web/assets/SourceEditor-ft02z20v.js +43 -0
- package/dist/web/assets/StatusBadge-C5G1fdZh.js +1 -0
- package/dist/web/assets/TaskDetailSheet-fUSHPFB-.js +11 -0
- package/dist/web/assets/{Tasks-wCQWVIFY.js → Tasks-uRqvmLz7.js} +9 -9
- package/dist/web/assets/Terminals-W5nszLI1.js +120 -0
- package/dist/web/assets/ViewHeader-DXR0ZaMO.js +1 -0
- package/dist/web/assets/Webhooks-lXLoKWdt.js +1 -0
- package/dist/web/assets/{abnfDiagram-VCTEODGH-D6z8wrMR.js → abnfDiagram-VCTEODGH-K8P_VxLi.js} +1 -1
- package/dist/web/assets/{arc-BG4KWrJo.js → arc-BOl9BKfD.js} +1 -1
- package/dist/web/assets/{architectureDiagram-5GKGNRK7-Cl_LN0pI.js → architectureDiagram-5GKGNRK7-DIZ15fO5.js} +2 -2
- package/dist/web/assets/{blockDiagram-I7D4REHJ-DDcSWANX.js → blockDiagram-I7D4REHJ-DMrufypV.js} +1 -1
- package/dist/web/assets/{c4Diagram-7LVT6UL2-1TklobpM.js → c4Diagram-7LVT6UL2-BUUxjwvU.js} +1 -1
- package/dist/web/assets/channel-CQFNQIhG.js +1 -0
- package/dist/web/assets/{chunk-2Q5K7J3B-1ZXhRK9s.js → chunk-2Q5K7J3B-wRIxA2_q.js} +1 -1
- package/dist/web/assets/{chunk-5VM5RSS4--PtYqixL.js → chunk-5VM5RSS4-B6lAVcgQ.js} +1 -1
- package/dist/web/assets/{chunk-F27PBJKO-CnodLCYk.js → chunk-F27PBJKO-DVuei-Pl.js} +1 -1
- package/dist/web/assets/{chunk-IMKFNOWR-Dtujfpt3.js → chunk-IMKFNOWR-CwyogA-y.js} +1 -1
- package/dist/web/assets/{chunk-JWPE2WC7-BhzEb4oh.js → chunk-JWPE2WC7-zdsOarNZ.js} +1 -1
- package/dist/web/assets/{chunk-POPQ4Y6H-CCRH8Odz.js → chunk-POPQ4Y6H-D3ieeKih.js} +1 -1
- package/dist/web/assets/{chunk-SVP7TREG-DvO1oor5.js → chunk-SVP7TREG-CmiQdvOH.js} +1 -1
- package/dist/web/assets/{chunk-TICWLB2K-HSsE-7e0.js → chunk-TICWLB2K-CieIpfOy.js} +1 -1
- package/dist/web/assets/{chunk-XXDRQBXY-CyZDfwNW.js → chunk-XXDRQBXY-BoTHwisB.js} +1 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-B5yD90Df.js +1 -0
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-B5yD90Df.js +1 -0
- package/dist/web/assets/{cose-bilkent-JH36ORCC-COSptbUK.js → cose-bilkent-JH36ORCC-CtGsuuTW.js} +1 -1
- package/dist/web/assets/{cynefin-OW5HDTMX-BjeQd0nx.js → cynefin-OW5HDTMX-vMXgcpgg.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-5FMLGOSQ-D2tfpg5R.js → cynefinDiagram-5FMLGOSQ-kMbm5D7e.js} +1 -1
- package/dist/web/assets/{dagre-GXQ25YYZ-LPFS53FJ.js → dagre-GXQ25YYZ-xmoviGlr.js} +1 -1
- package/dist/web/assets/{diagram-S7CK7UJ4-CJfymrr7.js → diagram-S7CK7UJ4-CguQzzXs.js} +1 -1
- package/dist/web/assets/{diagram-UQ7AKVKN-BxKvn9Ur.js → diagram-UQ7AKVKN-CMX0u7Gf.js} +1 -1
- package/dist/web/assets/{diagram-VSXAHHWV-Nqep4NOh.js → diagram-VSXAHHWV-cuhv3Fvj.js} +1 -1
- package/dist/web/assets/{diagram-VX7I27RA-DLNoOSxD.js → diagram-VX7I27RA-Bp_JbX0e.js} +1 -1
- package/dist/web/assets/{diagram-Z3DM3KII-CY3P-ZPA.js → diagram-Z3DM3KII-oZ6jRSCd.js} +1 -1
- package/dist/web/assets/{download-zED8Kwne.js → download-UgMvjBjR.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-PWID7BFC-ChViZVtc.js → ebnfDiagram-PWID7BFC-DbxnEjb0.js} +1 -1
- package/dist/web/assets/{erDiagram-RLTQ6QDP-ul1XVJVK.js → erDiagram-RLTQ6QDP-Cl5kXPho.js} +1 -1
- package/dist/web/assets/{flowDiagram-HODETNUW-CP6v5LZZ.js → flowDiagram-HODETNUW-DueO0Ju6.js} +1 -1
- package/dist/web/assets/{folder-open-BUB_WGMS.js → folder-open-DojCP5NP.js} +1 -1
- package/dist/web/assets/{ganttDiagram-EL5Y4UJY-DL4TffYj.js → ganttDiagram-EL5Y4UJY-DNjT4iVH.js} +4 -4
- package/dist/web/assets/{gitGraphDiagram-WWUBYQGX-D6vY0fsS.js → gitGraphDiagram-WWUBYQGX-B4aUQ9gY.js} +1 -1
- package/dist/web/assets/{highlighted-body-KPVGNVTW-Cu3NJ2kc.js → highlighted-body-KPVGNVTW-gt1u8RcC.js} +1 -1
- package/dist/web/assets/index-C_jtMgr7.js +412 -0
- package/dist/web/assets/index-CyjfnRiI.css +1 -0
- package/dist/web/assets/{infoDiagram-27XIBGKW-BlFz7M9s.js → infoDiagram-27XIBGKW-CWcOvNAB.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-5VMMS53U-DmwD3lCC.js → ishikawaDiagram-5VMMS53U-ccIPCUs4.js} +1 -1
- package/dist/web/assets/{journeyDiagram-3NMN7TZE-S4Kc25zO.js → journeyDiagram-3NMN7TZE-rRe3uTLu.js} +1 -1
- package/dist/web/assets/{kanban-definition-UXKFOSKX-CjO1NhtQ.js → kanban-definition-UXKFOSKX-tAKCWntJ.js} +1 -1
- package/dist/web/assets/{layout-Dq9Y2uvt.js → layout-7xCiQ5Mn.js} +1 -1
- package/dist/web/assets/{linear-nLdM3nNe.js → linear-WCNhc07o.js} +1 -1
- package/dist/web/assets/{list-CE13IgiY.js → list-BL4eRkIg.js} +1 -1
- package/dist/web/assets/{mermaid-HWGCJPDP-pjgtNVt2.js → mermaid-HWGCJPDP-C8QwWdo5.js} +6 -6
- package/dist/web/assets/{mindmap-definition-YA3MSWOX-DsxpW-uk.js → mindmap-definition-YA3MSWOX-Cj5-j6a7.js} +1 -1
- package/dist/web/assets/{pegDiagram-XKGWAZYB-DOKdX_Ft.js → pegDiagram-XKGWAZYB-BYB3oVZ_.js} +1 -1
- package/dist/web/assets/{pencil-CKDsHvse.js → pencil-gxvh59uO.js} +1 -1
- package/dist/web/assets/{pieDiagram-E7YTZNPT-iifNLjuz.js → pieDiagram-E7YTZNPT-CSbpzXas.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-AXDQQJYC-Ca9EdnrG.js → quadrantDiagram-AXDQQJYC-DKTP6jS5.js} +1 -1
- package/dist/web/assets/{railroadDiagram-O6MQD6OU-DNcc2r4p.js → railroadDiagram-O6MQD6OU-Ct8aPeLX.js} +1 -1
- package/dist/web/assets/{refresh-cw-CBpDF1Q6.js → refresh-cw-BQRdbjy6.js} +1 -1
- package/dist/web/assets/{requirementDiagram-BXWQKSXE-Bo2W4Z-S.js → requirementDiagram-BXWQKSXE-B9hH69zu.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-P5KCCOFB-BX_lnGu7.js → sankeyDiagram-P5KCCOFB-CDqNONxU.js} +1 -1
- package/dist/web/assets/{save-BK4gikTj.js → save-CYoz3QKB.js} +1 -1
- package/dist/web/assets/scroll-area-CU4DGUBA.js +1 -0
- package/dist/web/assets/{sequenceDiagram-WJ2MYXX4-pXgbZI8i.js → sequenceDiagram-WJ2MYXX4-BF77J63J.js} +1 -1
- package/dist/web/assets/{sizeCapture-INFHLROL-Cc-w7K4o.js → sizeCapture-INFHLROL-Dpubco_U.js} +1 -1
- package/dist/web/assets/{stateDiagram-D77RDMKH-BRg29_UM.js → stateDiagram-D77RDMKH-CzslKEYw.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-DKbNjyV-.js +1 -0
- package/dist/web/assets/{swimlanes-42K2YHIH-D1YPvrQr.js → swimlanes-42K2YHIH-bD_tUjo6.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-0wAluWQF.js +8 -0
- package/dist/web/assets/table-D3N_5Wee.js +1 -0
- package/dist/web/assets/tabs-CSlEXoxD.js +1 -0
- package/dist/web/assets/{timeline-definition-24CTP7MA-CvilnfxW.js → timeline-definition-24CTP7MA-owGoHn8z.js} +1 -1
- package/dist/web/assets/trash-2-D3Ey4I09.js +6 -0
- package/dist/web/assets/{upload-BKVutGgF.js → upload-DhVOCWST.js} +1 -1
- package/dist/web/assets/useDetailRoute-j9nlwack.js +1 -0
- package/dist/web/assets/{useJobs-DSLKgV8L.js → useJobs-Dcl-Vim3.js} +1 -1
- package/dist/web/assets/{useKnowledge-BbtBJLNm.js → useKnowledge-gIjk0_I1.js} +1 -1
- package/dist/web/assets/useListSelection-CSQd_Hmx.js +1 -0
- package/dist/web/assets/{useMemories-CPw6917_.js → useMemories-B8Zpz0Qz.js} +1 -1
- package/dist/web/assets/useProjectScope-Dk0mjyHf.js +1 -0
- package/dist/web/assets/useSessions-BrdK-12R.js +1 -0
- package/dist/web/assets/{vennDiagram-4TSXK5OY-yNMm3LJf.js → vennDiagram-4TSXK5OY-D0_6bldW.js} +1 -1
- package/dist/web/assets/view-params-Bm1Qf6KC.js +1 -0
- package/dist/web/assets/{wardleyDiagram-VM6X3IG4-CMCWNcNe.js → wardleyDiagram-VM6X3IG4-D9GbTBKy.js} +1 -1
- package/dist/web/assets/{xychartDiagram-S5SC5T6Z-CMMtcXgw.js → xychartDiagram-S5SC5T6Z-BFqPF2Hl.js} +1 -1
- package/dist/web/badge-96.png +0 -0
- package/dist/web/icon-192.png +0 -0
- package/dist/web/icon-512.png +0 -0
- package/dist/web/icon-maskable-512.png +0 -0
- package/dist/web/index.html +9 -2
- package/dist/web/manifest.webmanifest +36 -0
- package/dist/web/sw.js +123 -0
- package/package.json +1 -1
- package/dist/checksums.txt +0 -5
- package/dist/web/assets/Dashboard-CIh2K0FF.js +0 -1
- package/dist/web/assets/JobWebhooks-CoFraeFc.js +0 -1
- package/dist/web/assets/Settings-C_-DKk-Q.js +0 -20
- package/dist/web/assets/Skills-BpRge1yJ.js +0 -16
- package/dist/web/assets/SourceEditor-DcZduN5g.js +0 -14
- package/dist/web/assets/Terminals-BX77_gra.js +0 -120
- package/dist/web/assets/Webhooks-2tiGvHyx.js +0 -1
- package/dist/web/assets/channel-6li7uxlb.js +0 -1
- package/dist/web/assets/classDiagram-ZZMXUADV-DQx2YVEE.js +0 -1
- package/dist/web/assets/classDiagram-v2-VYDZK3BY-DQx2YVEE.js +0 -1
- package/dist/web/assets/index-CVKguVuJ.js +0 -468
- package/dist/web/assets/index-yWuNUmdj.css +0 -1
- package/dist/web/assets/scroll-area-BrMwE434.js +0 -1
- package/dist/web/assets/stateDiagram-v2-MP3YSRHH-IRoE1WuW.js +0 -1
- package/dist/web/assets/swimlanesDiagram-VR7AAH4N-C2iXhtwv.js +0 -8
- package/dist/web/assets/useProjectScope-Gvzzt8hR.js +0 -1
package/dist/checksums.txt
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
c3caac2335a1eeb6ac70bc80df21236ef1ed24d32d7b229b8922ca52fb0e8557 orc-linux-x64
|
|
2
|
-
90a4d96b2e4833a84f157bc41e50cc640bd427f0ea9a3dbfad5f576be0a3bce5 orc-linux-arm64
|
|
3
|
-
b8c22a5fda7c1d177705838ef44d142f4d05a06d70a76fd9742f58fe79a9b6f5 orc-mac-arm64
|
|
4
|
-
3b7cb59efc7f12889f2c74c7cd10ffbff1bba70ea8a4cb136f537d26135eee7e orc-mac-x64
|
|
5
|
-
dfbf6cdded4411cb855447e8dc39102f3357f661db0c8c9a526255ee93384f08 orc-windows-x64.exe
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as E,m as U,n as V,o as q,p as I,q as J,j as t,E as Q,S as H,s as T,P as S,t as z,v as W,w as L,x as m,y as O,z as v,A as F,D,R as G}from"./index-CVKguVuJ.js";import{u as K}from"./useJobs-DSLKgV8L.js";import{u as X}from"./useMemories-CPw6917_.js";import{u as Y}from"./useProjectScope-Gvzzt8hR.js";function l(o,p){return o.isLoading?"…":o.error?"—":p}function es({projectId:o}){var f,_;const p=E(),a=Y(o),$=U("sm"),i=s=>{const e=new URL(s,window.location.origin);e.searchParams.set("project",a),p({pathname:e.pathname,search:e.search,hash:e.hash})},d=a==="all"||a==="unassigned"?void 0:{project_id:a},c=V(d),{data:b,isLoading:A}=c,u=K(d),{data:N}=u,h=X({project_id:d==null?void 0:d.project_id,limit:1},{enabled:a!=="unassigned"}),P=a==="unassigned"?0:((f=h.data)==null?void 0:f.total)??0,{data:n}=q(),j=I(!0),g=(j.data??[]).filter(s=>a==="all"||(a==="unassigned"?s.project_id===null:s.project_id===a)),w=a==="unassigned"?(N??[]).filter(s=>s.project_id===null):N??[],k=a==="unassigned"?(b??[]).filter(s=>s.project_id===null):b??[],r=k.reduce((s,e)=>(s[e.status]=(s[e.status]??0)+1,s),{}),y=[...k].sort((s,e)=>new Date(e.updated_at).getTime()-new Date(s.updated_at).getTime()).slice(0,8),x=w.filter(s=>s.enabled),R=a==="all"?"All Projects":a==="unassigned"?"Unassigned":((_=n==null?void 0:n.find(s=>s.id===a))==null?void 0:_.name)??"",M=[{label:"Doing",value:l(c,r.doing??0),sub:"in progress",path:"/tasks?view=table&status=doing"},{label:"Review",value:l(c,r.review??0),sub:"awaiting review",path:"/tasks?view=table&status=review"},{label:"Blocked",value:l(c,r.blocked??0),sub:"needs attention",path:"/tasks?view=table&status=blocked"},{label:"Todo",value:l(c,(r.todo??0)+(r.queued??0)),sub:"pending",path:"/tasks?view=board"},{label:"Done",value:l(c,r.done??0),sub:"completed",path:"/tasks?view=table&status=done"}],B=[{label:"Active jobs",value:l(u,x.length),sub:`of ${w.length} total`,path:"/jobs"},{label:"Memories",value:l(h,P),sub:"in this scope",path:J},{label:"Projects",value:(n??[]).filter(s=>s.status==="active").length,sub:"active across workspace",path:"/projects"}];return t.jsxs("div",{"data-activity-preview":!0,"data-testid":"activity-preview",className:"activity-preview",children:[t.jsxs("div",{className:"activity-heading",children:[t.jsxs("div",{children:[t.jsx("h1",{"data-testid":"view-title",children:"Activity"}),t.jsx("p",{"data-testid":"view-meta",children:R||"All projects"})]}),t.jsx("button",{type:"button",className:"activity-primary",onClick:()=>i("/tasks"),children:"View tasks"})]}),[c,u,h,j].some(s=>s.isLoading)&&t.jsx("p",{role:"status",className:"activity-muted mb-4",children:"Loading activity…"}),[{name:"Tasks",query:c},{name:"Jobs",query:u},{name:"Memories",query:h},{name:"Sessions",query:j}].filter(({query:s})=>s.error).map(({name:s,query:e})=>{var C;return t.jsx(Q,{message:`${s}: ${((C=e.error)==null?void 0:C.message)??"Could not load activity"}`,onRetry:()=>e.refetch()},s)}),t.jsx("section",{className:"activity-metrics","aria-label":"Task summary",children:M.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,className:"activity-metric",onClick:()=>i(s.path),children:[t.jsx("span",{className:"activity-metric-label",children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-metric-value",children:s.value}),t.jsx("span",{className:"activity-metric-sub",children:s.sub})]},s.label))}),t.jsx("section",{className:"activity-resources","aria-label":"Workspace summary",children:B.map(s=>t.jsxs("button",{type:"button","data-testid":"stat-card","data-stat-label":s.label,onClick:()=>i(s.path),children:[t.jsx("span",{children:s.label}),t.jsx("span",{"data-testid":"stat-card-value",className:"activity-resource-value",children:s.value}),t.jsx("span",{className:"activity-resource-sub",children:s.sub})]},s.label))}),t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Recent tasks"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/tasks"),children:"View all"})]}),A?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(s=>t.jsx(H,{className:"h-10 w-full"},s))}):y.length===0?t.jsx("p",{className:"activity-empty",children:"No tasks"}):$?t.jsxs(z,{className:"activity-task-table",children:[t.jsx(W,{children:t.jsxs(L,{children:[t.jsx(m,{children:"Task"}),t.jsx(m,{className:"w-36",children:"Status"}),t.jsx(m,{className:"w-28",children:"Priority"}),t.jsx(m,{className:"w-28",children:"Updated"})]})}),t.jsx(O,{children:y.map(s=>t.jsxs(L,{onClick:()=>i(`/tasks/${s.id}`),children:[t.jsx(v,{children:t.jsx("button",{type:"button",className:"activity-task-title",onClick:e=>{e.stopPropagation(),i(`/tasks/${s.id}`)},children:s.title})}),t.jsx(v,{children:t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(T,{status:s.status})})}),t.jsx(v,{children:t.jsx("span",{className:"activity-priority",children:t.jsx(S,{priority:s.priority})})}),t.jsx(v,{className:"activity-muted",children:new Date(s.updated_at).toLocaleDateString()})]},s.id))})]}):t.jsx("div",{className:"activity-task-list",children:y.map(s=>t.jsxs("article",{className:"activity-task-mobile",children:[t.jsx("button",{type:"button",className:"activity-task-title",onClick:()=>i(`/tasks/${s.id}`),children:s.title}),t.jsxs("div",{className:"activity-task-meta",children:[t.jsx("span",{className:"activity-status","data-status":s.status,children:t.jsx(T,{status:s.status})}),t.jsx("span",{className:"activity-priority",children:t.jsx(S,{priority:s.priority})}),t.jsx("span",{children:new Date(s.updated_at).toLocaleDateString()})]})]},s.id))})]}),t.jsxs("div",{className:"activity-secondary",children:[x.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Active jobs"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/jobs"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:x.slice(0,5).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/jobs/${s.id}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name}),t.jsx("span",{className:"activity-muted",children:s.trigger_type})]}),s.last_run_at&&t.jsxs("span",{className:"activity-row-description",children:["Last run ",new Date(s.last_run_at).toLocaleString()]})]},s.id))})]}),g.length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Agent sessions"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/sessions"),children:"View all"})]}),t.jsx("div",{className:"activity-row-list",children:g.slice(0,5).map(s=>t.jsxs("div",{className:"activity-row",children:[t.jsxs("button",{type:"button",className:"w-full text-left","data-testid":"activity-session-link","data-session-id":s.id,onClick:()=>i(`/sessions?session=${encodeURIComponent(s.id)}`),children:[t.jsxs("span",{className:"activity-row-heading",children:[t.jsx("span",{children:s.name??s.agent}),t.jsx("span",{className:"activity-muted",children:F(s.last_activity_at)})]}),t.jsxs("span",{className:"activity-row-description inline-flex items-center gap-2",children:[t.jsx("span",{className:`size-1.5 rounded-full ${D[s.status].dot}`}),s.agent," · ",D[s.status].label,s.task?` · ${s.task.title}`:""]})]}),t.jsx(G,{session:s})]},s.id))})]})]}),a==="all"&&(n??[]).length>0&&t.jsxs("section",{className:"activity-section",children:[t.jsxs("div",{className:"activity-section-heading",children:[t.jsx("h2",{children:"Projects"}),t.jsx("button",{type:"button",className:"activity-text-action",onClick:()=>i("/projects"),children:"View all"})]}),t.jsx("div",{className:"activity-projects",children:(n??[]).filter(s=>s.status==="active").slice(0,6).map(s=>t.jsxs("button",{type:"button",className:"activity-row",onClick:()=>i(`/projects/${s.id}`),children:[t.jsx("span",{className:"activity-row-heading",children:s.name}),s.description&&t.jsx("span",{className:"activity-row-description",children:s.description})]},s.id))})]})]})}export{es as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as S,a as f,b as v,d as j,r as h,j as e,B as b,_ as w,$ as _,L as k,E as R,ab as $}from"./index-CVKguVuJ.js";import{a as F}from"./useJobs-DSLKgV8L.js";function L(t){return S({queryKey:["webhooks",t],queryFn:()=>j.webhooks.list(t),select:s=>s.webhooks})}function D(t){return S({queryKey:["webhook-deliveries",t],queryFn:()=>j.webhooks.deliveries(t),select:s=>s.deliveries,enabled:!!t,refetchInterval:3e3})}function U(){const t=f();return v({mutationFn:s=>j.webhooks.create(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function E(){const t=f();return v({mutationFn:({id:s,...a})=>j.webhooks.update(s,a),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function G(){const t=f();return v({mutationFn:s=>j.webhooks.delete(s),onSuccess:()=>t.invalidateQueries({queryKey:["webhooks"]})})}function P(){return v({mutationFn:t=>j.webhooks.rotate(t)})}function q(t){return[...new Set(t.split(",").map(s=>s.trim()).filter(Boolean))]}function I(t,s,a){return new URL(`/webhooks/${encodeURIComponent(t)}`,new URL(s,a)).href}function z(t){return["localhost","127.0.0.1","[::1]"].includes(new URL(t).hostname)}function N({id:t,testId:s,value:a,onChange:i,placeholder:d}){const[n,r]=h.useState(a.join(", "));return e.jsx(_,{id:t,"data-testid":s,value:n,placeholder:d,onChange:l=>{r(l.target.value),i(l.target.value)}})}function J({projectId:t,onCreated:s}){const a=U(),[i,d]=h.useState(""),[n,r]=h.useState("github"),[l,m]=h.useState(null),u=h.useId();return l?e.jsxs("div",{"data-testid":"webhook-created",className:"space-y-3",children:[e.jsx(W,{hook:l,secret:l.secret}),e.jsx(b,{type:"button",variant:"outline","data-testid":"webhook-setup-done",onClick:()=>{s==null||s(l),m(null),d("")},children:"I've copied the setup details"})]}):e.jsxs("div",{className:"space-y-3","data-testid":"webhook-create-form",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-name`,children:"Webhook name"}),e.jsx(_,{id:`${u}-name`,"data-testid":"webhook-name",value:i,onChange:c=>d(c.target.value),maxLength:100,placeholder:"GitHub repository events"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(w,{htmlFor:`${u}-provider`,children:"Provider"}),e.jsxs("select",{id:`${u}-provider`,"data-testid":"webhook-provider",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:n,onChange:c=>r(c.target.value),children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"generic",children:"Other service (HMAC)"})]})]}),e.jsx("p",{className:"text-xs text-outline",children:"Create the event source here. Connect jobs and choose their event filters in Jobs. No job is required to create a webhook."}),a.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:a.error.message}),e.jsx(b,{type:"button","data-testid":"webhook-create",disabled:!i.trim()||a.isPending,onClick:()=>a.mutate({name:i.trim(),provider:n,project_id:t??null},{onSuccess:m}),children:a.isPending?"Creating...":"Create webhook"})]})}function A({value:t,onChange:s,projectId:a}){const{data:i,error:d,isLoading:n,refetch:r}=L(a),l=i==null?void 0:i.filter(o=>o.project_id===null||o.project_id===a),[m,u]=h.useState(!1);function c(o){t.some(p=>p.webhook_id===o)||s([...t,{webhook_id:o,events:[],actions:[]}])}function y(o,p,x){s(t.map(g=>g.webhook_id===o?{...g,[p]:q(x)}:g))}return e.jsxs("section",{className:"space-y-3 border-y border-border py-4","data-testid":"job-webhook-picker",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Which webhook should trigger this job?"}),d?e.jsx(R,{message:d.message,onRetry:()=>r()}):e.jsxs(e.Fragment,{children:[e.jsx(w,{htmlFor:"job-webhook-source",children:"Configured webhooks"}),e.jsxs("select",{id:"job-webhook-source","data-testid":"job-webhook-select",className:"w-full min-h-11 rounded-md border border-control-border bg-background px-3 text-sm",value:"",disabled:n,onChange:o=>{o.target.value&&c(o.target.value)},children:[e.jsx("option",{value:"",children:n?"Loading webhooks...":"Select an existing webhook"}),(l??[]).filter(o=>!t.some(p=>p.webhook_id===o.id)).map(o=>e.jsxs("option",{value:o.id,children:[o.name,o.enabled?"":" (disabled)"]},o.id))]}),!n&&!(l!=null&&l.length)&&e.jsx("p",{className:"text-xs text-outline",children:"No webhooks configured for this project yet. Create one below or on the Webhooks page."})]}),t.map(o=>{var p;return e.jsxs("div",{className:"space-y-2 border-t border-border pt-3","data-testid":"job-webhook-binding","data-webhook-id":o.webhook_id,children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:((p=l==null?void 0:l.find(x=>x.id===o.webhook_id))==null?void 0:p.name)??o.webhook_id}),e.jsx(b,{type:"button",variant:"ghost",size:"sm","data-testid":"job-webhook-remove",onClick:()=>s(t.filter(x=>x.webhook_id!==o.webhook_id)),children:"Disconnect"})]}),e.jsx(w,{htmlFor:`events-${o.webhook_id}`,children:"Events for this job"}),e.jsx(N,{id:`events-${o.webhook_id}`,testId:"webhook-events",value:o.events,onChange:x=>y(o.webhook_id,"events",x),placeholder:"pull_request, push (blank accepts all)"}),e.jsx(w,{htmlFor:`actions-${o.webhook_id}`,children:"Actions for this job (optional)"}),e.jsx(N,{id:`actions-${o.webhook_id}`,testId:"webhook-actions",value:o.actions,onChange:x=>y(o.webhook_id,"actions",x),placeholder:"opened, synchronize (blank accepts all)"})]},o.webhook_id)}),e.jsx(b,{type:"button",size:"sm",variant:"outline","data-testid":"webhook-add",onClick:()=>u(!m),children:m?"Close new webhook":"Create a webhook"}),m&&e.jsx(J,{projectId:a,onCreated:o=>{c(o.id),u(!1)}})]})}function K({job:t}){const s=F(),[a,i]=h.useState(t.webhooks??[]);return e.jsxs("section",{className:"space-y-3","data-testid":"job-webhooks",children:[!t.enabled&&e.jsx("p",{className:"text-sm text-outline",children:"Job disabled. Configure connections now and enable it from Jobs when ready."}),e.jsx(A,{value:a,onChange:i,projectId:t.project_id??void 0}),s.error&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:s.error.message}),e.jsx(b,{type:"button",size:"sm","data-testid":"job-webhooks-save",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,webhooks:a,trigger_type:"webhook"}),children:"Save connections"}),s.isSuccess&&e.jsx("p",{role:"status",className:"text-xs text-outline",children:"Connections saved."}),e.jsx(k,{className:"inline-block text-sm underline",to:`/webhooks?project=${encodeURIComponent(t.project_id??"all")}`,children:"Manage configured webhooks and deliveries"})]})}function C({label:t,value:s,secret:a=!1}){const[i,d]=h.useState(!1),[n,r]=h.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-outline",children:t}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs","data-testid":a?"webhook-secret":"webhook-url",children:s}),e.jsx(b,{type:"button",size:"sm",variant:"outline","aria-label":`Copy ${t}`,onClick:async()=>{try{await navigator.clipboard.writeText(s),d(!0),r(!1)}catch{r(!0)}},children:i?"Copied":"Copy"})]}),n&&e.jsx("p",{role:"alert",className:"text-xs text-error",children:"Select and copy the value above; clipboard access is unavailable."})]})}function W({hook:t,secret:s}){const a=I(t.token,$(),window.location.origin);return e.jsxs("div",{className:"space-y-3","data-testid":"webhook-setup",children:[e.jsx(C,{label:"Payload URL",value:a}),z(a)&&e.jsx("p",{className:"text-sm text-warning",children:"This address is local. For external providers, use your publicly reachable ORC address with the same /webhooks/ path."}),s?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Signing secret",value:s,secret:!0}),e.jsx("p",{className:"text-xs text-outline",children:"Copy the signing secret before leaving. It is shown once."})]}):e.jsx("p",{className:"text-xs text-outline",children:"The signing secret is hidden. Generate a replacement only if you need to reconnect the sender."}),t.provider==="github"?e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-outline",children:[e.jsx("li",{children:"In your repository, open GitHub Settings - Webhooks - Add webhook."}),e.jsx("li",{children:"Paste the Payload URL, select application/json, and enter the signing secret."}),e.jsx("li",{children:"Select the events needed by your connected jobs. Each job has its own filters."}),e.jsx("li",{children:"Send an event and inspect Recent deliveries below."})]}):e.jsx("p",{className:"text-sm text-outline",children:"Send JSON, signed with HMAC-SHA256 of the raw body. Set X-Orc-Signature-256 to sha256=<hex signature>, X-Orc-Event to the event name and X-Orc-Delivery to a unique delivery ID."})]})}function Q({hook:t}){var u;const s=E(),a=P(),[i,d]=h.useState(!1),[n,r]=h.useState(!1),[l,m]=h.useState();return e.jsxs("article",{className:"space-y-3 border-b border-border pb-5","data-testid":"webhook-endpoint","data-webhook-id":t.id,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:t.name}),e.jsxs("span",{className:"text-xs text-outline",children:[t.provider," - ",t.enabled?"Enabled":"Disabled"]}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:s.isPending,onClick:()=>s.mutate({id:t.id,enabled:!t.enabled}),children:t.enabled?"Disable":"Enable"})]}),e.jsxs("div",{className:"space-y-1","data-testid":"webhook-connected-jobs",children:[e.jsxs("p",{className:"text-xs text-outline",children:["Connected jobs (",t.subscriptions.length,")"]}),t.subscriptions.length?t.subscriptions.map(c=>e.jsxs("div",{className:"text-sm",children:[e.jsx(k,{className:"underline","data-testid":"webhook-job-link",to:`/jobs/${c.job_id}?project=all`,children:c.name}),e.jsxs("span",{className:"text-xs text-outline",children:[" ","- ",c.enabled?"Enabled":"Disabled","; events:"," ",c.events.join(", ")||"all","; actions: ",c.actions.join(", ")||"all"]})]},c.job_id)):e.jsx("p",{className:"text-sm text-outline",children:"No connected jobs. Select this webhook when creating or editing a job."})]}),e.jsx(W,{hook:t,secret:l}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(b,{type:"button",variant:"outline",size:"sm","data-testid":"webhook-deliveries-toggle",onClick:()=>d(!i),children:i?"Hide deliveries":"Recent deliveries"}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(!n),children:"New signing secret"})]}),n&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsx("p",{children:"The sender's existing secret will stop working. Update it after generating the replacement."}),e.jsx(b,{type:"button",variant:"outline",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(t.id,{onSuccess:c=>{m(c.secret),r(!1)}}),children:"Generate replacement secret"})]}),(s.error||a.error)&&e.jsx("p",{role:"alert",className:"text-sm text-error",children:(u=s.error??a.error)==null?void 0:u.message}),i&&e.jsx(H,{id:t.id})]})}function H({id:t}){const{data:s,isLoading:a,error:i,refetch:d}=D(t);return e.jsxs("section",{className:"space-y-2","data-testid":"webhook-deliveries",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Recent deliveries"}),i?e.jsx(R,{message:i.message,onRetry:()=>d()}):a?e.jsx("p",{role:"status",children:"Loading deliveries..."}):s!=null&&s.length?s.map(n=>e.jsxs("div",{className:"space-y-1 border-t border-border py-2 text-xs","data-testid":"webhook-delivery",children:[e.jsxs("div",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[n.event,n.action?` / ${n.action}`:""]}),e.jsx("span",{children:n.status})]}),e.jsxs("p",{className:"text-outline",children:[n.repository," ",new Date(n.created_at).toLocaleString()]}),n.status==="ignored"&&e.jsx("p",{className:"text-outline",children:"No enabled connected job matched this event."}),n.error&&e.jsx("p",{className:"text-error",children:n.error}),n.runs.map(r=>e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs(k,{className:"underline",to:`/jobs/${r.job_id}?project=all`,children:["Job run: ",r.status]}),r.task_id&&e.jsx(k,{className:"underline",to:`/tasks/${r.task_id}?project=all`,children:"Created task"}),r.session_id&&e.jsx(k,{className:"underline",to:`/audit/${r.session_id}?project=all`,children:"Agent session"})]},r.job_run_id))]},n.id)):e.jsx("p",{className:"text-sm text-outline",children:"No events received yet. Register the endpoint with your provider, then send an event."})]})}export{K as J,J as W,G as a,Q as b,A as c,L as u};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{r as m,j as e,I as re,c as M,d as k,c1 as V,_ as p,$ as y,T as K,c2 as ie,B as w,W as oe,an as de,ao as F,ap as T,aq as A,ar as D,as as C,a9 as le,a as X,b as ce,c3 as me,c4 as he,c5 as ue,ai as xe,c6 as ge,c7 as pe,E as fe,bE as be,ab as G,c8 as I,V as ve,c9 as W,ca as q}from"./index-CVKguVuJ.js";import{u as je,a as ye,b as Ne,c as _e}from"./useKnowledge-BbtBJLNm.js";import{D as ke}from"./download-zED8Kwne.js";import{S as Z}from"./save-BK4gikTj.js";var we=Object.defineProperty,ee=(t,n)=>we(t,"name",{value:n,configurable:!0}),z={Horizontal:"horizontal",Vertical:"vertical"},Y=z.Horizontal,Se=Object.values(z),te=m.forwardRef(ee(function(n,h){const{decorative:c,orientation:s=Y,...x}=n,g=se(s)?s:Y,b=g===z.Vertical?g:void 0,v=c?{role:"none"}:{"aria-orientation":b,role:"separator"};return e.jsx(re.div,{"data-orientation":g,...v,...x,ref:h})},"Separator"));function se(t){return Se.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 Ce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ee=M("circle-check-big",Ce);/**
|
|
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 Re=[["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"}]],Pe=M("plug",Re);/**
|
|
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 Ie=[["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",Ie);function Fe(){const[t,n]=m.useState(null),[h,c]=m.useState(""),[s,x]=m.useState(""),[g,b]=m.useState(!1);m.useEffect(()=>{let o=!1;return k.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 k.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(p,{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(p,{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(p,{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(p,{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(p,{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 and serves meta tools that search, describe and invoke every ORC tool on demand. Host configuration may include other MCP servers; this setting does not disable them. Protected workspaces may also require ORC tools."})]}),e.jsx(ie,{config:t,onChange:n,disabled:g}),e.jsx(w,{"data-testid":"chat-settings-save",disabled:g,onClick:()=>void v(),children:g?"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:oe("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 Te(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 Ae={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 De(){var L,$,H,U;const t=je(),n=ye(),h=Ne(),c=_e(),[s,x]=m.useState(null),[g,b]=m.useState(null),[v,o]=m.useState(!1),[d,f]=m.useState(!1),[u,_]=m.useState(!1);if(m.useEffect(()=>{t.data&&x(Te(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(()=>k.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:()=>_(!0),children:[e.jsx(de,{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(()=>k.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(p,{htmlFor:"settings-kb-parser",className:"text-sm text-muted-foreground",children:"Default parser"}),e.jsxs(F,{value:s.parser,onValueChange:a=>l({parser:a}),disabled:N("PARSER"),children:[e.jsx(T,{id:"settings-kb-parser","data-testid":"settings-kb-parser",children:e.jsx(A,{})}),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(p,{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(p,{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(p,{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(p,{htmlFor:"settings-kb-provider",className:"text-sm text-muted-foreground",children:"Embedding provider"}),e.jsxs(F,{value:s.provider,onValueChange:a=>l({provider:a}),disabled:N("EMBEDDING_PROVIDER"),children:[e.jsx(T,{id:"settings-kb-provider","data-testid":"settings-kb-provider",children:e.jsx(A,{})}),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:Ae[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(p,{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(p,{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(p,{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(p,{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."})]})]}),g&&e.jsx("p",{role:"alert","data-testid":"settings-knowledge-error",className:"text-sm text-error",children:g}),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(le,{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:()=>_(!1),onConfirm:async()=>{_(!1),await S(()=>k.kb.uninstallDocling())}})]})}function Me(){const t=X();return ce({mutationFn:async()=>{const n=await k.system.restart(),h=Date.now()+6e4;for(;Date.now()<h;){await new Promise(c=>setTimeout(c,500));try{if((await k.health.check(AbortSignal.timeout(2e3))).instance_id!==n.instance_id)return}catch(c){if(c instanceof me&&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 ze(){const{data:t}=he(),n=Me();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 O="__local__";function J(t){return t?t instanceof Error?t.message:String(t):null}function Le(){var i;const{data:t,error:n,refetch:h}=ue(),{data:c}=xe(),s=ge(),x=pe(),[g,b]=m.useState(O),[v,o]=m.useState("");if(m.useEffect(()=>{t&&(b(t.host??O),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(fe,{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=g===O?null:g,f=t.host&&!t.hosts.includes(t.host)?[t.host,...t.hosts]:t.hosts,u=Number(v),_=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(p,{htmlFor:"ssh-host",className:"font-label text-sm text-muted-foreground",children:"Host"}),e.jsxs(F,{value:g,onValueChange:b,disabled:j,children:[e.jsx(T,{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(A,{})}),e.jsxs(D,{className:"bg-surface-highest border-outline-variant max-h-72",children:[e.jsx(C,{value:O,"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(p,{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&&!_),"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&&!_&&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&&!_||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(Z,{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(Pe,{size:12,className:"mr-1.5"})," ",x.isPending?"Testing…":"Test"]})]}),J(s.error??x.error)&&e.jsx("p",{"data-testid":"ssh-error",className:"font-body text-sm text-error",children:J(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 Ve(){const{theme:t}=be(),[n,h]=m.useState(G),[c,s]=m.useState(()=>localStorage.getItem(I)??""),[x,g]=m.useState(!1),[b,v]=m.useState(""),[o,d]=m.useState(""),[f,u]=m.useState(!1),_=X(),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 k.settings.save({theme:t,terminal_font:c.trim()});W(r.theme??t),s(r.terminal_font??""),r.terminal_font?localStorage.setItem(I,r.terminal_font):localStorage.removeItem(I);const S=(i||"/api")!==G();localStorage.setItem("orc_api_url",i||"/api"),S&&window.dispatchEvent(new Event(q)),_.invalidateQueries(),g(!0),v("Workspace preferences saved on the server. API address saved in this browser."),setTimeout(()=>g(!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 k.settings.save({terminal_font:""});localStorage.removeItem("orc_api_url"),localStorage.setItem(I,i.terminal_font??""),h("/api"),s(i.terminal_font??""),window.dispatchEvent(new Event(q)),_.invalidateQueries(),g(!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 k.settings.save({theme:i});W(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(ve,{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(p,{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(Le,{}),e.jsx(ze,{}),e.jsx(Fe,{}),e.jsx(De,{}),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(p,{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(Ee,{size:12,className:"mr-1.5"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{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{Ve as default};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var Ae=a=>{throw TypeError(a)};var ve=(a,t,i)=>t.has(a)||Ae("Cannot "+i);var j=(a,t,i)=>(ve(a,t,"read from private field"),i?i.call(a):t.get(a)),D=(a,t,i)=>t.has(a)?Ae("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,i),I=(a,t,i,r)=>(ve(a,t,"write to private field"),r?r.call(a,i):t.set(a,i),i),Q=(a,t,i)=>(ve(a,t,"access private method"),i);import{cb as rt,cc as ke,cd as nt,ce as lt,cf as Ye,a as A,cg as ot,ch as ct,r as N,ci as dt,cj as ut,ck as mt,cl as ht,cm as He,cn as xt,co as pt,c as Le,j as e,cp as ft,u as Z,b as $,d as L,aa as me,X as he,Y as xe,Z as pe,B as C,at as fe,ak as Je,_ as de,$ as Y,am as Xe,a1 as ue,a2 as gt,E as Ze,V as yt,al as bt,aD as jt,S as We,ah as vt,t as kt,v as St,w as $e,x as G,aE as Nt,cq as wt,y as Ct,z as V,e as Rt,a4 as Lt,a5 as It,a6 as Ot,a7 as Et,a8 as _t,ae as Te,l as et,M as qt}from"./index-CVKguVuJ.js";import{D as Pt,c as ze}from"./DocumentWorkspace-PsD0kzUF.js";import{u as Kt}from"./useProjectScope-Gvzzt8hR.js";import{r as Dt}from"./primitive-files-BwTyowra.js";import{D as Be}from"./download-zED8Kwne.js";function Me(a,t){const i=new Set(t);return a.filter(r=>!i.has(r))}function Qt(a,t,i){const r=a.slice(0);return r[t]=i,r}var J,_,X,B,P,H,se,ae,ie,re,R,Se,Ne,tt,we,Ce,Re,Ve,Ft=(Ve=class extends rt{constructor(t,i,r){super();D(this,R);D(this,J);D(this,_);D(this,X);D(this,B);D(this,P);D(this,H);D(this,se);D(this,ae);D(this,ie);D(this,re,[]);I(this,J,t),I(this,B,r),I(this,X,[]),I(this,P,[]),I(this,_,[]),this.setQueries(i)}onSubscribe(){this.listeners.size===1&&j(this,P).forEach(t=>{t.subscribe(i=>{Q(this,R,Ce).call(this,t,i)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,j(this,P).forEach(t=>{t.destroy()})}setQueries(t,i){I(this,X,t),I(this,B,i),ke.batch(()=>{const r=j(this,P),o=Q(this,R,we).call(this,j(this,X));o.forEach(y=>y.observer.setOptions(y.defaultedQueryOptions));const n=o.map(y=>y.observer),s=n.map(y=>y.getCurrentResult()),u=r.length!==n.length,d=n.some((y,p)=>y!==r[p]),h=u||d,g=h?!0:s.some((y,p)=>{const w=j(this,_)[p];return!w||!nt(y,w)});!h&&!g||(h&&(I(this,re,o),I(this,P,n)),I(this,_,s),this.hasListeners()&&(h&&(Me(r,n).forEach(y=>{y.destroy()}),Me(n,r).forEach(y=>{y.subscribe(p=>{Q(this,R,Ce).call(this,y,p)})})),Q(this,R,Re).call(this)))})}getCurrentResult(){return j(this,_)}getQueries(){return j(this,P).map(t=>t.getCurrentQuery())}getObservers(){return j(this,P)}getOptimisticResult(t,i){const r=Q(this,R,we).call(this,t),o=r.map(s=>s.observer.getOptimisticResult(s.defaultedQueryOptions)),n=r.map(s=>s.defaultedQueryOptions.queryHash);return[o,s=>Q(this,R,Ne).call(this,s??o,i,n),()=>Q(this,R,Se).call(this,o,r)]}},J=new WeakMap,_=new WeakMap,X=new WeakMap,B=new WeakMap,P=new WeakMap,H=new WeakMap,se=new WeakMap,ae=new WeakMap,ie=new WeakMap,re=new WeakMap,R=new WeakSet,Se=function(t,i){return i.map((r,o)=>{const n=t[o];return r.defaultedQueryOptions.notifyOnChangeProps?n:r.observer.trackResult(n,s=>{i.forEach(u=>{u.observer.trackProp(s)})})})},Ne=function(t,i,r){if(i){const o=j(this,ie),n=r!==void 0&&o!==void 0&&(o.length!==r.length||r.some((s,u)=>s!==o[u]));return(!j(this,H)||j(this,_)!==j(this,ae)||n||i!==j(this,se))&&(I(this,se,i),I(this,ae,j(this,_)),r!==void 0&&I(this,ie,r),I(this,H,lt(j(this,H),i(t)))),j(this,H)}return t},tt=function(){var t;return((t=j(this,B))==null?void 0:t.combine)!==void 0&&j(this,P).some((i,r)=>{var o;return i.options.suspense&&((o=j(this,_)[r])==null?void 0:o.data)===void 0})},we=function(t){const i=new Map;j(this,P).forEach(o=>{const n=o.options.queryHash;if(!n)return;const s=i.get(n);s?s.push(o):i.set(n,[o])});const r=[];return t.forEach(o=>{var d;const n=j(this,J).defaultQueryOptions(o),u=((d=i.get(n.queryHash))==null?void 0:d.shift())??new Ye(j(this,J),n);r.push({defaultedQueryOptions:n,observer:u})}),r},Ce=function(t,i){const r=j(this,P).indexOf(t);r!==-1&&(I(this,_,Qt(j(this,_),r,i)),Q(this,R,Re).call(this))},Re=function(){var t;if(this.hasListeners()){const i=Q(this,R,Se).call(this,j(this,_),j(this,re)),r=Q(this,R,tt).call(this),o=j(this,H),n=r?o:Q(this,R,Ne).call(this,i,(t=j(this,B))==null?void 0:t.combine);(r||o!==n)&&ke.batch(()=>{this.listeners.forEach(s=>{s(j(this,_))})})}},Ve);function At({queries:a,...t},i){const r=A(i),o=ot(),n=ct(),s=N.useMemo(()=>a.map(c=>{const m=r.defaultQueryOptions(c);return m._optimisticResults=o?"isRestoring":"optimistic",m}),[a,r,o]);s.forEach(c=>{dt(c);const m=r.getQueryCache().get(c.queryHash);ut(c,n,m)}),mt(n);const[u]=N.useState(()=>new Ft(r,s,t)),[d,h,g]=u.getOptimisticResult(s,t.combine),y=!o&&t.subscribed!==!1;N.useSyncExternalStore(N.useCallback(c=>y?u.subscribe(ke.batchCalls(c)):ht,[u,y]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),N.useEffect(()=>{u.setQueries(s,t)},[s,t,u]);const w=d.some((c,m)=>He(s[m],c))?d.flatMap((c,m)=>{const v=s[m];if(v&&He(v,c)){const x=new Ye(r,v);return xt(v,x,n)}return[]}):[];if(w.length>0)throw Promise.all(w);const f=d.find((c,m)=>{const v=s[m];return v&&pt({result:c,errorResetBoundary:n,throwOnError:v.throwOnError,query:r.getQueryCache().get(v.queryHash),suspense:v.suspense})});if(f!=null&&f.error)throw f.error;return h(g())}/**
|
|
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 Ht=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],$t=Le("arrow-up-down",Ht);/**
|
|
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 Tt=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],zt=Le("toggle-left",Tt);/**
|
|
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 Bt=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Mt=Le("toggle-right",Bt);function Ut({files:a,selected:t,onSelect:i,testId:r="document-file-tab",entryTestId:o}){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,s)=>e.jsxs("button",{type:"button",role:"tab","aria-selected":n===t,"data-testid":s===0&&o?o:r,"data-file-name":n,title:n,tabIndex:n===t?0:-1,onKeyDown:u=>{var y,p;if(!["ArrowRight","ArrowLeft","Home","End"].includes(u.key))return;u.preventDefault();let h=s;if(u.key==="ArrowRight"&&(h=(s+1)%a.length),u.key==="ArrowLeft"&&(h=(s+a.length-1)%a.length),u.key==="Home"&&(h=0),u.key==="End"&&(h=a.length-1),i(a[h])===!1)return;const g=(y=u.currentTarget.parentElement)==null?void 0:y.querySelectorAll('[role="tab"]');(p=g==null?void 0:g[h])==null||p.focus()},onClick:()=>i(n),className:`flex min-h-11 shrink-0 items-center gap-2 rounded px-3 text-sm ${n===t?"bg-surface-highest text-on-surface":"text-muted-foreground hover:bg-surface-low hover:text-on-surface"}`,children:[e.jsx(ft,{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:t,onChange:n=>i(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 Ue={new:"",installed:"Already in ORC",conflict:"Name taken in ORC (different content)",changed:"Changed since import",invalid:"Invalid"},te=a=>`${a.agent}/${a.name}`;function Gt({onClose:a}){var y,p,w;const[t,i]=N.useState([]),r=A(),o=Z({queryKey:["skills","local-agents"],queryFn:L.skills.localAgents}),n=$({mutationFn:L.skills.importLocal,onSuccess:async f=>{i([]),await r.invalidateQueries({queryKey:["skills"]}),f.skipped.length||a()}}),s=n.isPending,u=((y=o.data)==null?void 0:y.agents)??[],d=new Set(t.map(f=>f.split("/")[1])),h=(f,c)=>i(c?[...t,te(f)]:t.filter(m=>m!==te(f))),g=f=>{const c=[...t],m=new Set(d);for(const v of f)v.status!=="new"||m.has(v.name)||(c.push(te(v)),m.add(v.name));i(c)};return e.jsx(me,{open:!0,onOpenChange:f=>!f&&!s&&a(),children:e.jsxs(he,{className:"max-w-xl",children:[e.jsx(xe,{children:e.jsx(pe,{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."}),o.isLoading&&e.jsx("p",{role:"status",children:"Scanning agent folders…"}),o.data&&!u.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:u.map(f=>{const c=f.skills.filter(m=>m.status==="new");return e.jsxs("section",{"data-testid":"local-agent","data-agent":f.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:f.label}),e.jsx("p",{className:"text-xs text-outline",children:f.dir})]}),e.jsxs(C,{size:"sm",variant:"outline","data-testid":"local-agent-select-all",disabled:s||!c.length,onClick:()=>g(f.skills),children:["Select all new (",c.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:f.skills.map(m=>{const v=t.includes(te(m)),x=!v&&d.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:v,disabled:s||m.status!=="new"||x,onChange:b=>h(m,b.target.checked)}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:m.name}),Ue[m.status]&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:Ue[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(", ")]})]})]},te(m))})})]},f.id)})}),(p=n.data)==null?void 0:p.skipped.map(f=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:["Skipped ",f.name,": ",f.reason]},`${f.agent}/${f.name}`)),(o.error||n.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(w=o.error||n.error)==null?void 0:w.message}),e.jsxs(fe,{children:[e.jsx(C,{variant:"ghost",disabled:s,onClick:a,children:"Close"}),e.jsx(C,{"data-testid":"local-skill-import-submit",disabled:s||!t.length,onClick:()=>n.mutate(t.map(f=>{const[c="",m=""]=f.split("/");return{agent:c,name:m}})),children:n.isPending?"Importing…":`Import selected${t.length?` (${t.length})`:""}`})]})]})})}function Vt({onClose:a}){var y,p,w,f;const[t,i]=N.useState(""),[r,o]=N.useState([]),n=A(),s=$({mutationFn:L.skills.discover,onSuccess:()=>{u.clear(),o([])}}),u=Je((((y=s.data)==null?void 0:y.skills)??[]).filter(c=>!c.installed&&!r.includes(c.path)).map(c=>c.path),`${t}:${((p=s.data)==null?void 0:p.commit)??""}`),d=u.selectedIds,h=$({mutationFn:async()=>{if(!s.data)throw new Error("Discover skills first");const c=[],m=[];for(let v=0;v<d.length;v+=16){const x=d.slice(v,v+16);try{await L.skills.import({source:t.trim(),commit:s.data.commit,paths:x}),m.push(...x)}catch(b){c.push(...x.map(k=>({path:k,error:b instanceof Error?b.message:"Import failed"})))}}return{imported:m,failed:c}},onSuccess:async c=>{await n.invalidateQueries({queryKey:["skills"]}),o(m=>[...m,...c.imported]),u.select(c.failed.map(m=>m.path)),c.failed.length||a()}}),g=s.isPending||h.isPending;return e.jsx(me,{open:!0,onOpenChange:c=>!c&&!g&&a(),children:e.jsxs(he,{className:"max-w-xl",children:[e.jsx(xe,{children:e.jsx(pe,{children:"Import from GitHub"})}),e.jsxs("form",{className:"space-y-4",onSubmit:c=>{c.preventDefault(),s.mutate(t.trim())},children:[e.jsx(de,{htmlFor:"skill-repository",children:"Repository or skills.sh link"}),e.jsx(Y,{id:"skill-repository","data-testid":"skill-repository-input",value:t,disabled:g,onChange:c=>{i(c.target.value),s.reset(),h.reset(),u.clear(),o([])},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(C,{type:"submit","data-testid":"skill-discover",disabled:g||!t.trim(),children:s.isPending?"Discovering…":"Discover skills"})]}),s.data&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-outline",children:[s.data.skills.length," skills found · ",s.data.commit.slice(0,8)]}),!s.data.skills.length&&e.jsx("p",{role:"status",children:"No valid skills found in this source."}),e.jsx(Xe,{resourceLabel:"new skills",count:d.length,allSelected:u.allSelected,someSelected:u.someSelected,onSelectAll:u.selectAll,onClear:u.clear,disabled:g,children:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Imports run in batches of up to 16."})}),e.jsx("div",{className:"max-h-[45vh] overflow-y-auto space-y-2",children:s.data.skills.map(c=>e.jsxs("label",{className:"flex items-start gap-3 border border-surface-highest rounded p-3","data-testid":"remote-skill","data-skill-name":c.name,children:[e.jsx("input",{type:"checkbox","data-testid":"remote-skill-select",checked:d.includes(c.path),disabled:g||c.installed||r.includes(c.path),onChange:()=>u.toggle(c.path)}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:c.name}),(c.installed||r.includes(c.path))&&e.jsx("span",{className:"ml-2 text-xs text-outline",children:"Already installed"}),e.jsx("span",{className:"block text-xs text-outline",children:c.description}),e.jsx("span",{className:"block text-xs text-outline",children:c.path||"Repository root"})]})]},c.path))}),s.data.issues.map(c=>e.jsxs("p",{role:"alert",className:"text-xs text-destructive",children:[c.path,": ",c.error]},c.path))]}),(s.error||h.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:(w=s.error||h.error)==null?void 0:w.message}),!!((f=h.data)!=null&&f.failed.length)&&e.jsxs("div",{role:"alert",className:"text-sm text-destructive",children:[e.jsxs("p",{children:[h.data.imported.length," imported; ",h.data.failed.length," failed. Failed selections retained for retry."]}),h.data.failed.map(c=>e.jsxs("p",{children:[c.path||"Repository root",": ",c.error]},c.path))]}),e.jsxs(fe,{children:[e.jsx(C,{variant:"ghost",disabled:g,onClick:a,children:"Cancel"}),e.jsx(C,{"data-testid":"skill-import-submit",disabled:g||!s.data||!d.length,onClick:()=>h.mutate(),children:h.isPending?"Importing…":`Import selected${d.length?` (${d.length})`:""}`})]})]})})}function Yt({name:a,scope:t,mutation:i}){var d,h;const r=A(),[o,n]=N.useState(""),s=Z({queryKey:["skill-history",a,t],queryFn:()=>L.skills.history(a,t)}),u=$({mutationFn:g=>{if(!i)throw new Error("No active instruction edit");return L.skills.revert(a,{project_id:i.project_id,change_id:g,expected_change_id:i.id,reason:o.trim()})},onSuccess:()=>{r.invalidateQueries({queryKey:["skill"]}),r.invalidateQueries({queryKey:["skills"]}),r.invalidateQueries({queryKey:["skill-history"]}),n("")}});return!((d=s.data)!=null&&d.changes.length)&&!s.error?null:e.jsxs("section",{"data-testid":"skill-history-panel",className:"mb-5 space-y-3",children:[i&&e.jsxs("p",{"data-testid":"skill-mutated-label",className:"text-xs text-primary",children:["Mutated · ",i.project_id?"Project":"Global"," ·"," ",new Date(i.updated_at*1e3).toLocaleString()," · ",i.author]}),e.jsx("h3",{className:"text-sm font-medium",children:"Instruction history"}),e.jsx(Y,{"data-testid":"skill-revert-reason","aria-label":"Reason for reverting instructions",value:o,onChange:g=>n(g.target.value),placeholder:"Reason for reverting..."}),s.error&&e.jsx("p",{role:"alert",children:s.error.message}),u.error&&e.jsx("p",{role:"alert",children:u.error.message}),(h=s.data)==null?void 0:h.changes.map(g=>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:[g.action," · ",g.reason," · ",g.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:g.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:g.raw}),e.jsx(C,{"data-testid":"skill-revert-change",size:"sm",variant:"outline",disabled:!o.trim()||u.isPending,onClick:()=>u.mutate(g.id),children:"Restore instructions before this change"})]},g.id))]})}function Jt({name:a}){const t=A(),[i,r]=N.useState(!1),o=Z({queryKey:["skill-origin",a],queryFn:()=>L.skills.origin(a)}),n=$({mutationFn:d=>L.skills.sync(a,d),onSuccess:async d=>{r(!1),d.applied&&await Promise.all([t.invalidateQueries({queryKey:["skill",a]}),t.invalidateQueries({queryKey:["skills"]}),t.invalidateQueries({queryKey:["skill-origin",a]})])}});if(o.error)return e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:o.error.message});if(!o.data)return null;const s=n.data,u=s&&!s.applied&&s.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/${o.data.repository}/tree/${encodeURIComponent(o.data.ref==="HEAD"?o.data.commit:o.data.ref)}/${o.data.path}`,target:"_blank",rel:"noreferrer",children:o.data.repository})," ","· ",o.data.commit.slice(0,8)]}),e.jsx(C,{"data-testid":"skill-sync",variant:"outline",size:"sm",disabled:n.isPending,onClick:()=>n.mutate({}),children:n.isPending?"Syncing…":"Sync from GitHub"}),(s==null?void 0:s.applied)&&e.jsx("p",{role:"status","data-testid":"skill-sync-status",className:"text-xs",children:s.changed.length?`Synced ${s.changed.length} files. Local edits preserved outside confirmed conflicts.`:"Up to date. Local edits preserved."}),u&&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:s.conflicts.map(d=>e.jsx("li",{children:d},d))}),e.jsx(C,{"data-testid":"skill-sync-review-override",variant:"outline",size:"sm",onClick:()=>r(!0),children:"Review override"})]}),n.error&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n.error.message}),e.jsx(me,{open:i,onOpenChange:d=>!n.isPending&&r(d),children:e.jsxs(he,{children:[e.jsx(xe,{children:e.jsx(pe,{children:"Replace conflicting local edits?"})}),e.jsxs("p",{className:"text-sm",children:["GitHub's version at ",s==null?void 0:s.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:s==null?void 0:s.conflicts.map(d=>e.jsx("li",{children:d},d))}),e.jsxs(fe,{children:[e.jsx(C,{variant:"ghost",disabled:n.isPending,onClick:()=>r(!1),children:"Keep local edits"}),e.jsx(C,{"data-testid":"skill-sync-confirm-override",disabled:n.isPending,onClick:()=>s&&n.mutate({override:!0,expectedCommit:s.commit,expectedRevision:s.revision}),children:n.isPending?"Syncing…":"Replace listed files"})]})]})})]})}function Xt(a){return Z({queryKey:["skills",a],queryFn:()=>L.skills.list(a)})}function Zt(){return Z({queryKey:["skill-visibility"],queryFn:()=>L.skills.visibility()})}function Wt(){const a=A();return $({mutationFn:t=>L.skills.setVisibility(t),onSuccess:t=>{a.setQueryData(["skill-visibility"],t),a.invalidateQueries({queryKey:["skills"]})}})}function Ge(a,t,i={}){return Z({queryKey:["skill",a,t,i],queryFn:()=>L.skills.get(a,t,i),enabled:!!a})}function es(){const a=A();return $({mutationFn:t=>L.skills.create(t),onSuccess:()=>a.invalidateQueries({queryKey:["skills"]})})}const ts={default:"none",asc:"ascending",desc:"descending"},ss={default:$t,asc:wt,desc:Nt},as=[{value:"all",label:"All"},{value:"builtin",label:"Built-in"},{value:"user",label:"User"}],st={builtin:"text-muted-foreground",user:"text-muted-foreground"};function ms({projectId:a}){var Pe,Ke,De,Qe,Fe;const t=Kt(a),i=t==="all"||t==="unassigned"?{scope:"global"}:{project_id:t},[r,o]=ue("skillQuery",""),[n,s]=N.useState(r),[u,d]=ue("source","all",["all","builtin","user"]),[h,g]=ue("skillRepositorySort","default",["default","asc","desc"]),y=ss[h];N.useEffect(()=>s(r),[r]);const{selectedId:p,openDetail:w,closeDetail:f}=gt("/skills","skillName"),[c,m]=N.useState(!1),[v,x]=N.useState(!1),[b,k]=N.useState(!1),O=Zt(),ne=Wt(),le=JSON.stringify([t,r,u]),[Ie,Oe]=N.useState({scope:le,offset:0}),T=Ie.scope===le?Ie.offset:0,{data:q,isLoading:ge,error:Ee,refetch:at}=Xt({...i,q:r||void 0,source:u==="all"?void 0:u,include_hidden:!0,limit:30,offset:T}),oe=q==null?void 0:q.skills,ye=A(),be=(oe??[]).filter(l=>l.source==="user"),W=At({queries:be.map(l=>({queryKey:["skill-origin",l.name],queryFn:()=>L.skills.origin(l.name)}))}),je=be.filter((l,S)=>{var E;return!!((E=W[S])!=null&&E.data)}).map(l=>l.name),M=new Map(be.map((l,S)=>{var E,K;return[l.name,(K=(E=W[S])==null?void 0:E.data)==null?void 0:K.repository]})),_e=[...oe??[]];!r&&h!=="default"&&_e.sort((l,S)=>{const E=M.get(l.name),K=M.get(S.name);if(!E&&K)return 1;if(E&&!K)return-1;const U=(E??"").localeCompare(K??"",void 0,{sensitivity:"base"});return U?h==="asc"?U:-U:l.name.localeCompare(S.name)});const ee=JSON.stringify([t,r,u,T]),qe=N.useRef(ee);qe.current=ee;const F=Je(je,ee),z=$({mutationFn:async({names:l,scope:S})=>({...await Rt(l,async E=>{const K=await L.skills.sync(E);if(!K.applied)throw new Error(`Conflicts: ${K.conflicts.join(", ")}. Open this skill to review.`)}),scope:S}),onSuccess:async()=>{await Promise.all([ye.invalidateQueries({queryKey:["skills"]}),ye.invalidateQueries({queryKey:["skill"]}),ye.invalidateQueries({queryKey:["skill-origin"]})])}}),ce=((Pe=z.data)==null?void 0:Pe.scope)===ee?z.data:void 0;async function it(){const l=await z.mutateAsync({names:F.selectedIds,scope:ee});l.scope===qe.current&&F.select(l.failed.map(S=>S.id))}return Ee?e.jsx(Ze,{message:Ee.message,onRetry:()=>at()}):e.jsxs("div",{children:[e.jsx(yt,{title:"Skills",meta:`${(oe??[]).length} skills`,action:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(C,{"data-testid":"import-skill-button",size:"sm",variant:"outline",onClick:()=>x(!0),children:[e.jsx(Be,{size:12,className:"mr-1"})," Import from GitHub"]}),e.jsxs(C,{"data-testid":"import-local-skills-button",size:"sm",variant:"outline",onClick:()=>k(!0),children:[e.jsx(Be,{size:12,className:"mr-1"})," Import from agents"]}),e.jsxs(C,{"data-testid":"new-skill-button",size:"sm",onClick:()=>m(!0),className:"font-label text-sm ",children:[e.jsx(bt,{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:"Visibility applies to agent discovery across this installation. Hidden skills remain readable by name and available to flows. Modified means the skill instructions were edited."}),(O.error||ne.error)&&e.jsx("p",{role:"alert",className:"text-destructive text-xs mb-2",children:(Ke=O.error||ne.error)==null?void 0:Ke.message}),(De=q==null?void 0:q.broken)==null?void 0:De.map(l=>e.jsxs("p",{role:"alert",className:"text-destructive text-xs mb-2",children:[l.path,": ",l.error]},l.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:as.map(l=>e.jsx("button",{type:"button",onClick:()=>d(l.value),"data-testid":`skill-source-${l.value}`,"aria-pressed":u===l.value,className:`font-label text-sm px-3 py-1.5 border transition-colors ${u===l.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:l.label},l.value))}),e.jsxs("div",{className:"relative min-w-[160px] flex-1",children:[e.jsx(jt,{size:12,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(Y,{"data-testid":"skill-search-input","aria-label":"Search skills",value:n,onChange:l=>s(l.target.value),onKeyDown:l=>l.key==="Enter"&&o(l.currentTarget.value),placeholder:"Search skills...",className:"pl-8 bg-background text-on-surface font-body text-sm placeholder:text-muted-foreground"})]}),e.jsx(C,{"data-testid":"skill-search-submit",variant:"outline",size:"sm",onClick:()=>o(n),className:"font-label text-sm ",children:"Search"})]}),!!je.length&&e.jsxs(Xe,{resourceLabel:"GitHub skills",count:F.selectedIds.length,allSelected:F.allSelected,someSelected:F.someSelected,onSelectAll:F.selectAll,onClear:F.clear,disabled:z.isPending||W.some(l=>l.isPending),children:[e.jsx(C,{"data-testid":"skills-bulk-sync",variant:"outline",size:"sm",disabled:z.isPending,onClick:()=>void it(),children:z.isPending?"Syncing…":"Sync selected from GitHub"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Local edits are preserved; conflicts require review."})]}),W.some(l=>l.error)&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Could not check GitHub origins: ",(Fe=(Qe=W.find(l=>l.error))==null?void 0:Qe.error)==null?void 0:Fe.message]}),ce&&e.jsxs("div",{"data-testid":"skills-bulk-result",role:"status",className:"mb-3 text-sm",children:[e.jsxs("p",{children:[ce.succeeded.length," synced; ",ce.failed.length," need attention."]}),ce.failed.map(l=>e.jsxs("button",{type:"button",className:"block text-left text-destructive underline",onClick:()=>w(l.id),children:[l.id,": ",l.error]},l.id))]}),ge?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((l,S)=>e.jsx(We,{className:"h-10 w-full bg-surface-highest"},S))}):(oe??[]).length===0?e.jsx(vt,{message:r?"No skills match your search":"No skills found"}):e.jsx("div",{className:"overflow-hidden",children:e.jsxs(kt,{children:[e.jsx(St,{children:e.jsxs($e,{className:"border-b border-outline-variant hover:bg-transparent",children:[e.jsx(G,{className:"w-12",children:e.jsx("span",{className:"sr-only",children:"Select GitHub skills"})}),e.jsx(G,{className:"font-label text-sm text-muted-foreground",children:"Name"}),e.jsx(G,{className:"font-label text-sm text-muted-foreground",children:"Description"}),e.jsx(G,{className:"font-label text-sm text-muted-foreground w-24",children:"Source"}),e.jsx(G,{"data-testid":"skill-repository-header","aria-sort":ts[h],children:e.jsxs("button",{type:"button","data-testid":"skill-repository-sort",className:"flex min-h-11 items-center gap-2 text-sm text-muted-foreground hover:text-on-surface",onClick:()=>{g(h==="default"?"asc":h==="asc"?"desc":"default")},title:"Sort by GitHub repository: ascending, descending, then default order",children:["GitHub repository ",e.jsx(y,{size:14,"aria-hidden":"true"})]})}),e.jsx(G,{className:"text-xs text-muted-foreground",children:"Agent discovery"})]})}),e.jsx(Ct,{children:_e.map(l=>e.jsxs($e,{"data-testid":"skill-row","data-skill-name":l.name,className:"border-b border-outline-variant/50 hover:bg-surface-low cursor-pointer",onClick:()=>w(l.name),children:[e.jsx(V,{onClick:S=>S.stopPropagation(),children:je.includes(l.name)&&e.jsx("input",{type:"checkbox","data-testid":"skill-select","aria-label":`Select ${l.name}`,checked:F.selectedIds.includes(l.name),disabled:z.isPending,onChange:()=>F.toggle(l.name),className:"size-4 accent-primary"})}),e.jsxs(V,{className:"font-body text-sm font-medium text-on-surface",children:[e.jsx("button",{type:"button","data-testid":"skill-open",className:"min-h-11 text-left hover:text-primary",onClick:S=>{S.stopPropagation(),w(l.name)},children:l.name}),l.mutation&&e.jsx("span",{className:"ml-2 text-primary text-xs",children:"Modified"})]}),e.jsx(V,{className:"font-body text-sm text-muted-foreground max-w-md truncate",children:l.description||"—"}),e.jsx(V,{"data-testid":"skill-source-cell",children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${st[l.source]}`,children:l.source})}),e.jsx(V,{"data-testid":"skill-repository-cell",onClick:S=>S.stopPropagation(),className:"max-w-56 truncate text-sm text-muted-foreground",children:M.get(l.name)?e.jsx("a",{"data-testid":"skill-repository-link",href:`https://github.com/${M.get(l.name)}`,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",title:M.get(l.name),children:M.get(l.name)}):"—"}),e.jsx(V,{onClick:S=>S.stopPropagation(),children:e.jsxs("button",{type:"button",role:"switch","aria-label":`${l.name} visible to agents`,"aria-checked":!l.discovery_hidden,"data-testid":`skill-visibility-${l.name}`,disabled:!O.data||ne.isPending,className:"inline-flex min-h-11 items-center gap-2 text-xs text-primary disabled:opacity-50",title:l.discovery_hidden?"Show in agent discovery":"Hide from agent discovery",onClick:()=>{var K,U;const S=new Set(((K=O.data)==null?void 0:K.hidden_skills)??[]),E=new Set(((U=O.data)==null?void 0:U.hidden_builtins)??[]);l.discovery_hidden?(S.delete(l.name),E.delete(l.name)):S.add(l.name),ne.mutate({hidden_skills:[...S],hidden_builtins:[...E]})},children:[l.discovery_hidden?e.jsx(zt,{size:22,"aria-hidden":"true",className:"text-muted-foreground"}):e.jsx(Mt,{size:22,"aria-hidden":"true"}),l.discovery_hidden?"Hidden":"Visible",l.mutation&&" (Modified)"]})})]},l.name))})]})}),q&&q.total>30&&e.jsxs("div",{className:"flex items-center justify-end gap-3 mt-4","data-testid":"skills-pagination",children:[e.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":"skills-page-summary",children:[T+1,"–",Math.min(T+q.skills.length,q.total)," of"," ",q.total]}),e.jsx(C,{variant:"outline",size:"sm","data-testid":"skills-previous",disabled:T===0||ge,onClick:()=>Oe({scope:le,offset:Math.max(0,T-30)}),children:"Previous"}),e.jsx(C,{variant:"outline",size:"sm","data-testid":"skills-next",disabled:q.next_offset===null||ge,onClick:()=>Oe({scope:le,offset:q.next_offset??T}),children:"Next"})]}),e.jsx(is,{scope:i,skillName:p,open:!!p,onClose:f},p),c&&e.jsx(rs,{open:c,onClose:()=>m(!1)}),v&&e.jsx(Vt,{onClose:()=>x(!1)}),b&&e.jsx(Gt,{onClose:()=>k(!1)})]})}function is({skillName:a,scope:t,open:i,onClose:r}){const{data:o,isLoading:n,error:s,refetch:u}=Ge(a,void 0,t),d=o,[h,g]=ue("skillFile","SKILL.md"),y=Ge(a,h??"SKILL.md",t),p=y.data,w=A(),[f,c]=N.useState(!1),m=`skill:${t.project_id??"global"}:${a}:${h??"SKILL.md"}`;function v(b){return(b??"SKILL.md")===(h??"SKILL.md")?!0:ze(m)?(g(b??"SKILL.md"),!0):!1}const x=d?e.jsx(Ut,{files:["SKILL.md",...(d.files??[]).map(b=>b.name)],selected:h??"SKILL.md",onSelect:b=>v(b==="SKILL.md"?void 0:b),testId:"skill-file",entryTestId:"skill-show-entry"}):null;return e.jsx(Lt,{open:i,onOpenChange:b=>!b&&ze(m)&&r(),children:e.jsxs(It,{className:"w-screen max-w-full sm:w-[1120px] sm:max-w-[96vw]",children:[e.jsxs(Ot,{children:[e.jsx(Et,{children:(d==null?void 0:d.name)??"Skill Details"}),(d==null?void 0:d.description)&&e.jsx("p",{className:"font-body text-sm text-muted-foreground mt-1",children:d.description})]}),e.jsx(_t,{children:e.jsxs(e.Fragment,{children:[a&&d&&e.jsx(Yt,{name:a,scope:t,mutation:d.mutation}),a&&d&&e.jsx(Jt,{name:a}),s?e.jsx(Ze,{message:s.message,onRetry:()=>void u()}):n||!d?e.jsx("div",{className:"space-y-3",children:[...Array(4)].map((b,k)=>e.jsx(We,{className:"h-8 w-full bg-surface-highest"},k))}):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(Te,{label:"Source",children:e.jsx("span",{className:`inline-flex py-0.5 font-label text-sm ${st[d.source]}`,children:d.source})}),e.jsx(Te,{label:"Path",children:e.jsx("code",{className:"font-mono text-sm text-muted-foreground break-all",children:d.path})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-label text-sm text-muted-foreground mb-2",children:h??"SKILL.md"}),e.jsxs("div",{className:"overflow-hidden",children:[(p==null?void 0:p.encoding)==="base64"&&e.jsx("div",{className:"p-3",children:x}),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(et,{path:h??"SKILL.md",value:(p==null?void 0:p.content)??"",readOnly:!0,hidePreview:!0,height:400,testId:"skill-file-content"}):e.jsx(Pt,{documentId:m,expanded:f,onExpandedChange:c,navigation:x,path:h??"SKILL.md",content:(p==null?void 0:p.content)??"",testId:"skill-file-content",onSave:d.source==="user"&&(p==null?void 0:p.encoding)==="utf8"?async(b,k)=>{const O=h??"SKILL.md";return d.mutation&&O==="SKILL.md"?await L.skills.updateInstructions(d.name,{project_id:t.project_id??null,content:b,expected_content:k,reason:"Manual instruction edit",author:"human"}):await L.skills.editFile(d.name,{path:O,content:b,expectedContent:k}),await w.invalidateQueries({queryKey:["skill",d.name]}),await w.invalidateQueries({queryKey:["skills"]}),await w.invalidateQueries({queryKey:["skill-history",d.name]}),b}: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 rs({open:a,onClose:t}){var v;const[i,r]=N.useState(""),[o,n]=N.useState(""),s=es(),[u,d]=N.useState([]),[h,g]=N.useState(),[y,p]=N.useState(!1),w=!!(i||o||u.length);N.useEffect(()=>{if(!w)return;function x(b){b.preventDefault(),b.returnValue=""}return window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[w]);function f(){s.isPending||y||(!w||window.confirm("Discard this unsaved skill?"))&&t()}async function c(x){if(x!=null&&x.length){p(!0),g(void 0);try{const b=(await Dt(x)).map(O=>({...O,encoding:O.encoding??"utf8",id:crypto.randomUUID()})),k=b.find(O=>O.path==="SKILL.md");if(!k)throw new Error("Choose a skill folder containing SKILL.md");if(k.encoding!=="utf8")throw new Error("SKILL.md must be UTF-8 text");n(k.content),r(x[0].webkitRelativePath.split("/")[0]),d(b.filter(O=>O!==k))}catch(b){g(b.message)}finally{p(!1)}}}const m=()=>{!i.trim()||!o.trim()||s.isPending||y||u.some(x=>!x.path.trim())||s.mutate({name:i.trim(),content:o.trim(),files:u.map(({path:x,content:b,encoding:k})=>({path:x,content:b,encoding:k}))},{onSuccess:t})};return e.jsx(me,{open:a,onOpenChange:x=>!x&&f(),children:e.jsxs(he,{className:"bg-surface border-outline-variant w-[calc(100%_-_1rem)] max-w-5xl max-h-[94dvh] overflow-y-auto",children:[e.jsx(xe,{children:e.jsx(pe,{className:"font-headline text-base text-on-surface",children:"New skill"})}),e.jsxs("form",{onSubmit:x=>{x.preventDefault(),m()},className:"space-y-3 mt-2",children:[e.jsx(de,{htmlFor:"skill-folder-input",children:"Import skill folder"}),e.jsx(Y,{id:"skill-folder-input","data-testid":"skill-folder-input",type:"file",multiple:!0,webkitdirectory:"",onChange:x=>void c(x.target.files)}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(de,{className:"font-label text-sm text-muted-foreground",children:"Name *"}),e.jsx(Y,{"aria-label":"Name","data-testid":"skill-name-input",value:i,onChange:x=>r(x.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(de,{className:"font-label text-sm text-muted-foreground",children:"SKILL.md *"}),e.jsx(qt,{testId:"skill-content-input",path:"SKILL.md",value:o,onChange:n,onSave:m})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{"data-testid":"skill-add-file",type:"button",variant:"outline",onClick:()=>d([...u,{id:crypto.randomUUID(),path:"",content:"",encoding:"utf8"}]),children:"Add file"}),u.map(x=>e.jsxs("div",{"data-testid":"skill-supporting-file",className:"space-y-2 border border-outline-variant p-3",children:[e.jsx(Y,{"data-testid":"skill-file-path-input","aria-label":"File path",placeholder:"references/guide.md or scripts/check.py",value:x.path,onChange:b=>d(u.map(k=>k.id===x.id?{...k,path:b.target.value}:k))}),e.jsx(et,{testId:"skill-file-content-input",path:x.path||"supporting.txt",readOnly:x.encoding==="base64",label:`Content of ${x.path||"supporting file"}`,value:x.content,height:180,onChange:b=>d(u.map(k=>k.id===x.id?{...k,content:b}:k))}),x.encoding==="base64"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Binary asset (base64)"}),e.jsx(C,{type:"button",variant:"ghost",onClick:()=>d(u.filter(b=>b.id!==x.id)),children:"Remove file"})]},x.id))]}),(h||s.error)&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:h??((v=s.error)==null?void 0:v.message)}),e.jsxs(fe,{children:[e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:f,className:"font-label text-sm text-muted-foreground",children:"Cancel"}),e.jsx(C,{"data-testid":"skill-submit",type:"submit",size:"sm",disabled:y||s.isPending||!i.trim()||!o.trim()||u.some(x=>!x.path.trim()),className:"font-label text-sm ",children:s.isPending?"Creating...":"Create"})]})]})]})})}export{ms as default};
|
|
@@ -1,14 +0,0 @@
|
|
|
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,k as Ee,bG as ct,bH as gr,j as E,aD as pr,ad as yr}from"./index-CVKguVuJ.js";/**
|
|
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 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
|
-
`)?`\r
|
|
9
|
-
`:`
|
|
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
|
|
11
|
-
`)?`\r
|
|
12
|
-
`:`
|
|
13
|
-
`,p.state.doc.toString()!==e.replace(/\r\n/g,`
|
|
14
|
-
`)&&p.dispatch({changes:{from:0,to:p.state.doc.length,insert:e},annotations:Rt.of(!0)}))},[e]),E.jsxs("div",{"data-testid":"code-editor","data-file-path":t,"data-read-only":o,className:"flex min-h-0 flex-col overflow-hidden rounded-sm border border-control-border",style:{height:i},children:[E.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-surface-highest px-2 py-1 text-xs",children:[E.jsxs("span",{className:"min-w-0 flex-1 truncate text-outline",title:t,children:[t,o?" · Read-only":""]}),!u&&Ee(t)&&E.jsx("button",{type:"button","data-testid":"code-editor-preview-toggle","aria-pressed":ee,onClick:()=>we(!ee),className:"rounded px-2 py-1 hover:bg-surface-highest",children:ee?"Show source":"Preview Markdown"}),E.jsx("button",{type:"button","aria-label":"Find in file",title:"Find (Ctrl/Cmd+F)",onClick:()=>{we(!1),m.current&&tt(m.current)},className:"inline-flex min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 items-center justify-center rounded p-1 text-outline hover:bg-surface-highest",children:E.jsx(pr,{size:14})}),E.jsx("button",{type:"button","aria-label":"Word wrap",title:"Word wrap","aria-pressed":De,onClick:()=>{var te;const p=!De;In(p),(te=m.current)==null||te.dispatch({effects:it.current.reconfigure(p?x.lineWrapping:[])})},className:`inline-flex min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 items-center justify-center rounded p-1 hover:bg-surface-highest ${De?"text-primary":"text-outline"}`,children:E.jsx(br,{size:14})})]}),E.jsx("div",{ref:y,className:`min-h-0 flex-1 overflow-hidden ${ee?"hidden":""}`}),ee&&E.jsx("div",{"data-testid":"code-editor-markdown-preview",className:"min-h-0 flex-1 overflow-auto p-3",children:E.jsx(yr,{children:e})}),E.jsxs("footer",{className:"shrink-0 border-t border-surface-highest px-3 py-1 text-[10px] text-outline",children:[st," ",st===1?"line":"lines"," · UTF-8"]})]})}export{Oi as SourceEditor};
|