1import{b as l,j as t}from"./radix-MTJA6BZT.js";import{a6 as g,a8 as f,a9 as w,bt as b,e as j,bn as z,aX as y}from"./index-DjrR37Uk.js";import"./pdf-c7cqdgUt.js";import"./monaco-editor-CE8uQPSR.js";import"./dockview-Bat6QVRX.js";const v=async s=>(await f.post(w.auth.extensionAuthorize(),s)).data,C=()=>g({mutationFn:v}),I=()=>{const[s]=b(),o=j(),[d,n]=l.useState(null),[u,r]=l.useState(!1),{mutate:h,isPending:x}=C(),i=s.get("code_challenge"),m=s.get("code_challenge_method")||"S256",a=s.get("state");return l.useEffect(()=>{if(!localStorage.getItem("citable-token")){const e=window.location.pathname+window.location.search;o(`${z.authRoutes.login.path}?returnUrl=${encodeURIComponent(e)}`);return}if(!i||!a){n("Invalid authorization request. Missing required parameters.");return}u||x||(r(!0),h({code_challenge:i,code_challenge_method:m,state:a},{onSuccess:e=>{if(e.success&&e.data?.code){const c=encodeURIComponent(e.data.code),p=encodeURIComponent(a);window.location.replace(`/app/auth/extension-callback?code=${c}&state=${p}`)}else n(e.message||"Failed to authorize extension"),r(!1)},onError:e=>{const c=e?.response?.data?.message||e?.response?.data?.error?.message||e?.message||"Failed to authorize extension";n(c),r(!1)}}))},[i,a,o,h,u,x,m]),d?t.jsxs("div",{className:"w-[30%] space-y-6 text-center",children:[t.jsx("div",{className:"font-bold text-3xl text-red-500",children:"Authorization Failed"}),t.jsx("p",{className:"text-text-secondary",children:d}),t.jsx("button",{onClick:()=>window.close(),className:"px-6 py-2 bg-primary text-text-primary rounded-md hover:bg-primary/90 transition-colors",children:"Close Window"})]}):t.jsxs("div",{className:"w-[30%] space-y-6 text-center",children:[t.jsx("div",{className:"font-bold text-3xl text-primary",children:"Authorizing Extension"}),t.jsx("div",{className:"flex justify-center",children:t.jsx(y,{size:"lg"})}),t.jsx("p",{className:"text-text-secondary",children:"Please wait while we authorize the Citable browser extension..."})]})};export{I 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.