progon-agent 1.4.0 → 1.5.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.
Files changed (54) hide show
  1. package/dist/supervisor/cli.js +44 -44
  2. package/extension-bundle.json +3 -3
  3. package/extension-dist/background/background.js +88 -89
  4. package/extension-dist/card/card.css +1 -1
  5. package/extension-dist/card/card.html +8 -9
  6. package/extension-dist/card/card.js +3 -9
  7. package/extension-dist/chunks/shared-73iHxv_g.js +1 -0
  8. package/extension-dist/chunks/shared-BRaGK72I.css +1 -0
  9. package/extension-dist/chunks/shared-Beih6ywL.js +1 -0
  10. package/extension-dist/chunks/shared-BgEO6Nif.js +39 -0
  11. package/extension-dist/chunks/shared-ByZxg79I.js +1 -0
  12. package/extension-dist/chunks/shared-C7IWMwZY.js +1 -0
  13. package/extension-dist/chunks/shared-CFEBqIm7.js +21 -0
  14. package/extension-dist/chunks/shared-CKtbh_44.js +199 -0
  15. package/extension-dist/chunks/shared-CSBwVLDL.js +1 -0
  16. package/extension-dist/chunks/shared-CeI71eLt.js +134 -0
  17. package/extension-dist/chunks/shared-CfjrOLG1.js +336 -0
  18. package/extension-dist/chunks/shared-CgUMEof2.js +1 -0
  19. package/extension-dist/chunks/{shared-BgsXTfSV.js → shared-CwsTFlbT.js} +1 -1
  20. package/extension-dist/chunks/shared-D-c-eSoI.js +1 -0
  21. package/extension-dist/chunks/shared-DXp1f_Ub.css +1 -0
  22. package/extension-dist/chunks/shared-RcZD4SR-.js +1 -0
  23. package/extension-dist/chunks/shared-lM00HeT6.js +98 -0
  24. package/extension-dist/chunks/shared-t8TH2XkL.js +239 -0
  25. package/extension-dist/content/content.css +1 -1
  26. package/extension-dist/content/content.js +216 -231
  27. package/extension-dist/manifest.json +29 -30
  28. package/extension-dist/offscreen/offscreen.html +2 -3
  29. package/extension-dist/offscreen/offscreen.js +1 -1
  30. package/extension-dist/popup/popup.html +8 -8
  31. package/extension-dist/popup/popup.js +3 -3
  32. package/extension-dist/sidepanel/sidepanel.html +11 -10
  33. package/extension-dist/sidepanel/sidepanel.js +1 -1
  34. package/extension-dist/workspace/workspace.html +11 -11
  35. package/extension-dist/workspace/workspace.js +46 -83
  36. package/package.json +2 -2
  37. package/extension-dist/chunks/shared-B4EisBUi.js +0 -1
  38. package/extension-dist/chunks/shared-B7QwPadt.js +0 -98
  39. package/extension-dist/chunks/shared-BEB011Tg.js +0 -1
  40. package/extension-dist/chunks/shared-BQF2LG1p.js +0 -377
  41. package/extension-dist/chunks/shared-BpcMA-xb.js +0 -135
  42. package/extension-dist/chunks/shared-BvwA-cm2.css +0 -1
  43. package/extension-dist/chunks/shared-BwS34Mep.js +0 -111
  44. package/extension-dist/chunks/shared-CAKh7jnb.css +0 -1
  45. package/extension-dist/chunks/shared-CCOKrUJ3.js +0 -1
  46. package/extension-dist/chunks/shared-COCbj3mN.js +0 -1
  47. package/extension-dist/chunks/shared-Co5HfH-n.js +0 -1
  48. package/extension-dist/chunks/shared-Cs6uBr12.js +0 -1
  49. package/extension-dist/chunks/shared-D7SUgUlB.js +0 -1
  50. package/extension-dist/chunks/shared-DGDE0AeD.js +0 -1
  51. package/extension-dist/chunks/shared-DjlOTYdL.js +0 -1
  52. package/extension-dist/chunks/shared-LK5ScAJA.js +0 -227
  53. package/extension-dist/chunks/shared-_8sSdh22.js +0 -21
  54. package/extension-dist/chunks/shared-sY-POWsC.js +0 -51
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Progon",
4
- "version": "1.9.0",
4
+ "version": "1.10.0",
5
5
  "description": "Progon — visual QA tool with overlay for bug tracking, test recording, and risk zone highlighting",
6
6
  "minimum_chrome_version": "125",
