@kabmo-labs/kabmo 0.39.0 → 0.39.1
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/dist/client/index.html +1 -1
- package/dist/client/index.js +270 -270
- package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-7synegzg.js} +1 -1
- package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-v5d9n5yw.js} +1 -1
- package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-ww7y98tt.js} +1 -1
- package/dist/client/static/js/{ImageView-nreh25s0.js → ImageView-t3rkypzs.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-0x1q1q5z.js → LayoutWrapper-th2pd4yt.js} +1 -1
- package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-qj39shgb.js} +1 -1
- package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-t9v4datp.js} +1 -1
- package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-yqy0a1xg.js} +1 -1
- package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-6zkxbjd4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-7rt2p1y1.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-b04e26rb.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-32ph2m52.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-hwnaa333.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-5v3rzdxd.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-7er2jwy1.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-yf61ftn0.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-cn3rs9xn.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-7kvtsj6c.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-g3zg3r5e.js} +1 -1
- package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-f9j396wm.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-227xs61z.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-4671gdym.js} +1 -1
- package/dist/client/static/js/{index-a7qccdq2.js → index-28a5kf88.js} +1 -1
- package/dist/client/static/js/{index-ymp2wqtc.js → index-35mh9kbs.js} +1 -1
- package/dist/client/static/js/{index-3fw3sd10.js → index-4c2zcvem.js} +7 -7
- package/dist/client/static/js/{index-jkph8wqq.js → index-4ry8kz8h.js} +1 -1
- package/dist/client/static/js/{index-v8vjh5jj.js → index-668chrpq.js} +1 -1
- package/dist/client/static/js/{index-8qgwj6m8.js → index-6rs8e8ng.js} +1 -1
- package/dist/client/static/js/{index-56w8m083.js → index-7qc2avfy.js} +1 -1
- package/dist/client/static/js/{index-5kvvb0zm.js → index-87qandgr.js} +1 -1
- package/dist/client/static/js/{index-ntx3bbmb.js → index-8xasfxf3.js} +1 -1
- package/dist/client/static/js/{index-gvkc9e32.js → index-d3prrt2q.js} +1 -1
- package/dist/client/static/js/{index-4pehdq5h.js → index-f1nqk6z6.js} +1 -1
- package/dist/client/static/js/{index-pzqsp5jw.js → index-f73v86a3.js} +1 -1
- package/dist/client/static/js/{index-270y5r9k.js → index-fjqp03xe.js} +1 -1
- package/dist/client/static/js/{index-mmsszqvn.js → index-fs3pbqwn.js} +1 -1
- package/dist/client/static/js/{index-xdqsqhnn.js → index-h8rr48px.js} +1 -1
- package/dist/client/static/js/{index-dmd26a1y.js → index-hdd8nqz8.js} +1 -1
- package/dist/client/static/js/{index-me7m3516.js → index-j2g39xq7.js} +1 -1
- package/dist/client/static/js/{index-dt22v9ns.js → index-jze0zg3z.js} +1 -1
- package/dist/client/static/js/{index-m3r0j562.js → index-kkfbd1db.js} +1 -1
- package/dist/client/static/js/{index-7h5n5rz4.js → index-m847wafq.js} +1 -1
- package/dist/client/static/js/{index-y2prm0xm.js → index-mtadrbxt.js} +1 -1
- package/dist/client/static/js/{index-7z63xr1s.js → index-phm1zb8m.js} +1 -1
- package/dist/client/static/js/{index-p89z1qmj.js → index-qbnd827h.js} +1 -1
- package/dist/client/static/js/{index-8w2tx2k9.js → index-s80x8d58.js} +1 -1
- package/dist/client/static/js/{index-ywpdhntc.js → index-tmnnafht.js} +1 -1
- package/dist/client/static/js/{index-hh05xd1d.js → index-vb3srfyc.js} +1 -1
- package/dist/client/static/js/{index-k61tdd4a.js → index-w0rbyw47.js} +1 -1
- package/dist/client/static/js/{index-5a4w58r2.js → index-w0xvdda9.js} +1 -1
- package/dist/client/static/js/{index-878d61js.js → index-wfcgqjzr.js} +1 -1
- package/dist/client/static/js/{index-pr7gk5eq.js → index-wgvysmnr.js} +1 -1
- package/dist/client/static/js/{index-mdxnhndy.js → index-xfr6r539.js} +1 -1
- package/dist/client/static/js/{index-k3c3n69j.js → index-xnk1500f.js} +2 -2
- package/dist/client/static/js/{index-61qjr1k0.js → index-y5ymgp20.js} +2 -2
- package/dist/client/static/js/{index-k5a6r25s.js → index-y91j4t1q.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +1 -1
- package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-0gafsqrm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +1 -1
- package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
- package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-66mn2qnt.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +1 -1
- package/dist/client/static/js/{rust-jatm47v6.js → rust-jvkbr060.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zk37paj9.js → swimlanesDiagram-TC7HE7FX-d48g5gjf.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/terminal/attach-replay.test.ts +80 -17
- package/src/server/plugins/static.test.ts +23 -1
- package/src/server/plugins/static.ts +24 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
- package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
- package/dist/client/static/js/one-light-czk9dzya.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d,n,o,i,u,a,oe,pn,ga,Ri,Pg,e,w,s,Ao,E,ne,De,$a,Tn,xn,m,Vn,Le,Xt,L,_,Ls,en,Aa,Qn,Ms,ha,tn,wt,kr,f,B,ie,ba,Jo,qr,Xo,re,tt,Ua,fe,Ce,Ct,qe,Nt,nt,ge,Qe,Ga,de,bo,ya,Hr,Kr,sn,nn,va,ni,Mi,ka,Vr,Fn,Pi,Y,vo,Cr,D,Rt,O,ko,xo,pr,mr,Yn,Ft,_e,Yr,Ui,b,qg,ji,Sp,Hl,Tp,Hg,Mn,ri,Dp,G,Wg,rt,Jr,Ge,jf,Lu,Jn,Et,at,pe,ot,qi,J,jt,qt,Hf,Ie,Rp,je,he,Gs,Ki,rn,dA,pA,Mp,mA,fA,Pp,gA,Op,$p,Eo,AA,hA,zp,Wf,Up,ee,Ht,Wt,lt,qa,Kp,kA,xA,wA,CA,EA,BA,IA,Xl,_A,Vp,SA,TA,Yp,DA,ec,Gu,Zr,tc,Jp,Io,Ha,Xr,Ea,Zp,ju,Xp,Yf,NA,RA,FA,Jf,em,ht,_t,Ws,LA,Zf,fn,Vi,Wa,nc,nm,Yi,bt,So,rm,Xf,PA,eg,qu,am,ac,OA,ea,oc,$A,zA,om,im,tg,sm,UA,ic,sc,lm,lc,Ji,cm,He,cc,Zi,uc,Xi,Vs,dc,pc,mc,um}from"./index-3fw3sd10.js";import{vt,md,fd,gd,Kc,Ad,hd,ul,Jc,cs,dl,fi}from"./index-dt22v9ns.js";import{ra,pu,Cs,vg,mu,fu}from"./index-5kvvb0zm.js";import{ml,Ta,Ag,hg,fl,bg,yg,ws}from"./index-7h5n5rz4.js";var Ic={name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]},Bo=s(Ic);var Ac={name:"square-check-big",size:24,node:[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-square"]},_o=s(Ac);var Rc={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]},Je=s(Rc);var Mc={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]},Ko=s(Mc);var Ec={name:"calendar-range",size:24,node:[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M17 13h-6",key:"1qbiup"}],["path",{d:"M13 17H7",key:"1x38vv"}],["path",{d:"M7 13h.01",key:"1vezk1"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]},zo=s(Ec);var Lc={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]},Ho=s(Lc);var Oc={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]},Bt=s(Oc);var Dc={name:"dice-5",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]},Go=s(Dc);var Uc={name:"dollar-sign",size:24,node:[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]},Wo=s(Uc);var Fc={name:"file-diff",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]},qo=s(Fc);var jc={name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]},Vo=s(jc);var $c={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]},Yo=s($c);var Bc={name:"hammer",size:24,node:[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]},Qo=s(Bc);var _c={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]},Zo=s(_c);var zc={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]},mt=s(zc);var Hc={name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]},er=s(Hc);var Gc={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]},Kt=s(Gc);var Wc={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]},tr=s(Wc);var qc={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]},zt=s(qc);var Vc={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]},nr=s(Vc);var Yc={name:"power",size:24,node:[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]},or=s(Yc);var Xc={name:"store",size:24,node:[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]},dt=s(Xc);var Qc={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]},Gt=s(Qc);var Zc={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]},On=s(Zc);var ep={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]},rr=s(ep);var tp={name:"waypoints",size:24,node:[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]]},Dn=s(tp);function ir(t,r,l){let c={},p=typeof l==="function"?Object.keys(r):Object.keys(l);for(let h of p)if(r[h]!==t[h])c[h]=r[h];return c}var ar="color";var sr=["color","monochrome"];function np(t){return t==="color"||t==="monochrome"}function lr(t){return np(t)?t:"color"}var dr={color:{label:"Full colour",description:"The shipped app icon, plate and all. Matches the icon in the Dock, the taskbar and the launcher.",caption:"App icon"},monochrome:{label:"Monochrome",description:"A greyscale conversion of the app icon: the green plate and the cream strokes swap luminance with the theme, and the orange arm becomes the middle grey.",caption:"Greyscale"}};var cr={theme:Gs,editorFont:Gu,editorTheme:tc,autoSessionTitle:!0,soundAlerts:!0,chatCompletionSound:!0,notifyDesktopEnabled:!0,notifyMobileEnabled:!0,notifyOnFinish:!1,notifyOnAsk:!1,notifyOnError:!1,goalAuditEnabled:!0,goalAuditModel:"",goalDefaultBudget:null,chatWidthMode:Kp,toolRenderStyle:wA,showChangedFiles:!0,sidebarStyle:Ag,composerStyle:IA,surfaceStyle:SA,iconStyle:mA,trayIconStyle:ar,followUpBehavior:"queue",keybindingSend:"Enter",keybindingNewLine:"Shift + Enter",keybindingSteering:"Ctrl / Cmd + Enter"};function ur(){let[t,r]=n(!1),l=a(async()=>{r(!0);try{let c=await fetch("/api/omp/reload-engine",{method:"POST"}),p=await c.json().catch(()=>null);if(!c.ok||!p?.success)return{ok:!1,message:p?.error??`Reload failed (HTTP ${c.status})`};Io(),Xr();let h=p.utility??0,g=p.prewarmed??0;return{ok:!0,message:h+g===0?"No standby omp processes were running — the next command starts the current build.":`Reloaded omp engine — ${h} utility, ${g} prewarmed process${h+g===1?"":"es"} recycled.`}}catch(c){return{ok:!1,message:c instanceof Error?c.message:"Failed to reload the omp engine."}}finally{r(!1)}},[]);return{isReloading:t,reload:l}}function gr(t={}){let{restart:r}=t,[l,c]=n(!1),p=a(async()=>{c(!0);try{let h=await ju(r),g=await fetch("/api/console/restart",{method:"POST"}),v=await g.json().catch(()=>null);if(!g.ok||!v?.success)return{ok:!1,message:v?.error??`Restart failed (HTTP ${g.status})`};if(!v.restarting)return{ok:!1,message:v.message??"This instance cannot be restarted from the console."};let x=await Xp(h,r);if(x==="restarted")return window.location.reload(),{ok:!0,message:v.message??"Restarting — this page reloads on its own."};if(x==="timeout")return{ok:!1,message:`The server did not come back within ${Math.round((r?.timeoutMs??Zp)/1000)} seconds — reload this page once it is up.`};return{ok:!1,message:"The restart was cancelled."}}catch(h){return{ok:!1,message:h instanceof Error?h.message:"Failed to restart Kabmo."}}finally{c(!1)}},[r]);return{isRestarting:l,restart:p}}function br(t,r){if(typeof document<"u"&&r.theme)Up(r.theme);if(typeof window<"u"&&r.editorFont!==t.editorFont)window.dispatchEvent(new CustomEvent(em,{detail:r.editorFont}));if(typeof window<"u"&&r.editorTheme!==t.editorTheme)window.dispatchEvent(new CustomEvent(md,{detail:r.editorTheme}));if(r.chatWidthMode!==t.chatWidthMode)Yf(r.chatWidthMode);if(r.toolRenderStyle!==t.toolRenderStyle)NA(r.toolRenderStyle);if(r.showChangedFiles!==t.showChangedFiles)RA(r.showChangedFiles);if(r.sidebarStyle!==t.sidebarStyle)yg(r.sidebarStyle);if(r.composerStyle!==t.composerStyle)FA(r.composerStyle);if(r.surfaceStyle!==t.surfaceStyle)Jf(r.surfaceStyle);if(r.iconStyle!==t.iconStyle)Wf(r.iconStyle)}var fr=["KABMO","CONNECT","WORKSPACE","OMP","HARNESSES"];var hr=[{id:"appearance",label:"Appearance",icon:ka,section:"KABMO",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:sn,section:"KABMO",description:"Chat width, composer style, tool call rendering, session titles, and goal mode."},{id:"keyboard",label:"Keyboard",icon:ya,section:"KABMO",description:"Every command shortcut, the composer Enter keys, and chord conflicts."},{id:"notifications",label:"Notifications",icon:ha,section:"KABMO",description:"Completion sound, separate Desktop and Mobile delivery switches, and the finished, waiting-for-you and failed run triggers."},{id:"usage",label:"Usage",icon:Ao,section:"KABMO",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:Xo,section:"KABMO",description:"Token telemetry, cache, and cost breakdown."},{id:"panel-plugins",label:"Plugins Kabmo",icon:vo,section:"KABMO",description:"Plugins installed into Kabmo: panels, background services, and the MCP servers they register."},{id:"connect",label:"Connect",icon:Cr,section:"CONNECT",description:"Tunnels, addresses, and the devices paired to this server."},{id:"projects",label:"Projects",icon:Vo,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:Ua,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:Ho,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:wt,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:Bo,section:"OMP",description:"Native AGENTS.md and RULES.md: global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:_e,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:kr,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"plugins",label:"Plugins",icon:Pi,section:"OMP",description:"Installed omp plugins, marketplaces, features, and plugin settings."},{id:"skills",label:"Skills",icon:er,section:"OMP",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:tn,section:"OMP",description:"Browse and install new skills."},...Zf().map((t)=>({id:t.id,label:t.label,icon:Dn,section:"HARNESSES",...t.harness?{harness:t.harness}:{},description:t.description}))];function vr(t){let r=Zf(t&&t.length>0?t:void 0).map((c)=>({id:c.id,label:c.label,icon:Dn,section:"HARNESSES",...c.harness?{harness:c.harness}:{},description:c.description}));return[...hr.filter((c)=>c.section!=="HARNESSES"),...r]}function Un({activeCategory:t,onSelectCategory:r,searchQuery:l,onSearchChange:c,onReloadOmp:p,isReloading:h,onRestartKabmo:g,isRestarting:v,disabledHarnesses:x=[],categories:y=hr,className:k=""}){let P=y.filter((N)=>{if(N.harness&&x.includes(N.harness))return!1;if(!l.trim())return!0;let A=l.toLowerCase();return N.label.toLowerCase().includes(A)||N.section.toLowerCase().includes(A)||N.description.toLowerCase().includes(A)});return e("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${k}`,children:[e("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:e("div",{className:"relative flex items-center",children:[e(O,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",placeholder:"Search settings",value:l,onChange:(N)=>c(N.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),l&&e("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:e(b,{size:12})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:P.length===0?e("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):fr.map((N)=>{let A=P.filter((C)=>C.section===N);if(A.length===0)return null;return e("div",{className:"space-y-1",children:[e("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:N}),e("div",{className:"space-y-0.5",children:A.map((C)=>{let R=C.icon,S=t===C.id;return e("button",{type:"button",onClick:()=>r(C.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${S?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center space-x-2.5 truncate",children:[C.harness?e("span",{className:"flex w-[14px] shrink-0 items-center justify-center",children:e(ht,{harness:C.harness,size:14})}):e(R,{size:14,className:S?"text-ink":"text-ink/60"}),e("span",{className:"truncate",children:C.label})]}),C.badge&&e("span",{className:"px-1.5 py-0.2 text-[10px] font-mono font-medium rounded border border-warning/30 bg-warning/15 text-warning",children:C.badge})]},C.id)})})]},N)})}),e("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:h||v,title:"Recycle the standby omp processes so the next command uses the installed binary","aria-label":"Reload OMP",className:"shrink-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(D,{size:12,className:`shrink-0 ${h?"animate-spin text-warning":"text-ink/60"}`}),e("span",{className:"whitespace-nowrap",children:h?"Reloading…":"Reload OMP"})]}),e("button",{type:"button",onClick:g,disabled:h||v,title:"Stop and start this Kabmo instance","aria-label":"Restart Kabmo",className:"flex-1 min-w-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(or,{size:12,className:`shrink-0 ${v?"animate-pulse text-warning":"text-ink/60"}`}),e("span",{className:"truncate",children:v?"Restarting…":"Restart Kabmo"})]})]})]})}function xr({theme:t,selected:r,onSelect:l}){return e("button",{type:"button",onClick:()=>l(t.id),"aria-pressed":r,className:`group flex w-full flex-col gap-2.5 rounded-lg border p-2.5 text-left transition-all cursor-pointer ${r?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("div",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:t.name,children:t.name}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:t.variant}),r&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("div",{className:"flex items-center gap-1",children:pA.map((c)=>e("span",{title:`${c.label} · ${t[c.key]}`,style:{backgroundColor:t[c.key]},className:"h-5 flex-1 rounded-[3px] border border-ink/10"},c.key))})]})}var op=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function rp(t){return t==="all"?Ki:Ki.filter((r)=>r.variant===t)}function yr({selectedId:t,onSelect:r}){let[l,c]=n("all"),p=u(()=>rp(l),[l]);return e("div",{className:"space-y-3 pb-6",children:[e("div",{className:"flex items-center gap-1.5",children:[op.map((h)=>e("button",{type:"button",onClick:()=>c(h.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${l===h.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[h.id==="light"&&e(Gt,{size:11,className:"mr-1 inline align-[-1px]"}),h.id==="dark"&&e(zt,{size:11,className:"mr-1 inline align-[-1px]"}),h.label]},h.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:[p.length," themes"]})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3",children:p.map((h)=>e(xr,{theme:h,selected:h.id===t,onSelect:r},h.id))})]})}function ct({width:t,active:r=!1,trailing:l=!1}){return e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:`h-[5px] w-[5px] shrink-0 rounded-full ${r?"bg-ink":"bg-ink/25"}`}),e("span",{className:`h-[3px] rounded-full ${r?"bg-ink/70":"bg-ink/25"}`,style:{width:`${t}%`}}),l&&e("span",{className:"ml-auto h-[3px] w-[6px] rounded-full bg-ink/20"})]})}function ip(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[7px] w-[30%] rounded-sm bg-ink/80"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"})]}),e("span",{className:"flex h-[7px] items-center gap-1 px-1",children:e("span",{className:"h-[3px] w-[45%] rounded-full bg-ink/45"})}),e(ct,{width:62,trailing:!0}),e(ct,{width:50,active:!0,trailing:!0}),e(ct,{width:44,trailing:!0}),e(ct,{width:56,trailing:!0})]})}function ap(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex h-[7px] items-center rounded-sm bg-ink/5 px-1",children:e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/30"})}),e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[6px] w-[16%] rounded-full bg-ink/80"}),e("span",{className:"h-[6px] w-[22%] rounded-full border border-ink/20"}),e("span",{className:"h-[6px] w-[12%] rounded-full border border-ink/20"})]}),e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:"h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50"}),e("span",{className:"h-[3px] w-[40%] rounded-full bg-ink/45"}),e("span",{className:"ml-auto h-[3px] w-[5px] rounded-full bg-ink/20"})]}),e(ct,{width:62,active:!0,trailing:!0}),e(ct,{width:50,trailing:!0}),e(ct,{width:44,trailing:!0})]})}var sp={classic:ip,modern:ap};function wr({settings:t,onUpdate:r}){let l=fl(t.sidebarStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Session sidebar"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"How the left column draws its workspaces and chats. Both styles list the same workspaces and offer the same actions; the choice applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Session sidebar style",children:hg.map((c)=>{let p=bg[c],h=c===l,g=sp[c];return e("button",{type:"button",onClick:()=>r({sidebarStyle:c}),"aria-pressed":h,"aria-label":`${p.label} sidebar — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[86px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function Sr({backdropFilter:t,reducedTransparency:r}){let l=[];if(!t)l.push("no-backdrop-filter");if(r)l.push("reduced-transparency");return l}var Nr={"no-backdrop-filter":"This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.","reduced-transparency":"Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material."};var Pr="(prefers-reduced-transparency: reduce)";function lp(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;return CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function Tr(){let[t,r]=n(()=>typeof window>"u"?!1:window.matchMedia(Pr).matches);return o(()=>{let l=window.matchMedia(Pr),c=()=>r(l.matches);return c(),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[]),Sr({backdropFilter:lp(),reducedTransparency:t})}function Ir(){return e("span",{className:"flex h-full flex-col gap-1 p-1",children:[e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/40"}),e("span",{className:"ml-auto h-[6px] w-[10%] rounded-[2px] border border-ink/20"})]}),e("span",{className:"h-[2px] w-full rounded-full bg-ink/15"}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[52%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[18%] rounded-full bg-ink/15"})]}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[44%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[22%] rounded-full bg-ink/15"})]})]})}function dp(){return e("span",{className:"block h-full rounded-md border border-ink/15 bg-paper","aria-hidden":"true",children:[e("span",{className:"block h-[13px] rounded-t-[5px] border-b border-ink/10 bg-paper",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/35"})}),e(Ir,{})]})}function cp(){return e("span",{className:"relative block h-full overflow-hidden rounded-md border border-ink/15 bg-canvas","aria-hidden":"true",children:[e("span",{className:"pointer-events-none absolute inset-0",children:[e("span",{className:"absolute -left-2 top-2 h-[70%] w-[55%] rounded-full bg-info/40 blur-md"}),e("span",{className:"absolute -right-2 -top-2 h-[60%] w-[50%] rounded-full bg-meta/35 blur-md"}),e("span",{className:"absolute -bottom-2 right-3 h-[45%] w-[45%] rounded-full bg-success/30 blur-md"})]}),e("span",{className:"relative block h-[13px] border-b border-ink/10 bg-paper/40",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/40"})}),e("span",{className:"relative block h-[calc(100%-13px)] bg-paper/50",children:e(Ir,{})})]})}var pp={classic:dp,glass:cp};function up(){let t=Tr();if(t.length===0)return null;return e("ul",{className:"space-y-1 rounded-lg border border-ink/15 bg-ink/[0.03] p-2.5","aria-live":"polite",children:t.map((r)=>e("li",{className:"flex gap-1.5 text-[11px] leading-relaxed text-ink/60",children:[e("span",{"aria-hidden":"true",className:"mt-[5px] h-1 w-1 shrink-0 rounded-full bg-ink/40"}),e("span",{children:Nr[r]})]},r))})}function Ar({settings:t,onUpdate:r}){let l=Yp(t.surfaceStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Surfaces"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"What the windows are made of. Both styles draw the same panels, rows and dialogs; the frost is one blur pass per window, and it follows the palette — there is no separate glass colour to tune."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Surface style",children:TA.map((c)=>{let p=DA[c],h=c===l,g=pp[c];return e("button",{type:"button",onClick:()=>r({surfaceStyle:c}),"aria-pressed":h,"aria-label":`${p.label} surfaces — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[78px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})}),l==="glass"&&e(up,{})]})}function mp(t){return rn(t).paper}function jn({name:t,Icon:r,colored:l,paper:c}){let p=AA(t),h=!l?void 0:p?$p[p]:Eo(hA(t),"light",c);return e(r,{size:13,strokeWidth:2,style:h?{color:h}:void 0,"aria-hidden":"true"})}function Rr({name:t,base:r,colored:l}){let c=l?r:void 0;return e("span",{className:"flex h-5 w-5 items-center justify-center rounded-[5px] border border-ink/10",style:c?{backgroundColor:`${c}22`,color:c}:void 0,title:t,"aria-hidden":"true",children:e("span",{className:`block h-2 w-2 rounded-full ${l?"":"bg-ink/60"}`,style:c?{backgroundColor:c}:void 0})})}function Mr({colored:t,paper:r}){return e("span",{className:"flex h-full items-center gap-1.5 rounded-md border border-ink/10 bg-canvas/60 px-2",children:[e(jn,{name:"Trash2",Icon:L,colored:t,paper:r}),e(jn,{name:"Check",Icon:f,colored:t,paper:r}),e(jn,{name:"Sparkles",Icon:Le,colored:t,paper:r}),e("span",{className:"mx-0.5 h-4 w-px bg-ink/10"}),e(Rr,{name:"claude",base:Op.claude.light,colored:t}),e(Rr,{name:"Typescript",base:zp.Typescript.light,colored:t})]})}function Er({settings:t,onUpdate:r}){let l=Pp(t.iconStyle),c=mp(t.theme),p={monochrome:()=>e(Mr,{colored:!1,paper:c}),color:()=>e(Mr,{colored:!0,paper:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Icons"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Every icon: toolbar and panel glyphs, provider logos and file-type marks. Full colour gives each glyph its own hue and keeps the palette’s red, green, amber and blue for signals; a colour that would disappear on the active theme falls back to the ink. A control that sets its own colour keeps it."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Icon style",children:fA.map((h)=>{let g=gA[h],v=h===l,x=p[h];return e("button",{type:"button",onClick:()=>r({iconStyle:h}),"aria-pressed":v,"aria-label":`${g.label} icons — ${g.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:g.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:g.description})]},h)})})]})}function gp(){return e("span",{className:"flex h-full items-center justify-center rounded-md border border-ink/10 bg-canvas/60",children:e("img",{src:"/icon.svg",alt:"",width:26,height:26,className:"rounded-[6px]","aria-hidden":"true"})})}function bp({variant:t}){return e("span",{className:"flex h-full items-center justify-center rounded-md border border-ink/10 bg-canvas/60",children:e("img",{src:`/tray-monochrome-${t}.png`,alt:"",width:26,height:26,"aria-hidden":"true"})})}function Lr({settings:t,onUpdate:r}){let l=lr(t.trayIconStyle),c=rn(t.theme).variant,p={color:gp,monochrome:()=>e(bp,{variant:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Tray icon"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"The menu-bar (macOS) or notification-area (Windows, Linux) icon. Full colour is the shipped app icon, orange arm and all; monochrome is a greyscale conversion: the green plate and the cream strokes swap luminance with the theme, and the orange arm becomes the middle grey. Applies the next time the tray starts, or immediately when it is already running."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Tray icon style",children:sr.map((h)=>{let g=dr[h],v=h===l,x=p[h];return e("button",{type:"button",onClick:()=>r({trayIconStyle:h}),"aria-pressed":v,"aria-label":`${g.label} tray icon — ${g.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:g.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:g.description})]},h)})})]})}function Or({settings:t,onUpdate:r}){let l=t.editorFont||ec[0].id;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(Yr,{size:16,className:"text-ink/60"}),"Editor Font"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:"Typeface for the code editor and its line numbers, in both the desktop panel and the phone's full-screen editor. Only Fira Code ships with the app; the others are used when your device has them, and fall back to Fira Code when it does not."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ec.map((c)=>{let p=l===c.id;return e("button",{type:"button",onClick:()=>r({editorFont:c.id}),"aria-pressed":p,className:`flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-colors ${p?"border-ink/40 bg-ink/5":"border-ink/12 hover:bg-ink/5"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate text-xs text-ink",style:{fontFamily:`"${c.id}", monospace`},children:"const greet = () => 'hi'"}),e("span",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-ink/50",children:[e("span",{children:c.label}),c.bundled&&e("span",{className:"rounded bg-ink/8 px-1 py-px text-[10px] uppercase tracking-wide",children:"Bundled"})]})]}),p&&e(f,{size:14,className:"text-ink flex-shrink-0"})]},c.id)})})]})}var fp=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function hp(t){return`"${ec.find((l)=>l.id===t)?.id??ec[0].id}", monospace`}function vp({theme:t,face:r}){return e("span",{className:"block overflow-hidden rounded border border-ink/10",style:{backgroundColor:t.bg,color:t.fg},children:e("span",{className:"block px-1.5 py-1 font-mono text-[10px] leading-[1.4]",style:{fontFamily:r},children:[e("span",{style:{color:t.keyword},children:"const"})," ",e("span",{children:"answer"})," ",e("span",{style:{color:t.keyword},children:"="})," ",e("span",{style:{color:t.string},children:"42"}),e("span",{children:";"}),e("span",{className:"block truncate",style:{color:t.comment},children:["// ",t.label]})]})})}function Dr({settings:t,onUpdate:r}){let l=t.editorTheme||Zr,[c,p]=n("all"),h=hp(t.editorFont),g=u(()=>c==="all"?Jp:Jp.filter((v)=>v.variant===c),[c]);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(ka,{size:16,className:"text-ink/60"}),"Editor Theme"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Colours for the code editor only — the console around it keeps the theme above. ",e("strong",{children:"Auto"})," ","follows the app palette; any other choice paints the editor's own surface, gutter, selection and syntax, and applies to every open editor without a reload."]})]}),e("div",{className:"flex items-center gap-1.5",children:[fp.map((v)=>e("button",{type:"button",onClick:()=>p(v.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${c===v.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[v.id==="light"&&e(Gt,{size:11,className:"mr-1 inline align-[-1px]"}),v.id==="dark"&&e(zt,{size:11,className:"mr-1 inline align-[-1px]"}),v.label]},v.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:c==="all"?`${g.length} themes`:`${g.length} shown`})]}),e("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e("button",{type:"button",onClick:()=>r({editorTheme:Zr}),"aria-pressed":l===Zr,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${l===Zr?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",children:"Auto"}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:"app palette"}),l===Zr&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("span",{className:"flex h-8 items-center justify-center rounded border border-dashed border-ink/20 text-[10px] text-ink/50",children:"Follows the theme above"})]}),g.map((v)=>{let x=l===v.id;return e("button",{type:"button",onClick:()=>r({editorTheme:v.id}),"aria-pressed":x,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${x?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:v.label,children:v.label}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:v.variant}),x&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e(vp,{theme:v,face:h})]},v.id)})]})]})}function Ur({settings:t,onUpdate:r}){let l=G("editorIndentWidth"),c=typeof l==="number"&&gd.includes(l)?l:Kc.width,p=(h)=>{if(h===c)return;let g={...Ad(),width:h};Jr({editorIndentWidth:h,editorInsertSpaces:!0}),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(fd,{detail:g}))};return e("section",{className:"space-y-3",children:e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor indentation"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"One level, in spaces. Enter, Tab and the auto-indent rules all use it."})]}),e("div",{className:"flex items-center gap-1",role:"group","aria-label":"Indentation width",children:gd.map((h)=>e("button",{type:"button",onClick:()=>p(h),"aria-pressed":h===c,"aria-label":`${h} spaces`,className:`px-2.5 py-1 rounded border text-[11px] font-mono transition-colors cursor-pointer ${h===c?"border-ink/40 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:h},h))})]})})}function Fr({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.currentTarget.checked),"aria-label":t,className:`${he} mt-0.5 accent-ink flex-shrink-0`})]})}function jr({settings:t,onUpdate:r}){let l=Jc(),c=G("editorAutoCloseBrackets"),p=G("editorAutocomplete"),h=(g)=>{let v={...Jc(),...g};Jr(g),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(hd,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor typing"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Both change what typing does, which is why they are switches rather than always-on."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Fr,{label:"Auto-close brackets",hint:"Typing ( or { inserts the matching closer, and typing it again steps over it.",checked:typeof c==="boolean"?c:ul.autoCloseBrackets,onChange:(g)=>h({editorAutoCloseBrackets:g})}),e(Fr,{label:"Suggest words from the file",hint:`Offers identifiers already near the caret (${l.autocomplete?"on":"off"}). Words only — this is not a language server.`,checked:typeof p==="boolean"?p:ul.autocomplete,onChange:(g)=>h({editorAutocomplete:g})})]})]})}function $r({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.target.checked),className:`${he} mt-0.5 shrink-0 accent-ink`})]})}function Br({settings:t,onUpdate:r}){let l=G("editorBlame"),c=G("editorBlameInline"),p=fi(),h=(g)=>{let v={...fi(),...g};Jr(g),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(cs,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Line blame"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Who last touched a line, and which commit. Read from git, so it needs a committed file."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e($r,{label:"Show blame on hover",hint:"Hover a line number — or the label, when it is on — to see the author, the commit and the line's own history.",checked:typeof l==="boolean"?l:dl.enabled,onChange:(g)=>h({editorBlame:g})}),e($r,{label:"Show the label in the editor",hint:`Puts “author · age” at the end of each block. It costs horizontal room, so it is off on a narrow panel by default (${p.inline?"on":"off"}).`,checked:typeof c==="boolean"?c:dl.inline,onChange:(g)=>h({editorBlameInline:g})})]})]})}function _r({settings:t,onUpdate:r}){return e("div",{className:"w-full space-y-8 text-xs text-ink pb-3",children:[e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(ka,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),e(yr,{selectedId:t.theme,onSelect:(l)=>r({theme:dA(l)})})]}),e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(Vn,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Layout"})]}),e(wr,{settings:t,onUpdate:r}),e(Ar,{settings:t,onUpdate:r}),e(Er,{settings:t,onUpdate:r}),e(Lr,{settings:t,onUpdate:r})]}),e(Or,{settings:t,onUpdate:r}),e(Dr,{settings:t,onUpdate:r}),e(Ur,{settings:t,onUpdate:r}),e(jr,{settings:t,onUpdate:r}),e(Br,{settings:t,onUpdate:r})]})}function ye(){let[t,r]=n("list"),l=a(()=>r("detail"),[]),c=a(()=>r("list"),[]);return{pane:t,openDetail:l,back:c}}function we({pane:t,onBack:r,list:l,detail:c,listLabel:p,className:h=""}){return e("div",{className:`flex-1 flex flex-col md:flex-row h-full w-full min-w-0 overflow-hidden bg-paper text-ink ${h}`,children:[e("div",{className:`${t==="list"?"flex":"hidden"} md:flex flex-1 md:flex-none md:w-auto min-h-0 min-w-0 flex-col`,children:l}),e("div",{className:`${t==="detail"?"flex":"hidden"} md:flex flex-1 min-h-0 min-w-0 flex-col`,children:[e("div",{className:"md:hidden flex items-center px-2 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:e("button",{type:"button",onClick:r,"aria-label":`Back to ${p}`,className:"flex items-center gap-1 -ml-0.5 pl-0.5 pr-2 py-1 rounded-lg text-ink hover:bg-ink/5 active:bg-ink/10 transition-colors cursor-pointer",children:[e(ba,{size:18}),e("span",{className:"text-xs font-semibold truncate",children:p})]})}),c]})]})}function zr({groups:t,activeGroupId:r,onSelectGroup:l}){return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[t.length," group",t.length===1?"":"s"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 text-xs",children:e("div",{className:"space-y-0.5",children:t.map((c)=>{let p=c.id===r,h=c.icon;return e("button",{type:"button",onClick:()=>l(c.id),"aria-current":p?"true":void 0,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${p?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("span",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{"aria-hidden":!0,className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${p?"bg-ink/10 text-ink":"bg-ink/5 text-ink/70"}`,children:e(h,{size:12})}),e("span",{className:"font-semibold text-xs text-ink truncate",children:c.label})]}),e("span",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]",children:c.hint})]},c.id)})})})]})}var Pt=[{id:"layout",label:"Layout",hint:"Chat width and composer shape",description:"How wide the conversation is drawn, and the shape of the box you type into.",icon:Vn,sections:["width","composer"]},{id:"transcript",label:"Transcript",hint:"Tool calls, changed files and follow-up dispatch",description:"How a tool call is drawn, whether a run lists the files it changed, and what happens to a prompt sent while the agent is still running.",icon:Hr,sections:["tool-calls","changed-files","follow-up"]},{id:"sessions",label:"Sessions",hint:"Titles and goal mode",description:"How a session gets its name, and the defaults a new goal starts with.",icon:sn,sections:["titles","goal"]}];var xp={compact:"60%",wide:"85%",full:"100%"};function Gr({settings:t,onUpdate:r}){let l=t.chatWidthMode;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Chat Width"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How wide the conversation is drawn. The composer follows the transcript, and no mode hides a panel."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",role:"group","aria-label":"Chat width",children:kA.map((c)=>{let p=xA[c],h=l===c;return e("div",{onClick:()=>r({chatWidthMode:c}),role:"button",tabIndex:0,"aria-pressed":h,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({chatWidthMode:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${h?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${h?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:h&&e(f,{size:10,strokeWidth:3})})]}),e("div",{"aria-hidden":!0,className:"h-1.5 rounded-full bg-ink/10 mb-2.5 overflow-hidden",children:e("div",{className:`h-full rounded-full ${h?"bg-ink":"bg-ink/35"}`,style:{width:xp[c]}})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"On a phone the column already fills the screen, so the mode has no visible effect."})]})}function Wr({active:t=!1}){return e("span",{className:`h-[6px] w-[16px] rounded-sm border ${t?"border-ink/40 bg-ink/15":"border-ink/20 bg-ink/5"}`})}function kp({hero:t=!1}){return e("span",{className:`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${t?"flex-1 justify-center":""}`,children:[e("span",{className:"h-[2.5px] w-[72%] rounded-full bg-ink/25"}),e("span",{className:"h-[2.5px] w-[54%] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[30%] rounded-full bg-ink/15"})]})}function yp({rail:t=!1}){if(t)return e("span",{className:"flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono",children:[e("span",{className:"h-[2.5px] w-[14px] rounded-full bg-ink/30"}),e("span",{className:"h-[2.5px] w-[9px] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[11px] rounded-full bg-ink/20"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80"})]});return e("span",{className:"flex items-center gap-1 px-1",children:[e("span",{className:"h-[6px] w-[20px] rounded-sm bg-ink/15"}),e("span",{className:"h-[6px] w-[10px] rounded-sm bg-ink/10"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-full border border-ink/25"}),e("span",{className:"h-[7px] w-[7px] rounded-sm bg-ink/80"})]})}var wp={classic:"rounded-md bg-paper border-ink/10",calm:"rounded-lg bg-paper border-ink/10",console:"rounded-sm bg-paper border-ink/10",stage:"rounded-md bg-paper border-ink/15",glass:"rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent"};function Np({style:t}){let r=Vp({style:t,hero:t==="stage"});return e("span",{className:`flex h-full flex-col gap-1 border p-1 ${wp[t]}`,"aria-hidden":"true",children:r.wire.map((l,c)=>l==="draft"?e(kp,{hero:t==="stage"},c):l==="chip"?e("span",{className:"flex items-center gap-1 px-1",children:[e(Wr,{active:t!=="calm"}),e(Wr,{})]},c):e(yp,{rail:r.toolbarTone==="rail"},c))})}function Qr({settings:t,onUpdate:r}){let l=Xl(t.composerStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Composer"}),e("p",{className:"mt-0.5 text-[11px] text-ink/60",children:"The shape of the box you type into. Every style offers the same controls — attachments, plan and goal, access mode, model, thinking, voice, send — and only their order and frame change. Applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"group","aria-label":"Composer style",children:BA.map((c)=>{let p=_A[c],h=c===l;return e("button",{type:"button",onClick:()=>r({composerStyle:c}),"aria-pressed":h,"aria-label":`${p.label} composer — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[92px]",children:e(Np,{style:c})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function Cp({mode:t}){if(t==="card")return e("div",{"aria-hidden":!0,className:"space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5",children:[e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/50"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/35"}),e("span",{className:"ml-auto h-1 w-5 rounded-full bg-ink/20"})]}),e("div",{className:"h-1 w-16 rounded-full bg-ink/15"})]});if(t==="compact")return e("div",{"aria-hidden":!0,className:"space-y-1.5 rounded-md border border-transparent px-1 py-1",children:[0,1].map((r)=>e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-8 rounded-full bg-ink/30"}),e("span",{className:"ml-auto h-1 w-6 rounded-full bg-ink/15"})]},r))});if(t==="trace")return e("div",{"aria-hidden":!0,className:"relative ml-1 pl-3 py-1",children:[e("span",{className:"absolute left-[3px] top-1 bottom-1 w-px bg-ink/20"}),[0,1,2].map((r)=>e("div",{className:"flex items-center gap-1 py-0.5",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/25"})]},r))]});if(t==="tui")return e("div",{"aria-hidden":!0,className:"space-y-1 px-1 py-1 font-mono",children:[0,1].map((r)=>e("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-[6px] text-success",children:"✔"}),e("span",{className:"h-1 w-3 rounded-full bg-info/70"}),e("span",{className:"h-1 w-6 rounded-full bg-meta/70"}),e("span",{className:"ml-auto h-1 w-2 rounded-full bg-ink/25"})]},r))});return e("div",{"aria-hidden":!0,className:"space-y-1.5 px-1 py-1",children:[e("div",{className:"h-1 w-20 rounded-full bg-ink/25"}),e("div",{className:"h-1 w-14 rounded-full bg-ink/15"})]})}function ei({settings:t,onUpdate:r}){let l=t.toolRenderStyle;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Tool Calls"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:CA.map((c)=>{let p=EA[c],h=l===c;return e("div",{onClick:()=>r({toolRenderStyle:c}),role:"button",tabIndex:0,"aria-pressed":h,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({toolRenderStyle:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${h?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${h?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:h&&e(f,{size:10,strokeWidth:3})})]}),e("div",{className:"mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1",children:e(Cp,{mode:c})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"The style is global: it applies to every session, and the composer keeps its own frame."})]})}function Ip({label:t,enabled:r,onToggle:l}){return e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Disable":"Enable"} ${t}`,onClick:l,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${r?"bg-ink":"bg-ink/20"}`,children:e("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${r?"translate-x-5":"translate-x-0"}`})})}function ti({settings:t,onUpdate:r}){let l=t.showChangedFiles;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Changed Files"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A collapsed list of the files a run changed, above its footer. Clicking a file opens the agent's own diff — the content it wrote, not the current worktree."})]}),e("div",{className:"flex items-start justify-between gap-4 py-3",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(qo,{size:16,className:l?"text-ink":"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:"Show changed files"}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Read from the session's change journal. Sessions recorded before omp 18.20.1 have no journal, so the list stays empty there."})]})]}),e(Ip,{label:"Show changed files",enabled:l,onToggle:()=>r({showChangedFiles:!l})})]})]})}function oi({settings:t,onUpdate:r}){return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e("div",{onClick:()=>r({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="queue"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="queue"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Hr,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="queue"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="queue"&&e(f,{size:10,strokeWidth:3})})]})]}),e("div",{onClick:()=>r({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="steering"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="steering"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Bt,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="steering"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="steering"&&e(f,{size:10,strokeWidth:3})})]})]})]})]})}var Ap=[{enabled:!0,label:"Generate Automatically",badge:"Default",icon:Le,description:`As soon as your first message lands, the session is named from it using omp's own tiny title model — retried once when the run ends if that first attempt came back empty. Sessions stop showing "New Session - <timestamp>" in the sidebar.`,note:"One small model call per session"},{enabled:!1,label:"Manual Only",badge:"Opt-out",icon:Yr,description:"Sessions keep their timestamp placeholder until you rename them from the sidebar. Choose this when every title should be deliberate, or to avoid the extra model call.",note:"No background model calls"}];function ii({settings:t,onUpdate:r}){let l=t.autoSessionTitle??!0;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Session Titles"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a session gets its display name. A name you set yourself is never replaced."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Ap.map(({enabled:c,label:p,badge:h,icon:g,description:v,note:x})=>{let y=l===c,k=()=>r({autoSessionTitle:c});return e("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:(P)=>P.key==="Enter"&&k(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${y?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${y?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(g,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:p})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:h})]}),e("p",{className:"text-[11px] text-ink/70 leading-relaxed",children:v})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50",children:x}),y&&e("span",{className:"flex items-center gap-1 text-ink font-medium",children:[e(f,{size:12})," Active"]})]})]},p)})})]})}var Ep="flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-left font-mono text-[11px] text-ink transition-colors hover:border-ink/40 focus:border-ink/50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50";function Fe({value:t,options:r,placeholder:l,ariaLabel:c,onChange:p,disabled:h,className:g,searchable:v=!0}){let[x,y]=n(null),[k,P]=n(""),[N,A]=n(0),C=i(null),R=i(null),S=i([]),I=i(`search-select-${Math.random().toString(36).slice(2,9)}`).current,T=r.find((W)=>W.value===t),M=x!==null,U=u(()=>{let W=k.trim();if(!W)return r;return r.filter((K)=>Yi(`${K.label} ${K.value} ${K.hint??""}`,W))},[r,k]),F=u(()=>{let W=[];for(let K of U){let q=K.group??"",X=W.find((Z)=>Z.name===q);if(X)X.rows.push(K);else W.push({name:q,rows:[K]})}return W},[U]),j=(W=!1)=>{if(y(null),P(""),W)C.current?.focus()},V=()=>{if(h||!C.current)return;let W=Math.max(0,r.findIndex((K)=>K.value===t));P(""),A(W),y(Ht(C.current))},z=(W)=>{if(W!==t)p(W);j(!0)};o(()=>{A(0)},[k]),o(()=>{if(!M)return;S.current[N]?.scrollIntoView({block:"nearest"})},[M,N]),o(()=>{if(M)R.current?.focus()},[M]);let H=(W)=>{if(W.key==="ArrowDown")W.preventDefault(),A((K)=>Math.max(0,Math.min(U.length-1,K+1)));else if(W.key==="ArrowUp")W.preventDefault(),A((K)=>Math.max(0,K-1));else if(W.key==="Home")W.preventDefault(),A(0);else if(W.key==="End")W.preventDefault(),A(Math.max(0,U.length-1));else if(W.key==="Enter"){W.preventDefault();let K=U[N];if(K)z(K.value)}};return e(d,{children:[e("button",{ref:C,type:"button",role:"combobox","aria-label":c,"aria-haspopup":"listbox","aria-expanded":M,"aria-controls":M?I:void 0,disabled:h,title:T?.label??l,onClick:()=>M?j():V(),onKeyDown:(W)=>{if(W.key==="ArrowDown"||W.key==="Enter"||W.key===" ")W.preventDefault(),V()},className:`${Ep} ${g??""}`,children:[e("span",{className:`truncate ${T?"":"text-ink/40"}`,children:T?.label??(t?`${t} (not listed)`:l)}),e(B,{size:12,className:`flex-shrink-0 text-ink/40 transition-transform ${M?"rotate-180":""}`})]}),e(Wt,{anchor:x,align:"start",className:"w-72 max-w-[calc(100vw-2rem)] rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",...{"aria-label":c},onClose:()=>j(!0),children:e("div",{onKeyDown:H,children:[v&&e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(O,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{ref:R,type:"text",value:k,"aria-label":`Search ${c}`,placeholder:"Search…",onInput:(W)=>P(W.currentTarget.value),className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{id:I,role:"listbox","aria-label":c,className:"max-h-56 overflow-y-auto py-1",children:[e("button",{type:"button",role:"option","aria-selected":t==="",ref:(W)=>{S.current[0]=W},onClick:()=>z(""),onMouseEnter:()=>A(0),className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left ${t===""?"text-ink":"text-ink/60"} hover:bg-ink/5`,children:[e("span",{className:"truncate italic",children:l}),t===""&&e(f,{size:11,className:"flex-shrink-0"})]}),t!==""&&!T&&e("button",{type:"button",role:"option","aria-selected":!0,onClick:()=>z(t),className:"flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-ink",children:[e("span",{className:"truncate",children:[t," (not listed)"]}),e(f,{size:11,className:"flex-shrink-0"})]}),U.length===0?e("div",{className:"px-3 py-2 italic text-ink/40",children:["No match for “",k.trim(),"”"]}):F.map((W)=>e("div",{children:[W.name&&e("div",{className:"px-3 pb-0.5 pt-2 text-[9px] font-semibold uppercase tracking-wider text-ink/35",children:W.name}),W.rows.map((K)=>{let q=U.indexOf(K),X=K.value===t;return e("button",{type:"button",role:"option","aria-selected":X,ref:(Z)=>{S.current[q+1]=Z},onClick:()=>z(K.value),onMouseEnter:()=>A(q),title:K.hint??K.value,className:`flex w-full items-start justify-between gap-2 px-3 py-1.5 text-left transition-colors ${q===N?"bg-ink/5":""} ${X?"font-medium text-ink":"text-ink/75"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate",children:K.label}),K.hint&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:K.hint})]}),X&&e(f,{size:11,className:"mt-0.5 flex-shrink-0"})]},K.value)})]},W.name||"__flat"))]})]})})]})}var Lp=[{enabled:!0,label:"Independent auditor",badge:"Default",description:"After every finished turn a separate model reads the objective and the agent's own report and decides: keep going, done, or needs you. Without it nothing advances a goal on its own.",note:"One extra model call per turn"},{enabled:!1,label:"Manual only",badge:"Opt-out",description:"Goals still exist — objective, pause, resume and the token budget all work — but the loop never continues by itself. Use it when a goal should only ever run the turns you ask for.",note:"No background model calls"}];function ai({settings:t,onUpdate:r}){let l=nc(),[c,p]=n([]),[h,g]=n(!0),v=t.goalAuditEnabled??!0,x=t.goalAuditModel??"",y=t.goalDefaultBudget??null,[k,P]=n(y===null?"":String(y));o(()=>{P(y===null?"":String(y))},[y]);let N=()=>{let A=nm(k);if(P(A===null?"":String(A)),A!==y)r({goalDefaultBudget:A})};return o(()=>{let A=!0;return Ha().then((C)=>{if(!A)return;p(Array.isArray(C.modelList)?C.modelList.map((R)=>({id:R.id,name:R.name,provider:R.provider})):[])}).catch(()=>{}).finally(()=>{if(A)g(!1)}),()=>{A=!1}},[]),e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Goal Mode"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A goal keeps a session working toward one objective until it is done, out of budget, or the auditor says it needs you."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Lp.map(({enabled:A,label:C,badge:R,description:S,note:I})=>{let T=v===A,M=()=>r({goalAuditEnabled:A});return e("div",{onClick:M,role:"button",tabIndex:0,onKeyDown:(U)=>U.key==="Enter"&&M(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${T?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${T?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(xo,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:C})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:R})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:S})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:I}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${T?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:T&&e(f,{size:10,strokeWidth:3})})]})]},C)})}),v&&e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 space-y-3",children:e("div",{children:[e("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Auditor model"}),e(Fe,{ariaLabel:"Auditor model",value:x,onChange:(A)=>r({goalAuditModel:A}),disabled:h,placeholder:"Session model (default)",className:"w-full py-1.5 text-[11.5px]",options:c.map((A)=>({value:`${A.provider}/${A.id}`,label:A.name,hint:`${A.provider}/${A.id}`,group:Vi(A.provider,l)}))}),e("p",{className:"mt-1 text-[10.5px] text-ink/45",children:"The audit is a classification, not a task: it runs with thinking off, one small call per turn."})]})}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5",children:[e("label",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:[e(Xo,{size:11})," Default token budget"]}),e("div",{className:"flex items-center gap-2",children:[e("input",{value:k,onChange:(A)=>P(A.currentTarget.value),onBlur:N,onKeyDown:(A)=>{if(A.key==="Enter")N()},placeholder:"none: the turn ceiling is then the only stop",inputMode:"numeric","aria-label":"Default goal token budget",className:"w-56 rounded border border-ink/15 bg-paper px-2 py-1.5 font-mono text-[11.5px] outline-none focus:border-ink"}),e("span",{className:"text-[10.5px] text-ink/45",children:"New goals start with this budget; a goal you set explicitly keeps its own."})]})]}),e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/10 bg-canvas/40 p-3 text-[11px] text-ink/60",children:[e(Ft,{size:12,className:"mt-0.5 shrink-0"}),e("span",{children:"The objective is set per goal from the composer's target button. The auditor judges progress from the objective and the agent's own report only — write an objective that says what finished looks like."})]})]})}var Fp={width:Gr,composer:Qr,"tool-calls":ei,"changed-files":ti,"follow-up":oi,titles:ii,goal:ai};function si({settings:t,onUpdate:r}){let l=ye(),[c,p]=n(Pt[0].id),h=Pt.find((g)=>g.id===c)??Pt[0];return e(we,{pane:l.pane,onBack:l.back,listLabel:"Chat settings",list:e(zr,{groups:Pt,activeGroupId:h.id,onSelectGroup:(g)=>{p(g),l.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col text-xs text-ink",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0",children:[e("span",{className:"text-xs font-semibold text-ink/75",children:h.label}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:h.description})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6",children:h.sections.map((g)=>{let v=Fp[g];return e(v,{settings:t,onUpdate:r},g)})})]})})}function li(t){let r=new Map;for(let c of t){let p=PA(c.chord),h=r.get(p);if(h)h.push(c);else r.set(p,[c])}let l=[];for(let c of r.values())for(let p=0;p<c.length;p+=1)for(let h=p+1;h<c.length;h+=1){let g=c[p],v=c[h];if(g.command===v.command)continue;l.push({chord:g.chord,a:g,b:v,certain:!g.when||!v.when||g.when===v.when})}return l}var jp={Shift:!0,Control:!0,Alt:!0,Meta:!0,OS:!0,Super:!0,Hyper:!0,CapsLock:!0,Fn:!0},Bp={ShiftLeft:!0,ShiftRight:!0,ControlLeft:!0,ControlRight:!0,AltLeft:!0,AltRight:!0,MetaLeft:!0,MetaRight:!0,OSLeft:!0,OSRight:!0,CapsLock:!0};function di(t){return jp[t.key]===!0||Bp[t.code]===!0}function ci({chord:t,onCommit:r}){let[l,c]=n(!1),[p,h]=n([]),g=i(null);o(()=>{if(l)g.current?.focus()},[l]);let v=()=>{c(!1),h([])},x=(k)=>{if(!l)return;if(k.preventDefault(),k.stopPropagation(),k.key==="Escape"){v();return}if(k.key==="Backspace"||k.key==="Delete"){if(p.length===0)r(null),v();else h([]);return}if(k.key==="Enter"&&p.length===1){r(Xf(p)),v();return}if(di(k))return;let P=rm(k);if(p.length===0){h([P]);return}r(Xf([p[0],P])),v()},y=l?p.length>0?`${So(p,bt())} …`:"Press keys…":t||"Unassigned";return e("button",{ref:g,type:"button",onClick:()=>{c(!0),h([])},onBlur:()=>{if(l)v()},onKeyDown:x,"aria-label":l?"Recording shortcut, press keys":`Shortcut ${t||"unassigned"}, click to change`,className:`min-w-[7rem] px-2 py-1 rounded-md border text-[11px] font-mono transition-colors ${l?"border-ink/60 bg-ink/5 text-ink":"border-ink/20 text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:y})}function pi(){let{commands:t,chords:r,rules:l}=ac(),[c,p]=n(()=>am()),[h,g]=n(""),v=u(()=>li(l),[l]),x=bt(),y=(C)=>t.find((R)=>R.id===C)?.title??C,k=(C,R)=>{let S={...c,[C]:R};p(S),qu(S),eg(S)},P=(C)=>{let R={...c};delete R[C],p(R),qu(R),eg(R)},N=h.trim().toLowerCase(),A=t.filter((C)=>!N||C.title.toLowerCase().includes(N)||(r.get(C.id)??"").toLowerCase().includes(N)).sort((C,R)=>C.category.localeCompare(R.category)||C.title.localeCompare(R.title));return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Shortcuts"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Click a chord to record a new one. Two strokes are allowed; Enter keeps a single stroke."})]}),e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border border-ink/15 rounded-md bg-canvas",children:[e(O,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:h,onInput:(C)=>g(C.currentTarget.value),placeholder:"Filter","aria-label":"Filter shortcuts",className:"w-32 bg-transparent text-xs text-ink focus:outline-none placeholder-ink/40"})]})]}),v.length>0?e("div",{className:"border border-ink/15 rounded-lg p-3 space-y-1.5 bg-ink/[0.02]",children:[e("p",{className:"text-[11px] font-semibold text-ink/75",children:[v.length," chord ",v.length===1?"conflict":"conflicts"]}),v.map((C)=>e("p",{className:"text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-ink/80",children:So(C.chord,x)})," ","— ",y(C.a.command)," and ",y(C.b.command),C.certain?"":" (may not overlap)"]},`${C.a.command}-${C.b.command}`))]}):null,e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:A.length===0?e("p",{className:"px-3 py-4 text-center text-xs text-ink/50",children:"No command matches that filter."}):A.map((C)=>{let R=c[C.id]!==void 0;return e("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink truncate",children:C.title}),e("div",{className:"text-[10px] text-ink/45",children:[C.category,C.pluginId?` · ${C.pluginId}`:"",R?" · custom":""]})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e(ci,{chord:r.get(C.id)??"",onCommit:(S)=>k(C.id,S)}),R?e("button",{type:"button",onClick:()=>P(C.id),title:"Reset to default","aria-label":`Reset ${C.title} to its default shortcut`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors",children:e(Rt,{size:12})}):null]})]},C.id)})})]})}function ui({settings:t,onUpdate:r}){let l=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],c=(h,g)=>{r((v)=>{let x={[h]:g},y=["keybindingSend","keybindingNewLine","keybindingSteering"].filter((k)=>k!==h);for(let k of y)if(v[k]===g)x[k]=v[h];return{...v,...x}})},p=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:tt,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:Xt,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:Bt,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:[e(ya,{size:15,className:"text-ink/70"}),e("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),e("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:p.map((h)=>e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:e(h.icon,{size:14})}),e("div",{children:[e("div",{className:"font-semibold text-xs text-ink",children:h.label}),e("div",{className:"text-[11px] text-ink/60 mt-0.5",children:h.desc})]})]}),e("div",{className:"flex items-center gap-2 self-end sm:self-center",children:e("select",{value:h.value,onChange:(g)=>c(h.id,g.currentTarget.value),className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:l.map((g)=>e("option",{value:g,children:g},g))})})]},h.id))})]})}function mi({settings:t,onUpdate:r}){return e("div",{className:"flex-1 h-full overflow-y-auto scrollbar-overlay-container p-4 md:p-6 space-y-8 pb-8",children:[e(pi,{}),e(ui,{settings:t,onUpdate:r})]})}function gi({projects:t,selectedProjectId:r,onSelectProject:l,onAddProject:c,onTogglePin:p,isAdding:h=!1,folderFacts:g=[],loadError:v=null}){let x=new Map(g.map((y)=>[y.id,y.totalSessions]));return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:[t.length," project",t.length===1?"":"s"]}),e("button",{type:"button",onClick:c,disabled:h,"aria-label":"Add project",title:"Add project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:[v&&e("p",{className:"px-2 py-2 text-[11px] text-error",title:v,children:["Projects could not be read: ",v]}),!v&&t.length===0&&e("div",{className:"px-2 py-3 space-y-1.5",children:[e("p",{className:"text-[11.5px] text-ink/60",children:"No projects yet."}),e("button",{type:"button",onClick:c,className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add the first one"})]}),t.map((y)=>{let k=y.id===r,P=ea(y.icon),N=y.folderId===void 0?void 0:x.get(y.folderId);return e("div",{className:`group flex items-center rounded-md transition-colors ${k?"bg-ink/10 shadow-2xs":"hover:bg-ink/5"}`,children:[e("button",{type:"button",onClick:()=>l(y.id),"aria-current":k?"true":void 0,className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer",children:[y.customIconUrl?e("img",{src:y.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):e(P,{size:14,className:"flex-shrink-0",style:{color:y.accentColor||"currentColor"}}),e("span",{className:`text-[11.5px] truncate flex-1 ${k?"font-medium text-ink":"text-ink/80"}`,children:y.name}),typeof N==="number"&&N>0&&e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:N})]}),e("button",{type:"button",onClick:()=>p(y),"aria-label":y.isPinned?`Unpin ${y.name}`:`Pin ${y.name}`,title:y.isPinned?"Unpin (stop sorting first)":"Pin (sort first in the sidebar)",className:`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${y.isPinned?"text-ink/70 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:y.isPinned?e(Ta,{size:12}):e(ml,{size:12})})]},y.id)})]})]})}function bi({project:t,canDelete:r,isDeleting:l=!1,onDelete:c}){return e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0 flex-1",children:[e("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path||"Not bound to a directory"})]}),r&&e("button",{type:"button",onClick:c,disabled:l,title:"Delete this project",className:"inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1.5 text-[11px] font-medium text-ink/50 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer disabled:opacity-50",children:[e(L,{size:13}),e("span",{children:"Delete"})]})]})}function hi({name:t,disabled:r=!1,onCommit:l}){let[c,p]=n(t);return o(()=>{p(t)},[t]),e("div",{className:"space-y-2",children:[e("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project name"}),e("input",{id:"project-name-input",type:"text",value:c,disabled:r,onChange:(g)=>p(g.currentTarget.value),onBlur:()=>{let g=c.trim();if(!g){p(t);return}if(g===t)return;l(g)},onKeyDown:(g)=>{if(g.key==="Enter")g.preventDefault(),g.currentTarget.blur();if(g.key==="Escape")p(t),g.currentTarget.blur()},placeholder:"Enter project name…",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:"Names are unique: the sidebar identifies a project by it."})]})}function vi({path:t,disabled:r=!1,onCommit:l,onReveal:c,isRevealing:p=!1}){let[h,g]=n(t),[v,x]=n(!1);o(()=>{g(t)},[t]);let y=(k)=>{let P=k.trim();if(P===t)return;l(P)};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("label",{htmlFor:"project-path-input",className:"block text-xs font-semibold text-ink",children:"Project directory"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:()=>x(!0),disabled:r,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(Fn,{size:11}),e("span",{children:"Browse…"})]}),e("button",{type:"button",onClick:c,disabled:r||!t||p,title:t?"Reveal in the file manager":"This project is not bound to a directory",className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40",children:[e(Nt,{size:11}),e("span",{children:"Reveal"})]})]})]}),e("input",{id:"project-path-input",type:"text",value:h,disabled:r,onChange:(k)=>g(k.currentTarget.value),onBlur:()=>y(h),onKeyDown:(k)=>{if(k.key==="Enter")k.preventDefault(),k.currentTarget.blur();if(k.key==="Escape")g(t),k.currentTarget.blur()},placeholder:"~ or /absolute/path, or leave empty for an unbound grouping",spellcheck:!1,className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:t?"Sessions found under this directory appear in the project. One directory can belong to one project.":"Not bound to a directory: this project groups chats only and discovers no sessions."}),v&&e(ws,{initialPath:t||void 0,onSelect:(k)=>{x(!1),g(k),y(k)},onClose:()=>x(!1)})]})}function xi({model:t,models:r,onSelectModel:l,disabled:c=!1}){let[p,h]=n(!1),[g,v]=n(""),x=i(null);pe(x,()=>h(!1));let y=zA(t,r)??"Inherit Kabmo’s default",k=u(()=>{let N=g.trim().toLowerCase();if(!N)return r;return r.filter((A)=>A.name.toLowerCase().includes(N)||A.id.toLowerCase().includes(N)||A.provider.toLowerCase().includes(N))},[r,g]),P=(N)=>{l(N),h(!1),v("")};return e("div",{className:"space-y-2.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),e("span",{className:"inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help",title:"The model a chat started in this project uses until you pick another one in the composer.",children:e(de,{size:12})})]}),e("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink",children:"Project model"}),e("div",{className:"text-[11px] text-ink/50",children:r.length===0?"No model catalog yet — connect a provider first.":"Applied when the project starts a chat."})]}),e("div",{className:"relative shrink-0",ref:x,children:[e("button",{type:"button",onClick:()=>h((N)=>!N),disabled:c,className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50",children:[e(Le,{size:13,className:"text-ink/70 shrink-0"}),e("span",{className:"truncate",children:y}),e(B,{size:13,className:"text-ink/50 shrink-0"})]}),p&&e("div",{className:"glass-popover absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden",children:[e("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 shrink-0"}),e("input",{autoFocus:!0,value:g,onInput:(N)=>v(N.currentTarget.value),placeholder:"Search models…",className:"flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"max-h-64 scrollbar-overlay-container py-1",children:[e("button",{type:"button",onClick:()=>P(oc),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:t===oc?"font-semibold text-ink":"text-ink/80",children:"Inherit Kabmo’s default"}),t===oc&&e(f,{size:13,className:"text-ink"})]}),k.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/50",children:r.length===0?"The catalog is empty.":`No model matches “${g.trim()}”.`}):k.map((N)=>{let A=$A({provider:N.provider,modelId:N.id}),C=t===A;return e("button",{type:"button",onClick:()=>P(A),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:`truncate text-xs ${C?"font-semibold text-ink":"text-ink/85"}`,children:N.name}),e("span",{className:"truncate text-[10.5px] text-ink/45",children:N.provider})]}),C&&e(f,{size:13,className:"text-ink shrink-0"})]},A)})]}),t!==oc&&e("button",{type:"button",onClick:()=>P(oc),className:"w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(b,{size:11}),e("span",{children:"Clear the project model"})]})]})]})]})]})}function ki({accentColor:t,onSelectColor:r,options:l=tg,disabled:c=!1}){let p=l.length>0?l:tg,h=t.trim().toLowerCase(),g=p.some((R)=>R.value!==""&&R.value.toLowerCase()===h),v=h!==""&&!g,x=im(h)??om,[y,k]=n(x);o(()=>k(x),[x]);let P=(R)=>{let S=im(R);if(S===null){k(x);return}if(k(S),S!==h)r(S)},N=i(null),A=i(null),C=i({commit:P,clear:()=>r("")});return C.current={commit:P,clear:()=>r("")},o(()=>{let R=N.current,S=A.current;if(!R||!S)return;let I=(F)=>k(F.target.value.toLowerCase()),T=(F)=>C.current.commit(F.target.value),M=()=>{let F=S.value.trim();if(F==="")C.current.clear();else C.current.commit(F)},U=(F)=>{if(F.key==="Enter")F.preventDefault(),M();if(F.key==="Escape")k(x)};return R.addEventListener("input",I),R.addEventListener("change",T),S.addEventListener("blur",M),S.addEventListener("keydown",U),()=>{R.removeEventListener("input",I),R.removeEventListener("change",T),S.removeEventListener("blur",M),S.removeEventListener("keydown",U)}},[x]),e("div",{className:"space-y-2.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Accent colour"}),e("div",{className:"flex flex-wrap items-center gap-2.5",children:p.map((R)=>{let S=h===R.value.toLowerCase();if(R.value==="")return e("button",{type:"button",onClick:()=>r(""),disabled:c,"aria-label":"No accent colour","aria-pressed":S,title:"No accent colour",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${S?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:e(b,{size:12,strokeWidth:2.2})},"none");return e("button",{type:"button",onClick:()=>r(R.value),disabled:c,"aria-label":R.label,"aria-pressed":S,title:R.label,style:{backgroundColor:R.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${S?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},R.value)})}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("label",{title:"Pick a custom accent colour",className:`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${v?"ring-2 ring-ink ring-offset-2 ring-offset-paper":"border-ink/25 hover:border-ink/50"} ${c?"opacity-50 pointer-events-none":""}`,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundColor:y}}),e(nr,{size:12,strokeWidth:2.2,"aria-hidden":"true",className:"absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"}),e("input",{ref:N,type:"color",value:im(y)??om,disabled:c,"aria-label":"Custom accent colour",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e("input",{ref:A,type:"text",value:y,disabled:c,spellcheck:!1,"aria-label":"Custom accent colour hex",placeholder:om,onInput:(R)=>k(R.currentTarget.value),className:"w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"}),e("span",{className:"text-[11px] text-ink/45",children:v?"Custom accent":"Pick any colour"})]})]})}var $n=128,_p=700000;async function Hp(t){let r=Promise.withResolvers(),l=new FileReader;l.onload=(A)=>{let C=A.target?.result;if(typeof C==="string"&&C)r.resolve(C);else r.reject(Error("That file could not be read as an image."))},l.onerror=()=>r.reject(Error("That file could not be read as an image.")),l.readAsDataURL(t);let c=await r.promise;if(t.type==="image/svg+xml")return c;let p=Promise.withResolvers(),h=new Image;h.onload=()=>p.resolve(h),h.onerror=()=>p.reject(Error("That file is not an image Kabmo can read.")),h.src=c;let g=await p.promise,v=Math.min(1,$n/Math.max(g.naturalWidth,g.naturalHeight)),x=Math.max(1,Math.round(g.naturalWidth*v)),y=Math.max(1,Math.round(g.naturalHeight*v)),k=document.createElement("canvas");k.width=x,k.height=y;let P=k.getContext("2d");if(!P)return c;P.drawImage(g,0,0,x,y);let N=k.toDataURL("image/png");return N.length>0&&N.length<c.length?N:c}function yi({currentIcon:t,customIconUrl:r,projectName:l,onSelectIcon:c,onSetCustomIcon:p,disabled:h=!1}){let g=i(null),[v,x]=n(!1),[y,k]=n(!1),[P,N]=n(null),A=async(S)=>{let I=S.currentTarget.files?.[0];if(S.currentTarget.value="",!I)return;N(null),k(!0);try{let T=await Hp(I);if(T.length>_p){N("That image is too detailed to store as a mark — try a PNG or SVG.");return}p(T)}catch(T){N(T instanceof Error?T.message:String(T))}finally{k(!1)}},C=()=>{let I=`https://api.dicebear.com/7.x/identicon/svg?seed=${l.toLowerCase().replace(/[^a-z0-9]/g,"")||"project"}&radius=50&size=${$n}`;N(null),x(!0);let T=new Image;T.onload=()=>{x(!1),p(I)},T.onerror=()=>{x(!1),N("The generated icon could not be loaded — check your connection.")},T.src=I},R=h||y||v;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Project icon"}),r&&e("button",{type:"button",onClick:()=>p(void 0),disabled:R,className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:"Use a standard icon"})]}),e("div",{className:"flex flex-wrap gap-1.5",children:OA.map((S)=>{let I=!r&&t===S.id,T=S.icon;return e("button",{type:"button",onClick:()=>c(S.id),disabled:R,"aria-label":S.label,"aria-pressed":I,title:S.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${I?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"border border-transparent text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:e(T,{size:14,strokeWidth:1.8})},S.id)})}),e("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e("input",{type:"file",ref:g,onChange:(S)=>void A(S),accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden"}),e("button",{type:"button",onClick:()=>g.current?.click(),disabled:R,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[y?e(m,{size:13,className:"animate-spin text-ink/60"}):e(Ui,{size:13,className:"text-ink/60"}),e("span",{children:y?"Reading…":"Upload image"})]}),e("button",{type:"button",onClick:C,disabled:R,title:"Generate a stable identicon from the project name",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[v?e(m,{size:13,className:"animate-spin text-ink/60"}):e(Go,{size:13,className:"text-ink/60"}),e("span",{children:v?"Generating…":"Generate mark"})]}),r&&e("div",{className:"flex items-center gap-2 ml-1 pl-2 border-l border-ink/10",children:[e("img",{src:r,alt:"Current custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),e("span",{className:"text-[11px] text-ink/60",children:"Custom icon in use"}),e("button",{type:"button",onClick:()=>p(void 0),disabled:R,"aria-label":"Remove the custom icon",className:"p-0.5 rounded text-ink/40 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:12})})]})]}),e("p",{className:"text-[11px] text-ink/50",children:["Any image works — it is scaled down to a ",$n,"px mark. PNG, JPEG, WebP, GIF or SVG."]}),P&&e("p",{className:"text-[11px] text-error",children:P})]})}function wi({project:t,canDelete:r,isDeleting:l=!1,isRevealing:c=!1,models:p,accentColorOptions:h,onUpdateField:g,onUpdateFields:v,onReveal:x,onDeleteProject:y}){return e("div",{className:"p-6 md:p-8 space-y-7",children:[e(bi,{project:t,canDelete:r,isDeleting:l,onDelete:y}),e(hi,{name:t.name,onCommit:(k)=>g("name",k)}),e(vi,{path:t.path,onCommit:(k)=>g("path",k),onReveal:x,isRevealing:c}),e(xi,{model:t.model,models:p,onSelectModel:(k)=>g("model",k)}),e(ki,{accentColor:t.accentColor,onSelectColor:(k)=>g("accentColor",k),...h&&h.length>0?{options:h}:{}}),e(yi,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:(k)=>v({icon:k,customIconUrl:void 0}),onSetCustomIcon:(k)=>v({customIconUrl:k,icon:k===void 0?"default":"custom"})})]})}function Gp(t){return(t.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"").toLowerCase()}function Wp({isSaving:t,onClose:r,onSubmit:l}){let[c,p]=n(""),[h,g]=n(""),[v,x]=n(!1),[y,k]=n(!0),[P,N]=n(null),A=(R)=>{if(g(R),y||!c.trim())p(Gp(R)),k(!0)},C=async()=>{let R=c.trim();if(!R){N("Enter a project name.");return}N(null);try{await l({name:R,path:h.trim()}),r()}catch(S){N(S instanceof Error?S.message:String(S))}};return e(d,{children:e(J,{onClose:t?()=>{}:r,ariaLabel:"Add project",maxWidthClass:"max-w-[480px]",header:e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Add project"}),e("p",{className:"text-[11px] text-ink/50",children:"A name, and the directory its chats run in."})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,disabled:t,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:()=>void C(),disabled:t,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5",children:[t&&e(m,{size:13,className:"animate-spin"}),e("span",{children:t?"Adding…":"Add project"})]})]}),children:[e("div",{className:"px-5 py-4 space-y-4",children:[e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-name",className:"block text-xs font-semibold text-ink",children:"Name"}),e("input",{id:"add-project-name",type:"text",value:c,onInput:(R)=>{p(R.currentTarget.value),k(!1)},placeholder:"e.g. kabmo",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"}),e("p",{className:"text-[11px] text-ink/50",children:"Unique: the sidebar identifies a workspace by it."})]}),e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-path",className:"block text-xs font-semibold text-ink",children:["Directory ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("div",{className:"flex items-center gap-2",children:[e("input",{id:"add-project-path",type:"text",value:h,onInput:(R)=>g(R.currentTarget.value),placeholder:"~ or /absolute/path",spellcheck:!1,className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"}),e("button",{type:"button",onClick:()=>x(!0),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer",children:[e(Nt,{size:12}),e("span",{children:"Browse…"})]})]}),e("p",{className:"text-[11px] text-ink/50",children:"Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory behind it."})]}),P&&e("p",{className:"text-[11px] text-error",children:P})]}),v&&e(ws,{initialPath:h||void 0,onSelect:(R)=>{A(R),x(!1)},onClose:()=>x(!1)})]})})}function Si({isOpen:t,isSaving:r,onClose:l,onSubmit:c}){if(!t)return null;return e(Wp,{isSaving:r,onClose:l,onSubmit:c})}function Ni({project:t,isDeleting:r,error:l,onClose:c,onConfirm:p}){if(o(()=>{let h=(g)=>{if(g.key!=="Escape"||r)return;g.preventDefault(),c()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[c,r]),!t)return null;return e(J,{onClose:r?()=>{}:c,zClass:"z-[70]",maxWidthClass:"max-w-[440px]",ariaLabel:"Delete project",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(L,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete project?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:t.name})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:p,disabled:r,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[r?e(m,{size:13,className:"animate-spin"}):e(L,{size:13}),e("span",{children:r?"Deleting…":"Delete project"})]})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspace is unregistered from Kabmo — its place in the sidebar, its chats' grouping and its settings go."}),e("li",{children:t.path?"The directory itself is NOT deleted; a tombstone keeps omp discovery from re-adding it on the next boot.":"It has no directory, so nothing on disk is touched."}),e("li",{children:"Chat transcripts stay on disk under ~/.omp/agent/sessions."})]}),l&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:l})]})]})})}var Bn="worktreeDirectory",_n="worktreeCarryIgnored";function Ci(t){if(t.missing)return"folder is missing — its chats still open";let r=t.detached?`detached @ ${t.head.slice(0,7)||"unknown"}`:`${t.branch} checked out here`,l=t.sessions===1?"1 chat":`${t.sessions} chats`,c=t.dirty===0?"clean":`${t.dirty} changed`;return`${r} · ${l} · ${c}`}function Ti(t){return!t.detached&&Boolean(t.branch)&&t.aheadOfStart===0}function Kn(t){if(t.isPrimary)return"The main checkout cannot be removed.";if(t.dirty>0)return`${t.dirty} uncommitted file${t.dirty===1?"":"s"} here would be lost.`;return null}function Ii({root:t,folderId:r,onReport:l}){let{worktrees:c,base:p,loading:h,error:g,isRepo:v,refresh:x}=sm({root:t,folderId:r},Boolean(t)),[y,k]=n(()=>{let S=G(Bn);return typeof S==="string"?S:""}),[P,N]=n(()=>G(_n)!==!1),[A,C]=n(null);if(!t)return e("p",{className:"text-xs text-ink/50",children:"Bind this workspace to a repository to manage its worktrees."});let R=c.filter((S)=>!S.isPrimary);return e("div",{className:"flex flex-col gap-4",children:[e("section",{className:"flex flex-col gap-1",children:[e("h3",{className:"text-xs font-semibold text-ink",children:"Worktrees"}),h&&e("p",{className:"text-[11px] text-ink/50",children:"Reading worktrees…"}),g&&e("p",{className:"text-[11px] text-error",title:g,children:["Worktrees could not be read: ",g]}),!h&&!g&&v===!1&&e("p",{className:"text-[11px] text-ink/50",children:"Worktrees need a Git repository."}),!h&&!g&&v!==!1&&R.length===0&&e("p",{className:"text-[11px] text-ink/50",children:"No worktrees yet."}),R.map((S)=>e("div",{className:"group flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-ink/5",children:[e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"truncate text-xs text-ink",children:S.branch||"detached"}),e("p",{className:"truncate text-[10.5px] text-ink/50",title:S.path,children:Ci(S)})]}),e("button",{type:"button",disabled:A===S.path||Kn(S)!==null,"aria-label":`Remove worktree ${S.branch||S.path}`,title:Kn(S)??"Remove worktree",onClick:()=>{C(S.path),UA({root:t,folderId:r},S.path,{deleteBranch:Ti(S)}).then((I)=>(l(I.branchDeleted?`Removed ${S.branch} and its branch`:`Removed ${S.branch}${I.branchKept?" (branch kept)":""}`,"success"),x())).catch((I)=>l(I instanceof Error?I.message:String(I),"error")).finally(()=>C(null))},className:"shrink-0 rounded px-2 py-1 text-[11px] text-ink/60 hover:bg-error/10 hover:text-error disabled:opacity-40",children:"Remove"})]},S.path))]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Worktree location"}),e("input",{value:y,onChange:(S)=>k(S.currentTarget.value),onBlur:()=>rt(Bn,y.trim()),placeholder:p,className:"h-8 rounded-md border border-ink/15 bg-paper px-2 text-xs text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10.5px] text-ink/50",children:["Where new worktrees are created. Relative paths are resolved against the project; ~ is your home directory. Empty uses ",p,"."]})]}),e("label",{className:"flex items-start gap-2",children:[e("input",{type:"checkbox",checked:P,onChange:(S)=>{let I=S.currentTarget.checked;N(I),rt(_n,I)},className:`${he} mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Copy ignored files into new worktrees"}),e("span",{className:"text-[10.5px] text-ink/50",children:"A new worktree gets the project's ignored build folders (node_modules, .venv, target) copied in, so it works without reinstalling."})]})]})]})}var qp={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},Ae=({variant:t="full",children:r})=>e("div",{className:qp[t],children:r});var Vt="";function Ai(t){if(!w(t))return!1;return typeof t.id==="string"&&typeof t.name==="string"&&typeof t.path==="string"}function Qp(t){if(!w(t))return!1;return typeof t.label==="string"&&typeof t.value==="string"&&typeof t.bgHex==="string"}function eu(t,r){return t.some((c)=>c.id===r.id)?t.map((c)=>c.id===r.id?r:c):[...t,r]}function Ei(t){let[r,l]=n([]),[c,p]=n([]),[h,g]=n(Vt),[v,x]=n(!0),[y,k]=n(null),[P,N]=n(!1),[A,C]=n(!1),R=i(t);R.current=t;let S=a((K)=>{if(!w(K))return;let q=Array.isArray(K.projects)?K.projects.filter(Ai):null;if(q)l(q),g((X)=>q.some((Z)=>Z.id===X)?X:q[0]?.id??Vt);if(Array.isArray(K.accentColorOptions))p(K.accentColorOptions.filter(Qp))},[]),I=a(async()=>{try{let K=await fetch("/api/settings/projects"),q=await K.json();if(!K.ok){let X=w(q)&&typeof q.error==="string"?q.error:`HTTP ${K.status}`;k(X);return}k(null),S(q)}catch(K){k(K instanceof Error?K.message:String(K))}},[S]);o(()=>{let K=!0;return(async()=>{if(await I(),K)x(!1)})(),()=>{K=!1}},[I]);let T=He().folders,M=u(()=>T.map((K)=>`${K.id}:${K.name}:${K.model??""}:${K.icon??""}:${K.accentColor??""}:${K.project_path??""}:${K.isPinned?1:0}`).join("|"),[T]);o(()=>{if(!M)return;I()},[M,I]);let U=a(async(K,q)=>{if(K.folderId===void 0)return R.current("This project has no workspace row to save to."),!1;let X=r;l((te)=>te.map((Q)=>Q.id===K.id?{...Q,...q}:Q));let Z={folderId:K.folderId};for(let[te,Q]of Object.entries(q))Z[te]=Q===void 0?null:Q;try{let te=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:Z})}),Q=await te.json().catch(()=>null);if(!te.ok){let ae=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${te.status}`;throw Error(ae)}let se=w(Q)&&Ai(Q.project)?Q.project:null;if(se)l((ae)=>eu(ae,se));return!0}catch(te){return l(X),R.current(te instanceof Error?te.message:String(te)),!1}},[r]),F=a((K,q,X)=>U(K,{[q]:X}),[U]),j=a((K,q)=>U(K,q),[U]),V=a(async(K)=>{N(!0);try{let q=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K.name,path:K.path})}),X=await q.json().catch(()=>null),Z=w(X)?X.folder:null,te=w(Z)&&typeof Z.id==="number"?Z.id:null;if(!q.ok||!w(X)||X.success!==!0||te===null){let Q=w(X)&&typeof X.error==="string"?X.error:`HTTP ${q.status}`;throw Error(Q)}await I(),g(`folder-${te}`)}catch(q){throw R.current(q instanceof Error?q.message:String(q)),q}finally{N(!1)}},[I]),z=a(async(K)=>{C(!0);try{let q=await fetch(`/api/settings/projects?id=${encodeURIComponent(K.id)}`,{method:"DELETE"}),X=await q.json().catch(()=>null);if(!q.ok||!w(X)||X.success!==!0){let Z=w(X)&&typeof X.error==="string"?X.error:`HTTP ${q.status}`;throw Error(Z)}l((Z)=>{let te=Z.filter((Q)=>Q.id!==K.id);return g((Q)=>Q===K.id?te[0]?.id??Vt:Q),te})}catch(q){throw R.current(q instanceof Error?q.message:String(q)),q}finally{C(!1)}},[]),H=Wa((K)=>Array.isArray(K.modelList)&&K.modelList.length>0?K.modelList.map((q)=>({provider:q.provider,id:q.id,name:q.name||q.id})):void 0)??[],W=r.find((K)=>K.id===h)??r[0]??null;return{projects:r,selected:W,selectedId:W?.id??Vt,select:g,accentColorOptions:c,models:H,isLoading:v,loadError:y,refresh:I,updateField:F,updateFields:j,isAdding:P,addProject:V,isDeleting:A,deleteProject:z,onError:t}}function Li(){let t=ye(),{pushToast:r}=je(),[l,c]=n(!1),[p,h]=n(null),[g,v]=n(null),[x,y]=n(null),k=Ei((R)=>r(R,"error",{duration:7000})),{folders:P}=He(),N=async(R)=>{if(!R.path||R.folderId===void 0){r("This project is not bound to a directory.","error");return}y(R.id);try{let S=await fetch(`/api/folders/${R.folderId}/open`,{method:"POST"}),I=await S.json().catch(()=>null);if(!S.ok){let T=I&&typeof I==="object"&&"error"in I&&typeof I.error==="string"?I.error:`HTTP ${S.status}`;throw Error(T)}}catch(S){r(S instanceof Error?S.message:String(S),"error")}finally{y(null)}},A=async()=>{if(!p)return;v(null);try{await k.deleteProject(p),h(null),t.back()}catch(R){v(R instanceof Error?R.message:String(R))}};if(k.isLoading)return e(Ae,{children:"Loading projects…"});let C=k.selected;return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(we,{pane:t.pane,onBack:t.back,listLabel:"Projects",list:e(gi,{projects:k.projects,selectedProjectId:C?.id??"",onSelectProject:(R)=>{k.select(R),t.openDetail()},onAddProject:()=>c(!0),onTogglePin:(R)=>{k.updateField(R,"isPinned",!R.isPinned)},isAdding:k.isAdding,folderFacts:P,loadError:k.loadError}),detail:C?e("div",{className:"flex-1 min-h-0 scrollbar-overlay-container flex flex-col",children:[e(wi,{project:C,canDelete:k.projects.length>1,isDeleting:k.isDeleting&&p?.id===C.id,isRevealing:x===C.id,models:k.models,accentColorOptions:k.accentColorOptions,onUpdateField:(R,S)=>{k.updateField(C,R,S)},onUpdateFields:(R)=>{k.updateFields(C,R)},onReveal:()=>void N(C),onDeleteProject:()=>{v(null),h(C)}}),e("div",{className:"border-t border-ink/10 px-6 md:px-8 py-4",children:e(Ii,{root:C.path||null,folderId:C.folderId??null,onReport:(R,S)=>r(R,S??"success",{duration:6000})})})]}):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center",children:e("div",{className:"space-y-2",children:[e("p",{className:"text-xs text-ink/60",children:"No project selected."}),e("button",{type:"button",onClick:()=>c(!0),className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add a project"})]})})}),e(Si,{isOpen:l,isSaving:k.isAdding,onClose:()=>c(!1),onSubmit:async(R)=>{await k.addProject(R),t.openDetail()}}),e(Ni,{project:p,isDeleting:k.isDeleting,error:g,onClose:()=>{h(null),v(null)},onConfirm:()=>void A()})]})}function Oi(t){return t!==void 0&&(t.status==="connected"||Boolean(t.baseUrl))}function Di(t){return t.filter((r)=>r.slug.trim().length>0&&Oi(r)).map((r)=>r.slug)}function Fi(t,r){let l=new Map;for(let h of t){let g=h.slug.trim().toLowerCase();if(g)l.set(g,h)}let c=new Set,p=[];for(let h of r){let g=h.slug.trim().toLowerCase();if(c.has(g))continue;if(!h.bundled&&Oi(l.get(g)))continue;c.add(g),p.push(h)}return p}function $i(t){let r=[];for(let l of t){let c=r.find((p)=>p.group===l.group);if(c)c.options.push(l);else r.push({group:l.group,options:[l]})}return r}var Bi="/api/settings/providers";async function _i(t){let r=await fetch(Bi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)throw Error(l?.error||`Providers request failed (HTTP ${r.status})`);return Xr(),Array.isArray(l.providers)?l.providers:null}function zi(t){return _i({providers:t})}function Hi(t,r){return _i(r?{enableProvider:t}:{disableProvider:t})}async function Gi(t,r){try{let l=await fetch("/api/settings/provider-entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,...r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??c.reason??`HTTP ${l.status}`};return Xr(),{...c,ok:!0}}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while saving the provider"}}}async function Wi(t,r){try{let l=await fetch("/api/provider-icon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,baseUrl:r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??`HTTP ${l.status}`};return c}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while fetching the icon"}}}async function Qi(t){try{let r=await fetch("/api/settings/providers/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{slug:t}:{})}),l=await r.json();if(!r.ok)return{ok:!1,added:0,removed:0,changed:[],error:l.error??`HTTP ${r.status}`};return Xr(),l}catch(r){return{ok:!1,added:0,removed:0,changed:[],error:r instanceof Error?r.message:"Network error while refreshing models"}}}async function ta(t){try{let r=await fetch(`${Bi}?id=${encodeURIComponent(t)}`,{method:"DELETE"}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Delete failed (HTTP ${r.status})`};return Xr(),{...l,ok:!0}}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while deleting the provider"}}}function na(t,r){if(t.modelSource==="discovery")return{text:`${t.name} registered — omp discovers its models on each run.`,tone:"success"};if(t.modelSource==="override")return{text:`${t.name} endpoint registered — omp keeps its own model list for this provider.`,tone:"success"};if(r.fetchedCount>0)return{text:`Fetched ${r.fetchedCount} new model${r.fetchedCount===1?"":"s"} from the provider.`,tone:"success"};if(r.fetchedCount===-1)return{text:r.ompNote?`Provider registered, but models could not be listed: ${r.ompNote}`:"Auto-fetch models failed — provider added with default models.",tone:"warning"};return{text:`${t.name} registered — no new models to add.`,tone:"success"}}function oa(t){let r=(l)=>l===1?"":"s";if(t.addedCount>0&&t.removedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} and removed ${t.removedCount} the provider no longer serves.`,tone:"success"};if(t.addedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} from the provider.`,tone:"success"};if(t.removedCount>0)return{text:`Removed ${t.removedCount} model${r(t.removedCount)} the provider no longer serves.`,tone:"success"};return{text:"Models refreshed — the list already matches the provider.",tone:"success"}}function ia(t){if(!t.omp)return null;if(t.omp.written){let r=[];if(t.omp.addedCount>0)r.push(`${t.omp.addedCount} new model${t.omp.addedCount===1?"":"s"} registered`);if(t.omp.backfilledCount>0)r.push(`${t.omp.backfilledCount} model${t.omp.backfilledCount===1?"":"s"} enriched`);if((t.omp.removedCount??0)>0)r.push(`${t.omp.removedCount} model${t.omp.removedCount===1?"":"s"} removed`);return{text:`omp models.yml updated${r.length>0?`: ${r.join(", ")}`:""}.`,tone:"success"}}if(t.omp.reason)return{text:`omp models.yml not updated: ${t.omp.reason}`,tone:"warning"};return null}function aa(t,r){let l=(c)=>c===1?"":"s";if(r.added>0||r.removed>0){let c=[];if(r.added>0)c.push(`${r.added} new model${l(r.added)}`);if(r.removed>0)c.push(`${r.removed} model${l(r.removed)} gone`);return{text:`${t}: ${c.join(", ")} after omp re-ran discovery.`,tone:"success"}}return{text:`${t}: omp re-ran discovery — this provider's list is unchanged.`,tone:"success"}}async function gt(){try{let r=await(await fetch("/api/settings/providers")).json();if(!Array.isArray(r?.providers))return null;return{providers:r.providers,...r.presetProviders?{presetProviders:r.presetProviders}:{},...typeof r.catalogError==="string"?{catalogError:r.catalogError}:{}}}catch(t){return console.error("Failed to load providers from API:",t),null}}async function sa(t,r,l){let c={provider:t,modelId:r};if("maxTokens"in l)c.maxTokens=l.maxTokens??null;if("reasoningEffort"in l)c.reasoningEffort=l.reasoningEffort??null;if(Object.keys(c).length===2)return{ok:!0,written:!1};try{let p=await fetch("/api/settings/model-override",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),h=await p.json();if(!p.ok)return{ok:!1,error:h.error||"Failed to save the model configuration."};return{ok:!0,written:h.written,reason:h.reason}}catch(p){return console.error("Failed to save model override:",p),{ok:!1,error:"Failed to save the model configuration."}}}function la(t){let{providers:r,selectedProvider:l,isDeletingProvider:c,pushToast:p,setProviders:h,setSelectedProviderId:g,setIsAddModalOpen:v,setIsDeleteModalOpen:x,setIsDeletingProvider:y,openLogin:k,openEntryEditor:P,onAddModalClose:N}=t,A=async(j)=>{h(j);try{let V=await zi(j);if(V)h(V)}catch(V){console.error("Failed to save providers via API:",V),p("Failed to save provider settings.","error")}},C=async()=>{let j=await gt();if(j)h(j.providers);return j?.providers??[]},R=async(j,V)=>{try{let z=await Hi(j,V);if(z)h(z);return z}catch(z){return console.error("Failed to update provider connection:",z),p("Failed to update the provider connection.","error"),null}};return{handleAddProvider:async(j,V)=>{let z=j.slug.trim().toLowerCase(),H=r.filter((X)=>X.slug.trim().toLowerCase()!==z);await A([...H,j]);let K=(await R(j.slug,!0))?.find((X)=>X.slug.trim().toLowerCase()===z);g(K?.id||j.id),v(!1),N?.();let q=na(j,V);p(q.text,q.tone)},handleConnect:(j)=>{if(!l)return;if(j==="login")k();else P()},handleEntrySaved:async(j)=>{if(!l)return;p(j.length>0?`${l.name}: updated ${j.join(", ")} in models.yml.`:`${l.name}: nothing to change.`,"success"),await C()},handleOmpAuthSuccess:async()=>{if(!l)return;let j=l.slug;p(`${l.name} signed in — omp stored the credential.`,"success");let z=(await C()).find((H)=>H.slug===j);if(z)g(z.id)},handleToggleProviderDisabled:async()=>{if(!l)return;let j=l,V=j.disabled!==!0;if(!await R(j.slug,!V))return;p(V?`${j.name} disabled — it no longer appears in the model list.`:`${j.name} enabled — its models are offered again.`,"success")},handleDeleteProvider:async(j)=>{let V=j??l;if(!V||c)return;y(!0);try{let z=await ta(V.id);if(!z.ok){p(z.error||"Failed to delete the provider.","error");return}x(!1);let H=z.providers??[];if(l?.id===V.id)g(H[0]?.id??"");if(h(H),z.warning)p(`${V.name} removed from Kabmo, but models.yml cleanup failed: ${z.warning}`,"warning");else if(z.removedFromOmp){let W=z.modelsRemoved??0;p(`${V.name} deleted from models.yml${W>0?` with its ${W} model${W===1?"":"s"}`:""}.`,"success")}else p(`${V.name} removed from Kabmo.`,"success")}finally{y(!1)}},persistProviders:A,reloadProviders:C}}async function Yt(t){try{let r=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Request failed (HTTP ${r.status})`};return l}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while fetching models"}}}async function da(t){try{let r=await fetch("/api/settings/provider-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{...l,success:!1,written:!1,error:l?.error||l?.reason};return Xr(),l}catch(r){return{success:!1,written:!1,error:r instanceof Error?r.message:"Network error while adding the model"}}}function ca(t,r){let l=new Map(t.map((v)=>[v.id,v])),c=new Set,p=[],h=[];for(let v of r){if(!v.id||c.has(v.id))continue;c.add(v.id);let x=l.get(v.id);if(!x){let y={...v};h.push(y),p.push(y);continue}p.push({...v,isVisible:x.isVisible!==!1,...x.temperature!==void 0?{temperature:x.temperature}:{},...x.maxTokens!==void 0?{maxTokens:x.maxTokens}:{},...x.topP!==void 0?{topP:x.topP}:{},...x.reasoningEffort!==void 0?{reasoningEffort:x.reasoningEffort}:{}})}let g=t.filter((v)=>!c.has(v.id)).map((v)=>v.id);return{models:p,added:h,addedCount:h.length,removed:g,removedCount:g.length}}async function pa(t,r){try{await Promise.all(r.map((l)=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:l.id,name:l.name,provider:t,contextWindow:l.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),Xr()}catch(l){console.error("Failed to sync provider models to catalog:",l)}}var tu=/^model-\d+-(?:1|2)$/;function nu(t){return`${t.name} ${t.slug} ${t.baseUrl||""}`.toLowerCase().includes("kenari")}function ua(t,r){if(!nu(t))return r;return r.filter((l)=>{let c=l.name.trim().toLowerCase(),p=c==="kenari default model"||c==="kenari fast / flash";return!(tu.test(l.id)&&p)})}function ma(t){let{providers:r,selectedProvider:l,isFetchingModels:c,pushToast:p,setProviders:h,setIsFetchingModels:g,persistProviders:v,reloadProviders:x}=t,y=async()=>{if(!l||c)return;let S=l;g(!0);try{let I=await Qi(S.slug);if(!I.ok){p(I.error||"omp could not refresh the model catalog.","error");return}if(I.providers)h(I.providers);let T=aa(S.name,I);p(T.text,T.tone)}finally{g(!1)}},k=async()=>{if(!l||c)return;let S=l;if(!S.baseUrl){p("This provider has no endpoint to import from — use “refresh” instead.","error");return}g(!0);try{let I=await Yt({baseUrl:S.baseUrl,apiKey:S.apiKey,providerSlug:S.slug,persistToOmp:!0,replaceModels:!0,...S.api?{api:S.api}:{},...S.auth?{auth:S.auth}:{}});if(!I.ok||!I.models){p(I.error||"Failed to fetch models from the provider.","error");return}if(I.omp?.written)Xr();let T=ua(S,S.models),M=S.models.length-T.length,{added:U,addedCount:F,removedCount:j}=ca(T,I.models),V=j+M,z=oa({addedCount:F,removedCount:V});p(z.text,z.tone);let H=ia(I);if(H)p(H.text,H.tone);if(F>0)pa(S.name,U);await x()}finally{g(!1)}},P=(S)=>{if(!l)return;v(r.map((I)=>I.id===l.id?{...I,models:S(I.models)}:I))};return{handleRefreshModels:y,handleFetchModels:k,handleHideAll:()=>P((S)=>S.map((I)=>({...I,isVisible:!1}))),handleShowAll:()=>P((S)=>S.map((I)=>({...I,isVisible:!0}))),handleToggleModelVisibility:(S)=>P((I)=>I.map((T)=>T.id===S?{...T,isVisible:!T.isVisible}:T)),handleSaveModelConfig:async(S,I)=>{if(!l)return;let T=l;P((U)=>U.map((F)=>F.id===S?{...F,...I}:F));let M=await sa(T.slug,S,I);if(!M.ok){p(M.error||"Failed to save the model configuration.","error");return}if(M.written)Xr();else if(M.reason)p(M.reason,"error")}}}function fa({autoOpenAdd:t=!1,onAddModalClose:r}={}){let[l,c]=n([]),[p,h]=n([]),[g,v]=n(""),[x,y]=n(null),[k,P]=n(!0),[N,A]=n(!1),[C,R]=n(!1),[S,I]=n(!1),{pushToast:T}=je(),[M,U]=n(t),[F,j]=n(!1),[V,z]=n(!1),[H,W]=n(!1),[K,q]=n(!1),[X,Z]=n(!1),[te,Q]=n(!1),[se,ae]=n(null),[be,xe]=n(null);o(()=>{if(t)U(!0)},[t]),o(()=>{let le=!0;return gt().then((me)=>{if(!le)return;if(P(!1),!me)return;c(me.providers),h(me.presetProviders??[]),y(me.catalogError??null);let Be=me.providers.filter((Ye)=>Ye.status==="connected");v(Be[0]?.id??me.providers[0]?.id??"")}),()=>{le=!1}},[]),o(()=>{let le=null,me=Ea(()=>{if(le)clearTimeout(le);le=setTimeout(()=>{le=null,gt().then((Be)=>{if(Be)c(Be.providers)})},400)});return()=>{if(me(),le)clearTimeout(le)}},[]);let Pe=u(()=>Fi(l,p),[l,p]),ue=u(()=>Di(l),[l]),ve=l.find((le)=>le.id===g)??l[0],Te=la({providers:l,selectedProvider:ve,isDeletingProvider:K,pushToast:T,setProviders:c,setSelectedProviderId:v,setIsAddModalOpen:U,setIsDeleteModalOpen:z,setIsDeletingProvider:q,openLogin:()=>Q(!0),openEntryEditor:()=>Z(!0),...r?{onAddModalClose:r}:{}}),ke=ma({providers:l,selectedProvider:ve,isFetchingModels:C,pushToast:T,setProviders:c,setIsFetchingModels:R,persistProviders:Te.persistProviders,reloadProviders:Te.reloadProviders});return{providers:l,availablePresetProviders:Pe,existingSlugs:ue,selectedProvider:ve,catalogError:x,isLoading:k,isRefreshingList:N,handleRefreshList:async()=>{if(N)return;A(!0);try{let le=await gt();if(!le){T("Could not read the provider list — omp may still be starting.","error");return}c(le.providers),h(le.presetProviders??[]),y(le.catalogError??null),v((Be)=>le.providers.some((Ye)=>Ye.id===Be)?Be:le.providers.find((Ye)=>Ye.status==="connected")?.id??le.providers[0]?.id??"");let me=le.providers.length;T(`Provider list refreshed — ${me} provider${me===1?"":"s"}.`,"success")}finally{A(!1)}},isFetchingModels:C,isRefreshingIcon:S,handleRefreshIcon:async()=>{let le=ve;if(!le||S)return;if(!le.baseUrl){T("This provider has no endpoint, so there is no site to read an icon from.","error");return}I(!0);try{let me=await Wi(le.slug,le.baseUrl);if(!me.ok){T(me.error||"No usable icon on that host or its base domain — keeping the current mark.","error");return}let Ye=(await Te.reloadProviders()).find((Tc)=>Tc.slug===le.slug);if(Ye)v(Ye.id);T(`${le.name}: icon updated from ${le.baseUrl}.`,"success")}finally{I(!1)}},pushToast:T,isAddModelModalOpen:F,setIsAddModelModalOpen:j,handleModelAdded:async(le)=>{T(`${le} registered in models.yml.`,"success"),await Te.reloadProviders()},handleSignedOut:async(le)=>{W(!1),T(le,"success"),await Te.reloadProviders()},isDeleteModalOpen:V,setIsDeleteModalOpen:z,isLogoutModalOpen:H,setIsLogoutModalOpen:W,isDeletingProvider:K,isAddModalOpen:M,setIsAddModalOpen:U,isEntryModalOpen:X,setIsEntryModalOpen:Z,isLoginModalOpen:te,setIsLoginModalOpen:Q,configModel:se,setConfigModel:ae,capabilitiesModel:be,setCapabilitiesModel:xe,setSelectedProviderId:v,...Te,...ke}}function ou(t){if(t.disabled===!0)return"disabled";if(t.status==="connected")return"connected";return"signed-out"}var ru=[{id:"connected",label:"Signed in"},{id:"signed-out",label:"Not signed in",hint:"omp knows these providers; pick one to sign in or add its key."},{id:"disabled",label:"Disabled",hint:"Hidden from the model picker."}];function xa(t,r=""){let l=r.trim().toLowerCase(),c=l?t.filter((h)=>h.name.toLowerCase().includes(l)||h.slug.toLowerCase().includes(l)||h.models.some((g)=>g.id.toLowerCase().includes(l))):t,p=new Map;for(let h of c){let g=ou(h),v=p.get(g);if(v)v.push(h);else p.set(g,[h])}return ru.flatMap((h)=>{let g=p.get(h.id);if(!g||g.length===0)return[];return[{...h,providers:[...g].sort((v,x)=>v.name.localeCompare(x.name))}]})}function zn(t){return t.inModelsYml===!0||t.inOverlay===!0}function wa(t){if(t.disabled===!0)return"Disabled — hidden from the model picker";if(t.status==="connected")switch(t.credentialOrigin){case"models.yml":return"Signed in — key stored in models.yml";case"login":return"Signed in — OAuth credential stored by omp";case"api-key":return"Signed in — API key stored by omp";case"environment":return"Signed in — credential comes from the environment";default:return"Signed in"}return t.oauth===!0?"Not signed in — pick this row to sign in with OAuth":"Not signed in — no credential omp can resolve"}function Sa({providers:t,selectedProviderId:r,onSelectProvider:l,onOpenAddModal:c,onRefresh:p,isRefreshing:h,isLoading:g,catalogError:v}){let[x,y]=n(""),k=i(null),P=xa(t,x);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3 pt-3 pb-2 flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:g?"Loading…":`${t.length} provider${t.length===1?"":"s"}`}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:h||g,title:"Refresh the provider list","aria-label":"Refresh the provider list",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(D,{size:14,strokeWidth:2.2,className:h?"animate-spin":""})}),e("button",{type:"button",onClick:c,title:"Add provider","aria-label":"Add provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]})]}),e("div",{className:"px-3 pb-2",children:e("div",{className:"relative flex items-center",children:[e(O,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{ref:k,type:"text",value:x,onChange:(N)=>y(N.currentTarget.value),placeholder:"Filter providers or models…","aria-label":"Filter providers",className:"w-full bg-paper border border-ink/15 rounded-md pl-7 pr-7 py-1.5 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),x&&e("button",{type:"button",onClick:()=>{y(""),k.current?.focus()},title:"Clear the filter","aria-label":"Clear the filter",className:"absolute right-1.5 p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:11})})]})}),v&&e("p",{className:"mx-3 mb-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10 text-[10px] leading-relaxed text-ink/70",children:["Model catalog unavailable: ",v]}),e("div",{className:"flex-1 scrollbar-overlay-container px-1.5 pb-3",children:g?e("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-[11px] text-ink/45",role:"status","aria-live":"polite",children:[e(m,{size:16,className:"animate-spin"}),e("span",{children:"Reading providers…"})]}):P.length===0?e("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:x?`No provider or model matches “${x}”.`:"No providers detected yet. Use the plus button above to register one."}):P.map((N)=>e("div",{className:"pt-1.5 first:pt-0",children:[e("div",{className:"px-2 pb-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/45 uppercase",children:N.label}),e("span",{className:"text-[10px] font-mono text-ink/35",children:N.providers.length})]}),N.hint&&e("p",{className:"text-[10px] leading-snug text-ink/40 mt-0.5",children:N.hint})]}),e("div",{className:"space-y-0.5",children:N.providers.map((A)=>{let C=A.id===r;return e("button",{type:"button",onClick:()=>l(A.id),"aria-current":C?"true":void 0,title:wa(A),className:`w-full flex items-center gap-2 pl-1.5 pr-2 py-1 rounded-md text-left transition-colors cursor-pointer ${C?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(lt,{provider:A,size:22}),e("span",{className:"flex-1 min-w-0 text-[12px] truncate",children:A.name}),e("span",{className:"w-8 shrink-0 text-right text-[10px] font-mono tabular-nums text-ink/45",children:A.models.length})]},A.id)})})]},N.id))})]})}function Na({provider:t,onRefreshIcon:r,isRefreshingIcon:l=!1}){return e("div",{className:"flex items-start gap-3 pb-4",children:[e(lt,{provider:t,size:30,className:"mt-0.5"}),e("div",{className:"min-w-0 flex flex-1 flex-col gap-0.5",children:[e("h2",{className:"text-xl font-bold leading-tight tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs font-mono text-ink/50 truncate",children:t.slug})]}),r&&e("button",{type:"button",onClick:r,disabled:l,title:t.baseUrl?`Refetch the icon from ${t.baseUrl}`:"This provider has no endpoint to read an icon from","aria-label":"Refresh provider icon",className:"shrink-0 p-1.5 rounded-md border border-ink/15 text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(D,{size:12,className:l?"animate-spin":""})})]})}function Pa(t){switch(t){case"models.yml":return"models.yml key";case"login":return"OAuth login";case"api-key":return"stored API key";case"environment":return"environment variable";default:return"no credential"}}function Ca(t){return t==="login"||t==="api-key"}function Ia(t){let r=t.oauth===!0&&t.auth!=="none"&&t.credentialOrigin!=="models.yml",l=t.inModelsYml===!0;if(r||l)return{login:r,edit:l};return{login:!1,edit:!1,reason:"omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit."}}function Ra({provider:t,onConnect:r,onToggleDisabled:l,onDelete:c,onSignOut:p}){let[h,g]=n(!1),v=t.status==="connected",x=t.disabled===!0,y=t.credentialOrigin,k=Ca(y),P=Ia(t);return e("div",{className:"space-y-6",children:[e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[x?e(d,{children:[e(Qn,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):v?e(d,{children:[e(f,{size:15,className:"text-success flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):e(d,{children:[e(E,{size:15,className:"text-warning flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/80",children:"Not signed in"})]}),e("span",{className:"text-[11px] text-ink/55 font-mono px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10",children:Pa(y)}),e("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[e(de,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),h&&e("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl w-64 z-50 pointer-events-none leading-relaxed",children:x?"Disabled in omp’s config.yml — none of its models appear in the chat model list. The credential is untouched.":v?"omp can resolve a credential for this provider, so its models are offered in the chat picker.":"omp knows this provider but has no credential for it. Connect to sign in or supply a key."})]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:l,title:x?"Offer this provider in the model list again":"Hide this provider and its models from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:x?"enable":"disable"}),P.login&&e("button",{type:"button",onClick:()=>r("login"),title:"Sign in to this provider through omp",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:[e(tr,{size:12}),e("span",{children:v&&y==="login"?"sign in again":"sign in"})]}),P.edit&&e("button",{type:"button",onClick:()=>r("edit"),title:"Edit this provider’s endpoint, credential and dialect in models.yml",className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer border ${P.login?"bg-ink/5 hover:bg-ink/10 text-ink border-ink/15":"bg-ink text-canvas hover:opacity-90 border-ink"}`,children:[e(Fn,{size:12}),e("span",{children:"edit"})]}),!P.login&&!P.edit&&e("button",{type:"button",disabled:!0,title:P.reason,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium opacity-40 cursor-not-allowed",children:[e(bo,{size:12}),e("span",{children:"connect"})]}),k&&e("button",{type:"button",onClick:p,title:"Remove the credential omp stored for this provider",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:[e(Kt,{size:12}),e("span",{children:"sign out"})]}),e("button",{type:"button",onClick:c,disabled:!zn(t),title:zn(t)?t.inModelsYml?"Remove this provider’s models.yml entry":"Remove this provider’s Kabmo settings row":"Nothing to delete: omp discovered this provider from its endpoint. Use disable to hide it.",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-error/10 hover:bg-error/20 text-error text-xs font-medium transition-colors cursor-pointer border border-error/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(L,{size:12}),e("span",{children:"delete"})]})]})]})]}),e("div",{className:"border-b border-ink/10"}),e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Connection details"}),e("div",{className:"flex items-center justify-between gap-4",children:[e("div",{className:"text-xs text-ink/70 min-w-0",children:["Configured in:"," ",e("span",{className:"font-mono text-ink font-medium break-all",children:t.configuredIn})]}),e("span",{className:"text-[11px] text-ink/40 italic shrink-0",children:x?"hidden":v?"active":"inactive"})]}),(t.api||t.auth||t.discovery||t.transport)&&e("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[t.api&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Wire API omp uses for this provider",children:t.api}),t.auth&&t.auth!=="apiKey"&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Auth mode from models.yml",children:["auth: ",t.auth]}),t.discovery&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"omp lists this provider's models live",children:["discovery: ",t.discovery]}),t.transport&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Requests are routed through the auth gateway",children:["transport: ",t.transport]}),t.headers&&Object.keys(t.headers).length>0&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:Object.entries(t.headers).map(([N,A])=>`${N}: ${A}`).join(`
|
|
1
|
+
import{d,n,o,i,u,a,oe,pn,ga,Ri,Pg,e,w,s,Ao,E,ne,De,$a,Tn,xn,m,Vn,Le,Xt,L,_,Ls,en,Aa,Qn,Ms,ha,tn,wt,kr,f,B,ie,ba,Jo,qr,Xo,re,tt,Ua,fe,Ce,Ct,qe,Nt,nt,ge,Qe,Ga,de,bo,ya,Hr,Kr,sn,nn,va,ni,Mi,ka,Vr,Fn,Pi,Y,vo,Cr,D,Rt,O,ko,xo,pr,mr,Yn,Ft,_e,Yr,Ui,b,qg,ji,Sp,Hl,Tp,Hg,Mn,ri,Dp,G,Wg,rt,Jr,Ge,jf,Lu,Jn,Et,at,pe,ot,qi,J,jt,qt,Hf,Ie,Rp,je,he,Gs,Ki,rn,dA,pA,Mp,mA,fA,Pp,gA,Op,$p,Eo,AA,hA,zp,Wf,Up,ee,Ht,Wt,lt,qa,Kp,kA,xA,wA,CA,EA,BA,IA,Xl,_A,Vp,SA,TA,Yp,DA,ec,Gu,Zr,tc,Jp,Io,Ha,Xr,Ea,Zp,ju,Xp,Yf,NA,RA,FA,Jf,em,ht,_t,Ws,LA,Zf,fn,Vi,Wa,nc,nm,Yi,bt,So,rm,Xf,PA,eg,qu,am,ac,OA,ea,oc,$A,zA,om,im,tg,sm,UA,ic,sc,lm,lc,Ji,cm,He,cc,Zi,uc,Xi,Vs,dc,pc,mc,um}from"./index-4c2zcvem.js";import{vt,md,fd,gd,Kc,Ad,hd,ul,Jc,cs,dl,fi}from"./index-jze0zg3z.js";import{ra,pu,Cs,vg,mu,fu}from"./index-87qandgr.js";import{ml,Ta,Ag,hg,fl,bg,yg,ws}from"./index-m847wafq.js";var Ic={name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]},Bo=s(Ic);var Ac={name:"square-check-big",size:24,node:[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-square"]},_o=s(Ac);var Rc={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]},Je=s(Rc);var Mc={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]},Ko=s(Mc);var Ec={name:"calendar-range",size:24,node:[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M17 13h-6",key:"1qbiup"}],["path",{d:"M13 17H7",key:"1x38vv"}],["path",{d:"M7 13h.01",key:"1vezk1"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]},zo=s(Ec);var Lc={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]},Ho=s(Lc);var Oc={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]},Bt=s(Oc);var Dc={name:"dice-5",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]},Go=s(Dc);var Uc={name:"dollar-sign",size:24,node:[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]},Wo=s(Uc);var Fc={name:"file-diff",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]},qo=s(Fc);var jc={name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]},Vo=s(jc);var $c={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]},Yo=s($c);var Bc={name:"hammer",size:24,node:[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]},Qo=s(Bc);var _c={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]},Zo=s(_c);var zc={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]},mt=s(zc);var Hc={name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]},er=s(Hc);var Gc={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]},Kt=s(Gc);var Wc={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]},tr=s(Wc);var qc={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]},zt=s(qc);var Vc={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]},nr=s(Vc);var Yc={name:"power",size:24,node:[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]},or=s(Yc);var Xc={name:"store",size:24,node:[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]},dt=s(Xc);var Qc={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]},Gt=s(Qc);var Zc={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]},On=s(Zc);var ep={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]},rr=s(ep);var tp={name:"waypoints",size:24,node:[["path",{d:"m10.586 5.414-5.172 5.172",key:"4mc350"}],["path",{d:"m18.586 13.414-5.172 5.172",key:"8c96vv"}],["path",{d:"M6 12h12",key:"8npq4p"}],["circle",{cx:"12",cy:"20",r:"2",key:"144qzu"}],["circle",{cx:"12",cy:"4",r:"2",key:"muu5ef"}],["circle",{cx:"20",cy:"12",r:"2",key:"1xzzfp"}],["circle",{cx:"4",cy:"12",r:"2",key:"1hvhnz"}]]},Dn=s(tp);function ir(t,r,l){let c={},p=typeof l==="function"?Object.keys(r):Object.keys(l);for(let h of p)if(r[h]!==t[h])c[h]=r[h];return c}var ar="color";var sr=["color","monochrome"];function np(t){return t==="color"||t==="monochrome"}function lr(t){return np(t)?t:"color"}var dr={color:{label:"Full colour",description:"The shipped app icon, plate and all. Matches the icon in the Dock, the taskbar and the launcher.",caption:"App icon"},monochrome:{label:"Monochrome",description:"A greyscale conversion of the app icon: the green plate and the cream strokes swap luminance with the theme, and the orange arm becomes the middle grey.",caption:"Greyscale"}};var cr={theme:Gs,editorFont:Gu,editorTheme:tc,autoSessionTitle:!0,soundAlerts:!0,chatCompletionSound:!0,notifyDesktopEnabled:!0,notifyMobileEnabled:!0,notifyOnFinish:!1,notifyOnAsk:!1,notifyOnError:!1,goalAuditEnabled:!0,goalAuditModel:"",goalDefaultBudget:null,chatWidthMode:Kp,toolRenderStyle:wA,showChangedFiles:!0,sidebarStyle:Ag,composerStyle:IA,surfaceStyle:SA,iconStyle:mA,trayIconStyle:ar,followUpBehavior:"queue",keybindingSend:"Enter",keybindingNewLine:"Shift + Enter",keybindingSteering:"Ctrl / Cmd + Enter"};function ur(){let[t,r]=n(!1),l=a(async()=>{r(!0);try{let c=await fetch("/api/omp/reload-engine",{method:"POST"}),p=await c.json().catch(()=>null);if(!c.ok||!p?.success)return{ok:!1,message:p?.error??`Reload failed (HTTP ${c.status})`};Io(),Xr();let h=p.utility??0,g=p.prewarmed??0;return{ok:!0,message:h+g===0?"No standby omp processes were running — the next command starts the current build.":`Reloaded omp engine — ${h} utility, ${g} prewarmed process${h+g===1?"":"es"} recycled.`}}catch(c){return{ok:!1,message:c instanceof Error?c.message:"Failed to reload the omp engine."}}finally{r(!1)}},[]);return{isReloading:t,reload:l}}function gr(t={}){let{restart:r}=t,[l,c]=n(!1),p=a(async()=>{c(!0);try{let h=await ju(r),g=await fetch("/api/console/restart",{method:"POST"}),v=await g.json().catch(()=>null);if(!g.ok||!v?.success)return{ok:!1,message:v?.error??`Restart failed (HTTP ${g.status})`};if(!v.restarting)return{ok:!1,message:v.message??"This instance cannot be restarted from the console."};let x=await Xp(h,r);if(x==="restarted")return window.location.reload(),{ok:!0,message:v.message??"Restarting — this page reloads on its own."};if(x==="timeout")return{ok:!1,message:`The server did not come back within ${Math.round((r?.timeoutMs??Zp)/1000)} seconds — reload this page once it is up.`};return{ok:!1,message:"The restart was cancelled."}}catch(h){return{ok:!1,message:h instanceof Error?h.message:"Failed to restart Kabmo."}}finally{c(!1)}},[r]);return{isRestarting:l,restart:p}}function br(t,r){if(typeof document<"u"&&r.theme)Up(r.theme);if(typeof window<"u"&&r.editorFont!==t.editorFont)window.dispatchEvent(new CustomEvent(em,{detail:r.editorFont}));if(typeof window<"u"&&r.editorTheme!==t.editorTheme)window.dispatchEvent(new CustomEvent(md,{detail:r.editorTheme}));if(r.chatWidthMode!==t.chatWidthMode)Yf(r.chatWidthMode);if(r.toolRenderStyle!==t.toolRenderStyle)NA(r.toolRenderStyle);if(r.showChangedFiles!==t.showChangedFiles)RA(r.showChangedFiles);if(r.sidebarStyle!==t.sidebarStyle)yg(r.sidebarStyle);if(r.composerStyle!==t.composerStyle)FA(r.composerStyle);if(r.surfaceStyle!==t.surfaceStyle)Jf(r.surfaceStyle);if(r.iconStyle!==t.iconStyle)Wf(r.iconStyle)}var fr=["KABMO","CONNECT","WORKSPACE","OMP","HARNESSES"];var hr=[{id:"appearance",label:"Appearance",icon:ka,section:"KABMO",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:sn,section:"KABMO",description:"Chat width, composer style, tool call rendering, session titles, and goal mode."},{id:"keyboard",label:"Keyboard",icon:ya,section:"KABMO",description:"Every command shortcut, the composer Enter keys, and chord conflicts."},{id:"notifications",label:"Notifications",icon:ha,section:"KABMO",description:"Completion sound, separate Desktop and Mobile delivery switches, and the finished, waiting-for-you and failed run triggers."},{id:"usage",label:"Usage",icon:Ao,section:"KABMO",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:Xo,section:"KABMO",description:"Token telemetry, cache, and cost breakdown."},{id:"panel-plugins",label:"Plugins Kabmo",icon:vo,section:"KABMO",description:"Plugins installed into Kabmo: panels, background services, and the MCP servers they register."},{id:"connect",label:"Connect",icon:Cr,section:"CONNECT",description:"Tunnels, addresses, and the devices paired to this server."},{id:"projects",label:"Projects",icon:Vo,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:Ua,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:Ho,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:wt,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:Bo,section:"OMP",description:"Native AGENTS.md and RULES.md: global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:_e,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:kr,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"plugins",label:"Plugins",icon:Pi,section:"OMP",description:"Installed omp plugins, marketplaces, features, and plugin settings."},{id:"skills",label:"Skills",icon:er,section:"OMP",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:tn,section:"OMP",description:"Browse and install new skills."},...Zf().map((t)=>({id:t.id,label:t.label,icon:Dn,section:"HARNESSES",...t.harness?{harness:t.harness}:{},description:t.description}))];function vr(t){let r=Zf(t&&t.length>0?t:void 0).map((c)=>({id:c.id,label:c.label,icon:Dn,section:"HARNESSES",...c.harness?{harness:c.harness}:{},description:c.description}));return[...hr.filter((c)=>c.section!=="HARNESSES"),...r]}function Un({activeCategory:t,onSelectCategory:r,searchQuery:l,onSearchChange:c,onReloadOmp:p,isReloading:h,onRestartKabmo:g,isRestarting:v,disabledHarnesses:x=[],categories:y=hr,className:k=""}){let P=y.filter((N)=>{if(N.harness&&x.includes(N.harness))return!1;if(!l.trim())return!0;let A=l.toLowerCase();return N.label.toLowerCase().includes(A)||N.section.toLowerCase().includes(A)||N.description.toLowerCase().includes(A)});return e("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${k}`,children:[e("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:e("div",{className:"relative flex items-center",children:[e(O,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",placeholder:"Search settings",value:l,onChange:(N)=>c(N.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),l&&e("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:e(b,{size:12})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:P.length===0?e("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):fr.map((N)=>{let A=P.filter((C)=>C.section===N);if(A.length===0)return null;return e("div",{className:"space-y-1",children:[e("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:N}),e("div",{className:"space-y-0.5",children:A.map((C)=>{let R=C.icon,S=t===C.id;return e("button",{type:"button",onClick:()=>r(C.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${S?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center space-x-2.5 truncate",children:[C.harness?e("span",{className:"flex w-[14px] shrink-0 items-center justify-center",children:e(ht,{harness:C.harness,size:14})}):e(R,{size:14,className:S?"text-ink":"text-ink/60"}),e("span",{className:"truncate",children:C.label})]}),C.badge&&e("span",{className:"px-1.5 py-0.2 text-[10px] font-mono font-medium rounded border border-warning/30 bg-warning/15 text-warning",children:C.badge})]},C.id)})})]},N)})}),e("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:h||v,title:"Recycle the standby omp processes so the next command uses the installed binary","aria-label":"Reload OMP",className:"shrink-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(D,{size:12,className:`shrink-0 ${h?"animate-spin text-warning":"text-ink/60"}`}),e("span",{className:"whitespace-nowrap",children:h?"Reloading…":"Reload OMP"})]}),e("button",{type:"button",onClick:g,disabled:h||v,title:"Stop and start this Kabmo instance","aria-label":"Restart Kabmo",className:"flex-1 min-w-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(or,{size:12,className:`shrink-0 ${v?"animate-pulse text-warning":"text-ink/60"}`}),e("span",{className:"truncate",children:v?"Restarting…":"Restart Kabmo"})]})]})]})}function xr({theme:t,selected:r,onSelect:l}){return e("button",{type:"button",onClick:()=>l(t.id),"aria-pressed":r,className:`group flex w-full flex-col gap-2.5 rounded-lg border p-2.5 text-left transition-all cursor-pointer ${r?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("div",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:t.name,children:t.name}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:t.variant}),r&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("div",{className:"flex items-center gap-1",children:pA.map((c)=>e("span",{title:`${c.label} · ${t[c.key]}`,style:{backgroundColor:t[c.key]},className:"h-5 flex-1 rounded-[3px] border border-ink/10"},c.key))})]})}var op=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function rp(t){return t==="all"?Ki:Ki.filter((r)=>r.variant===t)}function yr({selectedId:t,onSelect:r}){let[l,c]=n("all"),p=u(()=>rp(l),[l]);return e("div",{className:"space-y-3 pb-6",children:[e("div",{className:"flex items-center gap-1.5",children:[op.map((h)=>e("button",{type:"button",onClick:()=>c(h.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${l===h.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[h.id==="light"&&e(Gt,{size:11,className:"mr-1 inline align-[-1px]"}),h.id==="dark"&&e(zt,{size:11,className:"mr-1 inline align-[-1px]"}),h.label]},h.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:[p.length," themes"]})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3",children:p.map((h)=>e(xr,{theme:h,selected:h.id===t,onSelect:r},h.id))})]})}function ct({width:t,active:r=!1,trailing:l=!1}){return e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:`h-[5px] w-[5px] shrink-0 rounded-full ${r?"bg-ink":"bg-ink/25"}`}),e("span",{className:`h-[3px] rounded-full ${r?"bg-ink/70":"bg-ink/25"}`,style:{width:`${t}%`}}),l&&e("span",{className:"ml-auto h-[3px] w-[6px] rounded-full bg-ink/20"})]})}function ip(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[7px] w-[30%] rounded-sm bg-ink/80"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"})]}),e("span",{className:"flex h-[7px] items-center gap-1 px-1",children:e("span",{className:"h-[3px] w-[45%] rounded-full bg-ink/45"})}),e(ct,{width:62,trailing:!0}),e(ct,{width:50,active:!0,trailing:!0}),e(ct,{width:44,trailing:!0}),e(ct,{width:56,trailing:!0})]})}function ap(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex h-[7px] items-center rounded-sm bg-ink/5 px-1",children:e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/30"})}),e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[6px] w-[16%] rounded-full bg-ink/80"}),e("span",{className:"h-[6px] w-[22%] rounded-full border border-ink/20"}),e("span",{className:"h-[6px] w-[12%] rounded-full border border-ink/20"})]}),e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:"h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50"}),e("span",{className:"h-[3px] w-[40%] rounded-full bg-ink/45"}),e("span",{className:"ml-auto h-[3px] w-[5px] rounded-full bg-ink/20"})]}),e(ct,{width:62,active:!0,trailing:!0}),e(ct,{width:50,trailing:!0}),e(ct,{width:44,trailing:!0})]})}var sp={classic:ip,modern:ap};function wr({settings:t,onUpdate:r}){let l=fl(t.sidebarStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Session sidebar"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"How the left column draws its workspaces and chats. Both styles list the same workspaces and offer the same actions; the choice applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Session sidebar style",children:hg.map((c)=>{let p=bg[c],h=c===l,g=sp[c];return e("button",{type:"button",onClick:()=>r({sidebarStyle:c}),"aria-pressed":h,"aria-label":`${p.label} sidebar — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[86px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function Sr({backdropFilter:t,reducedTransparency:r}){let l=[];if(!t)l.push("no-backdrop-filter");if(r)l.push("reduced-transparency");return l}var Nr={"no-backdrop-filter":"This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.","reduced-transparency":"Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material."};var Pr="(prefers-reduced-transparency: reduce)";function lp(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;return CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function Tr(){let[t,r]=n(()=>typeof window>"u"?!1:window.matchMedia(Pr).matches);return o(()=>{let l=window.matchMedia(Pr),c=()=>r(l.matches);return c(),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[]),Sr({backdropFilter:lp(),reducedTransparency:t})}function Ir(){return e("span",{className:"flex h-full flex-col gap-1 p-1",children:[e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/40"}),e("span",{className:"ml-auto h-[6px] w-[10%] rounded-[2px] border border-ink/20"})]}),e("span",{className:"h-[2px] w-full rounded-full bg-ink/15"}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[52%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[18%] rounded-full bg-ink/15"})]}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[44%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[22%] rounded-full bg-ink/15"})]})]})}function dp(){return e("span",{className:"block h-full rounded-md border border-ink/15 bg-paper","aria-hidden":"true",children:[e("span",{className:"block h-[13px] rounded-t-[5px] border-b border-ink/10 bg-paper",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/35"})}),e(Ir,{})]})}function cp(){return e("span",{className:"relative block h-full overflow-hidden rounded-md border border-ink/15 bg-canvas","aria-hidden":"true",children:[e("span",{className:"pointer-events-none absolute inset-0",children:[e("span",{className:"absolute -left-2 top-2 h-[70%] w-[55%] rounded-full bg-info/40 blur-md"}),e("span",{className:"absolute -right-2 -top-2 h-[60%] w-[50%] rounded-full bg-meta/35 blur-md"}),e("span",{className:"absolute -bottom-2 right-3 h-[45%] w-[45%] rounded-full bg-success/30 blur-md"})]}),e("span",{className:"relative block h-[13px] border-b border-ink/10 bg-paper/40",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/40"})}),e("span",{className:"relative block h-[calc(100%-13px)] bg-paper/50",children:e(Ir,{})})]})}var pp={classic:dp,glass:cp};function up(){let t=Tr();if(t.length===0)return null;return e("ul",{className:"space-y-1 rounded-lg border border-ink/15 bg-ink/[0.03] p-2.5","aria-live":"polite",children:t.map((r)=>e("li",{className:"flex gap-1.5 text-[11px] leading-relaxed text-ink/60",children:[e("span",{"aria-hidden":"true",className:"mt-[5px] h-1 w-1 shrink-0 rounded-full bg-ink/40"}),e("span",{children:Nr[r]})]},r))})}function Ar({settings:t,onUpdate:r}){let l=Yp(t.surfaceStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Surfaces"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"What the windows are made of. Both styles draw the same panels, rows and dialogs; the frost is one blur pass per window, and it follows the palette — there is no separate glass colour to tune."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Surface style",children:TA.map((c)=>{let p=DA[c],h=c===l,g=pp[c];return e("button",{type:"button",onClick:()=>r({surfaceStyle:c}),"aria-pressed":h,"aria-label":`${p.label} surfaces — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[78px]",children:e(g,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})}),l==="glass"&&e(up,{})]})}function mp(t){return rn(t).paper}function jn({name:t,Icon:r,colored:l,paper:c}){let p=AA(t),h=!l?void 0:p?$p[p]:Eo(hA(t),"light",c);return e(r,{size:13,strokeWidth:2,style:h?{color:h}:void 0,"aria-hidden":"true"})}function Rr({name:t,base:r,colored:l}){let c=l?r:void 0;return e("span",{className:"flex h-5 w-5 items-center justify-center rounded-[5px] border border-ink/10",style:c?{backgroundColor:`${c}22`,color:c}:void 0,title:t,"aria-hidden":"true",children:e("span",{className:`block h-2 w-2 rounded-full ${l?"":"bg-ink/60"}`,style:c?{backgroundColor:c}:void 0})})}function Mr({colored:t,paper:r}){return e("span",{className:"flex h-full items-center gap-1.5 rounded-md border border-ink/10 bg-canvas/60 px-2",children:[e(jn,{name:"Trash2",Icon:L,colored:t,paper:r}),e(jn,{name:"Check",Icon:f,colored:t,paper:r}),e(jn,{name:"Sparkles",Icon:Le,colored:t,paper:r}),e("span",{className:"mx-0.5 h-4 w-px bg-ink/10"}),e(Rr,{name:"claude",base:Op.claude.light,colored:t}),e(Rr,{name:"Typescript",base:zp.Typescript.light,colored:t})]})}function Er({settings:t,onUpdate:r}){let l=Pp(t.iconStyle),c=mp(t.theme),p={monochrome:()=>e(Mr,{colored:!1,paper:c}),color:()=>e(Mr,{colored:!0,paper:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Icons"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Every icon: toolbar and panel glyphs, provider logos and file-type marks. Full colour gives each glyph its own hue and keeps the palette’s red, green, amber and blue for signals; a colour that would disappear on the active theme falls back to the ink. A control that sets its own colour keeps it."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Icon style",children:fA.map((h)=>{let g=gA[h],v=h===l,x=p[h];return e("button",{type:"button",onClick:()=>r({iconStyle:h}),"aria-pressed":v,"aria-label":`${g.label} icons — ${g.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:g.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:g.description})]},h)})})]})}function gp(){return e("span",{className:"flex h-full items-center justify-center rounded-md border border-ink/10 bg-canvas/60",children:e("img",{src:"/icon.svg",alt:"",width:26,height:26,className:"rounded-[6px]","aria-hidden":"true"})})}function bp({variant:t}){return e("span",{className:"flex h-full items-center justify-center rounded-md border border-ink/10 bg-canvas/60",children:e("img",{src:`/tray-monochrome-${t}.png`,alt:"",width:26,height:26,"aria-hidden":"true"})})}function Lr({settings:t,onUpdate:r}){let l=lr(t.trayIconStyle),c=rn(t.theme).variant,p={color:gp,monochrome:()=>e(bp,{variant:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Tray icon"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"The menu-bar (macOS) or notification-area (Windows, Linux) icon. Full colour is the shipped app icon, orange arm and all; monochrome is a greyscale conversion: the green plate and the cream strokes swap luminance with the theme, and the orange arm becomes the middle grey. Applies the next time the tray starts, or immediately when it is already running."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Tray icon style",children:sr.map((h)=>{let g=dr[h],v=h===l,x=p[h];return e("button",{type:"button",onClick:()=>r({trayIconStyle:h}),"aria-pressed":v,"aria-label":`${g.label} tray icon — ${g.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:g.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:g.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:g.description})]},h)})})]})}function Or({settings:t,onUpdate:r}){let l=t.editorFont||ec[0].id;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(Yr,{size:16,className:"text-ink/60"}),"Editor Font"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:"Typeface for the code editor and its line numbers, in both the desktop panel and the phone's full-screen editor. Only Fira Code ships with the app; the others are used when your device has them, and fall back to Fira Code when it does not."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:ec.map((c)=>{let p=l===c.id;return e("button",{type:"button",onClick:()=>r({editorFont:c.id}),"aria-pressed":p,className:`flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-colors ${p?"border-ink/40 bg-ink/5":"border-ink/12 hover:bg-ink/5"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate text-xs text-ink",style:{fontFamily:`"${c.id}", monospace`},children:"const greet = () => 'hi'"}),e("span",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-ink/50",children:[e("span",{children:c.label}),c.bundled&&e("span",{className:"rounded bg-ink/8 px-1 py-px text-[10px] uppercase tracking-wide",children:"Bundled"})]})]}),p&&e(f,{size:14,className:"text-ink flex-shrink-0"})]},c.id)})})]})}var fp=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function hp(t){return`"${ec.find((l)=>l.id===t)?.id??ec[0].id}", monospace`}function vp({theme:t,face:r}){return e("span",{className:"block overflow-hidden rounded border border-ink/10",style:{backgroundColor:t.bg,color:t.fg},children:e("span",{className:"block px-1.5 py-1 font-mono text-[10px] leading-[1.4]",style:{fontFamily:r},children:[e("span",{style:{color:t.keyword},children:"const"})," ",e("span",{children:"answer"})," ",e("span",{style:{color:t.keyword},children:"="})," ",e("span",{style:{color:t.string},children:"42"}),e("span",{children:";"}),e("span",{className:"block truncate",style:{color:t.comment},children:["// ",t.label]})]})})}function Dr({settings:t,onUpdate:r}){let l=t.editorTheme||Zr,[c,p]=n("all"),h=hp(t.editorFont),g=u(()=>c==="all"?Jp:Jp.filter((v)=>v.variant===c),[c]);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(ka,{size:16,className:"text-ink/60"}),"Editor Theme"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Colours for the code editor only — the console around it keeps the theme above. ",e("strong",{children:"Auto"})," ","follows the app palette; any other choice paints the editor's own surface, gutter, selection and syntax, and applies to every open editor without a reload."]})]}),e("div",{className:"flex items-center gap-1.5",children:[fp.map((v)=>e("button",{type:"button",onClick:()=>p(v.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${c===v.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[v.id==="light"&&e(Gt,{size:11,className:"mr-1 inline align-[-1px]"}),v.id==="dark"&&e(zt,{size:11,className:"mr-1 inline align-[-1px]"}),v.label]},v.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:c==="all"?`${g.length} themes`:`${g.length} shown`})]}),e("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e("button",{type:"button",onClick:()=>r({editorTheme:Zr}),"aria-pressed":l===Zr,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${l===Zr?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",children:"Auto"}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:"app palette"}),l===Zr&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("span",{className:"flex h-8 items-center justify-center rounded border border-dashed border-ink/20 text-[10px] text-ink/50",children:"Follows the theme above"})]}),g.map((v)=>{let x=l===v.id;return e("button",{type:"button",onClick:()=>r({editorTheme:v.id}),"aria-pressed":x,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${x?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:v.label,children:v.label}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:v.variant}),x&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e(vp,{theme:v,face:h})]},v.id)})]})]})}function Ur({settings:t,onUpdate:r}){let l=G("editorIndentWidth"),c=typeof l==="number"&&gd.includes(l)?l:Kc.width,p=(h)=>{if(h===c)return;let g={...Ad(),width:h};Jr({editorIndentWidth:h,editorInsertSpaces:!0}),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(fd,{detail:g}))};return e("section",{className:"space-y-3",children:e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor indentation"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"One level, in spaces. Enter, Tab and the auto-indent rules all use it."})]}),e("div",{className:"flex items-center gap-1",role:"group","aria-label":"Indentation width",children:gd.map((h)=>e("button",{type:"button",onClick:()=>p(h),"aria-pressed":h===c,"aria-label":`${h} spaces`,className:`px-2.5 py-1 rounded border text-[11px] font-mono transition-colors cursor-pointer ${h===c?"border-ink/40 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:h},h))})]})})}function Fr({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.currentTarget.checked),"aria-label":t,className:`${he} mt-0.5 accent-ink flex-shrink-0`})]})}function jr({settings:t,onUpdate:r}){let l=Jc(),c=G("editorAutoCloseBrackets"),p=G("editorAutocomplete"),h=(g)=>{let v={...Jc(),...g};Jr(g),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(hd,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor typing"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Both change what typing does, which is why they are switches rather than always-on."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Fr,{label:"Auto-close brackets",hint:"Typing ( or { inserts the matching closer, and typing it again steps over it.",checked:typeof c==="boolean"?c:ul.autoCloseBrackets,onChange:(g)=>h({editorAutoCloseBrackets:g})}),e(Fr,{label:"Suggest words from the file",hint:`Offers identifiers already near the caret (${l.autocomplete?"on":"off"}). Words only — this is not a language server.`,checked:typeof p==="boolean"?p:ul.autocomplete,onChange:(g)=>h({editorAutocomplete:g})})]})]})}function $r({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.target.checked),className:`${he} mt-0.5 shrink-0 accent-ink`})]})}function Br({settings:t,onUpdate:r}){let l=G("editorBlame"),c=G("editorBlameInline"),p=fi(),h=(g)=>{let v={...fi(),...g};Jr(g),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(cs,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Line blame"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Who last touched a line, and which commit. Read from git, so it needs a committed file."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e($r,{label:"Show blame on hover",hint:"Hover a line number — or the label, when it is on — to see the author, the commit and the line's own history.",checked:typeof l==="boolean"?l:dl.enabled,onChange:(g)=>h({editorBlame:g})}),e($r,{label:"Show the label in the editor",hint:`Puts “author · age” at the end of each block. It costs horizontal room, so it is off on a narrow panel by default (${p.inline?"on":"off"}).`,checked:typeof c==="boolean"?c:dl.inline,onChange:(g)=>h({editorBlameInline:g})})]})]})}function _r({settings:t,onUpdate:r}){return e("div",{className:"w-full space-y-8 text-xs text-ink pb-3",children:[e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(ka,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),e(yr,{selectedId:t.theme,onSelect:(l)=>r({theme:dA(l)})})]}),e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(Vn,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Layout"})]}),e(wr,{settings:t,onUpdate:r}),e(Ar,{settings:t,onUpdate:r}),e(Er,{settings:t,onUpdate:r}),e(Lr,{settings:t,onUpdate:r})]}),e(Or,{settings:t,onUpdate:r}),e(Dr,{settings:t,onUpdate:r}),e(Ur,{settings:t,onUpdate:r}),e(jr,{settings:t,onUpdate:r}),e(Br,{settings:t,onUpdate:r})]})}function ye(){let[t,r]=n("list"),l=a(()=>r("detail"),[]),c=a(()=>r("list"),[]);return{pane:t,openDetail:l,back:c}}function we({pane:t,onBack:r,list:l,detail:c,listLabel:p,className:h=""}){return e("div",{className:`flex-1 flex flex-col md:flex-row h-full w-full min-w-0 overflow-hidden bg-paper text-ink ${h}`,children:[e("div",{className:`${t==="list"?"flex":"hidden"} md:flex flex-1 md:flex-none md:w-auto min-h-0 min-w-0 flex-col`,children:l}),e("div",{className:`${t==="detail"?"flex":"hidden"} md:flex flex-1 min-h-0 min-w-0 flex-col`,children:[e("div",{className:"md:hidden flex items-center px-2 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:e("button",{type:"button",onClick:r,"aria-label":`Back to ${p}`,className:"flex items-center gap-1 -ml-0.5 pl-0.5 pr-2 py-1 rounded-lg text-ink hover:bg-ink/5 active:bg-ink/10 transition-colors cursor-pointer",children:[e(ba,{size:18}),e("span",{className:"text-xs font-semibold truncate",children:p})]})}),c]})]})}function zr({groups:t,activeGroupId:r,onSelectGroup:l}){return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[t.length," group",t.length===1?"":"s"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 text-xs",children:e("div",{className:"space-y-0.5",children:t.map((c)=>{let p=c.id===r,h=c.icon;return e("button",{type:"button",onClick:()=>l(c.id),"aria-current":p?"true":void 0,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${p?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("span",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{"aria-hidden":!0,className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${p?"bg-ink/10 text-ink":"bg-ink/5 text-ink/70"}`,children:e(h,{size:12})}),e("span",{className:"font-semibold text-xs text-ink truncate",children:c.label})]}),e("span",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]",children:c.hint})]},c.id)})})})]})}var Pt=[{id:"layout",label:"Layout",hint:"Chat width and composer shape",description:"How wide the conversation is drawn, and the shape of the box you type into.",icon:Vn,sections:["width","composer"]},{id:"transcript",label:"Transcript",hint:"Tool calls, changed files and follow-up dispatch",description:"How a tool call is drawn, whether a run lists the files it changed, and what happens to a prompt sent while the agent is still running.",icon:Hr,sections:["tool-calls","changed-files","follow-up"]},{id:"sessions",label:"Sessions",hint:"Titles and goal mode",description:"How a session gets its name, and the defaults a new goal starts with.",icon:sn,sections:["titles","goal"]}];var xp={compact:"60%",wide:"85%",full:"100%"};function Gr({settings:t,onUpdate:r}){let l=t.chatWidthMode;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Chat Width"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How wide the conversation is drawn. The composer follows the transcript, and no mode hides a panel."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",role:"group","aria-label":"Chat width",children:kA.map((c)=>{let p=xA[c],h=l===c;return e("div",{onClick:()=>r({chatWidthMode:c}),role:"button",tabIndex:0,"aria-pressed":h,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({chatWidthMode:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${h?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${h?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:h&&e(f,{size:10,strokeWidth:3})})]}),e("div",{"aria-hidden":!0,className:"h-1.5 rounded-full bg-ink/10 mb-2.5 overflow-hidden",children:e("div",{className:`h-full rounded-full ${h?"bg-ink":"bg-ink/35"}`,style:{width:xp[c]}})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"On a phone the column already fills the screen, so the mode has no visible effect."})]})}function Wr({active:t=!1}){return e("span",{className:`h-[6px] w-[16px] rounded-sm border ${t?"border-ink/40 bg-ink/15":"border-ink/20 bg-ink/5"}`})}function kp({hero:t=!1}){return e("span",{className:`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${t?"flex-1 justify-center":""}`,children:[e("span",{className:"h-[2.5px] w-[72%] rounded-full bg-ink/25"}),e("span",{className:"h-[2.5px] w-[54%] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[30%] rounded-full bg-ink/15"})]})}function yp({rail:t=!1}){if(t)return e("span",{className:"flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono",children:[e("span",{className:"h-[2.5px] w-[14px] rounded-full bg-ink/30"}),e("span",{className:"h-[2.5px] w-[9px] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[11px] rounded-full bg-ink/20"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80"})]});return e("span",{className:"flex items-center gap-1 px-1",children:[e("span",{className:"h-[6px] w-[20px] rounded-sm bg-ink/15"}),e("span",{className:"h-[6px] w-[10px] rounded-sm bg-ink/10"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-full border border-ink/25"}),e("span",{className:"h-[7px] w-[7px] rounded-sm bg-ink/80"})]})}var wp={classic:"rounded-md bg-paper border-ink/10",calm:"rounded-lg bg-paper border-ink/10",console:"rounded-sm bg-paper border-ink/10",stage:"rounded-md bg-paper border-ink/15",glass:"rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent"};function Np({style:t}){let r=Vp({style:t,hero:t==="stage"});return e("span",{className:`flex h-full flex-col gap-1 border p-1 ${wp[t]}`,"aria-hidden":"true",children:r.wire.map((l,c)=>l==="draft"?e(kp,{hero:t==="stage"},c):l==="chip"?e("span",{className:"flex items-center gap-1 px-1",children:[e(Wr,{active:t!=="calm"}),e(Wr,{})]},c):e(yp,{rail:r.toolbarTone==="rail"},c))})}function Qr({settings:t,onUpdate:r}){let l=Xl(t.composerStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Composer"}),e("p",{className:"mt-0.5 text-[11px] text-ink/60",children:"The shape of the box you type into. Every style offers the same controls — attachments, plan and goal, access mode, model, thinking, voice, send — and only their order and frame change. Applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"group","aria-label":"Composer style",children:BA.map((c)=>{let p=_A[c],h=c===l;return e("button",{type:"button",onClick:()=>r({composerStyle:c}),"aria-pressed":h,"aria-label":`${p.label} composer — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${h?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[92px]",children:e(Np,{style:c})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),h&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function Cp({mode:t}){if(t==="card")return e("div",{"aria-hidden":!0,className:"space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5",children:[e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/50"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/35"}),e("span",{className:"ml-auto h-1 w-5 rounded-full bg-ink/20"})]}),e("div",{className:"h-1 w-16 rounded-full bg-ink/15"})]});if(t==="compact")return e("div",{"aria-hidden":!0,className:"space-y-1.5 rounded-md border border-transparent px-1 py-1",children:[0,1].map((r)=>e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-8 rounded-full bg-ink/30"}),e("span",{className:"ml-auto h-1 w-6 rounded-full bg-ink/15"})]},r))});if(t==="trace")return e("div",{"aria-hidden":!0,className:"relative ml-1 pl-3 py-1",children:[e("span",{className:"absolute left-[3px] top-1 bottom-1 w-px bg-ink/20"}),[0,1,2].map((r)=>e("div",{className:"flex items-center gap-1 py-0.5",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/25"})]},r))]});if(t==="tui")return e("div",{"aria-hidden":!0,className:"space-y-1 px-1 py-1 font-mono",children:[0,1].map((r)=>e("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-[6px] text-success",children:"✔"}),e("span",{className:"h-1 w-3 rounded-full bg-info/70"}),e("span",{className:"h-1 w-6 rounded-full bg-meta/70"}),e("span",{className:"ml-auto h-1 w-2 rounded-full bg-ink/25"})]},r))});return e("div",{"aria-hidden":!0,className:"space-y-1.5 px-1 py-1",children:[e("div",{className:"h-1 w-20 rounded-full bg-ink/25"}),e("div",{className:"h-1 w-14 rounded-full bg-ink/15"})]})}function ei({settings:t,onUpdate:r}){let l=t.toolRenderStyle;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Tool Calls"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:CA.map((c)=>{let p=EA[c],h=l===c;return e("div",{onClick:()=>r({toolRenderStyle:c}),role:"button",tabIndex:0,"aria-pressed":h,onKeyDown:(g)=>{if(g.key==="Enter"||g.key===" ")g.preventDefault(),r({toolRenderStyle:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${h?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${h?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:h&&e(f,{size:10,strokeWidth:3})})]}),e("div",{className:"mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1",children:e(Cp,{mode:c})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"The style is global: it applies to every session, and the composer keeps its own frame."})]})}function Ip({label:t,enabled:r,onToggle:l}){return e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Disable":"Enable"} ${t}`,onClick:l,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${r?"bg-ink":"bg-ink/20"}`,children:e("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${r?"translate-x-5":"translate-x-0"}`})})}function ti({settings:t,onUpdate:r}){let l=t.showChangedFiles;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Changed Files"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A collapsed list of the files a run changed, above its footer. Clicking a file opens the agent's own diff — the content it wrote, not the current worktree."})]}),e("div",{className:"flex items-start justify-between gap-4 py-3",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(qo,{size:16,className:l?"text-ink":"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:"Show changed files"}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Read from the session's change journal. Sessions recorded before omp 18.20.1 have no journal, so the list stays empty there."})]})]}),e(Ip,{label:"Show changed files",enabled:l,onToggle:()=>r({showChangedFiles:!l})})]})]})}function oi({settings:t,onUpdate:r}){return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e("div",{onClick:()=>r({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="queue"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="queue"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Hr,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="queue"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="queue"&&e(f,{size:10,strokeWidth:3})})]})]}),e("div",{onClick:()=>r({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="steering"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="steering"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Bt,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="steering"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="steering"&&e(f,{size:10,strokeWidth:3})})]})]})]})]})}var Ap=[{enabled:!0,label:"Generate Automatically",badge:"Default",icon:Le,description:`As soon as your first message lands, the session is named from it using omp's own tiny title model — retried once when the run ends if that first attempt came back empty. Sessions stop showing "New Session - <timestamp>" in the sidebar.`,note:"One small model call per session"},{enabled:!1,label:"Manual Only",badge:"Opt-out",icon:Yr,description:"Sessions keep their timestamp placeholder until you rename them from the sidebar. Choose this when every title should be deliberate, or to avoid the extra model call.",note:"No background model calls"}];function ii({settings:t,onUpdate:r}){let l=t.autoSessionTitle??!0;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Session Titles"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a session gets its display name. A name you set yourself is never replaced."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Ap.map(({enabled:c,label:p,badge:h,icon:g,description:v,note:x})=>{let y=l===c,k=()=>r({autoSessionTitle:c});return e("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:(P)=>P.key==="Enter"&&k(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${y?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${y?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(g,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:p})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:h})]}),e("p",{className:"text-[11px] text-ink/70 leading-relaxed",children:v})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50",children:x}),y&&e("span",{className:"flex items-center gap-1 text-ink font-medium",children:[e(f,{size:12})," Active"]})]})]},p)})})]})}var Ep="flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-left font-mono text-[11px] text-ink transition-colors hover:border-ink/40 focus:border-ink/50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50";function Fe({value:t,options:r,placeholder:l,ariaLabel:c,onChange:p,disabled:h,className:g,searchable:v=!0}){let[x,y]=n(null),[k,P]=n(""),[N,A]=n(0),C=i(null),R=i(null),S=i([]),I=i(`search-select-${Math.random().toString(36).slice(2,9)}`).current,T=r.find((W)=>W.value===t),M=x!==null,U=u(()=>{let W=k.trim();if(!W)return r;return r.filter((K)=>Yi(`${K.label} ${K.value} ${K.hint??""}`,W))},[r,k]),F=u(()=>{let W=[];for(let K of U){let q=K.group??"",X=W.find((Z)=>Z.name===q);if(X)X.rows.push(K);else W.push({name:q,rows:[K]})}return W},[U]),j=(W=!1)=>{if(y(null),P(""),W)C.current?.focus()},V=()=>{if(h||!C.current)return;let W=Math.max(0,r.findIndex((K)=>K.value===t));P(""),A(W),y(Ht(C.current))},z=(W)=>{if(W!==t)p(W);j(!0)};o(()=>{A(0)},[k]),o(()=>{if(!M)return;S.current[N]?.scrollIntoView({block:"nearest"})},[M,N]),o(()=>{if(M)R.current?.focus()},[M]);let H=(W)=>{if(W.key==="ArrowDown")W.preventDefault(),A((K)=>Math.max(0,Math.min(U.length-1,K+1)));else if(W.key==="ArrowUp")W.preventDefault(),A((K)=>Math.max(0,K-1));else if(W.key==="Home")W.preventDefault(),A(0);else if(W.key==="End")W.preventDefault(),A(Math.max(0,U.length-1));else if(W.key==="Enter"){W.preventDefault();let K=U[N];if(K)z(K.value)}};return e(d,{children:[e("button",{ref:C,type:"button",role:"combobox","aria-label":c,"aria-haspopup":"listbox","aria-expanded":M,"aria-controls":M?I:void 0,disabled:h,title:T?.label??l,onClick:()=>M?j():V(),onKeyDown:(W)=>{if(W.key==="ArrowDown"||W.key==="Enter"||W.key===" ")W.preventDefault(),V()},className:`${Ep} ${g??""}`,children:[e("span",{className:`truncate ${T?"":"text-ink/40"}`,children:T?.label??(t?`${t} (not listed)`:l)}),e(B,{size:12,className:`flex-shrink-0 text-ink/40 transition-transform ${M?"rotate-180":""}`})]}),e(Wt,{anchor:x,align:"start",className:"w-72 max-w-[calc(100vw-2rem)] rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",...{"aria-label":c},onClose:()=>j(!0),children:e("div",{onKeyDown:H,children:[v&&e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(O,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{ref:R,type:"text",value:k,"aria-label":`Search ${c}`,placeholder:"Search…",onInput:(W)=>P(W.currentTarget.value),className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{id:I,role:"listbox","aria-label":c,className:"max-h-56 overflow-y-auto py-1",children:[e("button",{type:"button",role:"option","aria-selected":t==="",ref:(W)=>{S.current[0]=W},onClick:()=>z(""),onMouseEnter:()=>A(0),className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left ${t===""?"text-ink":"text-ink/60"} hover:bg-ink/5`,children:[e("span",{className:"truncate italic",children:l}),t===""&&e(f,{size:11,className:"flex-shrink-0"})]}),t!==""&&!T&&e("button",{type:"button",role:"option","aria-selected":!0,onClick:()=>z(t),className:"flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-ink",children:[e("span",{className:"truncate",children:[t," (not listed)"]}),e(f,{size:11,className:"flex-shrink-0"})]}),U.length===0?e("div",{className:"px-3 py-2 italic text-ink/40",children:["No match for “",k.trim(),"”"]}):F.map((W)=>e("div",{children:[W.name&&e("div",{className:"px-3 pb-0.5 pt-2 text-[9px] font-semibold uppercase tracking-wider text-ink/35",children:W.name}),W.rows.map((K)=>{let q=U.indexOf(K),X=K.value===t;return e("button",{type:"button",role:"option","aria-selected":X,ref:(Z)=>{S.current[q+1]=Z},onClick:()=>z(K.value),onMouseEnter:()=>A(q),title:K.hint??K.value,className:`flex w-full items-start justify-between gap-2 px-3 py-1.5 text-left transition-colors ${q===N?"bg-ink/5":""} ${X?"font-medium text-ink":"text-ink/75"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate",children:K.label}),K.hint&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:K.hint})]}),X&&e(f,{size:11,className:"mt-0.5 flex-shrink-0"})]},K.value)})]},W.name||"__flat"))]})]})})]})}var Lp=[{enabled:!0,label:"Independent auditor",badge:"Default",description:"After every finished turn a separate model reads the objective and the agent's own report and decides: keep going, done, or needs you. Without it nothing advances a goal on its own.",note:"One extra model call per turn"},{enabled:!1,label:"Manual only",badge:"Opt-out",description:"Goals still exist — objective, pause, resume and the token budget all work — but the loop never continues by itself. Use it when a goal should only ever run the turns you ask for.",note:"No background model calls"}];function ai({settings:t,onUpdate:r}){let l=nc(),[c,p]=n([]),[h,g]=n(!0),v=t.goalAuditEnabled??!0,x=t.goalAuditModel??"",y=t.goalDefaultBudget??null,[k,P]=n(y===null?"":String(y));o(()=>{P(y===null?"":String(y))},[y]);let N=()=>{let A=nm(k);if(P(A===null?"":String(A)),A!==y)r({goalDefaultBudget:A})};return o(()=>{let A=!0;return Ha().then((C)=>{if(!A)return;p(Array.isArray(C.modelList)?C.modelList.map((R)=>({id:R.id,name:R.name,provider:R.provider})):[])}).catch(()=>{}).finally(()=>{if(A)g(!1)}),()=>{A=!1}},[]),e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Goal Mode"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A goal keeps a session working toward one objective until it is done, out of budget, or the auditor says it needs you."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Lp.map(({enabled:A,label:C,badge:R,description:S,note:I})=>{let T=v===A,M=()=>r({goalAuditEnabled:A});return e("div",{onClick:M,role:"button",tabIndex:0,onKeyDown:(U)=>U.key==="Enter"&&M(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${T?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${T?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(xo,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:C})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:R})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:S})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:I}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${T?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:T&&e(f,{size:10,strokeWidth:3})})]})]},C)})}),v&&e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 space-y-3",children:e("div",{children:[e("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Auditor model"}),e(Fe,{ariaLabel:"Auditor model",value:x,onChange:(A)=>r({goalAuditModel:A}),disabled:h,placeholder:"Session model (default)",className:"w-full py-1.5 text-[11.5px]",options:c.map((A)=>({value:`${A.provider}/${A.id}`,label:A.name,hint:`${A.provider}/${A.id}`,group:Vi(A.provider,l)}))}),e("p",{className:"mt-1 text-[10.5px] text-ink/45",children:"The audit is a classification, not a task: it runs with thinking off, one small call per turn."})]})}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5",children:[e("label",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:[e(Xo,{size:11})," Default token budget"]}),e("div",{className:"flex items-center gap-2",children:[e("input",{value:k,onChange:(A)=>P(A.currentTarget.value),onBlur:N,onKeyDown:(A)=>{if(A.key==="Enter")N()},placeholder:"none: the turn ceiling is then the only stop",inputMode:"numeric","aria-label":"Default goal token budget",className:"w-56 rounded border border-ink/15 bg-paper px-2 py-1.5 font-mono text-[11.5px] outline-none focus:border-ink"}),e("span",{className:"text-[10.5px] text-ink/45",children:"New goals start with this budget; a goal you set explicitly keeps its own."})]})]}),e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/10 bg-canvas/40 p-3 text-[11px] text-ink/60",children:[e(Ft,{size:12,className:"mt-0.5 shrink-0"}),e("span",{children:"The objective is set per goal from the composer's target button. The auditor judges progress from the objective and the agent's own report only — write an objective that says what finished looks like."})]})]})}var Fp={width:Gr,composer:Qr,"tool-calls":ei,"changed-files":ti,"follow-up":oi,titles:ii,goal:ai};function si({settings:t,onUpdate:r}){let l=ye(),[c,p]=n(Pt[0].id),h=Pt.find((g)=>g.id===c)??Pt[0];return e(we,{pane:l.pane,onBack:l.back,listLabel:"Chat settings",list:e(zr,{groups:Pt,activeGroupId:h.id,onSelectGroup:(g)=>{p(g),l.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col text-xs text-ink",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0",children:[e("span",{className:"text-xs font-semibold text-ink/75",children:h.label}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:h.description})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6",children:h.sections.map((g)=>{let v=Fp[g];return e(v,{settings:t,onUpdate:r},g)})})]})})}function li(t){let r=new Map;for(let c of t){let p=PA(c.chord),h=r.get(p);if(h)h.push(c);else r.set(p,[c])}let l=[];for(let c of r.values())for(let p=0;p<c.length;p+=1)for(let h=p+1;h<c.length;h+=1){let g=c[p],v=c[h];if(g.command===v.command)continue;l.push({chord:g.chord,a:g,b:v,certain:!g.when||!v.when||g.when===v.when})}return l}var jp={Shift:!0,Control:!0,Alt:!0,Meta:!0,OS:!0,Super:!0,Hyper:!0,CapsLock:!0,Fn:!0},Bp={ShiftLeft:!0,ShiftRight:!0,ControlLeft:!0,ControlRight:!0,AltLeft:!0,AltRight:!0,MetaLeft:!0,MetaRight:!0,OSLeft:!0,OSRight:!0,CapsLock:!0};function di(t){return jp[t.key]===!0||Bp[t.code]===!0}function ci({chord:t,onCommit:r}){let[l,c]=n(!1),[p,h]=n([]),g=i(null);o(()=>{if(l)g.current?.focus()},[l]);let v=()=>{c(!1),h([])},x=(k)=>{if(!l)return;if(k.preventDefault(),k.stopPropagation(),k.key==="Escape"){v();return}if(k.key==="Backspace"||k.key==="Delete"){if(p.length===0)r(null),v();else h([]);return}if(k.key==="Enter"&&p.length===1){r(Xf(p)),v();return}if(di(k))return;let P=rm(k);if(p.length===0){h([P]);return}r(Xf([p[0],P])),v()},y=l?p.length>0?`${So(p,bt())} …`:"Press keys…":t||"Unassigned";return e("button",{ref:g,type:"button",onClick:()=>{c(!0),h([])},onBlur:()=>{if(l)v()},onKeyDown:x,"aria-label":l?"Recording shortcut, press keys":`Shortcut ${t||"unassigned"}, click to change`,className:`min-w-[7rem] px-2 py-1 rounded-md border text-[11px] font-mono transition-colors ${l?"border-ink/60 bg-ink/5 text-ink":"border-ink/20 text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:y})}function pi(){let{commands:t,chords:r,rules:l}=ac(),[c,p]=n(()=>am()),[h,g]=n(""),v=u(()=>li(l),[l]),x=bt(),y=(C)=>t.find((R)=>R.id===C)?.title??C,k=(C,R)=>{let S={...c,[C]:R};p(S),qu(S),eg(S)},P=(C)=>{let R={...c};delete R[C],p(R),qu(R),eg(R)},N=h.trim().toLowerCase(),A=t.filter((C)=>!N||C.title.toLowerCase().includes(N)||(r.get(C.id)??"").toLowerCase().includes(N)).sort((C,R)=>C.category.localeCompare(R.category)||C.title.localeCompare(R.title));return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Shortcuts"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Click a chord to record a new one. Two strokes are allowed; Enter keeps a single stroke."})]}),e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border border-ink/15 rounded-md bg-canvas",children:[e(O,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:h,onInput:(C)=>g(C.currentTarget.value),placeholder:"Filter","aria-label":"Filter shortcuts",className:"w-32 bg-transparent text-xs text-ink focus:outline-none placeholder-ink/40"})]})]}),v.length>0?e("div",{className:"border border-ink/15 rounded-lg p-3 space-y-1.5 bg-ink/[0.02]",children:[e("p",{className:"text-[11px] font-semibold text-ink/75",children:[v.length," chord ",v.length===1?"conflict":"conflicts"]}),v.map((C)=>e("p",{className:"text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-ink/80",children:So(C.chord,x)})," ","— ",y(C.a.command)," and ",y(C.b.command),C.certain?"":" (may not overlap)"]},`${C.a.command}-${C.b.command}`))]}):null,e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:A.length===0?e("p",{className:"px-3 py-4 text-center text-xs text-ink/50",children:"No command matches that filter."}):A.map((C)=>{let R=c[C.id]!==void 0;return e("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink truncate",children:C.title}),e("div",{className:"text-[10px] text-ink/45",children:[C.category,C.pluginId?` · ${C.pluginId}`:"",R?" · custom":""]})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e(ci,{chord:r.get(C.id)??"",onCommit:(S)=>k(C.id,S)}),R?e("button",{type:"button",onClick:()=>P(C.id),title:"Reset to default","aria-label":`Reset ${C.title} to its default shortcut`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors",children:e(Rt,{size:12})}):null]})]},C.id)})})]})}function ui({settings:t,onUpdate:r}){let l=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],c=(h,g)=>{r((v)=>{let x={[h]:g},y=["keybindingSend","keybindingNewLine","keybindingSteering"].filter((k)=>k!==h);for(let k of y)if(v[k]===g)x[k]=v[h];return{...v,...x}})},p=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:tt,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:Xt,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:Bt,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:[e(ya,{size:15,className:"text-ink/70"}),e("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),e("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:p.map((h)=>e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:e(h.icon,{size:14})}),e("div",{children:[e("div",{className:"font-semibold text-xs text-ink",children:h.label}),e("div",{className:"text-[11px] text-ink/60 mt-0.5",children:h.desc})]})]}),e("div",{className:"flex items-center gap-2 self-end sm:self-center",children:e("select",{value:h.value,onChange:(g)=>c(h.id,g.currentTarget.value),className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:l.map((g)=>e("option",{value:g,children:g},g))})})]},h.id))})]})}function mi({settings:t,onUpdate:r}){return e("div",{className:"flex-1 h-full overflow-y-auto scrollbar-overlay-container p-4 md:p-6 space-y-8 pb-8",children:[e(pi,{}),e(ui,{settings:t,onUpdate:r})]})}function gi({projects:t,selectedProjectId:r,onSelectProject:l,onAddProject:c,onTogglePin:p,isAdding:h=!1,folderFacts:g=[],loadError:v=null}){let x=new Map(g.map((y)=>[y.id,y.totalSessions]));return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:[t.length," project",t.length===1?"":"s"]}),e("button",{type:"button",onClick:c,disabled:h,"aria-label":"Add project",title:"Add project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:[v&&e("p",{className:"px-2 py-2 text-[11px] text-error",title:v,children:["Projects could not be read: ",v]}),!v&&t.length===0&&e("div",{className:"px-2 py-3 space-y-1.5",children:[e("p",{className:"text-[11.5px] text-ink/60",children:"No projects yet."}),e("button",{type:"button",onClick:c,className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add the first one"})]}),t.map((y)=>{let k=y.id===r,P=ea(y.icon),N=y.folderId===void 0?void 0:x.get(y.folderId);return e("div",{className:`group flex items-center rounded-md transition-colors ${k?"bg-ink/10 shadow-2xs":"hover:bg-ink/5"}`,children:[e("button",{type:"button",onClick:()=>l(y.id),"aria-current":k?"true":void 0,className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer",children:[y.customIconUrl?e("img",{src:y.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):e(P,{size:14,className:"flex-shrink-0",style:{color:y.accentColor||"currentColor"}}),e("span",{className:`text-[11.5px] truncate flex-1 ${k?"font-medium text-ink":"text-ink/80"}`,children:y.name}),typeof N==="number"&&N>0&&e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:N})]}),e("button",{type:"button",onClick:()=>p(y),"aria-label":y.isPinned?`Unpin ${y.name}`:`Pin ${y.name}`,title:y.isPinned?"Unpin (stop sorting first)":"Pin (sort first in the sidebar)",className:`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${y.isPinned?"text-ink/70 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:y.isPinned?e(Ta,{size:12}):e(ml,{size:12})})]},y.id)})]})]})}function bi({project:t,canDelete:r,isDeleting:l=!1,onDelete:c}){return e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0 flex-1",children:[e("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path||"Not bound to a directory"})]}),r&&e("button",{type:"button",onClick:c,disabled:l,title:"Delete this project",className:"inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1.5 text-[11px] font-medium text-ink/50 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer disabled:opacity-50",children:[e(L,{size:13}),e("span",{children:"Delete"})]})]})}function hi({name:t,disabled:r=!1,onCommit:l}){let[c,p]=n(t);return o(()=>{p(t)},[t]),e("div",{className:"space-y-2",children:[e("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project name"}),e("input",{id:"project-name-input",type:"text",value:c,disabled:r,onChange:(g)=>p(g.currentTarget.value),onBlur:()=>{let g=c.trim();if(!g){p(t);return}if(g===t)return;l(g)},onKeyDown:(g)=>{if(g.key==="Enter")g.preventDefault(),g.currentTarget.blur();if(g.key==="Escape")p(t),g.currentTarget.blur()},placeholder:"Enter project name…",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:"Names are unique: the sidebar identifies a project by it."})]})}function vi({path:t,disabled:r=!1,onCommit:l,onReveal:c,isRevealing:p=!1}){let[h,g]=n(t),[v,x]=n(!1);o(()=>{g(t)},[t]);let y=(k)=>{let P=k.trim();if(P===t)return;l(P)};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("label",{htmlFor:"project-path-input",className:"block text-xs font-semibold text-ink",children:"Project directory"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:()=>x(!0),disabled:r,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(Fn,{size:11}),e("span",{children:"Browse…"})]}),e("button",{type:"button",onClick:c,disabled:r||!t||p,title:t?"Reveal in the file manager":"This project is not bound to a directory",className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40",children:[e(Nt,{size:11}),e("span",{children:"Reveal"})]})]})]}),e("input",{id:"project-path-input",type:"text",value:h,disabled:r,onChange:(k)=>g(k.currentTarget.value),onBlur:()=>y(h),onKeyDown:(k)=>{if(k.key==="Enter")k.preventDefault(),k.currentTarget.blur();if(k.key==="Escape")g(t),k.currentTarget.blur()},placeholder:"~ or /absolute/path, or leave empty for an unbound grouping",spellcheck:!1,className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:t?"Sessions found under this directory appear in the project. One directory can belong to one project.":"Not bound to a directory: this project groups chats only and discovers no sessions."}),v&&e(ws,{initialPath:t||void 0,onSelect:(k)=>{x(!1),g(k),y(k)},onClose:()=>x(!1)})]})}function xi({model:t,models:r,onSelectModel:l,disabled:c=!1}){let[p,h]=n(!1),[g,v]=n(""),x=i(null);pe(x,()=>h(!1));let y=zA(t,r)??"Inherit Kabmo’s default",k=u(()=>{let N=g.trim().toLowerCase();if(!N)return r;return r.filter((A)=>A.name.toLowerCase().includes(N)||A.id.toLowerCase().includes(N)||A.provider.toLowerCase().includes(N))},[r,g]),P=(N)=>{l(N),h(!1),v("")};return e("div",{className:"space-y-2.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),e("span",{className:"inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help",title:"The model a chat started in this project uses until you pick another one in the composer.",children:e(de,{size:12})})]}),e("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink",children:"Project model"}),e("div",{className:"text-[11px] text-ink/50",children:r.length===0?"No model catalog yet — connect a provider first.":"Applied when the project starts a chat."})]}),e("div",{className:"relative shrink-0",ref:x,children:[e("button",{type:"button",onClick:()=>h((N)=>!N),disabled:c,className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50",children:[e(Le,{size:13,className:"text-ink/70 shrink-0"}),e("span",{className:"truncate",children:y}),e(B,{size:13,className:"text-ink/50 shrink-0"})]}),p&&e("div",{className:"glass-popover absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden",children:[e("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 shrink-0"}),e("input",{autoFocus:!0,value:g,onInput:(N)=>v(N.currentTarget.value),placeholder:"Search models…",className:"flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"max-h-64 scrollbar-overlay-container py-1",children:[e("button",{type:"button",onClick:()=>P(oc),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:t===oc?"font-semibold text-ink":"text-ink/80",children:"Inherit Kabmo’s default"}),t===oc&&e(f,{size:13,className:"text-ink"})]}),k.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/50",children:r.length===0?"The catalog is empty.":`No model matches “${g.trim()}”.`}):k.map((N)=>{let A=$A({provider:N.provider,modelId:N.id}),C=t===A;return e("button",{type:"button",onClick:()=>P(A),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:`truncate text-xs ${C?"font-semibold text-ink":"text-ink/85"}`,children:N.name}),e("span",{className:"truncate text-[10.5px] text-ink/45",children:N.provider})]}),C&&e(f,{size:13,className:"text-ink shrink-0"})]},A)})]}),t!==oc&&e("button",{type:"button",onClick:()=>P(oc),className:"w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(b,{size:11}),e("span",{children:"Clear the project model"})]})]})]})]})]})}function ki({accentColor:t,onSelectColor:r,options:l=tg,disabled:c=!1}){let p=l.length>0?l:tg,h=t.trim().toLowerCase(),g=p.some((R)=>R.value!==""&&R.value.toLowerCase()===h),v=h!==""&&!g,x=im(h)??om,[y,k]=n(x);o(()=>k(x),[x]);let P=(R)=>{let S=im(R);if(S===null){k(x);return}if(k(S),S!==h)r(S)},N=i(null),A=i(null),C=i({commit:P,clear:()=>r("")});return C.current={commit:P,clear:()=>r("")},o(()=>{let R=N.current,S=A.current;if(!R||!S)return;let I=(F)=>k(F.target.value.toLowerCase()),T=(F)=>C.current.commit(F.target.value),M=()=>{let F=S.value.trim();if(F==="")C.current.clear();else C.current.commit(F)},U=(F)=>{if(F.key==="Enter")F.preventDefault(),M();if(F.key==="Escape")k(x)};return R.addEventListener("input",I),R.addEventListener("change",T),S.addEventListener("blur",M),S.addEventListener("keydown",U),()=>{R.removeEventListener("input",I),R.removeEventListener("change",T),S.removeEventListener("blur",M),S.removeEventListener("keydown",U)}},[x]),e("div",{className:"space-y-2.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Accent colour"}),e("div",{className:"flex flex-wrap items-center gap-2.5",children:p.map((R)=>{let S=h===R.value.toLowerCase();if(R.value==="")return e("button",{type:"button",onClick:()=>r(""),disabled:c,"aria-label":"No accent colour","aria-pressed":S,title:"No accent colour",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${S?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:e(b,{size:12,strokeWidth:2.2})},"none");return e("button",{type:"button",onClick:()=>r(R.value),disabled:c,"aria-label":R.label,"aria-pressed":S,title:R.label,style:{backgroundColor:R.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${S?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},R.value)})}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("label",{title:"Pick a custom accent colour",className:`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${v?"ring-2 ring-ink ring-offset-2 ring-offset-paper":"border-ink/25 hover:border-ink/50"} ${c?"opacity-50 pointer-events-none":""}`,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundColor:y}}),e(nr,{size:12,strokeWidth:2.2,"aria-hidden":"true",className:"absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"}),e("input",{ref:N,type:"color",value:im(y)??om,disabled:c,"aria-label":"Custom accent colour",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e("input",{ref:A,type:"text",value:y,disabled:c,spellcheck:!1,"aria-label":"Custom accent colour hex",placeholder:om,onInput:(R)=>k(R.currentTarget.value),className:"w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"}),e("span",{className:"text-[11px] text-ink/45",children:v?"Custom accent":"Pick any colour"})]})]})}var $n=128,_p=700000;async function Hp(t){let r=Promise.withResolvers(),l=new FileReader;l.onload=(A)=>{let C=A.target?.result;if(typeof C==="string"&&C)r.resolve(C);else r.reject(Error("That file could not be read as an image."))},l.onerror=()=>r.reject(Error("That file could not be read as an image.")),l.readAsDataURL(t);let c=await r.promise;if(t.type==="image/svg+xml")return c;let p=Promise.withResolvers(),h=new Image;h.onload=()=>p.resolve(h),h.onerror=()=>p.reject(Error("That file is not an image Kabmo can read.")),h.src=c;let g=await p.promise,v=Math.min(1,$n/Math.max(g.naturalWidth,g.naturalHeight)),x=Math.max(1,Math.round(g.naturalWidth*v)),y=Math.max(1,Math.round(g.naturalHeight*v)),k=document.createElement("canvas");k.width=x,k.height=y;let P=k.getContext("2d");if(!P)return c;P.drawImage(g,0,0,x,y);let N=k.toDataURL("image/png");return N.length>0&&N.length<c.length?N:c}function yi({currentIcon:t,customIconUrl:r,projectName:l,onSelectIcon:c,onSetCustomIcon:p,disabled:h=!1}){let g=i(null),[v,x]=n(!1),[y,k]=n(!1),[P,N]=n(null),A=async(S)=>{let I=S.currentTarget.files?.[0];if(S.currentTarget.value="",!I)return;N(null),k(!0);try{let T=await Hp(I);if(T.length>_p){N("That image is too detailed to store as a mark — try a PNG or SVG.");return}p(T)}catch(T){N(T instanceof Error?T.message:String(T))}finally{k(!1)}},C=()=>{let I=`https://api.dicebear.com/7.x/identicon/svg?seed=${l.toLowerCase().replace(/[^a-z0-9]/g,"")||"project"}&radius=50&size=${$n}`;N(null),x(!0);let T=new Image;T.onload=()=>{x(!1),p(I)},T.onerror=()=>{x(!1),N("The generated icon could not be loaded — check your connection.")},T.src=I},R=h||y||v;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Project icon"}),r&&e("button",{type:"button",onClick:()=>p(void 0),disabled:R,className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:"Use a standard icon"})]}),e("div",{className:"flex flex-wrap gap-1.5",children:OA.map((S)=>{let I=!r&&t===S.id,T=S.icon;return e("button",{type:"button",onClick:()=>c(S.id),disabled:R,"aria-label":S.label,"aria-pressed":I,title:S.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${I?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"border border-transparent text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:e(T,{size:14,strokeWidth:1.8})},S.id)})}),e("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e("input",{type:"file",ref:g,onChange:(S)=>void A(S),accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden"}),e("button",{type:"button",onClick:()=>g.current?.click(),disabled:R,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[y?e(m,{size:13,className:"animate-spin text-ink/60"}):e(Ui,{size:13,className:"text-ink/60"}),e("span",{children:y?"Reading…":"Upload image"})]}),e("button",{type:"button",onClick:C,disabled:R,title:"Generate a stable identicon from the project name",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[v?e(m,{size:13,className:"animate-spin text-ink/60"}):e(Go,{size:13,className:"text-ink/60"}),e("span",{children:v?"Generating…":"Generate mark"})]}),r&&e("div",{className:"flex items-center gap-2 ml-1 pl-2 border-l border-ink/10",children:[e("img",{src:r,alt:"Current custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),e("span",{className:"text-[11px] text-ink/60",children:"Custom icon in use"}),e("button",{type:"button",onClick:()=>p(void 0),disabled:R,"aria-label":"Remove the custom icon",className:"p-0.5 rounded text-ink/40 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:12})})]})]}),e("p",{className:"text-[11px] text-ink/50",children:["Any image works — it is scaled down to a ",$n,"px mark. PNG, JPEG, WebP, GIF or SVG."]}),P&&e("p",{className:"text-[11px] text-error",children:P})]})}function wi({project:t,canDelete:r,isDeleting:l=!1,isRevealing:c=!1,models:p,accentColorOptions:h,onUpdateField:g,onUpdateFields:v,onReveal:x,onDeleteProject:y}){return e("div",{className:"p-6 md:p-8 space-y-7",children:[e(bi,{project:t,canDelete:r,isDeleting:l,onDelete:y}),e(hi,{name:t.name,onCommit:(k)=>g("name",k)}),e(vi,{path:t.path,onCommit:(k)=>g("path",k),onReveal:x,isRevealing:c}),e(xi,{model:t.model,models:p,onSelectModel:(k)=>g("model",k)}),e(ki,{accentColor:t.accentColor,onSelectColor:(k)=>g("accentColor",k),...h&&h.length>0?{options:h}:{}}),e(yi,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:(k)=>v({icon:k,customIconUrl:void 0}),onSetCustomIcon:(k)=>v({customIconUrl:k,icon:k===void 0?"default":"custom"})})]})}function Gp(t){return(t.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"").toLowerCase()}function Wp({isSaving:t,onClose:r,onSubmit:l}){let[c,p]=n(""),[h,g]=n(""),[v,x]=n(!1),[y,k]=n(!0),[P,N]=n(null),A=(R)=>{if(g(R),y||!c.trim())p(Gp(R)),k(!0)},C=async()=>{let R=c.trim();if(!R){N("Enter a project name.");return}N(null);try{await l({name:R,path:h.trim()}),r()}catch(S){N(S instanceof Error?S.message:String(S))}};return e(d,{children:e(J,{onClose:t?()=>{}:r,ariaLabel:"Add project",maxWidthClass:"max-w-[480px]",header:e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Add project"}),e("p",{className:"text-[11px] text-ink/50",children:"A name, and the directory its chats run in."})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,disabled:t,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:()=>void C(),disabled:t,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5",children:[t&&e(m,{size:13,className:"animate-spin"}),e("span",{children:t?"Adding…":"Add project"})]})]}),children:[e("div",{className:"px-5 py-4 space-y-4",children:[e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-name",className:"block text-xs font-semibold text-ink",children:"Name"}),e("input",{id:"add-project-name",type:"text",value:c,onInput:(R)=>{p(R.currentTarget.value),k(!1)},placeholder:"e.g. kabmo",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"}),e("p",{className:"text-[11px] text-ink/50",children:"Unique: the sidebar identifies a workspace by it."})]}),e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-path",className:"block text-xs font-semibold text-ink",children:["Directory ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("div",{className:"flex items-center gap-2",children:[e("input",{id:"add-project-path",type:"text",value:h,onInput:(R)=>g(R.currentTarget.value),placeholder:"~ or /absolute/path",spellcheck:!1,className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"}),e("button",{type:"button",onClick:()=>x(!0),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer",children:[e(Nt,{size:12}),e("span",{children:"Browse…"})]})]}),e("p",{className:"text-[11px] text-ink/50",children:"Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory behind it."})]}),P&&e("p",{className:"text-[11px] text-error",children:P})]}),v&&e(ws,{initialPath:h||void 0,onSelect:(R)=>{A(R),x(!1)},onClose:()=>x(!1)})]})})}function Si({isOpen:t,isSaving:r,onClose:l,onSubmit:c}){if(!t)return null;return e(Wp,{isSaving:r,onClose:l,onSubmit:c})}function Ni({project:t,isDeleting:r,error:l,onClose:c,onConfirm:p}){if(o(()=>{let h=(g)=>{if(g.key!=="Escape"||r)return;g.preventDefault(),c()};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[c,r]),!t)return null;return e(J,{onClose:r?()=>{}:c,zClass:"z-[70]",maxWidthClass:"max-w-[440px]",ariaLabel:"Delete project",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(L,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete project?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:t.name})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:p,disabled:r,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[r?e(m,{size:13,className:"animate-spin"}):e(L,{size:13}),e("span",{children:r?"Deleting…":"Delete project"})]})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspace is unregistered from Kabmo — its place in the sidebar, its chats' grouping and its settings go."}),e("li",{children:t.path?"The directory itself is NOT deleted; a tombstone keeps omp discovery from re-adding it on the next boot.":"It has no directory, so nothing on disk is touched."}),e("li",{children:"Chat transcripts stay on disk under ~/.omp/agent/sessions."})]}),l&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(_,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:l})]})]})})}var Bn="worktreeDirectory",_n="worktreeCarryIgnored";function Ci(t){if(t.missing)return"folder is missing — its chats still open";let r=t.detached?`detached @ ${t.head.slice(0,7)||"unknown"}`:`${t.branch} checked out here`,l=t.sessions===1?"1 chat":`${t.sessions} chats`,c=t.dirty===0?"clean":`${t.dirty} changed`;return`${r} · ${l} · ${c}`}function Ti(t){return!t.detached&&Boolean(t.branch)&&t.aheadOfStart===0}function Kn(t){if(t.isPrimary)return"The main checkout cannot be removed.";if(t.dirty>0)return`${t.dirty} uncommitted file${t.dirty===1?"":"s"} here would be lost.`;return null}function Ii({root:t,folderId:r,onReport:l}){let{worktrees:c,base:p,loading:h,error:g,isRepo:v,refresh:x}=sm({root:t,folderId:r},Boolean(t)),[y,k]=n(()=>{let S=G(Bn);return typeof S==="string"?S:""}),[P,N]=n(()=>G(_n)!==!1),[A,C]=n(null);if(!t)return e("p",{className:"text-xs text-ink/50",children:"Bind this workspace to a repository to manage its worktrees."});let R=c.filter((S)=>!S.isPrimary);return e("div",{className:"flex flex-col gap-4",children:[e("section",{className:"flex flex-col gap-1",children:[e("h3",{className:"text-xs font-semibold text-ink",children:"Worktrees"}),h&&e("p",{className:"text-[11px] text-ink/50",children:"Reading worktrees…"}),g&&e("p",{className:"text-[11px] text-error",title:g,children:["Worktrees could not be read: ",g]}),!h&&!g&&v===!1&&e("p",{className:"text-[11px] text-ink/50",children:"Worktrees need a Git repository."}),!h&&!g&&v!==!1&&R.length===0&&e("p",{className:"text-[11px] text-ink/50",children:"No worktrees yet."}),R.map((S)=>e("div",{className:"group flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-ink/5",children:[e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"truncate text-xs text-ink",children:S.branch||"detached"}),e("p",{className:"truncate text-[10.5px] text-ink/50",title:S.path,children:Ci(S)})]}),e("button",{type:"button",disabled:A===S.path||Kn(S)!==null,"aria-label":`Remove worktree ${S.branch||S.path}`,title:Kn(S)??"Remove worktree",onClick:()=>{C(S.path),UA({root:t,folderId:r},S.path,{deleteBranch:Ti(S)}).then((I)=>(l(I.branchDeleted?`Removed ${S.branch} and its branch`:`Removed ${S.branch}${I.branchKept?" (branch kept)":""}`,"success"),x())).catch((I)=>l(I instanceof Error?I.message:String(I),"error")).finally(()=>C(null))},className:"shrink-0 rounded px-2 py-1 text-[11px] text-ink/60 hover:bg-error/10 hover:text-error disabled:opacity-40",children:"Remove"})]},S.path))]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Worktree location"}),e("input",{value:y,onChange:(S)=>k(S.currentTarget.value),onBlur:()=>rt(Bn,y.trim()),placeholder:p,className:"h-8 rounded-md border border-ink/15 bg-paper px-2 text-xs text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10.5px] text-ink/50",children:["Where new worktrees are created. Relative paths are resolved against the project; ~ is your home directory. Empty uses ",p,"."]})]}),e("label",{className:"flex items-start gap-2",children:[e("input",{type:"checkbox",checked:P,onChange:(S)=>{let I=S.currentTarget.checked;N(I),rt(_n,I)},className:`${he} mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Copy ignored files into new worktrees"}),e("span",{className:"text-[10.5px] text-ink/50",children:"A new worktree gets the project's ignored build folders (node_modules, .venv, target) copied in, so it works without reinstalling."})]})]})]})}var qp={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},Ae=({variant:t="full",children:r})=>e("div",{className:qp[t],children:r});var Vt="";function Ai(t){if(!w(t))return!1;return typeof t.id==="string"&&typeof t.name==="string"&&typeof t.path==="string"}function Qp(t){if(!w(t))return!1;return typeof t.label==="string"&&typeof t.value==="string"&&typeof t.bgHex==="string"}function eu(t,r){return t.some((c)=>c.id===r.id)?t.map((c)=>c.id===r.id?r:c):[...t,r]}function Ei(t){let[r,l]=n([]),[c,p]=n([]),[h,g]=n(Vt),[v,x]=n(!0),[y,k]=n(null),[P,N]=n(!1),[A,C]=n(!1),R=i(t);R.current=t;let S=a((K)=>{if(!w(K))return;let q=Array.isArray(K.projects)?K.projects.filter(Ai):null;if(q)l(q),g((X)=>q.some((Z)=>Z.id===X)?X:q[0]?.id??Vt);if(Array.isArray(K.accentColorOptions))p(K.accentColorOptions.filter(Qp))},[]),I=a(async()=>{try{let K=await fetch("/api/settings/projects"),q=await K.json();if(!K.ok){let X=w(q)&&typeof q.error==="string"?q.error:`HTTP ${K.status}`;k(X);return}k(null),S(q)}catch(K){k(K instanceof Error?K.message:String(K))}},[S]);o(()=>{let K=!0;return(async()=>{if(await I(),K)x(!1)})(),()=>{K=!1}},[I]);let T=He().folders,M=u(()=>T.map((K)=>`${K.id}:${K.name}:${K.model??""}:${K.icon??""}:${K.accentColor??""}:${K.project_path??""}:${K.isPinned?1:0}`).join("|"),[T]);o(()=>{if(!M)return;I()},[M,I]);let U=a(async(K,q)=>{if(K.folderId===void 0)return R.current("This project has no workspace row to save to."),!1;let X=r;l((te)=>te.map((Q)=>Q.id===K.id?{...Q,...q}:Q));let Z={folderId:K.folderId};for(let[te,Q]of Object.entries(q))Z[te]=Q===void 0?null:Q;try{let te=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:Z})}),Q=await te.json().catch(()=>null);if(!te.ok){let ae=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${te.status}`;throw Error(ae)}let se=w(Q)&&Ai(Q.project)?Q.project:null;if(se)l((ae)=>eu(ae,se));return!0}catch(te){return l(X),R.current(te instanceof Error?te.message:String(te)),!1}},[r]),F=a((K,q,X)=>U(K,{[q]:X}),[U]),j=a((K,q)=>U(K,q),[U]),V=a(async(K)=>{N(!0);try{let q=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K.name,path:K.path})}),X=await q.json().catch(()=>null),Z=w(X)?X.folder:null,te=w(Z)&&typeof Z.id==="number"?Z.id:null;if(!q.ok||!w(X)||X.success!==!0||te===null){let Q=w(X)&&typeof X.error==="string"?X.error:`HTTP ${q.status}`;throw Error(Q)}await I(),g(`folder-${te}`)}catch(q){throw R.current(q instanceof Error?q.message:String(q)),q}finally{N(!1)}},[I]),z=a(async(K)=>{C(!0);try{let q=await fetch(`/api/settings/projects?id=${encodeURIComponent(K.id)}`,{method:"DELETE"}),X=await q.json().catch(()=>null);if(!q.ok||!w(X)||X.success!==!0){let Z=w(X)&&typeof X.error==="string"?X.error:`HTTP ${q.status}`;throw Error(Z)}l((Z)=>{let te=Z.filter((Q)=>Q.id!==K.id);return g((Q)=>Q===K.id?te[0]?.id??Vt:Q),te})}catch(q){throw R.current(q instanceof Error?q.message:String(q)),q}finally{C(!1)}},[]),H=Wa((K)=>Array.isArray(K.modelList)&&K.modelList.length>0?K.modelList.map((q)=>({provider:q.provider,id:q.id,name:q.name||q.id})):void 0)??[],W=r.find((K)=>K.id===h)??r[0]??null;return{projects:r,selected:W,selectedId:W?.id??Vt,select:g,accentColorOptions:c,models:H,isLoading:v,loadError:y,refresh:I,updateField:F,updateFields:j,isAdding:P,addProject:V,isDeleting:A,deleteProject:z,onError:t}}function Li(){let t=ye(),{pushToast:r}=je(),[l,c]=n(!1),[p,h]=n(null),[g,v]=n(null),[x,y]=n(null),k=Ei((R)=>r(R,"error",{duration:7000})),{folders:P}=He(),N=async(R)=>{if(!R.path||R.folderId===void 0){r("This project is not bound to a directory.","error");return}y(R.id);try{let S=await fetch(`/api/folders/${R.folderId}/open`,{method:"POST"}),I=await S.json().catch(()=>null);if(!S.ok){let T=I&&typeof I==="object"&&"error"in I&&typeof I.error==="string"?I.error:`HTTP ${S.status}`;throw Error(T)}}catch(S){r(S instanceof Error?S.message:String(S),"error")}finally{y(null)}},A=async()=>{if(!p)return;v(null);try{await k.deleteProject(p),h(null),t.back()}catch(R){v(R instanceof Error?R.message:String(R))}};if(k.isLoading)return e(Ae,{children:"Loading projects…"});let C=k.selected;return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(we,{pane:t.pane,onBack:t.back,listLabel:"Projects",list:e(gi,{projects:k.projects,selectedProjectId:C?.id??"",onSelectProject:(R)=>{k.select(R),t.openDetail()},onAddProject:()=>c(!0),onTogglePin:(R)=>{k.updateField(R,"isPinned",!R.isPinned)},isAdding:k.isAdding,folderFacts:P,loadError:k.loadError}),detail:C?e("div",{className:"flex-1 min-h-0 scrollbar-overlay-container flex flex-col",children:[e(wi,{project:C,canDelete:k.projects.length>1,isDeleting:k.isDeleting&&p?.id===C.id,isRevealing:x===C.id,models:k.models,accentColorOptions:k.accentColorOptions,onUpdateField:(R,S)=>{k.updateField(C,R,S)},onUpdateFields:(R)=>{k.updateFields(C,R)},onReveal:()=>void N(C),onDeleteProject:()=>{v(null),h(C)}}),e("div",{className:"border-t border-ink/10 px-6 md:px-8 py-4",children:e(Ii,{root:C.path||null,folderId:C.folderId??null,onReport:(R,S)=>r(R,S??"success",{duration:6000})})})]}):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center",children:e("div",{className:"space-y-2",children:[e("p",{className:"text-xs text-ink/60",children:"No project selected."}),e("button",{type:"button",onClick:()=>c(!0),className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add a project"})]})})}),e(Si,{isOpen:l,isSaving:k.isAdding,onClose:()=>c(!1),onSubmit:async(R)=>{await k.addProject(R),t.openDetail()}}),e(Ni,{project:p,isDeleting:k.isDeleting,error:g,onClose:()=>{h(null),v(null)},onConfirm:()=>void A()})]})}function Oi(t){return t!==void 0&&(t.status==="connected"||Boolean(t.baseUrl))}function Di(t){return t.filter((r)=>r.slug.trim().length>0&&Oi(r)).map((r)=>r.slug)}function Fi(t,r){let l=new Map;for(let h of t){let g=h.slug.trim().toLowerCase();if(g)l.set(g,h)}let c=new Set,p=[];for(let h of r){let g=h.slug.trim().toLowerCase();if(c.has(g))continue;if(!h.bundled&&Oi(l.get(g)))continue;c.add(g),p.push(h)}return p}function $i(t){let r=[];for(let l of t){let c=r.find((p)=>p.group===l.group);if(c)c.options.push(l);else r.push({group:l.group,options:[l]})}return r}var Bi="/api/settings/providers";async function _i(t){let r=await fetch(Bi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)throw Error(l?.error||`Providers request failed (HTTP ${r.status})`);return Xr(),Array.isArray(l.providers)?l.providers:null}function zi(t){return _i({providers:t})}function Hi(t,r){return _i(r?{enableProvider:t}:{disableProvider:t})}async function Gi(t,r){try{let l=await fetch("/api/settings/provider-entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,...r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??c.reason??`HTTP ${l.status}`};return Xr(),{...c,ok:!0}}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while saving the provider"}}}async function Wi(t,r){try{let l=await fetch("/api/provider-icon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,baseUrl:r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??`HTTP ${l.status}`};return c}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while fetching the icon"}}}async function Qi(t){try{let r=await fetch("/api/settings/providers/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{slug:t}:{})}),l=await r.json();if(!r.ok)return{ok:!1,added:0,removed:0,changed:[],error:l.error??`HTTP ${r.status}`};return Xr(),l}catch(r){return{ok:!1,added:0,removed:0,changed:[],error:r instanceof Error?r.message:"Network error while refreshing models"}}}async function ta(t){try{let r=await fetch(`${Bi}?id=${encodeURIComponent(t)}`,{method:"DELETE"}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Delete failed (HTTP ${r.status})`};return Xr(),{...l,ok:!0}}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while deleting the provider"}}}function na(t,r){if(t.modelSource==="discovery")return{text:`${t.name} registered — omp discovers its models on each run.`,tone:"success"};if(t.modelSource==="override")return{text:`${t.name} endpoint registered — omp keeps its own model list for this provider.`,tone:"success"};if(r.fetchedCount>0)return{text:`Fetched ${r.fetchedCount} new model${r.fetchedCount===1?"":"s"} from the provider.`,tone:"success"};if(r.fetchedCount===-1)return{text:r.ompNote?`Provider registered, but models could not be listed: ${r.ompNote}`:"Auto-fetch models failed — provider added with default models.",tone:"warning"};return{text:`${t.name} registered — no new models to add.`,tone:"success"}}function oa(t){let r=(l)=>l===1?"":"s";if(t.addedCount>0&&t.removedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} and removed ${t.removedCount} the provider no longer serves.`,tone:"success"};if(t.addedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} from the provider.`,tone:"success"};if(t.removedCount>0)return{text:`Removed ${t.removedCount} model${r(t.removedCount)} the provider no longer serves.`,tone:"success"};return{text:"Models refreshed — the list already matches the provider.",tone:"success"}}function ia(t){if(!t.omp)return null;if(t.omp.written){let r=[];if(t.omp.addedCount>0)r.push(`${t.omp.addedCount} new model${t.omp.addedCount===1?"":"s"} registered`);if(t.omp.backfilledCount>0)r.push(`${t.omp.backfilledCount} model${t.omp.backfilledCount===1?"":"s"} enriched`);if((t.omp.removedCount??0)>0)r.push(`${t.omp.removedCount} model${t.omp.removedCount===1?"":"s"} removed`);return{text:`omp models.yml updated${r.length>0?`: ${r.join(", ")}`:""}.`,tone:"success"}}if(t.omp.reason)return{text:`omp models.yml not updated: ${t.omp.reason}`,tone:"warning"};return null}function aa(t,r){let l=(c)=>c===1?"":"s";if(r.added>0||r.removed>0){let c=[];if(r.added>0)c.push(`${r.added} new model${l(r.added)}`);if(r.removed>0)c.push(`${r.removed} model${l(r.removed)} gone`);return{text:`${t}: ${c.join(", ")} after omp re-ran discovery.`,tone:"success"}}return{text:`${t}: omp re-ran discovery — this provider's list is unchanged.`,tone:"success"}}async function gt(){try{let r=await(await fetch("/api/settings/providers")).json();if(!Array.isArray(r?.providers))return null;return{providers:r.providers,...r.presetProviders?{presetProviders:r.presetProviders}:{},...typeof r.catalogError==="string"?{catalogError:r.catalogError}:{}}}catch(t){return console.error("Failed to load providers from API:",t),null}}async function sa(t,r,l){let c={provider:t,modelId:r};if("maxTokens"in l)c.maxTokens=l.maxTokens??null;if("reasoningEffort"in l)c.reasoningEffort=l.reasoningEffort??null;if(Object.keys(c).length===2)return{ok:!0,written:!1};try{let p=await fetch("/api/settings/model-override",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),h=await p.json();if(!p.ok)return{ok:!1,error:h.error||"Failed to save the model configuration."};return{ok:!0,written:h.written,reason:h.reason}}catch(p){return console.error("Failed to save model override:",p),{ok:!1,error:"Failed to save the model configuration."}}}function la(t){let{providers:r,selectedProvider:l,isDeletingProvider:c,pushToast:p,setProviders:h,setSelectedProviderId:g,setIsAddModalOpen:v,setIsDeleteModalOpen:x,setIsDeletingProvider:y,openLogin:k,openEntryEditor:P,onAddModalClose:N}=t,A=async(j)=>{h(j);try{let V=await zi(j);if(V)h(V)}catch(V){console.error("Failed to save providers via API:",V),p("Failed to save provider settings.","error")}},C=async()=>{let j=await gt();if(j)h(j.providers);return j?.providers??[]},R=async(j,V)=>{try{let z=await Hi(j,V);if(z)h(z);return z}catch(z){return console.error("Failed to update provider connection:",z),p("Failed to update the provider connection.","error"),null}};return{handleAddProvider:async(j,V)=>{let z=j.slug.trim().toLowerCase(),H=r.filter((X)=>X.slug.trim().toLowerCase()!==z);await A([...H,j]);let K=(await R(j.slug,!0))?.find((X)=>X.slug.trim().toLowerCase()===z);g(K?.id||j.id),v(!1),N?.();let q=na(j,V);p(q.text,q.tone)},handleConnect:(j)=>{if(!l)return;if(j==="login")k();else P()},handleEntrySaved:async(j)=>{if(!l)return;p(j.length>0?`${l.name}: updated ${j.join(", ")} in models.yml.`:`${l.name}: nothing to change.`,"success"),await C()},handleOmpAuthSuccess:async()=>{if(!l)return;let j=l.slug;p(`${l.name} signed in — omp stored the credential.`,"success");let z=(await C()).find((H)=>H.slug===j);if(z)g(z.id)},handleToggleProviderDisabled:async()=>{if(!l)return;let j=l,V=j.disabled!==!0;if(!await R(j.slug,!V))return;p(V?`${j.name} disabled — it no longer appears in the model list.`:`${j.name} enabled — its models are offered again.`,"success")},handleDeleteProvider:async(j)=>{let V=j??l;if(!V||c)return;y(!0);try{let z=await ta(V.id);if(!z.ok){p(z.error||"Failed to delete the provider.","error");return}x(!1);let H=z.providers??[];if(l?.id===V.id)g(H[0]?.id??"");if(h(H),z.warning)p(`${V.name} removed from Kabmo, but models.yml cleanup failed: ${z.warning}`,"warning");else if(z.removedFromOmp){let W=z.modelsRemoved??0;p(`${V.name} deleted from models.yml${W>0?` with its ${W} model${W===1?"":"s"}`:""}.`,"success")}else p(`${V.name} removed from Kabmo.`,"success")}finally{y(!1)}},persistProviders:A,reloadProviders:C}}async function Yt(t){try{let r=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Request failed (HTTP ${r.status})`};return l}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while fetching models"}}}async function da(t){try{let r=await fetch("/api/settings/provider-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{...l,success:!1,written:!1,error:l?.error||l?.reason};return Xr(),l}catch(r){return{success:!1,written:!1,error:r instanceof Error?r.message:"Network error while adding the model"}}}function ca(t,r){let l=new Map(t.map((v)=>[v.id,v])),c=new Set,p=[],h=[];for(let v of r){if(!v.id||c.has(v.id))continue;c.add(v.id);let x=l.get(v.id);if(!x){let y={...v};h.push(y),p.push(y);continue}p.push({...v,isVisible:x.isVisible!==!1,...x.temperature!==void 0?{temperature:x.temperature}:{},...x.maxTokens!==void 0?{maxTokens:x.maxTokens}:{},...x.topP!==void 0?{topP:x.topP}:{},...x.reasoningEffort!==void 0?{reasoningEffort:x.reasoningEffort}:{}})}let g=t.filter((v)=>!c.has(v.id)).map((v)=>v.id);return{models:p,added:h,addedCount:h.length,removed:g,removedCount:g.length}}async function pa(t,r){try{await Promise.all(r.map((l)=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:l.id,name:l.name,provider:t,contextWindow:l.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),Xr()}catch(l){console.error("Failed to sync provider models to catalog:",l)}}var tu=/^model-\d+-(?:1|2)$/;function nu(t){return`${t.name} ${t.slug} ${t.baseUrl||""}`.toLowerCase().includes("kenari")}function ua(t,r){if(!nu(t))return r;return r.filter((l)=>{let c=l.name.trim().toLowerCase(),p=c==="kenari default model"||c==="kenari fast / flash";return!(tu.test(l.id)&&p)})}function ma(t){let{providers:r,selectedProvider:l,isFetchingModels:c,pushToast:p,setProviders:h,setIsFetchingModels:g,persistProviders:v,reloadProviders:x}=t,y=async()=>{if(!l||c)return;let S=l;g(!0);try{let I=await Qi(S.slug);if(!I.ok){p(I.error||"omp could not refresh the model catalog.","error");return}if(I.providers)h(I.providers);let T=aa(S.name,I);p(T.text,T.tone)}finally{g(!1)}},k=async()=>{if(!l||c)return;let S=l;if(!S.baseUrl){p("This provider has no endpoint to import from — use “refresh” instead.","error");return}g(!0);try{let I=await Yt({baseUrl:S.baseUrl,apiKey:S.apiKey,providerSlug:S.slug,persistToOmp:!0,replaceModels:!0,...S.api?{api:S.api}:{},...S.auth?{auth:S.auth}:{}});if(!I.ok||!I.models){p(I.error||"Failed to fetch models from the provider.","error");return}if(I.omp?.written)Xr();let T=ua(S,S.models),M=S.models.length-T.length,{added:U,addedCount:F,removedCount:j}=ca(T,I.models),V=j+M,z=oa({addedCount:F,removedCount:V});p(z.text,z.tone);let H=ia(I);if(H)p(H.text,H.tone);if(F>0)pa(S.name,U);await x()}finally{g(!1)}},P=(S)=>{if(!l)return;v(r.map((I)=>I.id===l.id?{...I,models:S(I.models)}:I))};return{handleRefreshModels:y,handleFetchModels:k,handleHideAll:()=>P((S)=>S.map((I)=>({...I,isVisible:!1}))),handleShowAll:()=>P((S)=>S.map((I)=>({...I,isVisible:!0}))),handleToggleModelVisibility:(S)=>P((I)=>I.map((T)=>T.id===S?{...T,isVisible:!T.isVisible}:T)),handleSaveModelConfig:async(S,I)=>{if(!l)return;let T=l;P((U)=>U.map((F)=>F.id===S?{...F,...I}:F));let M=await sa(T.slug,S,I);if(!M.ok){p(M.error||"Failed to save the model configuration.","error");return}if(M.written)Xr();else if(M.reason)p(M.reason,"error")}}}function fa({autoOpenAdd:t=!1,onAddModalClose:r}={}){let[l,c]=n([]),[p,h]=n([]),[g,v]=n(""),[x,y]=n(null),[k,P]=n(!0),[N,A]=n(!1),[C,R]=n(!1),[S,I]=n(!1),{pushToast:T}=je(),[M,U]=n(t),[F,j]=n(!1),[V,z]=n(!1),[H,W]=n(!1),[K,q]=n(!1),[X,Z]=n(!1),[te,Q]=n(!1),[se,ae]=n(null),[be,xe]=n(null);o(()=>{if(t)U(!0)},[t]),o(()=>{let le=!0;return gt().then((me)=>{if(!le)return;if(P(!1),!me)return;c(me.providers),h(me.presetProviders??[]),y(me.catalogError??null);let Be=me.providers.filter((Ye)=>Ye.status==="connected");v(Be[0]?.id??me.providers[0]?.id??"")}),()=>{le=!1}},[]),o(()=>{let le=null,me=Ea(()=>{if(le)clearTimeout(le);le=setTimeout(()=>{le=null,gt().then((Be)=>{if(Be)c(Be.providers)})},400)});return()=>{if(me(),le)clearTimeout(le)}},[]);let Pe=u(()=>Fi(l,p),[l,p]),ue=u(()=>Di(l),[l]),ve=l.find((le)=>le.id===g)??l[0],Te=la({providers:l,selectedProvider:ve,isDeletingProvider:K,pushToast:T,setProviders:c,setSelectedProviderId:v,setIsAddModalOpen:U,setIsDeleteModalOpen:z,setIsDeletingProvider:q,openLogin:()=>Q(!0),openEntryEditor:()=>Z(!0),...r?{onAddModalClose:r}:{}}),ke=ma({providers:l,selectedProvider:ve,isFetchingModels:C,pushToast:T,setProviders:c,setIsFetchingModels:R,persistProviders:Te.persistProviders,reloadProviders:Te.reloadProviders});return{providers:l,availablePresetProviders:Pe,existingSlugs:ue,selectedProvider:ve,catalogError:x,isLoading:k,isRefreshingList:N,handleRefreshList:async()=>{if(N)return;A(!0);try{let le=await gt();if(!le){T("Could not read the provider list — omp may still be starting.","error");return}c(le.providers),h(le.presetProviders??[]),y(le.catalogError??null),v((Be)=>le.providers.some((Ye)=>Ye.id===Be)?Be:le.providers.find((Ye)=>Ye.status==="connected")?.id??le.providers[0]?.id??"");let me=le.providers.length;T(`Provider list refreshed — ${me} provider${me===1?"":"s"}.`,"success")}finally{A(!1)}},isFetchingModels:C,isRefreshingIcon:S,handleRefreshIcon:async()=>{let le=ve;if(!le||S)return;if(!le.baseUrl){T("This provider has no endpoint, so there is no site to read an icon from.","error");return}I(!0);try{let me=await Wi(le.slug,le.baseUrl);if(!me.ok){T(me.error||"No usable icon on that host or its base domain — keeping the current mark.","error");return}let Ye=(await Te.reloadProviders()).find((Tc)=>Tc.slug===le.slug);if(Ye)v(Ye.id);T(`${le.name}: icon updated from ${le.baseUrl}.`,"success")}finally{I(!1)}},pushToast:T,isAddModelModalOpen:F,setIsAddModelModalOpen:j,handleModelAdded:async(le)=>{T(`${le} registered in models.yml.`,"success"),await Te.reloadProviders()},handleSignedOut:async(le)=>{W(!1),T(le,"success"),await Te.reloadProviders()},isDeleteModalOpen:V,setIsDeleteModalOpen:z,isLogoutModalOpen:H,setIsLogoutModalOpen:W,isDeletingProvider:K,isAddModalOpen:M,setIsAddModalOpen:U,isEntryModalOpen:X,setIsEntryModalOpen:Z,isLoginModalOpen:te,setIsLoginModalOpen:Q,configModel:se,setConfigModel:ae,capabilitiesModel:be,setCapabilitiesModel:xe,setSelectedProviderId:v,...Te,...ke}}function ou(t){if(t.disabled===!0)return"disabled";if(t.status==="connected")return"connected";return"signed-out"}var ru=[{id:"connected",label:"Signed in"},{id:"signed-out",label:"Not signed in",hint:"omp knows these providers; pick one to sign in or add its key."},{id:"disabled",label:"Disabled",hint:"Hidden from the model picker."}];function xa(t,r=""){let l=r.trim().toLowerCase(),c=l?t.filter((h)=>h.name.toLowerCase().includes(l)||h.slug.toLowerCase().includes(l)||h.models.some((g)=>g.id.toLowerCase().includes(l))):t,p=new Map;for(let h of c){let g=ou(h),v=p.get(g);if(v)v.push(h);else p.set(g,[h])}return ru.flatMap((h)=>{let g=p.get(h.id);if(!g||g.length===0)return[];return[{...h,providers:[...g].sort((v,x)=>v.name.localeCompare(x.name))}]})}function zn(t){return t.inModelsYml===!0||t.inOverlay===!0}function wa(t){if(t.disabled===!0)return"Disabled — hidden from the model picker";if(t.status==="connected")switch(t.credentialOrigin){case"models.yml":return"Signed in — key stored in models.yml";case"login":return"Signed in — OAuth credential stored by omp";case"api-key":return"Signed in — API key stored by omp";case"environment":return"Signed in — credential comes from the environment";default:return"Signed in"}return t.oauth===!0?"Not signed in — pick this row to sign in with OAuth":"Not signed in — no credential omp can resolve"}function Sa({providers:t,selectedProviderId:r,onSelectProvider:l,onOpenAddModal:c,onRefresh:p,isRefreshing:h,isLoading:g,catalogError:v}){let[x,y]=n(""),k=i(null),P=xa(t,x);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3 pt-3 pb-2 flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:g?"Loading…":`${t.length} provider${t.length===1?"":"s"}`}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:h||g,title:"Refresh the provider list","aria-label":"Refresh the provider list",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(D,{size:14,strokeWidth:2.2,className:h?"animate-spin":""})}),e("button",{type:"button",onClick:c,title:"Add provider","aria-label":"Add provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]})]}),e("div",{className:"px-3 pb-2",children:e("div",{className:"relative flex items-center",children:[e(O,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{ref:k,type:"text",value:x,onChange:(N)=>y(N.currentTarget.value),placeholder:"Filter providers or models…","aria-label":"Filter providers",className:"w-full bg-paper border border-ink/15 rounded-md pl-7 pr-7 py-1.5 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),x&&e("button",{type:"button",onClick:()=>{y(""),k.current?.focus()},title:"Clear the filter","aria-label":"Clear the filter",className:"absolute right-1.5 p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:11})})]})}),v&&e("p",{className:"mx-3 mb-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10 text-[10px] leading-relaxed text-ink/70",children:["Model catalog unavailable: ",v]}),e("div",{className:"flex-1 scrollbar-overlay-container px-1.5 pb-3",children:g?e("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-[11px] text-ink/45",role:"status","aria-live":"polite",children:[e(m,{size:16,className:"animate-spin"}),e("span",{children:"Reading providers…"})]}):P.length===0?e("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:x?`No provider or model matches “${x}”.`:"No providers detected yet. Use the plus button above to register one."}):P.map((N)=>e("div",{className:"pt-1.5 first:pt-0",children:[e("div",{className:"px-2 pb-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/45 uppercase",children:N.label}),e("span",{className:"text-[10px] font-mono text-ink/35",children:N.providers.length})]}),N.hint&&e("p",{className:"text-[10px] leading-snug text-ink/40 mt-0.5",children:N.hint})]}),e("div",{className:"space-y-0.5",children:N.providers.map((A)=>{let C=A.id===r;return e("button",{type:"button",onClick:()=>l(A.id),"aria-current":C?"true":void 0,title:wa(A),className:`w-full flex items-center gap-2 pl-1.5 pr-2 py-1 rounded-md text-left transition-colors cursor-pointer ${C?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(lt,{provider:A,size:22}),e("span",{className:"flex-1 min-w-0 text-[12px] truncate",children:A.name}),e("span",{className:"w-8 shrink-0 text-right text-[10px] font-mono tabular-nums text-ink/45",children:A.models.length})]},A.id)})})]},N.id))})]})}function Na({provider:t,onRefreshIcon:r,isRefreshingIcon:l=!1}){return e("div",{className:"flex items-start gap-3 pb-4",children:[e(lt,{provider:t,size:30,className:"mt-0.5"}),e("div",{className:"min-w-0 flex flex-1 flex-col gap-0.5",children:[e("h2",{className:"text-xl font-bold leading-tight tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs font-mono text-ink/50 truncate",children:t.slug})]}),r&&e("button",{type:"button",onClick:r,disabled:l,title:t.baseUrl?`Refetch the icon from ${t.baseUrl}`:"This provider has no endpoint to read an icon from","aria-label":"Refresh provider icon",className:"shrink-0 p-1.5 rounded-md border border-ink/15 text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(D,{size:12,className:l?"animate-spin":""})})]})}function Pa(t){switch(t){case"models.yml":return"models.yml key";case"login":return"OAuth login";case"api-key":return"stored API key";case"environment":return"environment variable";default:return"no credential"}}function Ca(t){return t==="login"||t==="api-key"}function Ia(t){let r=t.oauth===!0&&t.auth!=="none"&&t.credentialOrigin!=="models.yml",l=t.inModelsYml===!0;if(r||l)return{login:r,edit:l};return{login:!1,edit:!1,reason:"omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit."}}function Ra({provider:t,onConnect:r,onToggleDisabled:l,onDelete:c,onSignOut:p}){let[h,g]=n(!1),v=t.status==="connected",x=t.disabled===!0,y=t.credentialOrigin,k=Ca(y),P=Ia(t);return e("div",{className:"space-y-6",children:[e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[x?e(d,{children:[e(Qn,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):v?e(d,{children:[e(f,{size:15,className:"text-success flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):e(d,{children:[e(E,{size:15,className:"text-warning flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/80",children:"Not signed in"})]}),e("span",{className:"text-[11px] text-ink/55 font-mono px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10",children:Pa(y)}),e("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[e(de,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),h&&e("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl w-64 z-50 pointer-events-none leading-relaxed",children:x?"Disabled in omp’s config.yml — none of its models appear in the chat model list. The credential is untouched.":v?"omp can resolve a credential for this provider, so its models are offered in the chat picker.":"omp knows this provider but has no credential for it. Connect to sign in or supply a key."})]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:l,title:x?"Offer this provider in the model list again":"Hide this provider and its models from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:x?"enable":"disable"}),P.login&&e("button",{type:"button",onClick:()=>r("login"),title:"Sign in to this provider through omp",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:[e(tr,{size:12}),e("span",{children:v&&y==="login"?"sign in again":"sign in"})]}),P.edit&&e("button",{type:"button",onClick:()=>r("edit"),title:"Edit this provider’s endpoint, credential and dialect in models.yml",className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer border ${P.login?"bg-ink/5 hover:bg-ink/10 text-ink border-ink/15":"bg-ink text-canvas hover:opacity-90 border-ink"}`,children:[e(Fn,{size:12}),e("span",{children:"edit"})]}),!P.login&&!P.edit&&e("button",{type:"button",disabled:!0,title:P.reason,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium opacity-40 cursor-not-allowed",children:[e(bo,{size:12}),e("span",{children:"connect"})]}),k&&e("button",{type:"button",onClick:p,title:"Remove the credential omp stored for this provider",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:[e(Kt,{size:12}),e("span",{children:"sign out"})]}),e("button",{type:"button",onClick:c,disabled:!zn(t),title:zn(t)?t.inModelsYml?"Remove this provider’s models.yml entry":"Remove this provider’s Kabmo settings row":"Nothing to delete: omp discovered this provider from its endpoint. Use disable to hide it.",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-error/10 hover:bg-error/20 text-error text-xs font-medium transition-colors cursor-pointer border border-error/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(L,{size:12}),e("span",{children:"delete"})]})]})]})]}),e("div",{className:"border-b border-ink/10"}),e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Connection details"}),e("div",{className:"flex items-center justify-between gap-4",children:[e("div",{className:"text-xs text-ink/70 min-w-0",children:["Configured in:"," ",e("span",{className:"font-mono text-ink font-medium break-all",children:t.configuredIn})]}),e("span",{className:"text-[11px] text-ink/40 italic shrink-0",children:x?"hidden":v?"active":"inactive"})]}),(t.api||t.auth||t.discovery||t.transport)&&e("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[t.api&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Wire API omp uses for this provider",children:t.api}),t.auth&&t.auth!=="apiKey"&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Auth mode from models.yml",children:["auth: ",t.auth]}),t.discovery&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"omp lists this provider's models live",children:["discovery: ",t.discovery]}),t.transport&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Requests are routed through the auth gateway",children:["transport: ",t.transport]}),t.headers&&Object.keys(t.headers).length>0&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:Object.entries(t.headers).map(([N,A])=>`${N}: ${A}`).join(`
|
|
2
2
|
`),children:[Object.keys(t.headers).length," header",Object.keys(t.headers).length===1?"":"s"]})]})]}),e("div",{className:"border-b border-ink/10"})]})}var Jt=["openai-completions","openai-responses","openai-codex-responses","azure-openai-responses","anthropic-messages","bedrock-converse-stream","google-generative-ai","google-gemini-cli","google-vertex","openrouter-decisions","openai-decisions","workers-ai-systemone","typesafe"],Qt={"openai-completions":"[OI] Chat Completions — the default for gateways and local servers","openai-responses":"[OI] Responses API — newer [OI]-shaped endpoints","openai-codex-responses":"[OC] Responses — Codex-style endpoints","azure-openai-responses":"Azure [OI] Responses — api-key header, api-version query","anthropic-messages":"Anthropic Messages — Claude-shaped proxies (x-api-key)","bedrock-converse-stream":"Amazon Bedrock Converse — AWS credential chain","google-generative-ai":"Google Generative AI — Gemini API (x-goog-api-key)","google-gemini-cli":"Google Gemini CLI — OAuth-backed Gemini route","google-vertex":"Google Vertex AI — service-account / ADC route","openrouter-decisions":"OpenRouter decisions — judge role only","openai-decisions":"[OI] decisions — judge role only","workers-ai-systemone":"Workers AI System One — judge role only",typesafe:"Typesafe System One — judge role only"},pt=["minimal","low","medium","high","xhigh","max"];var Tt=[{value:"apiKey",label:"API key",hint:"omp requires a key for this provider"},{value:"none",label:"No auth (keyless)",hint:"Local server that needs no credential"},{value:"oauth",label:"OAuth",hint:"Claude-Code-style proxy expecting the cloaked request shape"}];var Hn=["chat","tiny","image","tts","stt","search","judge","embedding","rerank","video"],ut={chat:"Chat",tiny:"Tiny",image:"Image",tts:"Speech",stt:"Transcribe",search:"Search",judge:"Judge",embedding:"Embedding",rerank:"Rerank",video:"Video"};function ft(t){return typeof t==="string"&&Hn.includes(t)?t:"chat"}var xt=[{value:"openai-models-list",label:"OpenAI /v1/models",hint:"Any OpenAI-compatible endpoint"},{value:"ollama",label:"Ollama",hint:"Native Ollama /api/tags + /api/show"},{value:"llama.cpp",label:"llama.cpp",hint:"llama.cpp server model endpoints"},{value:"lm-studio",label:"LM Studio",hint:"LM Studio /v1/models + native metadata"},{value:"litellm",label:"LiteLLM proxy",hint:"LiteLLM proxy with rich model metadata"},{value:"proxy",label:"New-API / One-API proxy",hint:"Wire api read per model from the proxy"},{value:"apple-foundation-models",label:"Apple Foundation Models",hint:"On-device model (Apple silicon only)"}];function Ma(t){if(/anthropic\./i.test(t))return"anthropic-messages";if(/generativelanguage\.googleapis\.com/i.test(t))return"google-generative-ai";if(/openai\.azure\.com/i.test(t))return"azure-openai-responses";if(/openrouter\.ai/i.test(t))return"openai-completions";return"openai-completions"}function La(t){if(t.discovery||t.modelSource==="discovery")return"omp discovers this provider’s models live — they appear in the chat model picker, not here.";if(t.modelSource==="override")return t.auth==="none"?"Endpoint override — omp keeps its own model list for this provider. Use “fetch models” to add specific ids.":"Endpoint override — omp keeps its own model list for this provider. It still needs a credential: use “connect” to supply one, or “fetch models” to add specific ids.";if(t.auth==="none")return"No models registered yet. This server is keyless, so use “fetch models” to list what it serves.";return}function Oa(t){if(t.discovery!==void 0||t.modelSource==="discovery")return"omp lists this provider’s models itself — importing would freeze a snapshot beside that live list. Use “refresh”.";if(!t.baseUrl)return"This provider has no endpoint Kabmo can probe — omp owns its URL. Use “refresh” instead.";return}function Da({models:t,emptyReason:r,onToggleModelVisibility:l,onHideAll:c,onShowAll:p,onRefreshModels:h,onImportModels:g,onAddModel:v,fetchBlockReason:x,isFetchingModels:y,onOpenModelConfig:k,onOpenModelCapabilities:P}){let[N,A]=n(""),[C,R]=n("all"),S=u(()=>{let U=new Map;for(let F of t){let j=ft(F.kind);U.set(j,(U.get(j)??0)+1)}return U},[t]),I=u(()=>[...S.entries()].sort((U,F)=>F[1]-U[1]),[S]),T=t.filter((U)=>{if(C!=="all"&&ft(U.kind)!==C)return!1;if(!N.trim())return!0;let F=N.trim().toLowerCase();return U.id.toLowerCase().includes(F)||U.name.toLowerCase().includes(F)}),M=t.filter((U)=>!U.isVisible).length;return e("div",{className:"space-y-3.5",children:[e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"text-xs font-semibold text-ink",children:["Models ",e("span",{className:"font-normal text-ink/60",children:["(",t.length,")"]}),M>0&&e("span",{className:"font-normal text-ink/40",children:[" · ",M," hidden"]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:h,disabled:y,title:"Ask omp to re-run model discovery for every provider",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:opacity-90 transition-opacity cursor-pointer border border-ink disabled:opacity-40 disabled:cursor-not-allowed",children:[e(D,{size:12,className:y?"animate-spin":""}),e("span",{children:y?"refreshing…":"refresh"})]}),g&&e("button",{type:"button",onClick:g,disabled:Boolean(x)||y,title:x??"List this endpoint’s models and register them in models.yml",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(fe,{size:12}),e("span",{children:"import"})]}),e("button",{type:"button",onClick:v,title:"Register a model by hand",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:[e(Y,{size:12}),e("span",{children:"add model"})]}),e("button",{type:"button",onClick:c,disabled:t.length===0,title:"Hide every model from the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"hide all"}),e("button",{type:"button",onClick:p,disabled:M===0,title:"Show every model in the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"show all"})]})]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>R("all"),"aria-pressed":C==="all",className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${C==="all"?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:["All ",e("span",{className:"font-mono text-ink/45",children:t.length})]}),I.map(([U,F])=>e("button",{type:"button",onClick:()=>R(U),"aria-pressed":C===U,className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${C===U?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:[ut[U]," ",e("span",{className:"font-mono text-ink/45",children:F})]},U))]}),e("div",{className:"relative flex items-center",children:[e(O,{size:14,className:"absolute left-3 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:N,onChange:(U)=>A(U.currentTarget.value),placeholder:"Filter models by id or name…","aria-label":"Filter models",className:"w-full bg-paper border border-ink/15 rounded-lg pl-9 pr-9 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors shadow-2xs"}),N&&e("button",{type:"button",onClick:()=>A(""),title:"Clear the filter","aria-label":"Clear the model filter",className:"absolute right-2 p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:12})})]}),e("div",{className:"space-y-1 pt-1",children:T.length===0?e("div",{className:"py-8 text-center text-xs text-ink/40",children:N||C!=="all"?"No model matches this filter.":r||"No models registered for this provider yet."}):T.map((U)=>{let F=ft(U.kind);return e("div",{className:`flex items-center justify-between gap-3 px-3 py-2 rounded-lg hover:bg-ink/5 transition-colors group ${!U.isVisible?"opacity-50":""}`,children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:`text-xs font-medium truncate ${U.isVisible?"text-ink":"text-ink/60 line-through decoration-ink/40"}`,title:U.id,children:U.name}),F!=="chat"&&e("span",{className:"shrink-0 px-1 py-0 rounded border border-ink/15 text-[10px] font-mono uppercase tracking-wide text-ink/55",children:ut[F]})]}),U.name!==U.id&&e("span",{className:"text-[10px] font-mono text-ink/40 truncate block",children:U.id})]}),e("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(U.priceInput!==void 0||U.priceOutput!==void 0)&&e("span",{title:`$${U.priceInput??"?"} in / $${U.priceOutput??"?"} out per 1M tokens${U.pricingStatus&&U.pricingStatus!=="exact"?` (${U.pricingStatus})`:""}`,className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:[Hf(U.priceInput)," / ",Hf(U.priceOutput)]}),U.contextWindow&&e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:cc(U.contextWindow)}),e("button",{type:"button",onClick:()=>P(U),title:"What this model declares: tools, vision, reasoning","aria-label":`Capabilities of ${U.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(pr,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>k(U),title:"Per-model overrides omp honours (max output, reasoning level)","aria-label":`Configure ${U.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(ko,{size:13,strokeWidth:1.8})}),U.hasVision&&e("span",{title:"Accepts image input",className:"p-1 text-ink/60","aria-label":"Accepts image input",children:e(Zo,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>l(U.id),title:U.isVisible?"Hide model from chat picker":"Show model in chat picker","aria-label":U.isVisible?`Hide ${U.name}`:`Show ${U.name}`,"aria-pressed":U.isVisible,className:`p-1 rounded transition-colors cursor-pointer ${U.isVisible?"text-ink/60 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10"}`,children:U.isVisible?e(qe,{size:14,strokeWidth:1.8}):e(Ct,{size:14,strokeWidth:1.8})})]})]},U.id)})})]})}var Fa=[{value:"fetch",label:"Fetch now",hint:"List the endpoint here and write the ids into models.yml"},{value:"discovery",label:"Let omp discover",hint:"omp lists the models live on every run"},{value:"override",label:"Endpoint only",hint:"Keep omp’s own model list, change only the URL"}],Gn="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors cursor-pointer";function ja({api:t,onApiChange:r,auth:l,onAuthChange:c,source:p,onSourceChange:h,discovery:g,onDiscoveryChange:v}){return e(d,{children:[e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:t,onChange:(x)=>r(x.currentTarget.value),className:Gn,children:Jt.map((x)=>e("option",{value:x,children:x},x))})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:l,onChange:(x)=>c(x.currentTarget.value),className:Gn,children:Tt.map((x)=>e("option",{value:x.value,children:x.label},x.value))})]})]}),e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-1",children:[Qt[t]," · ",Tt.find((x)=>x.value===l)?.hint]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Model source"}),e("div",{className:"grid grid-cols-3 gap-2",children:Fa.map((x)=>{let y=p===x.value;return e("button",{type:"button",onClick:()=>h(x.value),className:`px-2 py-1.5 rounded-lg border text-[11px] transition-colors cursor-pointer ${y?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:x.label},x.value)})}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:Fa.find((x)=>x.value===p)?.hint})]}),p==="discovery"&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Discovery protocol"}),e("select",{value:g,onChange:(x)=>v(x.currentTarget.value),className:Gn,children:xt.map((x)=>e("option",{value:x.value,children:x.label},x.value))}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:xt.find((x)=>x.value===g)?.hint})]})]})}function Ba({presets:t,selectedPresetId:r,onSelectPreset:l}){let[c,p]=n({}),h=$i(t);if(t.length===0)return e("p",{className:"px-2 py-3 text-xs text-ink/50",children:"Every known provider is already configured."});return e("div",{className:"max-h-52 scrollbar-overlay-container pr-1 space-y-2",children:h.map((g)=>{let v=c[g.group]===!0;return e("div",{children:[e("button",{type:"button",onClick:()=>p((x)=>({...x,[g.group]:!v})),className:"w-full flex items-center gap-1.5 px-0.5 py-1 text-[10px] font-semibold tracking-wider text-ink/50 uppercase hover:text-ink/80 transition-colors cursor-pointer",children:[e(B,{size:11,className:`transition-transform ${v?"-rotate-90":""}`}),e("span",{children:g.group}),e("span",{className:"text-ink/30 normal-case tracking-normal",children:g.options.length})]}),!v&&e("div",{className:"grid grid-cols-2 gap-2 pt-1",children:g.options.map((x)=>{let y=x.id===r;return e("button",{type:"button",onClick:()=>l(x),title:x.defaultUrl,className:`flex items-center gap-2 p-2 rounded-lg border text-left text-xs transition-colors cursor-pointer ${y?"border-ink/50 bg-ink/5 font-semibold text-ink shadow-2xs":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e(lt,{provider:{icon:x.icon,slug:x.slug,name:x.name},size:18}),e("span",{className:"truncate flex-1",children:x.name}),y&&e(f,{size:12,className:"shrink-0 text-ink"})]},x.id)})})]},g.group)})})}var iu=/^[a-z0-9][a-z0-9._-]{0,63}$/;function _a(t){return{api:t?.api??Ma(t?.defaultUrl??""),auth:t?.auth??"apiKey",discovery:t?.discovery??"openai-models-list",source:t?.discovery?"discovery":t?.bundled?"override":"fetch"}}function Ka({isOpen:t,onClose:r,onAddProvider:l,presets:c,existingSlugs:p}){let h=c,g=h[0],v=_a(g),[x,y]=n(g?.id||"openai"),[k,P]=n(g?.name||"OpenAI"),[N,A]=n(g?.defaultUrl||"https://api.openai.com/v1"),[C,R]=n(""),[S,I]=n(v.api),[T,M]=n(v.auth),[U,F]=n(v.source),[j,V]=n(v.discovery),[z,H]=n(!1),W=(ue)=>{let ve=_a(ue);y(ue.id),P(ue.name),A(ue.defaultUrl),I(ve.api),M(ve.auth),V(ve.discovery),F(ve.source)};if(o(()=>{if(!h.find((ve)=>ve.id===x)&&h[0])W(h[0])},[h,x]),!t)return null;let K=h.find((ue)=>ue.id===x),q=k.trim(),X=(q&&K&&q===K.name?K.slug:q.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")).toLowerCase(),Z=new Set(p.map((ue)=>ue.trim().toLowerCase())),te=K?.bundled===!0,Q=!X?"Enter a provider name to derive an id.":!iu.test(X)?"The derived id must start with a letter or digit.":Z.has(X)&&!te?`"${X}" is already registered in models.yml — connecting it would overwrite that provider. Pick another name.`:"",se=T==="apiKey",ae=se&&U==="fetch",be=ae&&!C.trim()?'Enter the API key, or set Auth to "No auth" for a keyless local server.':"",xe=Boolean(q)&&!Q&&!be&&!z;return e(J,{onClose:r,header:e("div",{className:"flex items-center gap-2",children:[e(xn,{size:16,className:"text-ink/70"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Add Model Provider"})]}),form:{onSubmit:async(ue)=>{if(ue.preventDefault(),!xe)return;H(!0);try{let ve=Date.now(),Te=N.trim(),ke=C.trim(),We={id:`provider-${ve}`,name:q,slug:X,icon:K?.icon||"custom",status:"connected",configuredIn:"auth credentials",credentialSource:"models.yml",baseUrl:Te,...ke?{apiKey:ke}:{},api:S,...T!=="apiKey"?{auth:T}:{},...U==="discovery"?{discovery:j}:{},modelSource:U,models:[]},Me=await Yt({baseUrl:Te,apiKey:ke||void 0,providerSlug:We.slug,persistToOmp:!0,api:S,auth:T,...U==="discovery"?{discovery:j}:{},...U==="override"?{registerOnly:!0}:{}});if(Me.ok&&Me.models)We.models=Me.models,l(We,{fetchedCount:Me.models.length,ompNote:Me.omp?.reason});else l(We,{fetchedCount:-1,ompNote:Me.omp?.written?void 0:Me.error});r()}finally{H(!1)}},className:"p-5 space-y-4"},maxWidthClass:"max-w-lg",footer:e("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!xe,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:z?e(d,{children:[e($a,{size:14,className:"animate-pulse"}),e("span",{children:U==="fetch"?"Fetching models...":"Registering..."})]}):e(d,{children:[e(f,{size:14}),e("span",{children:"Connect Provider"})]})})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Provider Preset"}),e(Ba,{presets:h,selectedPresetId:x,onSelectPreset:W})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Display Name"}),e("input",{type:"text",required:!0,value:k,onChange:(ue)=>P(ue.currentTarget.value),placeholder:"e.g. My Provider",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"}),X&&e("p",{className:"text-[10px] text-ink/40 mt-1 font-mono",children:["models.yml id: ",X]}),Q&&e("p",{className:"text-[11px] text-error mt-1",children:Q})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Base URL"}),e("div",{className:"relative flex items-center",children:[e(Qe,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",required:!0,value:N,onChange:(ue)=>A(ue.currentTarget.value),placeholder:"https://api.domain.com/v1",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),e(ja,{api:S,onApiChange:I,auth:T,onAuthChange:M,source:U,onSourceChange:F,discovery:j,onDiscoveryChange:V}),se&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API Key (stored securely)",!ae&&e("span",{className:"font-normal text-ink/40",children:" (optional)"})]}),e("div",{className:"relative flex items-center",children:[e(mt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"password",value:C,onChange:(ue)=>R(ue.currentTarget.value),placeholder:"sk-••••••••••••••••",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),be&&e("p",{className:"text-[11px] text-error mt-1",children:be}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:[ae?"May name an environment variable (e.g. ":"Leave empty to keep using the provider’s existing credential. May name an environment variable (e.g. ",e("span",{className:"font-mono",children:"MY_KEY"}),") or run a command with a leading"," ",e("span",{className:"font-mono",children:"!"}),"."]})]})]})}var Zt="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",au={"openai-models-list":!0,"lm-studio":!0,proxy:!0};function za({discovery:t,onDiscoveryChange:r,headers:l,onHeadersChange:c}){let p=(x)=>r({...t,...x}),h=t.type==="openai-models-list",g=au[t.type]===!0,v=(x,y)=>{c(l.map((k,P)=>P===x?{...k,...y}:k))};return e(d,{children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Discovery ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("select",{value:t.type,onChange:(x)=>p({type:x.currentTarget.value}),className:Zt,children:[e("option",{value:"",children:"Use the registered model list"}),xt.map((x)=>e("option",{value:x.value,children:x.label},x.value))]}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:t.type?xt.find((x)=>x.value===t.type)?.hint:"With discovery set, omp lists this provider’s models live and importing here would freeze a snapshot beside that list."})]}),t.type&&e("div",{className:"space-y-2 pl-3 border-l-2 border-ink/10",children:[e("div",{children:[e("label",{className:"block text-[11px] font-medium text-ink/70 mb-1",children:["Timeout ",e("span",{className:"font-normal text-ink/40",children:"(ms, optional)"})]}),e("input",{type:"text",inputMode:"numeric",value:t.timeoutMs,onChange:(x)=>p({timeoutMs:x.currentTarget.value}),placeholder:"omp default",className:`${Zt} font-mono`})]}),h&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.injectV1===!0,onChange:(x)=>p({injectV1:x.currentTarget.checked}),className:`${he} mt-0.5`}),e("span",{children:["Skip the forced ",e("span",{className:"font-mono",children:"/v1"})," prefix — for a gateway rooted at a versioned path."]})]}),g&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.advertisedReasoning===!0,onChange:(x)=>p({advertisedReasoning:x.currentTarget.checked}),className:`${he} mt-0.5`}),e("span",{children:"Trust the reasoning ladder the endpoint advertises in its model rows."})]})]}),e("div",{children:[e("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e("label",{className:"block text-xs font-semibold text-ink",children:["Request headers ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("button",{type:"button",onClick:()=>c([...l,{key:"",value:""}]),className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(Y,{size:11}),e("span",{children:"add"})]})]}),l.length===0?e("p",{className:"text-[10px] text-ink/40 leading-relaxed",children:"Sent with every request to this provider — the place for a gateway’s routing or version header."}):e("div",{className:"space-y-1.5",children:l.map((x,y)=>e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:x.key,onChange:(k)=>v(y,{key:k.currentTarget.value}),placeholder:"Header-Name","aria-label":`Header ${y+1} name`,className:`${Zt} font-mono`}),e("input",{type:"text",value:x.value,onChange:(k)=>v(y,{value:k.currentTarget.value}),placeholder:"value","aria-label":`Header ${y+1} value`,className:`${Zt} font-mono`}),e("button",{type:"button",onClick:()=>c(l.filter((k,P)=>P!==y)),title:"Remove this header","aria-label":`Remove header ${y+1}`,className:"shrink-0 p-1.5 rounded text-ink/40 hover:text-error hover:bg-error/10 transition-colors cursor-pointer",children:e(b,{size:12})})]},y))})]})]})}var on="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",su="sk-••••••••••••••••••••••••";function Va({isOpen:t,provider:r,onClose:l,onSaved:c}){let[p,h]=n(r.baseUrl??""),[g,v]=n(""),[x,y]=n(r.api??""),[k,P]=n(r.auth??"apiKey"),[N,A]=n({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),[C,R]=n(Object.entries(r.headers??{}).map(([H,W])=>({key:H,value:W}))),[S,I]=n(!1),[T,M]=n(null);if(o(()=>{if(!t)return;h(r.baseUrl??""),v(""),y(r.api??""),P(r.auth??"apiKey"),A({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),R(Object.entries(r.headers??{}).map(([H,W])=>({key:H,value:W}))),M(null)},[t,r.id,r.baseUrl,r.api,r.auth,r.discovery]),!t)return null;let U=r.credentialOrigin==="models.yml"||r.credentialOrigin==="api-key",F=k!=="apiKey",j=!F&&!g.trim()&&!U?'omp needs a credential for a keyed provider — enter the key, or switch Auth to "No auth".':"",V=!S&&!j,z=async(H)=>{if(H.preventDefault(),!V)return;I(!0),M(null);let W={},K=p.trim();if(K!==(r.baseUrl??""))W.baseUrl=K||null;if(g.trim())W.apiKey=g.trim();if(x&&x!==r.api)W.api=x;if(k!==(r.auth??"apiKey"))W.auth=k;if(N.type!==(r.discovery??""))W.discovery=N.type?{type:N.type,...N.timeoutMs.trim()&&Number(N.timeoutMs)>0?{timeoutMs:Number(N.timeoutMs)}:{},...N.injectV1!==void 0?{injectV1:N.injectV1}:{},...N.advertisedReasoning!==void 0?{advertisedReasoning:N.advertisedReasoning}:{}}:null;let q=Object.fromEntries(C.filter((Q)=>Q.key.trim()).map((Q)=>[Q.key.trim(),Q.value.trim()])),X=r.headers??{};if(JSON.stringify(q)!==JSON.stringify(X))W.headers=Object.keys(q).length>0?q:null;if(Object.keys(W).length===0){I(!1),l();return}let te=await Gi(r.slug,W);if(I(!1),!te.ok){M(te.error??"Could not write the provider entry.");return}c(te.changed??[]),l()};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2.5",children:[e(lt,{provider:r,size:26}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Edit connection"}),e("p",{className:"text-[11px] text-ink/50 font-mono",children:["models.yml · ",r.slug]})]})]}),form:{onSubmit:z,className:"p-5 space-y-4"},footer:e("div",{className:"pt-3 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!V,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40 flex items-center gap-1.5",children:[e(vt,{size:13}),e("span",{children:S?"Saving…":"Save to models.yml"})]})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Endpoint URL"}),e("div",{className:"relative flex items-center",children:[e(Qe,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:p,onChange:(H)=>h(H.currentTarget.value),placeholder:"https://api.example.com/v1",className:`${on} pl-8 font-mono`})]})]}),F?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:[e(de,{size:13,className:"mt-0.5 flex-shrink-0 text-ink/50"}),e("span",{children:["Registered with ",e("span",{className:"font-mono",children:["auth: ",k]})," — omp sends no API key for this provider. Switch Auth to “API key” if the endpoint starts requiring one."]})]}):e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API key",U&&e("span",{className:"font-normal text-ink/40",children:" (stored; leave empty to keep it)"})]}),e("div",{className:"relative flex items-center",children:[e(mt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:g,onChange:(H)=>v(H.currentTarget.value),placeholder:U?su:"sk-…",autoComplete:"off",spellcheck:!1,className:`${on} pl-8 font-mono`})]}),j&&e("p",{className:"text-[11px] text-error mt-1",children:j}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:["A literal key, or ",e("span",{className:"font-mono",children:"!command"})," to have omp run a command for it — both are stored in ",e("span",{className:"font-mono",children:"models.yml"}),"."]})]}),e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:x,onChange:(H)=>y(H.currentTarget.value),className:on,children:[e("option",{value:"",children:"Inherit omp's setting"}),Jt.map((H)=>e("option",{value:H,children:H},H))]})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:k,onChange:(H)=>P(H.currentTarget.value),className:on,children:Tt.map((H)=>e("option",{value:H.value,children:H.label},H.value))})]})]}),x&&e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-2",children:Qt[x]}),e(za,{discovery:N,onDiscoveryChange:A,headers:C,onHeadersChange:R}),T&&e("div",{className:"flex items-start gap-2 text-[11px] text-error",children:[e(E,{size:13,className:"mt-0.5 shrink-0"}),e("span",{className:"select-text",children:T})]})]})}var Ya={status:"connecting",authUrl:null,launchUrl:null,instructions:null,prompt:null,notices:[],error:null};function Xa(t){if(!t)return null;return/^(.*\bcode:?\s+)([A-Za-z0-9][A-Za-z0-9-]{3,})\s*$/s.exec(t.trim())?.[2]??null}function Ja(t){let r=t.replace(/^\[|\]$/g,"");return r==="localhost"||r==="127.0.0.1"||r==="::1"||r.endsWith(".localhost")}function Wn(t){if(!t)return!1;let r;try{r=new URL(t)}catch{return!1}if(r.protocol!=="http:"&&r.protocol!=="https:")return!0;if(!Ja(r.hostname))return!0;return typeof window<"u"&&Ja(window.location.hostname)}function Qa({isOpen:t,providerId:r,onAuthenticated:l}){let[c,p]=n(Ya),[h,g]=n(""),v=i(null),x=i(l);x.current=l,o(()=>{if(!t)return;p(Ya),g("");let k=new AbortController,P=null,N=(A)=>{if(!P)return;fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...A,type:"extension_ui_response",loginId:P}),signal:k.signal}).catch(()=>{})};return v.current=N,fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r}),signal:k.signal}).then(async(A)=>{if(!A.ok){let I=await A.json().catch(()=>null),T=I&&typeof I.error==="string"?I.error:`HTTP ${A.status}`;throw Error(T)}if(!A.body)throw Error("Streaming is not supported by this browser");let C=A.body.getReader(),R=new TextDecoder,S="";for(;;){let{done:I,value:T}=await C.read();if(I)break;S+=R.decode(T,{stream:!0});let M=S.split(`
|
|
3
3
|
|
|
4
4
|
`);S=M.pop()??"";for(let U of M){let F=U.split(`
|