1import{r as i,s as b,j as t,cf as y}from"./index-DsK5E-oE.js";function C(){const[p,f]=i.useState(!1),[g,w]=i.useState(!1),[a,o]=i.useState("idle"),[k,l]=i.useState(""),n=(()=>{const r=window.location.hash.replace(/^#/,"");return new URLSearchParams(r).get("extId")||""})(),d=(()=>{const r=window.location.hash.replace(/^#/,"");return new URLSearchParams(r).get("auto")==="1"})();return i.useEffect(()=>{n&&a==="idle"&&(async()=>{var x,h,u;o("sending");const{data:r}=await b.auth.getSession(),s=r.session;f(!0),w(!!s);const e=(x=window.chrome)==null?void 0:x.runtime;if(!s){if(d){try{(h=e==null?void 0:e.sendMessage)==null||h.call(e,n,{type:"linkers/close-connect-tab"},()=>{})}catch{}setTimeout(()=>{try{window.close()}catch{}},250)}o("error"),l("No active session.");return}if(!(e!=null&&e.sendMessage)){o("error"),l("Chrome extension API not available. Open this page from the extension popup in Chrome.");return}try{try{localStorage.setItem("linkers:ext_id",n)}catch{}e.sendMessage(n,{type:"linkers/connect",explicit:!d,access_token:s.access_token,refresh_token:s.refresh_token,expires_at:s.expires_at,user_email:((u=s.user)==null?void 0:u.email)??""},c=>{var m;if(c!=null&&c.ok){o("ok");try{(m=e.sendMessage)==null||m.call(e,n,{type:"linkers/close-connect-tab"},()=>{})}catch{}setTimeout(()=>{try{window.close()}catch{}},400)}else o("error"),l("The extension didn't respond. Make sure it's installed.")})}catch(c){o("error"),l(c.message)}})()},[n,d,a]),p&&!g&&!d?t.jsx(y,{to:`/auth?redirect=${encodeURIComponent("/extension-connect"+window.location.hash)}`,replace:!0}):n?t.jsxs("div",{className:"mx-auto max-w-md p-8 text-center",children:[t.jsx("h1",{className:"text-base font-semibold",children:"Connecting extensionâ¦"}),a==="sending"&&t.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Sending your session to the extensionâ¦"}),a==="ok"&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-3 text-sm",style:{color:"#22C55E",fontWeight:600},children:"â Connected! You can close this tab and start using the extension."}),t.jsx("button",{type:"button",onClick:()=>window.close(),className:"mt-4 h-8 rounded-[6px] bg-primary px-4 text-sm font-semibold text-foreground",children:"Close tab"})]}),a==="error"&&t.jsx("p",{className:"mt-3 text-sm",style:{color:"#dc2626",fontWeight:600},children:k})]}):t.jsxs("div",{className:"mx-auto max-w-md p-8 text-center",children:[t.jsx("h1",{className:"text-base font-semibold",children:"Linkers extension"}),t.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:`This page is for connecting the Chrome extension. Open it from the extension's popup ("Connect to Linkers" button).`})]})}export{C as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.