import{c as e,r as t,u as s,a,b as i,j as r,H as c,S as n,M as l,d,A as m,W as o,e as x}from"./WhitelistPanel-DX2KLHCA.js";import"./constants-qmQlET8G.js";
/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const h=e("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]),u=e("panel-right",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);function p(){const[e,x]=t.useState(null),[p,j]=t.useState(!0),{isAuthenticated:y,user:f,loadFromStorage:b}=s(),{setAuthModalOpen:g,effectiveTheme:N,updateEffectiveTheme:v}=a(),{isDomainTrusted:k,trustDomain:w}=i();t.useEffect(()=>{b(),v(),j("sidePanel"in chrome),chrome.runtime.sendMessage({type:"GET_PAGE_CONTEXT"}).then(e=>{e?.success&&e.data&&x(e.data)}).catch(console.error)},[b,v]),t.useEffect(()=>{document.documentElement.classList.toggle("dark","dark"===N)},[N]);return r.jsxs("div",{className:"flex flex-col h-full bg-bg-primary",children:[r.jsx(c,{compact:!0}),r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[e&&r.jsxs("div",{className:"card",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs text-text-tertiary uppercase tracking-wide font-medium",children:"Current Page"}),r.jsxs("div",{className:"trust-badge "+(k(e.domain)?"trusted":"untrusted"),children:[r.jsx(n,{size:12}),k(e.domain)?"Trusted":"Restricted"]})]}),r.jsx("p",{className:"text-sm font-medium truncate",title:e.title,children:e.title||"Untitled"}),r.jsx("p",{className:"text-xs text-text-tertiary truncate",title:e.url,children:e.domain}),!k(e.domain)&&r.jsx("button",{onClick:async()=>{e&&await w(e.domain)},className:"btn btn-secondary w-full mt-3 text-sm",children:"Trust this site"})]}),r.jsxs("div",{className:"space-y-2",children:[p&&r.jsxs("button",{onClick:async()=>{try{const[e]=await chrome.tabs.query({active:!0,currentWindow:!0});e?.id&&(await chrome.runtime.sendMessage({type:"OPEN_SIDE_PANEL",payload:{tabId:e.id}}),window.close())}catch(e){console.error("Failed to open side panel:",e)}},className:"btn btn-primary w-full flex items-center justify-center gap-2",children:[r.jsx(u,{size:18}),"Open Side Panel"]}),r.jsxs("button",{onClick:()=>{chrome.tabs.create({url:"https://kimchi.chat"}),window.close()},className:"btn btn-secondary w-full flex items-center justify-center gap-2",children:[r.jsx(h,{size:18}),"Open Kimchi.chat"]})]}),r.jsx("div",{className:"card",children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium",children:y()?"Signed in":"Not signed in"}),f?.email&&r.jsx("p",{className:"text-xs text-text-tertiary",children:f.email})]}),y()?r.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-primary flex items-center justify-center text-white text-sm font-medium",children:(f?.email?.[0]||"U").toUpperCase()}):r.jsx("button",{onClick:()=>g(!0),className:"btn btn-primary text-sm",children:"Sign in"})]})}),y()&&f&&r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs("div",{className:"card text-center py-3",children:[r.jsx(l,{size:20,className:"mx-auto text-brand-primary mb-1"}),r.jsx("p",{className:"text-xs text-text-tertiary",children:"Tier"}),r.jsx("p",{className:"text-sm font-medium capitalize",children:f.subscription||"Free"})]}),r.jsxs("div",{className:"card text-center py-3",children:[r.jsx(d,{size:20,className:"mx-auto text-brand-primary mb-1"}),r.jsx("p",{className:"text-xs text-text-tertiary",children:"Today's Usage"}),r.jsx("p",{className:"text-sm font-medium",children:f.dailyUsage||0})]})]})]}),r.jsx("div",{className:"p-4 border-t border-[var(--border-color)]",children:r.jsxs("p",{className:"text-xs text-text-tertiary text-center",children:["Kimchi v1.0.0 •"," ",r.jsx("a",{href:"https://kimchi.chat/help",target:"_blank",rel:"noopener noreferrer",className:"text-brand-primary hover:underline",children:"Help"})]})}),r.jsx(m,{}),r.jsx(o,{})]})}document.body.classList.add("popup-mode");(async()=>{try{const e=(await chrome.storage.local.get("kimchi_ui_settings")).kimchi_ui_settings,t=e?.theme||"system";if("system"===t){const e=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",e)}else document.documentElement.classList.toggle("dark","dark"===t)}catch(e){console.error("Failed to initialize theme:",e)}})();const j=document.getElementById("root");j&&x.createRoot(j).render(r.jsx(t.StrictMode,{children:r.jsx(p,{})}));
