progon-agent 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +288 -29
- package/dist/supervisor/cli.js +315 -50
- package/extension-bundle.json +3 -3
- package/extension-dist/background/background.js +145 -122
- package/extension-dist/card/card.css +1 -1
- package/extension-dist/card/card.html +11 -10
- package/extension-dist/card/card.js +3 -9
- package/extension-dist/chunks/shared--PKAvBPy.js +1 -0
- package/extension-dist/chunks/shared-0jT00uC5.js +317 -0
- package/extension-dist/chunks/shared-8TdX8bnw.js +1 -0
- package/extension-dist/chunks/shared-BBwL-FWr.js +8 -0
- package/extension-dist/chunks/shared-BECVQaqd.js +1 -0
- package/extension-dist/chunks/shared-BGvIl9us.js +1 -0
- package/extension-dist/chunks/shared-BYkDbcM2.js +372 -0
- package/extension-dist/chunks/shared-BdaUsVif.css +1 -0
- package/extension-dist/chunks/shared-CDlAJRnF.js +117 -0
- package/extension-dist/chunks/shared-CQ5Ygj2p.js +1 -0
- package/extension-dist/chunks/shared-CnMBv8Ku.js +1 -0
- package/extension-dist/chunks/shared-CyNKhHOY.js +1 -0
- package/extension-dist/chunks/shared-D3X5MuUz.js +1 -0
- package/extension-dist/chunks/shared-D7GfVHk0.js +129 -0
- package/extension-dist/chunks/shared-QityJbuK.css +1 -0
- package/extension-dist/chunks/shared-U9lBnzuH.js +33 -0
- package/extension-dist/chunks/shared-VvEftNwZ.js +1 -0
- package/extension-dist/chunks/shared-XKyaHtl9.js +1 -0
- package/extension-dist/chunks/shared-fJPHxpB5.css +1 -0
- package/extension-dist/chunks/shared-o0-3vI--.js +193 -0
- package/extension-dist/chunks/shared-uKTblxo0.js +15 -0
- package/extension-dist/content/canvas-interceptor.js +1 -1
- package/extension-dist/content/canvas-mapbox-bridge-main.js +1 -1
- package/extension-dist/content/content.css +1 -1
- package/extension-dist/content/content.js +341 -324
- package/extension-dist/content/early-nonce-inject.js +1 -1
- package/extension-dist/content/frame.js +160 -0
- package/extension-dist/content/main-world-nav.js +1 -1
- package/extension-dist/manifest.json +36 -43
- package/extension-dist/offscreen/offscreen.html +2 -2
- package/extension-dist/offscreen/offscreen.js +1 -1
- package/extension-dist/popup/popup.html +9 -9
- package/extension-dist/popup/popup.js +3 -9
- package/extension-dist/sidepanel/sidepanel.css +1 -1
- package/extension-dist/sidepanel/sidepanel.html +13 -13
- package/extension-dist/sidepanel/sidepanel.js +1 -1
- package/extension-dist/workspace/workspace.css +1 -1
- package/extension-dist/workspace/workspace.html +13 -13
- package/extension-dist/workspace/workspace.js +241 -49
- package/npm-shrinkwrap.json +469 -0
- package/package.json +17 -12
- package/extension-dist/chunks/shared-73iHxv_g.js +0 -1
- package/extension-dist/chunks/shared-BRaGK72I.css +0 -1
- package/extension-dist/chunks/shared-Beih6ywL.js +0 -1
- package/extension-dist/chunks/shared-BgEO6Nif.js +0 -39
- package/extension-dist/chunks/shared-ByZxg79I.js +0 -1
- package/extension-dist/chunks/shared-C7IWMwZY.js +0 -1
- package/extension-dist/chunks/shared-CFEBqIm7.js +0 -21
- package/extension-dist/chunks/shared-CKtbh_44.js +0 -199
- package/extension-dist/chunks/shared-CSBwVLDL.js +0 -1
- package/extension-dist/chunks/shared-CeI71eLt.js +0 -134
- package/extension-dist/chunks/shared-CfjrOLG1.js +0 -336
- package/extension-dist/chunks/shared-CgUMEof2.js +0 -1
- package/extension-dist/chunks/shared-CwsTFlbT.js +0 -1
- package/extension-dist/chunks/shared-D-c-eSoI.js +0 -1
- package/extension-dist/chunks/shared-DXp1f_Ub.css +0 -1
- package/extension-dist/chunks/shared-Dk6zuyaK.css +0 -1
- package/extension-dist/chunks/shared-RcZD4SR-.js +0 -1
- package/extension-dist/chunks/shared-hePW80VL.js +0 -1
- package/extension-dist/chunks/shared-lM00HeT6.js +0 -98
- package/extension-dist/chunks/shared-t8TH2XkL.js +0 -239
- package/extension-dist/content/canvas-mapbox-fiber-discovery.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{r as e}from"../chunks/shared-
|
|
1
|
+
import{r as e}from"../chunks/shared-XKyaHtl9.js";import{$ as t,$a as n,$o as r,Bo as i,Br as a,Ca as o,Cl as s,Cs as c,Da as l,Di as u,Ea as d,Er as f,F as p,Fa as m,Fi as h,Fo as g,Hr as _,Hs as v,Ir as y,J as b,Ja as x,Jn as S,K as C,Ka as w,Kn as T,Na as E,No as D,Oa as ee,P as te,Po as ne,Q as re,R as ie,Ra as O,Ri as ae,Sa as oe,Sr as k,Ta as A,Vr as j,W as se,Wr as ce,Ws as le,Xa as ue,Xn as de,Y as fe,Za as pe,Zi as me,_l as he,_o as ge,_s as _e,ao as ve,ar as ye,as as be,bc as xe,bo as M,bs as Se,co as Ce,da as we,dc as Te,do as Ee,dr as De,ds as Oe,er as ke,fc as Ae,fs as N,go as je,gs as Me,ha as Ne,hr as Pe,hs as Fe,ii as Ie,ir as Le,j as Re,ja as ze,jr as Be,lo as P,mo as Ve,mr as He,n as Ue,no as We,nr as Ge,oo as Ke,os as qe,pc as Je,ps as F,qa as Ye,qn as Xe,r as I,tr as Ze,ui as L,ur as Qe,vs as $e,wl as et,wr as tt,xs as R,yl as nt,yo as z,ys as rt,zi as B}from"../chunks/shared-0jT00uC5.js";import{a as it,c as at,d as ot,f as st,i as ct,l as lt,n as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt}from"../chunks/shared-uKTblxo0.js";import{t as V}from"../chunks/shared-CDlAJRnF.js";import{a as _t,c as vt,d as yt,i as bt,l as xt,n as St,p as Ct,t as wt,u as Tt}from"../chunks/shared-U9lBnzuH.js";import{a as Et,c as Dt,i as Ot,l as kt,o as At,s as jt,t as Mt,u as Nt}from"../chunks/shared-BBwL-FWr.js";import{a as Pt,c as Ft,d as It,h as Lt,i as Rt,n as zt,o as Bt,r as Vt,s as Ht,t as Ut,u as Wt}from"../chunks/shared-8TdX8bnw.js";import{t as Gt}from"../chunks/shared-VvEftNwZ.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
|
|
8
|
+
;var Kt=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`}]]),qt=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`}]]),Jt=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`}]]),Yt=z(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Xt=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(qe(),1),U=be()
|
|
9
9
|
/**
|
|
10
10
|
* @license lucide-react v0.574.0 - ISC
|
|
11
11
|
*
|
|
@@ -30,10 +30,4 @@ import{r as e}from"../chunks/shared-hePW80VL.js";import{$a as t,$i as n,$t as r,
|
|
|
30
30
|
* This source code is licensed under the ISC license.
|
|
31
31
|
* See the LICENSE file in the root directory of this source tree.
|
|
32
32
|
*/
|
|
33
|
-
/**
|
|
34
|
-
* @license lucide-react v0.574.0 - ISC
|
|
35
|
-
*
|
|
36
|
-
* This source code is licensed under the ISC license.
|
|
37
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
38
|
-
*/
|
|
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)});
|
|
33
|
+
;function Zt({off:e}){let{t}=D();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)(y,{className:B(`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 Qt({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 $t({children:e,className:t}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:B(`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 en(){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`popup-loading`,children:[/* @__PURE__ */ (0,U.jsxs)(Qt,{children:[/* @__PURE__ */ (0,U.jsx)(Zt,{off:!1}),/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5 w-9 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`ml-2 size-7 rounded-md`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`ml-2 size-6 rounded-full`})]}),/* @__PURE__ */ (0,U.jsx)($t,{children:/* @__PURE__ */ (0,U.jsx)(tn,{})})]})}function tn(){let{t:e}=D();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)(k,{className:`size-8.5 rounded-md`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid flex-1 gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(k,{className:`h-2.5 w-12`}),/* @__PURE__ */ (0,U.jsx)(k,{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)(k,{className:`h-3 w-[60%]`})}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:[/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5.5 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5.5 w-20.5 rounded-full`})]})]}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(k,{className:`h-2.5 w-37.5`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(k,{className:`h-8.5 w-21 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`h-8.5 w-27.5 rounded-full`})]})]})]})}function nn({value:e,options:t,onChange:n,ariaLabel:r,size:i,fullWidth:a,className:o}){return/* @__PURE__ */ (0,U.jsx)(de,{value:e,options:t,onValueChange:n,"aria-label":r,size:i,fullWidth:a,className:o})}var rn=V(`pgs-4d9951d24e`);function an(e){let t=0,n=Promise.resolve(),r=null;async function i(n,i,a){if(n!==t)return;if(e.signedInUserId()!==a){rn.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){rn.info(`pgm-7aaa461c83`,{locale:i});return}if(n===t){e.onFailure(i,r);return}rn.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=>{rn.error(`pgm-1491eca8c6`,{locale:e,error:t})})},discardPending(){t+=1,r==null||r.abort()}}}var on=V(`pgs-b78fd5fe0f`),sn=(0,H.createContext)(null);function cn({user:e,children:t}){let[n]=(0,H.useState)(()=>dn(e.id)),[r,i]=(0,H.useState)(null);(0,H.useEffect)(()=>{n.setFailureReport((e,t)=>{on.error(`pgm-0f28f45227`,{locale:e,error:t instanceof Error?t.message:String(t)}),i({error:t})})},[n]),(0,H.useEffect)(()=>(n.start(),()=>n.end()),[n]);let a=(0,H.useMemo)(()=>({write:e=>{i(null),n.write(e)},discardPending:n.discardPending,failure:r,retry:()=>{i(null),n.retryShownLocale()}}),[n,r]);return/* @__PURE__ */ (0,U.jsx)(sn,{value:a,children:t})}function ln(){return(0,H.useContext)(sn)}function un(){let e=(0,H.useContext)(sn);if(e===null)throw Error(`useSignedInProfileLocale() is used outside the signed-in popup`);return e}function dn(e){let t=!1,n=null,r=an({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{write:t=>r.write(t,e),discardPending:()=>r.discardPending(),setFailureReport:e=>{n=e},retryShownLocale:()=>{t&&r.write(F(),e)},start:()=>{t=!0},end:()=>{t=!1,r.discardPending()}}}var fn=V(`pgs-5b08c33bee`);function pn(){let e=ln(),[t,n]=(0,H.useState)(null),r=(0,H.useRef)(0),i=t=>{r.current+=1;let i=r.current;n(null),Fe(t).then(n=>{n!==`superseded`&&(e==null||e.write(t))}).catch(e=>{fn.error(`pgm-7755abcb75`,{locale:t,error:e instanceof Error?e.message:String(e)}),i===r.current&&n({locale:t,error:e})})},a=null;if(t!==null){let{locale:e,error:n}=t;a={step:`store`,error:n,retry:()=>i(e)}}else e!==null&&e.failure!==null&&(a={step:`profile`,error:e.failure.error,retry:e.retry});return{choose:i,failure:a}}function mn({onChoose:e,size:t,fullWidth:n}){let{t:r}=D();return/* @__PURE__ */ (0,U.jsx)(nn,{value:F(),options:xe.map(e=>({value:e,label:r(`common.languageNames.${e}`)})),onChange:e,ariaLabel:r(`popup.languageGroup`),size:t,fullWidth:n})}function W({error:e,what:t,refusalKey:n,onRetry:r,className:i,"data-testid":a}){let{t:o}=D(),s=n===void 0?ce(o,e):_(o,N.has,e,e=>Oe(N,e,n));return/* @__PURE__ */ (0,U.jsx)(st,{tone:`error`,error:e,retry:{label:o(`common.retry`),onRetry:r},className:i,"data-testid":a,children:t===void 0?s:o(`popup.writeFailed`,{what:t,cause:s})})}function hn(){let{t:e}=D(),t=pn();return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:/* @__PURE__ */ (0,U.jsx)(ke,{subtitle:e(`shell.signIn.subtitlePopup`),footer:/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid justify-items-center gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(mn,{size:`sm`,onChoose:t.choose}),t.failure!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:t.failure.error,what:e(`popup.language.saveFailed`),onRetry:t.failure.retry,"data-testid":`popup-language-failure`})]})})})}function gn(e){let t=_e(e);return(0,H.useSyncExternalStore)(t.subscribe,t.getState)}var _n=V(`pgs-520a54a8e3`);function G(e){let t=gn(e);if(t.status===`failed`)throw t.error;return t.status===`ready`?t.value:void 0}function K(e){let{choose:t,failure:n,retry:r}=ot({write:t=>$e(e,t),confirm:()=>void 0,onWriteError:(t,n)=>{_n.error(`pgm-9c76e84061`,{setting:e,value:n,error:t instanceof Error?t.message:String(t)})}});return{choose:t,failure:n,retry:r}}var vn=V(`pgs-d05703aaa3`);function yn({user:e}){let{t}=D(),[n,r]=(0,H.useState)(!1),[a,o]=(0,H.useState)(null),s=un(),l=`${e.firstName} ${e.lastName}`,u=()=>{n||(r(!0),o(null),s.discardPending(),c.call(`AUTH_SIGN_OUT`).catch(e=>{vn.error(`pgm-4db83b7ea3`,{error:e instanceof Error?e.message:String(e)}),o({error:e})}).finally(()=>r(!1)))};return/* @__PURE__ */ (0,U.jsxs)(Re,{label:t(`popup.header.account`,{name:l}),align:`end`,className:`w-59`,onOpenChange:e=>{e||o(null)},trigger:/* @__PURE__ */ (0,U.jsx)(L,{"aria-label":t(`popup.header.account`,{name:l}),icon:/* @__PURE__ */ (0,U.jsx)(kt,{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:l}),/* @__PURE__ */ (0,U.jsxs)(`small`,{className:`text-xs text-fg-muted`,children:[e.email,` \u00B7 `,e.company.name]})]}),/* @__PURE__ */ (0,U.jsx)(ie,{}),/* @__PURE__ */ (0,U.jsx)(te,{label:t(`popup.header.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(Ee,{"aria-hidden":`true`}),onSelect:()=>i()}),/* @__PURE__ */ (0,U.jsx)(ie,{}),/* @__PURE__ */ (0,U.jsx)(te,{label:t(`popup.header.signOut`),icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),tone:`danger`,disabled:n,keepOpen:!0,onSelect:u,"data-testid":`popup-sign-out`}),a!==null&&/* @__PURE__ */ (0,U.jsx)(p,{children:/* @__PURE__ */ (0,U.jsx)(W,{error:a.error,what:t(`popup.header.signOutFailed`),onRetry:u,"data-testid":`popup-sign-out-failure`})})]})}function bn({enabled:e,onSwitch:t}){let{t:n}=D();return/* @__PURE__ */ (0,U.jsx)(M,{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)(T,{"aria-label":n(`popup.header.switchLabel`),checked:e,onChange:t,className:`p-1.5`,"data-testid":`popup-power-switch`})})})}function xn({user:e,onOpenSettings:t,notificationCounts:n,onOpenNotifications:r,onSwitch:i}){let{t:a}=D(),o=G(`enabled`);return/* @__PURE__ */ (0,U.jsxs)(Qt,{children:[/* @__PURE__ */ (0,U.jsx)(Zt,{off:o===!1}),o===void 0?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(bn,{enabled:o,onSwitch:i}),/* @__PURE__ */ (0,U.jsx)(dt,{host:`popup`,t:a,counts:o===!1?null:n,onClick:r}),/* @__PURE__ */ (0,U.jsx)(M,{relationship:`label`,content:a(`popup.header.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(L,{icon:/* @__PURE__ */ (0,U.jsx)(xt,{"aria-hidden":`true`}),onClick:t,"data-testid":`popup-open-settings`})}),/* @__PURE__ */ (0,U.jsx)(yn,{user:e})]})}var Sn=/^[^\p{L}\p{N}]*(\p{L})/u;function Cn(e){let t=e.trim().split(/\s+/).flatMap(e=>{var t;let n=(t=Sn.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`,Tn=`bg-(image:--btn-primary-fill) text-fg-on-accent`,En=`bg-(--color-bg-tertiary) text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,Dn=`shadow-[var(--shadow-primary-inset),var(--shadow-tile-primary-glow)]`,On={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`},kn=/* @__PURE__ */ new Set([26,32,40]);function An({name:e,size:t,drained:n=!1,className:r}){let i=e===null?null:Cn(e),a=n?En:B(Tn,kn.has(t)&&Dn);return/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,"data-size":t,"data-drained":n||void 0,className:B(wn,On[t],a,r),children:i??/* @__PURE__ */ (0,U.jsx)(P,{})})}var jn=5,Mn=3,Nn=`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)`,Pn=`grid shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted [&_svg]:size-4`,Fn=`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`,In=`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`,Ln={header:`min-w-0 max-w-45 truncate`,"header-narrow":`min-w-0 max-w-30 truncate`},Rn=`grid size-6.5 shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted`,zn=`grid grid-cols-[minmax(0,1fr)] gap-px overflow-y-auto overscroll-contain outline-none`,Bn=B(Qe,De.sm),Vn={popup:`w-75`,list:`max-h-[min(--spacing(80),var(--available-height))]`,search:B(Bn,`m-0.5 mb-1.5`),rowTile:null,row:`data-selected:bg-(--color-bg-primary-tint-10) [&>svg:last-child]:text-(--color-primary-text)`},Hn={full:{popup:`w-(--anchor-width)`,list:`max-h-[min(--spacing(52),var(--available-height))]`,search:B(Bn,`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:Vn,"header-narrow":Vn,"header-tile":Vn};function Un({value:e,onValueChange:i,list:a,labels:o,variant:s=`full`,recent:c,footerActions:l,open:u,onOpenChange:d,autoFocus:f,"data-testid":p}){let m=r(),h=(0,H.useId)(),g=(0,H.useId)(),[_,v]=(0,H.useState)(``),[y,x]=(0,H.useState)(!1),S=(0,H.useRef)(null),T=u??y,E=Hn[s],D=a.state===`ready`?a.projects:null,ee=(0,H.useMemo)(()=>D===null?/* @__PURE__ */ new Map:new Map(D.map(e=>[e.id,e])),[D]),te=(0,H.useMemo)(()=>{if(D===null||c===void 0||_.trim()!==``||D.length<=jn)return null;let e=new Set(c.ids),t=D.filter(t=>e.has(t.id));return t.length===0?null:[{heading:c.heading,items:t},{heading:c.restHeading,items:D.filter(t=>!e.has(t.id))}]},[D,c,_]),ne=D===null?[]:te??D,ie=e=>{u===void 0&&x(e),d==null||d(e),e||v(``)},O=e=>{let n=Cn(e.name);return/* @__PURE__ */ (0,U.jsxs)(Vt,{value:e,className:B(fe,E.row),children:[E.rowTile===null?/* @__PURE__ */ (0,U.jsx)(An,{name:e.name,size:22}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:E.rowTile,"aria-hidden":`true`,children:n??/* @__PURE__ */ (0,U.jsx)(P,{className:`size-3`})}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:B(re,`truncate`),children:e.name}),/* @__PURE__ */ (0,U.jsx)(ge,{"aria-hidden":`true`,className:t})]},e.id)},ae=a.state===`loading`?/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,"aria-label":o.loading,className:`grid gap-px`,children:Array.from({length:Mn},(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)(k,{className:`size-5.5 rounded-sm`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`h-3 w-[60%]`})]},t))}):a.state===`error`?/* @__PURE__ */ (0,U.jsx)(j,{tone:`error`,error:a.error,title:o.failed,onRetry:a.onRetry,retrying:a.retrying,line:!0}):a.projects.length===0&&_.trim()===``?/* @__PURE__ */ (0,U.jsx)(j,{tone:`empty`,icon:/* @__PURE__ */ (0,U.jsx)(P,{"aria-hidden":`true`}),title:o.noProjects,line:!0}):/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(zt,{query:_,words:o.nothingFound,onReset:()=>{var e;v(``),(e=S.current)==null||e.focus()}}),/* @__PURE__ */ (0,U.jsx)(Ht,{"aria-label":o.label,className:B(zn,E.list),children:te===null?O:e=>/* @__PURE__ */ (0,U.jsxs)(jt,{items:e.items,children:[/* @__PURE__ */ (0,U.jsx)(At,{className:se,children:e.heading}),/* @__PURE__ */ (0,U.jsx)(Ft,{children:O})]},e.heading)})]}),oe=B(e===null?Pn:Nn,`size-8.5`),A=e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{className:Rn,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(Wn,{name:null})}):/* @__PURE__ */ (0,U.jsx)(An,{name:e.name,size:26}),ce=/* @__PURE__ */ (0,U.jsx)(je,{"aria-hidden":`true`,className:B(`shrink-0 text-fg-muted [transition:transform_var(--motion-medium)_var(--ease-out)] group-data-popup-open/trigger:rotate-180`,s===`full`?`size-4`:`size-3.25`)}),le=s===`header-tile`?/* @__PURE__ */ (0,U.jsxs)(Dt,{"data-testid":p,autoFocus:f,"aria-labelledby":`${h} ${g}`,className:In,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`sr-only`,children:o.label}),A,/* @__PURE__ */ (0,U.jsx)(`span`,{id:g,className:`sr-only`,children:e===null?o.placeholder:e.name}),ce]}):s===`header`||s===`header-narrow`?/* @__PURE__ */ (0,U.jsxs)(Dt,{"data-testid":p,autoFocus:f,"aria-labelledby":`${h} ${g}`,className:In,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`sr-only`,children:o.label}),A,e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:g,className:B(Ln[s],`font-medium text-fg-secondary`),children:o.placeholder}):/* @__PURE__ */ (0,U.jsx)(w,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:g,className:Ln[s],children:e.name})}),ce]}):/* @__PURE__ */ (0,U.jsxs)(Dt,{"data-testid":p,autoFocus:f,"aria-labelledby":`${h} ${g}`,className:Fn,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:oe,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(Wn,{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:h,className:`text-(length:--text-picker-label) text-fg-muted`,children:o.label}),e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:g,className:`truncate text-base font-medium tracking-(--tracking-snug) text-fg-secondary`,children:o.placeholder}):/* @__PURE__ */ (0,U.jsx)(w,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:g,className:`truncate text-base font-semibold tracking-(--tracking-heading) text-fg-primary`,children:e.name})})]}),ce]});return/* @__PURE__ */ (0,U.jsxs)(Lt,{items:ne,value:e,onValueChange:e=>{if(e===null)return;let t=ee.get(e.id);if(t===void 0)throw Error(`ProjectPicker: chosen project ${e.id} is not in the list`);i(t)},itemToStringLabel:e=>e.name,isItemEqualToValue:(e,t)=>e.id===t.id,inputValue:_,onInputValueChange:v,open:T,onOpenChange:ie,autoHighlight:!0,children:[s===`header-tile`?/* @__PURE__ */ (0,U.jsx)(M,{relationship:`none`,content:e===null?o.placeholder:e.name,placement:`bottom`,children:le}):le,/* @__PURE__ */ (0,U.jsx)(Bt,{container:m,children:/* @__PURE__ */ (0,U.jsx)(Pt,{side:`bottom`,align:`start`,sideOffset:s===`full`?4:8,collisionPadding:8,positionMethod:`fixed`,className:b,children:/* @__PURE__ */ (0,U.jsxs)(Rt,{"data-project-picker":``,"aria-label":o.placeholder,className:B(C,E.popup),children:[/* @__PURE__ */ (0,U.jsxs)(Wt,{className:E.search,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:Le,children:/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`})}),/* @__PURE__ */ (0,U.jsx)(It,{ref:S,placeholder:o.search,"aria-label":o.search,className:ye})]}),ae,l!==void 0&&/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`div`,{className:`mx-2 my-1 h-px shrink-0 border-0 bg-stroke-hairline`,role:`separator`}),l.map(e=>/* @__PURE__ */ (0,U.jsxs)(`button`,{type:`button`,"data-testid":e.testId,className:B(`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-hover-layer active:bg-surface-active-layer data-selected:font-medium`,`hover:bg-surface-elevated-hover focus-visible:bg-surface-elevated-hover`),onClick:()=>{ie(!1),e.onSelect()},children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex shrink-0 text-fg-secondary`,children:e.icon}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 flex-1 wrap-anywhere`,children:e.label})]},e.label))]})]})})})]})}function Wn({name:e}){let t=e===null?null:Cn(e);return t===null?/* @__PURE__ */ (0,U.jsx)(P,{"aria-hidden":`true`,className:`size-4`}):/* @__PURE__ */ (0,U.jsx)(U.Fragment,{children:t})}var Gn=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function Kn({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 ${Gn}`,"data-testid":`popup-bind-consequence`,children:/* @__PURE__ */ (0,U.jsx)(ne,{i18nKey:l,components:c})},u):/* @__PURE__ */ (0,U.jsx)(`div`,{role:o===null?void 0:`alert`,"aria-live":o===null?`polite`:void 0,className:Gn,"data-testid":`popup-bind-consequence`,"data-replace":`true`,children:/* @__PURE__ */ (0,U.jsx)(Pe,{tone:`warning`,title:/* @__PURE__ */ (0,U.jsx)(ne,{i18nKey:l,components:c})})},u)}var qn={local:`dev`,dev:`dev`,staging:`staging`,prod:`production`},Jn=/* @__PURE__ */ new WeakMap;function Yn(e,t){return`${e}|${t}`}function Xn(e){let t=Jn.get(e);if(t!==void 0)return t;let n=new Map(e.map(e=>[Yn(e.applicationId,e.environmentId),e]));return Jn.set(e,n),n}function Zn(e,t,n){let r=Xn(e).get(Yn(t,n));return r===void 0?null:r}function Qn(e,t,n){return n===null||t.kind!==`existing`||n.kind!==`existing`?null:Zn(e.cells,t.id,n.id)}function $n(e){return e.trim().toLowerCase()}function q(e,t){let n=$n(t);if(n===``)return null;let r=e.find(e=>$n(e.name)===n);return r===void 0?null:r}function er(e,t,n){let r=e.environments.filter(n=>t===null||Zn(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:q(e.environments,n.name)===null?n.name:``},allTaken:e.environments.length>0}:{choice:{kind:`existing`,id:i.id},allTaken:!1}}var tr=/* @__PURE__ */ new Set([`targets.cell_exists`,`targets.modified_concurrently`,`targets.host_conflict`,`targets.not_found`]);function nr(e){return e instanceof he&&e.errorCode!==void 0?e.errorCode:null}function rr(e){return e instanceof Error?e.message:String(e)}function ir(e,t,n){return{application:e.application.kind===`new`&&n.application===null?q(t.applications,e.application.name):null,environment:e.environment!==null&&e.environment.kind===`new`&&n.environment===null?q(t.environments,e.environment.name):null}}function ar(e){let t=nr(e);return t!==null&&tr.has(t)}function or(e){return e.application!==null&&e.environment!==null?`both`:e.application===null?e.environment===null?null:`environment`:`application`}function sr(e,t){let n=or(e);return n===null?t:N.t(`popup.site.createdNotBound.${n}`,{application:e.application,environment:e.environment,reason:t})}function J(e,t){let n=or(t);if(n===null)return Oe(N,e,`popup.site.bindFailed`);let r={application:t.application,environment:t.environment},i=N.t(`popup.site.bindPartial.${n}`,r),a=Oe(N,e,`popup.site.bindPartial.${n}`,r);return a===i?a:sr(t,a)}function cr(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=er(t,c.kind===`existing`?c.id:null,o);l={...l,environment:e.choice,environmentAllTaken:e.allTaken,environmentChosen:!1}}let d=nr(n),f=Qn(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:lr(n,l,r,i.host)}:{...l,fresh:null,failure:J(n,r)}}function lr(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?J(e,n):sr(n,N.t(`popup.site.hostConflict`,{host:r,application:o.name,environment:c.name}))}var Y=V(`pgs-e9b150372c`);function ur(e){let{defaultApplicationId:t,host:n,proposal:r,requests:i}=e,[a,o]=(0,H.useState)(()=>{let n=er(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=er(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=q(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=er(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){Y.error(`pgm-9a173522f2`,{error:rr(e)}),o(t=>({...t,failure:J(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=Qn(c.lists,c.application,u);r===null?await i.createCell(t,n):await i.replaceCell(r)}catch(e){if(Y.error(`pgm-53ab6bb5fe`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null,status:e instanceof he?e.status:null,code:nr(e),error:rr(e)}),d!==null){await y(c,s,e);return}if(ar(e))try{let a=await i.readLists();o(i=>({...cr(i,a,e,s,{defaultApplicationId:t,proposal:r,host:n}),focus:{target:`submit`,seq:l()}}));return}catch(e){Y.error(`pgm-a2654be732`,{error:rr(e)})}o(t=>({...t,failure:J(e,s),focus:{target:`submit`,seq:l()}}));return}Y.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){Y.error(`pgm-200d50f185`,{error:rr(e)}),o(e=>({...e,createUnsettled:!0,failure:J(n,t),focus:{target:`submit`,seq:l()}}));return}b(e,r,t),o(e=>({...e,failure:J(n,t),focus:{target:`submit`,seq:l()}}))},b=(t,n,r)=>{let i=ir(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)&&Y.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`)}));else{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=q(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 dr=V(`pgs-e9b150372c`),fr=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function pr(e){let{t}=D(),n=ur(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;t=e.target===`submit`?c.current:e.target===`input`?(e.field===`application`?o:s).current:document.getElementById(`${i}-${e.field}`),t===null?dr.warn(`pgm-9d57cb6e57`,{target:e.target}):t.focus()},[r.focus,i]);let{lists:l,application:u,environment:d,pending:f,problem:p}=r,m=u.kind===`new`?u.name:mr(l.applications,u.id),g=d===null?``:d.kind===`new`?d.name:mr(l.environments,d.id),_=Qn(l,u,d),v=e=>{if(p!==null&&p.field===e)return p.kind===`empty`?t(e===`application`?`popup.site.emptyApplication`:`popup.site.emptyEnvironment`):p.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:p.name}),` `,/* @__PURE__ */ (0,U.jsx)(h,{variant:`link`,size:`xs`,onClick:()=>n.chooseExisting(e,p.id),"data-testid":`popup-bind-${e}-choose-existing`,children:t(`popup.site.chooseExisting`)})]})},y=(e,r,i)=>{let c=e===`application`||l.environments.length>0;return/* @__PURE__ */ (0,U.jsx)(Ge,{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)(We,{"aria-hidden":`true`,className:`size-3.5 text-fg-link`}),trailing:c?/* @__PURE__ */ (0,U.jsx)(M,{relationship:`label`,content:t(`popup.site.backToList`),placement:`top`,children:/* @__PURE__ */ (0,U.jsx)(L,{size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(x,{"aria-hidden":`true`}),onClick:()=>n.backToList(e),disabled:f,"data-testid":`popup-bind-${e}-back`})}):void 0,hint:i,error:v(e),className:fr,"data-testid":`popup-bind-${e}-name`},`${e}-new`)},b=e=>({options:[{value:`new`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),icon:/* @__PURE__ */ (0,U.jsx)(We,{"aria-hidden":`true`,className:`text-fg-link`})}]}),S=u.kind===`new`?y(`application`,u.name,void 0):/* @__PURE__ */ (0,U.jsx)(I,{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}))},b(`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:m.trim()===``?`\u2026`:m.trim()})}));let w=d!==null&&d.kind===`new`?y(`environment`,d.name,C):/* @__PURE__ */ (0,U.jsx)(I,{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:v(`environment`),onValueChange:e=>n.choose(`environment`,e),disabled:f,groups:[{options:l.environments.map(e=>{let n=u.kind===`existing`?Zn(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})}})},b(`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-lg surface-block 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]}),p===null&&d!==null&&/* @__PURE__ */ (0,U.jsx)(Kn,{host:e.host,applicationName:m,environmentName:g,newApplication:u.kind===`new`,newEnvironment:d.kind===`new`,replaced:_,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)(Ve,{"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)(h,{ref:c,size:`sm`,icon:_===null?/* @__PURE__ */ (0,U.jsx)(ve,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(Kt,{"aria-hidden":`true`}),loading:f,onClick:n.submit,className:`justify-self-end`,"data-testid":`popup-bind-submit`,children:t(_===null?`popup.site.bind`:`popup.site.replace`)})]})}function mr(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 X({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 Z({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)(Ce,{"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 hr=`inline-flex h-6 items-center rounded-full border border-stroke bg-surface-hover-layer text-xs text-fg-primary`;function gr({applicationName:e,environmentName:t}){let{t:n}=D();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:B(hr,`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:B(hr,`px-2.5 font-semibold animate-[popup-environment-in_var(--motion-long)_var(--ease-out)_both]`),children:t})]})}function _r({children:e,hintName:t,hint:n,tone:r=`default`,icon:i}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:B(`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:B(`m-0 min-w-0 text-(length:--text-compact) leading-normal [&_b]:font-semibold [&_b]:text-fg-primary`,r===`warning`?`text-inherit`:`text-fg-secondary`),children:e}),/* @__PURE__ */ (0,U.jsx)(Ye,{name:t,text:n,placement:`bottom-start`})]})}var vr=V(`pgs-f048f86b7e`);function yr({projectId:e,host:t,environments:n,chosenId:r,onChosen:i}){let{t:a}=D(),o=ot({write:async t=>{await R.environments.setActive(s(e),`extension`,t)},confirm:()=>{vr.info(`pgm-f54cd7418d`,{projectId:e}),i()},onWriteError:t=>{vr.error(`pgm-effdde2b56`,{projectId:e,error:t instanceof Error?t.message:String(t)})}});return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(_r,{hintName:a(`popup.site.more`,{about:a(`popup.site.environmentChoice`)}),hint:a(`popup.site.environmentChoiceHint`),children:a(`popup.site.environmentChoice`)}),/* @__PURE__ */ (0,U.jsx)(I,{size:`sm`,"aria-label":a(`popup.site.environmentLabel`),placeholder:a(`popup.site.environmentPlaceholder`),value:r,onValueChange:o.choose,disabled:o.saving,options:n.map(e=>({value:e.id,label:e.name,description:t})),"data-testid":`popup-site-environment`}),o.failure!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:o.failure.error,refusalKey:`popup.site.environmentFailed`,onRetry:o.retry,"data-testid":`popup-site-environment-failure`})]})}function br(e){let t=e.toLowerCase();return/(^|\/\/|\.)dev\./.test(t)?`dev`:/stag/.test(t)?`staging`:/localhost|127\.0/.test(t)?`local`:`prod`}function xr(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 Sr(e){let t=br(e);return{key:`popup.site.environmentSuggestion.${t}`,type:qn[t]}}function Cr(e,t,n,r){let{targets:i,applications:a,environments:o}=t,s=i.find(e=>e.baseUrl===null&&e.hostPattern===null);if(s!==void 0)return{kind:`inconsistent`,reason:`Cell ${s.id} has neither an origin nor a host pattern`};let c=i.map(Ot),l=Ae(r.href,c,null);switch(l.kind){case`unsupported_url`:return{kind:`unsupported`};case`matched`:{let t=Tr(a,l.applicationId),n=Tr(o,l.environmentId);return t===null||n===null?Er(e,t===null?l.applicationId:l.environmentId):{kind:`matched`,applicationName:t,environmentName:n}}case`ambiguous_application`:{let t=Tr(o,l.environmentId);return t===null?Er(e,l.environmentId):{kind:`ambiguous`,environmentName:t}}case`environment_choice`:{let t=l.environmentIds.find(e=>!o.some(t=>t.id===e));return t===void 0?{kind:`environmentChoice`,environments:o.filter(e=>l.environmentIds.includes(e.id)).map(e=>({id:e.id,name:e.name}))}:Er(e,t)}case`unknown_host`:case`no_targets`:{let i=v(r.href,{cells:c,environmentId:null,trustedSites:n.map(Et),runLaunchOrigin:null});if(!le(i))return{kind:`trustedSite`};let o=a.find(e=>e.isDefault);return o===void 0?{kind:`inconsistent`,reason:`Project ${e} has no default application`}:{kind:`bind`,reason:l.kind,lists:kr(t),defaultApplicationId:o.id}}}}function wr(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 Tr(e,t){let n=e.find(e=>e.id===t);return n===void 0?null:n.name}function Er(e,t){return{kind:`inconsistent`,reason:`A cell of project ${e} names ${t}, absent from the lists read`}}async function Dr(e,t){let n=s(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 Or(e,t){return kr(await Dr(e,t))}function kr(e){return{applications:e.applications.map(Ar),environments:e.environments.map(jr),cells:e.targets.map(Mr)}}function Ar(e){return{id:e.id,name:e.name}}function jr(e){return{id:e.id,name:e.name,envType:e.envType,isDefault:e.isDefault}}function Mr(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 Nr(e,t,n){return Ar(await e.applications.create({projectId:s(t),name:n}))}async function Pr(e,t,n,r){return jr(await e.environments.create({projectId:s(t),name:n,envType:xr(n),isDefault:r}))}async function Fr(e,t,n,r,i){await e.targets.create(s(t),{applicationId:nt(r),environmentId:i,baseUrl:n})}async function Ir(e,t,n,r){let i=r.hostPattern!==null&&Te(n,[{targetId:r.id,applicationId:r.applicationId,environmentId:r.environmentId,baseUrl:null,hostPattern:r.hostPattern}]).length>0;await e.targets.update(s(t),r.id,{baseUrl:n,...r.hostPattern===null||i?{}:{hostPattern:null},expectedUpdatedAt:r.updatedAt})}var Lr=V(`pgs-c1e3b0bb6f`);function Rr({page:e,projects:t,onSelect:n}){let{t:r}=D(),i=ze(),{data:a,error:o}=m({key:O(i,`target-matches`,e.href),read:()=>R.targets.match(e.href),freshness:`screen`});if((0,H.useEffect)(()=>{o!==null&&Lr.error(`pgm-f294aabbd9`,{error:o.message})},[o]),o!==null||a===void 0)return null;let s=new Set(a.items.map(e=>e.projectId)),c=t.filter(e=>s.has(e.id));return c.length===0?null:/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:e.host}),c.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)(h,{variant:`secondary`,size:`sm`,onClick:()=>n(e),"data-testid":`popup-site-suggestion`,children:r(`popup.site.select`)})]},e.id))]})}var zr=V(`pgs-94aad7e91e`),Br=class extends Error{constructor(e){super(e),this.name=`ProjectSiteInconsistencyError`}},Vr={phase:`none`};function Hr(e,t){let n=E(),[r,i]=(0,H.useState)(Vr),a=(0,H.useRef)({applications:null,environments:null}),s=(0,H.useMemo)(()=>({kind:`project`,projectId:e}),[e]),c=Ne({projectId:e}),u=l({projectId:e}),f=ee({projectId:e}),p=m({key:O(s,`trusted-sites`),read:t=>R.trustedSites.listAll(e,{signal:t}),freshness:`screen`}),h=t.href,g=(0,H.useMemo)(()=>c.data===void 0||u.data===void 0||f.data===void 0||p.data===void 0?null:Cr(e,{targets:c.data,applications:u.data,environments:f.data},p.data,new URL(h)),[e,c.data,u.data,f.data,p.data,h]),_=d({projectId:e,client:`extension`},{enabled:g!==null&&g.kind===`environmentChoice`}),v=g!==null&&g.kind===`inconsistent`?g.reason:null;(0,H.useEffect)(()=>{v!==null&&zr.error(`pgm-0efc4cf256`,{projectId:e,reason:v})},[v,e]);let y=[c,u,f,p],b=e=>()=>{for(let t of e)t.reload()},x,S=y.flatMap(e=>{let t=Ur(e);return t===null?[]:[{read:e,error:t}]}),[C]=S,w=Ur(_);if(C!==void 0)x={status:`failed`,error:C.error,retry:b(S.map(e=>e.read))};else if(g===null)x={status:`loading`};else if(g.kind===`inconsistent`)x={status:`failed`,error:new Br(g.reason),retry:b(y)};else if(g.kind===`environmentChoice`){if(w!==null)x={status:`failed`,error:w,retry:b([_])};else if(_.data===void 0)x={status:`loading`};else{let e=wr(_.data,g.environments);x={status:`ready`,screen:{...g,chosenId:e}}}}else x={status:`ready`,screen:g};r.phase===`outcome`&&x.status!==`failed`&&i(Vr);let T=x;return(r.phase===`press`||r.phase===`outcome`&&x.status===`failed`)&&(T={status:`binding`,screen:r.screen,failure:x.status===`failed`?{error:x.error,retry:x.retry}:null}),{state:T,bindStarted:()=>{let e;if(T.status===`binding`)e=T.screen;else if(T.status===`ready`&&T.screen.kind===`bind`)e=T.screen;else throw Error(`A bind press started while the site strip is ${T.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(o(s))},afterEnvironmentCreated:()=>{a.current.environments=n.invalidateAfterChange(A(s))},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,o(s)),t(e.environments,A(s))]),await n.invalidateAfterChange(we(s)),i(Vr)},afterEnvironmentChosen:()=>{n.invalidateAfterChange(oe(s))}}}function Ur(e){return e.error===null?e.refreshError:e.error}var Wr=V(`pgs-3b85b4fc58`);function Gr({tabId:e,project:t,projects:n,onSelectProject:r}){let i=Kr(e);if(i.status!==`read`)return null;let a=i.url,o=a===null?null:Je(a),s=o!==null&&o.ok?o.url:null;return t===null?s===null?null:/* @__PURE__ */ (0,U.jsx)(Rr,{page:s,projects:n,onSelect:r}):s===null?/* @__PURE__ */ (0,U.jsx)(qr,{}):/* @__PURE__ */ (0,U.jsx)(Jr,{project:t,page:s})}function Kr(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=>{Wr.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 qr(){let{t:e}=D();return/* @__PURE__ */ (0,U.jsx)(X,{children:/* @__PURE__ */ (0,U.jsx)(j,{tone:`empty`,icon:/* @__PURE__ */ (0,U.jsx)(Ce,{"aria-hidden":`true`}),title:e(`popup.site.notSite`),description:e(`popup.site.notSiteHint`)})})}function Jr({project:e,page:t}){let{t:n}=D(),r=Hr(s(e.id),t),{state:i}=r,a={createApplication:t=>Nr(R,e.id,t),createEnvironment:(t,n)=>Pr(R,e.id,t,n),createCell:(n,r)=>Fr(R,e.id,t.origin,n,r),replaceCell:n=>Ir(R,e.id,t.origin,n),readLists:()=>Or(R,e.id)},o=async()=>{try{let t=await c.call(`REFRESH_PROJECT_TARGETS`,{projectId:e.id});t.success||Wr.error(`pgm-ef389a0081`,{projectId:e.id,error:t.error})}catch(t){Wr.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)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Xr,{failure:i})]});if(i.status===`loading`)return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{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)(k,{className:`h-6 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(k,{className:`h-6 w-20.5 rounded-full`})]})]});let l=(n,i)=>/* @__PURE__ */ (0,U.jsx)(Yr,{project:e,page:t,screen:n,failure:i,requests:a,site:r,onBound:o});if(i.status===`binding`)return l(i.screen,i.failure);let u=i.screen;switch(u.kind){case`unsupported`:return/* @__PURE__ */ (0,U.jsx)(qr,{});case`matched`:return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(gr,{applicationName:u.applicationName,environmentName:u.environmentName})]});case`ambiguous`:return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(_r,{tone:`warning`,icon:/* @__PURE__ */ (0,U.jsx)(ue,{"aria-hidden":`true`}),hintName:n(`popup.site.more`,{about:n(`popup.site.ambiguous`,{environment:u.environmentName})}),hint:n(`popup.site.ambiguousHint`),children:n(`popup.site.ambiguous`,{environment:u.environmentName})})]});case`trustedSite`:return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(_r,{icon:/* @__PURE__ */ (0,U.jsx)(yt,{"aria-hidden":`true`,className:`text-fg-info`}),hintName:n(`popup.site.more`,{about:n(`popup.site.trustedSite`)}),hint:n(`popup.site.trustedSiteHint`),children:/* @__PURE__ */ (0,U.jsx)(`b`,{children:n(`popup.site.trustedSite`)})})]});case`environmentChoice`:return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(yr,{projectId:e.id,host:t.host,environments:u.environments,chosenId:u.chosenId,onChosen:r.afterEnvironmentChosen})]});case`bind`:return l(u,null)}}function Yr({project:e,page:t,screen:n,failure:r,requests:i,site:a,onBound:o}){let{t:s}=D(),c=Sr(t.host);return/* @__PURE__ */ (0,U.jsxs)(X,{children:[/* @__PURE__ */ (0,U.jsx)(Z,{host:t.host}),r!==null&&/* @__PURE__ */ (0,U.jsx)(Xr,{failure:r}),/* @__PURE__ */ (0,U.jsx)(j,{tone:`empty`,line:`flow`,icon:/* @__PURE__ */ (0,U.jsx)(Ce,{"aria-hidden":`true`}),title:{template:s(n.reason===`no_targets`?`popup.site.noTargets`:`popup.site.notBound`),values:{project:e.name}},hint:{name:s(`popup.site.bindMore`),text:s(`popup.site.bindInfo`)}}),/* @__PURE__ */ (0,U.jsx)(pr,{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 Xr({failure:e}){let{t}=D();return/* @__PURE__ */ (0,U.jsx)(j,{tone:`error`,error:e.error,title:t(`popup.site.readFailed`),onRetry:e.retry,"data-testid":`popup-site-read-failure`})}var Zr=V(`pgs-930365a583`),Qr=`all`;function $r({tabId:e,applications:t,applicationId:n}){let{t:r}=D(),i=ot({write:async t=>{let n=await c.call(`SET_TAB_STATE`,{tabId:e,state:{applicationId:t}});if(!n.success)throw Error(`SET_TAB_STATE refused: ${n.error}`)},confirm:()=>void 0,onWriteError:t=>{Zr.error(`pgm-e58825e7fe`,{tabId:e,error:t instanceof Error?t.message:String(t)})}});return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(I,{appearance:`tile`,"aria-label":r(`popup.application.label`),nameTooltip:!0,icon:/* @__PURE__ */ (0,U.jsx)(Ke,{"aria-hidden":`true`}),className:`ml-1.5`,value:n===null?Qr:n,onValueChange:e=>i.choose(e===Qr?null:e),options:[{value:Qr,label:r(`popup.application.all`)},...t.map(e=>({value:e.id,label:e.name}))],"data-testid":`popup-application`}),i.failure!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:i.failure.error,what:r(`popup.application.switchFailed`),onRetry:i.retry,className:`mx-1.5 mt-1`,"data-testid":`popup-application-failure`})]})}function ei({run:e}){let{t}=D();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 ti=V(`pgs-c184079221`);function ni({tabId:e,projects:t,tabProject:n,applicationId:r,run:i,onPick:a,switchFailure:o,onRetrySwitch:c,pickerOpen:l,onPickerOpenChange:u}){let{t:d}=D();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":d(`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)(Un,{value:n===null?null:{id:n.id,name:n.name},onValueChange:a,list:{state:`ready`,projects:t},labels:{label:d(`popup.project.label`),placeholder:d(`popup.project.placeholder`),search:d(`popup.project.search`),nothingFound:d(`popup.project.nothingFound`),noProjects:d(`popup.projects.emptyTitle`),loading:d(`popup.project.loading`),failed:d(`popup.projects.failedTitle`)},open:l,onOpenChange:u,autoFocus:!0,"data-testid":`popup-project`}),o!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:o.error,what:d(`popup.project.switchFailed`),onRetry:c,className:`mx-1.5 mt-1 mb-1`,"data-testid":`popup-project-failure`}),n!==null&&/* @__PURE__ */ (0,U.jsx)(ri,{tabId:e,projectId:s(n.id),applicationId:r},n.id)]}),/* @__PURE__ */ (0,U.jsx)(Gr,{tabId:e,project:n,projects:t,onSelectProject:a},`${e}:${n===null?``:n.id}`),i!==null&&/* @__PURE__ */ (0,U.jsx)(ei,{run:i})]})}function ri({tabId:e,projectId:t,applicationId:n}){let{data:r,error:i}=l({projectId:t});return(0,H.useEffect)(()=>{i!==null&&ti.error(`pgm-f42292fd59`,{error:i.message})},[i]),i!==null||r===void 0||r.length<=1?null:/* @__PURE__ */ (0,U.jsx)($r,{tabId:e,applications:r,applicationId:n})}var ii=[{key:`bugs`,tone:`error`},{key:`checklists`,tone:`primary`}],ai={bugs:`popup.filters.bugs`,checklists:`popup.filters.checklists`};function oi(){let{t:e}=D(),t=G(`filters`),n=K(`filters`);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?ii.map(e=>/* @__PURE__ */ (0,U.jsx)(k,{className:`h-8.5 w-24 rounded-full`},e.key)):ii.map(r=>/* @__PURE__ */ (0,U.jsx)(Ue,{pressed:t[r.key],tone:r.tone,size:`md`,onClick:()=>n.choose({...t,[r.key]:!t[r.key]}),"data-testid":`popup-filter-${r.key}`,children:e(ai[r.key])},r.key))}),n.failure!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:n.failure.error,what:e(`popup.filters.saveFailed`),onRetry:n.retry,className:`mx-0.5`,"data-testid":`popup-filters-failure`})]})}function si({onEnable:e}){let{t}=D();return/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,children:/* @__PURE__ */ (0,U.jsx)(Pe,{tone:`info`,icon:/* @__PURE__ */ (0,U.jsx)(Yt,{"aria-hidden":`true`}),title:t(`popup.paused.title`),actionsPlacement:`below`,actions:/* @__PURE__ */ (0,U.jsx)(He,{onClick:e,children:t(`popup.paused.enable`)}),"data-testid":`popup-paused`})})}function ci({projectSwitch:e,currentProjectName:t}){let{t:n}=D(),{question:r,busy:i,confirm:a,cancel:o}=e;if(r===null)return null;let{run:s,target:c}=r,l=s.kind===`free`,d=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)(u,{open:!0,busy:i,onCancel:o,tone:l?`danger`:`warning`,icon:l?/* @__PURE__ */ (0,U.jsx)(x,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(qt,{"aria-hidden":`true`}),title:n(l?`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)(h,{variant:`secondary`,onClick:o,children:n(`popup.switchRun.stay`)}),/* @__PURE__ */ (0,U.jsx)(h,{variant:l?`danger`:`primary`,loading:i,onClick:a,"data-testid":`popup-project-switch-confirm`,children:n(l?`popup.switchRun.freeConfirm`:`popup.switchRun.planConfirm`)})]})})}var li=V(`pgs-ab0307fe13`);function ui({tabId:e,projectId:t,currentTestRun:n}){let[r,i]=(0,H.useState)(null),[a,o]=(0,H.useState)(!1),[s,l]=(0,H.useState)(null),u=async t=>{try{let n=await c.call(`RESTORE_PROJECT`,{tabId:e,projectId:t.id,projectNumber:t.number,applicationId:null});if(!n.success)throw Error(`RESTORE_PROJECT refused: ${n.error}`)}catch(n){li.error(`pgm-61ab57a774`,{tabId:e,error:n instanceof Error?n.message:String(n)}),l({target:t,error:n});return}li.info(`pgm-496ade1c1d`,{tabId:e}),l(null)},d=e=>{l(null),e.id!==t&&(n===null?u(e):i({target:e,run:n}))};return{question:r,busy:a,choose:d,confirm(){r===null||a||(o(!0),u(r.target).finally(()=>{o(!1),i(null)}))},cancel(){a||i(null)},failure:s,retry(){if(s===null)throw Error(`useProjectSwitch: nothing failed to retry`);d(s.target)}}}function di({user:e,header:t,back:n,strip:r,snapshot:a,projects:o,tabProject:c,power:l}){let{t:u}=D(),d=G(`enabled`),[f,p]=(0,H.useState)(!1),{state:m,tabId:h}=a,g=ui({tabId:h,projectId:m.projectId,currentTestRun:m.currentTestRun}),_;switch(o.state){case`loading`:_=/* @__PURE__ */ (0,U.jsx)(tn,{});break;case`error`:_=/* @__PURE__ */ (0,U.jsx)(fi,{children:/* @__PURE__ */ (0,U.jsx)(j,{tone:`error`,error:o.error,title:u(`popup.projects.failedTitle`),onRetry:o.retry,retrying:o.retrying})});break;case`ready`:{if(o.projects.length===0){_=/* @__PURE__ */ (0,U.jsx)(fi,{children:/* @__PURE__ */ (0,U.jsx)(j,{tone:`empty`,icon:/* @__PURE__ */ (0,U.jsx)(P,{"aria-hidden":`true`}),title:u(`popup.projects.emptyTitle`),description:u(`popup.projects.emptyText`),primary:{label:u(`popup.projects.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(Ee,{"aria-hidden":`true`}),onClick:()=>i(),opensInNewTab:!0}})});break}let t=/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(ni,{tabId:h,projects:o.projects,tabProject:c,applicationId:m.applicationId,run:m.currentTestRun,onPick:g.choose,switchFailure:g.failure,onRetrySwitch:g.retry,pickerOpen:f,onPickerOpenChange:p}),/* @__PURE__ */ (0,U.jsx)(oi,{})]});_=c===null?t:/* @__PURE__ */ (0,U.jsx)(vt,{user:e,project:{id:s(c.id),number:et(c.number)},children:t});break}}let v=o.state===`ready`&&o.projects.length>0;return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:B(`flex min-h-0 flex-1 flex-col`,n?ht:ut),children:[t,/* @__PURE__ */ (0,U.jsxs)($t,{className:v&&f?`min-h-90`:void 0,children:[l.failure!==null&&/* @__PURE__ */ (0,U.jsx)(W,{error:l.failure.error,what:u(`popup.header.switchFailed`),onRetry:l.retry,className:`mx-0.5`,"data-testid":`popup-power-failure`}),v&&d===!1&&/* @__PURE__ */ (0,U.jsx)(si,{onEnable:()=>l.choose(!0)}),r,_]}),/* @__PURE__ */ (0,U.jsx)(ci,{projectSwitch:g,currentProjectName:c===null?null:c.name})]})}function fi({children:e}){return/* @__PURE__ */ (0,U.jsx)(a,{className:`h-84`,children:e})}function pi(){let{data:e,loading:t,error:n,retrying:r,reload:i}=me({previousErrorWhileRetrying:!0}),a=(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:a}:{state:`error`,error:n,retrying:r,retry:()=>void i()}}var mi=V(`pgs-aea740cf56`);function hi({windowId:e,revision:t,back:n,onBack:r,onOpenSettings:i}){let{t:a}=D(),o=(0,H.useRef)(null);return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n?ht:ut}`,"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)(M,{relationship:`label`,content:a(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(L,{icon:/* @__PURE__ */ (0,U.jsx)(Ct,{"aria-hidden":`true`}),onClick:r,autoFocus:!0,"data-testid":`popup-feed-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{ref:o,tabIndex:-1,className:`m-0 mr-auto rounded-xs text-body-md font-semibold tracking-(--tracking-title) text-fg-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-stroke-focus`,children:a(`notifications.feed.title`)}),/* @__PURE__ */ (0,U.jsx)(M,{relationship:`label`,content:a(`notifications.feed.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(L,{icon:/* @__PURE__ */ (0,U.jsx)(xt,{"aria-hidden":`true`}),onClick:i,"data-testid":`popup-feed-settings`})})]}),/* @__PURE__ */ (0,U.jsx)(it,{host:`popup`,focusOnLeave:o,api:R.notifications,locale:F(),t:a,revision:t,logger:mi,onOpenTarget:t=>lt(t,e),onOpenSettings:i,onSeen:()=>gt(`seen`)})]})}var gi=V(`pgs-a3c52049ce`);function _i({windowId:e,waitingCount:t,revision:n,onOpenFeed:r}){let{t:i}=D();return/* @__PURE__ */ (0,U.jsx)(ct,{api:R.notifications,locale:F(),t:i,waitingCount:t,revision:n,logger:gi,onOpenTarget:t=>lt(t,e),onOpenFeed:r,onSeen:()=>gt(`seen`)})}var vi=V(`pgs-fed3bb0e75`);function yi(e){return e instanceof Error?e.message:String(e)}function bi(){return ot({write:xi,confirm:()=>void 0,onWriteError:(e,t)=>{vi.error(`pgm-e410ff75a4`,{keySource:t.keySource,modelId:t.modelId,error:yi(e)})}})}async function xi(e){let t=await Me(`modelPick`);await $e(`modelPick`,e);try{await R.aiSettings.updateUser({selectedProvider:e.keySource,selectedModel:e.modelId})}catch(n){throw await Si(e,t).catch(t=>{vi.error(`pgm-545c072dd8`,{keySource:e.keySource,modelId:e.modelId,error:yi(t)})}),n}}async function Si(e,t){let n=await Me(`modelPick`);rt(n,e)?await $e(`modelPick`,t):vi.info(`pgm-ef3566b49a`,{refusedModelId:e.modelId,storedModelId:n===null?null:n.modelId})}var Ci={dark:`[--pg:var(--theme-preview-dark-ground)] [--pdot:color-mix(in_srgb,var(--theme-preview-dark-ink)_16%,transparent)] [--pisl:color-mix(in_srgb,var(--theme-preview-dark-island)_88%,transparent)] [--pring:color-mix(in_srgb,var(--theme-preview-dark-ink)_12%,transparent)] [--pline:color-mix(in_srgb,var(--theme-preview-dark-ink)_22%,transparent)] [--plight:color-mix(in_srgb,var(--color-primary-500)_30%,transparent)]`,light:`[--pg:var(--theme-preview-light-ground)] [--pdot:color-mix(in_srgb,var(--theme-preview-light-ink)_16%,transparent)] [--pisl:color-mix(in_srgb,var(--theme-preview-light-island)_90%,transparent)] [--pring:color-mix(in_srgb,var(--theme-preview-light-ink)_10%,transparent)] [--pline:color-mix(in_srgb,var(--theme-preview-light-ink)_16%,transparent)] [--plight:color-mix(in_srgb,var(--color-primary-300)_32%,transparent)]`},wi=`[clip-path:polygon(62%_0,100%_0,100%_100%,38%_100%)]`,Ti=`absolute z-1 block bg-(--pisl) shadow-[inset_0_0_0_1px_var(--pring)]`,Ei=`absolute top-[24%] left-[10%] h-1 w-[46%] rounded-full bg-(--pline)`;function Di({palette:e,half:t}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{className:B(`absolute inset-0`,Ci[e],t&&wi),children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`absolute inset-0 bg-(--pg)`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`absolute inset-0 bg-[radial-gradient(circle_at_1px_1px,var(--pdot)_0.8px,transparent_1.2px)] bg-size-[9px_9px]`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`absolute top-[-30%] left-[40%] h-[70%] w-[70%] rounded-full bg-(--plight) blur-[18px]`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:B(Ti,`top-[7%] right-[32%] left-[32%] h-[9%] rounded-full`)}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:B(Ti,`top-[23%] bottom-[7%] left-[5%] w-[22%] rounded-sm`),children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:Ei}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`absolute top-[44%] right-[10%] left-[10%] h-1.5 rounded-full bg-[color-mix(in_srgb,var(--color-primary-400)_40%,transparent)]`})]}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:B(Ti,`top-[23%] right-[5%] left-[31%] h-[30%] rounded-sm`),children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:Ei}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`absolute top-[22%] right-[9%] h-1.5 w-[16%] rounded-full bg-primary-400 opacity-90`})]}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:B(Ti,`top-[58%] right-[5%] bottom-[7%] left-[31%] rounded-sm`),children:/* @__PURE__ */ (0,U.jsx)(`span`,{className:Ei})})]})}function Oi({theme:e}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{"aria-hidden":`true`,className:`relative isolate block aspect-[16/10.5]`,children:[/* @__PURE__ */ (0,U.jsx)(Di,{palette:e===`light`?`light`:`dark`,half:!1}),e===`system`&&/* @__PURE__ */ (0,U.jsx)(Di,{palette:`light`,half:!0})]})}var ki=[`dark`,`light`,`system`],Ai=/* @__PURE__ */ new Set([`light`,`dark`,`system`]);function ji(e){return Ai.has(e)}function Mi({value:e,onChange:t,labels:n,className:r}){let i=(0,H.useId)();return/* @__PURE__ */ (0,U.jsx)(`fieldset`,{"aria-label":n.group,className:B(`m-0 grid min-w-0 grid-cols-3 gap-2.5 border-0 p-0`,r),children:ki.map(r=>/* @__PURE__ */ (0,U.jsx)(Mt,{name:i,value:r,checked:e===r,onChange:e=>{let n=e.target.value;if(!ji(n))throw Error(`ThemeToggle: unknown theme \u00AB${n}\u00BB`);t(n)},title:n[r],media:/* @__PURE__ */ (0,U.jsx)(Oi,{theme:r})},r))})}function Ni(e){if(e.look===`preview`)return/* @__PURE__ */ (0,U.jsx)(Mi,{...e});let{value:t,onChange:n,labels:r,size:i,fullWidth:a,className:o}=e;return/* @__PURE__ */ (0,U.jsx)(de,{value:t,onValueChange:n,"aria-label":r.group,size:i,fullWidth:a,className:o,options:[{value:`light`,label:r.light,icon:/* @__PURE__ */ (0,U.jsx)(Xt,{"aria-hidden":`true`})},{value:`dark`,label:r.dark,icon:/* @__PURE__ */ (0,U.jsx)(Jt,{"aria-hidden":`true`})},{value:`system`,label:r.system,icon:/* @__PURE__ */ (0,U.jsx)(Tt,{"aria-hidden":`true`})}]})}function Pi({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})}function Q({title:e,hint:t,children:n,"data-testid":r}){let{t:i}=D();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)(Ye,{name:i(`popup.site.more`,{about:e}),text:t,placement:`bottom-start`})]}),/* @__PURE__ */ (0,U.jsx)(Ut,{kind:`block`,body:`rows`,density:`compact`,children:/* @__PURE__ */ (0,U.jsx)(S,{children:n})})]})}function $({label:e,below:t,failure:n,stacked:r=!1,alignStart:i=!1,children:a,"data-testid":o}){return/* @__PURE__ */ (0,U.jsxs)(Xe,{title:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:e}),end:a,stacked:r,alignStart:i,under:r?void 0:n,"data-testid":o,children:[t,r?n:null]})}var Fi=/* @__PURE__ */ new Set([`Control`,`Alt`,`Shift`,`Meta`]);function Ii(e){if(Fi.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 Li(){let{t:e}=D(),t=K(`selectionHotkey`);return/* @__PURE__ */ (0,U.jsx)($,{label:e(`popup.settings.hotkey`),failure:t.failure===null?void 0:/* @__PURE__ */ (0,U.jsx)(W,{error:t.failure.error,onRetry:t.retry,"data-testid":`popup-hotkey-failure`}),children:/* @__PURE__ */ (0,U.jsx)(Ri,{onCapture:t.choose})})}function Ri({onCapture:e}){let{t}=D(),n=G(`selectionHotkey`),[r,i]=(0,H.useState)(!1);return n===void 0?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-(--control-height-sm) w-12 rounded-(--input-radius)`}):/* @__PURE__ */ (0,U.jsx)(Ze,{size:`sm`,active:r,"aria-label":t(`popup.settings.hotkeyName`,{hotkey:n}),onClick:()=>i(!0),onBlur:()=>i(!1),onKeyDown:t=>{if(!r)return;if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){i(!1);return}let n=Ii(t);n!==null&&(i(!1),e(n))},"data-testid":`popup-hotkey`,children:r?/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-(--color-primary-text) animate-pulse-dot`,children:t(`popup.settings.hotkeyCapture`)}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:n.split(`+`).map((e,t)=>/* @__PURE__ */ (0,U.jsx)(Pi,{children:e},`${e}-${t}`))})})}var zi=V(`pgs-fed3bb0e75`),Bi={managed:null,company:`popup.settings.modelKeyCompany`,personal:`popup.settings.modelKeyPersonal`};function Vi({save:e}){let{t}=D(),n=G(`modelPick`),r=(0,H.useMemo)(()=>wt({http:Gt(),logger:zi}),[]),i=ze(),a=(0,H.useRef)(null),{data:o,error:s,retrying:c,reload:l}=m({key:O(i,`chat-model-capabilities`),read:()=>r.load(),freshness:`screen`,previousErrorWhileRetrying:!0});(0,H.useEffect)(()=>{s!==null&&zi.error(`pgm-9665648376`,{error:s.message})},[s]);let u=e.failure===null?void 0:/* @__PURE__ */ (0,U.jsx)(W,{error:e.failure.error,refusalKey:`popup.settings.saveFailed`,onRetry:e.retry,"data-testid":`popup-model-failure`});if(s!==null)return/* @__PURE__ */ (0,U.jsx)($,{label:t(`popup.settings.model`),below:/* @__PURE__ */ (0,U.jsx)(j,{tone:`error`,error:s,title:t(`popup.settings.modelsReadFailed`),onRetry:()=>void l(),retrying:c,focusOnLeave:a,headingLevel:4,className:`mt-2`,"data-testid":`popup-model-read-failed`}),failure:u,alignStart:!0,"data-testid":`popup-model`,children:null});if(n===void 0||o===void 0)return/* @__PURE__ */ (0,U.jsx)($,{label:t(`popup.settings.model`),children:/* @__PURE__ */ (0,U.jsx)(k,{className:`h-8 w-37.5 rounded-lg`})});let d=o.groups,f=n===null?null:_t(o,n),p=St(o,f,null),h=d.every(e=>e.models.length===0)?{tone:`empty`,icon:/* @__PURE__ */ (0,U.jsx)(pe,{"aria-hidden":`true`}),title:t(`popup.settings.modelNone`)}:void 0;return/* @__PURE__ */ (0,U.jsx)($,{label:t(`popup.settings.model`),failure:u,"data-testid":`popup-model`,children:/* @__PURE__ */ (0,U.jsx)(I,{size:`sm`,"aria-label":t(`popup.settings.model`),placeholder:t(`popup.settings.modelNone`),listState:h,triggerRef:a,value:p===null?null:p.model.selectionId,onValueChange:t=>{for(let n of d){let r=n.models.find(e=>e.selectionId===t);if(r!==void 0){e.choose({keySource:n.source,modelId:r.id});return}}throw Error(`The AI model Select picked a row it did not render: ${t}`)},className:`w-37.5`,options:d.flatMap(e=>e.models.map(n=>{let r=Bi[e.source];return{value:n.selectionId,label:r===null?n.name:`${n.name} \u00B7 ${t(r)}`,disabled:!bt(n)}}))})})}var Hi=V(`pgs-cdc66fba2a`),Ui={permissions:[`notifications`]},Wi={status:`reading`},Gi={status:`off`},Ki={status:`asking`},qi={status:`on`},Ji={status:`denied`};function Yi(e){return e instanceof Error?e.message:String(e)}function Xi(){return[chrome.permissions.onAdded,chrome.permissions.onRemoved]}function Zi(e){var t;return((t=e.permissions)==null?void 0:t.includes(`notifications`))===!0}function Qi(){let{t:e}=D(),[t,n]=(0,H.useState)(Wi),r=(0,H.useRef)(!0),i=(0,H.useCallback)(()=>{chrome.permissions.contains(Ui).then(e=>{r.current&&n(t=>e?qi:t.status===`denied`?Ji:Gi)},e=>{Hi.error(`pgm-cbfb085fbb`,{error:Yi(e)}),r.current&&n({status:`readFailed`,error:e,retrying:!1})})},[]);(0,H.useEffect)(()=>{r.current=!0;let e=e=>{Zi(e)&&i()},t=Xi();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(e=>e.status===`readFailed`?{...e,retrying:!0}:e),i()},o=e=>{e?(n(Ki),chrome.permissions.request(Ui).then(e=>n(e?qi:Ji),e=>{Hi.error(`pgm-67efc28caa`,{error:Yi(e)}),n(Gi)})):chrome.permissions.remove(Ui).then(e=>{e||Hi.error(`pgm-2cbfb59188`),n(e?Gi:qi)},e=>{Hi.error(`pgm-ac8845b9f5`,{error:Yi(e)})})},s=e(`popup.settings.osNotifications`);return/* @__PURE__ */ (0,U.jsx)($,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[s,/* @__PURE__ */ (0,U.jsx)(Ye,{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.status===`denied`&&/* @__PURE__ */ (0,U.jsx)(st,{tone:`neutral`,announce:!0,"data-testid":`popup-os-notifications-denied`,children:e(`popup.settings.osNotificationsDenied`)}),t.status===`readFailed`&&/* @__PURE__ */ (0,U.jsx)(j,{tone:`error`,error:t.error,title:e(`popup.settings.osNotificationsReadFailed`),onRetry:a,retrying:t.retrying,headingLevel:4,className:`mt-2`,"data-testid":`popup-os-notifications-read-failed`})]}),alignStart:!0,"data-testid":`popup-os-notifications`,children:t.status===`reading`?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5 w-9 rounded-full`}):t.status===`readFailed`?null:/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[t.status===`asking`&&/* @__PURE__ */ (0,U.jsx)(ae,{}),/* @__PURE__ */ (0,U.jsx)(T,{"aria-label":s,checked:t.status===`on`,onChange:o,"data-testid":`popup-os-notifications-switch`})]})})}var $i=V(`pgs-7fed4be7cb`);function ea(){let{t:e}=D(),t=G(`notificationsEnabled`),n=K(`notificationsEnabled`),r=e(`popup.settings.notifications`);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Q,{title:e(`popup.settings.groups.notifications`),hint:e(`popup.settings.groups.notificationsHint`),"data-testid":`popup-notification-groups`,children:/* @__PURE__ */ (0,U.jsx)(pt,{api:R.notifications,locale:F(),t:e,logger:$i,onChanged:()=>gt(`group_changed`)})}),/* @__PURE__ */ (0,U.jsxs)(Q,{title:e(`popup.settings.groups.thisBrowser`),children:[/* @__PURE__ */ (0,U.jsx)(Qi,{}),/* @__PURE__ */ (0,U.jsx)($,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[r,/* @__PURE__ */ (0,U.jsx)(Ye,{name:e(`popup.site.more`,{about:r}),text:e(`popup.settings.notificationsHint`),placement:`bottom-start`})]}),failure:n.failure===null?void 0:/* @__PURE__ */ (0,U.jsx)(W,{error:n.failure.error,onRetry:n.retry,"data-testid":`popup-notifications-failure`}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(T,{"aria-label":r,checked:t,onChange:n.choose,"data-testid":`popup-notifications`})})]})]})}var ta=/^\d+$/;function na(e){let t=e.trim();return ta.test(t)?Number(t)>Se?`tooLong`:null:`notWholeNumber`}function ra(){let{t:e,i18n:t}=D(),n=G(`autoplayStepPauseMs`),r=K(`autoplayStepPauseMs`),[i,a]=(0,H.useState)(null),o=i===null?null:na(i),s=o!==null,c=()=>{if(i===null||s)return;let e=Number(i.trim());a(null),e!==n&&r.choose(e)};return/* @__PURE__ */ (0,U.jsx)($,{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)(Ve,{"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(Se)}):e(`popup.settings.pauseInvalid`)})]}):void 0,failure:s||r.failure===null?void 0:/* @__PURE__ */ (0,U.jsx)(W,{error:r.failure.error,onRetry:r.retry,"data-testid":`popup-step-pause-failure`}),"data-testid":`popup-step-pause`,children:n===void 0?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-8 w-26 rounded-lg`}):/* @__PURE__ */ (0,U.jsx)(Ge,{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 ia({modelSave:e,onBack:t}){let{t:n}=D();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${ut}`,"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)(M,{relationship:`label`,content:n(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(L,{icon:/* @__PURE__ */ (0,U.jsx)(Ct,{"aria-hidden":`true`}),onClick:t,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:n(`popup.settings.title`)})]}),/* @__PURE__ */ (0,U.jsxs)($t,{children:[/* @__PURE__ */ (0,U.jsx)(ea,{}),/* @__PURE__ */ (0,U.jsxs)(Q,{title:n(`popup.settings.groups.view`),children:[/* @__PURE__ */ (0,U.jsx)(aa,{}),/* @__PURE__ */ (0,U.jsx)(oa,{})]}),/* @__PURE__ */ (0,U.jsxs)(Q,{title:n(`popup.settings.groups.recording`),children:[/* @__PURE__ */ (0,U.jsx)(Li,{}),/* @__PURE__ */ (0,U.jsx)(ra,{})]}),/* @__PURE__ */ (0,U.jsx)(Q,{title:n(`popup.settings.groups.assistant`),children:/* @__PURE__ */ (0,U.jsx)(Vi,{save:e})})]})]})}function aa(){let{t:e}=D(),t=G(`theme`),n=K(`theme`);return/* @__PURE__ */ (0,U.jsx)($,{label:e(`popup.settings.theme`),stacked:!0,failure:n.failure===null?void 0:/* @__PURE__ */ (0,U.jsx)(W,{error:n.failure.error,onRetry:n.retry,"data-testid":`popup-theme-failure`}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(k,{className:`h-9 w-full rounded-full`}):/* @__PURE__ */ (0,U.jsx)(Ni,{value:t,onChange:n.choose,labels:{group:e(`popup.settings.theme`),light:e(`popup.settings.themeLight`),dark:e(`popup.settings.themeDark`),system:e(`popup.settings.themeSystem`)},fullWidth:!0})})}function oa(){let{t:e}=D(),t=pn(),{failure:n}=t;return/* @__PURE__ */ (0,U.jsx)($,{label:e(`popup.settings.language`),stacked:!0,failure:n===null?void 0:n.step===`profile`?/* @__PURE__ */ (0,U.jsx)(W,{error:n.error,refusalKey:`popup.language.profileSaveFailed`,onRetry:n.retry,"data-testid":`popup-language-failure`}):/* @__PURE__ */ (0,U.jsx)(W,{error:n.error,onRetry:n.retry,"data-testid":`popup-language-failure`}),children:/* @__PURE__ */ (0,U.jsx)(mn,{onChoose:t.choose,fullWidth:!0})})}var sa=V(`pgs-b5906754fa`);function ca({user:e}){let t=Be(),n=pi(),r=G(`enabled`),i=K(`enabled`),a=bi(),o=at(e.id),c=mt(),[l,u]=(0,H.useState)({name:`main`,back:!1});if((0,H.useEffect)(()=>{gt(`surface_opened`)},[]),c===void 0)return/* @__PURE__ */ (0,U.jsx)(en,{});let d=n.state===`ready`?la(t,n.byId):null,f=o.status===`ready`?o.snapshot:null,p=o.status===`ready`?o.revision:0,m=()=>u({name:`settings`,back:!1}),h=()=>u({name:`feed`,back:!1}),g=()=>u({name:`main`,back:!0}),_=/* @__PURE__ */ (0,U.jsx)(xn,{user:e,onOpenSettings:m,notificationCounts:f,onOpenNotifications:h,onSwitch:i.choose}),v=r===!0&&f!==null?/* @__PURE__ */ (0,U.jsx)(_i,{windowId:c,waitingCount:f.waitingCount,revision:p,onOpenFeed:h}):null;switch(l.name){case`settings`:{let t=/* @__PURE__ */ (0,U.jsx)(ia,{modelSave:a,onBack:g});return d===null?t:/* @__PURE__ */ (0,U.jsx)(vt,{user:e,project:{id:s(d.id),number:et(d.number)},children:t})}case`feed`:return/* @__PURE__ */ (0,U.jsx)(hi,{windowId:c,revision:p,back:l.back,onBack:g,onOpenSettings:m});case`main`:return/* @__PURE__ */ (0,U.jsx)(di,{user:e,header:_,back:l.back,strip:v,snapshot:t,projects:n,tabProject:d,power:i})}}function la(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 ua(){let{t:e}=D();return/* @__PURE__ */ (0,U.jsx)(Ie,{loading:/* @__PURE__ */ (0,U.jsx)(en,{}),signedOut:/* @__PURE__ */ (0,U.jsx)(hn,{}),unavailable:t=>/* @__PURE__ */ (0,U.jsx)(`div`,{className:`grid flex-1 content-center p-5`,children:/* @__PURE__ */ (0,U.jsx)(tt,{state:t,description:e(`shell.session.checkNotDone`)})}),children:e=>/* @__PURE__ */ (0,U.jsx)(cn,{user:e,children:/* @__PURE__ */ (0,U.jsx)(H.Suspense,{fallback:/* @__PURE__ */ (0,U.jsx)(en,{}),children:/* @__PURE__ */ (0,U.jsx)(ca,{user:e})})})})}var da=V(`pgs-2e3f74b175`),fa=document.getElementById(`popup-root`);fa===null?da.error(`pgm-f13077b9ed`):f({surface:`popup`,root:fa,followedTab:ft(),editorNavigation:g(`popup`),render:()=>/* @__PURE__ */ (0,U.jsx)(ua,{})}).catch(e=>{da.error(`pgm-f4cc990f36`,e)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
html,body{width:100%;height:100%;overflow:hidden}.qa-tooltip-trigger:focus-visible{outline:2px solid var(--color-border-focus);outline-offset:2px}#assistant-root{flex-direction:column;width:100%;height:100vh;display:flex;overflow:hidden}.qa-sidepanel-center{flex:1;min-height:0;display:grid;overflow:auto}.qa-sidepanel-sign-in{width:100%;max-width:320px;padding-top:var(--spacing-3);justify-self:center}.qa-sidepanel-skeleton{flex-direction:column;flex:1;min-height:0;display:flex}.qa-sidepanel-skeleton__head{padding:var(--spacing-2) var(--spacing-2) var(--spacing-2) var(--spacing-3);flex-direction:column;flex:none;gap:2px;display:flex}.qa-sidepanel-skeleton__head-row{align-items:center;gap:9px;min-height:34px;display:flex}.qa-sidepanel-skeleton__head-row--conversation{gap:var(--spacing-1)}.qa-sidepanel-skeleton__head-tile{border-radius:var(--radius-full);flex:none;width:26px;height:26px}.qa-sidepanel-skeleton__head-names{align-items:center;gap:7px;display:flex}.qa-sidepanel-skeleton__head-title{width:52px;height:12px}.qa-sidepanel-skeleton__head-project{width:96px;height:10px}.qa-sidepanel-skeleton__head-capsule{border-radius:var(--radius-full);flex:1;min-width:0;height:36px}.qa-sidepanel-skeleton__head-new{border-radius:var(--radius-full);flex:none;width:32px;height:32px}.qa-sidepanel-skeleton__body{min-height:0;padding:var(--spacing-6);flex:1;align-content:center;justify-items:center;gap:6px;display:grid}.qa-sidepanel-skeleton__body-tile{border-radius:var(--radius-lg);width:44px;height:44px}.qa-sidepanel-skeleton__body-title{width:170px;height:16px;margin-top:6px}.qa-sidepanel-skeleton__body-line{width:220px;height:12px}.qa-sidepanel-skeleton__body-suggestion{border-radius:var(--radius-full);width:200px;height:32px;margin-top:10px}.qa-sidepanel-skeleton__body-suggestion--wide{width:220px;margin-top:0}.qa-sidepanel-skeleton__composer{margin:0 var(--spacing-3) var(--spacing-3);padding:var(--spacing-3) var(--spacing-3) 10px;border:1px solid var(--color-border);border-radius:var(--radius-xl);background:var(--color-bg-secondary);box-shadow:var(--shadow-sm);flex:none;gap:10px;display:grid}[data-theme=light] .qa-sidepanel-skeleton__composer{background:var(--color-bg-card)}@media (prefers-color-scheme:light){[data-theme=system] .qa-sidepanel-skeleton__composer{background:var(--color-bg-card)}}.qa-sidepanel-skeleton__composer-text{width:60%;height:14px}.qa-sidepanel-skeleton__composer-foot{align-items:center;gap:var(--spacing-2);display:flex}.qa-sidepanel-skeleton__composer-pill{border-radius:var(--radius-full);width:80px;height:26px;margin-left:auto}.qa-sidepanel-skeleton__composer-send{border-radius:50%;width:32px;height:32px}
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title
|
|
6
|
+
<title>Progon AI Assistant</title>
|
|
7
7
|
<script type="module" crossorigin src="../sidepanel/sidepanel.js"></script>
|
|
8
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
9
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
13
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
16
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="../chunks/shared
|
|
18
|
-
<link rel="stylesheet" crossorigin href="../chunks/shared-
|
|
19
|
-
<link rel="stylesheet" crossorigin href="../chunks/shared-
|
|
8
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-XKyaHtl9.js">
|
|
9
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-CDlAJRnF.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-0jT00uC5.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-U9lBnzuH.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-uKTblxo0.js">
|
|
13
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-o0-3vI--.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-BECVQaqd.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-BYkDbcM2.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared-VvEftNwZ.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="../chunks/shared--PKAvBPy.js">
|
|
18
|
+
<link rel="stylesheet" crossorigin href="../chunks/shared-BdaUsVif.css">
|
|
19
|
+
<link rel="stylesheet" crossorigin href="../chunks/shared-fJPHxpB5.css">
|
|
20
20
|
<link rel="stylesheet" crossorigin href="../sidepanel/sidepanel.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body>
|