function e(){const[e,j]=x.useState(""),[p,C]=x.useState(""),[v,y]=x.useState(!1),[w,S]=x.useState(!1),[k,_]=x.useState(null);x.useEffect(()=>{u.get("/wp-json/fleekdash/v1/settings/gmail").then(e=>{j(e.fleekdash_gmail_client_id||""),C(e.fleekdash_gmail_client_secret||"")}).catch(e=>{_(e instanceof Error?e.message:m("Failed to load settings"))})},[]);const G=async s=>{s.preventDefault(),y(!0),_(null),S(!1);try{await u.post("/wp-json/fleekdash/v1/settings/gmail",{fleekdash_gmail_client_id:e,fleekdash_gmail_client_secret:p}),S(!0)}catch(l){_(l instanceof Error?l.message:m("An unexpected error occurred"))}finally{y(!1)}},I=f()?.location.origin??"";return g.jsxs("div",{className:"flex flex-col gap-6",children:[g.jsxs(s,{children:[g.jsxs(l,{children:[g.jsx(t,{children:m("Gmail API Settings")}),g.jsx(a,{children:m("Configure your Google Cloud Console credentials for Gmail integration.")})]}),g.jsxs(n,{className:"flex flex-col gap-6",children:[k&&g.jsx(i,{variant:"error",icon:g.jsx(o,{name:"danger",className:"h-4 w-4"}),children:k}),w&&g.jsx(i,{variant:"success",icon:g.jsx(o,{name:"check",className:"h-4 w-4"}),children:m("Settings saved successfully!")}),g.jsxs("form",{onSubmit:G,className:"flex flex-col gap-4",children:[g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx(r,{htmlFor:"clientId",children:m("Client ID")}),g.jsx(c,{id:"clientId",value:e,onChange:e=>j(e.target.value),placeholder:m("Your Google OAuth Client ID")})]}),g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx(r,{htmlFor:"clientSecret",children:m("Client Secret")}),g.jsx(c,{id:"clientSecret",type:"password",value:p,onChange:e=>C(e.target.value),placeholder:m("Your Google OAuth Client Secret"),autoComplete:"new-password"})]})]})]}),g.jsxs(d,{className:"flex gap-4",children:[g.jsx(h,{type:"submit",onClick:G,disabled:v,state:v?"loading":null,loadingText:m("Saving..."),minWidth:160,children:m("Save Settings")}),g.jsx(h,{type:"button",variant:"secondary",onClick:async()=>{try{y(!0),_(null);const e=await u.post("/wp-json/fleekdash/v1/gmail/auth",{});window.location.href=e.authUrl}catch(e){_(e instanceof Error?e.message:m("An unexpected error occurred"))}finally{y(!1)}},disabled:v||!e||!p,state:v?"loading":null,loadingText:m("Connecting..."),minWidth:200,children:m("Connect with Google")})]})]}),g.jsxs(s,{children:[g.jsxs(l,{children:[g.jsx(t,{children:m("Setup Instructions")}),g.jsx(a,{children:m("Follow these steps to get your Google Cloud Console credentials.")})]}),g.jsx(n,{children:g.jsxs("ol",{className:"text-muted-foreground flex list-inside list-decimal flex-col gap-2 text-sm",children:[g.jsxs("li",{children:[m("Go to the")," ",g.jsx("a",{href:"https://console.cloud.google.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:m("Google Cloud Console")})]}),g.jsx("li",{children:m("Create a new project or select an existing one")}),g.jsx("li",{children:m("Enable the Gmail API for your project")}),g.jsx("li",{children:m("Go to the Credentials page")}),g.jsx("li",{children:m("Create an OAuth 2.0 Client ID")}),g.jsx("li",{children:m("Add %s/wp-json/fleekdash/v1/gmail/callback to the authorized redirect URIs",I)})]})})]})]})}import{y as s,z as l,E as t,F as a,G as n,af as i,f as o,L as r,I as c,aM as d,B as h}from"./vendor-design-system.Cz5A3ECO.js";import{r as x,j as g}from"./vendor-react.DHNfi5sm.js";import{f as u,i as m,g as f}from"./platform-core.tlhrBXt0.js";export{e as GmailSettings};
//# sourceMappingURL=gmail-settings.DCN5wx4Y.js.map
