import{ar as y,bc as $,aY as n,aL as f,aP as B,b7 as q,aT as e,a2 as A,p as S,V as C,d as D,q as V,aq as O,c as E,t as M,Y as H,ab as J,aR as U,ae as Y,b9 as h,ao as X}from"./chunk-02oqS8tD.js";import"./chunk-B8Q4vgLh.js";import"./chunk-x_Z6cwvR.js";/**
 * @license lucide-react v0.451.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Z=y("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
 * @license lucide-react v0.451.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const F=y("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
 * @license lucide-react v0.451.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const G=y("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),P=[{name:"notifications",label:"Notifications",hint:"Push and desktop notification prompts",icon:Z},{name:"camera",label:"Camera",hint:"getUserMedia video capture",icon:D},{name:"microphone",label:"Microphone",hint:"getUserMedia audio capture",icon:G},{name:"clipboard",label:"Clipboard",hint:"Reading and writing the clipboard",icon:F},{name:"popups",label:"Pop-ups",hint:"window.open and pop-under windows",icon:V}],K=["allow","deny","ask"];function te(){const i=$(t=>t.go),[s,m]=n.useState(null),[I,u]=n.useState({}),[p,x]=n.useState({}),[v,o]=n.useState(!1),[j,g]=n.useState(null),[l,k]=n.useState(!0),c=n.useCallback(()=>{f().then(t=>{m(t.state),u(t.effective),x(t.state?.permissions??{})}),B().then(t=>{if(!t.ok)return k(t.error);k(t.value.targetable===!1?"Switch to a normal web page — permissions are set per origin.":t.value.tabId===null?"Open the app under test in a browser window first.":!0)})},[]);n.useEffect(()=>(c(),q(c)),[c]);const w=t=>p[t]??"ask",T=async()=>{o(!0),g(null);const t=await Y(p);if(o(!1),!t.ok)return g(t.error);m(t.value),f().then(b=>u(b.effective));const a=Object.keys(t.value.rejected??{}),r=Object.keys(t.value.permissions).length;a.length>0?h.info(`${String(r)} applied — ${a.join(", ")} refused by this browser`):r===0?h.info("All permissions handed back to Chrome"):h.success(`${String(r)} permission${r===1?"":"s"} set`)},L=async()=>{o(!0),await X(),o(!1),m(null),x({}),f().then(t=>u(t.effective)),h.info("Site settings this extension applied were removed")},N=JSON.stringify(z(p))!==JSON.stringify(z(s?.permissions??{}));return e.jsxs(A,{title:"Permissions",subtitle:"Decide what the browser grants the page, without touching a prompt.",onBack:()=>i(U("tools")),actions:s?e.jsxs(E,{size:"sm",variant:"outline",className:"h-7",onClick:L,loading:v,children:[e.jsx(J,{className:"h-3 w-3"}),"Clear"]}):void 0,sticky:s&&Object.keys(s.permissions).length>0?e.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border border-dynamic-azure/40 bg-dynamic-azure/[0.07] px-2 py-1.5",children:[e.jsx(H,{className:"h-3 w-3 shrink-0 text-dynamic-azure"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[10.5px] text-dynamic-azure",children:Object.entries(s.permissions).map(([t,a])=>`${Q(t)}: ${String(a)}`).join(" · ")})]}):void 0,children:[l!==!0&&e.jsx(S,{title:"Not available here",message:l,onRetry:c}),j&&e.jsx(S,{message:j,onRetry:()=>g(null),retryLabel:"Dismiss"}),e.jsxs(C,{title:"Permissions",hint:"Applied to the origin of the tab under test.",children:[e.jsx("div",{className:"space-y-1.5",children:P.map(t=>{const a=s?.rejected?.[t.name],r=I[t.name],b=r!==void 0&&r!==w(t.name);return e.jsxs("div",{className:O("rounded-lg border px-2.5 py-2 dark:border-stroke/25",a?"border-alert-orange/40 bg-alert-orange/[0.05]":"border-stroke/70"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.icon,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-[11px] font-medium",children:t.label}),e.jsx("span",{className:"block text-[9.5px] text-muted-foreground",children:t.hint})]}),e.jsx("div",{className:"flex shrink-0 gap-0.5 rounded-md bg-stroke/15 p-0.5 dark:bg-white/[0.04]",children:K.map(d=>e.jsx("button",{type:"button",disabled:l!==!0,onClick:()=>x(R=>({...R,[t.name]:d})),className:O("flex min-h-6 items-center justify-center rounded px-2 text-[9px] font-semibold capitalize transition-colors",w(t.name)===d?"bg-white text-dynamic-azure shadow-sm dark:bg-midnight-navy":"text-muted-foreground hover:text-foreground"),children:d},d))})]}),a&&e.jsxs("p",{className:"mt-1 text-[9.5px] leading-snug text-alert-orange",children:["This browser refused the override: ",a]}),!a&&b&&e.jsxs("p",{className:"mt-1 text-[9.5px] leading-snug text-muted-foreground",children:["Chrome currently reports ",e.jsx("strong",{className:"text-foreground",children:r})," for this origin. Apply to change it."]})]},t.name)})}),e.jsx(E,{size:"sm",className:"h-7 w-full",loading:v,disabled:!N||l!==!0,onClick:T,children:N?"Apply permissions":"No changes to apply"})]}),e.jsx(C,{title:"Elsewhere and unavailable",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-1.5 rounded-lg bg-stroke/10 px-2.5 py-2 dark:bg-white/[0.03]",children:[e.jsx(M,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground"}),e.jsxs("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:[e.jsx("strong",{className:"text-foreground",children:"Location"})," lives on the Location screen — granting it and choosing the coordinates the page receives are one decision, not two."," ",e.jsx("button",{type:"button",onClick:()=>i({name:"location"}),className:"font-semibold text-dynamic-azure hover:underline",children:"Open it"})]})]}),e.jsxs("div",{className:"flex items-start gap-1.5 rounded-lg bg-stroke/10 px-2.5 py-2 dark:bg-white/[0.03]",children:[e.jsx(M,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground"}),e.jsxs("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:["These are ",e.jsx("strong",{className:"text-foreground",children:"real Chrome site settings"})," for this origin, not session overrides — they outlive the tab and the browser restart. Clearing here removes every one this extension set, and never touches your own site preferences."]})]})]})})]})}function z(i){return Object.fromEntries(Object.entries(i).filter(([,s])=>s!=="ask"))}function Q(i){return P.find(s=>s.name===i)?.label??i}export{te as PermissionsScreen};
//# sourceMappingURL=chunk-l4BwvmPl.js.map