7
7
  "permissions": [
@@ -118,21 +118,20 @@
118
118
  {
119
119
  "resources": [
120
120
  "card/*",
121
- "chunks/shared-B4EisBUi.js",
122
- "chunks/shared-B7QwPadt.js",
123
- "chunks/shared-BEB011Tg.js",
124
- "chunks/shared-BpcMA-xb.js",
125
- "chunks/shared-BwS34Mep.js",
126
- "chunks/shared-CAKh7jnb.css",
127
- "chunks/shared-COCbj3mN.js",
128
- "chunks/shared-Co5HfH-n.js",
129
- "chunks/shared-Cs6uBr12.js",
130
- "chunks/shared-D7SUgUlB.js",
131
- "chunks/shared-DGDE0AeD.js",
132
- "chunks/shared-DjlOTYdL.js",
121
+ "chunks/shared-BRaGK72I.css",
122
+ "chunks/shared-Beih6ywL.js",
123
+ "chunks/shared-ByZxg79I.js",
124
+ "chunks/shared-C7IWMwZY.js",
125
+ "chunks/shared-CKtbh_44.js",
126
+ "chunks/shared-CSBwVLDL.js",
127
+ "chunks/shared-CeI71eLt.js",
128
+ "chunks/shared-CgUMEof2.js",
129
+ "chunks/shared-D-c-eSoI.js",
133
130
  "chunks/shared-Dk6zuyaK.css",
134
- "chunks/shared-LK5ScAJA.js",
135
- "chunks/shared-hePW80VL.js"
131
+ "chunks/shared-RcZD4SR-.js",
132
+ "chunks/shared-hePW80VL.js",
133
+ "chunks/shared-lM00HeT6.js",
134
+ "chunks/shared-t8TH2XkL.js"
136
135
  ],
137
136
  "matches": [
138
137
  "<all_urls>"
@@ -142,23 +141,23 @@
142
141
  {
143
142
  "resources": [
144
143
  "workspace/*",
145
- "chunks/shared-B4EisBUi.js",
146
- "chunks/shared-B7QwPadt.js",
147
- "chunks/shared-BQF2LG1p.js",
148
- "chunks/shared-BgsXTfSV.js",
149
- "chunks/shared-BpcMA-xb.js",
150
- "chunks/shared-BvwA-cm2.css",
151
- "chunks/shared-BwS34Mep.js",
152
- "chunks/shared-CAKh7jnb.css",
153
- "chunks/shared-CCOKrUJ3.js",
154
- "chunks/shared-Co5HfH-n.js",
155
- "chunks/shared-Cs6uBr12.js",
156
- "chunks/shared-D7SUgUlB.js",
157
- "chunks/shared-DGDE0AeD.js",
144
+ "chunks/shared-73iHxv_g.js",
145
+ "chunks/shared-BRaGK72I.css",
146
+ "chunks/shared-Beih6ywL.js",
147
+ "chunks/shared-BgEO6Nif.js",
148
+ "chunks/shared-ByZxg79I.js",
149
+ "chunks/shared-CKtbh_44.js",
150
+ "chunks/shared-CSBwVLDL.js",
151
+ "chunks/shared-CeI71eLt.js",
152
+ "chunks/shared-CfjrOLG1.js",
153
+ "chunks/shared-CgUMEof2.js",
154
+ "chunks/shared-CwsTFlbT.js",
155
+ "chunks/shared-DXp1f_Ub.css",
158
156
  "chunks/shared-Dk6zuyaK.css",
159
- "chunks/shared-LK5ScAJA.js",
157
+ "chunks/shared-RcZD4SR-.js",
160
158
  "chunks/shared-hePW80VL.js",
161
- "chunks/shared-sY-POWsC.js"
159
+ "chunks/shared-lM00HeT6.js",
160
+ "chunks/shared-t8TH2XkL.js"
162
161
  ],
163
162
  "matches": [
164
163
  "<all_urls>"
@@ -4,9 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <title>Progon Offscreen</title>
6
6
  <script type="module" crossorigin src="../offscreen/offscreen.js"></script>
7
- <link rel="modulepreload" crossorigin href="../chunks/shared-B7QwPadt.js">
8
- <link rel="modulepreload" crossorigin href="../chunks/shared-BgsXTfSV.js">
9
- <link rel="modulepreload" crossorigin href="../chunks/shared-COCbj3mN.js">
7
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
8
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CwsTFlbT.js">
10
9
  </head>
11
10
  <body>
12
11
  </body>
@@ -1 +1 @@
1
- import{t as e}from"../chunks/shared-B7QwPadt.js";import"../chunks/shared-BgsXTfSV.js";import{o as t}from"../chunks/shared-COCbj3mN.js";var n=2e4,r=e(`pgs-6c97a01773`),i={type:t};setInterval(()=>{chrome.runtime.sendMessage(i).catch(e=>{r.warn(`pgm-45c13bd730`,{error:e instanceof Error?e.message:String(e)})})},n);
1
+ import{t as e}from"../chunks/shared-lM00HeT6.js";import"../chunks/shared-CwsTFlbT.js";var t=2e4,n=`AGENT_RUNTIME_HEARTBEAT`,r=e(`pgs-6c97a01773`),i={type:n};setInterval(()=>{chrome.runtime.sendMessage(i).catch(e=>{r.warn(`pgm-45c13bd730`,{error:e instanceof Error?e.message:String(e)})})},t);
@@ -5,14 +5,14 @@
5
5
  <title>Progon</title>
6
6
  <script type="module" crossorigin src="../popup/popup.js"></script>
7
7
  <link rel="modulepreload" crossorigin href="../chunks/shared-hePW80VL.js">
8
- <link rel="modulepreload" crossorigin href="../chunks/shared-B7QwPadt.js">
9
- <link rel="modulepreload" crossorigin href="../chunks/shared-LK5ScAJA.js">
10
- <link rel="modulepreload" crossorigin href="../chunks/shared-sY-POWsC.js">
11
- <link rel="modulepreload" crossorigin href="../chunks/shared-_8sSdh22.js">
12
- <link rel="modulepreload" crossorigin href="../chunks/shared-D7SUgUlB.js">
13
- <link rel="modulepreload" crossorigin href="../chunks/shared-CCOKrUJ3.js">
14
- <link rel="modulepreload" crossorigin href="../chunks/shared-BEB011Tg.js">
15
- <link rel="stylesheet" crossorigin href="../chunks/shared-CAKh7jnb.css">
8
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
9
+ <link rel="modulepreload" crossorigin href="../chunks/shared-t8TH2XkL.js">
10
+ <link rel="modulepreload" crossorigin href="../chunks/shared-C7IWMwZY.js">
11
+ <link rel="modulepreload" crossorigin href="../chunks/shared-73iHxv_g.js">
12
+ <link rel="modulepreload" crossorigin href="../chunks/shared-BgEO6Nif.js">
13
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CFEBqIm7.js">
14
+ <link rel="modulepreload" crossorigin href="../chunks/shared-RcZD4SR-.js">
15
+ <link rel="stylesheet" crossorigin href="../chunks/shared-BRaGK72I.css">
16
16
  <link rel="stylesheet" crossorigin href="../popup/popup.css">
17
17
  </head>
18
18
  <body>
@@ -1,11 +1,11 @@
1
- import{r as e}from"../chunks/shared-hePW80VL.js";import{$i as t,$n as n,A as r,B as i,Bn as a,Bo as o,Ci as s,D as c,Dn as l,E as u,En as d,Er as f,Fr as p,G as m,Gn as h,Gr as g,Hr as _,Io as v,Ir as y,Ji as b,Jn as x,Jr as S,Kr as C,L as w,Oi as T,P as ee,Po as E,Pr as D,Pt as te,Qn as ne,Qr as O,Qt as re,R as ie,Si as k,Ui as ae,Un as A,Ur as j,V as oe,Vn as se,Vo as M,W as ce,Wn as le,Xn as ue,Xr as de,Xt as fe,Y as pe,Yr as me,Zr as he,Zt as ge,aa as _e,ar as ve,br as ye,ca as be,ci as N,dn as xe,ea as P,ei as Se,en as Ce,fa as F,fn as we,fr as Te,gn as Ee,gr as De,hr as I,i as Oe,ia as ke,ii as Ae,in as je,ji as Me,jr as Ne,l as Pe,la as Fe,li as L,mn as Ie,n as Le,oa as Re,oi as ze,on as Be,pn as Ve,qa as He,qi as Ue,qn as We,qr as Ge,r as Ke,ra as qe,si as Je,t as Ye,ta as Xe,ua as R,ut as Ze,xi as z,z as Qe,zn as $e,zr as B}from"../chunks/shared-LK5ScAJA.js";import{t as V}from"../chunks/shared-B7QwPadt.js";import{a as et,c as tt,d as nt,f as rt,i as it,l as at,n as ot,o as st,p as ct,r as lt,s as ut,t as dt,u as ft}from"../chunks/shared-_8sSdh22.js";import{C as pt,a as mt,b as ht,c as gt,d as _t,f as vt,g as yt,h as bt,i as xt,l as St,m as Ct,n as wt,o as Tt,p as Et,r as Dt,s as Ot,t as kt,u as At,v as jt,w as Mt,x as Nt,y as Pt}from"../chunks/shared-D7SUgUlB.js";import{C as Ft,D as It,S as Lt,T as Rt,a as zt,b as Bt,g as Vt,k as Ht,n as Ut,o as Wt,r as Gt,x as Kt,y as qt}from"../chunks/shared-sY-POWsC.js";import{t as Jt}from"../chunks/shared-CCOKrUJ3.js";import{t as Yt}from"../chunks/shared-BEB011Tg.js"
1
+ import{r as e}from"../chunks/shared-hePW80VL.js";import{$a as t,$i as n,$t as r,Ai as i,B as a,Bi as o,Bn as s,Ca as c,Dn as l,Ei as u,F as d,Ft as f,G as p,Gn as m,Gr as h,H as g,Ha as _,Hi as v,Hn as y,Ia as b,Ir as x,Ja as S,Ji as C,Jr as ee,K as te,Ki as w,Kn as T,Lo as E,Lr as D,Ls as O,Nr as k,Ns as ne,O as re,Oi as A,On as ie,Or as ae,Qa as j,Qn as oe,Qt as se,R as ce,Ri as M,Rr as le,Rs as ue,Sr as de,Ui as fe,Un as pe,V as me,Va as he,Vi as ge,Vn as _e,Vr as N,Wi as ve,Wr as ye,X as be,Xn as xe,Ya as Se,Yn as Ce,Za as we,Zt as Te,_a as Ee,_n as De,_r as P,a as Oe,ai as ke,an as Ae,bi as je,d as Me,dt as Ne,eo as Pe,er as Fe,fn as Ie,ga as F,gi as Le,hi as Re,hn as ze,i as Be,ia as I,io as L,j as Ve,js as He,li as Ue,mn as We,mr as Ge,na as Ke,no as qe,o as Je,oo as R,pn as Ye,qa as Xe,qn as Ze,r as Qe,ra as z,ro as $e,sn as et,sr as tt,ta as nt,tn as rt,tr as it,va as at,vi as ot,vr as st,wi as ct,xi as lt,yi as ut,z as dt,zi as B}from"../chunks/shared-t8TH2XkL.js";import{V as ft,t as V}from"../chunks/shared-lM00HeT6.js";import{t as pt}from"../chunks/shared-C7IWMwZY.js";import{i as mt,r as ht,t as gt}from"../chunks/shared-73iHxv_g.js";import{a as _t,c as vt,d as yt,f as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"../chunks/shared-CFEBqIm7.js";import{a as kt,c as At,d as jt,f as Mt,g as Nt,i as Pt,l as Ft,m as It,n as Lt,p as Rt,t as zt,u as Bt}from"../chunks/shared-BgEO6Nif.js";import{a as Vt,b as Ht,c as Ut,d as Wt,f as Gt,g as Kt,h as qt,i as Jt,l as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an,x as on,y as sn}from"../chunks/shared-RcZD4SR-.js"
2
2
  /**
3
3
  * @license lucide-react v0.574.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
7
  */
8
- ;var Xt=N(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Zt=N(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),Qt=N(`log-out`,[[`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`}]]),$t=N(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),en=N(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),tn=N(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),H=/* @__PURE__ */ e(b(),1),U=Ue()
8
+ ;var cn=z(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),ln=z(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),un=z(`log-out`,[[`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`}]]),dn=z(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),fn=z(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),pn=z(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),H=/* @__PURE__ */ e(_(),1),U=he()
9
9
  /**
10
10
  * @license lucide-react v0.574.0 - ISC
11
11
  *
@@ -36,4 +36,4 @@ import{r as e}from"../chunks/shared-hePW80VL.js";import{$i as t,$n as n,A as r,B
36
36
  * This source code is licensed under the ISC license.
37
37
  * See the LICENSE file in the root directory of this source tree.
38
38
  */
39
- ;function nn({off:e}){let{t}=z();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`mr-auto flex items-center gap-2 text-body-md font-semibold tracking-(--tracking-brand) text-fg-primary`,children:[/* @__PURE__ */ (0,U.jsx)(Kt,{className:j(`size-5 [transition:filter_var(--motion-medium)_var(--ease-out),opacity_var(--motion-medium)_var(--ease-out)]`,e&&`opacity-50 grayscale`)}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.brand`)})]})}function rn({children:e}){return/* @__PURE__ */ (0,U.jsx)(`header`,{className:`flex h-12 flex-none items-center gap-1 border-b border-stroke-light bg-(--color-bg-window-header) pr-2 pl-3.5`,children:e})}function an({children:e,className:t}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:j(`grid min-h-0 flex-1 grid-cols-1 content-start gap-4 overflow-y-auto px-3 pt-3 pb-4 [scrollbar-width:thin]`,t),children:e})}function on(){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`popup-loading`,children:[/* @__PURE__ */ (0,U.jsxs)(rn,{children:[/* @__PURE__ */ (0,U.jsx)(nn,{off:!1}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5 w-9 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`ml-2 size-7 rounded-md`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`ml-2 size-6 rounded-full`})]}),/* @__PURE__ */ (0,U.jsx)(an,{children:/* @__PURE__ */ (0,U.jsx)(sn,{})})]})}function sn(){let{t:e}=z();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":e(`shell.loading`),className:`grid gap-2.5 rounded-lg border border-stroke bg-surface-card pt-3 pr-3 pb-3.5 pl-3.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`size-8.5 rounded-md`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid flex-1 gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`h-2.5 w-12`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-3.5 w-[62%]`})]})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:/* @__PURE__ */ (0,U.jsx)(I,{className:`h-3 w-[60%]`})}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5.5 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5.5 w-20.5 rounded-full`})]})]}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`h-2.5 w-37.5`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8.5 w-21 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8.5 w-27.5 rounded-full`})]})]})]})}function cn({value:e,options:t,onChange:n,ariaLabel:r,size:i,fullWidth:a,className:o}){return/* @__PURE__ */ (0,U.jsx)(A,{value:e,options:t,onValueChange:n,"aria-label":r,size:i,fullWidth:a,className:o})}var ln=V(`pgs-4d9951d24e`);function un(e){let t=0,n=Promise.resolve(),r=null;async function i(n,i,a){if(n!==t)return;if(e.signedInUserId()!==a){ln.warn(`pgm-4b072233de`,{locale:i});return}let o=new AbortController;r=o;try{await e.save(i,o.signal)}catch(r){if(o.signal.aborted){ln.info(`pgm-7aaa461c83`,{locale:i});return}if(n===t){e.onFailure(i,r);return}ln.warn(`pgm-f93a88619e`,{locale:i,error:r})}finally{r=null}}return{write(e,r){t+=1;let a=t;n=n.then(()=>i(a,e,r)).catch(t=>{ln.error(`pgm-1491eca8c6`,{locale:e,error:t})})},discardPending(){t+=1,r==null||r.abort()}}}var dn=V(`pgs-b78fd5fe0f`),fn=(0,H.createContext)(null);function pn({user:e,children:t}){let{t:n}=z(),r=D(),[i]=(0,H.useState)(()=>gn(e.id));return(0,H.useEffect)(()=>{i.setFailureReport((e,t)=>{dn.error(`pgm-0f28f45227`,{locale:e,error:t instanceof Error?t.message:String(t)}),r.show({id:`popup-profile-language`,variant:`error`,message:n(`popup.language.profileSaveFailed`),action:{label:n(`common.retry`),onAction:()=>i.retryShownLocale()}})})}),(0,H.useEffect)(()=>(i.start(),()=>i.end()),[i]),/* @__PURE__ */ (0,U.jsx)(fn,{value:i.profileLocale,children:t})}function mn(){return(0,H.useContext)(fn)}function hn(){let e=(0,H.useContext)(fn);if(e===null)throw Error(`useSignedInProfileLocale() is used outside the signed-in popup`);return e}function gn(e){let t=!1,n=null,r=un({save:async(e,t)=>{await R.preferences.update({locale:e},{signal:t})},signedInUserId:()=>t?e:null,onFailure:(e,t)=>{if(n===null)throw Error(`A profile language write failed before the popup was rendered`);n(e,t)}});return{profileLocale:{write:t=>r.write(t,e),discardPending:()=>r.discardPending()},setFailureReport:e=>{n=e},retryShownLocale:()=>{t&&r.write(Xe(),e)},start:()=>{t=!0},end:()=>{t=!1,r.discardPending()}}}function _n(e){let t=ke(e);return(0,H.useSyncExternalStore)(t.subscribe,t.getState)}var vn=V(`pgs-520a54a8e3`);function W(e){let t=_n(e);if(t.status===`failed`)throw t.error;return t.status===`ready`?t.value:void 0}function yn(){let{t:e}=z(),t=D();return(0,H.useCallback)(function n(r){r.run().catch(i=>{vn.error(r.log.message,{...r.log.context,error:i instanceof Error?i.message:String(i)}),t.show({id:r.id,variant:`error`,message:r.message,detail:r.detail,action:{label:e(`common.retry`),onAction:()=>n(r)}})})},[e,t])}function G(){let{t:e}=z(),t=yn();return(0,H.useCallback)((n,r)=>t({id:`setting-${n}`,run:()=>_e(n,r),log:{message:`A setting was not stored`,context:{key:n}},message:e(`popup.settings.saveFailed`)}),[e,t])}function bn({size:e,fullWidth:t}){let{t:n}=z(),r=yn(),i=mn();return/* @__PURE__ */ (0,U.jsx)(cn,{value:Xe(),options:He.map(e=>({value:e,label:n(`common.languageNames.${e}`)})),onChange:e=>r({id:`popup-language`,run:async()=>{await qe(e)!==`superseded`&&(i==null||i.write(e))},log:{message:`The language was not switched or not stored`,context:{locale:e}},message:n(`popup.settings.saveFailed`)}),ariaLabel:n(`popup.languageGroup`),size:e,fullWidth:t})}function xn(){let{t:e}=z();return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:/* @__PURE__ */ (0,U.jsx)(Bt,{subtitle:e(`shell.signIn.subtitlePopup`),footer:/* @__PURE__ */ (0,U.jsx)(bn,{size:`sm`})})})}var Sn=V(`pgs-d05703aaa3`);function Cn({user:e}){let{t}=z(),n=D(),[i,a]=(0,H.useState)(!1),o=hn(),s=`${e.firstName} ${e.lastName}`;return/* @__PURE__ */ (0,U.jsxs)(c,{label:t(`popup.header.account`,{name:s}),align:`end`,className:`w-59`,trigger:/* @__PURE__ */ (0,U.jsx)(p,{"aria-label":t(`popup.header.account`,{name:s}),icon:/* @__PURE__ */ (0,U.jsx)(Jt,{firstName:e.firstName,lastName:e.lastName,email:e.email,size:`sm`,unknownLabel:t(`popup.header.unknownUser`)}),"data-testid":`popup-account`}),children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-px px-2.5 py-2`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`text-body-sm font-semibold text-fg-primary`,children:s}),/* @__PURE__ */ (0,U.jsxs)(`small`,{className:`text-xs text-fg-muted`,children:[e.email,` \u00B7 `,e.company.name]})]}),/* @__PURE__ */ (0,U.jsx)(ee,{}),/* @__PURE__ */ (0,U.jsx)(r,{label:t(`popup.header.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onSelect:()=>T()}),/* @__PURE__ */ (0,U.jsx)(ee,{}),/* @__PURE__ */ (0,U.jsx)(r,{label:t(`popup.header.signOut`),icon:/* @__PURE__ */ (0,U.jsx)(Qt,{"aria-hidden":`true`}),tone:`danger`,disabled:i,onSelect:()=>{i||(a(!0),o.discardPending(),R.auth.logout().catch(e=>{Sn.error(`pgm-4db83b7ea3`,{error:e instanceof Error?e.message:String(e)}),n.show({id:`popup-sign-out`,variant:`error`,message:t(`popup.header.signOutFailed`)})}).finally(()=>a(!1)))},"data-testid":`popup-sign-out`})]})}function wn({enabled:e}){let{t}=z(),n=yn();return/* @__PURE__ */ (0,U.jsx)(L,{relationship:`description`,content:t(e?`popup.header.switchOn`:`popup.header.switchOff`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex`,children:/* @__PURE__ */ (0,U.jsx)(Vt,{"aria-label":t(`popup.header.switchLabel`),checked:e,onChange:e=>n({id:`popup-power-switch`,run:()=>_e(`enabled`,e),log:{message:`The extension switch was not stored`,context:{enabled:e}},message:t(`popup.header.switchFailed`),detail:t(`popup.header.switchFailedDetail`)}),className:`p-1.5`,"data-testid":`popup-power-switch`})})})}function Tn({user:e,onOpenSettings:t,notificationCounts:n,onOpenNotifications:r}){let{t:i}=z(),a=W(`enabled`);return/* @__PURE__ */ (0,U.jsxs)(rn,{children:[/* @__PURE__ */ (0,U.jsx)(nn,{off:a===!1}),a===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(wn,{enabled:a}),/* @__PURE__ */ (0,U.jsx)(ut,{host:`popup`,t:i,counts:a===!1?null:n,onClick:r}),/* @__PURE__ */ (0,U.jsx)(L,{relationship:`label`,content:i(`popup.header.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(p,{icon:/* @__PURE__ */ (0,U.jsx)(ct,{"aria-hidden":`true`}),onClick:t,"data-testid":`popup-open-settings`})}),/* @__PURE__ */ (0,U.jsx)(Cn,{user:e})]})}var En=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:u,disabled:f,setTouched:p,setFocused:m,validationMode:h,validation:g}=Pe(),{labelId:_}=Oe(),v=Nt(),y=v.useState(`selectionMode`),b=v.useState(`disabled`),x=v.useState(`readOnly`),S=v.useState(`required`),C=v.useState(`positionerElement`),w=v.useState(`listElement`),T=v.useState(`popupId`),ee=v.useState(`triggerProps`),E=v.useState(`inputInsidePopup`),D=v.useState(`id`),ne=v.useState(`labelId`),O=v.useState(`open`),ie=v.useState(`selectedValue`),k=v.useState(`activeIndex`),ae=v.useState(`selectedIndex`),A=v.useState(`hasSelectedValue`),j=Pt(),oe=ht(),se=Ce(),M=f||b||a,ce=Et(),le=Ct(v);Ke({id:E?o:void 0});let ue=E?o??D:o,de=Le(_,ne),me;O&&E?me=T??jt(D):O&&(me=w==null?void 0:w.id);let he=H.useRef(``);function _e(e){he.current=e.pointerType}let{reference:ye}=Ze(j,{enabled:!O&&!x&&!b&&y===`single`,listRef:v.context.labelsRef,activeIndex:k,selectedIndex:ae,onMatch(e){let t=v.context.valuesRef.current[e];t!==void 0&&v.context.setSelectedValue(t,je(l))}}),{reference:be}=te(j,{enabled:!b,event:`mousedown`}),{buttonRef:N,getButtonProps:P}=xe({native:i,disabled:M}),Se={...u,readOnly:x,open:O,disabled:M,popupSide:le,listEmpty:ce,placeholder:y!==`none`&&!A},F=Ie(e=>{v.set(`triggerElement`,e)});return ve(`button`,e,{ref:[t,N,F],state:Se,props:[ee,be,ye,{id:ue,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":O,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":me,"aria-required":E&&S||void 0,"aria-readonly":E&&x||void 0,"aria-labelledby":de,onPointerDown:_e,onPointerEnter:_e,onFocus(){m(!0),!M&&se.start(0,v.context.forceMount)},onBlur(e){if(!fe(C,e.relatedTarget)&&(p(!0),m(!1),h===`onBlur`)){let e=y===`none`?oe:ie;g.commit(e)}},onMouseDown(e){if(M)return;if(E||j.set(`domReferenceElement`,e.currentTarget),v.context.forceMount(),he.current!==`touch`){var t;(t=v.context.inputRef.current)==null||t.focus(),E||e.preventDefault()}if(O)return;let n=we(e.currentTarget);function r(e){let t=v.state.triggerElement;if(!t)return;let n=ge(e),r=v.state.positionerElement,i=v.state.listElement;fe(t,n)||fe(r,n)||fe(i,n)||pe(e,t)||v.context.setOpen(!1,je(Ee,e))}E&&n.addEventListener(`mouseup`,r,{once:!0})},onKeyDown(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){var t;re(e),v.context.setOpen(!0,je(d,e.nativeEvent)),(t=v.context.inputRef.current)==null||t.focus()}}},g.getValidationProps(M,c),P],stateAttributesMapping:bt})}),Dn=/*#__PURE__*/ H.createContext(void 0);function On(){let e=H.useContext(Dn);if(e===void 0)throw Error(Te(18));return e}var kn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=Nt().useState(`grid`),[c,l]=H.useState(),u=H.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=ve(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=/*#__PURE__*/ (0,U.jsx)(Dn.Provider,{value:u,children:d});return a?/*#__PURE__*/ (0,U.jsx)(At,{items:a,children:f}):f}),An=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=On(),c=Be(a);return Ve(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),ve(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),jn=/^[^\p{L}\p{N}]*(\p{L})/u;function Mn(e){let t=e.trim().split(/\s+/).flatMap(e=>{var t;let n=(t=jn.exec(e))==null?void 0:t[1];return n===void 0?[]:[n.toLocaleUpperCase()]}).slice(0,2).join(``);return t===``?null:t}var Nn=`grid shrink-0 place-items-center font-semibold tracking-(--tracking-snug) select-none`,Pn=`bg-(image:--btn-primary-fill) text-fg-on-accent`,Fn=`bg-(--color-bg-tertiary) text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,In=`shadow-[var(--shadow-primary-inset),var(--shadow-tile-primary-glow)]`,Ln={22:`size-5.5 rounded-sm text-(length:--text-2xs) [&_svg]:size-3`,26:`size-6.5 rounded-md text-xs [&_svg]:size-3.5`,32:`size-8 rounded-md text-sm [&_svg]:size-4`,40:`size-10 rounded-lg text-base [&_svg]:size-4.5`},Rn=/* @__PURE__ */ new Set([26,32,40]);function zn({name:e,size:t,drained:n=!1,className:r}){let i=e===null?null:Mn(e),a=n?Fn:j(Pn,Rn.has(t)&&In);return/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,"data-size":t,"data-drained":n||void 0,className:j(Nn,Ln[t],a,r),children:i??/* @__PURE__ */ (0,U.jsx)(Rt,{})})}var Bn=5,Vn=3,Hn=`grid shrink-0 place-items-center rounded-md border border-solid border-[color-mix(in_srgb,var(--color-primary)_28%,transparent)] bg-(--color-bg-primary-tint-10) text-sm font-semibold tracking-(--tracking-snug) text-(--color-primary-text)`,Un=`grid shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted [&_svg]:size-4`,Wn=`group/trigger flex h-11.5 w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md border border-solid border-transparent bg-transparent pr-2 pl-1.25 text-left font-sans outline-none [transition:background-color_var(--motion-short)_var(--ease-out),border-color_var(--motion-short)_var(--ease-out)] hover:border-stroke hover:bg-surface-hover-layer focus-visible:border-stroke-focus focus-visible:ring-3 focus-visible:ring-focus-ring data-popup-open:border-stroke-focus data-popup-open:bg-surface-secondary`,Gn=`group/trigger inline-flex h-9 min-w-0 shrink-0 cursor-pointer items-center gap-2 rounded-full border-0 bg-transparent pr-2.25 pl-1.25 font-sans text-body-sm font-semibold tracking-(--tracking-control) text-fg-primary [transition:background-color_var(--motion-short)_var(--ease-out)] hover:bg-surface-hover-layer data-popup-open:bg-surface-hover-layer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-stroke-focus`,Kn={header:`min-w-0 max-w-45 truncate`,"header-narrow":`min-w-0 max-w-30 truncate`},qn=`grid size-6.5 shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted`,Jn=`grid grid-cols-[minmax(0,1fr)] gap-px overflow-y-auto overscroll-contain outline-none`,Yn={popup:`w-75`,list:`max-h-[min(--spacing(80),var(--available-height))]`,search:j(ue(`default`,!1,`page`,`sm`,`search`),`m-0.5 mb-1.5`),rowTile:null,row:`data-selected:bg-(--color-bg-primary-tint-10) [&>svg:last-child]:text-(--color-primary-text)`},Xn={full:{popup:`w-(--anchor-width)`,list:`max-h-[min(--spacing(52),var(--available-height))]`,search:j(ue(`default`,!1,`page`,`popup-search`),`mb-1`),rowTile:`grid size-5.5 shrink-0 place-items-center rounded-sm bg-surface-hover-layer text-caption font-semibold text-fg-secondary`,row:``},header:Yn,"header-narrow":Yn,"header-tile":Yn};function Zn({value:e,onValueChange:t,list:n,labels:r,variant:a=`full`,recent:o,footerActions:s,open:c,onOpenChange:l,autoFocus:u,"data-testid":d}){let f=ae(),p=(0,H.useId)(),h=(0,H.useId)(),[_,v]=(0,H.useState)(``),[y,b]=(0,H.useState)(!1),S=c??y,C=Xn[a],T=n.state===`ready`?n.projects:null,ee=(0,H.useMemo)(()=>T===null?/* @__PURE__ */ new Map:new Map(T.map(e=>[e.id,e])),[T]),E=(0,H.useMemo)(()=>{if(T===null||o===void 0||_.trim()!==``||T.length<=Bn)return null;let e=new Set(o.ids),t=T.filter(t=>e.has(t.id));return t.length===0?null:[{heading:o.heading,items:t},{heading:o.restHeading,items:T.filter(t=>!e.has(t.id))}]},[T,o,_]),D=T===null?[]:E??T,te=e=>{c===void 0&&b(e),l==null||l(e),e||v(``)},ne=e=>{let t=Mn(e.name);return/* @__PURE__ */ (0,U.jsxs)(xt,{value:e,className:j(oe,C.row),children:[C.rowTile===null?/* @__PURE__ */ (0,U.jsx)(zn,{name:e.name,size:22}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:C.rowTile,"aria-hidden":`true`,children:t??/* @__PURE__ */ (0,U.jsx)(Rt,{className:`size-3`})}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:j(ce,`truncate`),children:e.name}),/* @__PURE__ */ (0,U.jsx)(Je,{"aria-hidden":`true`,className:m})]},e.id)},O=n.state===`loading`?/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,"aria-label":r.loading,className:`grid gap-px`,children:Array.from({length:Vn},(e,t)=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2.5 px-2.5 py-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`size-5.5 rounded-sm`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-3 w-[60%]`})]},t))}):n.state===`error`?/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`grid justify-items-center gap-2 pb-2`,children:[/* @__PURE__ */ (0,U.jsx)(`p`,{className:j(w,`m-0 pb-0`),children:n.message}),/* @__PURE__ */ (0,U.jsx)(B,{variant:`secondary`,size:`sm`,onClick:n.onRetry,children:r.retry})]}):/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Dt,{children:/* @__PURE__ */ (0,U.jsx)(`div`,{className:w,children:r.empty})}),/* @__PURE__ */ (0,U.jsx)(gt,{"aria-label":r.label,className:j(Jn,C.list),children:E===null?ne:e=>/* @__PURE__ */ (0,U.jsxs)(kn,{items:e.items,children:[/* @__PURE__ */ (0,U.jsx)(An,{className:ie,children:e.heading}),/* @__PURE__ */ (0,U.jsx)(St,{children:ne})]},e.heading)})]}),re=j(e===null?Un:Hn,`size-8.5`),k=e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{className:qn,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(Qn,{name:null})}):/* @__PURE__ */ (0,U.jsx)(zn,{name:e.name,size:26}),A=/* @__PURE__ */ (0,U.jsx)(ze,{"aria-hidden":`true`,className:j(`shrink-0 text-fg-muted [transition:transform_var(--motion-medium)_var(--ease-out)] group-data-popup-open/trigger:rotate-180`,a===`full`?`size-4`:`size-3.25`)}),se=a===`header-tile`?/* @__PURE__ */ (0,U.jsxs)(En,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:Gn,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:p,className:`sr-only`,children:r.label}),k,/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`sr-only`,children:e===null?r.placeholder:e.name}),A]}):a===`header`||a===`header-narrow`?/* @__PURE__ */ (0,U.jsxs)(En,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:Gn,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:p,className:`sr-only`,children:r.label}),k,e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:j(Kn[a],`font-medium text-fg-secondary`),children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(g,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:Kn[a],children:e.name})}),A]}):/* @__PURE__ */ (0,U.jsxs)(En,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:Wn,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:re,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(Qn,{name:(e==null?void 0:e.name)??null})}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`grid min-w-0 flex-1 leading-(--leading-picker)`,children:[/* @__PURE__ */ (0,U.jsx)(`small`,{id:p,className:`text-(length:--text-picker-label) text-fg-muted`,children:r.label}),e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`truncate text-base font-medium tracking-(--tracking-snug) text-fg-secondary`,children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(g,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`truncate text-base font-semibold tracking-(--tracking-heading) text-fg-primary`,children:e.name})})]}),A]});return/* @__PURE__ */ (0,U.jsxs)(yt,{items:D,value:e,onValueChange:e=>{if(e===null)return;let n=ee.get(e.id);if(n===void 0)throw Error(`ProjectPicker: chosen project ${e.id} is not in the list`);t(n)},itemToStringLabel:e=>e.name,isItemEqualToValue:(e,t)=>e.id===t.id,inputValue:_,onInputValueChange:v,open:S,onOpenChange:te,autoHighlight:!0,children:[a===`header-tile`?/* @__PURE__ */ (0,U.jsx)(L,{relationship:`none`,content:e===null?r.placeholder:e.name,placement:`bottom`,children:se}):se,/* @__PURE__ */ (0,U.jsx)(Ot,{container:f,children:/* @__PURE__ */ (0,U.jsx)(Tt,{side:`bottom`,align:`start`,sideOffset:a===`full`?4:8,collisionPadding:8,positionMethod:`fixed`,className:i,children:/* @__PURE__ */ (0,U.jsxs)(mt,{"data-project-picker":``,"aria-label":r.placeholder,className:j(Qe,C.popup),children:[/* @__PURE__ */ (0,U.jsxs)(_t,{className:C.search,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:We,children:/* @__PURE__ */ (0,U.jsx)(me,{"aria-hidden":`true`})}),/* @__PURE__ */ (0,U.jsx)(vt,{placeholder:r.search,"aria-label":r.search,className:x})]}),O,s!==void 0&&/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`div`,{className:`mx-(--menu-padding) my-1 h-px border-0 bg-stroke-light`,role:`separator`}),s.map(e=>/* @__PURE__ */ (0,U.jsxs)(`button`,{type:`button`,"data-testid":e.testId,className:j(`group/opt flex min-h-(--menu-row-height) w-full cursor-pointer select-none items-center gap-(--menu-row-gap) rounded-(--menu-row-radius) border-0 bg-transparent px-(--menu-row-padding-x) py-(--menu-row-padding-y) text-left font-sans text-[length:var(--text-body-sm)] leading-normal outline-hidden [transition:background-color_var(--motion-instant)_var(--ease-out)] data-disabled:cursor-not-allowed data-disabled:opacity-disabled [&_svg]:size-(--menu-icon-size) [&_svg]:shrink-0 text-fg-primary data-highlighted:bg-surface-elevated-hover active:bg-surface-elevated-active data-selected:font-medium`,`hover:bg-surface-elevated-hover focus-visible:bg-surface-elevated-hover`),onClick:()=>{te(!1),e.onSelect()},children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex shrink-0 text-fg-muted`,children:e.icon}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.label})]},e.label))]})]})})})]})}function Qn({name:e}){let t=e===null?null:Mn(e);return t===null?/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`,className:`size-4`}):/* @__PURE__ */ (0,U.jsx)(U.Fragment,{children:t})}var $n=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function er({host:e,applicationName:t,environmentName:n,newApplication:r,newEnvironment:i,replaced:a,fresh:o}){let s=e=>e.trim()===``?`\u2026`:e.trim(),c={host:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e}),application:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(t)}),environment:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(n)}),old:/* @__PURE__ */ (0,U.jsx)(`span`,{children:a===null?``:a.address}),b:/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`})},l;l=a===null?r&&i?`popup.site.bindSay.both`:r?`popup.site.bindSay.newApplication`:i?`popup.site.bindSay.newEnvironment`:`popup.site.bindSay.free`:o===`taken`?`popup.site.bindSay.freshTaken`:o===`changed`?`popup.site.bindSay.freshChanged`:`popup.site.bindSay.replace`;let u=`${l}|${t}|${n}|${a===null?``:a.address}`;return a===null?/* @__PURE__ */ (0,U.jsx)(`p`,{"aria-live":`polite`,className:`m-0 min-w-0 text-(length:--text-compact) leading-normal text-fg-secondary text-pretty wrap-anywhere ${$n}`,"data-testid":`popup-bind-consequence`,children:/* @__PURE__ */ (0,U.jsx)(k,{i18nKey:l,components:c})},u):/* @__PURE__ */ (0,U.jsx)(`div`,{role:o===null?void 0:`alert`,"aria-live":o===null?`polite`:void 0,className:$n,"data-testid":`popup-bind-consequence`,"data-replace":`true`,children:/* @__PURE__ */ (0,U.jsx)(ne,{tone:`warning`,title:/* @__PURE__ */ (0,U.jsx)(k,{i18nKey:l,components:c})})},u)}var tr={local:`dev`,dev:`dev`,staging:`staging`,prod:`production`},nr=/* @__PURE__ */ new WeakMap;function rr(e,t){return`${e}|${t}`}function ir(e){let t=nr.get(e);if(t!==void 0)return t;let n=new Map(e.map(e=>[rr(e.applicationId,e.environmentId),e]));return nr.set(e,n),n}function ar(e,t,n){let r=ir(e).get(rr(t,n));return r===void 0?null:r}function or(e,t,n){return n===null||t.kind!==`existing`||n.kind!==`existing`?null:ar(e.cells,t.id,n.id)}function sr(e){return e.trim().toLowerCase()}function cr(e,t){let n=sr(t);if(n===``)return null;let r=e.find(e=>sr(e.name)===n);return r===void 0?null:r}function lr(e,t,n){let r=e.environments.filter(n=>t===null||ar(e.cells,t,n.id)===null),i=r.find(e=>e.envType===n.type)??r.find(e=>e.isDefault)??r.at(0);return i===void 0?{choice:{kind:`new`,name:cr(e.environments,n.name)===null?n.name:``},allTaken:e.environments.length>0}:{choice:{kind:`existing`,id:i.id},allTaken:!1}}var ur=/* @__PURE__ */ new Set([`targets.cell_exists`,`targets.modified_concurrently`,`targets.host_conflict`,`targets.not_found`]);function dr(e){return e instanceof E&&e.errorCode!==void 0?e.errorCode:null}function fr(e){return e instanceof Error?e.message:String(e)}function pr(e,t,n){return{application:e.application.kind===`new`&&n.application===null?cr(t.applications,e.application.name):null,environment:e.environment!==null&&e.environment.kind===`new`&&n.environment===null?cr(t.environments,e.environment.name):null}}function mr(e){let t=dr(e);return t!==null&&ur.has(t)}function hr(e){return e.application!==null&&e.environment!==null?`both`:e.application===null?e.environment===null?null:`environment`:`application`}function gr(e,t){let n=hr(e);return n===null?t:P.t(`popup.site.createdNotBound.${n}`,{application:e.application,environment:e.environment,reason:t})}function K(e,n){let r=hr(n);if(r===null)return t(P,e,`popup.site.bindFailed`);let i={application:n.application,environment:n.environment},a=P.t(`popup.site.bindPartial.${r}`,i),o=t(P,e,`popup.site.bindPartial.${r}`,i);return o===a?o:gr(n,o)}function _r(e,t,n,r,i){let{defaultApplicationId:a,proposal:o}=i,s=e.application,c=s.kind===`existing`&&!t.applications.some(e=>e.id===s.id)?{kind:`existing`,id:a}:s;if(!t.applications.some(e=>e.id===a))throw Error(`The default application ${a} left the project`);let l={...e,lists:t,application:c},u=e.environment;if(u!==null&&u.kind===`existing`&&!t.environments.some(e=>e.id===u.id)){let e=lr(t,c.kind===`existing`?c.id:null,o);l={...l,environment:e.choice,environmentAllTaken:e.allTaken,environmentChosen:!1}}let d=dr(n),f=or(t,l.application,l.environment);return d===`targets.cell_exists`?{...l,fresh:f===null?null:`taken`,failure:null}:d===`targets.modified_concurrently`?{...l,fresh:f===null?null:`changed`,failure:null}:d===`targets.host_conflict`?{...l,fresh:null,failure:vr(n,l,r,i.host)}:{...l,fresh:null,failure:K(n,r)}}function vr(e,t,n,r){var i;let a=e instanceof E&&typeof((i=e.params)==null?void 0:i.applicationId)==`string`?e.params.applicationId:null,o=t.lists.applications.find(e=>e.id===a),s=t.environment,c=s!==null&&s.kind===`existing`?t.lists.environments.find(e=>e.id===s.id):void 0;return o===void 0||c===void 0?K(e,n):gr(n,P.t(`popup.site.hostConflict`,{host:r,application:o.name,environment:c.name}))}var q=V(`pgs-e9b150372c`);function yr(e){let{defaultApplicationId:t,host:n,proposal:r,requests:i}=e,[a,o]=(0,H.useState)(()=>{let n=lr(e.lists,t,r);return{lists:e.lists,application:{kind:`existing`,id:t},environment:n.choice,environmentChosen:!1,environmentAllTaken:n.allTaken,problem:null,failure:null,fresh:null,pending:!1,createUnsettled:!1,focus:null}}),s=(0,H.useRef)(!1),c=(0,H.useRef)(0),l=()=>(c.current+=1,c.current),u=(e,t)=>({target:e,field:t,seq:l()}),d=(e,t)=>{if(e.environmentChosen&&e.environment!==null)return{environment:e.environment,environmentAllTaken:e.environmentAllTaken};let n=lr(e.lists,t.kind===`existing`?t.id:null,r);return{environment:n.choice,environmentAllTaken:n.allTaken}},f=(e,t)=>({...e,application:t,...d(e,t),problem:null,failure:null,fresh:null}),p=(e,t)=>({...e,environment:t,environmentChosen:!0,environmentAllTaken:!1,problem:null,failure:null,fresh:null}),m=(e,t)=>{s.current||o(n=>{if(e===`application`)return t===`new`?{...f(n,{kind:`new`,name:``}),focus:u(`input`,e)}:f(n,{kind:`existing`,id:t});if(t!==`new`)return p(n,{kind:`existing`,id:t});let i=cr(n.lists.environments,r.name)!==null;return{...p(n,{kind:`new`,name:i?``:r.name}),focus:u(`input`,e)}})},h=(e,t)=>{o(n=>{let r=e===`application`?n.application:n.environment;if(r===null||r.kind!==`new`)throw Error(`The ${e} field is not a new name, it cannot be renamed`);let i={kind:`new`,name:t};return{...n,...e===`application`?{application:i}:{environment:i},problem:n.problem!==null&&n.problem.field===e?null:n.problem}})},g=e=>{s.current||o(n=>{if(e===`application`)return{...f(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)};if(n.lists.environments.length===0)throw Error(`A project without environments has no list to go back to`);let i=lr(n.lists,n.application.kind===`existing`?n.application.id:null,r),a=i.choice.kind===`existing`?i.choice:null;return{...p(n,a),focus:u(`trigger`,e)}})},_=(e,t)=>{o(n=>({...e===`application`?f(n,{kind:`existing`,id:t}):p(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)}))},v=async a=>{let s={application:null,environment:null},c=a;if(c.createUnsettled)try{c=b(c,await i.readLists(),s)}catch(e){q.error(`pgm-9a173522f2`,{error:fr(e)}),o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}let u=c.environment;if(u===null)throw Error(`The bind press ran with no environment chosen`);let d=null;try{let t;if(c.application.kind===`new`){d=`application`;let n=await i.createApplication(c.application.name.trim());d=null,s.application=n.name,t=n.id,o(e=>({...e,lists:{...e.lists,applications:[...e.lists.applications,n]},application:{kind:`existing`,id:n.id}})),e.onApplicationCreated()}else t=c.application.id;let n;if(u.kind===`new`){d=`environment`;let e=await i.createEnvironment(u.name.trim(),c.lists.environments.length===0);d=null,s.environment=e.name,n=e.id,o(t=>({...t,lists:{...t.lists,environments:[...t.lists.environments,e]},environment:{kind:`existing`,id:e.id},environmentAllTaken:!1}))}else n=u.id;let r=or(c.lists,c.application,u);r===null?await i.createCell(t,n):await i.replaceCell(r)}catch(e){if(q.error(`pgm-53ab6bb5fe`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null,status:e instanceof E?e.status:null,code:dr(e),error:fr(e)}),d!==null){await y(c,s,e);return}if(mr(e))try{let a=await i.readLists();o(i=>({..._r(i,a,e,s,{defaultApplicationId:t,proposal:r,host:n}),focus:{target:`submit`,seq:l()}}));return}catch(e){q.error(`pgm-a2654be732`,{error:fr(e)})}o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}q.info(`pgm-dfe3d492ed`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null}),await e.onBound()},y=async(e,t,n)=>{let r;try{r=await i.readLists()}catch(e){q.error(`pgm-200d50f185`,{error:fr(e)}),o(e=>({...e,createUnsettled:!0,failure:K(n,t),focus:{target:`submit`,seq:l()}}));return}b(e,r,t),o(e=>({...e,failure:K(n,t),focus:{target:`submit`,seq:l()}}))},b=(t,n,r)=>{let i=pr(t,n,r);i.application!==null&&(r.application=i.application.name,e.onApplicationCreated()),i.environment!==null&&(r.environment=i.environment.name),(i.application!==null||i.environment!==null)&&q.info(`pgm-52181e7844`,{application:i.application!==null,environment:i.environment!==null});let a=e=>({...e,lists:n,createUnsettled:!1,...i.application===null?{}:{application:{kind:`existing`,id:i.application.id}},...i.environment===null?{}:{environment:{kind:`existing`,id:i.environment.id},environmentAllTaken:!1}});return o(a),a(t)};return{state:a,choose:m,rename:h,backToList:g,chooseExisting:_,submit:()=>{if(!s.current){if(a.environment===null){o(e=>({...e,problem:{field:`environment`,kind:`unchosen`},focus:u(`trigger`,`environment`)}));return}for(let e of[`application`,`environment`]){let t=e===`application`?a.application:a.environment;if(t.kind!==`new`)continue;if(t.name.trim()===``){o(t=>({...t,problem:{field:e,kind:`empty`},focus:u(`input`,e)}));return}let n=cr(e===`application`?a.lists.applications:a.lists.environments,t.name);if(n!==null){o(t=>({...t,problem:{field:e,kind:`duplicate`,id:n.id,name:n.name},focus:u(`input`,e)}));return}}s.current=!0,o(e=>({...e,pending:!0,failure:null,fresh:null,problem:null})),v(a).finally(()=>{s.current=!1,o(e=>({...e,pending:!1}))})}}}}var br=V(`pgs-e9b150372c`),xr=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function Sr(e){let{t}=z(),n=yr(e),{state:r}=n,i=(0,H.useId)(),a=e=>`${i}-${e}`,o=(0,H.useRef)(null),s=(0,H.useRef)(null),c=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=r.focus;if(e===null)return;let t;if(t=e.target===`submit`?c.current:e.target===`input`?(e.field===`application`?o:s).current:document.getElementById(`${i}-${e.field}`),t===null){br.warn(`pgm-9d57cb6e57`,{target:e.target});return}t.focus()},[r.focus,i]);let{lists:l,application:u,environment:d,pending:f,problem:m}=r,g=u.kind===`new`?u.name:Cr(l.applications,u.id),_=d===null?``:d.kind===`new`?d.name:Cr(l.environments,d.id),v=or(l,u,d),y=e=>{if(m!==null&&m.field===e)return m.kind===`empty`?t(e===`application`?`popup.site.emptyApplication`:`popup.site.emptyEnvironment`):m.kind===`unchosen`?t(`popup.site.environmentRequired`):/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[t(e===`application`?`popup.site.duplicateApplication`:`popup.site.duplicateEnvironment`,{name:m.name}),` `,/* @__PURE__ */ (0,U.jsx)(B,{variant:`link`,size:`xs`,onClick:()=>n.chooseExisting(e,m.id),"data-testid":`popup-bind-${e}-choose-existing`,children:t(`popup.site.chooseExisting`)})]})},b=(e,r,i)=>{let c=e===`application`||l.environments.length>0;return/* @__PURE__ */ (0,U.jsx)(h,{ref:e===`application`?o:s,id:a(e),size:`sm`,fieldClassName:`grid-cols-1`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),placeholder:t(e===`application`?`popup.site.newApplicationPlaceholder`:`popup.site.newEnvironmentPlaceholder`),autoComplete:`off`,value:r,onValueChange:t=>n.rename(e,t),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),n.submit()):t.key===`Escape`&&c&&(t.preventDefault(),n.backToList(e))},disabled:f,leading:/* @__PURE__ */ (0,U.jsx)(he,{"aria-hidden":`true`,className:`size-3.5 text-fg-link`}),trailing:c?/* @__PURE__ */ (0,U.jsx)(L,{relationship:`label`,content:t(`popup.site.backToList`),placement:`top`,children:/* @__PURE__ */ (0,U.jsx)(p,{size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(Ge,{"aria-hidden":`true`}),onClick:()=>n.backToList(e),disabled:f,"data-testid":`popup-bind-${e}-back`})}):void 0,hint:i,error:y(e),className:xr,"data-testid":`popup-bind-${e}-name`},`${e}-new`)},x=e=>({options:[{value:`new`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),icon:/* @__PURE__ */ (0,U.jsx)(he,{"aria-hidden":`true`,className:`text-fg-link`})}]}),S=u.kind===`new`?b(`application`,u.name,void 0):/* @__PURE__ */ (0,U.jsx)(Ye,{id:a(`application`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.applicationLabel`),value:u.id,onValueChange:e=>n.choose(`application`,e),disabled:f,groups:[{options:l.applications.map(e=>({value:e.id,label:e.name}))},x(`application`)],"data-testid":`popup-bind-application`},`application-list`),C;l.environments.length===0?C=t(`popup.site.noEnvironmentsHint`):r.environmentAllTaken&&(C=/* @__PURE__ */ (0,U.jsx)(`span`,{className:`wrap-anywhere`,children:t(`popup.site.allTakenHint`,{application:g.trim()===``?`\u2026`:g.trim()})}));let w=d!==null&&d.kind===`new`?b(`environment`,d.name,C):/* @__PURE__ */ (0,U.jsx)(Ye,{id:a(`environment`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.environmentLabel`),value:d===null?null:d.id,placeholder:t(`popup.site.environmentPlaceholder`),error:y(`environment`),onValueChange:e=>n.choose(`environment`,e),disabled:f,groups:[{options:l.environments.map(e=>{let n=u.kind===`existing`?ar(l.cells,u.id,e.id):null;return n===null?{value:e.id,label:e.name}:{value:e.id,label:e.name,description:t(`popup.site.taken`,{address:n.address})}})},x(`environment`)],"data-testid":`popup-bind-environment`},`environment-list`);return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`group`,"aria-label":t(`popup.site.bind`),"aria-busy":f,className:`grid min-w-0 grid-cols-1 gap-2.5 rounded-md border border-stroke-light bg-surface-modal-inset px-3 pt-2.5 pb-3`,"data-testid":`popup-bind-form`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2.5`,children:[S,w]}),m===null&&d!==null&&/* @__PURE__ */ (0,U.jsx)(er,{host:e.host,applicationName:g,environmentName:_,newApplication:u.kind===`new`,newEnvironment:d.kind===`new`,replaced:v,fresh:r.fresh}),r.failure!==null&&/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-1.5 text-(length:--text-compact) leading-(--leading-caption) text-fg-error`,"data-testid":`popup-bind-failure`,children:[/* @__PURE__ */ (0,U.jsx)(Ae,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:r.failure})]}),/* @__PURE__ */ (0,U.jsx)(B,{ref:c,size:`sm`,icon:v===null?/* @__PURE__ */ (0,U.jsx)(O,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(Xt,{"aria-hidden":`true`}),loading:f,onClick:n.submit,className:`justify-self-end`,"data-testid":`popup-bind-submit`,children:t(v===null?`popup.site.bind`:`popup.site.replace`)})]})}function Cr(e,t){let n=e.find(e=>e.id===t);if(n===void 0)throw Error(`The bind form chose ${t}, absent from its list`);return n.name}function J({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{"aria-live":`polite`,className:`grid grid-cols-1 gap-2 border-t border-stroke-light py-2.5 pr-3 pl-3.5 animate-ui-fade-in motion-reduce:animate-none`,"data-testid":`popup-site`,children:e})}function Y({host:e}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-body-sm text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-fg-muted`}),/* @__PURE__ */ (0,U.jsx)(`b`,{className:`min-w-0 truncate font-medium text-fg-primary`,children:e})]})}var wr=`inline-flex h-6 items-center rounded-full border border-stroke bg-surface-hover-layer text-xs text-fg-primary`;function Tr({applicationName:e,environmentName:t}){let{t:n}=z();return/* @__PURE__ */ (0,U.jsxs)(`div`,{"aria-label":n(`popup.site.cellLabel`),className:`flex flex-wrap items-center gap-1.5`,"data-testid":`popup-site-cell`,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:j(wr,`px-2.25 font-medium`),children:e}),/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-fg-muted`,children:`\u00D7`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:j(wr,`px-2.5 font-semibold animate-[popup-environment-in_var(--motion-long)_var(--ease-out)_both]`),children:t})]})}function Er({children:e,hintName:t,hint:n,tone:r=`default`,icon:i}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:j(`flex min-w-0 items-center gap-1.5 [&>svg]:size-3.5 [&>svg]:shrink-0`,r===`warning`&&`text-fg-warning`),children:[i,/* @__PURE__ */ (0,U.jsx)(`p`,{className:j(`m-0 min-w-0 text-(length:--text-compact) leading-normal [&_b]:font-semibold [&_b]:text-fg-primary`,r===`warning`?`text-inherit`:r===`muted`?`text-fg-muted`:`text-fg-secondary`),children:e}),/* @__PURE__ */ (0,U.jsx)(C,{name:t,text:n,placement:`bottom-start`})]})}var Dr=V(`pgs-f048f86b7e`);function Or({projectId:e,host:t,environments:n,chosenId:r,onChosen:i}){let{t:a}=z(),s=D(),[c,l]=(0,H.useState)(!1);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Er,{hintName:a(`popup.site.more`,{about:a(`popup.site.environmentChoice`)}),hint:a(`popup.site.environmentChoiceHint`),children:a(`popup.site.environmentChoice`)}),/* @__PURE__ */ (0,U.jsx)(Ye,{size:`sm`,"aria-label":a(`popup.site.environmentLabel`),placeholder:a(`popup.site.environmentPlaceholder`),value:r,onValueChange:t=>{c||(l(!0),R.environments.setActive(o(e),`extension`,t).then(()=>{Dr.info(`pgm-f54cd7418d`,{projectId:e}),i()}).catch(t=>{Dr.error(`pgm-effdde2b56`,{projectId:e,error:t instanceof Error?t.message:String(t)}),s.show({id:`popup-environment-choice`,variant:`error`,message:a(`popup.site.environmentFailed`)})}).finally(()=>l(!1)))},disabled:c,options:n.map(e=>({value:e.id,label:e.name,description:t})),"data-testid":`popup-site-environment`})]})}function kr(e){let t=e.toLowerCase();return/(^|\/\/|\.)dev\./.test(t)?`dev`:/stag/.test(t)?`staging`:/localhost|127\.0/.test(t)?`local`:`prod`}function Ar(e){let t=e.toLowerCase();return/prod/.test(t)?`production`:/stag/.test(t)?`staging`:/dev|local|\u043B\u043E\u043A\u0430\u043B/.test(t)?`dev`:`custom`}function jr(e){let t=kr(e);return{key:`popup.site.environmentSuggestion.${t}`,type:tr[t]}}async function Mr(e,t,n){let r=o(t),[i,a,s]=await Promise.all([e.targets.listAll(r,{signal:n}),e.applications.byProject(r,{signal:n}),e.environments.list(r,{signal:n})]);return{targets:i,applications:a,environments:s}}async function Nr(e,t,n,r){let i=await Mr(e,t,r),{targets:a,applications:s,environments:c}=i,l=(e,n)=>{let r=e.find(e=>e.id===n);if(r===void 0)throw Error(`A cell of project ${t} names ${n}, absent from the lists just read`);return r.name},u=Mt(n.href,a.map(Yt),null);switch(u.kind){case`matched`:return{kind:`matched`,applicationName:l(s,u.applicationId),environmentName:l(c,u.environmentId)};case`ambiguous_application`:return{kind:`ambiguous`,environmentName:l(c,u.environmentId)};case`environment_choice`:{let n=await e.environments.getActive(o(t),`extension`,{signal:r}),i=n.source===`user_preference`&&u.environmentIds.includes(n.environmentId)?n.environmentId:null;return{kind:`environmentChoice`,environments:c.filter(e=>u.environmentIds.includes(e.id)).map(e=>({id:e.id,name:e.name})),chosenId:i}}case`unknown_host`:case`no_targets`:{let e=s.find(e=>e.isDefault);if(e===void 0)throw Error(`Project ${t} has no default application`);return{kind:`bind`,reason:u.kind,lists:Fr(i),defaultApplicationId:e.id}}case`unsupported_url`:return{kind:`unsupported`}}}async function Pr(e,t){return Fr(await Mr(e,t,void 0))}function Fr(e){return{applications:e.applications.map(Ir),environments:e.environments.map(Lr),cells:e.targets.map(Rr)}}function Ir(e){return{id:e.id,name:e.name}}function Lr(e){return{id:e.id,name:e.name,envType:e.envType,isDefault:e.isDefault}}function Rr(e){let t;if(e.baseUrl!==null)t=new URL(e.baseUrl).host;else if(e.hostPattern!==null)t=e.hostPattern;else throw Error(`Cell ${e.id} has neither an origin nor a host pattern`);return{id:e.id,applicationId:e.applicationId,environmentId:e.environmentId,address:t,hostPattern:e.hostPattern,updatedAt:e.updatedAt}}async function zr(e,t,n){return Ir(await e.applications.create({projectId:o(t),name:n}))}async function Br(e,t,n,r){return Lr(await e.environments.create({projectId:o(t),name:n,envType:Ar(n),isDefault:r}))}async function Vr(e,t,n,r,i){await e.targets.create(o(t),{applicationId:v(r),environmentId:i,baseUrl:n})}async function Hr(e,t,n,r){let i=r.hostPattern!==null&&pt(n,[{targetId:r.id,applicationId:r.applicationId,environmentId:r.environmentId,baseUrl:null,hostPattern:r.hostPattern}]).length>0;await e.targets.update(o(t),r.id,{baseUrl:n,...r.hostPattern===null||i?{}:{hostPattern:null},expectedUpdatedAt:r.updatedAt})}var Ur=V(`pgs-c1e3b0bb6f`);function Wr({page:e,projects:t,onSelect:n}){let{t:r}=z(),{data:i,error:a}=u({fetcher:()=>R.targets.match(e.href),deps:[e.href]});if((0,H.useEffect)(()=>{a!==null&&Ur.error(`pgm-f294aabbd9`,{error:a.message})},[a]),a!==null||i===void 0)return null;let o=new Set(i.items.map(e=>e.projectId)),s=t.filter(e=>o.has(e.id));return s.length===0?null:/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:e.host}),s.map(e=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover-layer py-2 pr-2 pl-2.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 truncate text-(length:--text-compact) leading-(--leading-caption) text-fg-secondary`,children:[r(`popup.site.suggestion`),` `,/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:r(`popup.site.suggestionProject`,{project:e.name})})]}),/* @__PURE__ */ (0,U.jsx)(B,{variant:`secondary`,size:`sm`,onClick:()=>n(e),"data-testid":`popup-site-suggestion`,children:r(`popup.site.select`)})]},e.id))]})}var Gr=V(`pgs-3b85b4fc58`);function Kr({tabId:e,project:t,projects:n,onSelectProject:r,onApplicationCreated:i}){let{data:a,error:o}=u({fetcher:()=>chrome.tabs.get(e).then(e=>e.url??null),deps:[e]});if((0,H.useEffect)(()=>{o!==null&&Gr.error(`pgm-df207305cf`,{tabId:e,error:o.message})},[o,e]),o!==null||a===void 0)return null;let s=a===null?null:Me(a),c=s!==null&&s.ok?s.url:null;return t===null?c===null?null:/* @__PURE__ */ (0,U.jsx)(Wr,{page:c,projects:n,onSelect:r}):c===null?/* @__PURE__ */ (0,U.jsx)(qr,{}):/* @__PURE__ */ (0,U.jsx)(Jr,{project:t,page:c,onApplicationCreated:i})}function qr(){let{t:e}=z();return/* @__PURE__ */ (0,U.jsx)(J,{children:/* @__PURE__ */ (0,U.jsx)(Er,{tone:`muted`,hintName:e(`popup.site.more`,{about:e(`popup.site.notSite`)}),hint:e(`popup.site.notSiteHint`),children:e(`popup.site.notSite`)})})}function Jr({project:e,page:t,onApplicationCreated:n}){let{t:r}=z(),{data:i,loading:a,error:o,reload:s}=u({fetcher:n=>Nr(R,e.id,t,n),deps:[e.id,t.href]}),c={createApplication:t=>zr(R,e.id,t),createEnvironment:(t,n)=>Br(R,e.id,t,n),createCell:(n,r)=>Vr(R,e.id,t.origin,n,r),replaceCell:n=>Hr(R,e.id,t.origin,n),readLists:()=>Pr(R,e.id)},l=async()=>{try{let t=await F.call(`REFRESH_PROJECT_TARGETS`,{projectId:e.id});t.success||Gr.error(`pgm-ef389a0081`,{projectId:e.id,error:t.error})}catch(t){Gr.error(`pgm-fc30de5d00`,{projectId:e.id,error:t instanceof Error?t.message:String(t)})}s()};if(o!==null)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsxs)(`p`,{role:`alert`,className:`m-0 flex gap-1.5 text-(length:--text-compact) leading-normal text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(Ae,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:r(`popup.site.readFailed`)})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{children:/* @__PURE__ */ (0,U.jsx)(B,{variant:`secondary`,size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(de,{"aria-hidden":`true`}),onClick:s,"data-testid":`popup-site-retry`,children:r(`common.retry`)})})]});if(a||i===void 0)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":r(`popup.site.reading`),className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{className:`h-6 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(I,{className:`h-6 w-20.5 rounded-full`})]})]});switch(i.kind){case`unsupported`:return/* @__PURE__ */ (0,U.jsx)(qr,{});case`matched`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Tr,{applicationName:i.applicationName,environmentName:i.environmentName})]});case`ambiguous`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Er,{tone:`warning`,icon:/* @__PURE__ */ (0,U.jsx)(S,{"aria-hidden":`true`}),hintName:r(`popup.site.more`,{about:r(`popup.site.ambiguous`,{environment:i.environmentName})}),hint:r(`popup.site.ambiguousHint`),children:r(`popup.site.ambiguous`,{environment:i.environmentName})})]});case`environmentChoice`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Or,{projectId:e.id,host:t.host,environments:i.environments,chosenId:i.chosenId,onChosen:s})]});case`bind`:{let a=jr(t.host);return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Er,{hintName:r(`popup.site.bindMore`),hint:r(`popup.site.bindInfo`),children:/* @__PURE__ */ (0,U.jsx)(k,{i18nKey:i.reason===`no_targets`?`popup.site.noTargets`:`popup.site.notBound`,components:{b:/* @__PURE__ */ (0,U.jsx)(`b`,{}),project:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e.name})}})}),/* @__PURE__ */ (0,U.jsx)(Sr,{lists:i.lists,defaultApplicationId:i.defaultApplicationId,host:t.host,proposal:{name:r(a.key),type:a.type},requests:c,onApplicationCreated:n,onBound:l})]})}}}var Yr=V(`pgs-930365a583`),Xr=`all`;function Zr({tabId:e,applications:t,applicationId:n}){let{t:r}=z(),i=D();return/* @__PURE__ */ (0,U.jsx)(Ye,{appearance:`inline`,label:r(`popup.application.label`),value:n===null?Xr:n,onValueChange:t=>{let n=t===Xr?null:t;F.call(`SET_TAB_STATE`,{tabId:e,state:{applicationId:n}}).then(e=>{if(!e.success)throw Error(`SET_TAB_STATE refused: ${e.error}`)}).catch(t=>{Yr.error(`pgm-e58825e7fe`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-application`,variant:`error`,message:r(`popup.application.switchFailed`)})})},options:[{value:Xr,label:r(`popup.application.all`)},...t.map(e=>({value:e.id,label:e.name}))],"data-testid":`popup-application`})}function Qr({run:e}){let{t}=z();return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-b-lg border-t border-stroke-light bg-[color-mix(in_srgb,var(--color-info)_8%,transparent)] py-2.25 pr-3 pl-3.5 text-(length:--text-compact) leading-snug`,"data-testid":`popup-run-line`,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-info shadow-(--glow-status-info) animate-pulse-dot`}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:e.kind===`free`?t(`popup.run.free`,{number:e.number}):t(`popup.run.plan`,{plan:e.planName})}),` `,t(`popup.run.where`)]})]})}var $r=V(`pgs-c184079221`);function ei({tabId:e,projects:t,tabProject:n,applicationId:r,run:i,onPick:a,pickerOpen:o,onPickerOpenChange:s}){let{t:c}=z(),[l,u]=(0,H.useState)(0);return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":c(`popup.project.contextLabel`),className:`relative rounded-lg border border-(--color-border-overlay) bg-surface-card shadow-(--shadow-context-card)`,"data-testid":`popup-context`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`relative grid p-2`,children:[/* @__PURE__ */ (0,U.jsx)(Zn,{value:n===null?null:{id:n.id,name:n.name},onValueChange:a,list:{state:`ready`,projects:t},labels:{label:c(`popup.project.label`),placeholder:c(`popup.project.placeholder`),search:c(`popup.project.search`),empty:c(`popup.project.empty`),loading:c(`popup.project.loading`),retry:c(`common.retry`)},open:o,onOpenChange:s,autoFocus:!0,"data-testid":`popup-project`}),n!==null&&/* @__PURE__ */ (0,U.jsx)(ti,{tabId:e,projectId:n.id,applicationId:r,applicationsCreated:l},n.id)]}),/* @__PURE__ */ (0,U.jsx)(Kr,{tabId:e,project:n,projects:t,onSelectProject:a,onApplicationCreated:()=>u(e=>e+1)},`${e}:${n===null?``:n.id}`),i!==null&&/* @__PURE__ */ (0,U.jsx)(Qr,{run:i})]})}function ti({tabId:e,projectId:t,applicationId:n,applicationsCreated:r}){let{data:i,error:a}=u({fetcher:e=>R.applications.byProject(o(t),{signal:e}),deps:[t,r]});return(0,H.useEffect)(()=>{a!==null&&$r.error(`pgm-f42292fd59`,{error:a.message})},[a]),a!==null||i===void 0||i.length<=1?null:/* @__PURE__ */ (0,U.jsx)(Zr,{tabId:e,applications:i,applicationId:n})}var ni=[{key:`bugs`,tone:`error`},{key:`checklists`,tone:`primary`},...be.incidentsEnabled?[{key:`incidents`,tone:`warning`}]:[]],ri={bugs:`popup.filters.bugs`,checklists:`popup.filters.checklists`,incidents:`popup.filters.incidents`};function ii(){let{t:e}=z(),t=W(`filters`),n=G();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":e(`popup.filters.title`),className:`grid gap-2`,"data-testid":`popup-filters`,children:[/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`mx-0.5 my-0 text-xs font-medium text-fg-muted`,children:e(`popup.filters.title`)}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t===void 0?ni.map(e=>/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8.5 w-24 rounded-full`},e.key)):ni.map(r=>/* @__PURE__ */ (0,U.jsx)(wt,{pressed:t[r.key],tone:r.tone,size:`md`,onClick:()=>n(`filters`,{...t,[r.key]:!t[r.key]}),"data-testid":`popup-filter-${r.key}`,children:e(ri[r.key])},r.key))})]})}function ai(){let{t:e}=z(),t=G();return/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,children:/* @__PURE__ */ (0,U.jsx)(ne,{tone:`info`,icon:/* @__PURE__ */ (0,U.jsx)(en,{"aria-hidden":`true`}),title:e(`popup.paused.title`),actionsPlacement:`below`,actions:/* @__PURE__ */ (0,U.jsx)(n,{onClick:()=>t(`enabled`,!0),children:e(`popup.paused.enable`)}),"data-testid":`popup-paused`})})}function oi({projectSwitch:e,currentProjectName:t}){let{t:n}=z(),{question:r,busy:i,confirm:a,cancel:o}=e;if(r===null)return null;let{run:s,target:c}=r,l=s.kind===`free`,u=s.kind===`free`?n(`popup.switchRun.freeText`,{number:s.number,project:c.name}):t===null?n(`popup.switchRun.planTextNoProject`,{plan:s.planName}):n(`popup.switchRun.planText`,{plan:s.planName,project:t});return/* @__PURE__ */ (0,U.jsx)(y,{open:!0,busy:i,onCancel:o,tone:l?`danger`:`warning`,icon:l?/* @__PURE__ */ (0,U.jsx)(Ge,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(Zt,{"aria-hidden":`true`}),title:n(l?`popup.switchRun.freeTitle`:`popup.switchRun.planTitle`),description:u,"data-testid":`popup-project-switch-question`,actions:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(B,{variant:`secondary`,onClick:o,children:n(`popup.switchRun.stay`)}),/* @__PURE__ */ (0,U.jsx)(B,{variant:l?`danger`:`primary`,loading:i,onClick:a,"data-testid":`popup-project-switch-confirm`,children:n(l?`popup.switchRun.freeConfirm`:`popup.switchRun.planConfirm`)})]})})}var si=V(`pgs-ab0307fe13`);function ci({tabId:e,projectId:t,currentTestRun:n}){let{t:r}=z(),i=D(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=async t=>{let n=await F.call(`RESTORE_PROJECT`,{tabId:e,projectId:t.id,projectNumber:t.number,applicationId:null});if(!n.success)throw Error(`RESTORE_PROJECT refused: ${n.error}`);si.info(`pgm-496ade1c1d`,{tabId:e})},u=t=>{si.error(`pgm-61ab57a774`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-project-switch`,variant:`error`,message:r(`popup.project.switchFailed`)})};return{question:a,busy:s,choose(e){if(e.id!==t){if(n!==null){o({target:e,run:n});return}l(e).catch(u)}},confirm(){a===null||s||(c(!0),l(a.target).catch(u).finally(()=>{c(!1),o(null)}))},cancel(){s||o(null)}}}function li({user:e,header:t,back:n,strip:r,snapshot:i,projects:a,tabProject:s}){let{t:c}=z(),l=W(`enabled`),[u,d]=(0,H.useState)(!1),{state:p,tabId:m}=i,h=ci({tabId:m,projectId:p.projectId,currentTestRun:p.currentTestRun}),g;switch(a.state){case`loading`:g=/* @__PURE__ */ (0,U.jsx)(sn,{});break;case`error`:g=/* @__PURE__ */ (0,U.jsx)(ui,{children:/* @__PURE__ */ (0,U.jsx)(f,{icon:/* @__PURE__ */ (0,U.jsx)(Lt,{"aria-hidden":`true`}),title:c(`popup.projects.failedTitle`),description:c(`popup.projects.failedText`),retry:{label:c(`common.retry`),onRetry:a.retry}})});break;case`ready`:{if(a.projects.length===0){g=/* @__PURE__ */ (0,U.jsx)(ui,{children:/* @__PURE__ */ (0,U.jsx)(se,{icon:/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`}),title:c(`popup.projects.emptyTitle`),description:c(`popup.projects.emptyText`),action:/* @__PURE__ */ (0,U.jsx)(B,{icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onClick:()=>T(),children:c(`popup.projects.openWeb`)})})});break}let t=/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(ei,{tabId:m,projects:a.projects,tabProject:s,applicationId:p.applicationId,run:p.currentTestRun,onPick:h.choose,pickerOpen:u,onPickerOpenChange:d}),/* @__PURE__ */ (0,U.jsx)(ii,{})]});g=s===null?t:/* @__PURE__ */ (0,U.jsx)(qt,{user:e,project:{id:o(s.id),number:M(s.number)},children:t});break}}let _=a.state===`ready`&&a.projects.length>0;return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:j(`flex min-h-0 flex-1 flex-col`,n?ot:lt),children:[t,/* @__PURE__ */ (0,U.jsxs)(an,{className:_&&u?`min-h-90`:void 0,children:[_&&l===!1&&/* @__PURE__ */ (0,U.jsx)(ai,{}),r,g]}),/* @__PURE__ */ (0,U.jsx)(oi,{projectSwitch:h,currentProjectName:s===null?null:s.name})]})}function ui({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`grid min-h-84 content-center`,children:e})}function di(){let{data:e,loading:t,error:n,reload:r}=u({fetcher:e=>R.projects.list({signal:e})}),i=(0,H.useMemo)(()=>new Map(e===void 0?[]:e.map(e=>[e.id,e])),[e]);return n===null?t||e===void 0?{state:`loading`}:{state:`ready`,projects:e,byId:i}:{state:`error`,error:n,retry:r}}var fi=V(`pgs-aea740cf56`);function pi({windowId:e,revision:t,back:n,onBack:r,onOpenSettings:i}){let{t:a}=z();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n?ot:lt}`,"data-testid":`popup-notification-feed`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(L,{relationship:`label`,content:a(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(p,{icon:/* @__PURE__ */ (0,U.jsx)(Ht,{"aria-hidden":`true`}),onClick:r,autoFocus:!0,"data-testid":`popup-feed-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 mr-auto text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:a(`notifications.feed.title`)}),/* @__PURE__ */ (0,U.jsx)(L,{relationship:`label`,content:a(`notifications.feed.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(p,{icon:/* @__PURE__ */ (0,U.jsx)(ct,{"aria-hidden":`true`}),onClick:i,"data-testid":`popup-feed-settings`})})]}),/* @__PURE__ */ (0,U.jsx)(st,{host:`popup`,api:R.notifications,locale:Xe(),t:a,revision:t,logger:fi,onOpenTarget:t=>ft(t,e),onOpenSettings:i,onSeen:()=>nt(`seen`)})]})}var mi=V(`pgs-a3c52049ce`);function hi({windowId:e,waitingCount:t,revision:n,onOpenFeed:r}){let{t:i}=z();return/* @__PURE__ */ (0,U.jsx)(et,{api:R.notifications,locale:Xe(),t:i,waitingCount:t,revision:n,logger:mi,onOpenTarget:t=>ft(t,e),onOpenFeed:r,onSeen:()=>nt(`seen`)})}function gi({value:e,onChange:t,labels:n,size:r,fullWidth:i,className:a}){return/* @__PURE__ */ (0,U.jsx)(A,{value:e,onValueChange:t,"aria-label":n.group,size:r,fullWidth:i,className:a,options:[{value:`light`,label:n.light,icon:/* @__PURE__ */ (0,U.jsx)(tn,{"aria-hidden":`true`})},{value:`dark`,label:n.dark,icon:/* @__PURE__ */ (0,U.jsx)($t,{"aria-hidden":`true`})},{value:`system`,label:n.system,icon:/* @__PURE__ */ (0,U.jsx)(Ft,{"aria-hidden":`true`})}]})}function X({title:e,hint:t,children:n,"data-testid":r}){let{t:i}=z();return/* @__PURE__ */ (0,U.jsxs)(`section`,{className:`grid gap-1.5`,"data-testid":r,children:[/* @__PURE__ */ (0,U.jsxs)(`h3`,{className:`mx-0.5 my-0 flex items-center gap-1 text-xs font-medium text-fg-muted`,children:[e,t!==void 0&&/* @__PURE__ */ (0,U.jsx)(C,{name:i(`popup.site.more`,{about:e}),text:t,placement:`bottom-start`})]}),/* @__PURE__ */ (0,U.jsx)(kt,{kind:`block`,body:`rows`,density:`compact`,children:/* @__PURE__ */ (0,U.jsx)(a,{children:n})})]})}function Z({label:e,below:t,stacked:n=!1,alignStart:r=!1,children:i,"data-testid":a}){return/* @__PURE__ */ (0,U.jsx)($e,{title:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:e}),end:i,stacked:n,alignStart:r,"data-testid":a,children:t})}var _i={on:`bg-success shadow-(--glow-status-success)`,neutral:`bg-fg-muted`,warning:`bg-warning`,error:`bg-error`},vi={on:`text-fg-muted`,neutral:`text-fg-muted`,warning:`text-fg-warning`,error:`text-fg-error`};function Q({tone:e,announce:t=!1,children:n,action:r,"data-testid":i}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{role:e===`error`?`alert`:t?`status`:void 0,className:j(`flex items-start gap-1.75 text-xs leading-(--leading-caption)`,vi[e]),"data-testid":i,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:j(`mt-1.25 size-1.75 flex-none rounded-full`,_i[e])}),/* @__PURE__ */ (0,U.jsxs)(`span`,{children:[n,r]})]})}function yi({onRetry:e}){let{t}=z();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[` \u00B7 `,/* @__PURE__ */ (0,U.jsx)(B,{variant:`link`,size:`xs`,onClick:e,children:t(`common.retry`)})]})}var bi=V(`pgs-6344bc6f0d`);function xi(e,t){let n=u({fetcher:async()=>{if(e===null)throw Error(`Discovery settings are read per project`);let t=await F.call(`REFRESH_DISCOVERY_SETTINGS`,{projectId:e});if(!t.success)throw Error(`REFRESH_DISCOVERY_SETTINGS refused: ${t.error}`);if(t.discoverySettings===null)throw Error(`The service worker could not read the discovery settings`);return t.discoverySettings},deps:[e],enabled:e!==null}),[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(!1),m=(0,H.useRef)(null),h=(0,H.useRef)(!1),g=(0,H.useRef)(!1),_=(0,H.useRef)(null),v=(0,H.useCallback)(async()=>{if(!(g.current||e===null)){g.current=!0,c(!0),d(!1),p(!1);try{for(;m.current!==null||h.current;){let n=m.current;if(n!==null){try{await R.discovery.updateUserSettings(n)}catch(t){bi.warn(`pgm-6e1d90d469`,{projectId:e,error:t instanceof Error?t.message:String(t)}),_.current=m.current,m.current=null,o(null),d(!0);continue}h.current=!0,m.current===n&&(m.current=null,o(null));continue}h.current=!1;let r=await Si(e,t);r===null?p(!0):(i(r),p(!1))}}finally{g.current=!1,c(!1)}}},[e,t]),y=(0,H.useCallback)(e=>{m.current=e,o(e),v()},[v]),b=(0,H.useCallback)(()=>{let e=_.current;if(e===null)throw Error(`No failed discovery save to retry`);_.current=null,y(e)},[y]),x=(0,H.useCallback)(()=>{h.current=!0,v()},[v]);if(e===null)return{status:`noProject`};if(n.error!==null&&r===null)return{status:`readFailed`,retry:n.reload};if(f&&!s)return{status:`readFailed`,retry:x};let S=r===null?n.data:r;return S===void 0?{status:`loading`}:{status:`ready`,settings:S,checked:a===null?S.userEnabled:a,saving:s,saveFailed:l,toggle:y,retrySave:b}}async function Si(e,t){let n=await F.call(`REFRESH_DISCOVERY_SETTINGS`,{tabId:t,projectId:e}).catch(t=>(bi.warn(`pgm-8a2d41a868`,{projectId:e,error:t instanceof Error?t.message:String(t)}),null));return n===null?null:n.success?(n.discoverySettings===null&&bi.warn(`pgm-842d0b7de2`,{projectId:e}),n.discoverySettings):(bi.warn(`pgm-a943e9be7d`,{projectId:e,error:n.error}),null)}function Ci(e){var t;return((t=e.disabledReasons)==null?void 0:t.includes(`company_disabled`))===!0||!e.companyEnabled}function wi(e){return e.gatingModel===`company+user+project`&&e.projectEnabled===!1}var $=`popup-discovery-status`;function Ti({tabId:e,project:t}){let{t:n}=z(),r=xi(t==null?null:t.id,e),i=t===void 0?{status:`loading`}:r,a,o=null;switch(i.status){case`noProject`:a=/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.noProject`)});break;case`loading`:a=/* @__PURE__ */ (0,U.jsx)(I,{className:`mt-1 h-3 w-40`}),o=/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5 w-9 rounded-full`});break;case`readFailed`:a=/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(yi,{onRetry:i.retry}),children:n(`popup.settings.discoveryStatus.readFailed`)});break;case`ready`:{let{settings:e}=i;if(t==null)throw Error(`Discovery settings were read without a project`);a=i.saving?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.saving`)}):i.saveFailed?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(yi,{onRetry:i.retrySave}),children:n(`popup.settings.discoveryStatus.saveFailed`)}):Ci(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.companyOff`)}):wi(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.projectOff`,{project:t.name})}):e.effectiveEnabled?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`on`,children:n(`popup.settings.discoveryStatus.on`,{project:t.name})}):/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.off`)}),o=/* @__PURE__ */ (0,U.jsx)(Vt,{"aria-label":n(`popup.settings.discovery`),checked:i.checked,onChange:i.toggle,"data-testid":`popup-discovery-toggle`});break}}return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[n(`popup.settings.discovery`),/* @__PURE__ */ (0,U.jsx)(C,{name:n(`popup.site.more`,{about:n(`popup.settings.discovery`)}),text:n(`popup.settings.discoveryHint`),placement:`bottom-start`})]}),below:a,alignStart:!0,"data-testid":`popup-discovery`,children:o})}function Ei({children:e}){return/* @__PURE__ */ (0,U.jsx)(`kbd`,{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.75 font-sans text-(length:--text-micro) leading-none font-medium whitespace-nowrap text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,children:e})}var Di=/* @__PURE__ */ new Set([`Control`,`Alt`,`Shift`,`Meta`]);function Oi(e){if(Di.has(e.key))return null;let t=[];return(e.ctrlKey||e.metaKey)&&t.push(`Ctrl`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`),e.key===` `?t.push(`Space`):t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join(`+`)}function ki(){let{t:e}=z(),t=W(`selectionHotkey`),n=G(),[r,i]=(0,H.useState)(!1);return t===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-(--control-height-sm) w-12 rounded-(--input-radius)`}):/* @__PURE__ */ (0,U.jsx)(le,{size:`sm`,active:r,"aria-label":e(`popup.settings.hotkeyName`,{hotkey:t}),onClick:()=>i(!0),onBlur:()=>i(!1),onKeyDown:e=>{if(!r)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Oi(e);t!==null&&(i(!1),n(`selectionHotkey`,t))},"data-testid":`popup-hotkey`,children:r?/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-(--color-primary-text) animate-pulse-dot`,children:e(`popup.settings.hotkeyCapture`)}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:t.split(`+`).map((e,t)=>/* @__PURE__ */ (0,U.jsx)(Ei,{children:e},`${e}-${t}`))})})}function Ai(e,t){return t?`element`:e?`window`:`off`}function ji(e){return{isolationWindow:e===`window`,isolationElement:e===`element`}}var Mi=Promise.resolve();function Ni(e){let t=()=>Re(ji(e)),n=Mi.then(t,t);return Mi=n,n}var Pi=V(`pgs-fed3bb0e75`),Fi={managed:null,company:`popup.settings.modelKeyCompany`,personal:`popup.settings.modelKeyPersonal`};function Ii(){let{t:e}=z(),t=D(),n=G(),r=W(`modelPick`),i=(0,H.useMemo)(()=>Ut({http:dt(),logger:Pi}),[]),{data:a,error:o,reload:s}=u({fetcher:()=>i.load()});if((0,H.useEffect)(()=>{o!==null&&(Pi.error(`pgm-9665648376`,{error:o.message}),t.show({id:`popup-models`,variant:`error`,message:e(`popup.settings.modelLoadFailed`),action:{label:e(`common.retry`),onAction:s}}))},[o,s,e,t]),r===void 0||a===void 0&&o===null)return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),children:/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8 w-37.5 rounded-md`})});let c=a===void 0?[]:a.groups,l=a===void 0||r===null?null:Wt(a,r),d=a===void 0?null:Gt(a,l,null);return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),"data-testid":`popup-model`,children:/* @__PURE__ */ (0,U.jsx)(Ye,{size:`sm`,"aria-label":e(`popup.settings.model`),placeholder:e(`popup.settings.modelNone`),value:d===null?null:d.model.selectionId,onValueChange:r=>{for(let i of c){let a=i.models.find(e=>e.selectionId===r);if(a!==void 0){n(`modelPick`,{keySource:i.source,modelId:a.id}),R.aiSettings.updateUser({selectedProvider:i.source,selectedModel:a.id}).catch(n=>{Pi.error(`pgm-573d3af0bc`,{error:n instanceof Error?n.message:String(n)}),t.show({id:`popup-model-save`,variant:`error`,message:e(`popup.settings.saveFailed`)})});return}}throw Error(`The AI model Select picked a row it did not render: ${r}`)},className:`w-37.5`,options:c.flatMap(t=>t.models.map(n=>{let r=Fi[t.source];return{value:n.selectionId,label:r===null?n.name:`${n.name} \u00B7 ${e(r)}`,disabled:!zt(n)}}))})})}var Li=V(`pgs-cdc66fba2a`),Ri={permissions:[`notifications`]};function zi(e){return e instanceof Error?e.message:String(e)}function Bi(){return[chrome.permissions.onAdded,chrome.permissions.onRemoved]}function Vi(e){var t;return((t=e.permissions)==null?void 0:t.includes(`notifications`))===!0}function Hi(){let{t:e}=z(),[t,n]=(0,H.useState)(`reading`),r=(0,H.useRef)(!0),i=(0,H.useCallback)(()=>{chrome.permissions.contains(Ri).then(e=>{r.current&&n(t=>e?`on`:t===`denied`?`denied`:`off`)},e=>{Li.error(`pgm-cbfb085fbb`,{error:zi(e)}),r.current&&n(`readFailed`)})},[]);(0,H.useEffect)(()=>{r.current=!0;let e=e=>{Vi(e)&&i()},t=Bi();for(let n of t)n.addListener(e);return i(),()=>{r.current=!1;for(let n of t)n.removeListener(e)}},[i]);let a=()=>{n(`reading`),i()},o=e=>{if(e){n(`asking`),chrome.permissions.request(Ri).then(e=>n(e?`on`:`denied`),e=>{Li.error(`pgm-67efc28caa`,{error:zi(e)}),n(`off`)});return}chrome.permissions.remove(Ri).then(e=>{e||Li.error(`pgm-2cbfb59188`),n(e?`off`:`on`)},e=>{Li.error(`pgm-ac8845b9f5`,{error:zi(e)})})},s=e(`popup.settings.osNotifications`);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[s,/* @__PURE__ */ (0,U.jsx)(C,{name:e(`popup.site.more`,{about:s}),text:e(`popup.settings.osNotificationsHint`),placement:`bottom-start`})]}),below:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`small`,{className:`text-xs leading-(--leading-caption) text-fg-muted`,children:e(`popup.settings.osNotificationsWhen`)}),t===`denied`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`neutral`,announce:!0,"data-testid":`popup-os-notifications-denied`,children:e(`popup.settings.osNotificationsDenied`)}),t===`readFailed`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(yi,{onRetry:a}),"data-testid":`popup-os-notifications-read-failed`,children:e(`popup.settings.osNotificationsReadFailed`)})]}),alignStart:!0,"data-testid":`popup-os-notifications`,children:t===`reading`?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5 w-9 rounded-full`}):t===`readFailed`?null:/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[t===`asking`&&/* @__PURE__ */ (0,U.jsx)(_,{}),/* @__PURE__ */ (0,U.jsx)(Vt,{"aria-label":s,checked:t===`on`,onChange:o,"data-testid":`popup-os-notifications-switch`})]})})}var Ui=V(`pgs-7fed4be7cb`);function Wi(){let{t:e}=z(),t=W(`notificationsEnabled`),n=G(),r=e(`popup.settings.notifications`);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(X,{title:e(`popup.settings.groups.notifications`),hint:e(`popup.settings.groups.notificationsHint`),"data-testid":`popup-notification-groups`,children:/* @__PURE__ */ (0,U.jsx)(it,{api:R.notifications,locale:Xe(),t:e,logger:Ui,onChanged:()=>nt(`group_changed`)})}),/* @__PURE__ */ (0,U.jsxs)(X,{title:e(`popup.settings.groups.thisBrowser`),children:[/* @__PURE__ */ (0,U.jsx)(Hi,{}),/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[r,/* @__PURE__ */ (0,U.jsx)(C,{name:e(`popup.site.more`,{about:r}),text:e(`popup.settings.notificationsHint`),placement:`bottom-start`})]}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(Vt,{"aria-label":r,checked:t,onChange:e=>n(`notificationsEnabled`,e),"data-testid":`popup-notifications`})})]})]})}var Gi=/^\d+$/;function Ki(e){let t=e.trim();return Gi.test(t)?Number(t)>Fe?`tooLong`:null:`notWholeNumber`}function qi(){let{t:e,i18n:t}=z(),n=W(`autoplayStepPauseMs`),r=G(),[i,a]=(0,H.useState)(null),o=i===null?null:Ki(i),s=o!==null,c=()=>{if(i===null||s)return;let e=Number(i.trim());a(null),e!==n&&r(`autoplayStepPauseMs`,e)};return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.pause`),alignStart:!0,below:s?/* @__PURE__ */ (0,U.jsxs)(`span`,{role:`alert`,className:`mt-0.5 flex items-start gap-1.5 text-xs leading-(--leading-caption) text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(Ae,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:o===`tooLong`?e(`popup.settings.pauseTooLong`,{max:new Intl.NumberFormat(t.language).format(Fe)}):e(`popup.settings.pauseInvalid`)})]}):void 0,"data-testid":`popup-step-pause`,children:n===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8 w-26 rounded-md`}):/* @__PURE__ */ (0,U.jsx)(h,{size:`sm`,inputMode:`numeric`,"aria-label":e(`popup.settings.pauseName`),value:i??String(n),onValueChange:a,onBlur:c,onKeyDown:e=>{e.key===`Enter`&&c()},invalid:s,trailing:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`popup.settings.ms`)}),className:`w-26 [&_input]:text-right [&_input]:tabular-nums`})})}function Ji({tabId:e,project:t,onBack:n}){let{t:r}=z(),i=W(`theme`),a=G();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${lt}`,"data-testid":`popup-settings`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(L,{relationship:`label`,content:r(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(p,{icon:/* @__PURE__ */ (0,U.jsx)(Ht,{"aria-hidden":`true`}),onClick:n,autoFocus:!0,"data-testid":`popup-settings-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:r(`popup.settings.title`)})]}),/* @__PURE__ */ (0,U.jsxs)(an,{children:[/* @__PURE__ */ (0,U.jsx)(Wi,{}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.view`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.theme`),stacked:!0,children:i===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(gi,{value:i,onChange:e=>a(`theme`,e),labels:{group:r(`popup.settings.theme`),light:r(`popup.settings.themeLight`),dark:r(`popup.settings.themeDark`),system:r(`popup.settings.themeSystem`)},fullWidth:!0})}),/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.language`),stacked:!0,children:/* @__PURE__ */ (0,U.jsx)(bn,{fullWidth:!0})})]}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.recording`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.hotkey`),children:/* @__PURE__ */ (0,U.jsx)(ki,{})}),/* @__PURE__ */ (0,U.jsx)(qi,{}),/* @__PURE__ */ (0,U.jsx)(Yi,{})]}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.assistant`),children:/* @__PURE__ */ (0,U.jsx)(Ii,{})}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.pages`),children:/* @__PURE__ */ (0,U.jsx)(Ti,{tabId:e,project:t},t==null?``:t.id)})]})]})}function Yi(){let{t:e}=z(),t=yn(),n=W(`isolationWindow`),r=W(`isolationElement`),i=n=>{t({id:`popup-isolation`,run:()=>Ni(n),log:{message:`Input isolation was not stored`,context:{isolation:n}},message:e(`popup.settings.saveFailed`)})},a=n===void 0||r===void 0?void 0:Ai(n,r);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[e(`popup.settings.isolation`),/* @__PURE__ */ (0,U.jsx)(C,{name:e(`popup.site.more`,{about:e(`popup.settings.isolation`)}),text:e(`popup.settings.isolationHint`),placement:`bottom-start`})]}),stacked:!0,"data-testid":`popup-isolation`,children:a===void 0?/* @__PURE__ */ (0,U.jsx)(I,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(A,{value:a,onValueChange:i,"aria-label":e(`popup.settings.isolation`),fullWidth:!0,options:[{value:`off`,label:e(`popup.settings.isolationOff`)},{value:`window`,label:e(`popup.settings.isolationWindow`)},{value:`element`,label:e(`popup.settings.isolationElement`)}]})})}var Xi=V(`pgs-b5906754fa`);function Zi({user:e}){let t=ye(),n=di(),r=W(`enabled`),i=at(e.id),a=tt(),[s,c]=(0,H.useState)({name:`main`,back:!1});if((0,H.useEffect)(()=>{nt(`surface_opened`)},[]),a===void 0)return/* @__PURE__ */ (0,U.jsx)(on,{});let l=n.state===`ready`?Qi(t,n.byId):null,u=i.status===`ready`?i.snapshot:null,d=i.status===`ready`?i.revision:0,f=()=>c({name:`settings`,back:!1}),p=()=>c({name:`feed`,back:!1}),m=()=>c({name:`main`,back:!0}),h=/* @__PURE__ */ (0,U.jsx)(Tn,{user:e,onOpenSettings:f,notificationCounts:u,onOpenNotifications:p}),g=r===!0&&u!==null?/* @__PURE__ */ (0,U.jsx)(hi,{windowId:a,waitingCount:u.waitingCount,revision:d,onOpenFeed:p}):null;switch(s.name){case`settings`:{let r=/* @__PURE__ */ (0,U.jsx)(Ji,{tabId:t.tabId,project:n.state===`loading`?void 0:l,onBack:m});return l===null?r:/* @__PURE__ */ (0,U.jsx)(qt,{user:e,project:{id:o(l.id),number:M(l.number)},children:r})}case`feed`:return/* @__PURE__ */ (0,U.jsx)(pi,{windowId:a,revision:d,back:s.back,onBack:m,onOpenSettings:f});case`main`:return/* @__PURE__ */ (0,U.jsx)(li,{user:e,header:h,back:s.back,strip:g,snapshot:t,projects:n,tabProject:l})}}function Qi(e,t){let{projectId:n}=e.state;if(n===null)return null;let r=t.get(n);return r===void 0?(Xi.warn(`pgm-cb1ec83f44`,{tabId:e.tabId}),null):r}function $i(){return/* @__PURE__ */ (0,U.jsx)(Ne,{loading:/* @__PURE__ */ (0,U.jsx)(on,{}),signedOut:/* @__PURE__ */ (0,U.jsx)(xn,{}),children:e=>/* @__PURE__ */ (0,U.jsx)(pn,{user:e,children:/* @__PURE__ */ (0,U.jsx)(H.Suspense,{fallback:/* @__PURE__ */ (0,U.jsx)(on,{}),children:/* @__PURE__ */ (0,U.jsx)(Zi,{user:e})})})})}var ea=V(`pgs-2e3f74b175`),ta=document.getElementById(`popup-root`);ta===null?ea.error(`pgm-f13077b9ed`):De({surface:`popup`,root:ta,followedTab:rt(),editorNavigation:s(`popup`),render:()=>/* @__PURE__ */ (0,U.jsx)($i,{})}).catch(e=>{ea.error(`pgm-f4cc990f36`,e)});
39
+ ;function mn({off:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`mr-auto flex items-center gap-2 text-body-md font-semibold tracking-(--tracking-brand) text-fg-primary`,children:[/* @__PURE__ */ (0,U.jsx)(Bt,{className:h(`size-5 [transition:filter_var(--motion-medium)_var(--ease-out),opacity_var(--motion-medium)_var(--ease-out)]`,e&&`opacity-50 grayscale`)}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.brand`)})]})}function hn({children:e}){return/* @__PURE__ */ (0,U.jsx)(`header`,{className:`flex h-12 flex-none items-center gap-1 border-b border-stroke-light bg-(--color-bg-window-header) pr-2 pl-3.5`,children:e})}function gn({children:e,className:t}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:h(`grid min-h-0 flex-1 grid-cols-1 content-start gap-4 overflow-y-auto px-3 pt-3 pb-4 [scrollbar-width:thin]`,t),children:e})}function _n(){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`popup-loading`,children:[/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:!1}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-7 rounded-md`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-6 rounded-full`})]}),/* @__PURE__ */ (0,U.jsx)(gn,{children:/* @__PURE__ */ (0,U.jsx)(vn,{})})]})}function vn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":e(`shell.loading`),className:`grid gap-2.5 rounded-lg border border-stroke bg-surface-card pt-3 pr-3 pb-3.5 pl-3.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-8.5 rounded-md`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid flex-1 gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-12`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3.5 w-[62%]`})]})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-20.5 rounded-full`})]})]}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-37.5`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-21 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-27.5 rounded-full`})]})]})]})}function yn({value:e,options:t,onChange:n,ariaLabel:r,size:i,fullWidth:a,className:o}){return/* @__PURE__ */ (0,U.jsx)(m,{value:e,options:t,onValueChange:n,"aria-label":r,size:i,fullWidth:a,className:o})}var bn=V(`pgs-4d9951d24e`);function xn(e){let t=0,n=Promise.resolve(),r=null;async function i(n,i,a){if(n!==t)return;if(e.signedInUserId()!==a){bn.warn(`pgm-4b072233de`,{locale:i});return}let o=new AbortController;r=o;try{await e.save(i,o.signal)}catch(r){if(o.signal.aborted){bn.info(`pgm-7aaa461c83`,{locale:i});return}if(n===t){e.onFailure(i,r);return}bn.warn(`pgm-f93a88619e`,{locale:i,error:r})}finally{r=null}}return{write(e,r){t+=1;let a=t;n=n.then(()=>i(a,e,r)).catch(t=>{bn.error(`pgm-1491eca8c6`,{locale:e,error:t})})},discardPending(){t+=1,r==null||r.abort()}}}var Sn=V(`pgs-b78fd5fe0f`),Cn=(0,H.createContext)(null);function wn({user:e,children:t}){let{t:n}=F(),r=x(),[i]=(0,H.useState)(()=>Dn(e.id));return(0,H.useEffect)(()=>{i.setFailureReport((e,t)=>{Sn.error(`pgm-0f28f45227`,{locale:e,error:t instanceof Error?t.message:String(t)}),r.show({id:`popup-profile-language`,variant:`error`,message:n(`popup.language.profileSaveFailed`),action:{label:n(`common.retry`),onAction:()=>i.retryShownLocale()}})})}),(0,H.useEffect)(()=>(i.start(),()=>i.end()),[i]),/* @__PURE__ */ (0,U.jsx)(Cn,{value:i.profileLocale,children:t})}function Tn(){return(0,H.useContext)(Cn)}function En(){let e=(0,H.useContext)(Cn);if(e===null)throw Error(`useSignedInProfileLocale() is used outside the signed-in popup`);return e}function Dn(e){let t=!1,n=null,r=xn({save:async(e,t)=>{await L.preferences.update({locale:e},{signal:t})},signedInUserId:()=>t?e:null,onFailure:(e,t)=>{if(n===null)throw Error(`A profile language write failed before the popup was rendered`);n(e,t)}});return{profileLocale:{write:t=>r.write(t,e),discardPending:()=>r.discardPending()},setFailureReport:e=>{n=e},retryShownLocale:()=>{t&&r.write(Se(),e)},start:()=>{t=!0},end:()=>{t=!1,r.discardPending()}}}function On(e){let t=j(e);return(0,H.useSyncExternalStore)(t.subscribe,t.getState)}var kn=V(`pgs-520a54a8e3`);function W(e){let t=On(e);if(t.status===`failed`)throw t.error;return t.status===`ready`?t.value:void 0}function An(){let{t:e}=F(),t=x();return(0,H.useCallback)(function n(r){r.run().catch(i=>{kn.error(r.log.message,{...r.log.context,error:i instanceof Error?i.message:String(i)}),t.show({id:r.id,variant:`error`,message:r.message,detail:r.detail,action:{label:e(`common.retry`),onAction:()=>n(r)}})})},[e,t])}function G(){let{t:e}=F(),n=An();return(0,H.useCallback)((r,i)=>n({id:`setting-${r}`,run:()=>t(r,i),log:{message:`A setting was not stored`,context:{key:r}},message:e(`popup.settings.saveFailed`)}),[e,n])}function jn({size:e,fullWidth:t}){let{t:n}=F(),r=An(),i=Tn();return/* @__PURE__ */ (0,U.jsx)(yn,{value:Se(),options:ft.map(e=>({value:e,label:n(`common.languageNames.${e}`)})),onChange:e=>r({id:`popup-language`,run:async()=>{await we(e)!==`superseded`&&(i==null||i.write(e))},log:{message:`The language was not switched or not stored`,context:{locale:e}},message:n(`popup.settings.saveFailed`)}),ariaLabel:n(`popup.languageGroup`),size:e,fullWidth:t})}function Mn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:/* @__PURE__ */ (0,U.jsx)(Ft,{subtitle:e(`shell.signIn.subtitlePopup`),footer:/* @__PURE__ */ (0,U.jsx)(jn,{size:`sm`})})})}var Nn=V(`pgs-d05703aaa3`);function Pn({user:e}){let{t}=F(),n=x(),[r,i]=(0,H.useState)(!1),a=En(),o=`${e.firstName} ${e.lastName}`;return/* @__PURE__ */ (0,U.jsxs)(re,{label:t(`popup.header.account`,{name:o}),align:`end`,className:`w-59`,trigger:/* @__PURE__ */ (0,U.jsx)(D,{"aria-label":t(`popup.header.account`,{name:o}),icon:/* @__PURE__ */ (0,U.jsx)(gt,{firstName:e.firstName,lastName:e.lastName,email:e.email,size:`sm`,unknownLabel:t(`popup.header.unknownUser`)}),"data-testid":`popup-account`}),children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-px px-2.5 py-2`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`text-body-sm font-semibold text-fg-primary`,children:o}),/* @__PURE__ */ (0,U.jsxs)(`small`,{className:`text-xs text-fg-muted`,children:[e.email,` \u00B7 `,e.company.name]})]}),/* @__PURE__ */ (0,U.jsx)(d,{}),/* @__PURE__ */ (0,U.jsx)(Ve,{label:t(`popup.header.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onSelect:()=>c()}),/* @__PURE__ */ (0,U.jsx)(d,{}),/* @__PURE__ */ (0,U.jsx)(Ve,{label:t(`popup.header.signOut`),icon:/* @__PURE__ */ (0,U.jsx)(un,{"aria-hidden":`true`}),tone:`danger`,disabled:r,onSelect:()=>{r||(i(!0),a.discardPending(),L.auth.logout().catch(e=>{Nn.error(`pgm-4db83b7ea3`,{error:e instanceof Error?e.message:String(e)}),n.show({id:`popup-sign-out`,variant:`error`,message:t(`popup.header.signOutFailed`)})}).finally(()=>i(!1)))},"data-testid":`popup-sign-out`})]})}function Fn({enabled:e}){let{t:n}=F(),r=An();return/* @__PURE__ */ (0,U.jsx)(I,{relationship:`description`,content:n(e?`popup.header.switchOn`:`popup.header.switchOff`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex`,children:/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":n(`popup.header.switchLabel`),checked:e,onChange:e=>r({id:`popup-power-switch`,run:()=>t(`enabled`,e),log:{message:`The extension switch was not stored`,context:{enabled:e}},message:n(`popup.header.switchFailed`),detail:n(`popup.header.switchFailedDetail`)}),className:`p-1.5`,"data-testid":`popup-power-switch`})})})}function In({user:e,onOpenSettings:t,notificationCounts:n,onOpenNotifications:r}){let{t:i}=F(),a=W(`enabled`);return/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:a===!1}),a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(Fn,{enabled:a}),/* @__PURE__ */ (0,U.jsx)(wt,{host:`popup`,t:i,counts:a===!1?null:n,onClick:r}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:i(`popup.header.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:t,"data-testid":`popup-open-settings`})}),/* @__PURE__ */ (0,U.jsx)(Pn,{user:e})]})}var Ln=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:i,nativeButton:a=!0,disabled:o=!1,id:s,style:c,...u}=e,{state:d,disabled:p,setTouched:m,setFocused:h,validationMode:g,validation:_}=Me(),{labelId:v}=Je(),y=on(),b=y.useState(`selectionMode`),x=y.useState(`disabled`),S=y.useState(`readOnly`),C=y.useState(`required`),ee=y.useState(`positionerElement`),te=y.useState(`listElement`),w=y.useState(`popupId`),T=y.useState(`triggerProps`),E=y.useState(`inputInsidePopup`),D=y.useState(`id`),O=y.useState(`labelId`),k=y.useState(`open`),ne=y.useState(`selectedValue`),re=y.useState(`activeIndex`),A=y.useState(`selectedIndex`),ae=y.useState(`hasSelectedValue`),j=sn(),oe=Ht(),ce=rt(),M=p||x||o,le=$t(),ue=Xt(y);Oe({id:E?s:void 0});let de=E?s??D:s,fe=Be(v,O),pe;k&&E?pe=w??an(D):k&&(pe=te==null?void 0:te.id);let me=H.useRef(``);function he(e){me.current=e.pointerType}let{reference:ge}=Ne(j,{enabled:!k&&!S&&!x&&b===`single`,listRef:y.context.labelsRef,activeIndex:re,selectedIndex:A,onMatch(e){let t=y.context.valuesRef.current[e];t!==void 0&&y.context.setSelectedValue(t,Ae(ie))}}),{reference:_e}=f(j,{enabled:!x,event:`mousedown`}),{buttonRef:N,getButtonProps:ve}=Ie({native:a,disabled:M}),ye={...d,readOnly:S,open:k,disabled:M,popupSide:ue,listEmpty:le,placeholder:b!==`none`&&!ae},xe=ze(e=>{y.set(`triggerElement`,e)});return tt(`button`,e,{ref:[t,N,xe],state:ye,props:[T,_e,ge,{id:de,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":pe,"aria-required":E&&C||void 0,"aria-readonly":E&&S||void 0,"aria-labelledby":fe,onPointerDown:he,onPointerEnter:he,onFocus(){h(!0),!M&&ce.start(0,y.context.forceMount)},onBlur(e){if(!Te(ee,e.relatedTarget)&&(m(!0),h(!1),g===`onBlur`)){let e=b===`none`?oe:ne;_.commit(e)}},onMouseDown(e){if(M)return;if(E||j.set(`domReferenceElement`,e.currentTarget),y.context.forceMount(),me.current!==`touch`){var t;(t=y.context.inputRef.current)==null||t.focus(),E||e.preventDefault()}if(k)return;let n=Ye(e.currentTarget);function r(e){let t=y.state.triggerElement;if(!t)return;let n=se(e),r=y.state.positionerElement,i=y.state.listElement;Te(t,n)||Te(r,n)||Te(i,n)||be(e,t)||y.context.setOpen(!1,Ae(De,e))}E&&n.addEventListener(`mouseup`,r,{once:!0})},onKeyDown(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){var t;r(e),y.context.setOpen(!0,Ae(l,e.nativeEvent)),(t=y.context.inputRef.current)==null||t.focus()}}},_.getValidationProps(M,u),ve],stateAttributesMapping:qt})}),Rn=/*#__PURE__*/ H.createContext(void 0);function zn(){let e=H.useContext(Rn);if(e===void 0)throw Error(Ge(18));return e}var Bn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=on().useState(`grid`),[c,l]=H.useState(),u=H.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=tt(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=/*#__PURE__*/ (0,U.jsx)(Rn.Provider,{value:u,children:d});return a?/*#__PURE__*/ (0,U.jsx)(rn,{items:a,children:f}):f}),Vn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=zn(),c=et(a);return We(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),tt(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),Hn=/^[^\p{L}\p{N}]*(\p{L})/u;function Un(e){let t=e.trim().split(/\s+/).flatMap(e=>{var t;let n=(t=Hn.exec(e))==null?void 0:t[1];return n===void 0?[]:[n.toLocaleUpperCase()]}).slice(0,2).join(``);return t===``?null:t}var Wn=`grid shrink-0 place-items-center font-semibold tracking-(--tracking-snug) select-none`,Gn=`bg-(image:--btn-primary-fill) text-fg-on-accent`,Kn=`bg-(--color-bg-tertiary) text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,qn=`shadow-[var(--shadow-primary-inset),var(--shadow-tile-primary-glow)]`,Jn={22:`size-5.5 rounded-sm text-(length:--text-2xs) [&_svg]:size-3`,26:`size-6.5 rounded-md text-xs [&_svg]:size-3.5`,32:`size-8 rounded-md text-sm [&_svg]:size-4`,40:`size-10 rounded-lg text-base [&_svg]:size-4.5`},Yn=/* @__PURE__ */ new Set([26,32,40]);function Xn({name:e,size:t,drained:n=!1,className:r}){let i=e===null?null:Un(e),a=n?Kn:h(Gn,Yn.has(t)&&qn);return/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,"data-size":t,"data-drained":n||void 0,className:h(Wn,Jn[t],a,r),children:i??/* @__PURE__ */ (0,U.jsx)(Rt,{})})}var Zn=5,Qn=3,$n=`grid shrink-0 place-items-center rounded-md border border-solid border-[color-mix(in_srgb,var(--color-primary)_28%,transparent)] bg-(--color-bg-primary-tint-10) text-sm font-semibold tracking-(--tracking-snug) text-(--color-primary-text)`,er=`grid shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted [&_svg]:size-4`,tr=`group/trigger flex h-11.5 w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md border border-solid border-transparent bg-transparent pr-2 pl-1.25 text-left font-sans outline-none [transition:background-color_var(--motion-short)_var(--ease-out),border-color_var(--motion-short)_var(--ease-out)] hover:border-stroke hover:bg-surface-hover-layer focus-visible:border-stroke-focus focus-visible:ring-3 focus-visible:ring-focus-ring data-popup-open:border-stroke-focus data-popup-open:bg-surface-secondary`,nr=`group/trigger inline-flex h-9 min-w-0 shrink-0 cursor-pointer items-center gap-2 rounded-full border-0 bg-transparent pr-2.25 pl-1.25 font-sans text-body-sm font-semibold tracking-(--tracking-control) text-fg-primary [transition:background-color_var(--motion-short)_var(--ease-out)] hover:bg-surface-hover-layer data-popup-open:bg-surface-hover-layer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-stroke-focus`,rr={header:`min-w-0 max-w-45 truncate`,"header-narrow":`min-w-0 max-w-30 truncate`},ir=`grid size-6.5 shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted`,ar=`grid grid-cols-[minmax(0,1fr)] gap-px overflow-y-auto overscroll-contain outline-none`,or={popup:`w-75`,list:`max-h-[min(--spacing(80),var(--available-height))]`,search:h(oe(`default`,!1,`page`,`sm`,`search`),`m-0.5 mb-1.5`),rowTile:null,row:`data-selected:bg-(--color-bg-primary-tint-10) [&>svg:last-child]:text-(--color-primary-text)`},sr={full:{popup:`w-(--anchor-width)`,list:`max-h-[min(--spacing(52),var(--available-height))]`,search:h(oe(`default`,!1,`page`,`popup-search`),`mb-1`),rowTile:`grid size-5.5 shrink-0 place-items-center rounded-sm bg-surface-hover-layer text-caption font-semibold text-fg-secondary`,row:``},header:or,"header-narrow":or,"header-tile":or};function cr({value:e,onValueChange:t,list:n,labels:r,variant:i=`full`,recent:o,footerActions:s,open:c,onOpenChange:l,autoFocus:u,"data-testid":d}){let f=b(),m=(0,H.useId)(),_=(0,H.useId)(),[y,x]=(0,H.useState)(``),[S,C]=(0,H.useState)(!1),ee=c??S,w=sr[i],T=n.state===`ready`?n.projects:null,E=(0,H.useMemo)(()=>T===null?/* @__PURE__ */ new Map:new Map(T.map(e=>[e.id,e])),[T]),D=(0,H.useMemo)(()=>{if(T===null||o===void 0||y.trim()!==``||T.length<=Zn)return null;let e=new Set(o.ids),t=T.filter(t=>e.has(t.id));return t.length===0?null:[{heading:o.heading,items:t},{heading:o.restHeading,items:T.filter(t=>!e.has(t.id))}]},[T,o,y]),O=T===null?[]:D??T,k=e=>{c===void 0&&C(e),l==null||l(e),e||x(``)},ne=e=>{let t=Un(e.name);return/* @__PURE__ */ (0,U.jsxs)(Jt,{value:e,className:h(g,w.row),children:[w.rowTile===null?/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:22}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:w.rowTile,"aria-hidden":`true`,children:t??/* @__PURE__ */ (0,U.jsx)(Rt,{className:`size-3`})}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(p,`truncate`),children:e.name}),/* @__PURE__ */ (0,U.jsx)(Ke,{"aria-hidden":`true`,className:te})]},e.id)},re=n.state===`loading`?/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,"aria-label":r.loading,className:`grid gap-px`,children:Array.from({length:Qn},(e,t)=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2.5 px-2.5 py-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-5.5 rounded-sm`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})]},t))}):n.state===`error`?/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`grid justify-items-center gap-2 pb-2`,children:[/* @__PURE__ */ (0,U.jsx)(`p`,{className:h(ce,`m-0 pb-0`),children:n.message}),/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,onClick:n.onRetry,children:r.retry})]}):/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(en,{children:/* @__PURE__ */ (0,U.jsx)(`div`,{className:ce,children:r.empty})}),/* @__PURE__ */ (0,U.jsx)(Ut,{"aria-label":r.label,className:h(ar,w.list),children:D===null?ne:e=>/* @__PURE__ */ (0,U.jsxs)(Bn,{items:e.items,children:[/* @__PURE__ */ (0,U.jsx)(Vn,{className:dt,children:e.heading}),/* @__PURE__ */ (0,U.jsx)(Yt,{children:ne})]},e.heading)})]}),A=h(e===null?er:$n,`size-8.5`),ie=e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{className:ir,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:null})}):/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:26}),ae=/* @__PURE__ */ (0,U.jsx)(nt,{"aria-hidden":`true`,className:h(`shrink-0 text-fg-muted [transition:transform_var(--motion-medium)_var(--ease-out)] group-data-popup-open/trigger:rotate-180`,i===`full`?`size-4`:`size-3.25`)}),j=i===`header-tile`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:m,className:`sr-only`,children:r.label}),ie,/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`sr-only`,children:e===null?r.placeholder:e.name}),ae]}):i===`header`||i===`header-narrow`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:m,className:`sr-only`,children:r.label}),ie,e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:h(rr[i],`font-medium text-fg-secondary`),children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(M,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:rr[i],children:e.name})}),ae]}):/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:tr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:A,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:(e==null?void 0:e.name)??null})}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`grid min-w-0 flex-1 leading-(--leading-picker)`,children:[/* @__PURE__ */ (0,U.jsx)(`small`,{id:m,className:`text-(length:--text-picker-label) text-fg-muted`,children:r.label}),e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`truncate text-base font-medium tracking-(--tracking-snug) text-fg-secondary`,children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(M,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`truncate text-base font-semibold tracking-(--tracking-heading) text-fg-primary`,children:e.name})})]}),ae]});return/* @__PURE__ */ (0,U.jsxs)(Kt,{items:O,value:e,onValueChange:e=>{if(e===null)return;let n=E.get(e.id);if(n===void 0)throw Error(`ProjectPicker: chosen project ${e.id} is not in the list`);t(n)},itemToStringLabel:e=>e.name,isItemEqualToValue:(e,t)=>e.id===t.id,inputValue:y,onInputValueChange:x,open:ee,onOpenChange:k,autoHighlight:!0,children:[i===`header-tile`?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`none`,content:e===null?r.placeholder:e.name,placement:`bottom`,children:j}):j,/* @__PURE__ */ (0,U.jsx)(tn,{container:f,children:/* @__PURE__ */ (0,U.jsx)(Qt,{side:`bottom`,align:`start`,sideOffset:i===`full`?4:8,collisionPadding:8,positionMethod:`fixed`,className:me,children:/* @__PURE__ */ (0,U.jsxs)(Vt,{"data-project-picker":``,"aria-label":r.placeholder,className:h(a,w.popup),children:[/* @__PURE__ */ (0,U.jsxs)(Wt,{className:w.search,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:Ce,children:/* @__PURE__ */ (0,U.jsx)(v,{"aria-hidden":`true`})}),/* @__PURE__ */ (0,U.jsx)(Gt,{placeholder:r.search,"aria-label":r.search,className:xe})]}),re,s!==void 0&&/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`div`,{className:`mx-(--menu-padding) my-1 h-px border-0 bg-stroke-light`,role:`separator`}),s.map(e=>/* @__PURE__ */ (0,U.jsxs)(`button`,{type:`button`,"data-testid":e.testId,className:h(`group/opt flex min-h-(--menu-row-height) w-full cursor-pointer select-none items-center gap-(--menu-row-gap) rounded-(--menu-row-radius) border-0 bg-transparent px-(--menu-row-padding-x) py-(--menu-row-padding-y) text-left font-sans text-[length:var(--text-body-sm)] leading-normal outline-hidden [transition:background-color_var(--motion-instant)_var(--ease-out)] data-disabled:cursor-not-allowed data-disabled:opacity-disabled [&_svg]:size-(--menu-icon-size) [&_svg]:shrink-0 text-fg-primary data-highlighted:bg-surface-elevated-hover active:bg-surface-elevated-active data-selected:font-medium`,`hover:bg-surface-elevated-hover focus-visible:bg-surface-elevated-hover`),onClick:()=>{k(!1),e.onSelect()},children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex shrink-0 text-fg-muted`,children:e.icon}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.label})]},e.label))]})]})})})]})}function lr({name:e}){let t=e===null?null:Un(e);return t===null?/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`,className:`size-4`}):/* @__PURE__ */ (0,U.jsx)(U.Fragment,{children:t})}var ur=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function dr({host:e,applicationName:t,environmentName:n,newApplication:r,newEnvironment:i,replaced:a,fresh:o}){let s=e=>e.trim()===``?`\u2026`:e.trim(),c={host:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e}),application:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(t)}),environment:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(n)}),old:/* @__PURE__ */ (0,U.jsx)(`span`,{children:a===null?``:a.address}),b:/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`})},l;l=a===null?r&&i?`popup.site.bindSay.both`:r?`popup.site.bindSay.newApplication`:i?`popup.site.bindSay.newEnvironment`:`popup.site.bindSay.free`:o===`taken`?`popup.site.bindSay.freshTaken`:o===`changed`?`popup.site.bindSay.freshChanged`:`popup.site.bindSay.replace`;let u=`${l}|${t}|${n}|${a===null?``:a.address}`;return a===null?/* @__PURE__ */ (0,U.jsx)(`p`,{"aria-live":`polite`,className:`m-0 min-w-0 text-(length:--text-compact) leading-normal text-fg-secondary text-pretty wrap-anywhere ${ur}`,"data-testid":`popup-bind-consequence`,children:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:l,components:c})},u):/* @__PURE__ */ (0,U.jsx)(`div`,{role:o===null?void 0:`alert`,"aria-live":o===null?`polite`:void 0,className:ur,"data-testid":`popup-bind-consequence`,"data-replace":`true`,children:/* @__PURE__ */ (0,U.jsx)(Fe,{tone:`warning`,title:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:l,components:c})})},u)}var fr={local:`dev`,dev:`dev`,staging:`staging`,prod:`production`},pr=/* @__PURE__ */ new WeakMap;function mr(e,t){return`${e}|${t}`}function hr(e){let t=pr.get(e);if(t!==void 0)return t;let n=new Map(e.map(e=>[mr(e.applicationId,e.environmentId),e]));return pr.set(e,n),n}function gr(e,t,n){let r=hr(e).get(mr(t,n));return r===void 0?null:r}function _r(e,t,n){return n===null||t.kind!==`existing`||n.kind!==`existing`?null:gr(e.cells,t.id,n.id)}function vr(e){return e.trim().toLowerCase()}function yr(e,t){let n=vr(t);if(n===``)return null;let r=e.find(e=>vr(e.name)===n);return r===void 0?null:r}function br(e,t,n){let r=e.environments.filter(n=>t===null||gr(e.cells,t,n.id)===null),i=r.find(e=>e.envType===n.type)??r.find(e=>e.isDefault)??r.at(0);return i===void 0?{choice:{kind:`new`,name:yr(e.environments,n.name)===null?n.name:``},allTaken:e.environments.length>0}:{choice:{kind:`existing`,id:i.id},allTaken:!1}}var xr=/* @__PURE__ */ new Set([`targets.cell_exists`,`targets.modified_concurrently`,`targets.host_conflict`,`targets.not_found`]);function Sr(e){return e instanceof He&&e.errorCode!==void 0?e.errorCode:null}function Cr(e){return e instanceof Error?e.message:String(e)}function wr(e,t,n){return{application:e.application.kind===`new`&&n.application===null?yr(t.applications,e.application.name):null,environment:e.environment!==null&&e.environment.kind===`new`&&n.environment===null?yr(t.environments,e.environment.name):null}}function Tr(e){let t=Sr(e);return t!==null&&xr.has(t)}function Er(e){return e.application!==null&&e.environment!==null?`both`:e.application===null?e.environment===null?null:`environment`:`application`}function Dr(e,t){let n=Er(e);return n===null?t:S.t(`popup.site.createdNotBound.${n}`,{application:e.application,environment:e.environment,reason:t})}function K(e,t){let n=Er(t);if(n===null)return Xe(S,e,`popup.site.bindFailed`);let r={application:t.application,environment:t.environment},i=S.t(`popup.site.bindPartial.${n}`,r),a=Xe(S,e,`popup.site.bindPartial.${n}`,r);return a===i?a:Dr(t,a)}function Or(e,t,n,r,i){let{defaultApplicationId:a,proposal:o}=i,s=e.application,c=s.kind===`existing`&&!t.applications.some(e=>e.id===s.id)?{kind:`existing`,id:a}:s;if(!t.applications.some(e=>e.id===a))throw Error(`The default application ${a} left the project`);let l={...e,lists:t,application:c},u=e.environment;if(u!==null&&u.kind===`existing`&&!t.environments.some(e=>e.id===u.id)){let e=br(t,c.kind===`existing`?c.id:null,o);l={...l,environment:e.choice,environmentAllTaken:e.allTaken,environmentChosen:!1}}let d=Sr(n),f=_r(t,l.application,l.environment);return d===`targets.cell_exists`?{...l,fresh:f===null?null:`taken`,failure:null}:d===`targets.modified_concurrently`?{...l,fresh:f===null?null:`changed`,failure:null}:d===`targets.host_conflict`?{...l,fresh:null,failure:kr(n,l,r,i.host)}:{...l,fresh:null,failure:K(n,r)}}function kr(e,t,n,r){var i;let a=e instanceof He&&typeof((i=e.params)==null?void 0:i.applicationId)==`string`?e.params.applicationId:null,o=t.lists.applications.find(e=>e.id===a),s=t.environment,c=s!==null&&s.kind===`existing`?t.lists.environments.find(e=>e.id===s.id):void 0;return o===void 0||c===void 0?K(e,n):Dr(n,S.t(`popup.site.hostConflict`,{host:r,application:o.name,environment:c.name}))}var q=V(`pgs-e9b150372c`);function Ar(e){let{defaultApplicationId:t,host:n,proposal:r,requests:i}=e,[a,o]=(0,H.useState)(()=>{let n=br(e.lists,t,r);return{lists:e.lists,application:{kind:`existing`,id:t},environment:n.choice,environmentChosen:!1,environmentAllTaken:n.allTaken,problem:null,failure:null,fresh:null,pending:!1,createUnsettled:!1,focus:null}}),s=(0,H.useRef)(!1),c=(0,H.useRef)(0),l=()=>(c.current+=1,c.current),u=(e,t)=>({target:e,field:t,seq:l()}),d=(e,t)=>{if(e.environmentChosen&&e.environment!==null)return{environment:e.environment,environmentAllTaken:e.environmentAllTaken};let n=br(e.lists,t.kind===`existing`?t.id:null,r);return{environment:n.choice,environmentAllTaken:n.allTaken}},f=(e,t)=>({...e,application:t,...d(e,t),problem:null,failure:null,fresh:null}),p=(e,t)=>({...e,environment:t,environmentChosen:!0,environmentAllTaken:!1,problem:null,failure:null,fresh:null}),m=(e,t)=>{s.current||o(n=>{if(e===`application`)return t===`new`?{...f(n,{kind:`new`,name:``}),focus:u(`input`,e)}:f(n,{kind:`existing`,id:t});if(t!==`new`)return p(n,{kind:`existing`,id:t});let i=yr(n.lists.environments,r.name)!==null;return{...p(n,{kind:`new`,name:i?``:r.name}),focus:u(`input`,e)}})},h=(e,t)=>{o(n=>{let r=e===`application`?n.application:n.environment;if(r===null||r.kind!==`new`)throw Error(`The ${e} field is not a new name, it cannot be renamed`);let i={kind:`new`,name:t};return{...n,...e===`application`?{application:i}:{environment:i},problem:n.problem!==null&&n.problem.field===e?null:n.problem}})},g=e=>{s.current||o(n=>{if(e===`application`)return{...f(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)};if(n.lists.environments.length===0)throw Error(`A project without environments has no list to go back to`);let i=br(n.lists,n.application.kind===`existing`?n.application.id:null,r),a=i.choice.kind===`existing`?i.choice:null;return{...p(n,a),focus:u(`trigger`,e)}})},_=(e,t)=>{o(n=>({...e===`application`?f(n,{kind:`existing`,id:t}):p(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)}))},v=async a=>{let s={application:null,environment:null},c=a;if(c.createUnsettled)try{c=b(c,await i.readLists(),s)}catch(e){q.error(`pgm-9a173522f2`,{error:Cr(e)}),o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}let u=c.environment;if(u===null)throw Error(`The bind press ran with no environment chosen`);let d=null;try{let t;if(c.application.kind===`new`){d=`application`;let n=await i.createApplication(c.application.name.trim());d=null,s.application=n.name,t=n.id,o(e=>({...e,lists:{...e.lists,applications:[...e.lists.applications,n]},application:{kind:`existing`,id:n.id}})),e.onApplicationCreated()}else t=c.application.id;let n;if(u.kind===`new`){d=`environment`;let t=await i.createEnvironment(u.name.trim(),c.lists.environments.length===0);d=null,s.environment=t.name,n=t.id,o(e=>({...e,lists:{...e.lists,environments:[...e.lists.environments,t]},environment:{kind:`existing`,id:t.id},environmentAllTaken:!1})),e.onEnvironmentCreated()}else n=u.id;let r=_r(c.lists,c.application,u);r===null?await i.createCell(t,n):await i.replaceCell(r)}catch(e){if(q.error(`pgm-53ab6bb5fe`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null,status:e instanceof He?e.status:null,code:Sr(e),error:Cr(e)}),d!==null){await y(c,s,e);return}if(Tr(e))try{let a=await i.readLists();o(i=>({...Or(i,a,e,s,{defaultApplicationId:t,proposal:r,host:n}),focus:{target:`submit`,seq:l()}}));return}catch(e){q.error(`pgm-a2654be732`,{error:Cr(e)})}o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}q.info(`pgm-dfe3d492ed`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null}),await e.onBound()},y=async(e,t,n)=>{let r;try{r=await i.readLists()}catch(e){q.error(`pgm-200d50f185`,{error:Cr(e)}),o(e=>({...e,createUnsettled:!0,failure:K(n,t),focus:{target:`submit`,seq:l()}}));return}b(e,r,t),o(e=>({...e,failure:K(n,t),focus:{target:`submit`,seq:l()}}))},b=(t,n,r)=>{let i=wr(t,n,r);i.application!==null&&(r.application=i.application.name,e.onApplicationCreated()),i.environment!==null&&(r.environment=i.environment.name,e.onEnvironmentCreated()),(i.application!==null||i.environment!==null)&&q.info(`pgm-52181e7844`,{application:i.application!==null,environment:i.environment!==null});let a=e=>({...e,lists:n,createUnsettled:!1,...i.application===null?{}:{application:{kind:`existing`,id:i.application.id}},...i.environment===null?{}:{environment:{kind:`existing`,id:i.environment.id},environmentAllTaken:!1}});return o(a),a(t)};return{state:a,choose:m,rename:h,backToList:g,chooseExisting:_,submit:()=>{if(!s.current){if(a.environment===null){o(e=>({...e,problem:{field:`environment`,kind:`unchosen`},focus:u(`trigger`,`environment`)}));return}for(let e of[`application`,`environment`]){let t=e===`application`?a.application:a.environment;if(t.kind!==`new`)continue;if(t.name.trim()===``){o(t=>({...t,problem:{field:e,kind:`empty`},focus:u(`input`,e)}));return}let n=yr(e===`application`?a.lists.applications:a.lists.environments,t.name);if(n!==null){o(t=>({...t,problem:{field:e,kind:`duplicate`,id:n.id,name:n.name},focus:u(`input`,e)}));return}}s.current=!0,o(e=>({...e,pending:!0,failure:null,fresh:null,problem:null})),e.onPressStarted(),v(a).finally(()=>{s.current=!1,o(e=>({...e,pending:!1})),e.onPressEnded()})}}}}var jr=V(`pgs-e9b150372c`),Mr=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function Nr(e){let{t}=F(),r=Ar(e),{state:i}=r,a=(0,H.useId)(),s=e=>`${a}-${e}`,c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=i.focus;if(e===null)return;let t;if(t=e.target===`submit`?u.current:e.target===`input`?(e.field===`application`?c:l).current:document.getElementById(`${a}-${e.field}`),t===null){jr.warn(`pgm-9d57cb6e57`,{target:e.target});return}t.focus()},[i.focus,a]);let{lists:d,application:f,environment:p,pending:m,problem:h}=i,g=f.kind===`new`?f.name:Pr(d.applications,f.id),_=p===null?``:p.kind===`new`?p.name:Pr(d.environments,p.id),v=_r(d,f,p),y=e=>{if(h!==null&&h.field===e)return h.kind===`empty`?t(e===`application`?`popup.site.emptyApplication`:`popup.site.emptyEnvironment`):h.kind===`unchosen`?t(`popup.site.environmentRequired`):/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[t(e===`application`?`popup.site.duplicateApplication`:`popup.site.duplicateEnvironment`,{name:h.name}),` `,/* @__PURE__ */ (0,U.jsx)(N,{variant:`link`,size:`xs`,onClick:()=>r.chooseExisting(e,h.id),"data-testid":`popup-bind-${e}-choose-existing`,children:t(`popup.site.chooseExisting`)})]})},b=(e,n,i)=>{let a=e===`application`||d.environments.length>0;return/* @__PURE__ */ (0,U.jsx)(Ze,{ref:e===`application`?c:l,id:s(e),size:`sm`,fieldClassName:`grid-cols-1`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),placeholder:t(e===`application`?`popup.site.newApplicationPlaceholder`:`popup.site.newEnvironmentPlaceholder`),autoComplete:`off`,value:n,onValueChange:t=>r.rename(e,t),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),r.submit()):t.key===`Escape`&&a&&(t.preventDefault(),r.backToList(e))},disabled:m,leading:/* @__PURE__ */ (0,U.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5 text-fg-link`}),trailing:a?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:t(`popup.site.backToList`),placement:`top`,children:/* @__PURE__ */ (0,U.jsx)(D,{size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(o,{"aria-hidden":`true`}),onClick:()=>r.backToList(e),disabled:m,"data-testid":`popup-bind-${e}-back`})}):void 0,hint:i,error:y(e),className:Mr,"data-testid":`popup-bind-${e}-name`},`${e}-new`)},x=e=>({options:[{value:`new`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),icon:/* @__PURE__ */ (0,U.jsx)(ve,{"aria-hidden":`true`,className:`text-fg-link`})}]}),S=f.kind===`new`?b(`application`,f.name,void 0):/* @__PURE__ */ (0,U.jsx)(Qe,{id:s(`application`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.applicationLabel`),value:f.id,onValueChange:e=>r.choose(`application`,e),disabled:m,groups:[{options:d.applications.map(e=>({value:e.id,label:e.name}))},x(`application`)],"data-testid":`popup-bind-application`},`application-list`),C;d.environments.length===0?C=t(`popup.site.noEnvironmentsHint`):i.environmentAllTaken&&(C=/* @__PURE__ */ (0,U.jsx)(`span`,{className:`wrap-anywhere`,children:t(`popup.site.allTakenHint`,{application:g.trim()===``?`\u2026`:g.trim()})}));let ee=p!==null&&p.kind===`new`?b(`environment`,p.name,C):/* @__PURE__ */ (0,U.jsx)(Qe,{id:s(`environment`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.environmentLabel`),value:p===null?null:p.id,placeholder:t(`popup.site.environmentPlaceholder`),error:y(`environment`),onValueChange:e=>r.choose(`environment`,e),disabled:m,groups:[{options:d.environments.map(e=>{let n=f.kind===`existing`?gr(d.cells,f.id,e.id):null;return n===null?{value:e.id,label:e.name}:{value:e.id,label:e.name,description:t(`popup.site.taken`,{address:n.address})}})},x(`environment`)],"data-testid":`popup-bind-environment`},`environment-list`);return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`group`,"aria-label":t(`popup.site.bind`),"aria-busy":m,className:`grid min-w-0 grid-cols-1 gap-2.5 rounded-md border border-stroke-light bg-surface-modal-inset px-3 pt-2.5 pb-3`,"data-testid":`popup-bind-form`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2.5`,children:[S,ee]}),h===null&&p!==null&&/* @__PURE__ */ (0,U.jsx)(dr,{host:e.host,applicationName:g,environmentName:_,newApplication:f.kind===`new`,newEnvironment:p.kind===`new`,replaced:v,fresh:i.fresh}),i.failure!==null&&/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-1.5 text-(length:--text-compact) leading-(--leading-caption) text-fg-error`,"data-testid":`popup-bind-failure`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:i.failure})]}),/* @__PURE__ */ (0,U.jsx)(N,{ref:u,size:`sm`,icon:v===null?/* @__PURE__ */ (0,U.jsx)(w,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(cn,{"aria-hidden":`true`}),loading:m,onClick:r.submit,className:`justify-self-end`,"data-testid":`popup-bind-submit`,children:t(v===null?`popup.site.bind`:`popup.site.replace`)})]})}function Pr(e,t){let n=e.find(e=>e.id===t);if(n===void 0)throw Error(`The bind form chose ${t}, absent from its list`);return n.name}function J({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{"aria-live":`polite`,className:`grid grid-cols-1 gap-2 border-t border-stroke-light py-2.5 pr-3 pl-3.5 animate-ui-fade-in motion-reduce:animate-none`,"data-testid":`popup-site`,children:e})}function Y({host:e}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-body-sm text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(C,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-fg-muted`}),/* @__PURE__ */ (0,U.jsx)(`b`,{className:`min-w-0 truncate font-medium text-fg-primary`,children:e})]})}var Fr=`inline-flex h-6 items-center rounded-full border border-stroke bg-surface-hover-layer text-xs text-fg-primary`;function Ir({applicationName:e,environmentName:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{"aria-label":n(`popup.site.cellLabel`),className:`flex flex-wrap items-center gap-1.5`,"data-testid":`popup-site-cell`,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(Fr,`px-2.25 font-medium`),children:e}),/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-fg-muted`,children:`\u00D7`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(Fr,`px-2.5 font-semibold animate-[popup-environment-in_var(--motion-long)_var(--ease-out)_both]`),children:t})]})}function Lr({children:e,hintName:t,hint:n,tone:r=`default`,icon:i}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:h(`flex min-w-0 items-center gap-1.5 [&>svg]:size-3.5 [&>svg]:shrink-0`,r===`warning`&&`text-fg-warning`),children:[i,/* @__PURE__ */ (0,U.jsx)(`p`,{className:h(`m-0 min-w-0 text-(length:--text-compact) leading-normal [&_b]:font-semibold [&_b]:text-fg-primary`,r===`warning`?`text-inherit`:r===`muted`?`text-fg-muted`:`text-fg-secondary`),children:e}),/* @__PURE__ */ (0,U.jsx)(B,{name:t,text:n,placement:`bottom-start`})]})}var Rr=V(`pgs-f048f86b7e`);function zr({projectId:e,host:t,environments:n,chosenId:r,onChosen:i}){let{t:a}=F(),o=x(),[s,c]=(0,H.useState)(!1);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:a(`popup.site.more`,{about:a(`popup.site.environmentChoice`)}),hint:a(`popup.site.environmentChoiceHint`),children:a(`popup.site.environmentChoice`)}),/* @__PURE__ */ (0,U.jsx)(Qe,{size:`sm`,"aria-label":a(`popup.site.environmentLabel`),placeholder:a(`popup.site.environmentPlaceholder`),value:r,onValueChange:t=>{s||(c(!0),L.environments.setActive(O(e),`extension`,t).then(()=>{Rr.info(`pgm-f54cd7418d`,{projectId:e}),i()}).catch(t=>{Rr.error(`pgm-effdde2b56`,{projectId:e,error:t instanceof Error?t.message:String(t)}),o.show({id:`popup-environment-choice`,variant:`error`,message:a(`popup.site.environmentFailed`)})}).finally(()=>c(!1)))},disabled:s,options:n.map(e=>({value:e.id,label:e.name,description:t})),"data-testid":`popup-site-environment`})]})}function Br(e){let t=e.toLowerCase();return/(^|\/\/|\.)dev\./.test(t)?`dev`:/stag/.test(t)?`staging`:/localhost|127\.0/.test(t)?`local`:`prod`}function Vr(e){let t=e.toLowerCase();return/prod/.test(t)?`production`:/stag/.test(t)?`staging`:/dev|local|\u043B\u043E\u043A\u0430\u043B/.test(t)?`dev`:`custom`}function Hr(e){let t=Br(e);return{key:`popup.site.environmentSuggestion.${t}`,type:fr[t]}}function Ur(e){return{targetId:e.id,applicationId:e.applicationId,environmentId:e.environmentId,baseUrl:e.baseUrl,hostPattern:e.hostPattern}}function Wr(e,t,n){let{targets:r,applications:i,environments:a}=t,o=r.find(e=>e.baseUrl===null&&e.hostPattern===null);if(o!==void 0)return{kind:`inconsistent`,reason:`Cell ${o.id} has neither an origin nor a host pattern`};let s=mt(n.href,r.map(Ur),null);switch(s.kind){case`matched`:{let t=Kr(i,s.applicationId),n=Kr(a,s.environmentId);return t===null||n===null?qr(e,t===null?s.applicationId:s.environmentId):{kind:`matched`,applicationName:t,environmentName:n}}case`ambiguous_application`:{let t=Kr(a,s.environmentId);return t===null?qr(e,s.environmentId):{kind:`ambiguous`,environmentName:t}}case`environment_choice`:{let t=s.environmentIds.find(e=>!a.some(t=>t.id===e));return t===void 0?{kind:`environmentChoice`,environments:a.filter(e=>s.environmentIds.includes(e.id)).map(e=>({id:e.id,name:e.name}))}:qr(e,t)}case`unknown_host`:case`no_targets`:{let n=i.find(e=>e.isDefault);return n===void 0?{kind:`inconsistent`,reason:`Project ${e} has no default application`}:{kind:`bind`,reason:s.kind,lists:Xr(t),defaultApplicationId:n.id}}case`unsupported_url`:return{kind:`unsupported`}}}function Gr(e,t){if(e.source!==`user_preference`||e.environmentId===null)return null;let n=e.environmentId;return t.some(e=>e.id===n)?n:null}function Kr(e,t){let n=e.find(e=>e.id===t);return n===void 0?null:n.name}function qr(e,t){return{kind:`inconsistent`,reason:`A cell of project ${e} names ${t}, absent from the lists read`}}async function Jr(e,t){let n=O(t),[r,i,a]=await Promise.all([e.targets.listAll(n),e.applications.byProject(n),e.environments.list(n)]);return{targets:r,applications:i,environments:a}}async function Yr(e,t){return Xr(await Jr(e,t))}function Xr(e){return{applications:e.applications.map(Zr),environments:e.environments.map(Qr),cells:e.targets.map($r)}}function Zr(e){return{id:e.id,name:e.name}}function Qr(e){return{id:e.id,name:e.name,envType:e.envType,isDefault:e.isDefault}}function $r(e){let t;if(e.baseUrl!==null)t=new URL(e.baseUrl).host;else if(e.hostPattern!==null)t=e.hostPattern;else throw Error(`Cell ${e.id} has neither an origin nor a host pattern`);return{id:e.id,applicationId:e.applicationId,environmentId:e.environmentId,address:t,hostPattern:e.hostPattern,updatedAt:e.updatedAt}}async function ei(e,t,n){return Zr(await e.applications.create({projectId:O(t),name:n}))}async function ti(e,t,n,r){return Qr(await e.environments.create({projectId:O(t),name:n,envType:Vr(n),isDefault:r}))}async function ni(e,t,n,r,i){await e.targets.create(O(t),{applicationId:ne(r),environmentId:i,baseUrl:n})}async function ri(e,t,n,r){let i=r.hostPattern!==null&&ht(n,[{targetId:r.id,applicationId:r.applicationId,environmentId:r.environmentId,baseUrl:null,hostPattern:r.hostPattern}]).length>0;await e.targets.update(O(t),r.id,{baseUrl:n,...r.hostPattern===null||i?{}:{hostPattern:null},expectedUpdatedAt:r.updatedAt})}var ii=V(`pgs-c1e3b0bb6f`);function ai({page:e,projects:t,onSelect:n}){let{t:r}=F(),a=ct(),{data:o,error:s}=A({key:i(a,`target-matches`,e.href),read:()=>L.targets.match(e.href),freshness:`screen`});if((0,H.useEffect)(()=>{s!==null&&ii.error(`pgm-f294aabbd9`,{error:s.message})},[s]),s!==null||o===void 0)return null;let c=new Set(o.items.map(e=>e.projectId)),l=t.filter(e=>c.has(e.id));return l.length===0?null:/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:e.host}),l.map(e=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover-layer py-2 pr-2 pl-2.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 truncate text-(length:--text-compact) leading-(--leading-caption) text-fg-secondary`,children:[r(`popup.site.suggestion`),` `,/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:r(`popup.site.suggestionProject`,{project:e.name})})]}),/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,onClick:()=>n(e),"data-testid":`popup-site-suggestion`,children:r(`popup.site.select`)})]},e.id))]})}var oi=V(`pgs-94aad7e91e`),si={phase:`none`};function ci(e,t){let n=u(),[r,i]=(0,H.useState)(si),a=(0,H.useRef)({applications:null,environments:null}),o=(0,H.useMemo)(()=>({kind:`project`,projectId:e}),[e]),s=Ue({projectId:e}),c=je({projectId:e}),l=lt({projectId:e}),d=t.href,f=(0,H.useMemo)(()=>s.data===void 0||c.data===void 0||l.data===void 0?null:Wr(e,{targets:s.data,applications:c.data,environments:l.data},new URL(d)),[e,s.data,c.data,l.data,d]),p=ut({projectId:e,client:`extension`},{enabled:f!==null&&f.kind===`environmentChoice`}),m=f!==null&&f.kind===`inconsistent`?f.reason:null;(0,H.useEffect)(()=>{m!==null&&oi.error(`pgm-0efc4cf256`,{projectId:e,reason:m})},[m,e]);let h=[s,c,l],g=e=>()=>{for(let t of e)t.reload()},_,v=h.filter(li);if(v.length>0)_={status:`failed`,retry:g(v)};else if(f===null)_={status:`loading`};else if(f.kind===`inconsistent`)_={status:`failed`,retry:g(h)};else if(f.kind===`environmentChoice`){if(li(p))_={status:`failed`,retry:g([p])};else if(p.data===void 0)_={status:`loading`};else{let e=Gr(p.data,f.environments);_={status:`ready`,screen:{...f,chosenId:e}}}}else _={status:`ready`,screen:f};r.phase===`outcome`&&_.status!==`failed`&&i(si);let y=_;return(r.phase===`press`||r.phase===`outcome`&&_.status===`failed`)&&(y={status:`binding`,screen:r.screen,retry:_.status===`failed`?_.retry:null}),{state:y,bindStarted:()=>{let e;if(y.status===`binding`)e=y.screen;else if(y.status===`ready`&&y.screen.kind===`bind`)e=y.screen;else throw Error(`A bind press started while the site strip is ${y.status}`);a.current={applications:null,environments:null},i({phase:`press`,screen:e})},bindEnded:()=>{i(e=>e.phase===`press`?{phase:`outcome`,screen:e.screen}:e)},afterApplicationCreated:()=>{a.current.applications=n.invalidateAfterChange(Le(o))},afterEnvironmentCreated:()=>{a.current.environments=n.invalidateAfterChange(ot(o))},afterBind:async()=>{let e=a.current;a.current={applications:null,environments:null};let t=(e,t)=>e===null?n.invalidateAfterChange(t):e;await Promise.all([t(e.applications,Le(o)),t(e.environments,ot(o))]),await n.invalidateAfterChange(ke(o)),i(si)},afterEnvironmentChosen:()=>{n.invalidateAfterChange(Re(o))}}}function li(e){return e.error!==null||e.refreshError!==null}var ui=V(`pgs-3b85b4fc58`);function di({tabId:e,project:t,projects:n,onSelectProject:r}){let i=fi(e);if(i.status!==`read`)return null;let a=i.url,o=a===null?null:E(a),s=o!==null&&o.ok?o.url:null;return t===null?s===null?null:/* @__PURE__ */ (0,U.jsx)(ai,{page:s,projects:n,onSelect:r}):s===null?/* @__PURE__ */ (0,U.jsx)(pi,{}):/* @__PURE__ */ (0,U.jsx)(mi,{project:t,page:s})}function fi(e){let[t,n]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let t=!0;return chrome.tabs.get(e).then(r=>{t&&n({tabId:e,result:{status:`read`,url:r.url??null}})},r=>{ui.error(`pgm-df207305cf`,{tabId:e,error:r instanceof Error?r.message:String(r)}),t&&n({tabId:e,result:{status:`failed`}})}),()=>{t=!1}},[e]),t===null||t.tabId!==e?{status:`reading`}:t.result}function pi(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(J,{children:/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`muted`,hintName:e(`popup.site.more`,{about:e(`popup.site.notSite`)}),hint:e(`popup.site.notSiteHint`),children:e(`popup.site.notSite`)})})}function mi({project:e,page:t}){let{t:n}=F(),r=ci(O(e.id),t),{state:i}=r,a={createApplication:t=>ei(L,e.id,t),createEnvironment:(t,n)=>ti(L,e.id,t,n),createCell:(n,r)=>ni(L,e.id,t.origin,n,r),replaceCell:n=>ri(L,e.id,t.origin,n),readLists:()=>Yr(L,e.id)},o=async()=>{try{let t=await R.call(`REFRESH_PROJECT_TARGETS`,{projectId:e.id});t.success||ui.error(`pgm-ef389a0081`,{projectId:e.id,error:t.error})}catch(t){ui.error(`pgm-fc30de5d00`,{projectId:e.id,error:t instanceof Error?t.message:String(t)})}await r.afterBind()};if(i.status===`failed`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(gi,{retry:i.retry})]});if(i.status===`loading`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":n(`popup.site.reading`),className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-20.5 rounded-full`})]})]});let s=(n,i)=>/* @__PURE__ */ (0,U.jsx)(hi,{project:e,page:t,screen:n,retry:i,requests:a,site:r,onBound:o});if(i.status===`binding`)return s(i.screen,i.retry);let c=i.screen;switch(c.kind){case`unsupported`:return/* @__PURE__ */ (0,U.jsx)(pi,{});case`matched`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Ir,{applicationName:c.applicationName,environmentName:c.environmentName})]});case`ambiguous`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`warning`,icon:/* @__PURE__ */ (0,U.jsx)(ge,{"aria-hidden":`true`}),hintName:n(`popup.site.more`,{about:n(`popup.site.ambiguous`,{environment:c.environmentName})}),hint:n(`popup.site.ambiguousHint`),children:n(`popup.site.ambiguous`,{environment:c.environmentName})})]});case`environmentChoice`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(zr,{projectId:e.id,host:t.host,environments:c.environments,chosenId:c.chosenId,onChosen:r.afterEnvironmentChosen})]});case`bind`:return s(c,null)}}function hi({project:e,page:t,screen:n,retry:r,requests:i,site:a,onBound:o}){let{t:s}=F(),c=Hr(t.host);return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),r!==null&&/* @__PURE__ */ (0,U.jsx)(gi,{retry:r}),/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:s(`popup.site.bindMore`),hint:s(`popup.site.bindInfo`),children:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:n.reason===`no_targets`?`popup.site.noTargets`:`popup.site.notBound`,components:{b:/* @__PURE__ */ (0,U.jsx)(`b`,{}),project:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e.name})}})}),/* @__PURE__ */ (0,U.jsx)(Nr,{lists:n.lists,defaultApplicationId:n.defaultApplicationId,host:t.host,proposal:{name:s(c.key),type:c.type},requests:i,onPressStarted:a.bindStarted,onPressEnded:a.bindEnded,onApplicationCreated:a.afterApplicationCreated,onEnvironmentCreated:a.afterEnvironmentCreated,onBound:o})]})}function gi({retry:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{role:`alert`,className:`m-0 flex gap-1.5 text-(length:--text-compact) leading-normal text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.site.readFailed`)})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{children:/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(fe,{"aria-hidden":`true`}),onClick:e,"data-testid":`popup-site-retry`,children:t(`common.retry`)})})]})}var _i=V(`pgs-930365a583`),vi=`all`;function yi({tabId:e,applications:t,applicationId:n}){let{t:r}=F(),i=x();return/* @__PURE__ */ (0,U.jsx)(Qe,{appearance:`inline`,label:r(`popup.application.label`),value:n===null?vi:n,onValueChange:t=>{let n=t===vi?null:t;R.call(`SET_TAB_STATE`,{tabId:e,state:{applicationId:n}}).then(e=>{if(!e.success)throw Error(`SET_TAB_STATE refused: ${e.error}`)}).catch(t=>{_i.error(`pgm-e58825e7fe`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-application`,variant:`error`,message:r(`popup.application.switchFailed`)})})},options:[{value:vi,label:r(`popup.application.all`)},...t.map(e=>({value:e.id,label:e.name}))],"data-testid":`popup-application`})}function bi({run:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-b-lg border-t border-stroke-light bg-[color-mix(in_srgb,var(--color-info)_8%,transparent)] py-2.25 pr-3 pl-3.5 text-(length:--text-compact) leading-snug`,"data-testid":`popup-run-line`,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-info shadow-(--glow-status-info) animate-pulse-dot`}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:e.kind===`free`?t(`popup.run.free`,{number:e.number}):t(`popup.run.plan`,{plan:e.planName})}),` `,t(`popup.run.where`)]})]})}var xi=V(`pgs-c184079221`);function Si({tabId:e,projects:t,tabProject:n,applicationId:r,run:i,onPick:a,pickerOpen:o,onPickerOpenChange:s}){let{t:c}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":c(`popup.project.contextLabel`),className:`relative rounded-lg border border-(--color-border-overlay) bg-surface-card shadow-(--shadow-context-card)`,"data-testid":`popup-context`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`relative grid p-2`,children:[/* @__PURE__ */ (0,U.jsx)(cr,{value:n===null?null:{id:n.id,name:n.name},onValueChange:a,list:{state:`ready`,projects:t},labels:{label:c(`popup.project.label`),placeholder:c(`popup.project.placeholder`),search:c(`popup.project.search`),empty:c(`popup.project.empty`),loading:c(`popup.project.loading`),retry:c(`common.retry`)},open:o,onOpenChange:s,autoFocus:!0,"data-testid":`popup-project`}),n!==null&&/* @__PURE__ */ (0,U.jsx)(Ci,{tabId:e,projectId:O(n.id),applicationId:r},n.id)]}),/* @__PURE__ */ (0,U.jsx)(di,{tabId:e,project:n,projects:t,onSelectProject:a},`${e}:${n===null?``:n.id}`),i!==null&&/* @__PURE__ */ (0,U.jsx)(bi,{run:i})]})}function Ci({tabId:e,projectId:t,applicationId:n}){let{data:r,error:i}=je({projectId:t});return(0,H.useEffect)(()=>{i!==null&&xi.error(`pgm-f42292fd59`,{error:i.message})},[i]),i!==null||r===void 0||r.length<=1?null:/* @__PURE__ */ (0,U.jsx)(yi,{tabId:e,applications:r,applicationId:n})}var wi=[{key:`bugs`,tone:`error`},{key:`checklists`,tone:`primary`},...qe.incidentsEnabled?[{key:`incidents`,tone:`warning`}]:[]],Ti={bugs:`popup.filters.bugs`,checklists:`popup.filters.checklists`,incidents:`popup.filters.incidents`};function Ei(){let{t:e}=F(),t=W(`filters`),n=G();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":e(`popup.filters.title`),className:`grid gap-2`,"data-testid":`popup-filters`,children:[/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`mx-0.5 my-0 text-xs font-medium text-fg-muted`,children:e(`popup.filters.title`)}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t===void 0?wi.map(e=>/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-24 rounded-full`},e.key)):wi.map(r=>/* @__PURE__ */ (0,U.jsx)(Zt,{pressed:t[r.key],tone:r.tone,size:`md`,onClick:()=>n(`filters`,{...t,[r.key]:!t[r.key]}),"data-testid":`popup-filter-${r.key}`,children:e(Ti[r.key])},r.key))})]})}function Di(){let{t:e}=F(),t=G();return/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,children:/* @__PURE__ */ (0,U.jsx)(Fe,{tone:`info`,icon:/* @__PURE__ */ (0,U.jsx)(fn,{"aria-hidden":`true`}),title:e(`popup.paused.title`),actionsPlacement:`below`,actions:/* @__PURE__ */ (0,U.jsx)(it,{onClick:()=>t(`enabled`,!0),children:e(`popup.paused.enable`)}),"data-testid":`popup-paused`})})}function Oi({projectSwitch:e,currentProjectName:t}){let{t:n}=F(),{question:r,busy:i,confirm:a,cancel:s}=e;if(r===null)return null;let{run:c,target:l}=r,u=c.kind===`free`,d=c.kind===`free`?n(`popup.switchRun.freeText`,{number:c.number,project:l.name}):t===null?n(`popup.switchRun.planTextNoProject`,{plan:c.planName}):n(`popup.switchRun.planText`,{plan:c.planName,project:t});return/* @__PURE__ */ (0,U.jsx)(le,{open:!0,busy:i,onCancel:s,tone:u?`danger`:`warning`,icon:u?/* @__PURE__ */ (0,U.jsx)(o,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(ln,{"aria-hidden":`true`}),title:n(u?`popup.switchRun.freeTitle`:`popup.switchRun.planTitle`),description:d,"data-testid":`popup-project-switch-question`,actions:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,onClick:s,children:n(`popup.switchRun.stay`)}),/* @__PURE__ */ (0,U.jsx)(N,{variant:u?`danger`:`primary`,loading:i,onClick:a,"data-testid":`popup-project-switch-confirm`,children:n(u?`popup.switchRun.freeConfirm`:`popup.switchRun.planConfirm`)})]})})}var ki=V(`pgs-ab0307fe13`);function Ai({tabId:e,projectId:t,currentTestRun:n}){let{t:r}=F(),i=x(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=async t=>{let n=await R.call(`RESTORE_PROJECT`,{tabId:e,projectId:t.id,projectNumber:t.number,applicationId:null});if(!n.success)throw Error(`RESTORE_PROJECT refused: ${n.error}`);ki.info(`pgm-496ade1c1d`,{tabId:e})},u=t=>{ki.error(`pgm-61ab57a774`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-project-switch`,variant:`error`,message:r(`popup.project.switchFailed`)})};return{question:a,busy:s,choose(e){if(e.id!==t){if(n!==null){o({target:e,run:n});return}l(e).catch(u)}},confirm(){a===null||s||(c(!0),l(a.target).catch(u).finally(()=>{c(!1),o(null)}))},cancel(){s||o(null)}}}function ji({user:e,header:t,back:n,strip:r,snapshot:i,projects:a,tabProject:o}){let{t:s}=F(),l=W(`enabled`),[u,d]=(0,H.useState)(!1),{state:f,tabId:p}=i,m=Ai({tabId:p,projectId:f.projectId,currentTestRun:f.currentTestRun}),g;switch(a.state){case`loading`:g=/* @__PURE__ */ (0,U.jsx)(vn,{});break;case`error`:g=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(ae,{icon:/* @__PURE__ */ (0,U.jsx)(jt,{"aria-hidden":`true`}),title:s(`popup.projects.failedTitle`),description:s(`popup.projects.failedText`),retry:{label:s(`common.retry`),onRetry:a.retry}})});break;case`ready`:{if(a.projects.length===0){g=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(pe,{icon:/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`}),title:s(`popup.projects.emptyTitle`),description:s(`popup.projects.emptyText`),action:/* @__PURE__ */ (0,U.jsx)(N,{icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onClick:()=>c(),children:s(`popup.projects.openWeb`)})})});break}let t=/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Si,{tabId:p,projects:a.projects,tabProject:o,applicationId:f.applicationId,run:f.currentTestRun,onPick:m.choose,pickerOpen:u,onPickerOpenChange:d}),/* @__PURE__ */ (0,U.jsx)(Ei,{})]});g=o===null?t:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(o.id),number:ue(o.number)},children:t});break}}let _=a.state===`ready`&&a.projects.length>0;return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:h(`flex min-h-0 flex-1 flex-col`,n?Dt:Ct),children:[t,/* @__PURE__ */ (0,U.jsxs)(gn,{className:_&&u?`min-h-90`:void 0,children:[_&&l===!1&&/* @__PURE__ */ (0,U.jsx)(Di,{}),r,g]}),/* @__PURE__ */ (0,U.jsx)(Oi,{projectSwitch:m,currentProjectName:o===null?null:o.name})]})}function Mi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`grid min-h-84 content-center`,children:e})}function Ni(){let{data:e,loading:t,error:n,reload:r}=ee(),i=(0,H.useMemo)(()=>new Map(e===void 0?[]:e.map(e=>[e.id,e])),[e]);return n===null?t||e===void 0?{state:`loading`}:{state:`ready`,projects:e,byId:i}:{state:`error`,error:n,retry:()=>void r()}}var Pi=V(`pgs-aea740cf56`);function Fi({windowId:e,revision:t,back:n,onBack:r,onOpenSettings:i}){let{t:a}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n?Dt:Ct}`,"data-testid":`popup-notification-feed`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:r,autoFocus:!0,"data-testid":`popup-feed-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 mr-auto text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:a(`notifications.feed.title`)}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`notifications.feed.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:i,"data-testid":`popup-feed-settings`})})]}),/* @__PURE__ */ (0,U.jsx)(_t,{host:`popup`,api:L.notifications,locale:Se(),t:a,revision:t,logger:Pi,onOpenTarget:t=>St(t,e),onOpenSettings:i,onSeen:()=>Ot(`seen`)})]})}var Ii=V(`pgs-a3c52049ce`);function Li({windowId:e,waitingCount:t,revision:n,onOpenFeed:r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsx)(xt,{api:L.notifications,locale:Se(),t:i,waitingCount:t,revision:n,logger:Ii,onOpenTarget:t=>St(t,e),onOpenFeed:r,onSeen:()=>Ot(`seen`)})}function Ri({value:e,onChange:t,labels:n,size:r,fullWidth:i,className:a}){return/* @__PURE__ */ (0,U.jsx)(m,{value:e,onValueChange:t,"aria-label":n.group,size:r,fullWidth:i,className:a,options:[{value:`light`,label:n.light,icon:/* @__PURE__ */ (0,U.jsx)(pn,{"aria-hidden":`true`})},{value:`dark`,label:n.dark,icon:/* @__PURE__ */ (0,U.jsx)(dn,{"aria-hidden":`true`})},{value:`system`,label:n.system,icon:/* @__PURE__ */ (0,U.jsx)(Mt,{"aria-hidden":`true`})}]})}function X({title:e,hint:t,children:n,"data-testid":r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{className:`grid gap-1.5`,"data-testid":r,children:[/* @__PURE__ */ (0,U.jsxs)(`h3`,{className:`mx-0.5 my-0 flex items-center gap-1 text-xs font-medium text-fg-muted`,children:[e,t!==void 0&&/* @__PURE__ */ (0,U.jsx)(B,{name:i(`popup.site.more`,{about:e}),text:t,placement:`bottom-start`})]}),/* @__PURE__ */ (0,U.jsx)(nn,{kind:`block`,body:`rows`,density:`compact`,children:/* @__PURE__ */ (0,U.jsx)(y,{children:n})})]})}function Z({label:e,below:t,stacked:n=!1,alignStart:r=!1,children:i,"data-testid":a}){return/* @__PURE__ */ (0,U.jsx)(_e,{title:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:e}),end:i,stacked:n,alignStart:r,"data-testid":a,children:t})}var zi={on:`bg-success shadow-(--glow-status-success)`,neutral:`bg-fg-muted`,warning:`bg-warning`,error:`bg-error`},Bi={on:`text-fg-muted`,neutral:`text-fg-muted`,warning:`text-fg-warning`,error:`text-fg-error`};function Q({tone:e,announce:t=!1,children:n,action:r,"data-testid":i}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{role:e===`error`?`alert`:t?`status`:void 0,className:h(`flex items-start gap-1.75 text-xs leading-(--leading-caption)`,Bi[e]),"data-testid":i,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:h(`mt-1.25 size-1.75 flex-none rounded-full`,zi[e])}),/* @__PURE__ */ (0,U.jsxs)(`span`,{children:[n,r]})]})}function Vi({onRetry:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[` \u00B7 `,/* @__PURE__ */ (0,U.jsx)(N,{variant:`link`,size:`xs`,onClick:e,children:t(`common.retry`)})]})}var Hi=V(`pgs-6344bc6f0d`);function Ui(e,t){let n=u(),r=(0,H.useMemo)(()=>i({kind:`project`,projectId:e},`discovery-settings`),[e]),a=A({key:r,read:async()=>{let t=await R.call(`REFRESH_DISCOVERY_SETTINGS`,{projectId:e});if(!t.success)throw Error(`REFRESH_DISCOVERY_SETTINGS refused: ${t.error}`);if(t.discoverySettings===null)throw Error(`The service worker could not read the discovery settings`);return t.discoverySettings},freshness:`screen`}),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),h=(0,H.useRef)(null),g=(0,H.useRef)(!1),_=(0,H.useRef)(!1),v=(0,H.useRef)(null),y=(0,H.useCallback)(async()=>{if(!_.current){_.current=!0,l(!0),f(!1),m(!1);try{for(;h.current!==null||g.current;){let i=h.current;if(i!==null){try{await L.discovery.updateUserSettings(i)}catch(t){Hi.warn(`pgm-6e1d90d469`,{projectId:e,error:t instanceof Error?t.message:String(t)}),v.current=h.current,h.current=null,s(null),f(!0);continue}g.current=!0,h.current===i&&(h.current=null,s(null));continue}g.current=!1;let a=await Wi(e,t);a===null?m(!0):(n.write(r,a),m(!1))}}finally{_.current=!1,l(!1)}}},[n,r,e,t]),b=(0,H.useCallback)(e=>{h.current=e,s(e),y()},[y]),x=(0,H.useCallback)(()=>{let e=v.current;if(e===null)throw Error(`No failed discovery save to retry`);v.current=null,b(e)},[b]),S=(0,H.useCallback)(()=>{g.current=!0,y()},[y]);if(a.error!==null)return{status:`readFailed`,retry:()=>void a.reload()};if(p&&!c)return{status:`readFailed`,retry:S};let C=a.data;return C===void 0?{status:`loading`}:{status:`ready`,settings:C,checked:o===null?C.userEnabled:o,saving:c,saveFailed:d,toggle:b,retrySave:x}}async function Wi(e,t){let n=await R.call(`REFRESH_DISCOVERY_SETTINGS`,{tabId:t,projectId:e}).catch(t=>(Hi.warn(`pgm-8a2d41a868`,{projectId:e,error:t instanceof Error?t.message:String(t)}),null));return n===null?null:n.success?(n.discoverySettings===null&&Hi.warn(`pgm-842d0b7de2`,{projectId:e}),n.discoverySettings):(Hi.warn(`pgm-a943e9be7d`,{projectId:e,error:n.error}),null)}function Gi(e){var t;return((t=e.disabledReasons)==null?void 0:t.includes(`company_disabled`))===!0||!e.companyEnabled}function Ki(e){return e.gatingModel===`company+user+project`&&e.projectEnabled===!1}var $=`popup-discovery-status`;function qi({tabId:e,project:t}){let{t:n}=F();return t===void 0?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Yi,{}),control:/* @__PURE__ */ (0,U.jsx)(Xi,{})}):t===null?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.noProject`)}),control:null}):/* @__PURE__ */ (0,U.jsx)(Ji,{tabId:e,project:t})}function Ji({tabId:e,project:t}){let{t:n}=F(),r=Ui(O(t.id),e),i,a=null;switch(r.status){case`loading`:i=/* @__PURE__ */ (0,U.jsx)(Yi,{}),a=/* @__PURE__ */ (0,U.jsx)(Xi,{});break;case`readFailed`:i=/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retry}),children:n(`popup.settings.discoveryStatus.readFailed`)});break;case`ready`:{let{settings:e}=r;i=r.saving?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.saving`)}):r.saveFailed?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retrySave}),children:n(`popup.settings.discoveryStatus.saveFailed`)}):Gi(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.companyOff`)}):Ki(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.projectOff`,{project:t.name})}):e.effectiveEnabled?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`on`,children:n(`popup.settings.discoveryStatus.on`,{project:t.name})}):/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.off`)}),a=/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":n(`popup.settings.discovery`),checked:r.checked,onChange:r.toggle,"data-testid":`popup-discovery-toggle`});break}}return/* @__PURE__ */ (0,U.jsx)(Zi,{status:i,control:a})}function Yi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`mt-1 h-3 w-40`})}function Xi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`})}function Zi({status:e,control:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[n(`popup.settings.discovery`),/* @__PURE__ */ (0,U.jsx)(B,{name:n(`popup.site.more`,{about:n(`popup.settings.discovery`)}),text:n(`popup.settings.discoveryHint`),placement:`bottom-start`})]}),below:e,alignStart:!0,"data-testid":`popup-discovery`,children:t})}function Qi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`kbd`,{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.75 font-sans text-(length:--text-micro) leading-none font-medium whitespace-nowrap text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,children:e})}var $i=/* @__PURE__ */ new Set([`Control`,`Alt`,`Shift`,`Meta`]);function ea(e){if($i.has(e.key))return null;let t=[];return(e.ctrlKey||e.metaKey)&&t.push(`Ctrl`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`),e.key===` `?t.push(`Space`):t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join(`+`)}function ta(){let{t:e}=F(),t=W(`selectionHotkey`),n=G(),[r,i]=(0,H.useState)(!1);return t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-(--control-height-sm) w-12 rounded-(--input-radius)`}):/* @__PURE__ */ (0,U.jsx)(T,{size:`sm`,active:r,"aria-label":e(`popup.settings.hotkeyName`,{hotkey:t}),onClick:()=>i(!0),onBlur:()=>i(!1),onKeyDown:e=>{if(!r)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=ea(e);t!==null&&(i(!1),n(`selectionHotkey`,t))},"data-testid":`popup-hotkey`,children:r?/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-(--color-primary-text) animate-pulse-dot`,children:e(`popup.settings.hotkeyCapture`)}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:t.split(`+`).map((e,t)=>/* @__PURE__ */ (0,U.jsx)(Qi,{children:e},`${e}-${t}`))})})}function na(e,t){return t?`element`:e?`window`:`off`}function ra(e){return{isolationWindow:e===`window`,isolationElement:e===`element`}}var ia=Promise.resolve();function aa(e){let t=()=>Pe(ra(e)),n=ia.then(t,t);return ia=n,n}var oa=V(`pgs-fed3bb0e75`),sa={managed:null,company:`popup.settings.modelKeyCompany`,personal:`popup.settings.modelKeyPersonal`};function ca(){let{t:e}=F(),t=x(),n=G(),r=W(`modelPick`),a=(0,H.useMemo)(()=>zt({http:pt(),logger:oa}),[]),o=ct(),{data:s,error:c,reload:l}=A({key:i(o,`chat-model-capabilities`),read:()=>a.load(),freshness:`screen`});if((0,H.useEffect)(()=>{c!==null&&(oa.error(`pgm-9665648376`,{error:c.message}),t.show({id:`popup-models`,variant:`error`,message:e(`popup.settings.modelLoadFailed`),action:{label:e(`common.retry`),onAction:()=>void l()}}))},[c,l,e,t]),r===void 0||s===void 0&&c===null)return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-37.5 rounded-md`})});let u=s===void 0?[]:s.groups,d=s===void 0||r===null?null:kt(s,r),f=s===void 0?null:Lt(s,d,null);return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),"data-testid":`popup-model`,children:/* @__PURE__ */ (0,U.jsx)(Qe,{size:`sm`,"aria-label":e(`popup.settings.model`),placeholder:e(`popup.settings.modelNone`),value:f===null?null:f.model.selectionId,onValueChange:r=>{for(let i of u){let a=i.models.find(e=>e.selectionId===r);if(a!==void 0){n(`modelPick`,{keySource:i.source,modelId:a.id}),L.aiSettings.updateUser({selectedProvider:i.source,selectedModel:a.id}).catch(n=>{oa.error(`pgm-573d3af0bc`,{error:n instanceof Error?n.message:String(n)}),t.show({id:`popup-model-save`,variant:`error`,message:e(`popup.settings.saveFailed`)})});return}}throw Error(`The AI model Select picked a row it did not render: ${r}`)},className:`w-37.5`,options:u.flatMap(t=>t.models.map(n=>{let r=sa[t.source];return{value:n.selectionId,label:r===null?n.name:`${n.name} \u00B7 ${e(r)}`,disabled:!Pt(n)}}))})})}var la=V(`pgs-cdc66fba2a`),ua={permissions:[`notifications`]};function da(e){return e instanceof Error?e.message:String(e)}function fa(){return[chrome.permissions.onAdded,chrome.permissions.onRemoved]}function pa(e){var t;return((t=e.permissions)==null?void 0:t.includes(`notifications`))===!0}function ma(){let{t:e}=F(),[t,n]=(0,H.useState)(`reading`),r=(0,H.useRef)(!0),i=(0,H.useCallback)(()=>{chrome.permissions.contains(ua).then(e=>{r.current&&n(t=>e?`on`:t===`denied`?`denied`:`off`)},e=>{la.error(`pgm-cbfb085fbb`,{error:da(e)}),r.current&&n(`readFailed`)})},[]);(0,H.useEffect)(()=>{r.current=!0;let e=e=>{pa(e)&&i()},t=fa();for(let n of t)n.addListener(e);return i(),()=>{r.current=!1;for(let n of t)n.removeListener(e)}},[i]);let a=()=>{n(`reading`),i()},o=e=>{if(e){n(`asking`),chrome.permissions.request(ua).then(e=>n(e?`on`:`denied`),e=>{la.error(`pgm-67efc28caa`,{error:da(e)}),n(`off`)});return}chrome.permissions.remove(ua).then(e=>{e||la.error(`pgm-2cbfb59188`),n(e?`off`:`on`)},e=>{la.error(`pgm-ac8845b9f5`,{error:da(e)})})},c=e(`popup.settings.osNotifications`);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[c,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:c}),text:e(`popup.settings.osNotificationsHint`),placement:`bottom-start`})]}),below:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`small`,{className:`text-xs leading-(--leading-caption) text-fg-muted`,children:e(`popup.settings.osNotificationsWhen`)}),t===`denied`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`neutral`,announce:!0,"data-testid":`popup-os-notifications-denied`,children:e(`popup.settings.osNotificationsDenied`)}),t===`readFailed`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:a}),"data-testid":`popup-os-notifications-read-failed`,children:e(`popup.settings.osNotificationsReadFailed`)})]}),alignStart:!0,"data-testid":`popup-os-notifications`,children:t===`reading`?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):t===`readFailed`?null:/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[t===`asking`&&/* @__PURE__ */ (0,U.jsx)(ye,{}),/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":c,checked:t===`on`,onChange:o,"data-testid":`popup-os-notifications-switch`})]})})}var ha=V(`pgs-7fed4be7cb`);function ga(){let{t:e}=F(),t=W(`notificationsEnabled`),n=G(),r=e(`popup.settings.notifications`);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(X,{title:e(`popup.settings.groups.notifications`),hint:e(`popup.settings.groups.notificationsHint`),"data-testid":`popup-notification-groups`,children:/* @__PURE__ */ (0,U.jsx)(Tt,{api:L.notifications,locale:Se(),t:e,logger:ha,onChanged:()=>Ot(`group_changed`)})}),/* @__PURE__ */ (0,U.jsxs)(X,{title:e(`popup.settings.groups.thisBrowser`),children:[/* @__PURE__ */ (0,U.jsx)(ma,{}),/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[r,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:r}),text:e(`popup.settings.notificationsHint`),placement:`bottom-start`})]}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":r,checked:t,onChange:e=>n(`notificationsEnabled`,e),"data-testid":`popup-notifications`})})]})]})}var _a=/^\d+$/;function va(e){let t=e.trim();return _a.test(t)?Number(t)>$e?`tooLong`:null:`notWholeNumber`}function ya(){let{t:e,i18n:t}=F(),r=W(`autoplayStepPauseMs`),i=G(),[a,o]=(0,H.useState)(null),s=a===null?null:va(a),c=s!==null,l=()=>{if(a===null||c)return;let e=Number(a.trim());o(null),e!==r&&i(`autoplayStepPauseMs`,e)};return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.pause`),alignStart:!0,below:c?/* @__PURE__ */ (0,U.jsxs)(`span`,{role:`alert`,className:`mt-0.5 flex items-start gap-1.5 text-xs leading-(--leading-caption) text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:s===`tooLong`?e(`popup.settings.pauseTooLong`,{max:new Intl.NumberFormat(t.language).format($e)}):e(`popup.settings.pauseInvalid`)})]}):void 0,"data-testid":`popup-step-pause`,children:r===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-26 rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ze,{size:`sm`,inputMode:`numeric`,"aria-label":e(`popup.settings.pauseName`),value:a??String(r),onValueChange:o,onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l()},invalid:c,trailing:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`popup.settings.ms`)}),className:`w-26 [&_input]:text-right [&_input]:tabular-nums`})})}function ba({tabId:e,project:t,onBack:n}){let{t:r}=F(),i=W(`theme`),a=G();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${Ct}`,"data-testid":`popup-settings`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:r(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:n,autoFocus:!0,"data-testid":`popup-settings-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:r(`popup.settings.title`)})]}),/* @__PURE__ */ (0,U.jsxs)(gn,{children:[/* @__PURE__ */ (0,U.jsx)(ga,{}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.view`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.theme`),stacked:!0,children:i===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ri,{value:i,onChange:e=>a(`theme`,e),labels:{group:r(`popup.settings.theme`),light:r(`popup.settings.themeLight`),dark:r(`popup.settings.themeDark`),system:r(`popup.settings.themeSystem`)},fullWidth:!0})}),/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.language`),stacked:!0,children:/* @__PURE__ */ (0,U.jsx)(jn,{fullWidth:!0})})]}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.recording`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.hotkey`),children:/* @__PURE__ */ (0,U.jsx)(ta,{})}),/* @__PURE__ */ (0,U.jsx)(ya,{}),/* @__PURE__ */ (0,U.jsx)(xa,{})]}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.assistant`),children:/* @__PURE__ */ (0,U.jsx)(ca,{})}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.pages`),children:/* @__PURE__ */ (0,U.jsx)(qi,{tabId:e,project:t},t==null?``:t.id)})]})]})}function xa(){let{t:e}=F(),t=An(),n=W(`isolationWindow`),r=W(`isolationElement`),i=n=>{t({id:`popup-isolation`,run:()=>aa(n),log:{message:`Input isolation was not stored`,context:{isolation:n}},message:e(`popup.settings.saveFailed`)})},a=n===void 0||r===void 0?void 0:na(n,r);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[e(`popup.settings.isolation`),/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:e(`popup.settings.isolation`)}),text:e(`popup.settings.isolationHint`),placement:`bottom-start`})]}),stacked:!0,"data-testid":`popup-isolation`,children:a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(m,{value:a,onValueChange:i,"aria-label":e(`popup.settings.isolation`),fullWidth:!0,options:[{value:`off`,label:e(`popup.settings.isolationOff`)},{value:`window`,label:e(`popup.settings.isolationWindow`)},{value:`element`,label:e(`popup.settings.isolationElement`)}]})})}var Sa=V(`pgs-b5906754fa`);function Ca({user:e}){let t=de(),n=Ni(),r=W(`enabled`),i=vt(e.id),a=Et(),[o,s]=(0,H.useState)({name:`main`,back:!1});if((0,H.useEffect)(()=>{Ot(`surface_opened`)},[]),a===void 0)return/* @__PURE__ */ (0,U.jsx)(_n,{});let c=n.state===`ready`?wa(t,n.byId):null,l=i.status===`ready`?i.snapshot:null,u=i.status===`ready`?i.revision:0,d=()=>s({name:`settings`,back:!1}),f=()=>s({name:`feed`,back:!1}),p=()=>s({name:`main`,back:!0}),m=/* @__PURE__ */ (0,U.jsx)(In,{user:e,onOpenSettings:d,notificationCounts:l,onOpenNotifications:f}),h=r===!0&&l!==null?/* @__PURE__ */ (0,U.jsx)(Li,{windowId:a,waitingCount:l.waitingCount,revision:u,onOpenFeed:f}):null;switch(o.name){case`settings`:{let r=/* @__PURE__ */ (0,U.jsx)(ba,{tabId:t.tabId,project:n.state===`loading`?void 0:c,onBack:p});return c===null?r:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(c.id),number:ue(c.number)},children:r})}case`feed`:return/* @__PURE__ */ (0,U.jsx)(Fi,{windowId:a,revision:u,back:o.back,onBack:p,onOpenSettings:d});case`main`:return/* @__PURE__ */ (0,U.jsx)(ji,{user:e,header:m,back:o.back,strip:h,snapshot:t,projects:n,tabProject:c})}}function wa(e,t){let{projectId:n}=e.state;if(n===null)return null;let r=t.get(n);return r===void 0?(Sa.warn(`pgm-cb1ec83f44`,{tabId:e.tabId}),null):r}function Ta(){return/* @__PURE__ */ (0,U.jsx)(k,{loading:/* @__PURE__ */ (0,U.jsx)(_n,{}),signedOut:/* @__PURE__ */ (0,U.jsx)(Mn,{}),children:e=>/* @__PURE__ */ (0,U.jsx)(wn,{user:e,children:/* @__PURE__ */ (0,U.jsx)(H.Suspense,{fallback:/* @__PURE__ */ (0,U.jsx)(_n,{}),children:/* @__PURE__ */ (0,U.jsx)(Ca,{user:e})})})})}var Ea=V(`pgs-2e3f74b175`),Da=document.getElementById(`popup-root`);Da===null?Ea.error(`pgm-f13077b9ed`):st({surface:`popup`,root:Da,followedTab:yt(),editorNavigation:at(`popup`),render:()=>/* @__PURE__ */ (0,U.jsx)(Ta,{})}).catch(e=>{Ea.error(`pgm-f4cc990f36`,e)});
@@ -6,16 +6,17 @@
6
6
  <title data-i18n="sidepanel.title">Progon AI Assistant</title>
7
7
  <script type="module" crossorigin src="../sidepanel/sidepanel.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="../chunks/shared-hePW80VL.js">
9
- <link rel="modulepreload" crossorigin href="../chunks/shared-B7QwPadt.js">
10
- <link rel="modulepreload" crossorigin href="../chunks/shared-LK5ScAJA.js">
11
- <link rel="modulepreload" crossorigin href="../chunks/shared-BwS34Mep.js">
12
- <link rel="modulepreload" crossorigin href="../chunks/shared-sY-POWsC.js">
13
- <link rel="modulepreload" crossorigin href="../chunks/shared-BgsXTfSV.js">
14
- <link rel="modulepreload" crossorigin href="../chunks/shared-BQF2LG1p.js">
15
- <link rel="modulepreload" crossorigin href="../chunks/shared-_8sSdh22.js">
16
- <link rel="modulepreload" crossorigin href="../chunks/shared-DjlOTYdL.js">
17
- <link rel="stylesheet" crossorigin href="../chunks/shared-CAKh7jnb.css">
18
- <link rel="stylesheet" crossorigin href="../chunks/shared-BvwA-cm2.css">
9
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
10
+ <link rel="modulepreload" crossorigin href="../chunks/shared-t8TH2XkL.js">
11
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CKtbh_44.js">
12
+ <link rel="modulepreload" crossorigin href="../chunks/shared-BgEO6Nif.js">
13
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CwsTFlbT.js">
14
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CfjrOLG1.js">
15
+ <link rel="modulepreload" crossorigin href="../chunks/shared-C7IWMwZY.js">
16
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CFEBqIm7.js">
17
+ <link rel="modulepreload" crossorigin href="../chunks/shared-D-c-eSoI.js">
18
+ <link rel="stylesheet" crossorigin href="../chunks/shared-BRaGK72I.css">
19
+ <link rel="stylesheet" crossorigin href="../chunks/shared-DXp1f_Ub.css">
19
20
  <link rel="stylesheet" crossorigin href="../sidepanel/sidepanel.css">
20
21
  </head>
21
22
  <body>