@openartifactsai/cli 0.23.0 → 0.25.0
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/SKILL.md +23 -6
- package/package.json +1 -1
- package/vendor/CHANGELOG.md +1116 -0
- package/vendor/artifact-types/docs/SKILL.md +7 -5
- package/vendor/artifact-types/page/SKILL.md +3 -1
- package/vendor/artifact-types/page/artifact-type/reference/capabilities.d.ts +0 -1
- package/vendor/artifact-types/page/artifact-type/reference/capabilities.md +1 -1
- package/vendor/frame-host/client/comments.js +20 -25
- package/vendor/frame-host/client/page.js +1363 -0
- package/vendor/frame-host/client/review.js +279 -0
- package/vendor/frame-host/client/runtime.js +8 -6
- package/vendor/frame-host/client/sample.js +1 -1
- package/vendor/frame-host/client/shell.css +1 -0
- package/vendor/frame-host/client/shell.js +207 -6
- package/vendor/frame-host/client/translate.js +375 -0
- package/vendor/frame-host/frame-host.mjs +193 -32
- package/vendor/home/assets/{browser-models-DWkPVHmp.js → browser-models-CNChpEzB.js} +4 -4
- package/vendor/home/assets/library-DAVNFZ4g.js +1 -0
- package/vendor/home/assets/main-C7DAdnKi.js +32 -0
- package/vendor/home/assets/main-Cduee5v6.css +1 -0
- package/vendor/home/assets/node.browser-BX90gLvV.js +1 -0
- package/vendor/home/assets/node.browser-BltE9Vxw.js +1 -0
- package/vendor/home/assets/tokens-B6Dchhk5.js +572 -0
- package/vendor/home/index.html +3 -3
- package/vendor/home/library/index.html +2 -2
- package/vendor/open-artifacts.mjs +11128 -3829
- package/vendor/runtime.json +1 -1
- package/vendor/shell/assets/{browser-models-BzwWAVuE.js → browser-models-DEdnh4xg.js} +4 -4
- package/vendor/shell/assets/index-BbQPECay.js +47 -0
- package/vendor/shell/assets/index-Cduee5v6.css +1 -0
- package/vendor/shell/assets/{node.browser-BvryIsl7.js → node.browser-CzAEKnJQ.js} +1 -1
- package/vendor/shell/assets/{node.browser-BgqLTfql.js → node.browser-Dt1frvjW.js} +1 -1
- package/vendor/shell/index.html +2 -2
- package/vendor/type-server/cli.mjs +217 -34
- package/vendor/type-server/editors/data/assets/{index-CX_sn7ZZ.js → index-M7l6GYrQ.js} +6 -11
- package/vendor/type-server/editors/data/index.html +1 -1
- package/vendor/type-server/editors/design/assets/{index-BpNUmTVD.js → index-D3IExhNM.js} +79 -84
- package/vendor/type-server/editors/design/index.html +1 -1
- package/vendor/type-server/editors/design-system/assets/{index-CP6AEO1P.js → index-DdgIQkBN.js} +8 -13
- package/vendor/type-server/editors/design-system/index.html +1 -1
- package/vendor/type-server/editors/docs/assets/{abnfDiagram-WEYOIA3C-Do25i7oS.js → abnfDiagram-WEYOIA3C-DYZ28wZy.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{architectureDiagram-ZHVYKT53-BLlpboc2.js → architectureDiagram-ZHVYKT53-BlNOisCb.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{blockDiagram-RJAE7QA3-D0rO5p7M.js → blockDiagram-RJAE7QA3-CQVhlYNw.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{c4Diagram-XDPPPE54-OoTiysJI.js → c4Diagram-XDPPPE54-CGbpwSFn.js} +1 -1
- package/vendor/type-server/editors/docs/assets/channel-7ZHbNf0E.js +1 -0
- package/vendor/type-server/editors/docs/assets/{chunk-2E7WHVMD-yBl5BEaI.js → chunk-2E7WHVMD-CeCe17xo.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-2Q5K7J3B-DHKM5gd6.js → chunk-2Q5K7J3B-CzZ2Xznn.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-4EMNKR2T-B-f8WPM6.js → chunk-4EMNKR2T-CNzxjPBJ.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-55XCU76K-n8RDJr36.js → chunk-55XCU76K-CfB8c3Md.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-5VM5RSS4-DzLzcqXE.js → chunk-5VM5RSS4-DzQqctZp.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-JWPE2WC7-BLXkUVcK.js → chunk-JWPE2WC7-BOlMn2TP.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-VQ5W62QI-DAGNVD29.js → chunk-VQ5W62QI-DeIWF9s3.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-XXDRQBXY-fgVyAbWV.js → chunk-XXDRQBXY-DafVeBuV.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{chunk-ZCHMQSOR-D90xHR9n.js → chunk-ZCHMQSOR-Ck41oHN3.js} +2 -2
- package/vendor/type-server/editors/docs/assets/{classDiagram-v2-4MYWR3UA-uk1mPogR.js → classDiagram-v2-4MYWR3UA-Cplz4GWc.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{core-BMv5rGOd.js → core-BjihJIUD.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cose-bilkent-JH36ORCC-BJdqW8l3.js → cose-bilkent-JH36ORCC-DWdy6m2J.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cynefin-EF2NZ3EQ-BCce_ZhK.js → cynefin-EF2NZ3EQ-Dj_QahA-.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{cynefinDiagram-WF24UDRP-DxD-4yjR.js → cynefinDiagram-WF24UDRP-CsxxQbyD.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{dagre-NK4GIZVX-B3VAS51Y.js → dagre-NK4GIZVX-NEPrnyXL.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-CBK3MWTC-B0kHeUdr.js → diagram-CBK3MWTC-Pg1cO5IF.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-I5XIIV2D-BCRvsLAu.js → diagram-I5XIIV2D-CPc4fLeT.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-ODIL2UCW-DFOTsSuA.js → diagram-ODIL2UCW-BFAo5sAk.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-PFBEJUXE-_DT3jk0i.js → diagram-PFBEJUXE-ueA4BuBI.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-RJA3I4VV-UFrdnTgs.js → diagram-RJA3I4VV-B8Qh64n3.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{diagram-TYUNFSNR-DrbWyZOX.js → diagram-TYUNFSNR-udgAkDbB.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ebnfDiagram-V4P3TTPT-M-DCWgZM.js → ebnfDiagram-V4P3TTPT-DNNGufNH.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{elk-QONTBCTQ-l6XmbRQj.js → elk-QONTBCTQ-fAnGl2cK.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{erDiagram-KYQIGQAA-CHqbnmEE.js → erDiagram-KYQIGQAA-C2mbNrl5.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{flowDiagram-IUGLLWBU-BzkFyGCL.js → flowDiagram-IUGLLWBU-D7L47nKm.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ganttDiagram-R7GPNTJY-BcNaSXNv.js → ganttDiagram-R7GPNTJY-CovbGSkl.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{gitGraphDiagram-PDYL7XHY-JaNdSZbv.js → gitGraphDiagram-PDYL7XHY-C6EQlzk2.js} +1 -1
- package/vendor/type-server/editors/docs/assets/index-BvPuZVZu.js +87 -0
- package/vendor/type-server/editors/docs/assets/index-QPklhVMX.css +1 -0
- package/vendor/type-server/editors/docs/assets/{infoDiagram-MVDRKAX5-Cl2Q_Ylf.js → infoDiagram-MVDRKAX5-Bs-D7mTo.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{ishikawaDiagram-HPEHV2GE-umirqIpN.js → ishikawaDiagram-HPEHV2GE-D__AsXXu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{journeyDiagram-BOSHW7O7-HMtvkXvq.js → journeyDiagram-BOSHW7O7-C_6yyXoB.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{kanban-definition-FNSA4HC5-CYouTBUM.js → kanban-definition-FNSA4HC5-BYfemxGS.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{mermaid.core-BEcbgpI8.js → mermaid.core-DFabEkrU.js} +4 -4
- package/vendor/type-server/editors/docs/assets/{mindmap-definition-6OY57UG3-BnwugHtV.js → mindmap-definition-6OY57UG3-BnLoWczF.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{pegDiagram-ECIUJNBX-DqT6jxo7.js → pegDiagram-ECIUJNBX-eT3tDxZi.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{pieDiagram-GNMPY74T-CBKjnr1W.js → pieDiagram-GNMPY74T-DpwWxanm.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{quadrantDiagram-D57K4MC3-CdTG11Ff.js → quadrantDiagram-D57K4MC3-CASaoK3Z.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{railroadDiagram-Y72NRBL7-BZgG8r2y.js → railroadDiagram-Y72NRBL7-CgI3O5bH.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{requirementDiagram-EQYSW5RA-CutdnAmY.js → requirementDiagram-EQYSW5RA-Bxj0Eaeh.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sankeyDiagram-SY24JHO5-DBaoPDhR.js → sankeyDiagram-SY24JHO5-BxSCdedw.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sequenceDiagram-BLEHNHQU-B6YZp-Wu.js → sequenceDiagram-BLEHNHQU-DkF2KRDu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{sizeCapture-INFHLROL-xATlK6Zl.js → sizeCapture-INFHLROL-cEjHrAFu.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{stateDiagram-v2-A6IESKWZ-C7BND5vv.js → stateDiagram-v2-A6IESKWZ-mbWVZCn4.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{swimlanes-B3ENRKFQ-WYLzM6hb.js → swimlanes-B3ENRKFQ-oOsIo2dg.js} +1 -1
- package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-CzluHeRp.js +8 -0
- package/vendor/type-server/editors/docs/assets/{timeline-definition-JXYKGLGB-BXC0F4xE.js → timeline-definition-JXYKGLGB-CiHqWceA.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{usecaseDiagram-WPOLBNNX-Cx58jkEj.js → usecaseDiagram-WPOLBNNX-BJmiiDPK.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{vennDiagram-Q3Y3IDCW-DhdwpApW.js → vennDiagram-Q3Y3IDCW-VoyQedKk.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{wardleyDiagram-IVAIDKWA-CBdbPWVr.js → wardleyDiagram-IVAIDKWA-CZ-NZ6bq.js} +1 -1
- package/vendor/type-server/editors/docs/assets/{xychartDiagram-4URNHDU4-Cb0tcPqs.js → xychartDiagram-4URNHDU4-0-P15J94.js} +1 -1
- package/vendor/type-server/editors/docs/index.html +2 -2
- package/vendor/type-server/editors/motion/assets/{gif-jobs-Bq4rwLBV.js → gif-jobs-BJFbhQfZ.js} +1 -1
- package/vendor/type-server/editors/motion/assets/{index-BDOqtmcc.js → index-bQ-JgltP.js} +20 -25
- package/vendor/type-server/editors/motion/assets/{src-8SKXU1IY.js → src-BJ9yQZbU.js} +1 -1
- package/vendor/type-server/editors/motion/index.html +1 -1
- package/vendor/type-server/editors/sheets/assets/{index-BY38EAff.js → index-BOzYyyQN.js} +10 -15
- package/vendor/type-server/editors/sheets/assets/{workbook-worker-CRtLrZhP.js → workbook-worker-7n7WEEgt.js} +4 -9
- package/vendor/type-server/editors/sheets/index.html +1 -1
- package/vendor/type-server/editors/slides/assets/{index-B51oMclO.js → index-ClAq-wit.js} +10 -15
- package/vendor/type-server/editors/slides/assets/{src-CdsEFSuC.js → src-BizehBWa.js} +1 -1
- package/vendor/type-server/editors/slides/index.html +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{drawing-look-worker-Dd2iYbXC.js → drawing-look-worker-DY5ZQpAe.js} +5 -10
- package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-DmIqT6gk.js → gif-jobs-DM6GuLRR.js} +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{index-CTf9pd4S.js → index-BJfZV8fQ.js} +9 -14
- package/vendor/type-server/editors/whiteboard/assets/{index-B3oRKavi.js → index-DXRE64I0.js} +2 -2
- package/vendor/type-server/editors/whiteboard/index.html +1 -1
- package/vendor/type-server/shell/assets/{browser-models-BzwWAVuE.js → browser-models-DEdnh4xg.js} +4 -4
- package/vendor/type-server/shell/assets/index-BbQPECay.js +47 -0
- package/vendor/type-server/shell/assets/index-Cduee5v6.css +1 -0
- package/vendor/type-server/shell/assets/{node.browser-BvryIsl7.js → node.browser-CzAEKnJQ.js} +1 -1
- package/vendor/type-server/shell/assets/{node.browser-BgqLTfql.js → node.browser-Dt1frvjW.js} +1 -1
- package/vendor/type-server/shell/index.html +2 -2
- package/vendor/home/assets/RuntimeUpdate-BwvJ9sYp.js +0 -43
- package/vendor/home/assets/library-CyeaNaQo.js +0 -226
- package/vendor/home/assets/main-DUyobyFI.js +0 -5
- package/vendor/home/assets/main-DXpv3z2x.css +0 -1
- package/vendor/home/assets/node.browser-Cy4GM7Yl.js +0 -1
- package/vendor/home/assets/node.browser-nUfHL25Z.js +0 -1
- package/vendor/shell/assets/index-BIHLxOO6.js +0 -52
- package/vendor/shell/assets/index-DXpv3z2x.css +0 -1
- package/vendor/type-server/editors/docs/assets/channel-Cgat34ii.js +0 -1
- package/vendor/type-server/editors/docs/assets/index-BMNUnwXE.js +0 -92
- package/vendor/type-server/editors/docs/assets/index-DHqOb_n-.css +0 -1
- package/vendor/type-server/editors/docs/assets/swimlanesDiagram-AYQRV4AK-Bwh1tnzE.js +0 -8
- package/vendor/type-server/shell/assets/index-BIHLxOO6.js +0 -52
- package/vendor/type-server/shell/assets/index-DXpv3z2x.css +0 -1
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browser-models-DWkPVHmp.js","assets/RuntimeUpdate-BwvJ9sYp.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as $,r as u,f as we,u as ce,p as an,a as tt,b as st,d as rn,e as nt,t as ss,g as yr,h as gt,i as on,F as ln,C as cn,j as s,k as dn,l as un,I as pn,m as bt,n as fn,o as Re,q as Me,s as vr,v as be,w as mn,R as ns,x as hn,y as xn,z as gn,P as bn,A as yn,B as vn,D as jn,E as kn,G as Nn,H as wn,J as Sn,K as as,L as Kt,M as jr,N as kr,O as Nr,Q as Tn,S as wr,T as Vt,U as Sr,V as Tr,W as Cr,X as Er,Y as Pr,Z as Rr,_ as Or,$ as Mr,a0 as Ir,a1 as Ar,a2 as qt,a3 as Dr,a4 as zr,a5 as Lr,a6 as _r,a7 as Fr,a8 as Hr,a9 as Ur,aa as $r,ab as Br,ac as Te,ad as Kr,ae as Vr,af as qr,ag as Wr,ah as Gr,ai as Cn,aj as Yr,ak as ie,al as Xr,am as C,an as Zr,ao as Jr,ap as Qr,aq as eo,ar as ks,as as Ns,at as to,au as so,av as no,aw as ao,ax as He,ay as Oe,az as ro,aA as oo,aB as En,aC as io,aD as lo,aE as co,aF as uo,aG as Wt,aH as po,aI as fo,aJ as mo,aK as ho,aL as Ye,aM as xo,aN as go,aO as bo,aP as yo,aQ as vo,aR as jo,aS as at,aT as ko,aU as H,aV as No,aW as Pn,aX as wo,aY as So,aZ as To,a_ as Co,a$ as rs,b0 as Eo,b1 as Po,b2 as Ro,b3 as Oo,b4 as r,b5 as U,b6 as Mo,b7 as Rn,b8 as Io,b9 as he,ba as os,bb as is,bc as ut,bd as Ao,be as Do,bf as $e,bg as Ne,bh as Xe,bi as zo,bj as Lo,bk as Be,bl as On,bm as ft,bn as _o,bo as Fo,bp as Ho,bq as yt,br as Uo,bs as $o,bt as Bo,bu as rt,bv as Ko,bw as Et,bx as Ze,by as Vo,bz as qo,bA as Mn,bB as Wo,bC as Go,bD as Yo,bE as Xo,bF as Zo,bG as Jo,bH as Qo,bI as ei,bJ as ti,bK as si}from"./RuntimeUpdate-BwvJ9sYp.js";const In={name:"arrow-down",size:24,node:[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]};In.node;const ni=$(In);const An={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};An.node;const ai=$(An);const Dn={name:"circle-alert",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle"]};Dn.node;const ri=$(Dn);const zn={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};zn.node;const ls=$(zn);const Ln={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"}]]};Ln.node;const oi=$(Ln);const _n={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};_n.node;const Ke=$(_n);const Fn={name:"ellipsis",size:24,node:[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],aliases:["more-horizontal"]};Fn.node;const ii=$(Fn);const Hn={name:"external-link",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]};Hn.node;const vt=$(Hn);const Un={name:"file-up",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:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]};Un.node;const li=$(Un);const $n={name:"folder",size:24,node:[["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"}]]};$n.node;const ci=$($n);const Bn={name:"globe",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]};Bn.node;const di=$(Bn);const Kn={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};Kn.node;const Vn=$(Kn);const qn={name:"key-round",size:24,node:[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]};qn.node;const ui=$(qn);const Wn={name:"link",size:24,node:[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]};Wn.node;const pi=$(Wn);const Gn={name:"list-filter",size:24,node:[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]};Gn.node;const fi=$(Gn);const Yn={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};Yn.node;const Je=$(Yn);const Xn={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"}]]};Xn.node;const mi=$(Xn);const Zn={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"}]]};Zn.node;const hi=$(Zn);const Jn={name:"message-square",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]};Jn.node;const xi=$(Jn);const Qn={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Qn.node;const gi=$(Qn);const ea={name:"pin-off",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]};ea.node;const bi=$(ea);const ta={name:"pin",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]};ta.node;const ws=$(ta);const sa={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};sa.node;const jt=$(sa);const na={name:"rotate-ccw",size:24,node:[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]};na.node;const yi=$(na);const aa={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};aa.node;const ra=$(aa);const oa={name:"shapes",size:24,node:[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]};oa.node;const vi=$(oa);const ia={name:"shield-check",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};ia.node;const ji=$(ia);const la={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};la.node;const mt=$(la);const ca={name:"triangle-alert",size:24,node:[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle"]};ca.node;const Ie=$(ca);const da={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};da.node;const ua=$(da);const pa={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};pa.node;const kt=$(pa),fa=u.createContext(void 0);function De(e){const t=u.useContext(fa);if(!e&&t===void 0)throw new Error(we(27));return t}const ki=u.forwardRef(function(t,n){const{render:a,className:o,style:i,forceRender:c=!1,...d}=t,l=De(),p=l.useState("open"),m=l.useState("nested"),h=l.useState("mounted"),f=l.useState("transitionStatus");return ce("div",t,{state:{open:p,transitionStatus:f},ref:[l.context.backdropRef,n],stateAttributesMapping:an,props:[{role:"presentation",hidden:!h,style:{userSelect:"none",WebkitUserSelect:"none"}},d],enabled:c||!m})}),Ni=u.forwardRef(function(t,n){const{render:a,className:o,style:i,disabled:c=!1,nativeButton:d=!0,...l}=t,p=De(),m=p.useState("open"),{getButtonProps:h,buttonRef:f}=tt({disabled:c,native:d}),g={disabled:c};function x(b){m&&p.setOpen(!1,st(rn,b.nativeEvent))}return ce("button",t,{state:g,ref:[n,f],props:[{onClick:x},l,h]})}),wi=u.forwardRef(function(t,n){const{render:a,className:o,style:i,id:c,...d}=t,l=De(),p=nt(c);return l.useSyncedValueWithCleanup("descriptionElementId",p),ce("p",t,{ref:n,props:[{id:p},d]})}),ma=u.createContext(void 0);function Si(){const e=u.useContext(ma);if(e===void 0)throw new Error(we(26));return e}const Ti="--nested-dialogs",Ci="data-nested-dialog-open",Ei={...yr,...ss,nestedDialogOpen(e){return e?{[Ci]:""}:null}},Pi=u.forwardRef(function(t,n){const{render:a,className:o,style:i,finalFocus:c,initialFocus:d,...l}=t,p=De(),m=p.useState("descriptionElementId"),h=p.useState("disablePointerDismissal"),f=p.useState("floatingRootContext"),g=p.useState("popupProps"),x=p.useState("modal"),b=p.useState("mounted"),j=p.useState("nested"),v=p.useState("nestedOpenDialogCount"),T=p.useState("open"),N=p.useState("openMethod"),E=p.useState("titleElementId"),k=p.useState("transitionStatus"),D=p.useState("role"),L=f.useState("floatingId");Si(),gt({open:T,ref:p.context.popupRef,onComplete(){T&&p.context.onOpenChangeComplete?.(!0)}});const R=d===void 0?on(p.context.popupRef):d,_=v>0,A=p.useStateSetter("popupElement"),q=ce("div",t,{state:{open:T,nested:j,transitionStatus:k,nestedDialogOpen:_},props:[g,{id:L,"aria-labelledby":E,"aria-describedby":m,role:D,...ln,hidden:!b,onKeyDown(S){cn.has(S.key)&&S.stopPropagation()},style:{[Ti]:v}},l],ref:[n,p.context.popupRef,A],stateAttributesMapping:Ei});return s.jsx(dn,{context:f,openInteractionType:N,disabled:!b,closeOnFocusOut:!h,initialFocus:R,returnFocus:c,modal:x!==!1,restoreFocus:"popup",children:q})}),Ri=u.forwardRef(function(t,n){const{keepMounted:a=!1,...o}=t,i=De(),c=i.useState("mounted"),d=i.useState("modal"),l=i.useState("open");return c||a?s.jsx(ma.Provider,{value:a,children:s.jsxs(un,{ref:n,...o,children:[c&&d===!0&&s.jsx(pn,{ref:i.context.internalBackdropRef,inert:bt(!l)}),t.children]})}):null});function Oi({store:e,parentContext:t,isDrawer:n}){const a=e.useState("open"),o=e.useState("disablePointerDismissal"),i=e.useState("modal"),c=e.useState("popupElement"),d=e.useState("floatingRootContext"),[l,p]=u.useState(0),[m,h]=u.useState(0),f=l===0,g=fn(d,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(x){if(!e.context.outsidePressEnabledRef.current||"button"in x&&x.button!==0)return!1;if("touches"in x){if(x.type==="touchend"){if(x.changedTouches.length!==1||x.touches.length!==0)return!1}else if(x.touches.length!==1)return!1}const b=Re(x);if(f&&!o){if(i){const j=e.context.internalBackdropRef.current,v=e.context.backdropRef.current;return j||v?j===b||v===b||Me(b,c)&&!b?.hasAttribute("data-base-ui-portal"):!0}return!0}return!1},escapeKey:f});return vr(a&&i===!0,c),e.useContextCallback("onNestedDialogOpen",(x,b)=>{p(x),h(b)}),be(()=>(t?.onNestedDialogOpen&&(a?t.onNestedDialogOpen(l+1,m+(n?1:0)):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&a&&t.onNestedDialogOpen(0,0)}),[n,a,l,m,t]),mn(e,{activeTriggerProps:g.reference,inactiveTriggerProps:g.trigger,popupProps:g.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:m}),null}const Mi={...hn,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role};class Ii extends ns{constructor(t,n,a){const o=new bn,i=Ai(t,o,n,a);super(i,Di(o),Mi)}setOpen=(t,n)=>{n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),!n.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(t,n),this.update(xn(this.state,t,n.trigger)))}}function Ai(e,t,n,a=!1){return{...gn(t,n,a),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function Di(e){return{popupRef:u.createRef(),backdropRef:u.createRef(),internalBackdropRef:u.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function zi(e,t){const{children:n,open:a,defaultOpen:o=!1,onOpenChange:i,onOpenChangeComplete:c,disablePointerDismissal:d=!1,modal:l=!0,actionsRef:p,handle:m,triggerId:h,defaultTriggerId:f=null}=t,g=e==="drawer",x=l,b=d,j="dialog",v=De(!0),T=v!=null,N={modal:x,disablePointerDismissal:b,nested:T,role:j},E=yn((A,X)=>new Ii({open:o,openProp:a,activeTriggerId:f,triggerIdProp:h,...N},A,X),!0);E.useControlledProp("openProp",a),E.useControlledProp("triggerIdProp",h),E.useSyncedValues(N),E.useContextCallback("onOpenChange",i),E.useContextCallback("onOpenChangeComplete",c);const k=E.useState("open"),D=E.useState("mounted"),L=E.useState("payload");vn(E,k),jn(E);const{forceUnmount:R}=kn(k,E);u.useImperativeHandle(p,()=>({unmount:R,close:()=>E.setOpen(!1,st(Nn))}),[R,E]);const _=k||D;return s.jsxs(fa.Provider,{value:E,children:[m&&s.jsx(wn,{handle:m,store:E}),_&&s.jsx(Oi,{store:E,parentContext:v?.context,isDrawer:g}),typeof n=="function"?n({payload:L}):n]})}const Li=Sn(function(t){return zi("dialog",t)}),_i=u.forwardRef(function(t,n){const{render:a,className:o,style:i,id:c,...d}=t,l=De(),p=nt(c);return l.useSyncedValueWithCleanup("titleElementId",p),ce("h2",t,{ref:n,props:[{id:p},d]})}),ha=u.createContext(void 0);function ot(e){const t=u.useContext(ha);if(t===void 0&&!e)throw new Error(we(47));return t}const Fi={...hn,disabled:e=>e.disabled,instantType:e=>e.instantType,openMethod:e=>e.openMethod,openChangeReason:e=>e.openChangeReason,modal:e=>e.modal,focusManagerModal:e=>e.focusManagerModal,stickIfOpen:e=>e.stickIfOpen,titleElementId:e=>e.titleElementId,descriptionElementId:e=>e.descriptionElementId,openOnHover:e=>e.openOnHover,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Hi extends ns{constructor(t,n,a){const o=new bn;super(Ui(t,o,n,a),$i(o),Fi)}setOpen=(t,n)=>{const a=n.reason===as,o=n.reason===Kt&&n.event.detail===0,i=!t&&(n.reason===jr||n.reason==null),c=kr(n),d=this.select("activeTriggerId");if(!t&&n.reason===rn&&n.trigger==null&&d!=null&&(n.trigger=this.context.triggerElements.getById(d)??this.select("activeTriggerElement")??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const l=()=>{const m=xn(this.state,t,n.trigger,c());m.openChangeReason=n.reason,this.update(m)};a?(this.set("stickIfOpen",!0),this.context.stickIfOpenTimeout.start(Nr,()=>{this.set("stickIfOpen",!1)}),Tn.flushSync(l)):l();let p;o?p="click":i?p="dismiss":n.reason===wr&&(p="focus"),this.set("instantType",p)}}function Ui(e,t,n,a=!1){const o={...gn(t,n,a),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,openOnHover:!1,closeDelay:0,adaptiveOrigin:void 0,...e};return o.open&&e?.mounted===void 0&&(o.mounted=!0),o}function $i(e){return{popupRef:u.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:u.createRef(),beforeContentFocusGuardRef:u.createRef(),stickIfOpenTimeout:new Vt,triggerElements:e}}const Ss=Sn(function({props:t}){const{children:n,open:a,defaultOpen:o=!1,onOpenChange:i,onOpenChangeComplete:c,modal:d=!1,handle:l,triggerId:p,defaultTriggerId:m=null}=t,h=Ki(l,{modal:d,open:o,openProp:a,activeTriggerId:m,triggerIdProp:p});h.useControlledProp("openProp",a),h.useControlledProp("triggerIdProp",p);const f=h.useState("open"),g=h.useState("mounted"),x=h.useState("payload");h.useContextCallback("onOpenChange",i),h.useContextCallback("onOpenChangeComplete",c),vn(h,f),jn(h);const{forceUnmount:b}=kn(f,h,()=>{h.update({stickIfOpen:!0,openChangeReason:null})});h.useSyncedValues({modal:d}),u.useEffect(()=>{f||h.context.stickIfOpenTimeout.clear()},[h,f]),u.useImperativeHandle(t.actionsRef,()=>({unmount:b,close:()=>h.setOpen(!1,st(Nn))}),[b,h]);const j=f||g;return s.jsxs(ha.Provider,{value:h,children:[l&&s.jsx(wn,{handle:l,store:h}),j&&s.jsx(Vi,{store:h,modal:d}),typeof n=="function"?n({payload:x}):n]})});function Bi(e){return ot(!0)?s.jsx(Ss,{props:e}):s.jsx(Sr,{children:s.jsx(Ss,{props:e})})}function Ki(e,t){const n=yn((a,o)=>new Hi(t,a,o));return u.useEffect(()=>n.context.stickIfOpenTimeout.disposeEffect(),[n]),n}function Vi({store:e,modal:t}){const n=e.useState("floatingRootContext"),a=fn(n,{outsidePressEvent:{mouse:t==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}}),o=a.reference,i=a.floating;return mn(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i}),null}const qi=300,Wi=Tr(function(t,n){const{render:a,className:o,style:i,disabled:c=!1,nativeButton:d=!0,handle:l,payload:p,openOnHover:m=!1,delay:h=qi,closeDelay:f=0,id:g,...x}=t,b=ot(!0),v=Cr(l)??b;if(!v)throw new Error(we(74));const T=nt(g),N=v.useState("isTriggerActive",T),E=v.useState("floatingRootContext"),k=v.useState("isOpenedByTrigger",T),D=v.useState("triggerPopupId",T),L=u.useRef(null),{registerTrigger:R,isMountedByThisTrigger:_}=Er(T,L,v,{payload:p,disabled:c,openOnHover:m,closeDelay:f}),A=v.useState("openChangeReason"),X=v.useState("stickIfOpen"),q=v.useState("openMethod"),S=v.useState("focusManagerModal"),W=Pr(E,{enabled:!c&&m&&(q!=="touch"||A!==Kt),mouseOnly:!0,move:!1,handleClose:Rr(),restMs:h,delay:{close:f},triggerElementRef:L,isActiveTrigger:N,isClosing:()=>v.select("transitionStatus")==="ending"}),M=Or(E,{stickIfOpen:X}),F=Mr(()=>v.select("open"),se=>{v.set("openMethod",se)}),K=v.useState("triggerProps",_),{getButtonProps:Z,buttonRef:P}=tt({disabled:c,native:d}),w={open(se){return se&&A===Kt?Dr.open(se):zr.open(se)}},{preFocusGuardRef:O,handlePreFocusGuardFocus:B,handleFocusTargetFocus:G}=Ir(v,L),I=ce("button",t,{state:{disabled:c,open:k},ref:[P,n,R,L],props:[M.reference,W,K,F,{[Ar]:"",id:T,"aria-haspopup":"dialog","aria-expanded":k,"aria-controls":D},x,Z],stateAttributesMapping:w}),J=s.jsx(u.Fragment,{children:I},T);return _&&!S?s.jsxs(u.Fragment,{children:[s.jsx(qt,{ref:O,onFocus:B}),J,s.jsx(qt,{ref:v.context.triggerFocusTargetRef,onFocus:G})]}):J}),xa=u.createContext(void 0);function Gi(){const e=u.useContext(xa);if(e===void 0)throw new Error(we(45));return e}const Yi=u.forwardRef(function(t,n){const{keepMounted:a=!1,...o}=t;return ot().useState("mounted")||a?s.jsx(xa.Provider,{value:a,children:s.jsx(un,{ref:n,...o})}):null}),ga=u.createContext(void 0);function Xi(){const e=u.useContext(ga);if(!e)throw new Error(we(46));return e}const Zi=u.forwardRef(function(t,n){const{render:a,className:o,style:i,anchor:c,positionMethod:d,side:l,align:p,sideOffset:m,alignOffset:h,collisionBoundary:f="clipping-ancestors",collisionPadding:g,arrowPadding:x,sticky:b,disableAnchorTracking:j=!1,collisionAvoidance:v=Lr,...T}=t,N=ot(),E=Gi(),k=_r(),D=N.useState("floatingRootContext"),L=N.useState("mounted"),R=N.useState("open"),_=N.useState("openChangeReason"),A=N.useState("activeTriggerElement"),X=N.useState("modal"),q=N.useState("openMethod"),S=N.useState("positionerElement"),W=N.useState("instantType"),M=N.useState("transitionStatus"),F=N.useState("adaptiveOrigin"),K=u.useRef(null),Z=Fr(S),P=Hr({anchor:c,floatingRootContext:D,positionMethod:d,mounted:L,side:l,sideOffset:m,align:p,alignOffset:h,arrowPadding:x,collisionBoundary:f,collisionPadding:g,sticky:b,disableAnchorTracking:j,keepMounted:E,nodeId:k,collisionAvoidance:v,adaptiveOrigin:F}),w=D.useState("domReferenceElement");be(()=>{const I=w,J=K.current;if(I&&(K.current=I),J&&I&&I!==J){N.set("instantType",void 0);const se=new AbortController;return Z(()=>{N.set("instantType","trigger-change")},se.signal),()=>{se.abort()}}},[w,Z,N]);const O=X===!0&&_!==as;Ur(R&&O,q==="touch",S,A);const B=N.useStateSetter("positionerElement"),G={open:R,side:P.side,align:P.align,anchorHidden:P.anchorHidden,instant:W},te=$r(t,G,{styles:P.positionerStyles,transitionStatus:M,props:T,refs:[n,B],hidden:!L,inert:!R});return s.jsxs(ga.Provider,{value:P,children:[L&&O&&s.jsx(pn,{inert:bt(!R),cutout:A}),s.jsx(Br,{id:k,children:te})]})}),Ji=u.createContext(void 0);function Qi(){const[e,t]=u.useState(0),n=Te(()=>(t(o=>o+1),()=>{t(o=>Math.max(0,o-1))}));return{context:u.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}const el=u.forwardRef(function(t,n){const{render:a,className:o,style:i,initialFocus:c,finalFocus:d,...l}=t,p=ot(),m=Xi(),h=Kr()!=null,{context:f,hasClosePart:g}=Qi(),x=p.useState("open"),b=p.useState("openMethod"),j=p.useState("instantType"),v=p.useState("transitionStatus"),T=p.useState("popupProps"),N=p.useState("titleElementId"),E=p.useState("descriptionElementId"),k=p.useState("modal"),D=p.useState("mounted"),L=p.useState("openChangeReason"),R=p.useState("activeTriggerElement"),_=p.useState("floatingRootContext"),A=_.useState("floatingId"),X=p.useState("disabled"),q=p.useState("openOnHover"),S=p.useState("closeDelay");gt({open:x,ref:p.context.popupRef,onComplete(){x&&p.context.onOpenChangeComplete?.(!0)}}),Vr(_,{enabled:q&&!X,closeDelay:S});const W=c===void 0?on(p.context.popupRef):c,M=k!==!1&&g;p.useSyncedValue("focusManagerModal",M);const F=p.useStateSetter("popupElement"),K={open:x,side:m.side,align:m.align,instant:j,transitionStatus:v},Z=ce("div",t,{state:K,ref:[n,p.context.popupRef,F],props:[T,{id:A,role:"dialog",...ln,"aria-labelledby":N,"aria-describedby":E,onKeyDown(P){h&&cn.has(P.key)&&P.stopPropagation()}},qr(v),l],stateAttributesMapping:an});return s.jsx(dn,{context:_,openInteractionType:b,modal:M,disabled:!D||L===as,initialFocus:W,returnFocus:d,restoreFocus:"popup",previousFocusableElement:Wr(R)?R:void 0,nextFocusableElement:p.context.triggerFocusTargetRef,beforeContentFocusGuardRef:p.context.beforeContentFocusGuardRef,children:s.jsx(Ji.Provider,{value:f,children:Z})})}),tl="data-select-all";function sl(e,t){u.useEffect(()=>{const n=e.current;if(!t||n===null)return;const a=n.ownerDocument,o=()=>n.isConnected&&n.hasAttribute("data-open")&&!n.hasAttribute("data-nested-dialog-open"),i=d=>{d.target!==a.body||!o()||(d.preventDefault(),a.getSelection()?.selectAllChildren(n.querySelector(`[${tl}]`)??n))},c=d=>{if(!(d.metaKey||d.ctrlKey)||!Qr(d)||!o())return;const l=a.getSelection(),p=l?.anchorNode??null,m=p===null?null:p.nodeType===Node.ELEMENT_NODE?p:p.parentElement;m!==null&&!n.contains(m)&&l?.removeAllRanges()};return a.addEventListener("selectstart",i),a.addEventListener("keydown",c,!0),()=>{a.removeEventListener("selectstart",i),a.removeEventListener("keydown",c,!0)}},[e,t])}function ze({open:e,onOpenChange:t,title:n,description:a,children:o,footer:i,className:c,onOpenChangeComplete:d,onKeyCapture:l,initialFocus:p,finalFocus:m}){const h=u.useRef(!1),f=u.useRef(e),[g]=u.useState(Gr),x=u.useRef(null),[b,j]=u.useState(!1),v=u.useCallback(N=>{x.current=N,j(N!==null)},[]);sl(x,e&&b),u.useEffect(()=>{e!==f.current&&(f.current=e,!e&&h.current&&Cn(window,"Enter",()=>!1),h.current=!1)},[e]);const T=N=>{l?.(N),N.key==="Enter"&&(h.current=N.type==="keydown")};return s.jsx(Yr.Provider,{value:g,children:s.jsx(Li,{open:e,onOpenChange:(N,E)=>{Xr(g,E)||t(N)},onOpenChangeComplete:d,children:s.jsxs(Ri,{children:[s.jsx(ki,{className:"fixed inset-0 z-[900] bg-black/30 transition-opacity data-[starting-style]:opacity-0 data-[ending-style]:opacity-0"}),s.jsxs(Pi,{ref:v,className:ie("fixed left-1/2 top-1/2 z-[901] max-h-[calc(100dvh-2rem)] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto overscroll-contain rounded-xl bg-surface p-5 text-fg shadow-popup outline-none","transition-[opacity,transform] data-[starting-style]:scale-95 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",c),onKeyDownCapture:T,onKeyUpCapture:T,initialFocus:p,finalFocus:m,children:[s.jsxs("div",{className:"mb-3 flex items-start gap-3",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx(_i,{className:"text-[15px] font-semibold",children:n}),a?s.jsx(wi,{className:"mt-1 text-fg-muted",children:a}):null]}),s.jsx(Ni,{"aria-label":"Close",className:"rounded-md p-1 text-fg-muted hover:bg-hover",children:s.jsx(kt,{className:"size-4"})})]}),o,i?s.jsx("div",{className:"mt-4 flex justify-end gap-2",children:i}):null]})]})})})}function nl(e,t){for(let n=e.parentElement;n&&n!==t;n=n.parentElement){const{overflowY:a}=getComputedStyle(n);if((a==="auto"||a==="scroll")&&n.scrollHeight>n.clientHeight)return n}return t}function al(e){const t=e?.closest('[role="dialog"], [role="alertdialog"]');return!e||!t?!0:Jr(e.getBoundingClientRect(),nl(e,t).getBoundingClientRect())?e:t}function rl({open:e,onOpenChange:t,title:n,description:a,confirmLabel:o="Confirm",cancelLabel:i="Cancel",danger:c,guardEarlyPress:d,initialFocus:l,finalFocus:p,onConfirm:m}){const h=u.useRef(null),f=u.useRef(null),g=u.useRef(null),x=!!(c&&d);return e?x&&!h.current&&(h.current={opened:performance.now(),shown:null}):h.current=null,s.jsx(ze,{open:e,onOpenChange:t,title:n,description:a,initialFocus:l==="cancel"?f:l==="confirm"?()=>al(g.current):l,finalFocus:p,onOpenChangeComplete:x?b=>{b&&h.current&&h.current.shown===null&&(h.current={...h.current,shown:performance.now()})}:void 0,onKeyCapture:x?b=>{h.current&&Zr(h.current,performance.now(),{key:b.key,repeat:b.repeat,isTrusted:b.nativeEvent.isTrusted})&&b.preventDefault()}:void 0,footer:s.jsxs(s.Fragment,{children:[s.jsx(C,{ref:f,onClick:()=>t(!1),children:i}),s.jsx(C,{ref:g,variant:c?"danger":"primary",onClick:()=>{m(),t(!1)},children:o})]})})}const ba=u.createContext(void 0);function cs(){const e=u.useContext(ba);if(e===void 0)throw new Error(we(64));return e}const ol="data-activation-direction",Nt={tabActivationDirection:e=>({[ol]:e})},il=u.forwardRef(function(t,n){const{className:a,defaultValue:o=0,onValueChange:i,orientation:c="horizontal",render:d,value:l,style:p,...m}=t,h=t.defaultValue!==void 0,f=u.useRef([]),[g,x]=u.useState(()=>new Map),[b,j]=eo({controlled:l,default:o,name:"Tabs",state:"value"}),v=l!==void 0,[T,N]=u.useState(()=>new Map),E=u.useRef(void 0),k=u.useCallback(Y=>Gt(T,Y),[T]),[D,L]=u.useState(()=>({previousValue:b,tabActivationDirection:"none"})),{previousValue:R,tabActivationDirection:_}=D;let A=_,X=!1;R!==b&&(A=Ts(R,b,c,T),X=R!=null&&b!=null&&k(b)==null);const q=X?R:b,S=R!==q||_!==A;be(()=>{S&&L({previousValue:q,tabActivationDirection:A})},[q,S,A]);const W=Te((Y,ee)=>{const ue=Ts(b,Y,c,T);ee.activationDirection=ue,i?.(Y,ee),!ee.isCanceled&&j(Y)}),M=Te((Y,ee)=>{i?.(Y,st(ee,void 0,void 0,{activationDirection:"none"}))}),F=Te((Y,ee)=>(x(ue=>{const pe=new Map(ue);return pe.set(Y,ee),pe}),()=>{x(ue=>{if(ue.get(Y)!==ee)return ue;const pe=new Map(ue);return pe.delete(Y),pe})})),K=u.useCallback(Y=>g.get(Y),[g]),Z=u.useCallback(Y=>{for(const ee of T.values())if(Y===ee.value)return ee.id},[T]),P=u.useMemo(()=>({getTabElementBySelectedValue:k,getTabIdByPanelValue:Z,getTabPanelIdByValue:K,onValueChange:W,orientation:c,registerMountedTabPanel:F,setTabMap:N,tabActivationDirection:A,value:b}),[k,Z,K,W,c,F,N,A,b]),w=u.useMemo(()=>{for(const Y of T.values())if(Y.value===b)return Y},[T,b]),O=u.useMemo(()=>{for(const Y of T.values())if(!Y.disabled)return Y.value},[T]),B=u.useRef(!h),G=u.useRef(o),te=u.useRef(h),I=u.useRef(!1);be(()=>{if(v)return;function Y(Ce,je){j(Ce),L({previousValue:Ce,tabActivationDirection:"none"}),M(Ce,je),B.current=!1}if(T.size===0){I.current&&b!==null&&!E.current?.isConnected&&Y(null,Ns);return}I.current=!0,E.current=T.keys().next().value;const ee=w?.disabled,ue=w==null&&b!==null;if(!ee&&b===G.current&&(te.current=!1),te.current&&ee&&b===G.current)return;const pe=B.current;if(ee||ue){const Ce=O??null;if(b===Ce){B.current=!1;return}let je=Ns;pe?je=ks:ee&&(je=so),Y(Ce,je);return}pe&&w!=null&&(M(b,ks),B.current=!1)},[O,v,M,w,j,T,b]);const se=ce("div",t,{state:{orientation:c,tabActivationDirection:A},ref:n,props:m,stateAttributesMapping:Nt});return s.jsx(ba.Provider,{value:P,children:s.jsx(to,{elementsRef:f,children:se})})});function Gt(e,t){for(const[n,a]of e.entries())if(t===a.value)return n;return null}function Ts(e,t,n,a){if(e==null||t==null)return"none";const[o,i,c]=n==="horizontal"?["left","left","right"]:["top","up","down"],d=Gt(a,e),l=Gt(a,t);if(d==null||l==null)return d!==l&&(typeof e=="number"||typeof e=="string")&&typeof e==typeof t?t>e?c:i:"none";const p=d.getBoundingClientRect()[o],m=l.getBoundingClientRect()[o];return m<p?i:m>p?c:"none"}const ya=u.createContext(void 0);function ll(){const e=u.useContext(ya);if(e===void 0)throw new Error(we(65));return e}const cl=u.forwardRef(function(t,n){const{className:a,disabled:o=!1,render:i,value:c,id:d,nativeButton:l=!0,style:p,...m}=t,{value:h,getTabPanelIdByValue:f,onValueChange:g,orientation:x,tabActivationDirection:b}=cs(),{activateOnFocus:j,registerTabResizeObserverElement:v,tabsListElement:T}=ll(),{highlightedIndex:N,onHighlightedIndexChange:E}=no(),k=nt(d),D=u.useMemo(()=>({disabled:o,id:k,value:c}),[o,k,c]),{compositeProps:L,compositeRef:R,index:_}=ao({metadata:D}),A=c===h,X=u.useRef(!1),q=u.useRef(null),S=Te(I=>{q.current?.(),q.current=I?v(I):null});be(()=>{if(X.current){X.current=!1;return}if(!(A&&_>-1&&N!==_))return;const I=T;if(I!=null){const J=He(Oe(I));if(J&&Me(I,J))return}o||E(_)},[A,_,N,E,o,T]);const{getButtonProps:W,buttonRef:M}=tt({disabled:o,native:l,focusableWhenDisabled:!0}),F=f(c),K=u.useRef(!1),Z=u.useRef(!1);function P(I){g(c,st(oo,I.nativeEvent,void 0,{activationDirection:"none"}))}function w(I){A||o||P(I)}function O(I){A||o||j&&(!K.current||Z.current)&&P(I)}function B(I){if(A||o)return;K.current=!0,Z.current=I.button===0;const J=Oe(I.currentTarget);function se(){K.current=!1,Z.current=!1,J.removeEventListener("pointerup",se),J.removeEventListener("pointercancel",se)}J.addEventListener("pointerup",se),J.addEventListener("pointercancel",se)}return ce("button",t,{state:{disabled:o,active:A,orientation:x,tabActivationDirection:b},ref:[n,M,R,S],props:[L,{role:"tab","aria-controls":F,"aria-selected":A,id:k,onClick:w,onFocus:O,onPointerDown:B,[ro]:A?"":void 0,onKeyDownCapture(){X.current=!0}},m,W],stateAttributesMapping:Nt})});function dl(e,t){const n=En(e).getComputedStyle(e).transform;let a=0,o=0,i=1;if(n&&n!=="none"){const c=n.match(/matrix(?:3d)?\(([^)]+)\)/);if(c){const d=c[1].split(", ").map(parseFloat);d.length===6?(a=d[4],o=d[5],i=Math.sqrt(d[0]*d[0]+d[1]*d[1])):d.length===16&&(a=d[12],o=d[13],i=d[0])}}return{x:a,y:o,scale:i}}const ul="data-index",pl={...Nt,...ss},fl=u.forwardRef(function(t,n){const{className:a,value:o,render:i,keepMounted:c=!1,style:d,...l}=t,{value:p,getTabIdByPanelValue:m,orientation:h,tabActivationDirection:f,registerMountedTabPanel:g}=cs(),x=nt(),{ref:b,index:j}=io(),v=o===p,{mounted:T,transitionStatus:N,setMounted:E}=lo(v),k=!T,D=m(o),L={hidden:k,orientation:h,tabActivationDirection:f,transitionStatus:N},R=u.useRef(null),_=ce("div",t,{state:L,ref:[n,b,R],props:[{"aria-labelledby":D,hidden:k,id:x,role:"tabpanel",tabIndex:v?0:-1,inert:bt(!v),[ul]:j},l],stateAttributesMapping:pl});return gt({open:v,ref:R,onComplete(){v||E(!1)}}),be(()=>{if(!(x==null||k&&!c))return g(o,x)},[k,c,o,x,g]),c||T?_:null}),ml=u.forwardRef(function(t,n){const{activateOnFocus:a=!1,className:o,loopFocus:i=!0,render:c,style:d,...l}=t,{orientation:p,setTabMap:m,tabActivationDirection:h}=cs(),[f,g]=u.useState(0),[x,b]=u.useState(null),j=u.useRef(new Set),v=u.useRef(new Set),T=u.useRef(null);be(()=>{if(typeof ResizeObserver>"u")return;const R=new ResizeObserver(()=>{j.current.forEach(_=>{_()})});return T.current=R,x&&R.observe(x),v.current.forEach(_=>{R.observe(_)}),()=>{R.disconnect(),T.current=null}},[x]);const N=Te(R=>(j.current.add(R),()=>{j.current.delete(R)})),E=Te(R=>(v.current.add(R),T.current?.observe(R),()=>{v.current.delete(R),T.current?.unobserve(R)})),k={orientation:p,tabActivationDirection:h},D={"aria-orientation":p==="vertical"?"vertical":void 0,role:"tablist"},L=u.useMemo(()=>({activateOnFocus:a,registerIndicatorUpdateListener:N,registerTabResizeObserverElement:E,tabsListElement:x}),[a,N,E,x]);return s.jsx(ya.Provider,{value:L,children:s.jsx(co,{render:c,className:o,style:d,state:k,refs:[n,b],props:[D,l],stateAttributesMapping:Nt,highlightedIndex:f,enableHomeAndEndKeys:!0,loopFocus:i,orientation:p,onHighlightedIndexChange:g,onMapChange:m,disabledIndices:uo})})}),va=u.createContext(void 0);function wt(){const e=u.useContext(va);if(!e)throw new Error(we(73));return e}let Cs=0;function ja(e){return Cs+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Cs}`}function Pt(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const n=e(t);return typeof n=="string"?{description:n}:n}return e}function Rt(e){const t=new Map;let n=0,a=0;return e.forEach((o,i)=>{const c=o.transitionStatus==="ending";t.set(o.id,{value:o,domIndex:i,visibleIndex:c?-1:n,offsetY:a}),a+=o.height||0,c||(n+=1)}),t}function Ot(e,t){let n=0;return e.map(a=>{if(a.transitionStatus==="ending")return a;const o=n>=t;return n+=1,a.limited===o?a:{...a,limited:o}})}const ve={toasts:e=>e.toasts,isEmpty:e=>e.toasts.length===0,toast:(e,t)=>e.toastMetadata.get(t)?.value,toastIndex:(e,t)=>e.toastMetadata.get(t)?.domIndex??-1,toastOffsetY:(e,t)=>e.toastMetadata.get(t)?.offsetY??0,toastVisibleIndex:(e,t)=>e.toastMetadata.get(t)?.visibleIndex??-1,focused:e=>e.focused,expanded:e=>e.hovering||e.focused,expandedOrOutOfFocus:e=>e.hovering||e.focused||!e.isWindowFocused,prevFocusElement:e=>e.prevFocusElement};class hl extends ns{timers=new Map;areTimersPaused=!1;constructor(t){super({...t,toastMetadata:Rt(t.toasts)},{},ve)}setViewport=t=>{this.set("viewport",t)};syncProviderProps(t,n){const a=this.state.limit!==n;if(this.state.timeout===t&&!a)return;const o={timeout:t,limit:n};if(a){const i=Ot(this.state.toasts,n);o.toasts=i,o.toastMetadata=Rt(i)}this.update(o)}disposeEffect=()=>()=>{this.timers.forEach(t=>{t.timeout?.clear()}),this.timers.clear()};removeToast(t,n=!1){const a=ve.toastIndex(this.state,t);if(a===-1)return;const o=this.state.toasts[a];n||o?.onRemove?.();const i=[...this.state.toasts];i.splice(a,1),this.setToasts(i)}addToast=t=>{const{timeout:n,limit:a}=this.state,o=t.id||ja("toast");if(t.id){const l=ve.toast(this.state,t.id);if(l)if(l.transitionStatus==="ending")this.removeToast(t.id,!0);else{const{id:p,transitionStatus:m,...h}=t;return this.updateToastInternal(t.id,h,!0,!0),t.id}}const i={...t,id:o,updateKey:0,transitionStatus:"starting"},c=[i,...this.state.toasts];this.setToasts(Ot(c,a));const d=i.timeout??n;return i.type!=="loading"&&d>0&&this.scheduleTimer(o,d,()=>this.closeToast(o)),ve.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),o};updateToast=(t,n)=>{const a=ve.toast(this.state,t);!a||a.transitionStatus==="ending"||this.updateToastInternal(t,typeof n=="function"?n(a):n,!1,!0)};updateToastInternal=(t,n,a=!1,o=!1)=>{const{timeout:i,toasts:c}=this.state,d=ve.toast(this.state,t);if(!d||d.transitionStatus==="ending")return;const l={...d,...n,...o&&{updateKey:d.updateKey+1}};this.setToasts(c.map(j=>j.id===t?l:j));const p=l.timeout??i,m=d.timeout??i,h=Object.hasOwn(n,"timeout"),f=l.transitionStatus!=="ending"&&l.type!=="loading"&&p>0,g=this.timers.has(t),x=m!==p,b=d.type==="loading";if(!f&&g){this.clearTimer(t);return}f&&(!g||x||h||b||a)&&(this.clearTimer(t),this.scheduleTimer(t,p,()=>this.closeToast(t)),ve.expandedOrOutOfFocus(this.state)&&this.pauseTimers())};closeToast=t=>{const n=t===void 0,{limit:a,toasts:o}=this.state;let i;if(n)i=o,this.clearTimers();else{const l=ve.toast(this.state,t);if(!l)return;i=[l],this.clearTimer(t)}const c=o.map(l=>n||l.id===t?{...l,transitionStatus:"ending",height:0}:l),d=Ot(c,a);this.setToasts(d,!d.some(l=>l.transitionStatus!=="ending")),i.forEach(l=>{l.transitionStatus!=="ending"&&l.onClose?.()}),this.handleFocusManagement(t)};promiseToast=(t,n)=>{const a=Pt(n.loading),o=this.addToast({...a,type:"loading"}),i=t.then(c=>{const d=Pt(n.success,c);return this.updateToast(o,{...d,type:"success",timeout:d.timeout}),c}).catch(c=>{const d=Pt(n.error,c);return this.updateToast(o,{...d,type:"error",timeout:d.timeout}),Promise.reject(c)});return{}.hasOwnProperty.call(n,"setPromise")&&n.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(t=>{t.timeout&&(t.timeout.clear(),t.remaining=Math.max(t.remaining-(Date.now()-t.start),0))}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((t,n)=>{t.remaining=t.remaining>0?t.remaining:t.delay,t.timeout??=Vt.create(),t.timeout.start(t.remaining,()=>{this.handleTimerFired(n),t.callback()}),t.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=t=>{if(t.pointerType!=="touch")return;const n=Re(t);Me(this.state.viewport,n)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(t,n,a){const o=Date.now(),c=!ve.expandedOrOutOfFocus(this.state)?Vt.create():void 0;c?.start(n,()=>{this.handleTimerFired(t),a()}),this.timers.set(t,{timeout:c,start:o,delay:n,remaining:n,callback:a})}clearTimers(){this.timers.forEach(t=>{t.timeout?.clear()}),this.timers.clear(),this.areTimersPaused=!1}clearTimer(t){this.timers.get(t)?.timeout?.clear(),this.timers.delete(t),this.resetPausedStateIfNoTimersRemain()}handleTimerFired(t){this.timers.delete(t),this.resetPausedStateIfNoTimersRemain()}resetPausedStateIfNoTimersRemain(){this.timers.size===0&&(this.areTimersPaused=!1)}setToasts(t,n=t.length===0){const a={toasts:t,toastMetadata:Rt(t)};n&&(a.hovering=!1,a.focused=!1),this.update(a)}handleFocusManagement(t){const n=He(Oe(this.state.viewport));if(!this.state.viewport||!Me(this.state.viewport,n)||!Wt(n))return;if(t===void 0){this.restoreFocusToPrevElement();return}const a=ve.toasts(this.state),o=ve.toastIndex(this.state,t),i=(d,l)=>{for(let p=d;p>=0&&p<a.length;p+=l)if(a[p].transitionStatus!=="ending")return a[p];return null},c=i(o+1,1)??i(o-1,-1);c?c.ref?.current?.focus():this.restoreFocusToPrevElement()}}const xl=function(t){const{children:n,timeout:a=5e3,limit:o=3,toastManager:i}=t,c=po(()=>new hl({timeout:a,limit:o,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return fo(c.disposeEffect),u.useEffect(function(){return i?i[" subscribe"](({action:p,options:m})=>{const h=m.id;p==="promise"&&m.promise?c.promiseToast(m.promise,m):p==="update"&&h?c.updateToast(h,m.updates):p==="close"?c.closeToast(h):c.addToast(m)}):void 0},[c,i]),s.jsxs(va.Provider,{value:c,children:[s.jsx(gl,{store:c,timeout:a,limit:o}),n]})};function gl(e){const{store:t,timeout:n,limit:a}=e;return be(()=>{t.syncProviderProps(n,a)},[t,n,a]),null}const bl="--toast-frontmost-height",yl=u.forwardRef(function(t,n){const{render:a,className:o,style:i,children:c,...d}=t,l=wt(),p=mo(),m=u.useRef(!1),h=u.useRef(!1),f=u.useRef(!1),g=l.useState("isEmpty"),x=l.useState("toasts"),b=l.useState("focused"),j=l.useState("expanded"),v=l.useState("prevFocusElement"),T=x[0]?.height,N=x.some(P=>P.transitionStatus==="ending"),E=x.filter(P=>P.priority==="high");u.useEffect(()=>{const P=l.state.viewport;if(!P||g)return;const w=En(P),O=Oe(P);function B(I){I.key==="F6"&&Re(I)!==P&&(I.preventDefault(),l.set("prevFocusElement",He(O)),P?.focus({preventScroll:!0}),l.pauseTimers(),l.set("focused",!0))}function G(I){Re(I)===w&&(l.set("isWindowFocused",!1),l.pauseTimers())}function te(I){if(I.relatedTarget)return;const J=Re(I),se=He(Oe(P));(J===w||!Me(P,J)||!Wt(se))&&l.resumeTimers(),p.start(0,()=>l.set("isWindowFocused",!0))}return ho(Ye(w,"keydown",B),Ye(w,"blur",G,!0),Ye(w,"focus",te,!0),Ye(O,"pointerdown",l.handleDocumentPointerDown,!0))},[l,p,g]);function k(P){m.current=!0;const w=P.relatedTarget===l.state.viewport?x.find(O=>O.transitionStatus!=="ending"&&!O.limited):void 0;w?w.ref?.current?.focus():l.restoreFocusToPrevElement()}function D(P){P.key==="Tab"&&P.shiftKey&&Re(P.nativeEvent)===l.state.viewport&&(P.preventDefault(),l.restoreFocusToPrevElement())}function L(){l.state.toasts.some(w=>w.transitionStatus==="ending")||f.current||!h.current||(l.state.isWindowFocused&&l.resumeTimers(),l.set("hovering",!1),h.current=!1)}u.useEffect(L,[N,l]);function R(){l.pauseTimers(),l.set("hovering",!0),h.current=!1}function _(){l.state.isWindowFocused&&l.resumeTimers()}function A(){h.current=!0,L()}function X(P){P.pointerType==="touch"&&(f.current=!0)}function q(P){P.pointerType==="touch"&&(f.current=!1,L())}function S(){if(m.current){m.current=!1;return}b||Wt(He(Oe(l.state.viewport)))&&(l.set("focused",!0),l.pauseTimers())}function W(P){!b||Me(l.state.viewport,P.relatedTarget)||(l.set("focused",!1),_())}const M={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:R,onMouseMove:R,onMouseLeave:A,onFocus:S,onBlur:W,onKeyDown:D,onClick:S,onPointerDown:X,onPointerUp:q,onPointerCancel:q,style:{[bl]:T?`${T}px`:void 0}},F={expanded:j},K=!g&&v&&s.jsx(qt,{onFocus:k}),Z=ce("div",t,{ref:[n,l.setViewport],state:F,props:[M,d,{children:s.jsxs(u.Fragment,{children:[K,c,K]})}]});return s.jsxs(u.Fragment,{children:[K,Z,!b&&E.length>0&&s.jsx("div",{style:xo,children:E.map(P=>s.jsxs("div",{role:"alert","aria-atomic":!0,children:[s.jsx("div",{children:P.title}),s.jsx("div",{children:P.description})]},P.id))})]})}),ka=u.createContext(void 0);function St(){const e=u.useContext(ka);if(!e)throw new Error(we(66));return e}function Mt(e,t,n){switch(e){case"up":return-n;case"down":return n;case"left":return-t;case"right":return t;default:return 0}}const vl="--toast-index",jl="--toast-offset-y",kl="--toast-height",Nl="--toast-swipe-movement-x",wl="--toast-swipe-movement-y",Sl="data-swipe-direction",Tl={...ss,swipeDirection(e){return e?{[Sl]:e}:null}},Es=40,Cl=10,Ps=.5,El=1,Pl=`${go},${bo}`,Rl=u.forwardRef(function(t,n){const{toast:a,render:o,className:i,swipeDirection:c=["down","right"],style:d,...l}=t,p=a.positionerProps?.anchor!==void 0;let m=[];p||(m=Array.isArray(c)?c:[c]);const h=m.length>0,f=wt(),[g,x]=u.useState(void 0),[b,j]=u.useState(!1),[v,T]=u.useState(!1),[N,E]=u.useState({x:0,y:0}),[k,D]=u.useState({x:0,y:0,scale:1}),[L,R]=u.useState(),[_,A]=u.useState(),[X,q]=u.useState(null),S=u.useRef(null),W=u.useRef(void 0),M=u.useRef({x:0,y:0}),F=u.useRef({x:0,y:0,scale:1}),K=u.useRef(void 0),Z=u.useRef(0),P=u.useRef(!1),w=u.useRef({x:0,y:0}),O=u.useRef(!1),B=u.useRef({x:0,y:0}),G=u.useRef(null),te=u.useRef(null),I=f.useState("toastIndex",a.id),J=f.useState("toastVisibleIndex",a.id),se=f.useState("toastOffsetY",a.id),Y=f.useState("focused"),ee=f.useState("expanded");gt({open:a.transitionStatus!=="ending",ref:S,onComplete(){a.transitionStatus==="ending"&&f.removeToast(a.id)}});const ue=Te((z=!1)=>{const V=S.current;if(!V)return;const oe=V.style.height;V.style.height="auto";const xe=V.offsetHeight;V.style.height=oe;function fe(){f.updateToastInternal(a.id,{ref:S,height:xe,transitionStatus:void 0})}z?Tn.flushSync(fe):fe()});be(()=>{const z=W.current;a.transitionStatus!=="starting"&&z===a.id||(z!==void 0&&(x(void 0),D({x:0,y:0,scale:1}),pe({x:0,y:0})),W.current=a.id,ue())},[ue,a.id,a.transitionStatus]);function pe(z){B.current=z,E(z)}be(()=>()=>{te.current?.abort()},[]);function Ce(z,V){const oe=Q=>Q>0?Q**Ps:-(Math.abs(Q)**Ps),xe=z>0&&!m.includes("right")||z<0&&!m.includes("left"),fe=V>0&&!m.includes("down")||V<0&&!m.includes("up");return{x:xe?oe(z):z,y:fe?oe(V):V}}const je=Te(z=>{if(z.pointerId!==G.current)return;G.current=null,te.current?.abort(),te.current=null,j(!1),T(!1),q(null);const V=F.current;if(z.type==="pointercancel"||P.current){pe({x:V.x,y:V.y}),x(void 0);return}const oe=B.current,xe=oe.x-V.x,fe=oe.y-V.y;let Q;for(const de of m)if(Mt(de,xe,fe)>Es){Q=de;break}Q?(x(Q),f.closeToast(a.id)):(pe({x:V.x,y:V.y}),x(void 0))});function ar(z){if(z.button!==0||(z.pointerType==="touch"&&f.pauseTimers(),Re(z.nativeEvent)?.closest(`button,a,input,textarea,[role="button"],${Pl}`)))return;P.current=!1,K.current=void 0,Z.current=0,G.current=z.pointerId,M.current={x:z.clientX,y:z.clientY},w.current=M.current;const xe=z.currentTarget,fe=dl(xe);F.current=fe,D(fe),pe({x:fe.x,y:fe.y}),f.set("hovering",!0),j(!0),T(!1),q(null),O.current=!0,te.current?.abort();const Q=new AbortController;te.current=Q;const de=Oe(xe);de.addEventListener("pointerup",je,{signal:Q.signal}),de.addEventListener("pointercancel",je,{signal:Q.signal}),xe.setPointerCapture?.(z.pointerId)}function rr(z){if(z.pointerId!==G.current)return;z.preventDefault(),O.current&&(M.current={x:z.clientX,y:z.clientY},O.current=!1);const{clientY:V,clientX:oe,movementX:xe,movementY:fe}=z;(fe<0&&V>w.current.y||fe>0&&V<w.current.y)&&(w.current={x:w.current.x,y:V}),(xe<0&&oe>w.current.x||xe>0&&oe<w.current.x)&&(w.current={x:oe,y:w.current.y});const Q=oe-M.current.x,de=V-M.current.y,pr=V-w.current.y,fr=oe-w.current.x;let _e=X;if(!v&&Math.sqrt(Q*Q+de*de)>=El){T(!0);const dt=m.includes("left")||m.includes("right"),xr=m.includes("up")||m.includes("down");if(dt&&xr){const gr=Math.abs(Q),br=Math.abs(de);_e=gr>br?"horizontal":"vertical",q(_e)}}let ye;if(!K.current)_e==="vertical"?de>0?ye="down":de<0&&(ye="up"):_e==="horizontal"?Q>0?ye="right":Q<0&&(ye="left"):Math.abs(Q)>=Math.abs(de)?ye=Q>0?"right":"left":ye=de>0?"down":"up",ye&&m.includes(ye)&&(K.current=ye,Z.current=Mt(ye,Q,de),x(ye));else{const Ct=K.current,dt=Mt(Ct,fr,pr);dt>Es?(P.current=!1,x(Ct)):!(m.includes("left")&&m.includes("right"))&&!(m.includes("up")&&m.includes("down"))&&Z.current-dt>=Cl&&(P.current=!0)}const ys=Ce(Q,de);let vs=F.current.x,js=F.current.y;const mr=m.includes("left")||m.includes("right"),hr=m.includes("up")||m.includes("down");_e!=="vertical"&&mr&&(vs+=ys.x),_e!=="horizontal"&&hr&&(js+=ys.y),pe({x:vs,y:js})}function or(z){if(z.key==="Escape"){if(!S.current||!Me(S.current,He(Oe(S.current))))return;f.closeToast(a.id)}}u.useEffect(()=>{const z=S.current;if(!h||!z)return;function V(oe){G.current===null||!Me(z,Re(oe))||oe.preventDefault()}return Ye(z,"touchmove",V,{passive:!1})},[h]);function ir(){const z=N.x-k.x,V=N.y-k.y;return{transition:b?"none":void 0,transform:b?`translateX(${N.x}px) translateY(${N.y}px) scale(${k.scale})`:void 0,[Nl]:`${z}px`,[wl]:`${V}px`}}const bs=a.priority==="high",lr={role:bs?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":L,"aria-describedby":_,"aria-hidden":bs&&!Y?!0:void 0,onPointerDown:h?ar:void 0,onPointerMove:h?rr:void 0,onPointerUp:h?je:void 0,onPointerCancel:h?je:void 0,onKeyDown:or,inert:bt(a.limited),style:{...ir(),[vl]:a.transitionStatus==="ending"?I:J,[jl]:`${se}px`,[kl]:a.height?`${a.height}px`:void 0}},cr=u.useMemo(()=>({toast:a,setTitleId:R,setDescriptionId:A,recalculateHeight:ue,visibleIndex:J,expanded:ee}),[a,R,A,ue,J,ee]),dr={transitionStatus:a.transitionStatus,expanded:ee,limited:a.limited||!1,type:a.type,swiping:b,swipeDirection:g},ur=ce("div",t,{ref:[n,S],state:dr,stateAttributesMapping:Tl,props:[lr,l]});return s.jsx(ka.Provider,{value:cr,children:ur})}),Ol=u.forwardRef(function(t,n){const{render:a,className:o,style:i,...c}=t,{visibleIndex:d,expanded:l,recalculateHeight:p}=St(),m=u.useRef(null);be(()=>{p();const g=m.current;if(!g||typeof ResizeObserver!="function"||typeof MutationObserver!="function")return;const x=new ResizeObserver(()=>p(!0)),b=new MutationObserver(()=>p(!0));return x.observe(g),b.observe(g,{childList:!0,subtree:!0,characterData:!0}),()=>{x.disconnect(),b.disconnect()}},[p]);const h=d>0;return ce("div",t,{ref:[n,m],state:{expanded:l,behind:h},props:c})});function Na(e){return e==null||typeof e=="boolean"||e===""?!1:Array.isArray(e)?e.some(Na):!0}function wa(e){return u.isValidElement(e)&&Na(e.props.children)}function Sa(e,t,n){const{toast:a,setTitleId:o,setDescriptionId:i}=St(),c=n==="title"?o:i,d=t??(n==="title"?a.title:a.description);return{id:yo(e),children:d,type:a.type,setId:c}}function Ta(e,t,n){const a=wa(e);return be(()=>{if(a)return n(t),()=>{n(o=>o===t?void 0:o)}},[a,t,n]),a?e:null}const Ml=u.forwardRef(function(t,n){const{render:a,className:o,style:i,id:c,children:d,...l}=t,{id:p,children:m,type:h,setId:f}=Sa(c,d,"description"),x=ce("p",t,{ref:n,state:{type:h},props:{...l,id:p,children:m}});return Ta(x,p,f)}),Il=u.forwardRef(function(t,n){const{render:a,className:o,style:i,id:c,children:d,...l}=t,{id:p,children:m,type:h,setId:f}=Sa(c,d,"title"),x=ce("h2",t,{ref:n,state:{type:h},props:{...l,id:p,children:m}});return Ta(x,p,f)}),Al=u.forwardRef(function(t,n){const{render:a,className:o,style:i,disabled:c,nativeButton:d=!0,...l}=t,p=wt(),{toast:m,expanded:h}=St(),[f,g]=u.useState(!1),{getButtonProps:x,buttonRef:b}=tt({disabled:c,native:d}),j={type:m.type};return ce("button",t,{ref:[n,b],state:j,props:[{"aria-hidden":!h&&!f,onClick(){p.closeToast(m.id)},onFocus(){g(!0)},onBlur(){g(!1)}},l,x]})}),Dl=u.forwardRef(function(t,n){const{render:a,className:o,style:i,disabled:c,nativeButton:d=!0,...l}=t,{toast:p}=St(),m=p.actionProps?.children??l.children,{getButtonProps:h,buttonRef:f}=tt({disabled:c,native:d}),g={type:p.type},x=ce("button",t,{ref:[n,f],state:g,props:[l,p.actionProps,h,{children:m}]});return wa(x)?x:null}),zl=u.forwardRef(function(t,n){return s.jsx(vo,{ref:n,...t})});function Ll(){const e=wt(),t=e.useState("toasts");return u.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function _l(){const e=new Set;function t(n){e.forEach(a=>a(n))}return{" subscribe":function(a){return e.add(a),()=>{e.delete(a)}},add(n){const a=n.id||ja("toast"),o={...n,id:a,transitionStatus:"starting"};return t({action:"add",options:o}),a},close(n){t({action:"close",options:{id:n}})},update(n,a){t({action:"update",options:{id:n,updates:a}})},promise(n,a){let o=n;return t({action:"promise",options:{...a,promise:n,setPromise(i){o=i}}}),o}}}const Fl=8,Hl=48;function Ul(e,t,n,a=Hl){if(e.length===0)return null;let o=t-n*(e.length-1);for(const d of e)o-=d.chrome;const i=e.map(d=>d.content).sort((d,l)=>d-l);let c=i.length;for(const d of i){const l=o/c;if(d>l)return Math.max(a,Math.floor(l));o-=d,c-=1}return null}function Ca({value:e,onChange:t,items:n,className:a,trailing:o,label:i}){return s.jsxs(il,{value:e,onValueChange:c=>t(c),className:ie("flex min-h-0 flex-col",a),children:[s.jsxs("div",{className:"flex h-9 shrink-0 items-center gap-1 border-b border-line px-2","data-ui-tabs-bar":"",children:[s.jsx(ml,{"aria-label":i,className:"relative flex items-center gap-1",children:n.map(c=>s.jsx(cl,{value:c.value,className:"h-7 rounded-md px-2 text-[13px] font-medium text-fg-muted outline-none hover:text-fg data-[active]:bg-hover data-[active]:text-fg focus-visible:outline-2 focus-visible:outline-accent",children:c.label},c.value))}),s.jsx("div",{className:"ml-auto flex items-center gap-1",children:o})]}),n.map(c=>s.jsx(fl,{value:c.value,keepMounted:c.keepMounted,className:"min-h-0 flex-1 overflow-auto outline-none focus-visible:rounded focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-accent data-[ending-style]:hidden",children:c.content},c.value))]})}function Ve({icon:e,title:t,children:n}){return s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-8 text-center text-fg-muted",children:[e?s.jsx("div",{className:"text-fg-subtle",children:e}):null,s.jsx("div",{className:"text-[15px] font-semibold text-fg",children:t}),n?s.jsx("div",{className:"max-w-sm",children:n}):null]})}const Ae=_l();function $l(e){if(e.repeat||e.key!=="Enter"&&e.key!==" ")return;const t=e.currentTarget.closest("[data-toast]")??e.currentTarget,n=t.ownerDocument.defaultView;n&&Cn(n,e.key,a=>a instanceof n.Node&&t.contains(a))}function Bl({children:e}){const t=u.useRef(null),[n,a]=u.useState("none");return u.useEffect(()=>{const o=t.current;if(!o)return;const i=()=>{const d=getComputedStyle(o),{scrollWidth:l,clientWidth:p,scrollHeight:m,clientHeight:h,scrollTop:f}=o;a(jo({scrollWidth:l,clientWidth:p,scrollHeight:m,clientHeight:h,scrollTop:f,overflowX:d.overflowX,overflowY:d.overflowY}))};i();const c=new ResizeObserver(i);c.observe(o);for(const d of o.children)c.observe(d);return o.addEventListener("scroll",i,{passive:!0}),()=>{c.disconnect(),o.removeEventListener("scroll",i)}},[]),s.jsx(Ol,{ref:t,role:n==="none"?void 0:"group",tabIndex:n==="none"?void 0:0,"data-overflow":n==="none"?void 0:n,"data-toast-body":"",className:"flex max-h-[var(--toast-fit,none)] min-w-0 flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain rounded-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent data-[overflow=more]:[mask-image:linear-gradient(to_bottom,black_calc(100%-1.5rem),transparent)]",children:e})}function Kl(e,t){u.useLayoutEffect(()=>{const n=e?.ownerDocument.defaultView;if(!e||!n)return;const a=()=>Array.from(e.querySelectorAll("[data-toast]")),o=()=>{const c=[];for(const m of a()){const h=m.querySelector("[data-toast-body]");h&&c.push({chrome:m.offsetHeight-h.offsetHeight,content:h.scrollHeight})}const d=e.getBoundingClientRect().bottom-Fl,l=Ul(c,d,parseFloat(n.getComputedStyle(e).rowGap)||0),p=l===null?"none":`${l}px`;e.style.getPropertyValue("--toast-fit")!==p&&e.style.setProperty("--toast-fit",p)};o();const i=new ResizeObserver(o);for(const c of a()){i.observe(c);const d=c.querySelector("[data-toast-body]");if(d)for(const l of d.children)i.observe(l)}return n.addEventListener("resize",o),()=>{i.disconnect(),n.removeEventListener("resize",o)}},[e,t])}function Vl({type:e}){return e==="success"?s.jsx(ls,{"aria-hidden":"true",className:"mt-px size-4 shrink-0 fill-success text-surface"}):e==="error"?s.jsx(ri,{"aria-hidden":"true",className:"mt-px size-4 shrink-0 fill-danger text-surface"}):e==="warning"?s.jsx(Ie,{"aria-hidden":"true",className:"mt-px size-4 shrink-0 fill-warning text-surface"}):s.jsx(Vn,{"aria-hidden":"true",className:"mt-px size-4 shrink-0 text-fg-muted"})}function ql({viewport:e}){const{toasts:t}=Ll();return Kl(e,t),t.map(n=>s.jsxs(Rl,{toast:n,"data-toast":"",className:"pointer-events-auto flex w-80 items-start gap-3 rounded-lg bg-surface p-3 text-fg shadow-popup transition-[opacity,transform] data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0",children:[s.jsx(Vl,{type:n.type}),s.jsxs(Bl,{children:[s.jsx(Il,{className:"text-[13px] font-semibold"}),s.jsx(Ml,{className:"text-xs text-fg-muted"}),n.actionProps?s.jsx(Dl,{className:"mt-1 self-start rounded px-2 py-0.5 text-xs font-medium text-accent hover:bg-hover"}):null]}),s.jsx(Al,{"aria-label":"Dismiss",onKeyDown:$l,className:"rounded p-0.5 text-fg-muted hover:bg-hover",children:s.jsx(kt,{className:"size-3.5"})})]},n.id))}function Wl({children:e}){const[t,n]=u.useState(null);return s.jsxs(xl,{toastManager:Ae,timeout:4e3,children:[e,s.jsx(zl,{children:s.jsx(yl,{ref:n,"aria-label":"Notifications",className:"pointer-events-none fixed bottom-[var(--toast-foot,1rem)] right-4 z-[1100] flex flex-col gap-2",children:s.jsx(ql,{viewport:t})})})]})}const Gl="modulepreload",Yl=function(e){return"/_open-artifacts/home/"+e},Rs={},Xl=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(p){return Promise.all(p.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=c?.nonce||c?.getAttribute("nonce");o=l(n.map(p=>{if(p=Yl(p),p in Rs)return;Rs[p]=!0;const m=p.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${h}`))return;const f=document.createElement("link");if(f.rel=m?"stylesheet":Gl,m||(f.as="script"),f.crossOrigin="",f.href=p,d&&f.setAttribute("nonce",d),document.head.appendChild(f),m)return new Promise((g,x)=>{f.addEventListener("load",g),f.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};class Zl extends Error{code;fix;status;current;constructor(t,n,a={}){super(n),this.name="OpenArtifactsError",this.code=t,a.fix!==void 0&&(this.fix=a.fix),a.status!==void 0&&(this.status=a.status),a.current!==void 0&&(this.current=a.current)}toJSON(){return{code:this.code,message:this.message,...this.fix?{fix:this.fix}:{},...this.current!==void 0?{current:this.current}:{}}}}const Jl="application/zip",Ql=Object.freeze(["private","site","link"]),It={list:"types",update:"types.update",unpublish:"types.unpublish"};function ec(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!=="https:"&&t.protocol!=="http:"||t.username||t.password||t.search||t.hash)return null;const n=/^\/t\/([A-Za-z0-9][A-Za-z0-9._-]{0,63})\/?$/.exec(t.pathname);return!n||/\.(oatype|zip)$/i.test(n[1])?null:{origin:t.origin,id:n[1]}}const ne=e=>typeof e=="string",Os=e=>Array.isArray(e)?e.filter(ne):[];function ds(e){if(!e||typeof e!="object")return null;const t=e;if(!ne(t.id)||!ne(t.uid)||!ne(t.name)||!ne(t.version))return null;const n=Ql.includes(t.visibility)?t.visibility:"private",a=t.publisher&&typeof t.publisher=="object"?t.publisher:{};return{id:t.id,uid:t.uid,name:t.name,version:t.version,description:ne(t.description)?t.description:"",visibility:n,publisher:{id:ne(a.id)?a.id:"",name:ne(a.name)?a.name:null},mine:t.mine===!0,unpublished:t.unpublished===!0,sha256:ne(t.sha256)?t.sha256:"",bytes:typeof t.bytes=="number"?t.bytes:0,capabilities:Os(t.capabilities),network:Os(t.network),createdAt:ne(t.createdAt)?t.createdAt:"",updatedAt:ne(t.updatedAt)?t.updatedAt:""}}function Ea(e){const t=ds(e);if(!t)return null;const n=e;return!ne(n.pageUrl)||!ne(n.packageUrl)||!ne(n.install)?null:{...t,skill:ne(n.skill)?n.skill:null,manages:n.manages===!0,pageUrl:n.pageUrl,packageUrl:n.packageUrl,install:n.install,notice:ne(n.notice)?n.notice:""}}function tc(e){if(!(!e||typeof e!="object"))return Ea(e.typePage)??void 0}const At=e=>`/api/open-artifacts.${e}`;async function Dt(e,t,n){let a;try{a=await e(t,n)}catch(o){throw new at("connect_failed",o instanceof Error?o.message:String(o),0)}return ko(a)}const Ms=e=>({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});function sc(e=(t,n)=>fetch(t,n)){return{async list(){const t=await Dt(e,At(It.list),{cache:"no-store"}),n=Array.isArray(t.types)?t.types.map(ds).filter(o=>!!o):[],a=t.publish&&typeof t.publish=="object"?t.publish:{allowed:!1,refusal:null};return{types:n,notice:ne(t.notice)?t.notice:"",publish:{allowed:a.allowed===!0,refusal:ne(a.refusal)?a.refusal:null}}},async setVisibility(t,n){const a=Ea(await Dt(e,At(It.update),Ms({id:t,visibility:n})));if(!a)throw new at("server_failed","The site answered without the type.",0);return a},unpublish:t=>Dt(e,At(It.unpublish),Ms({id:t}))}}const nc=e=>`/t/${encodeURIComponent(e)}`,Pa=Object.freeze({models:"oa.models.v1:",grants:"oa.grants.v1:",usage:"oa.usage.v1:"}),ac="anon";function Ra(e){if(!e||typeof e!="object")return null;const t=e;if(t.mode!=="viewer-key")return null;const n=Array.isArray(t.endpoints)?t.endpoints.filter(a=>typeof a=="string"&&/^https?:\/\/[^/]+$/i.test(a)):null;return n?.length?{mode:"viewer-key",endpoints:n}:{mode:"viewer-key"}}function Oa(e){return e&&typeof e.id=="string"&&e.id?e.id:ac}function rc(e,t){const n=e?Ra(e.sample):null;return n?{account:Oa(e?.user??null),config:n,origin:t}:null}function us(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function oc(e,t=us()){try{t?.removeItem(Pa.models+e)}catch{}}function Ma(e){const t=e.toLowerCase().replace(/^\[|\]$/g,"");return t==="localhost"||t.endsWith(".localhost")||t==="::1"||/^127(\.\d{1,3}){3}$/.test(t)}function Is(e){if(Ma(e))return!0;const t=e.toLowerCase().replace(/^\[|\]$/g,"");if(t.endsWith(".local")||t.endsWith(".internal")||t.endsWith(".lan"))return!0;const n=/^(\d{1,3})\.(\d{1,3})\.\d{1,3}\.\d{1,3}$/.exec(t);if(n){const a=Number(n[1]),o=Number(n[2]);return a===10||a===172&&o>=16&&o<=31||a===192&&o===168||a===169&&o===254||a===0}return/^f[cd][0-9a-f]{2}:/.test(t)||/^fe80:/.test(t)}function cp(e,t,n){let a;try{a=new URL(e.trim())}catch{return"endpoint_bad"}return a.protocol!=="https:"&&a.protocol!=="http:"?"endpoint_bad":t.endpoints?.length?t.endpoints.includes(a.origin)?null:"endpoint_not_allowed":a.protocol==="https:"||Ma(a.hostname)||n.startsWith("http:")?null:"endpoint_needs_https"}function dp(e,t){try{const n=new URL(e).hostname,a=new URL(t).hostname;return Is(n)&&!Is(a)?"private":"blocked"}catch{return"blocked"}}const ic="__OPEN_ARTIFACTS_HOME__";function lc(e){if(!e||typeof e!="object")return{};const t=e.cloud;if(!t||typeof t!="object")return{};const n=t;if(typeof n.signInUrl!="string"||typeof n.signOutUrl!="string"||typeof n.appOrigin!="string")return{};const a=n.user&&typeof n.user=="object"&&typeof n.user.id=="string"&&typeof n.user.name=="string"?n.user:null,o=typeof n.trashDays=="number"&&Number.isInteger(n.trashDays)&&n.trashDays>=0?n.trashDays:void 0,i=n.limits&&typeof n.limits=="object"?n.limits.importBytes:void 0,c=typeof i=="number"&&Number.isInteger(i)&&i>0?{importBytes:i}:void 0,d=ps(n.site),l=Ra(n.sample),p=tc(e);return{...p?{typePage:p}:{},cloud:{user:a,appOrigin:n.appOrigin,signInUrl:n.signInUrl,signOutUrl:n.signOutUrl,...o!==void 0?{trashDays:o}:{},...c?{limits:c}:{},...d?{site:d}:{},...n.siteTypes===!0?{siteTypes:!0}:{},...l?{sample:l}:{}}}}function zt(e){return typeof e!="string"||e.length===0||e.length>2048||/[\u0000-\u001f\u007f]/.test(e)?!1:e.startsWith("/")?!e.startsWith("//")&&!e.includes("\\"):/^https?:\/\//i.test(e)}function As(e,t){if(typeof e!="string")return null;const n=e.trim();return n.length>0&&n.length<=t?n:null}function ps(e){if(!e||typeof e!="object")return;const t=e,n=[];if(Array.isArray(t.links))for(const o of t.links){if(!o||typeof o!="object")continue;const{label:i,href:c,where:d}=o,l=As(i,80);l&&zt(c)&&(d==="account-menu"||d==="home")&&n.push({label:l,href:c,where:d})}let a;if(t.brand&&typeof t.brand=="object"){const{name:o,logoUrl:i}=t.brand,c=As(o,80);(c||zt(i))&&(a={...c?{name:c}:{},...zt(i)?{logoUrl:i}:{}})}if(!(n.length===0&&!a))return{...n.length>0?{links:n}:{},...a?{brand:a}:{}}}function Ia(e,t){return(ps(e)?.links??[]).filter(n=>n.where===t).map(({label:n,href:a})=>({label:n,href:a}))}function Aa(e,t){if(e.startsWith("/"))return!1;try{return new URL(e).origin!==t}catch{return!0}}function cc(e,t,n){let a;try{a=new URL(e,n)}catch{return e}return!a.searchParams.has("return_to")&&t.startsWith("/")&&!t.startsWith("//")&&a.searchParams.set("return_to",t),a.origin===n?`${a.pathname}${a.search}${a.hash}`:a.href}function Da(e){if(!e||typeof e!="object")return null;const t=e.accessLogoutUrl;if(typeof t!="string")return null;try{const n=new URL(t);return n.protocol==="https:"||n.protocol==="http:"?n.href:null}catch{return null}}function dc(e){if(!e||typeof e!="object")return!1;if(za(e))return!0;const t=e.providers;return Array.isArray(t)&&t.some(n=>!!n&&typeof n=="object"&&n.id==="cloudflare-access")}function za(e){return Da(e)}let me=null,Qe=null,fs=!1;const uc=new Map,pc=new Set;function fc(e){me=e,Qe=null,fs=!1}function Ue(){return me}function mc(){const e=me;return e?(Qe??=Xl(async()=>{const{BrowserModels:t}=await import("./browser-models-DWkPVHmp.js").then(n=>n.b);return{BrowserModels:t}},__vite__mapDeps([0,1])).then(({BrowserModels:t})=>{const n=new t({account:e.account,config:e.config,origin:e.origin,storage:us(),events:typeof window>"u"?null:window});n.on(a=>{for(const o of[...pc])o(a)});for(const a of uc.values())n.noteArtifact(a);return fs=!0,n}),Qe):Promise.reject(new at("unsupported","No model service here.",0))}function hc(e){return e instanceof Zl?new at(e.code,e.message,400):e}async function Ee(e){const t=await mc();try{return await e(t)}catch(n){throw hc(n)}}const ge={modelsList:()=>me?Ee(e=>e.modelsList()):H.modelsList(),modelsSet:e=>me?Ee(t=>t.modelsSet(e)):H.modelsSet(e),modelsRemove:e=>me?Ee(t=>t.modelsRemove(e)):H.modelsRemove(e),modelsTest:e=>me?Ee(t=>t.modelsTest(e)):H.modelsTest(e),modelsCatalog:(e,t)=>me?Promise.resolve({provider:e,models:[],error:"There are no agent apps here."}):H.modelsCatalog(e,t),grantsList:e=>me?Ee(t=>t.grantsList(e)):H.grantsList(e),grantsAnswer:e=>me?Ee(t=>t.grantsAnswer(e)):H.grantsAnswer(e),grantsRevoke:e=>me?Ee(t=>t.grantsRevoke(e)):H.grantsRevoke(e),usageSummary:e=>me?!fs&&!xc(me.account)?Promise.resolve({artifacts:[]}):Ee(t=>t.usageSummary(e)):H.usageSummary(e)};function xc(e){try{return!!us()?.getItem(Pa.usage+e)}catch{return!1}}async function gc(e){if(oc(e),me?.account===e&&Qe)try{(await Qe).forgetKeys()}catch{}}const bc=["user","extra"],yc=["design","page"];function Ds(e){return Date.parse(e.contentAt||e.updatedAt||e.createdAt||"")||0}function vc(e,t){if(!t||!t.harness&&!t.workspace)return[...e];const n=d=>d.replace(/[\\/]+$/,""),a=(d,l)=>d===l||d.startsWith(`${l}/`)||d.startsWith(`${l}\\`),o=t.workspace?n(t.workspace):null,i=d=>!!o&&!!d&&a(n(d),o),c=d=>!!o&&!!d&&(a(n(d),o)||a(o,n(d)));return e.filter(d=>(!t.harness||d.owner?.harness===t.harness)&&(!o||i(d.owner?.workspace)||i(d.root)||c(d.project)))}function jc(e,t){return t!==null&&e.some(n=>n.project===t)?t:null}function kc(e,t){return t===null?[...e]:e.filter(n=>(n.project||Pn)===t)}const La=Object.freeze({query:"",types:[],date:"any",sharing:"any",pinned:!1});function _a(e){return(e.types.length>0?1:0)+(e.date!=="any"?1:0)+(e.sharing!=="any"?1:0)+(e.pinned?1:0)}function Nc(e){return e.query.trim()!==""||_a(e)>0}function wc(e,t,n){const a=t.query.trim().toLocaleLowerCase();return e.filter(o=>(t.types.length===0||t.types.includes(o.type))&&(!t.pinned||o.pinned)&&(t.sharing==="any"||o.shared===(t.sharing==="shared"))&&No(o.contentAt||o.updatedAt,t.date,n)&&(!a||o.title.toLocaleLowerCase().includes(a)))}function Sc(e,t){const n=new Map;for(const a of e){const o=n.get(a.type);o?o.count+=1:n.set(a.type,{id:a.type,title:a.typeTitle||a.type,count:1})}return[...n.values()].sort((a,o)=>a.title.localeCompare(o.title,t)||a.id.localeCompare(o.id))}function Tc(e){return[...e].sort((t,n)=>Number(n.pinned)-Number(t.pinned)||Ds(n)-Ds(t))}function Cc(e){return e.enabled&&e.runnable&&!e.shadowedBy}function ms(e){return!Cc(e)||e.trusted===!1?null:e.scope==="builtin"?wo(e.id):yc.includes(e.id)?"agent":bc.includes(e.scope)&&e.runtime==="frame"?"custom":null}function ht(e){return ms(e)!==null}function Ec(e){const t={blank:[],agent:[],custom:[]};for(const n of e){const a=ms(n);a&&t[a].push(n)}return t}function Pc(e){return e.find(t=>t.id==="design"&&ht(t))??e.find(ht)??null}function Rc(e){return e?e.live?e.status==="running"&&e.working!==!1?"working":"idle":"offline":"none"}function Oc(e,t){return e.map(n=>n.id===t.id?t:n)}function Mc(e,t){return e.filter(n=>n.id!==t)}function Fa(){let e=0;return{get asked(){return e>0},async run(t,n,a){const o=++e;let i;try{i=await t()}catch(c){o===e&&a(c);return}o===e&&n(i)}}}function Ic(e,t,n){const a=So(e);return!a||a.openArtifacts!=="host_hello"?null:{origin:t,caps:a.caps,harness:a.harness??null,agentName:a.agentName??null,declared:n,library:a.library??null}}function Ac(e){const t=e.thumbnail?.trim();return t?t.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`/api/open-artifacts.${To.thumbnail}?id=${encodeURIComponent(e.id)}&v=${encodeURIComponent(t)}`:null}function Dc(e,t){switch(t.type){case"start":return e.kind==="sending"||e.kind==="checking"?e:{kind:"sending",name:t.name,loaded:0,total:t.size};case"progress":return e.kind!=="sending"?e:{...e,loaded:Math.max(e.loaded,t.loaded),total:t.total||e.total};case"sent":return e.kind==="sending"?{kind:"checking",name:e.name}:e;case"done":return e.kind==="sending"||e.kind==="checking"?{kind:"done",name:e.name,id:t.id}:e;case"failed":return e.kind==="idle"||e.kind==="done"?e:{kind:"failed",name:e.name,said:t.said};case"dismiss":return e.kind==="failed"?{kind:"idle"}:e}}function Ha(e){return e.kind==="sending"||e.kind==="checking"||e.kind==="done"}function zc(e){return e.kind==="checking"||e.kind==="done"?100:e.kind!=="sending"||e.total<=0?null:Math.min(100,Math.floor(e.loaded/e.total*100))}function Lc(e){const t=e.type.toLowerCase();return/\.zip$/i.test(e.name)||t==="application/zip"||t==="application/x-zip-compressed"}function _c(e){if(!e.length)return null;const t=e.find(Lc);return t?{file:t}:{said:{key:"uploadNotZip"}}}function Fc(e,t){return t===void 0||!(t>0)||e<=t?null:{key:"uploadTooLargeLimit",vars:{limit:Ua(t)}}}function Hc(e){return!!e&&e.includes("Files")}function Ua(e){if(e<1024)return`${e} B`;const t=["KB","MB","GB"];let n=e/1024,a=0;for(;n>=1024&&a<t.length-1;)n/=1024,a++;return`${n>=10||Number.isInteger(n)?Math.round(n):n.toFixed(1)} ${t[a]}`}function Uc(e){const t=/(\d{4,})\s*bytes/i.exec(e);if(!t)return null;const n=Number(t[1]);return Number.isFinite(n)&&n>0?Ua(n):null}function zs(e){const{status:t,code:n,message:a}=e;if(t===0)return{key:"uploadNoAnswer"};if(t===401)return{key:"uploadSignedOut"};if(t===403)return{key:"uploadNotAllowed"};if(t===413||n==="too_large"){const o=Uc(a);return o?{key:"uploadTooLargeLimit",vars:{limit:o}}:a?{key:"uploadTooLargeSaid",vars:{error:a}}:{key:"uploadTooLarge"}}if(t===415)return{key:"uploadNotZip"};if(t===409)return{key:"uploadConflict"};if(t===400){const o=/The (\S+) type is not installed/.exec(a)?.[1];return n==="unsupported"||o?o?{key:"uploadTypeMissing",vars:{type:o}}:{key:"uploadFailed",vars:{error:a}}:{key:"uploadNotArtifact"}}return t===429?{key:"uploadBusy"}:{key:"uploadFailed",vars:{error:a||`HTTP ${t}`}}}function $c(e,t){let n="error",a="";try{const o=JSON.parse(t);if(o&&typeof o=="object"){const i=o;typeof i.code=="string"&&(n=i.code),typeof i.message=="string"&&(a=i.message)}}catch{}return{status:e,code:n,message:a}}function Bc(e){try{const t=JSON.parse(e),n=t&&typeof t=="object"?t.id:void 0;return typeof n=="string"&&n?n:null}catch{return null}}function Kc(e=typeof location>"u"?"":location.hash){return e==="#trash"?"trash":e==="#types"?"types":e==="#models"?"models":"artifacts"}const $a="open-artifacts.tab";function Vc(e){return e==="#models"||e==="#settings"?"settings":null}function qc(){const e=typeof location>"u"?null:Vc(location.hash);if(e)return e;try{const t=localStorage.getItem($a);return t==="types"||t==="settings"?t:"artifacts"}catch{return"artifacts"}}const y=Co()(e=>({tab:qc(),artifacts:null,project:null,listFilters:La,types:null,error:null,host:null,creating:null,makingType:!1,installing:null,sites:null,sitesLoading:null,sitesError:null,renaming:null,undo:null,cloudTab:Kc(),trash:null,purgeUnsupported:!1,purging:null,upload:{kind:"idle"},setTab:t=>{try{localStorage.setItem($a,t)}catch{}e({tab:t})},setArtifacts:t=>e({artifacts:t}),setProject:t=>e({project:t}),setListFilters:t=>e({listFilters:t}),setTypes:t=>e({types:t}),setError:t=>e({error:t}),setHost:t=>e({host:t}),setCreating:t=>e({creating:t}),setMakingType:t=>e({makingType:t}),setInstalling:t=>e({installing:t}),setSites:(t,n=null,a=null)=>e({sites:t,sitesLoading:n,sitesError:a}),setSitesLoading:t=>e({sitesLoading:t}),setRenaming:t=>e({renaming:t}),setUndo:t=>e({undo:t}),setCloudTab:t=>e({cloudTab:t}),setTrash:t=>e({trash:t}),setPurgeUnsupported:()=>e({purgeUnsupported:!0}),setPurging:t=>e({purging:t}),uploadEvent:t=>e(n=>({upload:Dc(n.upload,t)}))})),re=lc(window[ic]);fc(rc(re.cloud,location.origin));const Ba=window.parent!==window,Wc=Ro();function Ka(e){const t=y.getState().host;t&&window.parent.postMessage(rs(e),t.origin)}function Ls(e){const t=Eo(e.data);if(!Ba||e.source!==window.parent||!Po(t)||t.openArtifacts!=="host_hello")return;const n=e.origin;Wc().then(({hosts:a,latest:o})=>{if(!o)return;const i=!!a?.length&&a.includes(n);if(a?.length&&!i){y.getState().host?.origin===n&&y.getState().setHost(null);return}const c=Ic(t,n,i);c&&(y.getState().setHost(c),window.parent.postMessage(rs({openArtifacts:"home_ready"}),n))})}function Gc(){return window.addEventListener("message",Ls),Ba&&window.parent.postMessage(rs({openArtifacts:"home_hello"}),"*"),()=>window.removeEventListener("message",Ls)}const Se=e=>typeof e=="string",Yc=["unreachable","timeout","signed_out","unsupported","refused","error"],Xc=["project","user","extra","installed","builtin"];function Zc(e,t,n){if(!Se(e))return null;const a=ec(e);if(!a||a.id!==n)return null;try{return new URL(t).origin===a.origin?e:null}catch{return null}}function Jc(e){if(!e||typeof e!="object")return null;const t=e;return Se(t.id)?{id:t.id,version:Se(t.version)?t.version:null,scope:Xc.includes(t.scope)?t.scope:"user",...Se(t.sha256)?{sha256:t.sha256}:{},...Se(t.installedFrom)?{installedFrom:t.installedFrom}:{}}:null}function Qc(e){if(!e||typeof e!="object")return null;const t=e;if(!Se(t.remote)||!Se(t.host))return null;const n=[];for(const i of Array.isArray(t.types)?t.types:[]){const c=ds(i);if(!c||c.unpublished)continue;const d=i,l=Zc(d.page,t.host,c.id);if(!l)continue;const p=Oo.includes(d.standing)?d.standing:"new";n.push({...c,page:l,standing:p,local:Jc(d.local)})}const a=Se(t.error)&&t.error?t.error:null,o=a?Yc.includes(t.code)?t.code:"error":null;return{remote:t.remote,host:t.host,types:a?[]:n,error:a,code:o}}function ed(e){const t=e&&typeof e=="object"?e:{};return{sites:(Array.isArray(t.sites)?t.sites:[]).map(Qc).filter(a=>!!a),notice:Se(t.notice)?t.notice:""}}function td(e){switch(e.standing){case"installed":case"published-here":return{action:"none",label:e.standing};case"update":return e.local?.installedFrom===e.page?{action:"update",open:{update:e.local.id}}:{action:"update",open:{url:e.page,...e.local?{as:e.local.id}:{},auto:!0}};case"clash":return{action:"install-as",open:{url:e.page,auto:!1}};default:return{action:"install",open:{url:e.page,auto:!0}}}}function sd(e){return e.map(t=>({id:t.id,title:t.title,typeTitle:t.typeTitle,when:typeof t.trashedAt=="string"&&t.trashedAt?{kind:"trashed",at:t.trashedAt}:{kind:"changed",at:t.updatedAt},mine:t.role===void 0||t.role==="owner"})).sort((t,n)=>(Date.parse(n.when.at)||0)-(Date.parse(t.when.at)||0))}function nd(e){return e===void 0||!Number.isInteger(e)||e<0?null:e===0?{key:"trashKeptForever"}:e===1?{key:"trashKeptOneDay"}:{key:"trashKeptDays",vars:{days:e}}}function ad(e,t){return e.mine&&!t}function rd(e,t){return e===501?{unsupported:!0}:e===409?{unsupported:!1,said:{key:"purgeNotTrashed"}}:e===404?{unsupported:!1,said:{key:"purgeGone"}}:{unsupported:!1,said:{key:"couldNotPurge",vars:{error:t||`HTTP ${e}`}}}}const le=e=>{Ae.add({title:e})},it=e=>`/a/${encodeURIComponent(e)}`;function Lt(e){y.getState().host?.caps.artifacts?Ka({openArtifacts:"open_artifact",url:e.url,id:e.id,title:e.title,type:e.type}):location.href=it(e.id)}const od=Fa();async function lt(){await od.run(()=>H.artifacts(),e=>{y.getState().setArtifacts(e),y.getState().setError(null)},e=>y.getState().setError(r("couldNotLoad",{error:U(e)})))}function id(e){window.open(e,"_blank","noopener")}async function ld(e){await Rn(e),le(r("webLinkCopied"))}async function Le(){try{y.getState().setTypes(await H.types())}catch(e){y.getState().setError(r("couldNotLoad",{error:U(e)}))}}let _t=0;async function et(e){const t=++_t;y.getState().setSitesLoading(e??"*");try{const n=ed(await H.typesSites(e));if(t!==_t)return;const a=y.getState().sites;if(e&&a){const o=n.sites.find(i=>i.remote===e);y.getState().setSites({...a,sites:a.sites.map(i=>i.remote===e&&o?o:i)})}else y.getState().setSites(n)}catch(n){if(t!==_t)return;const a=y.getState().sites,o=i=>!e||i.remote===e?{...i,types:[],error:U(n),code:"error"}:i;a&&a.sites.length?y.getState().setSites({...a,sites:a.sites.map(o)}):y.getState().setSites({sites:[],notice:""},null,U(n))}}async function cd(e){if(!e.id.trim())return{error:r("needTypeId")};try{const t=await H.typesNew({...e,id:e.id.trim()});return await Le(),{made:t}}catch(t){return{error:r("couldNotMakeType",{error:U(t)})}}}async function dd(e,t){try{await H.typesEnable(e.id,t),await Le()}catch(n){le(r("couldNotToggleType",{error:U(n)}))}}async function ud(e){const t=new Uint8Array(await e.arrayBuffer());let n="";for(let a=0;a<t.length;a+=32768)n+=String.fromCharCode(...t.subarray(a,a+32768));return btoa(n)}async function Ft(e,t){try{const n=t?.trim()?{as:t.trim()}:{};return"update"in e?{preview:await H.typesUpdate(e.update)}:"url"in e?e.url.trim()?{preview:await H.typesPreview({url:e.url.trim(),...n})}:{error:r("needPackage")}:{preview:await H.typesPreview({name:e.file.name,data:await ud(e.file),...n})}}catch(n){return{error:r("couldNotReadPackage",{error:U(n)})}}}async function pd(e,t={}){try{return t.update?await H.typesUpdate(t.update,e.sha256):await H.typesInstall(e.sha256,t.as?.trim()||void 0),await Le(),y.getState().sites&&et(),le(r(t.update?"typeUpdated":"typeInstalled",{type:e.name,version:e.version})),{ok:!0}}catch(n){return{error:r("couldNotInstall",{error:U(n)})}}}async function fd(e){try{await H.typesUninstall(e.id),await Le(),le(r("typeUninstalled",{type:e.title}))}catch(t){le(r("couldNotUninstall",{error:U(t)}))}}async function md(e,t){try{await H.typesTrust(e,t),await Le()}catch(n){le(r("couldNotTrust",{error:U(n)}))}}const Va=e=>{const t=y.getState().artifacts;t&&y.getState().setArtifacts(Oc(t,e))};async function hd(e){const t=!e.pinned;try{Va(await H.update({id:e.id,pinned:t}))}catch(n){le(r(t?"couldNotPin":"couldNotUnpin",{error:U(n)}))}}async function xd(e,t){const n=t.trim();if(!(!n||n===e.title))try{Va(await H.update({id:e.id,title:n}))}catch(a){le(r("couldNotRename",{error:U(a)}))}}async function gd(e){try{await H.duplicate(e.id),le(r("duplicated")),await lt()}catch(t){le(r("couldNotDuplicate",{error:U(t)}))}}let Ht=null;const hs=Fa();async function _s(e){const t=y.getState(),n=t.artifacts;n&&t.setArtifacts(Mc(n,e.id));try{const a=await H.remove(e.id);t.setUndo({id:e.id,title:e.title,...re.cloud?{trash:!0}:{},...a.webShare?{webShared:!0}:{}}),hs.asked&&qe(),Ht&&clearTimeout(Ht),Ht=setTimeout(()=>{y.getState().undo?.id===e.id&&y.getState().setUndo(null)},8e3)}catch(a){n&&t.setArtifacts(n),le(r("couldNotDelete",{error:U(a)}))}}async function bd(){const e=y.getState().undo;if(e){y.getState().setUndo(null);try{await H.restore(e.id),le(r("restored")),await lt(),hs.asked&&qe()}catch(t){le(r("couldNotRestore",{error:U(t)}))}}}async function qe(){await hs.run(()=>H.trashed(),e=>y.getState().setTrash(e),e=>y.getState().setError(r("couldNotLoad",{error:U(e)})))}async function yd(e){const t=y.getState(),n=t.trash;n&&t.setTrash(n.filter(a=>a.id!==e.id));try{await H.restore(e.id),le(r("restoredTitle",{title:e.title})),await Promise.all([lt(),qe()])}catch(a){n&&y.getState().setTrash(n),le(r("couldNotRestore",{error:U(a)}))}}async function vd(e){try{await H.purge(e.id);const t=y.getState().trash;t&&y.getState().setTrash(t.filter(n=>n.id!==e.id)),le(r("purged",{title:e.title}))}catch(t){const n=t instanceof at?t.status:0,a=rd(n,U(t));a.unsupported?y.getState().setPurgeUnsupported():le(r(a.said.key,a.said.vars)),qe()}}const jd="/api/open-artifacts.artifacts.import";function qa(e){const t=y.getState();if(Ha(t.upload))return;const n=_c(e);if(!n)return;if("said"in n){const c=e[0]?.name??"";t.uploadEvent({type:"start",name:c,size:0}),t.uploadEvent({type:"failed",said:n.said});return}const a=n.file;t.uploadEvent({type:"start",name:a.name,size:a.size});const o=Fc(a.size,re.cloud?.limits?.importBytes);if(o){t.uploadEvent({type:"failed",said:o});return}const i=new XMLHttpRequest;i.open("POST",jd),i.setRequestHeader("Content-Type",Jl),i.upload.onprogress=c=>y.getState().uploadEvent({type:"progress",loaded:c.loaded,total:c.lengthComputable?c.total:0}),i.upload.onload=()=>y.getState().uploadEvent({type:"sent"}),i.onload=()=>{const c=i.status===201||i.status===200?Bc(i.responseText):null;if(c){y.getState().uploadEvent({type:"done",id:c}),location.href=it(c);return}y.getState().uploadEvent({type:"failed",said:zs($c(i.status,i.responseText))})},i.onerror=()=>y.getState().uploadEvent({type:"failed",said:zs({status:0,code:"connect_failed",message:""})}),i.send(a)}async function kd(e,t,n,a=!1){if(!t.trim())return r("needTitle");try{const o=await H.create({type:e.id,title:t.trim(),...n.trim()?{folder:n.trim()}:{},...a?{blank:!0}:{}});return location.href=it(o.id),null}catch(o){return r("couldNotCreate",{error:U(o)})}}function Nd(e){e.owner&&Ka({openArtifacts:"open_session",session:e.owner.session,harness:e.owner.harness})}function wd(){let e=null,t=!1;const n=Mo(a=>{a.type==="types/changed"&&(t=!0),e&&clearTimeout(e),e=setTimeout(()=>{lt(),t&&!re.cloud&&(Le(),y.getState().tab==="types"&&y.getState().sites&&et()),re.cloud&&y.getState().cloudTab==="trash"&&qe(),t=!1},200)});return()=>{e&&clearTimeout(e),n()}}const Sd={none:"statusNone",working:"statusWorking",idle:"statusIdle",waiting:"statusWaiting",offline:"statusOffline"};function Td({state:e,className:t}){return s.jsx("span",{"aria-hidden":"true",className:ie("inline-block size-2 shrink-0 rounded-full",e==="working"?"animate-pulse bg-accent motion-reduce:animate-none":e==="idle"||e==="waiting"?"bg-success":"bg-fg-subtle",t)})}function Cd({state:e,prefix:t,label:n,className:a}){const o=n??r(Sd[e]);return s.jsxs("span",{className:ie("inline-flex min-w-0 items-center gap-1.5 text-xs text-fg-muted",a),children:[s.jsx(Td,{state:e}),s.jsx("span",{className:"truncate",children:t?`${t} · ${o}`:o})]})}function ae({children:e}){return s.jsx("span",{className:"inline-flex max-w-full items-center gap-1 truncate rounded-full bg-surface-2 px-2 py-px text-xs text-fg-muted",children:e})}function Ed({artifact:e}){const t=y(f=>f.host),n=re.cloud?void 0:e.remote?.url,a=it(e.id),o=!re.cloud,i=!o&&e.role==="owner",c=o||e.role===void 0||e.role==="owner"||e.role==="editor",d=o&&!!(t?.caps.sessions&&e.owner?.session&&(!t.harness||e.owner.harness===t.harness)),l=Ac(e),[p,m]=u.useState(null),h=f=>{f.target.closest('a, button, [role="menu"]')||getSelection()?.toString()||Lt(e)};return s.jsxs("div",{onClick:h,className:"group flex min-w-0 cursor-pointer flex-col overflow-hidden rounded-xl border border-line bg-surface transition-[border-color,box-shadow] hover:border-line-strong hover:shadow-popup",children:[l&&p!==l?s.jsx("img",{src:l,alt:"",loading:"lazy",onError:()=>m(l),className:"aspect-[16/9] w-full border-b border-line bg-surface-2 object-cover object-top"}):null,s.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5 p-3.5",children:[s.jsxs("a",{href:a,className:"flex min-w-0 items-center gap-1.5 break-words font-semibold text-fg no-underline hover:text-accent",onClick:f=>{!t?.caps.artifacts||f.metaKey||f.ctrlKey||f.shiftKey||(f.preventDefault(),Lt(e))},children:[e.pinned?s.jsx(ws,{className:"size-3.5 shrink-0 text-fg-muted","aria-label":r("pinned")}):null,s.jsx("span",{className:"min-w-0",children:e.title}),n?s.jsx("span",{title:r("pubCloudAt",{url:n}),"data-home-published":"",className:"inline-flex shrink-0 text-accent",children:s.jsx(oi,{className:"size-3.5","aria-label":r("pubCloudMark")})}):null,e.webShare?.url?s.jsx("span",{title:`${r("wsSharedMark")}: ${e.webShare.url}`,"data-home-webshare":"",className:"inline-flex shrink-0 text-accent",children:s.jsx(di,{className:"size-3.5","aria-label":r("wsSharedMark")})}):null]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx(ae,{children:e.typeTitle}),o?s.jsx(ae,{children:s.jsx(Cd,{state:Rc(e.owner),prefix:e.owner?e.owner.harnessTitle??e.owner.harness:void 0})}):null,o&&e.open?s.jsx(ae,{children:r("pageOpen")}):null,o&&e.project?s.jsx("span",{title:r("projectOf",{folder:e.project}),"data-home-project":e.project,className:"inline-flex min-w-0 max-w-full",children:s.jsxs(ae,{children:[s.jsx(ci,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:Lo(e.project)})]})}):null]}),e.typeMissing?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-warning",children:[s.jsx(Ie,{className:"size-3.5"}),r("typeMissing")]}):null,o?s.jsx("div",{className:"break-all text-xs text-fg-muted",title:e.root,children:e.root}):null,s.jsx("div",{className:"text-xs text-fg-muted",children:r("updated",{when:Be(e.contentAt||e.updatedAt)})}),s.jsxs("div",{className:"mt-auto flex items-center gap-1.5 pt-1",children:[s.jsx(C,{size:"sm",variant:"primary",onClick:()=>Lt(e),children:r("open")}),d?s.jsx(C,{size:"sm",icon:s.jsx(xi,{className:"size-3"}),onClick:()=>Nd(e),children:r("backToSession")}):null,s.jsx("span",{className:"flex-1"}),s.jsxs(is,{align:"end",trigger:s.jsx(os,{label:r("moreActions"),icon:s.jsx(ii,{className:"size-4"}),size:"sm",noTooltip:!0}),children:[s.jsx(Ne,{icon:e.pinned?s.jsx(bi,{className:"size-3.5"}):s.jsx(ws,{className:"size-3.5"}),onSelect:()=>{hd(e)},children:e.pinned?r("unpin"):r("pin")}),n?s.jsxs(s.Fragment,{children:[s.jsx(Ne,{icon:s.jsx(vt,{className:"size-3.5"}),onSelect:()=>id(n),children:r("openOnWeb")}),s.jsx(Ne,{icon:s.jsx(pi,{className:"size-3.5"}),onSelect:()=>{ld(n)},children:r("copyWebLink")})]}):null,c?s.jsx(Ne,{icon:s.jsx(gi,{className:"size-3.5"}),onSelect:()=>y.getState().setRenaming(e),children:r("rename")}):null,o?s.jsxs(s.Fragment,{children:[s.jsx(Ne,{icon:s.jsx(On,{className:"size-3.5"}),onSelect:()=>{gd(e)},children:r("duplicate")}),s.jsx($e,{}),s.jsx(Ne,{icon:s.jsx(mt,{className:"size-3.5"}),danger:!0,onSelect:()=>{_s(e)},children:r("delete")})]}):null,i?s.jsxs(s.Fragment,{children:[s.jsx($e,{}),s.jsx(Ne,{icon:s.jsx(mt,{className:"size-3.5"}),danger:!0,onSelect:()=>{_s(e)},children:r("moveToTrash")})]}):null]})]})]})]})}function Pd({choices:e,shown:t,total:n}){const a=(o,i,c,d)=>{const l=t===o;return s.jsxs("button",{type:"button",role:"radio","aria-checked":l,title:d,"data-home-project-filter":o??"*",onClick:()=>y.getState().setProject(o),className:`inline-flex max-w-[220px] cursor-pointer items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs transition-colors ${l?"border-transparent bg-hover font-medium text-fg":"border-line bg-transparent text-fg-muted hover:border-line-strong hover:text-fg"}`,children:[s.jsx("span",{className:"truncate",children:i}),s.jsx("span",{className:"tabular-nums opacity-70",children:c})]},o??"*")};return s.jsxs("div",{role:"radiogroup","aria-label":r("projectFilter"),"data-testid":"project-filter",className:"mb-3 flex flex-wrap items-center gap-1.5",children:[a(null,r("projectAll"),n),e.map(o=>a(o.project,o.project===Pn?r("projectNone"):o.label,o.count,o.project||void 0))]})}const Fs={any:"dateAny",today:"dateToday",yesterday:"dateYesterday",week:"dateWeek",month:"dateMonth"},Hs={any:"sharingAny",shared:"sharingShared",private:"sharingPrivate"};function Ut({label:e,value:t,children:n}){return s.jsx(zo,{label:s.jsxs("span",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"flex-1",children:e}),s.jsx("span",{className:"text-fg-subtle",children:t})]}),children:n})}function Rd({artifacts:e,filters:t,shown:n}){const a=l=>y.getState().setListFilters({...t,...l}),o=Sc(e,Xe),i=_a(t),c=l=>o.find(p=>p.id===l)?.title??l,d=t.types.length===0?r("filterAny"):t.types.length===1?c(t.types[0]):r("filterSome",{count:String(t.types.length)});return s.jsxs("div",{"data-home-tools":"",className:"mb-3 flex flex-wrap items-center gap-2",children:[s.jsxs("label",{className:"relative flex w-full max-w-xs items-center",children:[s.jsx(ra,{"aria-hidden":"true",className:"pointer-events-none absolute left-2 size-3.5 text-fg-subtle"}),s.jsx(he,{type:"search","data-home-search":"","aria-label":r("searchArtifacts"),placeholder:r("searchArtifacts"),value:t.query,onChange:l=>a({query:l.currentTarget.value}),onKeyDown:l=>{l.key!=="Escape"||!t.query||(l.preventDefault(),a({query:""}))},className:"h-8 pl-7 pr-7 [&::-webkit-search-cancel-button]:hidden"}),t.query?s.jsx("span",{className:"absolute right-1",children:s.jsx(os,{label:r("clearSearch"),size:"sm",noTooltip:!0,icon:s.jsx(kt,{className:"size-3.5"}),onClick:()=>a({query:""})})}):null]}),s.jsxs(is,{align:"start",trigger:s.jsxs(C,{size:"lg","data-home-filter-button":"","data-home-filter":i||void 0,icon:s.jsx(fi,{className:"size-3.5"}),className:i?"border-accent text-accent":void 0,children:[r("filter"),i?s.jsxs("span",{className:"tabular-nums",children:["· ",i]}):null]}),children:[s.jsx(Ut,{label:r("filterType"),value:d,children:o.map(l=>{const p=t.types.includes(l.id);return s.jsx(ut,{checked:p,onCheckedChange:()=>a({types:p?t.types.filter(m=>m!==l.id):[...t.types,l.id]}),children:s.jsxs("span",{className:"flex items-center gap-4",children:[s.jsx("span",{className:"flex-1",children:l.title}),s.jsx("span",{className:"tabular-nums text-fg-subtle",children:l.count})]})},l.id)})}),s.jsx(Ut,{label:r("filterEdited"),value:r(Fs[t.date]),children:Ao.map(l=>s.jsx(ut,{checked:t.date===l,onCheckedChange:()=>a({date:l}),children:r(Fs[l])},l))}),s.jsx(Ut,{label:r("filterSharing"),value:r(Hs[t.sharing]),children:Do.map(l=>s.jsx(ut,{checked:t.sharing===l,onCheckedChange:()=>a({sharing:l}),children:r(Hs[l])},l))}),s.jsx($e,{}),s.jsx(ut,{checked:t.pinned,onCheckedChange:l=>a({pinned:l}),children:r("filterPinned")}),i?s.jsxs(s.Fragment,{children:[s.jsx($e,{}),s.jsx(Ne,{onSelect:()=>a({types:[],date:"any",sharing:"any",pinned:!1}),children:r("clearFilters")})]}):null]}),Nc(t)?s.jsx("span",{"data-home-match-count":n,className:"text-xs tabular-nums text-fg-muted",children:r("matchCount",{shown:String(n),total:String(e.length)})}):null]})}function Yt(){const e=y(d=>d.artifacts),t=y(d=>d.host?.library??null),n=y(d=>d.project),a=y(d=>d.listFilters),o=e&&t?vc(e,t):e;if(o===null)return s.jsx("p",{className:"py-8 text-fg-muted",children:r("loading")});if(!o.length)return s.jsx(Ve,{title:r("artifacts"),children:r(re.cloud?"noArtifactsCloud":"noArtifacts")});if(re.cloud){const d=wc(o,a,Date.now());return s.jsxs(s.Fragment,{children:[s.jsx(Rd,{artifacts:o,filters:a,shown:d.length}),d.length?s.jsx(Us,{artifacts:d}):s.jsx("div",{"data-home-no-matches":"",children:s.jsxs(Ve,{title:r("noMatches"),children:[r("noMatchesHint"),s.jsx(C,{className:"mx-auto mt-3 flex",onClick:()=>y.getState().setListFilters(La),children:r("clearSearchAndFilters")})]})})]})}const i=Io(o,Xe),c=jc(i,n);return s.jsxs(s.Fragment,{children:[i.length>1?s.jsx(Pd,{choices:i,shown:c,total:o.length}):null,s.jsx(Us,{artifacts:kc(o,c)})]})}function Us({artifacts:e}){return s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3",children:Tc(e).map(t=>s.jsx(Ed,{artifact:t},t.id))})}const Xt=sc(),xs={private:"siteTypePrivate",link:"siteTypeLink",site:"siteTypeSite"},Zt=e=>e instanceof Error?e.message:String(e);function We({label:e,children:t,testId:n}){return s.jsxs("div",{className:"grid grid-cols-[8rem_1fr] gap-2 text-xs",children:[s.jsx("span",{className:"text-fg-muted",children:e}),s.jsx("span",{"data-testid":n,className:"min-w-0 break-words",children:t})]})}const Wa=e=>e.publisher.name??r("siteTypeUnnamedPublisher");function Od({type:e}){return s.jsxs("a",{href:nc(e.id),"data-site-type":e.id,className:"flex flex-col gap-1 rounded-lg border border-border bg-surface px-3 py-2.5 text-fg no-underline hover:bg-hover",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx(ae,{children:e.version}),s.jsx(ae,{children:r(xs[e.visibility])}),e.unpublished?s.jsx(ae,{children:r("siteTypeDelisted")}):null]}),e.description?s.jsx("span",{className:"text-xs text-fg-muted",children:e.description}):null,s.jsx("span",{className:"text-xs text-fg-subtle",children:r("siteTypeBy",{name:Wa(e),when:e.updatedAt?Be(e.updatedAt):""})})]})}function Md(){const[e,t]=u.useState(null),[n,a]=u.useState(null);return u.useEffect(()=>{Xt.list().then(t,o=>a(Zt(o)))},[]),n?s.jsx("p",{role:"alert",className:"py-4 text-xs text-danger",children:n}):e?s.jsxs("div",{"data-home-site-types":"",className:"flex flex-col gap-3",children:[s.jsxs("p",{className:"m-0 text-xs text-fg-muted",children:[r("siteTypesNote")," ",e.publish.allowed?r("siteTypesYouMayPublish"):e.publish.refusal?r("siteTypesNoPublish",{why:e.publish.refusal}):null]}),e.types.length?s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.types.map(o=>s.jsx(Od,{type:o},o.uid))}):s.jsx(Ve,{title:r("siteTypesEmptyTitle"),children:r("siteTypesEmpty")})]}):s.jsx("p",{className:"py-8 text-fg-muted",children:r("loading")})}function Id({type:e,onChange:t}){const[n,a]=u.useState(!1),[o,i]=u.useState(!1),c=async l=>{a(!0);try{t(await Xt.setVisibility(e.id,l))}catch(p){Ae.add({title:r("siteTypeCouldNot",{error:Zt(p)})})}finally{a(!1)}},d=async()=>{i(!1),a(!0);try{const l=await Xt.unpublish(e.id);Ae.add({title:l.removed?r("siteTypeRemoved",{name:e.name}):r("siteTypeDelistedNow",{name:e.name,count:l.artifacts})}),t(l.removed?null:{...e,unpublished:!0})}catch(l){Ae.add({title:r("siteTypeCouldNot",{error:Zt(l)})})}finally{a(!1)}};return s.jsxs("section",{"data-site-type-manage":"",className:"flex flex-col gap-2 rounded-lg border border-border p-3",children:[s.jsx("h2",{className:"m-0 text-sm font-medium",children:r("siteTypeManage")}),e.unpublished?s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("siteTypeDelistedManage",{id:e.id})}):s.jsxs(s.Fragment,{children:[s.jsx(ft,{"aria-label":r("siteTypeWhoSees"),value:e.visibility,options:["private","link","site"].map(l=>({value:l,label:r(xs[l])})),onChange:l=>!n&&l!==e.visibility&&void c(l)}),s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("siteTypeVisibilityNote")}),s.jsx("div",{children:s.jsx(C,{size:"sm",variant:"ghost",className:"text-danger",disabled:n,onClick:()=>i(!0),children:r("siteTypeUnpublish")})})]}),s.jsx(ze,{open:o,onOpenChange:l=>!l&&i(!1),title:r("siteTypeUnpublishTitle",{name:e.name}),description:r("siteTypeUnpublishBody"),footer:s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"lg",onClick:()=>i(!1),children:r("cancel")}),s.jsx(C,{size:"lg",variant:"danger",onClick:()=>{d()},children:r("siteTypeUnpublish")})]})})]})}function Ad({detail:e}){const[t,n]=u.useState(e);return u.useEffect(()=>{document.title=e.name},[e.name]),t?s.jsxs("div",{"data-type-page":t.id,className:"flex flex-col gap-4",children:[s.jsx($s,{}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("h2",{className:"m-0 flex flex-wrap items-center gap-2 text-lg font-semibold",children:[s.jsx("span",{"data-testid":"type-page-name",children:t.name}),s.jsx(ae,{children:t.version}),s.jsx(ae,{children:r(xs[t.visibility])})]}),t.description?s.jsx("p",{className:"m-0 text-fg-muted","data-testid":"type-page-description",children:t.description}):null]}),t.unpublished?s.jsx("p",{role:"status","data-testid":"type-page-delisted",className:"m-0 rounded-md bg-hover px-3 py-2 text-xs",children:r("siteTypeDelistedNote")}):null,s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(We,{label:r("siteTypePublisher"),testId:"type-page-publisher",children:Wa(t)}),s.jsx(We,{label:r("siteTypeUpdated"),children:t.updatedAt?Be(t.updatedAt):"—"}),s.jsx(We,{label:r("packageCapabilities"),testId:"type-page-capabilities",children:t.capabilities.length?t.capabilities.join(", "):r("noCapabilities")}),s.jsx(We,{label:r("packageNetwork"),testId:"type-page-network",children:t.network.length?t.network.join(", "):r("noNetwork")}),s.jsx(We,{label:"sha256",children:s.jsx("span",{className:"font-mono break-all",children:t.sha256})})]}),s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("packageThirdParty")}),t.unpublished?null:s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h2",{className:"m-0 text-sm font-medium",children:r("siteTypeInstall")}),s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("siteTypeInstallNote")}),s.jsx("pre",{"data-testid":"type-page-install",className:"m-0 overflow-x-auto rounded-md bg-hover px-3 py-2 text-xs",children:t.install}),s.jsx("div",{children:s.jsxs("a",{href:t.packageUrl,download:!0,className:"inline-flex items-center gap-1.5 text-xs",children:[s.jsx(Ke,{className:"size-3.5"}),r("siteTypeDownload")]})})]}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h2",{className:"m-0 text-sm font-medium",children:"SKILL.md"}),s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("siteTypeSkillNote")}),t.skill?s.jsx("pre",{"data-testid":"type-page-skill",className:"m-0 max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-md border border-border px-3 py-2 text-xs",children:t.skill}):s.jsx("p",{className:"m-0 text-xs text-fg-subtle",children:r("siteTypeNoSkill")})]}),t.manages?s.jsx(Id,{type:t,onChange:n}):null]}):s.jsxs("div",{"data-type-page":"",className:"flex flex-col gap-3",children:[s.jsx(Ve,{title:r("siteTypeGoneTitle"),children:r("siteTypeGone")}),s.jsx($s,{})]})}function $s(){return s.jsxs("a",{href:"/#types",className:"inline-flex items-center gap-1 text-xs",children:[s.jsx(ai,{className:"size-3.5"}),r("siteTypesBack")]})}const Dd=/^[^\s\x00-\x1f\x7f-][^\x00-\x1f\x7f]{0,127}$/;function zd(e){return Dd.test(e.trim())}function Ld(e,t=[]){const n=new Set,a=[];for(const o of[...t.map(i=>({id:i})),...e])!o.id||n.has(o.id)||(n.add(o.id),a.push(o));return a}function _d(e,t,n){const a=e.id.toLowerCase(),o=(e.label??"").toLowerCase();return t.every(i=>a.includes(i)||o.includes(i))?a===n||o===n?4:a.startsWith(n)||o.startsWith(n)?3:a.includes(n)||o.includes(n)?2:1:0}function Fd(e,t){const n=t.trim().toLowerCase();if(!n)return[...e];const a=n.split(/\s+/);return e.map((o,i)=>({entry:o,index:i,score:_d(o,a,n)})).filter(o=>o.score>0).sort((o,i)=>i.score-o.score||o.index-i.index).map(o=>o.entry)}function Hd(e,t,n){const a=t.trim(),o=[];n.allowDefault&&!a&&o.push({kind:"default",key:"default"});for(const i of Fd(e,a))o.push({kind:"model",key:`m:${i.id}`,id:i.id,...i.label?{label:i.label}:{}});return a&&zd(a)&&!e.some(i=>i.id===a)&&o.push({kind:"typed",key:`typed:${a}`,id:a}),o}const gs=Object.freeze({low:"effortLow",medium:"effortMedium",high:"effortHigh",xhigh:"effortXhigh",max:"effortMax"});function Bs(e){return{default:e.models?.default??"",quick:e.models?.quick??"",complex:e.models?.complex??"",effort:e.effort??""}}function Ks(e){const t={};for(const n of["default","quick","complex"])e[n].trim()&&(t[n]=e[n].trim());return{...Object.keys(t).length?{models:t}:{},...e.effort?{effort:e.effort}:{}}}function Ud(e,t){return(e.choice.models??{})[t]||e.defaults[t]||""}function $d(e,t){const n=[];if(e.model){const a=Ud(e,"default");n.push(t("harnessModelLine",{model:a||t("harnessAppDefault")}))}return e.efforts.length&&n.push(t("harnessEffortLine",{effort:e.choice.effort?t(gs[e.choice.effort]):t("harnessAppDefault")})),n.join(" · ")}const ke=30,Vs=300,qs=6;function Ga({value:e,onChange:t,models:n,defaultLabel:a,loading:o,error:i,onRefresh:c,onOpen:d,name:l,className:p,...m}){const[h,f]=u.useState(!1),g=m["aria-label"],x=e?n.find(j=>j.id===e):void 0,b=e?x?.label?`${x.label}`:e:a??"";return s.jsxs(Bi,{open:h,onOpenChange:j=>{f(j),j&&d?.()},children:[s.jsx(Wi,{"data-model-picker":l,"data-value":e,onKeyDown:_o,render:s.jsxs("button",{type:"button","aria-label":`${g}: ${b}`,className:ie("flex h-8 w-full min-w-0 items-center gap-1 rounded-control border border-line bg-surface-2 pl-2 pr-1.5 text-left text-[13px] text-fg outline-none","focus-visible:border-accent data-[popup-open]:border-accent",p),children:[s.jsx("span",{className:ie("min-w-0 flex-1 truncate",!e&&"text-fg-muted"),children:b}),x?.label?s.jsx("span",{className:"shrink-0 truncate text-[11px] text-fg-subtle",children:e}):null,s.jsx(Fo,{className:"size-3.5 shrink-0 text-fg-subtle"})]})}),s.jsx(Yi,{children:s.jsx(Zi,{side:"bottom",align:"start",sideOffset:6,collisionPadding:8,className:"z-[1000]",children:s.jsx(el,{"aria-label":g,className:ie(Ho,"w-[min(22rem,calc(100vw-2rem))] p-0"),children:h?s.jsx(Bd,{value:e,models:n,defaultLabel:a,loading:o,error:i,onRefresh:c,onPick:j=>{t(j),f(!1)}}):null})})})]})}function Bd({value:e,models:t,defaultLabel:n,loading:a,error:o,onRefresh:i,onPick:c}){const d=u.useId(),[l,p]=u.useState(""),m=u.useRef(null),h=u.useRef(null),[f,g]=u.useState(0),x=u.useMemo(()=>Hd(t,l,{allowDefault:n!==void 0}),[t,l,n]),b=S=>S.kind==="default"?"":S.id,j=x.findIndex(S=>b(S)===e&&(S.kind!=="default"||n!==void 0)),[v,T]=u.useState(0),N=Math.min(Vs,Math.max(1,x.length)*ke+8);u.useEffect(()=>h.current?.focus(),[]);const E=(S,W="nearest")=>{const M=m.current;if(!M||S<0)return;const F=S*ke,K=M.clientHeight||N;W==="center"?M.scrollTop=Math.max(0,F-K/2+ke/2):F<M.scrollTop?M.scrollTop=F:F+ke>M.scrollTop+K&&(M.scrollTop=F+ke-K),g(M.scrollTop)},k=u.useRef(!1);u.useEffect(()=>{if(!k.current){k.current=!0;const S=j>=0?j:0;T(S),requestAnimationFrame(()=>E(S,"center"));return}T(0)},[x]);const D=S=>{if(!x.length)return;const W=Math.min(x.length-1,Math.max(0,v+S));T(W),E(W)},L=S=>{if($o(S.nativeEvent))return;const M={ArrowDown:1,ArrowUp:-1,PageDown:8,PageUp:-8}[S.key];if(M!==void 0){S.preventDefault(),D(M);return}if(S.key==="Enter"){S.preventDefault();const F=x[v];F&&c(b(F))}},R=Math.max(0,Math.floor(f/ke)-qs),_=Math.min(x.length,Math.ceil((f+Vs)/ke)+qs),A=`${d}-list`,X=S=>`${d}-opt-${S}`,q=t.length;return s.jsxs("div",{className:"flex flex-col","data-model-picker-list":"",children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-2.5",children:[s.jsx(ra,{className:"size-3.5 shrink-0 text-fg-subtle","aria-hidden":"true"}),s.jsx("input",{ref:h,role:"combobox","aria-expanded":"true","aria-controls":A,"aria-autocomplete":"list","aria-activedescendant":x[v]?X(v):void 0,"aria-label":r("pickerSearch"),placeholder:r("pickerSearch"),spellCheck:!1,autoComplete:"off",value:l,onChange:S=>{p(S.target.value),m.current&&(m.current.scrollTop=0),g(0)},onKeyDown:L,className:"h-9 min-w-0 flex-1 bg-transparent text-[13px] text-fg outline-none placeholder:text-fg-subtle"})]}),s.jsxs("div",{className:"flex min-h-7 items-center gap-2 border-b border-line px-2.5 py-1 text-[11px] text-fg-muted",children:[s.jsx("span",{className:"min-w-0 flex-1",role:"status",children:a?s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(Je,{className:"size-3 animate-spin motion-reduce:animate-none"}),r("pickerLoading")]}):o?s.jsx("span",{className:"text-warning",children:r("pickerListFailed",{error:o})}):q?r("pickerCount",{count:q}):null}),i?s.jsx("button",{type:"button","aria-label":r("pickerRefresh"),title:r("pickerRefresh"),disabled:a,"data-model-picker-refresh":"",onClick:()=>{i(),h.current?.focus()},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-fg-subtle outline-none hover:bg-hover hover:text-fg focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-45",children:s.jsx(yt,{className:"size-3"})}):null]}),s.jsxs("div",{ref:m,id:A,role:"listbox","aria-label":r("pickerSearch"),tabIndex:-1,className:"relative overflow-y-auto p-1",style:{height:N},onScroll:S=>g(S.currentTarget.scrollTop),children:[s.jsx("div",{style:{height:x.length*ke,position:"relative"},children:x.slice(R,_).map((S,W)=>{const M=R+W,F=M===j;return s.jsxs("div",{id:X(M),role:"option","aria-selected":M===v,"aria-checked":F,"data-model-option":b(S),style:{position:"absolute",top:M*ke,left:0,right:0,height:ke},onPointerMove:()=>M!==v&&T(M),onClick:()=>c(b(S)),className:ie("flex cursor-default select-none items-center gap-2 rounded-md px-2 text-[13px]",M===v&&"bg-hover"),children:[s.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:F?s.jsx(Uo,{className:"size-3.5 text-accent"}):null}),S.kind==="default"?s.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-muted",children:n}):S.kind==="typed"?s.jsx("span",{className:"min-w-0 flex-1 truncate",children:r("pickerUseTyped",{model:S.id})}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:S.label??S.id}),S.label?s.jsx("span",{className:"max-w-[45%] shrink-0 truncate text-[11px] text-fg-subtle",children:S.id}):null]})]},S.key)})}),x.length?null:s.jsx("div",{className:"px-3 py-1.5 text-center text-xs text-fg-subtle",children:r("pickerNoMatch")})]})]})}const Kd=Object.freeze({openai:"sourceKindOpenai",anthropic:"sourceKindAnthropic",gemini:"sourceKindGemini"}),Ya=Bo;function Jt(e){return e==="anthropic"?{default:Et.default,quick:Et.quick??"",complex:Et.complex??""}:{default:"",quick:"",complex:""}}function Vd(e="openai"){return{kind:e,name:"",baseUrl:rt[e],apiKey:"",models:Jt(e)}}const qd=e=>{const t=e.trim().replace(/\/+$/,"");return!t||Ya.some(n=>rt[n]===t)};function Wd(e,t){if(t===e.kind)return e;const n=Jt(e.kind),a=Jt(t),o=i=>e.models[i].trim()===""||e.models[i]===n[i]?a[i]:e.models[i];return{...e,kind:t,baseUrl:qd(e.baseUrl)?rt[t]:e.baseUrl,models:{default:o("default"),quick:o("quick"),complex:o("complex")}}}const Gd=48;function Xa(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,Gd).replace(/-+$/,"")||t}function Za(e,t){const n=Xa(e.name,e.kind);if(!t.includes(n)||n!==e.kind)return n;for(let a=2;;a++)if(!t.includes(`${n}-${a}`))return`${n}-${a}`}const Yd=/^\$\{[A-Za-z_][A-Za-z0-9_]*\}$/;function Xd(e){const t=e.trim();return t?Yd.test(t)?t:`••••${t.length>8?t.slice(-4):""}`:""}function Qt(e){return e.keyEnv?`\${${e.keyEnv.name}}`:e.keyHint?`••••${e.keyHint.slice(-4)}`:e.hasKey?"••••":""}function Zd(e){return{kind:e.kind,name:e.label||e.name,baseUrl:e.baseUrl||rt[e.kind],apiKey:"",models:{default:e.models.default??"",quick:e.models.quick??"",complex:e.models.complex??""},...e.effort?{effort:e.effort}:{}}}function Jd(e,t,n){const a=e.name.trim();return a?a.toLowerCase().startsWith(Ko)?"sourceNameReserved":!n&&t.includes(Za(e,t))?"sourceNameTaken":eu(e.baseUrl)?e.models.default.trim()?null:"sourceModelMissing":"sourceEndpointBad":"sourceNameMissing"}function Qd(e,t){const n=a=>{try{return new URL(a.trim()).origin}catch{return""}};return e.kind===t.kind&&n(e.baseUrl)===n(t.baseUrl||rt[t.kind])}function eu(e){try{const t=new URL(e.trim());return(t.protocol==="https:"||t.protocol==="http:")&&!!t.hostname}catch{return!1}}function xt(e,t){const n={default:e.models.default.trim()},a=e.models.quick.trim(),o=e.models.complex.trim();a&&(n.quick=a),o&&(n.complex=o);const i=e.apiKey.trim();return{kind:e.kind,label:e.name.trim(),baseUrl:e.baseUrl.trim().replace(/\/+$/,""),...i?{apiKey:i}:{},models:n,...e.effort?{effort:e.effort}:{},...t?.allowModels?.length?{allowModels:[...t.allowModels]}:{}}}function tu(e,t,n){return{name:n?n.name:Za(e,t),provider:xt(e,n)}}function su(e,t){return t?{name:t.name,provider:xt(e,t)}:{provider:xt(e)}}function nu(e,t){const n=[...new Set(e.filter(o=>typeof o=="string"&&o.trim()))].sort((o,i)=>o.localeCompare(i)),a=t.trim();return a&&!n.includes(a)?[a,...n]:n}function Ws(e){try{return new URL(e.trim()).hostname}catch{return""}}async function au(e,t,n,a,o={}){const i={...tu(t,n,a),...o.tabOnly?{tabOnly:!0}:{}},c=i.name??Xa(t.name,t.kind);await e.modelsSet(i);try{const d=await e.modelsList();return{key:c,view:d.providers.find(l=>l.name===c)??null}}catch{return{key:c,view:null}}}const Gs="${OPENAI_API_KEY}";function Fe({id:e,label:t,hint:n,select:a,children:o}){return s.jsxs("div",{className:"mt-3 first:mt-0",children:[a?s.jsx("div",{"aria-hidden":"true",className:"mb-1 block text-xs font-medium",children:t}):s.jsx("label",{htmlFor:e,className:"mb-1 block text-xs font-medium",children:t}),o,n?s.jsx("div",{id:`${e}-hint`,className:"mt-1 text-xs text-fg-muted",children:n}):null]})}function ru({result:e}){return e.ok?s.jsxs("div",{role:"status",className:"mt-2 flex items-start gap-1.5 text-xs text-success",children:[s.jsx(ls,{className:"mt-px size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 break-words",children:e.message})]}):s.jsxs("div",{role:"alert",className:"mt-2 flex items-start gap-1.5 text-xs text-danger",children:[s.jsx(Ie,{className:"mt-px size-3.5 shrink-0"}),s.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words",children:e.message})]})}function Ys({taken:e,onSaved:t,onCancel:n,initial:a=null,api:o=ge}){const[i,c]=u.useState(()=>a?Zd(a):Vd()),d=a?Qt(a):"",l=!!d&&!!a&&!Qd(i,a),p=l?"":d,m=a?r("sourceFormEditTitle",{source:a.label||a.name}):r("sourceFormTitle"),[h,f]=u.useState(null),[g,x]=u.useState(null),[b,j]=u.useState(null),[v,T]=u.useState(!1),[N,E]=u.useState(""),k={kind:u.useId(),name:u.useId(),endpoint:u.useId(),key:u.useId(),default:u.useId(),quick:u.useId(),complex:u.useId(),effort:u.useId()},D=Ue(),[L,R]=u.useState(a?a.tabOnly===!0:!1),_=D?D.config.endpoints?.length?r("siteEndpointHintAllowed",{allowed:D.config.endpoints.join(", ")}):r("siteEndpointHint"):r("sourceEndpointHint"),A=Ws(i.baseUrl)||i.baseUrl,X=l?r("sourceKeyReenter",{host:A}):D?p?r("siteKeyKeepHint",{key:p,host:A}):r("siteKeyHint",{host:A}):p?r("sourceKeyKeepHint",{key:p,example:Gs}):r("sourceKeyHint",{example:Gs}),q=Jd(i,e,a),S=w=>{c(O=>({...O,...w})),E("")},W=(w,O)=>c(B=>({...B,models:{...B.models,[w]:O}})),M=w=>{S(w),f(null),j(null)},F=async w=>{if(g)return;x(w),j(null);let O;try{O=await o.modelsTest(su(i,a))}catch(G){O={ok:!1,message:D?U(G):r("sourceCouldNotReach",{error:U(G)})}}x(null);const B=Array.isArray(O.models)?O.models.filter(G=>typeof G=="string"):[];if(w==="fetch"){B.length?(f(B),j({ok:!0,message:r("sourceModelsFound",{count:B.length})})):j(O.ok?{ok:!0,message:r("sourceNoModelList")}:{ok:!1,message:O.message});return}B.length&&!h&&f(B),j({ok:O.ok,message:O.message||(O.ok?r("sourceTestOk"):`HTTP ${O.status??"?"}`)})},K=async()=>{if(T(!0),g||q)return;x("save"),E("");const w=xt(i,a);try{const O=await au(o,i,e,a,D&&L?{tabOnly:!0}:{}),B=O.view?Qt(O.view):Xd(w.apiKey??"");c(G=>({...G,apiKey:""})),x(null),t({key:O.key,kind:w.kind,label:O.view?.label||w.label||O.key,host:O.view?.host||Ws(w.baseUrl??""),keyText:B})}catch(O){x(null),E(r("sourceCouldNotSave",{error:U(O)}))}},Z=(w,O,B)=>{const G=i.models[w],te=h?nu(h,G):null;return s.jsx(Fe,{id:k[w],label:O,select:!!te?.length,children:te&&te.length?s.jsx(Ga,{name:w,"aria-label":O,value:G,models:te.map(I=>({id:I})),...B?{}:{defaultLabel:r("sourceModelSameAsDefault")},onChange:I=>W(w,I)}):s.jsx(he,{id:k[w],value:G,required:B,spellCheck:!1,autoComplete:"off",placeholder:B?void 0:r("sourceModelSameAsDefault"),className:"h-8 text-[13px]",onChange:I=>W(w,I.target.value)})})},P=v?q:null;return s.jsxs("form",{"data-model-source-form":"","aria-label":m,"data-editing":a?a.name:void 0,className:"mt-2 rounded-xl border border-line p-3",noValidate:!0,onSubmit:w=>{w.preventDefault(),K()},children:[s.jsx("div",{className:"mb-3 text-[13px] font-semibold",children:m}),s.jsx(Fe,{id:k.kind,label:r("sourceKind"),select:!0,children:s.jsx(Ze,{"aria-label":r("sourceKind"),value:i.kind,className:"h-8 text-[13px]",options:Ya.map(w=>({value:w,label:r(Kd[w])})),onChange:w=>M(Wd(i,w))})}),s.jsx(Fe,{id:k.name,label:r("sourceName"),children:s.jsx(he,{id:k.name,value:i.name,maxLength:80,spellCheck:!1,autoComplete:"off",placeholder:r("sourceNamePlaceholder"),className:"h-8 text-[13px]",onChange:w=>S({name:w.target.value})})}),s.jsx(Fe,{id:k.endpoint,label:r("sourceEndpoint"),hint:_,children:s.jsx(he,{id:k.endpoint,"aria-describedby":`${k.endpoint}-hint`,value:i.baseUrl,type:"text",inputMode:"url",spellCheck:!1,autoComplete:"off",className:"h-8 text-[13px]",onChange:w=>M({baseUrl:w.target.value})})}),s.jsx(Fe,{id:k.key,label:r("sourceKey"),hint:X,children:s.jsx(he,{id:k.key,"aria-describedby":`${k.key}-hint`,value:i.apiKey,placeholder:p||void 0,type:"password",spellCheck:!1,autoComplete:"off","data-1p-ignore":"","data-lpignore":"true",className:"h-8 text-[13px]",onChange:w=>M({apiKey:w.target.value})})}),D?s.jsxs("label",{className:"mt-2 flex items-start gap-2 text-xs",children:[s.jsx("input",{type:"checkbox","data-testid":"source-tab-only",className:"mt-0.5",checked:L,onChange:w=>R(w.target.checked)}),s.jsxs("span",{children:[s.jsx("span",{className:"font-medium",children:r("siteTabOnly")}),s.jsx("span",{className:"block text-fg-muted",children:r("siteTabOnlyHint")})]})]}):null,s.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[s.jsx("span",{className:"flex-1 text-xs font-medium",children:r("sourceModels")}),s.jsx(C,{size:"sm",disabled:!!g,onClick:()=>{F("fetch")},icon:g==="fetch"?s.jsx(Je,{className:"size-3.5 animate-spin"}):void 0,children:g==="fetch"?r("sourceFetching"):r("sourceFetchModels")})]}),s.jsxs("div",{className:"mt-2 rounded-lg bg-surface-2 p-2.5",children:[Z("default",r("sourceModelDefault"),!0),Z("quick",r("sourceModelQuick"),!1),Z("complex",r("sourceModelComplex"),!1),s.jsx("div",{className:"mt-2 text-xs text-fg-muted",children:r("sourceModelsHint")})]}),s.jsx("div",{className:"mt-3","data-source-effort":i.effort??"",children:s.jsx(Fe,{id:k.effort,label:r("sourceEffort"),hint:r("effortHint"),select:!0,children:s.jsx(Ze,{"aria-label":r("sourceEffort"),value:i.effort??"",className:"h-8 w-56 text-[13px]",options:[{value:"",label:r("sourceEffortDefault")},...Vo.map(w=>({value:w,label:r(gs[w])}))],onChange:w=>S({effort:w})})})}),b?s.jsx(ru,{result:b}):null,P||N?s.jsx("div",{role:"alert",className:"mt-2 text-xs text-danger",children:N||(P?r(P):"")}):null,s.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[s.jsx(C,{size:"lg",className:"mr-auto",disabled:!!g,onClick:()=>{F("test")},icon:g==="test"?s.jsx(Je,{className:"size-3.5 animate-spin"}):void 0,children:g==="test"?r("sourceTesting"):r("sourceTest")}),s.jsx(C,{size:"lg",disabled:g==="save",onClick:n,children:r("cancel")}),s.jsx(C,{type:"submit",size:"lg",variant:"primary",disabled:!!g,children:g==="save"?r("sourceSaving"):r("sourceSave")})]})]})}const ou=[{tier:"default",label:"sourceModelDefault"},{tier:"quick",label:"sourceModelQuick"},{tier:"complex",label:"sourceModelComplex"}];function Xs(e){return e.startsWith("harness:")?e.slice(8):e}function iu(e,t){const[n,a]=u.useState({models:[],loading:t,error:""}),o=i=>{let c=!0;return a(d=>({...d,loading:!0,error:""})),ge.modelsCatalog(e,i).then(d=>c&&a({models:d.models,loading:!1,error:d.error??""}),d=>c&&a(l=>({...l,loading:!1,error:U(d)}))),()=>{c=!1}};return u.useEffect(()=>t?o(!1):void 0,[e,t]),{...n,refresh:()=>{o(!0)}}}function lu({harness:e,onSaved:t,onCancel:n}){const a=e.cli,[o,i]=u.useState(()=>Bs(a.choice)),[c,d]=u.useState(!1),[l,p]=u.useState(""),m=iu(e.provider,a.model&&a.lists),h=u.useMemo(()=>Ld(m.models,a.known),[m.models,a.known]),f=Object.keys(Ks(Bs(a.choice))).length>0,g=async(j=Ks(o))=>{if(!c){d(!0),p("");try{await ge.modelsSet({harness:{name:Xs(e.provider),choice:j}}),d(!1),t()}catch(v){d(!1),p(r("usageCouldNotChange",{error:U(v)}))}}},x=j=>{const v=a.defaults[j];return v?r("harnessAppDefaultNamed",{model:v}):j==="default"?r("harnessAppDefaultOption"):r("sourceModelSameAsDefault")},b=e.way==="adapter"?r("harnessWayAdapter"):r("harnessWayMcp");return s.jsxs("form",{"data-harness-choice":Xs(e.provider),"aria-label":r("harnessChoiceTitle",{app:e.title}),className:"mt-2 rounded-xl border border-line p-3",noValidate:!0,onSubmit:j=>{j.preventDefault(),g()},children:[s.jsx("div",{className:"mb-2 text-[13px] font-semibold",children:r("harnessChoiceTitle",{app:e.title})}),a.applies?null:s.jsxs("p",{"data-harness-not-applied":"",className:"mb-2 mt-0 flex items-start gap-1.5 text-xs text-fg-muted",children:[s.jsx(Vn,{className:"mt-px size-3.5 shrink-0"}),s.jsx("span",{children:r("harnessNotApplied",{app:e.title,way:b})})]}),a.model?s.jsxs("div",{className:"rounded-lg bg-surface-2 p-2.5",children:[ou.map(({tier:j,label:v})=>s.jsxs("div",{className:"mt-3 first:mt-0",children:[s.jsx("div",{"aria-hidden":"true",className:"mb-1 block text-xs font-medium",children:r(v)}),s.jsx(Ga,{name:j,"aria-label":r(v),value:o[j],models:h,defaultLabel:x(j),loading:m.loading,error:m.error,onRefresh:a.lists?m.refresh:void 0,className:"bg-surface",onChange:T=>i(N=>({...N,[j]:T}))})]},j)),s.jsx("div",{className:"mt-2 text-xs text-fg-muted",children:r("harnessModelsHint")})]}):null,a.efforts.length?s.jsxs("div",{className:"mt-3","data-harness-effort":o.effort,children:[s.jsx("div",{"aria-hidden":"true",className:"mb-1 block text-xs font-medium",children:r("sourceEffort")}),s.jsx(Ze,{"aria-label":r("sourceEffort"),value:o.effort,className:"h-8 w-56 text-[13px]",options:[{value:"",label:r("harnessAppDefaultOption")},...a.efforts.map(j=>({value:j,label:r(gs[j])}))],onChange:j=>i(v=>({...v,effort:j}))}),s.jsx("div",{className:"mt-1 text-xs text-fg-muted",children:r("effortHint")})]}):null,l?s.jsx("div",{role:"alert",className:"mt-2 text-xs text-danger",children:l}):null,s.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-end gap-2",children:[f?s.jsx(C,{size:"sm",variant:"ghost",className:"mr-auto",disabled:c,"data-harness-reset":"",onClick:()=>{g({})},children:r("harnessReset")}):null,s.jsx(C,{size:"sm",disabled:c,onClick:n,children:r("cancel")}),s.jsx(C,{type:"submit",size:"sm",variant:"primary",disabled:c,"data-harness-save":"",children:r("sourceSave")})]})]})}function Ja(e,t="en"){const n=Number.isFinite(e)?Math.max(0,e):0;return new Intl.NumberFormat(t,{notation:"compact",maximumFractionDigits:n<1e3?0:1}).format(n)}function cu(e){return e.calls?e.unreported>=e.calls?"unreported":e.unreported>0?"partial":e.estimated>0?"estimated":"exact":"none"}function du(e,t,n){const a=cu(e),o=e.input+e.output;if(a==="none"||a==="unreported"||o<=0)return null;const i=Ja(o,n);return t(a==="exact"?"usageTokens":"usageTokensApprox",{count:i})}function es(e,t){if(!e)return"";const n=t?.providers.find(i=>i.name===e);if(n)return n.label||n.name;const a=(t?.harnesses??[]).find(i=>i.provider===e);if(a)return a.title;const o=qo(e);return o?.kind==="harness"?o.harness:e}function uu(e,t){return t(e==="cli"?"sourceViaCli":e==="mcp"?"sourceViaAppMcp":"sourceViaApp")}function Qa(e,t){return e?[uu(e.way,t),er(e,t),e.available?"":e.reason||t("grantUnavailable")].filter(Boolean):[]}function er(e,t){return e.noteCode==="plan"?t("grantNotePlan",{app:e.title}):e.noteCode==="cli-read-only"?t("grantNoteCliReadOnly",{app:e.title}):e.note??""}function pu(e,t,n={}){if(!e)return[];const a=e.harnesses??[],o=d=>t?er(d,t):d.note??"",i=d=>!d.available||n.broad===!0&&d.artifactOnly===!0,c=d=>({value:d.provider,label:t?[d.title,...Qa(d,t).filter(l=>l!==o(d))].join(" · "):d.title,...i(d)?{disabled:!0}:{}});return[...e.providers.map(d=>({value:d.name,label:d.host?`${d.label||d.name} · ${d.host}`:d.label||d.name})),...a.filter(d=>!i(d)).map(c),...a.filter(i).map(c)]}function fu(e,t,n){const a=o=>(t instanceof Map?t.get(o):t[o])??"";return e.map(o=>({artifactId:o.artifactId,title:a(o.artifactId),source:es(o.recent[0]?.provider,n),today:o.today,month:o.month,total:o.total}))}const mu=Object.freeze({by:"tokens",period:"total"}),pt=(e,t)=>t==="calls"?e.calls:e.input+e.output;function hu(e,t){const n=t.by==="calls"?"tokens":"calls";return[...e].sort((a,o)=>pt(o[t.period],t.by)-pt(a[t.period],t.by)||pt(o[t.period],n)-pt(a[t.period],n)||(a.title||a.artifactId).localeCompare(o.title||o.artifactId))}function xu(e,t){return`${JSON.stringify({exportedAt:t,artifacts:e},null,2)}
|
|
3
|
-
`}const Zs=["today","month","total"],Js=["calls","input","output","estimated","unreported"];function gu(e){let t=String(e);return/^[=+\-@\t\r]/.test(t)&&(t=`'${t}`),/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function bu(e){const t=["artifact_id","title","source",...Zs.flatMap(a=>Js.map(o=>`${a}_${o}`))],n=e.map(a=>[a.artifactId,a.title,a.source,...Zs.flatMap(o=>Js.map(i=>a[o][i]))].map(gu).join(","));return`${[t.join(","),...n].join(`\r
|
|
4
|
-
`)}\r
|
|
5
|
-
`}function Qs(e,t){return`open-artifacts-usage-${`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}.${e}`}function yu(e,t){return(e??"").replace(/\s*[((][^()()]*[))]\s*$/,"").trim()||(e??"").trim()||t}function vu(e){const t=e?.all?.sample?.provider;return typeof t=="string"&&t?{on:!0,provider:t}:{on:!1}}function ju(e,t){return Object.entries(e?.types??{}).filter(([,n])=>typeof n?.sample?.provider=="string").map(([n,a])=>({typeId:n,title:t.get(n)||n,provider:a.sample.provider})).sort((n,a)=>n.title.localeCompare(a.title))}function ku(e){return e?e.default&&e.providers.some(t=>t.name===e.default)?e.default:e.providers[0]?.name??(e.harnesses??[]).find(t=>t.available&&!t.artifactOnly)?.provider??null:null}function Nu(e,t){return e?t?{scope:"all",provider:t}:null:{scope:"all"}}function wu(e){const t=Number(e.perArtifactPerHour.trim());if(e.perArtifactPerHour.trim()===""||!Number.isInteger(t)||t<0)return{problem:"perArtifactPerHour"};const n=Number(e.maxOutputTokens.trim());return e.maxOutputTokens.trim()===""||!Number.isInteger(n)||n<=0?{problem:"maxOutputTokens"}:{request:{limits:{perArtifactPerHour:t,maxOutputTokens:n}}}}function Tt({title:e,actions:t,children:n,id:a}){return s.jsxs("section",{id:a,className:"rounded-xl border border-line bg-surface p-4",children:[s.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h3",{className:"m-0 text-[13px] font-semibold",children:e}),t?s.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:t}):null]}),n]})}function ct({children:e}){return s.jsxs("p",{role:"alert",className:"mb-0 mt-2 flex items-start gap-1.5 text-xs text-danger",children:[s.jsx(Ie,{className:"mt-px size-3.5 shrink-0"}),s.jsx("span",{children:e})]})}function Su({source:e,isDefault:t,onChanged:n,onEdit:a,onRemove:o}){const[i,c]=u.useState(!1),[d,l]=u.useState(null),[p,m]=u.useState(""),h=Qt(e),f=async()=>{c(!0),l(null),m("");try{l(await ge.modelsTest({name:e.name}))}catch(b){m(U(b))}c(!1)},g=async()=>{try{await ge.modelsSet({name:e.name,makeDefault:!0}),n()}catch(b){m(r("usageCouldNotChange",{error:U(b)}))}},x=e.keyEnv&&!e.keyEnv.set?e.keyEnv.name:"";return s.jsxs("li",{"data-model-source":e.name,className:"flex flex-col gap-1 border-t border-line py-2.5 first:border-t-0 first:pt-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-medium",children:e.label||e.name}),s.jsx("span",{className:"text-xs text-fg-muted",children:e.host}),t?s.jsx("span",{className:"rounded-full bg-accent-soft px-2 py-px text-[11px] font-medium text-accent",children:r("modelsDefault")}):null,e.tabOnly?s.jsx("span",{"data-tab-only":"",className:"rounded-full bg-surface-2 px-2 py-px text-[11px] font-medium text-fg-muted",children:r("siteTabOnlyBadge")}):null,s.jsxs("span",{className:"ml-auto flex flex-wrap items-center gap-1",children:[t?null:s.jsx(C,{size:"sm",variant:"ghost",onClick:()=>{g()},children:r("modelsMakeDefault")}),s.jsx(C,{size:"sm",variant:"ghost","data-model-source-edit":"",onClick:a,children:r("modelsEdit")}),s.jsx(C,{size:"sm",variant:"ghost",disabled:i,icon:i?s.jsx(Je,{className:"size-3 animate-spin motion-reduce:animate-none"}):void 0,onClick:()=>{f()},children:i?r("sourceTesting"):r("modelsTest")}),s.jsx(C,{size:"sm",variant:"ghost",className:"text-danger","data-model-source-remove":"",onClick:o,children:Ue()?r("siteForget"):r("modelsRemove")})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-xs text-fg-muted",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(ui,{className:"size-3"}),x?s.jsx("span",{className:"text-warning",children:r("modelsKeyEnvUnset",{name:x})}):h||r("modelsNoKey")]}),s.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:r("modelsTierModels",{default:e.models.default,quick:e.models.quick||e.models.default,complex:e.models.complex||e.models.default})})]}),d?s.jsxs("p",{role:"status",className:ie("m-0 flex items-start gap-1.5 text-xs",d.ok?"text-success":"text-danger"),children:[d.ok?s.jsx(ls,{className:"mt-px size-3.5 shrink-0"}):s.jsx(Ie,{className:"mt-px size-3.5 shrink-0"}),s.jsx("span",{className:"break-words",children:d.ok?`${r("sourceTestOk")} ${d.message}`:d.message})]}):null,p?s.jsx(ct,{children:p}):null]})}function Tu({models:e,reload:t}){const[n,a]=u.useState(!1),[o,i]=u.useState(null),[c,d]=u.useState(null),[l,p]=u.useState(""),m=async f=>{try{await ge.modelsRemove(f.name),t()}catch(g){p(r("usageCouldNotChange",{error:U(g)}))}},h=e.providers.map(f=>({value:f.name,label:f.label||f.name}));return s.jsxs(Tt,{title:r("modelsSources"),actions:n?null:s.jsx(C,{size:"sm",icon:s.jsx(jt,{className:"size-3"}),"data-testid":"models-add-source",onClick:()=>{i(null),a(!0)},children:r("modelsAddSource")}),children:[e.providers.length||e.harnesses?.length?s.jsxs("ul",{className:"m-0 list-none p-0",children:[e.providers.map(f=>o===f.name?s.jsx("li",{"data-model-source":f.name,className:"border-t border-line py-2.5 first:border-t-0 first:pt-0",children:s.jsx(Ys,{initial:f,taken:e.providers.map(g=>g.name),onSaved:()=>{i(null),t()},onCancel:()=>i(null)})},f.name):s.jsx(Su,{source:f,isDefault:e.default===f.name,onChanged:t,onEdit:()=>{a(!1),i(f.name)},onRemove:()=>d(f)},f.name)),(e.harnesses??[]).map(f=>s.jsxs("li",{"data-model-source":f.provider,"data-unavailable":f.available?void 0:"","aria-disabled":f.available?void 0:!0,className:"flex flex-col gap-0.5 border-t border-line py-2.5 first:border-t-0 first:pt-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2",children:[s.jsx("span",{className:ie("font-medium",!f.available&&"text-fg-muted"),children:f.title}),s.jsx("span",{className:"text-xs text-fg-muted",children:r("modelsAgentApp")}),f.cli&&o!==f.provider?s.jsx("span",{className:"ml-auto",children:s.jsx(C,{size:"sm",variant:"ghost","data-harness-change":"",onClick:()=>{a(!1),i(f.provider)},children:r("harnessChange")})}):null]}),s.jsx("div",{className:"text-xs text-fg-muted",children:Qa(f,r).map((g,x)=>s.jsx("span",{className:ie(x>0&&"before:mx-1 before:content-['·']",!f.available&&g===(f.reason||r("grantUnavailable"))&&"text-warning"),children:g},g))}),f.cli?s.jsx("div",{"data-harness-summary":"",className:ie("text-xs",f.cli.applies?"text-fg-muted":"text-fg-subtle"),children:$d(f.cli,r)}):null,f.cli&&o===f.provider?s.jsx(lu,{harness:f,onSaved:()=>{i(null),t()},onCancel:()=>i(null)}):null]},f.provider))]}):n?null:s.jsx("p",{className:"m-0 text-fg-muted",children:r("modelsNoSources")}),n?s.jsx("div",{className:"mt-3",children:s.jsx(Ys,{taken:e.providers.map(f=>f.name),onSaved:()=>{a(!1),t()},onCancel:()=>a(!1)})}):null,e.providers.length?s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-line pt-3",children:[s.jsx("span",{className:"text-xs font-medium",children:r("modelsDefaultSource")}),s.jsx(Ze,{"aria-label":r("modelsDefaultSource"),value:e.default&&e.providers.some(f=>f.name===e.default)?e.default:null,options:h,placeholder:r("modelsNone"),className:"w-56",onChange:f=>{ge.modelsSet({name:f,makeDefault:!0}).then(t,g=>p(r("usageCouldNotChange",{error:U(g)})))}}),s.jsx("span",{className:"text-xs text-fg-muted",children:r("modelsDefaultHint")})]}):null,l?s.jsx(ct,{children:l}):null,s.jsx(rl,{open:!!c,onOpenChange:f=>{f||d(null)},title:r(Ue()?"siteForgetConfirm":"modelsRemoveConfirm",{source:c?.label||c?.name||""}),description:Ue()?r("siteForgetBody"):r("modelsRemoveBody"),confirmLabel:Ue()?r("siteForget"):r("modelsRemove"),cancelLabel:r("cancel"),danger:!0,onConfirm:()=>{c&&m(c),d(null)}})]})}function Cu({models:e,reload:t}){const n={perArtifactPerHour:String(e.limits.perArtifactPerHour),maxOutputTokens:String(e.limits.maxOutputTokens)},[a,o]=u.useState(n),[i,c]=u.useState("idle"),[d,l]=u.useState("");u.useEffect(()=>o({perArtifactPerHour:String(e.limits.perArtifactPerHour),maxOutputTokens:String(e.limits.maxOutputTokens)}),[e.limits.perArtifactPerHour,e.limits.maxOutputTokens]);const p=wu(a),m=async()=>{if("request"in p){c("saving"),l("");try{await ge.modelsSet(p.request),c("saved"),t()}catch(g){c("idle"),l(r("usageCouldNotChange",{error:U(g)}))}}},h=(g,x,b,j)=>s.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[s.jsx("span",{className:"text-xs font-medium",children:x}),s.jsx("input",{type:"number",inputMode:"numeric",min:j,step:1,"data-limit":g,value:a[g],"aria-invalid":"problem"in p&&p.problem===g?!0:void 0,className:ie(Wo,"w-40 tabular-nums","problem"in p&&p.problem===g&&"border-danger"),onChange:v=>{c("idle"),o({...a,[g]:v.target.value})}}),"problem"in p&&p.problem===g?s.jsx("span",{className:"text-xs text-danger",children:r(g==="perArtifactPerHour"?"modelsPerHourBad":"modelsMaxOutputBad")}):b?s.jsx("span",{className:"text-xs text-fg-muted",children:b}):null]}),f=a.perArtifactPerHour!==n.perArtifactPerHour||a.maxOutputTokens!==n.maxOutputTokens;return s.jsxs(Tt,{title:r("modelsLimits"),children:[s.jsxs("div",{className:"flex flex-wrap items-start gap-4",children:[h("perArtifactPerHour",r("modelsPerHour"),r("modelsPerHourHint"),0),h("maxOutputTokens",r("modelsMaxOutput"),null,1)]}),s.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[s.jsx(C,{size:"sm",variant:"primary",disabled:!f||!("request"in p)||i==="saving",onClick:()=>{m()},children:r("modelsSaveLimits")}),i==="saved"?s.jsx("span",{role:"status",className:"text-xs text-success",children:r("modelsSaved")}):null]}),d?s.jsx(ct,{children:d}):null]})}function Eu({models:e,grants:t,reload:n}){const a=y(x=>x.types),[o,i]=u.useState(""),[c,d]=u.useState(!1),l=u.useMemo(()=>new Map((a?.types??[]).map(x=>[x.id,yu(x.title,x.id)])),[a]),p=vu(t.grants),m=ju(t.grants,l),h=ku(e),f=pu(e,r,{broad:!0}),g=async x=>{if(!(!x||c)){d(!0),i("");try{await ge.grantsRevoke(x),n()}catch(b){i(r("usageCouldNotChange",{error:U(b)}))}d(!1)}};return s.jsxs(Tt,{title:r("modelsPermissions"),children:[s.jsxs("div",{"data-always-allow":p.on?"on":"off",className:"flex items-start gap-3",children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(Mn,{checked:p.on,disabled:c||!p.on&&!h,"aria-label":r("modelsAlwaysAllow"),onChange:x=>{g(Nu(x,h))}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium",children:r("modelsAlwaysAllow")}),s.jsx("div",{className:ie("text-xs",p.on?"text-fg":"text-fg-muted"),children:p.on?r("modelsAlwaysOn",{source:es(p.provider,e)}):h?r("modelsAlwaysOff"):`${r("modelsAlwaysOff")} ${r("modelsAlwaysNeedsSource")}`}),p.on&&f.length>1?s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-xs text-fg-muted",children:r("modelsAlwaysSource")}),s.jsx(Ze,{"aria-label":r("modelsAlwaysSource"),value:f.some(x=>x.value===p.provider)?p.provider:null,options:f,className:"w-56",onChange:x=>{g({scope:"all",provider:x})}})]}):null]})]}),s.jsxs("div",{className:"mt-4 border-t border-line pt-3",children:[s.jsx("div",{className:"mb-1.5 text-xs font-semibold text-fg-muted",children:r("modelsTypeAllowances")}),m.length?s.jsx("ul",{className:"m-0 list-none p-0",children:m.map(x=>s.jsxs("li",{"data-type-allowance":x.typeId,className:"flex flex-wrap items-center gap-x-3 gap-y-1 py-1",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:[r("modelsTypeAllowed",{type:x.title}),s.jsxs("span",{className:"text-xs text-fg-muted",children:[" · ",es(x.provider,e)]})]}),s.jsx(C,{size:"sm",variant:"ghost",className:"text-danger",disabled:c,onClick:()=>{g({scope:"type",typeId:x.typeId})},children:r("modelsRemove")})]},x.typeId))}):s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:r("modelsNoTypeAllowances")})]}),o?s.jsx(ct,{children:o}):null]})}function en(e,t,n){const a=URL.createObjectURL(new Blob([e],{type:n})),o=document.createElement("a");o.href=a,o.download=t,document.body.append(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(a),1e3)}const Pu=[["today","usagePeriodToday"],["month","usagePeriodMonth"],["total","usagePeriodTotal"]];function $t({totals:e}){if(!e.calls)return s.jsx("span",{className:"text-fg-subtle",children:"—"});const t=du(e,r,Xe);return s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:r("modelsCellCalls",{count:Ja(e.calls,Xe)})}),t?s.jsx("span",{className:"text-xs text-fg-muted",children:t}):s.jsx("span",{className:"text-xs text-fg-subtle",children:r("usageNotReported")})]})}function Ru({usage:e,models:t}){const n=y(l=>l.artifacts),[a,o]=u.useState({...mu}),i=u.useMemo(()=>new Map((n??[]).map(l=>[l.id,l.title])),[n]),c=u.useMemo(()=>hu(fu(e.artifacts,i,t),a),[e,i,t,a]),d=l=>{const p=new Date;l==="json"?en(xu(c,p.toISOString()),Qs("json",p),"application/json"):en(bu(c),Qs("csv",p),"text/csv")};return s.jsx(Tt,{id:"models-usage",title:r("modelsUsage"),actions:c.length?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-xs text-fg-muted",children:r("modelsSortBy")}),s.jsx(ft,{"aria-label":r("modelsSortBy"),value:a.by,options:[{value:"tokens",label:r("modelsSortTokens")},{value:"calls",label:r("modelsSortCalls")}],className:"text-xs",onChange:l=>o({...a,by:l})}),s.jsx(C,{size:"sm",icon:s.jsx(Ke,{className:"size-3"}),"data-testid":"usage-export-json",onClick:()=>d("json"),children:r("modelsExportJson")}),s.jsx(C,{size:"sm",icon:s.jsx(Ke,{className:"size-3"}),"data-testid":"usage-export-csv",onClick:()=>d("csv"),children:r("modelsExportCsv")})]}):null,children:c.length?s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{"data-usage-table":"",className:"w-full min-w-[36rem] border-collapse text-left text-[13px] tabular-nums",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-xs text-fg-muted",children:[s.jsx("th",{className:"py-1.5 pr-3 font-medium",children:r("modelsColArtifact")}),s.jsx("th",{className:"py-1.5 pr-3 font-medium",children:r("usageSource")}),Pu.map(([l,p])=>s.jsx("th",{className:"py-1.5 pr-3 font-medium","aria-sort":a.period===l?"descending":void 0,children:s.jsxs("button",{type:"button",className:ie("inline-flex items-center gap-1 rounded px-1 -mx-1 hover:bg-hover hover:text-fg",a.period===l&&"text-fg"),onClick:()=>o({...a,period:l}),children:[r(p),a.period===l?s.jsx(ni,{className:"size-3"}):null]})},l))]})}),s.jsx("tbody",{children:c.map(l=>s.jsxs("tr",{"data-usage-row":l.artifactId,className:"border-t border-line align-top",children:[s.jsx("td",{className:"max-w-64 py-2 pr-3",children:l.title?s.jsx("a",{href:it(l.artifactId),className:"block truncate font-medium text-fg hover:text-accent hover:underline",title:l.title,children:l.title}):s.jsx("span",{className:"block truncate text-fg-muted",title:l.artifactId,children:r("modelsDeletedArtifact")})}),s.jsx("td",{className:"py-2 pr-3 text-fg-muted",children:l.source||"—"}),s.jsx("td",{className:"py-2 pr-3",children:s.jsx($t,{totals:l.today})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsx($t,{totals:l.month})}),s.jsx("td",{className:"py-2 pr-3",children:s.jsx($t,{totals:l.total})})]},l.artifactId))})]})}):s.jsx("p",{className:"m-0 text-fg-muted",children:r("modelsNoUsage")})})}function tr(){const[e,t]=u.useState(null),[n,a]=u.useState(""),[o,i]=u.useState(!1),c=async()=>{i(!0);const[l,p,m]=await Promise.allSettled([ge.modelsList(),ge.grantsList(),ge.usageSummary()]);t({models:l.status==="fulfilled"?l.value:null,grants:p.status==="fulfilled"?p.value:null,usage:m.status==="fulfilled"?m.value:null});const h=[l,p,m].find(f=>f.status==="rejected");a(h?r("modelsCouldNotLoad",{error:U(h.reason)}):""),i(!1)};u.useEffect(()=>{c()},[]);const d=()=>{c()};return s.jsxs("div",{"data-testid":"model-settings",className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{id:"models",className:"m-0 text-base font-semibold",children:r("modelsHeading")}),s.jsx("p",{className:"mb-0 mt-0.5 text-fg-muted",children:Ue()?r("siteModelsSub"):r("modelsSub")})]}),s.jsx(C,{size:"sm",variant:"ghost",disabled:o,icon:s.jsx(yt,{className:ie("size-3",o&&"animate-spin motion-reduce:animate-none")}),onClick:d,children:r("refresh")})]}),n?s.jsx(ct,{children:n}):null,e?s.jsxs(s.Fragment,{children:[e.models?s.jsx(Tu,{models:e.models,reload:d}):null,e.models&&e.grants?s.jsx(Eu,{models:e.models,grants:e.grants,reload:d}):null,e.models?s.jsx(Cu,{models:e.models,reload:d}):null,e.usage?s.jsx(Ru,{usage:e.usage,models:e.models}):null]}):s.jsxs("p",{className:"m-0 flex items-center gap-1.5 text-fg-muted",children:[s.jsx(Je,{className:"size-3.5 animate-spin motion-reduce:animate-none"}),r("loading")]})]})}function Ou(){const e=u.useRef(null),t=y(n=>Ha(n.upload));return s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"lg",icon:s.jsx(ua,{className:"size-3.5"}),disabled:t,title:r("uploadHint"),onClick:()=>e.current?.click(),children:r("upload")}),s.jsx("input",{ref:e,type:"file",accept:".zip,application/zip,application/x-zip-compressed","data-home-upload":"",className:"hidden",onChange:n=>{const a=[...n.target.files??[]];n.target.value="",qa(a)}})]})}function Mu(){const e=y(a=>a.upload);if(e.kind==="idle")return null;if(e.kind==="failed")return s.jsxs("div",{role:"alert","data-home-upload-error":"",className:"mb-3 flex items-start gap-2 rounded-lg border border-line bg-surface p-3 text-[13px]",children:[s.jsx(Ie,{className:"mt-px size-4 shrink-0 text-danger"}),s.jsx("span",{className:"min-w-0 flex-1 break-words",children:r(e.said.key,e.said.vars)}),s.jsx(os,{label:r("dismiss"),size:"sm",noTooltip:!0,icon:s.jsx(kt,{className:"size-3.5"}),onClick:()=>y.getState().uploadEvent({type:"dismiss"})})]});const t=zc(e),n=e.kind==="done"?r("uploadOpening",{name:e.name}):e.kind==="checking"?r("uploadChecking",{name:e.name}):t===null?r("uploadSendingSize",{name:e.name}):r("uploadSending",{name:e.name,percent:t});return s.jsxs("div",{role:"status","data-home-upload-state":e.kind,className:"mb-3 rounded-lg border border-line bg-surface p-3 text-[13px]",children:[s.jsx("div",{className:"mb-2 truncate",children:n}),s.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-surface-2",children:s.jsx("div",{className:"h-full rounded-full bg-accent transition-[width] duration-150",style:{width:`${t??5}%`}})})]})}function Iu({children:e}){const[t,n]=u.useState(!1),a=u.useRef(0),o=!!re.cloud?.user,i=c=>o&&Hc([...c.dataTransfer.types]);return s.jsxs("div",{className:"relative","data-home-drop":t?"over":"",onDragEnter:c=>{i(c)&&(c.preventDefault(),a.current++,n(!0))},onDragOver:c=>{i(c)&&(c.preventDefault(),c.dataTransfer.dropEffect="copy")},onDragLeave:c=>{i(c)&&(a.current=Math.max(0,a.current-1),a.current||n(!1))},onDrop:c=>{i(c)&&(c.preventDefault(),a.current=0,n(!1),qa([...c.dataTransfer.files]))},children:[e,t?s.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 grid min-h-32 place-items-center rounded-xl border-2 border-dashed border-accent bg-surface/80 text-[13px] font-medium text-accent",children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ua,{className:"size-4"}),r("uploadDrop")]})}):null]})}function Au({row:e}){const t=y(n=>n.purgeUnsupported);return s.jsxs("div",{"data-home-trashed":e.id,className:"flex min-w-0 flex-wrap items-center gap-3 rounded-xl border border-line bg-surface p-3.5",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"break-words font-semibold",children:e.title}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-xs text-fg-muted",children:[s.jsx(ae,{children:e.typeTitle}),s.jsx("span",{children:e.when.kind==="trashed"?r("trashedWhen",{when:Be(e.when.at)}):r("updated",{when:Be(e.when.at)})})]})]}),e.mine?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(C,{size:"sm",icon:s.jsx(yi,{className:"size-3"}),onClick:()=>{yd(e)},children:r("restore")}),ad(e,t)?s.jsx(C,{size:"sm",variant:"ghost",className:"text-danger",icon:s.jsx(mt,{className:"size-3"}),onClick:()=>y.getState().setPurging({id:e.id,title:e.title}),children:r("deleteForever")}):null]}):null]})}function Du(){const e=y(o=>o.trash);u.useEffect(()=>{qe()},[]);const t=nd(re.cloud?.trashDays),n=s.jsxs("p",{className:"mb-3 mt-0 text-xs text-fg-muted",children:[r("trashNote"),t?` ${r(t.key,t.vars)}`:""]});if(e===null)return s.jsx("p",{className:"py-8 text-fg-muted",children:r("loading")});const a=sd(e);return s.jsxs("div",{"data-home-trash":"",children:[n,a.length?s.jsx("div",{className:"flex flex-col gap-2",children:a.map(o=>s.jsx(Au,{row:o},o.id))}):s.jsx(Ve,{title:r("trash"),children:r("trashEmpty")})]})}function zu(){const e=y(n=>n.purging),t=()=>y.getState().setPurging(null);return s.jsx(ze,{open:!!e,onOpenChange:n=>!n&&t(),title:e?r("purgeTitle",{title:e.title}):"",description:r("purgeBody"),footer:s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"lg",onClick:t,children:r("cancel")}),s.jsx(C,{size:"lg",variant:"danger",onClick:()=>{e&&vd(e),t()},children:r("deleteForever")})]})})}function Lu(){const e=y(n=>n.cloudTab),t=e==="types"&&!re.cloud?.siteTypes||e==="models"&&!re.cloud?.sample?"artifacts":e;return s.jsx(Ca,{value:t,onChange:n=>y.getState().setCloudTab(n),className:"[&>[role=tabpanel]]:overflow-visible [&>[role=tabpanel]]:pt-4 [&_[role=tab][aria-selected=true]]:bg-hover [&_[role=tab][aria-selected=true]]:text-fg",items:[{value:"artifacts",label:r("artifacts"),content:s.jsxs(Iu,{children:[s.jsx(Mu,{}),s.jsx(Yt,{})]})},...re.cloud?.siteTypes?[{value:"types",label:r("types"),content:s.jsx(Md,{})}]:[],{value:"trash",label:r("trash"),content:s.jsx(Du,{})},...re.cloud?.sample?[{value:"models",label:r("modelsHeading"),content:s.jsx(tr,{})}]:[]]})}function ts({label:e,children:t}){return s.jsxs("label",{className:"mt-3 block",children:[s.jsx("span",{className:"mb-1 block text-xs text-fg-muted",children:e}),t]})}const Bt={blank:{title:"createGroupBlank",hint:"createGroupBlankHint"},agent:{title:"createGroupAgent",hint:"createGroupAgentHint"},custom:{title:"createGroupCustom",hint:"createGroupCustomHint"}};function _u({chosen:e,onChoose:t}){const n=y(o=>o.types),a=Ec(n?.types??[e]);return s.jsx("div",{role:"radiogroup","aria-label":r("createType"),className:"mt-3",children:Object.keys(Bt).map(o=>a[o].length?s.jsxs("div",{"data-testid":`create-group-${o}`,className:"mt-2 first:mt-0",children:[s.jsx("div",{className:"text-xs font-medium text-fg",children:r(Bt[o].title)}),s.jsx("p",{className:"mb-1.5 mt-0.5 text-xs text-fg-muted",children:r(Bt[o].hint)}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:a[o].map(i=>{const c=i.id===e.id&&i.root===e.root;return s.jsx("button",{type:"button",role:"radio","aria-checked":c,"data-testid":"create-type","data-type-id":i.id,onClick:()=>t(i),className:ie("rounded-md border px-2.5 py-1 text-xs",c?"border-accent bg-accent/10 text-fg":"border-line text-fg-muted hover:bg-hover"),children:i.title},`${i.root}:${i.id}`)})})]},o):null)})}function Fu(){const e=y(g=>g.creating),[t,n]=u.useState(e),[a,o]=u.useState(""),[i,c]=u.useState(""),[d,l]=u.useState(""),[p,m]=u.useState(!1);u.useEffect(()=>{e&&(n(e),o(""),c(""),l(""))},[e]);const h=t?ms(t):null,f=async g=>{if(g.preventDefault(),!t||p)return;m(!0);const x=await kd(t,a,i,h==="blank");m(!1),x&&l(x)};return s.jsx(ze,{open:!!e,onOpenChange:g=>!g&&y.getState().setCreating(null),title:t?r("newOf",{type:t.title}):"",description:t?.description?t.description.slice(0,160):void 0,children:s.jsxs("form",{"data-testid":"create-form",onSubmit:g=>{f(g)},children:[t?s.jsx(_u,{chosen:t,onChoose:g=>(n(g),l(""))}):null,s.jsx(ts,{label:r("title"),children:s.jsx(he,{autoFocus:!0,required:!0,name:"title",value:a,maxLength:200,onChange:g=>o(g.target.value),className:"h-8"})}),s.jsx(ts,{label:r("folderOptional"),children:s.jsx(he,{value:i,placeholder:r("folderHint"),onChange:g=>c(g.target.value),className:"h-8"})}),d?s.jsx("p",{role:"alert",className:"mb-0 mt-2 text-xs text-danger",children:d}):null,s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(C,{size:"lg",onClick:()=>y.getState().setCreating(null),children:r("cancel")}),s.jsx(C,{size:"lg",type:"submit",variant:"primary",disabled:p||!a.trim(),children:r(h==="blank"?"createBlank":"create")})]})]})})}function Hu(){const e=y(o=>o.renaming),[t,n]=u.useState("");u.useEffect(()=>n(e?.title??""),[e]);const a=()=>y.getState().setRenaming(null);return s.jsx(ze,{open:!!e,onOpenChange:o=>!o&&a(),title:r("renameArtifact"),children:s.jsxs("form",{onSubmit:o=>{o.preventDefault(),e&&xd(e,t),a()},children:[s.jsx(ts,{label:r("title"),children:s.jsx(he,{autoFocus:!0,value:t,maxLength:200,onChange:o=>n(o.target.value),className:"h-8"})}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(C,{size:"lg",onClick:a,children:r("cancel")}),s.jsx(C,{size:"lg",type:"submit",variant:"primary",disabled:!t.trim(),children:r("save")})]})]})})}function Uu(){const e=y(t=>t.undo);return e?s.jsxs("div",{role:"status",className:"fixed bottom-5 left-1/2 z-[1100] flex max-w-[calc(100vw-32px)] -translate-x-1/2 items-center gap-3 rounded-lg bg-fg px-3.5 py-2 text-[13px] text-surface shadow-popup",children:[s.jsx("span",{className:"min-w-0 truncate",children:r(e.trash?"movedToTrash":e.webShared?"deletedWebShared":"deleted",{title:e.title})}),s.jsx("button",{type:"button",className:"shrink-0 font-semibold text-surface underline-offset-2 hover:underline",onClick:()=>{bd()},children:r("undo")})]}):null}function Pe({label:e,children:t,testId:n}){return s.jsxs("div",{className:"grid grid-cols-[7rem_1fr] gap-2 text-xs",children:[s.jsx("span",{className:"text-fg-muted",children:e}),s.jsx("span",{"data-testid":n,className:"min-w-0 break-all",children:t})]})}function $u({preview:e}){return s.jsxs("div",{"data-testid":"type-preview",className:"flex flex-col gap-1.5",children:[s.jsxs("p",{className:"m-0 text-sm font-semibold",children:[e.name," ",e.version]}),e.description?s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:e.description}):null,s.jsx(Pe,{label:r("packageId"),children:e.id}),s.jsx(Pe,{label:r("packageSource"),testId:"type-preview-source",children:e.source}),e.site?s.jsxs(s.Fragment,{children:[s.jsx(Pe,{label:r("packagePublisher"),testId:"type-preview-publisher",children:r("packagePublisherText",{name:e.site.publisher??r("siteTypeUnnamedPublisher"),site:e.site.origin})}),s.jsx(Pe,{label:r("packageSite"),testId:"type-preview-site",children:e.site.remote?r("packageSiteRemote",{site:e.site.origin,remote:e.site.remote}):r("packageSitePublic",{site:e.site.origin})})]}):null,s.jsx(Pe,{label:"sha256",children:s.jsx("span",{className:"font-mono",children:e.sha256})}),s.jsx(Pe,{label:r("packageCapabilities"),testId:"type-preview-capabilities",children:e.capabilities.length?e.capabilities.join(", "):r("noCapabilities")}),s.jsx(Pe,{label:r("packageNetwork"),testId:"type-preview-network",children:e.network.length?e.network.join(", "):r("noNetwork")}),e.replaces?s.jsx(Pe,{label:r("packageReplaces"),children:r("packageReplacesText",{version:e.replaces.version,source:e.replaces.source})}):null,e.warnings.map(t=>s.jsx("p",{className:"m-0 text-xs text-warning",children:t},t)),s.jsx("p",{className:"mb-0 mt-2 text-xs text-fg-muted",children:e.skill?r("packageSkill",{path:e.skill.path,chars:e.skill.chars,lines:e.skill.lines}):r("packageNoSkill")}),e.skill?s.jsx("pre",{"data-testid":"type-preview-skill",className:"m-0 max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-2 p-2 font-mono text-xs",children:e.skill.text}):null,s.jsx("p",{className:"mb-0 mt-2 text-xs text-fg-subtle",children:r("packageThirdParty")})]})}function Bu(){const e=y(k=>k.installing),t=e!==null,n=e?.update,a=e?.url,o=e?.as,i=e?.auto===!0,[c,d]=u.useState(""),[l,p]=u.useState(""),[m,h]=u.useState(""),[f,g]=u.useState(!1),[x,b]=u.useState(null),j=u.useRef(null);u.useEffect(()=>{t&&(d(a??""),p(o??""),h(""),b(null),g(!1),!n&&a&&i&&(g(!0),Ft({url:a},o).then(k=>{g(!1),"error"in k?h(k.error):b(k.preview)})),n&&(g(!0),Ft({update:n}).then(k=>{g(!1),"error"in k?h(k.error):b(k.preview)})))},[t,n,a,o,i]);const v=()=>y.getState().setInstalling(null),T=async k=>{if(f)return;g(!0),h("");const D=await Ft(k,l);g(!1),"error"in D?h(D.error):b(D.preview)},N=k=>{k.preventDefault(),T({url:c})},E=async()=>{if(!x||f)return;g(!0);const k=await pd(x,n?{update:n}:{as:l});g(!1),"error"in k?h(k.error):v()};return s.jsx(ze,{open:t,onOpenChange:k=>!k&&v(),title:n?r("updateTypeTitle",{id:n}):r("installType"),description:x?r("installTypeCheck"):n?void 0:r("installTypeDescription"),className:"w-[min(40rem,calc(100vw-2rem))]",children:x?s.jsxs(s.Fragment,{children:[s.jsx($u,{preview:x}),m?s.jsx("p",{role:"alert",className:"mb-0 mt-2 text-xs text-danger",children:m}):null,s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(C,{size:"lg",onClick:v,children:r("cancel")}),s.jsx(C,{size:"lg",variant:"primary","data-testid":"type-install-confirm",disabled:f,onClick:()=>{E()},children:n?r("updateType"):r("installTypeAs",{id:x.id})})]})]}):n?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"m-0 text-xs text-fg-muted",children:f?r("loading"):null}),m?s.jsx("p",{role:"alert",className:"mb-0 mt-2 text-xs text-danger",children:m}):null]}):s.jsxs("form",{onSubmit:N,"data-testid":"install-type-form",children:[s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsxs("div",{children:[s.jsx(C,{size:"md",icon:s.jsx(li,{className:"size-3"}),disabled:f,"data-testid":"install-type-file",onClick:()=>j.current?.click(),children:r("chooseTypePackage")}),s.jsx("input",{ref:j,type:"file",accept:".oatype,application/zip",hidden:!0,"data-testid":"install-type-file-input",onChange:k=>{const D=k.target.files?.[0];k.target.value="",D&&T({file:D})}})]}),s.jsxs("div",{children:[s.jsx("span",{className:"mb-1 block text-xs text-fg-muted",children:r("typePackageUrl")}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(he,{name:"url",value:c,placeholder:"https://…/my-type-1.0.0.oatype",spellCheck:!1,"aria-label":r("typePackageUrl"),onChange:k=>d(k.target.value),className:"h-8 flex-1"}),s.jsx(C,{size:"md",type:"submit",disabled:f||!c.trim(),children:r("readPackage")})]})]}),a&&!i?s.jsx("p",{"data-testid":"install-type-clash",className:"m-0 text-xs text-warning",children:r("siteTypeClashHint")}):null,s.jsxs("div",{children:[s.jsx("span",{className:"mb-1 block text-xs text-fg-muted",children:r("installAs")}),s.jsx(he,{name:"as",value:l,maxLength:64,spellCheck:!1,"aria-label":r("installAs"),onChange:k=>p(k.target.value.toLowerCase()),className:"h-8"}),s.jsx("span",{className:"mt-1 block text-xs text-fg-subtle",children:r("installAsHint")})]})]}),f?s.jsx("p",{className:"mb-0 mt-2 text-xs text-fg-muted",children:r("loading")}):null,m?s.jsx("p",{role:"alert",className:"mb-0 mt-2 text-xs text-danger",children:m}):null]})})}function Ge({label:e,hint:t,children:n}){return s.jsxs("div",{className:"mt-3",children:[s.jsx("span",{className:"mb-1 block text-xs text-fg-muted",children:e}),n,t?s.jsx("span",{className:"mt-1 block text-xs text-fg-subtle",children:t}):null]})}function tn({text:e,testId:t}){return s.jsxs("div",{className:"mt-1 flex items-start gap-2 rounded-lg bg-surface-2 p-2",children:[s.jsx("pre",{"data-testid":t,className:"m-0 min-w-0 flex-1 whitespace-pre-wrap break-all font-mono text-xs",children:e}),s.jsx(C,{size:"sm",icon:s.jsx(On,{className:"size-3"}),"aria-label":r("copy"),onClick:()=>{Rn(e).then(()=>Ae.add({title:r("copied")}))}})]})}function Ku({made:e,onDone:t}){const n=e.check.warnings.length;return s.jsxs("div",{"data-testid":"type-made",children:[s.jsx("p",{className:"mb-0 mt-0 text-sm font-semibold",children:r("typeMade",{id:e.id})}),s.jsx("p",{className:"mb-0 mt-3 text-xs text-fg-muted",children:r("typeMadeAt")}),s.jsx(tn,{text:e.dir,testId:"type-made-dir"}),s.jsx("p",{className:"mb-0 mt-3 text-xs text-fg-muted",children:r("typeMadePrompt")}),s.jsx(tn,{text:e.prompt,testId:"type-made-prompt"}),n?s.jsx("p",{className:"mb-0 mt-2 text-xs text-warning",children:r("typeCheckWarnings",{count:n})}):null,s.jsx("div",{className:"mt-4 flex justify-end",children:s.jsx(C,{size:"lg",variant:"primary","data-testid":"type-made-done",onClick:t,children:r("done")})})]})}function Vu(){const e=y(N=>N.makingType),[t,n]=u.useState(""),[a,o]=u.useState(""),[i,c]=u.useState("page"),[d,l]=u.useState("user"),[p,m]=u.useState(""),[h,f]=u.useState(""),[g,x]=u.useState(!1),[b,j]=u.useState(null);u.useEffect(()=>{e&&(n(""),o(""),c("page"),l("user"),m(""),f(""),j(null))},[e]);const v=()=>y.getState().setMakingType(!1),T=async N=>{if(N.preventDefault(),g)return;const E=p.trim();if(d==="project"&&!E.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(E)){f(r("needProjectFolder"));return}x(!0);const k=await cd({id:t,template:i,scope:d,...a.trim()?{name:a.trim()}:{},...d==="project"?{project:E}:{}});x(!1),"error"in k?f(k.error):j(k.made)};return s.jsx(ze,{open:e,onOpenChange:N=>!N&&v(),title:r("newType"),description:b?void 0:r("newTypeDescription"),children:b?s.jsx(Ku,{made:b,onDone:v}):s.jsxs("form",{onSubmit:N=>{T(N)},"data-testid":"new-type-form",children:[s.jsx(Ge,{label:r("typeId"),hint:r("typeIdHint"),children:s.jsx(he,{autoFocus:!0,required:!0,name:"id",value:t,maxLength:64,spellCheck:!1,"aria-label":r("typeId"),onChange:N=>n(N.target.value.toLowerCase()),className:"h-8"})}),s.jsx(Ge,{label:r("typeName"),children:s.jsx(he,{name:"name",value:a,maxLength:80,"aria-label":r("typeName"),onChange:N=>o(N.target.value),className:"h-8"})}),s.jsx(Ge,{label:r("typeTemplate"),hint:r(i==="page"?"templatePageHint":"templateDataHint"),children:s.jsx(ft,{"aria-label":r("typeTemplate"),value:i,onChange:c,options:[{value:"page",label:r("templatePage")},{value:"data",label:r("templateData")}]})}),s.jsx(Ge,{label:r("typeScope"),hint:r(d==="user"?"scopeUserHint":"scopeProjectHint"),children:s.jsx(ft,{"aria-label":r("typeScope"),value:d,onChange:l,options:[{value:"user",label:r("scopeUser")},{value:"project",label:r("scopeProject")}]})}),d==="project"?s.jsx(Ge,{label:r("projectFolder"),children:s.jsx(he,{name:"project",value:p,placeholder:r("projectFolderHint"),"aria-label":r("projectFolder"),onChange:N=>m(N.target.value),className:"h-8"})}):null,h?s.jsx("p",{role:"alert",className:"mb-0 mt-2 text-xs text-danger",children:h}):null,s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(C,{size:"lg",onClick:v,children:r("cancel")}),s.jsx(C,{size:"lg",type:"submit",variant:"primary",disabled:g||!t.trim(),children:r("create")})]})]})})}const qu={private:"siteTypePrivate",link:"siteTypeLink",site:"siteTypeSite"};function Wu({type:e}){const t=td(e),n=()=>{t.action!=="none"&&y.getState().setInstalling(t.open)};return s.jsxs("div",{"data-connected-site-type":e.id,"data-standing":e.standing,className:"flex min-w-0 flex-col gap-1.5 rounded-xl border border-line bg-surface p-3.5",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate font-semibold",children:e.name}),s.jsx("div",{className:"truncate text-xs text-fg-muted",children:e.id})]}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsxs(ae,{children:["v",e.version]}),s.jsx(ae,{children:r(qu[e.visibility])})]}),e.description?s.jsx("div",{className:"line-clamp-4 text-xs text-fg-muted",children:e.description}):null,s.jsx("div",{"data-testid":"site-type-publisher",className:"text-xs text-fg-subtle",children:r("siteTypeBy",{name:e.publisher.name??r("siteTypeUnnamedPublisher"),when:e.updatedAt?Be(e.updatedAt):""})}),e.standing==="update"&&e.local?s.jsx("div",{className:"text-xs text-fg-muted",children:r("siteTypeUpdateNote",{local:e.local.version??"?",id:e.local.id,version:e.version})}):null,e.standing==="clash"&&e.local?s.jsx("div",{className:"text-xs text-warning",children:r("siteTypeClashNote",{id:e.local.id})}):null,s.jsxs("div",{className:"mt-auto flex flex-wrap items-center gap-1.5 pt-1",children:[t.action==="install"?s.jsx(C,{size:"sm",variant:"primary",icon:s.jsx(Ke,{className:"size-3"}),"data-testid":"site-type-install",onClick:n,children:r("siteTypeInstallHere")}):t.action==="update"?s.jsx(C,{size:"sm",icon:s.jsx(yt,{className:"size-3"}),"data-testid":"site-type-update",onClick:n,children:r("siteTypeUpdateHere",{version:e.version})}):t.action==="install-as"?s.jsx(C,{size:"sm",icon:s.jsx(Ke,{className:"size-3"}),"data-testid":"site-type-install-as",onClick:n,children:r("siteTypeInstallAsOther")}):s.jsx("span",{"data-testid":"site-type-label",className:"text-xs text-fg-muted",children:e.standing==="published-here"?r("siteTypePublishedHere"):e.local&&e.local.id!==e.id?r("siteTypeInstalledAs",{id:e.local.id}):r("siteTypeInstalledHere")}),s.jsxs("a",{href:e.page,target:"_blank",rel:"noopener noreferrer","data-testid":"site-type-page",className:"ml-auto inline-flex items-center gap-1 text-xs",children:[s.jsx(vt,{className:"size-3"}),r("siteTypeOpenPage")]})]})]})}function Gu({site:e}){const t=y(o=>o.sitesLoading),n=t==="*"||t===e.remote;let a=e.host;try{a=new URL(e.host).host}catch{}return s.jsxs("section",{"data-connected-site":e.remote,className:"mt-6",children:[s.jsx("h2",{className:"mb-1 mt-0 min-w-0 break-all text-sm font-semibold",children:r("connectedSiteTitle",{name:e.remote,host:a})}),e.error?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{role:"alert","data-testid":"connected-site-error",className:"m-0 min-w-0 break-words text-xs text-danger",children:e.error}),s.jsx(C,{size:"sm",disabled:n,"data-testid":"connected-site-retry",onClick:()=>{et(e.remote)},children:n?r("loading"):r("connectedSiteRetry")})]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"mb-2 mt-0 text-xs text-fg-muted",children:[r("connectedSiteNote")," ",r("packageThirdParty")]}),e.types.length?s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3",children:e.types.map(o=>s.jsx(Wu,{type:o},o.uid))}):s.jsx("p",{className:"m-0 text-xs text-fg-subtle",children:r("connectedSiteEmpty")})]})]})}function Yu(){const e=y(a=>a.sites),t=y(a=>a.sitesError),n=y(a=>a.sitesLoading);return u.useEffect(()=>{et()},[]),t?s.jsxs("div",{"data-connected-sites":"",className:"mt-6 flex flex-wrap items-center gap-2",children:[s.jsx("p",{role:"alert",className:"m-0 text-xs text-danger",children:r("connectedSitesFailed",{error:t})}),s.jsx(C,{size:"sm",disabled:n!==null,onClick:()=>{et()},children:r("connectedSiteRetry")})]}):e?e.sites.length?s.jsx("div",{"data-connected-sites":"",children:e.sites.map(a=>s.jsx(Gu,{site:a},a.remote))}):s.jsx("p",{"data-connected-sites":"none",className:"mb-0 mt-6 text-xs text-fg-subtle",children:r("connectedSitesNone")}):s.jsx("p",{"data-connected-sites":"loading",className:"mb-0 mt-6 text-xs text-fg-subtle",children:r("connectedSitesLoading")})}function Xu({type:e}){const[t,n]=u.useState(!1);return!e.icon||t?s.jsx("span",{className:"grid size-8 shrink-0 place-items-center rounded-lg bg-surface-2 text-fg-muted",children:s.jsx(vi,{className:"size-4"})}):s.jsx("img",{src:H.typeIconUrl(e.id),alt:"",className:"size-8 shrink-0 rounded-lg",onError:()=>n(!0)})}function Zu({type:e}){return s.jsxs("div",{"data-type-id":e.id,"data-type-scope":e.scope,className:"flex min-w-0 flex-col gap-1.5 rounded-xl border border-line bg-surface p-3.5",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsx(Xu,{type:e}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-semibold",children:e.title}),s.jsx("div",{className:"truncate text-xs text-fg-muted",children:e.id})]}),s.jsx(Mn,{checked:e.enabled,"aria-label":r(e.enabled?"turnTypeOff":"turnTypeOn",{type:e.title}),onChange:t=>{dd(e,t)}})]}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.jsx(ae,{children:r(e.source==="installed"?"sourceInstalled":e.source==="builtin"?"sourceBuiltin":"sourceLocal")}),e.source==="local"||!e.source?s.jsx(ae,{children:e.scope}):null,s.jsx(ae,{children:e.runtime}),e.version?s.jsxs(ae,{children:["v",e.version]}):null,e.enabled?null:s.jsx(ae,{children:r("disabled")}),e.shadowedBy?s.jsx(ae,{children:r("shadowedBy",{root:e.shadowedBy})}):null]}),e.description?s.jsx("div",{className:"line-clamp-4 text-xs text-fg-muted",children:e.description}):null,e.capabilities?.length?s.jsx("div",{"data-testid":"type-capabilities",className:"text-xs text-fg-muted",children:r("typeCapabilities",{list:e.capabilities.join(", ")})}):null,e.source==="installed"?s.jsxs(s.Fragment,{children:[s.jsx("div",{"data-testid":"type-network",className:"text-xs text-fg-muted",children:e.network?.length?r("typeNetwork",{list:e.network.join(", ")}):r("noNetwork")}),e.installedFrom?s.jsx("div",{className:"break-all text-xs text-fg-subtle",children:r("installedFrom",{source:e.installedFrom})}):null]}):null,e.problems.length?s.jsxs("div",{className:"flex items-start gap-1 text-xs text-warning",children:[s.jsx(Ie,{className:"mt-px size-3.5 shrink-0"}),e.problems.join(" ")]}):null,ht(e)||e.source==="installed"?s.jsxs("div",{className:"mt-auto flex flex-wrap gap-1.5 pt-1",children:[ht(e)?s.jsx(C,{size:"sm",variant:"primary",icon:s.jsx(jt,{className:"size-3"}),onClick:()=>y.getState().setCreating(e),children:r("newOf",{type:e.title})}):null,e.source==="installed"?s.jsxs(s.Fragment,{children:[s.jsx(C,{size:"sm",icon:s.jsx(yt,{className:"size-3"}),"data-testid":"type-update",onClick:()=>y.getState().setInstalling({update:e.id}),children:r("updateType")}),s.jsx(C,{size:"sm",icon:s.jsx(mt,{className:"size-3"}),"data-testid":"type-uninstall",onClick:()=>{window.confirm(r("uninstallConfirm",{type:e.title}))&&fd(e)},children:r("uninstallType")})]}):null]}):null]})}function sr({types:e}){return s.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3",children:e.map(t=>s.jsx(Zu,{type:t},`${t.root}:${t.id}`))})}function Ju({project:e}){return s.jsxs("section",{"data-project":e.dir,className:"mt-6",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx("h2",{className:"m-0 min-w-0 break-all text-sm font-semibold",children:r("projectTypes",{dir:e.dir})}),s.jsx(C,{size:"sm",variant:e.trusted?"secondary":"primary",icon:e.trusted?void 0:s.jsx(ji,{className:"size-3"}),onClick:()=>{md(e.dir,!e.trusted)},children:r(e.trusted?"untrustProject":"trustProject")})]}),e.trusted?null:s.jsx("p",{className:"mb-2 mt-0 text-xs text-warning",children:r("projectUntrusted")}),s.jsx(sr,{types:e.types})]})}function Qu(){const e=y(a=>a.types);if(e===null)return s.jsx("p",{className:"py-8 text-fg-muted",children:r("loading")});const t=e.roots.map(a=>`${a.dir} (${a.scope})`).join(", "),n=e.roots.find(a=>a.scope==="user")?.dir;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-3",children:[s.jsx("p",{className:"m-0 min-w-0 break-words text-xs text-fg-muted",children:n?r("typesExplain",{user:n}):r("typesExplainNoUser")}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(C,{size:"md","data-testid":"install-type",icon:s.jsx(Ke,{className:"size-3"}),onClick:()=>y.getState().setInstalling({}),children:r("installType")}),s.jsx(C,{size:"md","data-testid":"new-type",icon:s.jsx(jt,{className:"size-3"}),onClick:()=>y.getState().setMakingType(!0),children:r("newType")})]})]}),t?s.jsx("p",{className:"mb-3 mt-0 break-all text-xs text-fg-subtle",children:r("typeRoots",{roots:t})}):null,e.types.length?s.jsx(sr,{types:e.types}):s.jsx(Ve,{title:r("noTypes")}),(e.projects??[]).map(a=>s.jsx(Ju,{project:a},a.dir)),s.jsx(Yu,{})]})}async function ep(e,t,n){if(t)try{await n.forgetKeys(t)}catch{}try{const a=await n.fetch(e,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json",accept:"application/json"},body:"{}"});if(!a.ok&&a.status!==401)throw new Error(`HTTP ${a.status}`);n.go(Da(await a.json().catch(()=>null))??await n.accessLogout())}catch(a){n.failed(a instanceof Error?a.message:String(a))}}async function tp(e,t){await ep(e,t,{forgetKeys:gc,fetch:(n,a)=>fetch(n,a),accessLogout:async()=>(await nr()).accessLogout,go:n=>{n?location.href=n:location.reload()},failed:n=>Ae.add({title:r("signOutFailed",{error:n})})})}let sn=null;function nr(){return sn??=fetch("/api/open-artifacts.auth.me",{credentials:"same-origin",cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>({access:dc(e),accessLogout:za(e)}),()=>({access:!1,accessLogout:null})),sn}function nn({id:e,name:t,avatar:n,size:a=28}){const[o,i]=u.useState(!1),c={width:a,height:a,fontSize:Math.round(a*.4)};return n&&!o?s.jsx("img",{src:n,alt:"",referrerPolicy:"no-referrer",className:"shrink-0 rounded-full bg-surface-2 object-cover",style:c,onError:()=>i(!0)}):s.jsx("span",{"aria-hidden":!0,className:"grid shrink-0 place-items-center rounded-full font-semibold text-white",style:{...c,background:Xo(`user${e}`)},children:Yo(t)})}function sp(e){Aa(e,location.origin)?window.open(e,"_blank","noopener,noreferrer"):location.href=e}function np({cloud:e}){const t=e.user,n=Ia(e.site,"account-menu"),[a,o]=u.useState(!1);if(u.useEffect(()=>{if(!t)return;let i=!0;return nr().then(c=>i&&o(c.access)),()=>{i=!1}},[t]),!t){const i=`${location.pathname}${location.search}`;return s.jsx(C,{size:"lg",variant:"ghost",className:"gap-1.5 px-2 font-normal",icon:s.jsx(mi,{className:"size-4"}),onClick:()=>location.href=cc(e.signInUrl,i,location.origin),children:s.jsx("span",{className:"max-sm:hidden",children:r("signIn")})})}return s.jsxs(is,{align:"end",trigger:s.jsx("button",{type:"button","aria-label":r("accountOf",{name:t.name}),title:t.email?`${t.name} · ${t.email}`:t.name,className:"inline-flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:bg-hover focus-visible:outline-2 focus-visible:outline-accent data-[popup-open]:bg-hover",children:s.jsx(nn,{id:t.id,name:t.name,avatar:t.avatar,size:26})}),children:[s.jsx(Go,{children:s.jsxs("span",{className:"flex max-w-64 items-center gap-2.5 py-0.5",children:[s.jsx(nn,{id:t.id,name:t.name,avatar:t.avatar,size:32}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-[13px] font-medium text-fg",children:t.name}),t.email?s.jsx("span",{className:"block truncate text-xs",children:t.email}):null]})]})}),s.jsx($e,{}),n.map(i=>s.jsx(Ne,{icon:s.jsx(vt,{className:"size-3.5"}),onSelect:()=>sp(i.href),children:i.label},`${i.label} ${i.href}`)),n.length>0?s.jsx($e,{}):null,s.jsx(Ne,{icon:s.jsx(hi,{className:"size-3.5"}),onSelect:()=>{tp(e.signOutUrl,Oa(e.user))},children:a?r("signOutAccess"):r("signOut")})]})}function ap({site:e,compact:t=!1}){const n=ps(e)?.brand,[a,o]=u.useState(!1);if(!n)return null;const i=n.logoUrl&&!a?s.jsx("img",{src:n.logoUrl,alt:n.name?"":"logo",referrerPolicy:"no-referrer",className:t?"h-5 w-auto shrink-0":"h-6 w-auto shrink-0",onError:()=>o(!0)}):null;return s.jsxs("span",{"data-site-brand":"",className:"inline-flex min-w-0 items-center gap-1.5",children:[i,n.name?s.jsx("span",{className:t?"truncate text-[13px] font-medium text-fg-muted max-sm:hidden":"truncate",children:n.name}):null]})}function rp({site:e}){const t=Ia(e,"home");return t.length===0?null:s.jsx("nav",{"aria-label":"Site links",className:"mb-4 flex flex-wrap gap-x-4 gap-y-1 text-[13px]",children:t.map(n=>{const a=Aa(n.href,location.origin);return s.jsxs("a",{href:n.href,...a?{target:"_blank",rel:"noopener noreferrer"}:{},className:"inline-flex items-center gap-1 text-accent hover:underline",children:[n.label,a?s.jsx(vt,{"aria-hidden":!0,className:"size-3"}):null]},`${n.label} ${n.href}`)})})}function op(){const e=y(a=>a.types),t=e?Pc(e.types):null,n=s.jsx(C,{size:"lg",variant:"primary","data-testid":"new-artifact",icon:s.jsx(jt,{className:"size-3.5"}),disabled:!t,onClick:()=>t&&y.getState().setCreating(t),children:r("newArtifact")});return t||!e?n:s.jsx(ei,{label:r("cannotCreateYet"),children:s.jsx("span",{tabIndex:0,children:n})})}function ip(){const e=y(o=>o.tab),t=y(o=>o.error),n=re.cloud,a=n?.site?.brand?.name;return u.useEffect(()=>{a&&(document.title=a)},[a]),u.useEffect(()=>{lt(),n||(Le(),Zo());const o=Gc(),i=wd();return()=>{o(),i()}},[]),s.jsxs("div",{className:"h-full overflow-auto bg-canvas text-fg",children:[s.jsxs("div",{className:"mx-auto max-w-[1040px] px-4 pb-12 pt-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"mb-1 mt-0 text-xl font-semibold",children:n?.site?.brand?s.jsx(ap,{site:n.site}):r("homeTitle")}),s.jsx("p",{className:"mb-5 mt-0 text-fg-muted",children:r(n?"homeSubCloud":"homeSub")}),n?s.jsx(rp,{site:n.site}):null]}),n?s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[n.user?s.jsx(Ou,{}):null,s.jsx(np,{cloud:n})]}):s.jsx(op,{})]}),n?null:s.jsx(Jo,{}),t?s.jsxs("p",{role:"alert",className:"mb-3 flex items-center gap-1.5 text-xs text-danger",children:[s.jsx(Ie,{className:"size-3.5"}),t]}):null,n&&re.typePage?s.jsx(Ad,{detail:re.typePage}):n?n.user?s.jsx(Lu,{}):s.jsx(Yt,{}):s.jsx(Ca,{value:e,onChange:o=>y.getState().setTab(o),className:"[&>[role=tabpanel]]:overflow-visible [&>[role=tabpanel]]:pt-4 [&_[role=tab][aria-selected=true]]:bg-hover [&_[role=tab][aria-selected=true]]:text-fg",items:[{value:"artifacts",label:r("artifacts"),content:s.jsx(Yt,{})},{value:"types",label:r("types"),content:s.jsx(Qu,{})},{value:"settings",label:r("settings"),content:s.jsxs(s.Fragment,{children:[s.jsx(tr,{}),s.jsx(Qo,{})]})}]})]}),s.jsx(Fu,{}),n?null:s.jsx(Vu,{}),n?null:s.jsx(Bu,{}),s.jsx(Hu,{}),s.jsx(Uu,{}),n?s.jsx(zu,{}):null]})}document.documentElement.lang=Xe;ti.createRoot(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(si,{children:s.jsx(Wl,{children:s.jsx(ip,{})})})}));export{Zl as O,Pa as S,Xl as _,dp as r,cp as s};
|