1import{b as C,a as y,d as I,E as P,G as E,r as d,j as e,C as S,g as D,h as A,k as T,l as L,am as M,c as x,aB as z,H as h,ak as F,L as O,n as B}from"./main-DX7XzkoU.js";import{D as R,a as U,b as G,c as f,e as H}from"./dropdown-menu-D6liHcXh.js";import{u as V}from"./useInstagramProfiles-D_KQvT_K.js";import{I as q}from"./instagramPublishingService-BVQSHM0o.js";import{f as J}from"./instagram-connection-error-C5t4-2DQ.js";import{I as l}from"./instagram-uOX4SJX4.js";import{P as K}from"./plus-C6FQ2-b-.js";import{E as j}from"./external-link-Bhm5X9sQ.js";import{A as Q}from"./arrow-left-Cf41rOjY.js";import{S as W}from"./shield-B57RWQ5_.js";import"./index-D6Z5KIMn.js";import"./chevron-right-D27HfhtL.js";import"./circle-BXmX70XD.js";const le=()=>{const{t:a}=C(),n=y(),[g]=I(),{toast:N}=P(),{selectedProfile:i}=E(),{profiles:t,loading:m}=V(),[r,c]=d.useState(null),[u,p]=d.useState(!1);d.useEffect(()=>{if(m)return;if(t.length===0){n("/add-instagram",{replace:!0});return}const s=g.get("profileId");if(s){const o=t.find(k=>k.id===s);if(o){c(o);return}}if(i&&t.some(o=>o.id===i.id)){c(i);return}c(t[0])},[t,m,i,g,n]);const w=s=>{c(s)},_=async()=>{if(r){p(!0);try{const s=await q.startOAuth(r.id);if(s.success&&s.authorizationUrl){window.location.href=s.authorizationUrl;return}else throw new Error(s.error||"Erro ao iniciar conexão")}catch(s){console.error("Error starting OAuth:",s),N({title:a("common.error","Erro"),description:s instanceof Error?s.message:a("publishing.connect.error","Erro ao conectar Instagram"),variant:"destructive"}),p(!1)}}},b=()=>{n(-1)},v=()=>{n("/add-instagram")};return m||!r?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 mx-auto flex items-center justify-center animate-pulse",children:e.jsx(l,{className:"w-8 h-8 text-white"})}),e.jsx("p",{className:"text-muted-foreground",children:a("common.loading","Carregando...")})]})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs(S,{className:"w-full max-w-md",children:[e.jsxs(D,{className:"text-center",children:[e.jsx("div",{className:"flex items-center justify-center w-16 h-16 rounded-2xl bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 mx-auto mb-4 shadow-lg shadow-pink-500/20",children:e.jsx(l,{className:"w-8 h-8 text-white"})}),e.jsx(A,{className:"text-xl",children:a("connect_instagram_page.title","Conectar Instagram")}),e.jsx(T,{children:a("connect_instagram_page.description","Confirme qual perfil você deseja conectar para publicação")})]}),e.jsxs(L,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl border border-amber-400 bg-amber-50 dark:border-amber-500 dark:bg-amber-950/50",children:[e.jsx("div",{className:"p-2 rounded-full bg-amber-100 dark:bg-amber-900/50 shrink-0 mt-0.5",children:e.jsx(M,{className:"w-5 h-5 text-amber-700 dark:text-amber-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold text-amber-700 dark:text-amber-400 uppercase tracking-wide",children:a("connect_instagram_page.important")}),e.jsxs("p",{className:"text-sm text-foreground leading-tight mt-0.5",children:[a("connect_instagram_page.login_warning_v2")," ",e.jsxs("strong",{children:["@",r.username]}),"."," ",a("connect_instagram_page.must_match")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-muted-foreground",children:a("connect_instagram_page.profile_to_connect","Perfil a conectar")}),e.jsxs(R,{children:[e.jsx(U,{asChild:!0,children:e.jsxs(x,{variant:"outline",className:"w-full justify-between h-auto py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r.profile_pic_url?e.jsx("img",{src:r.profile_pic_url,alt:r.username,className:"w-10 h-10 rounded-full object-cover"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 flex items-center justify-center",children:e.jsx(l,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("p",{className:"font-medium",children:["@",r.username]}),r.full_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r.full_name})]})]}),e.jsx(z,{className:"w-4 h-4 text-muted-foreground"})]})}),e.jsxs(G,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",children:[t.map(s=>e.jsx(f,{onClick:()=>w(s),className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-3 w-full",children:[s.profile_pic_url?e.jsx("img",{src:s.profile_pic_url,alt:s.username,className:"w-8 h-8 rounded-full object-cover"}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 flex items-center justify-center",children:e.jsx(l,{className:"w-4 h-4 text-white"})}),e.jsx("div",{className:"flex-1",children:e.jsxs("p",{className:"font-medium text-sm",children:["@",s.username]})}),s.id===r.id&&e.jsx(h,{className:"w-4 h-4 text-primary"})]})},s.id)),e.jsx(H,{}),e.jsxs(f,{onClick:v,className:"py-2",children:[e.jsx(K,{className:"w-4 h-4 mr-2"}),a("connect_instagram_page.add_new_profile","Adicionar novo perfil")]})]})]})]}),e.jsx("div",{className:"bg-muted/50 rounded-lg p-4 space-y-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-purple-500 via-pink-500 to-orange-400 flex items-center justify-center flex-shrink-0",children:e.jsx(j,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:a("connect_instagram_page.redirect_title","Você será redirecionado para o Instagram")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a("connect_instagram_page.redirect_desc","O login é feito diretamente no site oficial do Instagram (instagram.com). Nós nunca vemos ou armazenamos sua senha.")})]})]})}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(x,{onClick:_,disabled:u,size:"lg",className:"w-full gap-2 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700",children:u?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),a("connect_instagram_page.redirecting","Redirecionando para Instagram...")]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{className:"w-4 h-4"}),a("connect_instagram_page.go_to_instagram","Ir para Instagram")]})}),e.jsxs(x,{variant:"ghost",onClick:b,className:"w-full gap-2",children:[e.jsx(Q,{className:"w-4 h-4"}),a("common.back","Voltar")]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:e.jsx(O,{to:J(r.
1id),className:"font-medium text-primary underline-offset-4 hover:underline",children:a("instagram_connection_help.entry_link")})})]}),e.jsxs("div",{className:"flex flex-col items-center gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-green-600 dark:text-green-400"}),e.jsx("span",{className:"text-sm font-medium text-green-700 dark:text-green-300",children:a("publishing.security_badge","Conexão segura aprovada pelo Meta")})]}),e.jsxs("div",{className:"flex flex-col items-center gap-1 text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3"}),e.jsx("span",{children:a("connect_instagram_page.password_info","Sua senha é digitada apenas no site do Instagram")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{className:"w-3 h-3"}),e.jsx("span",{children:a("connect_instagram_page.no_access","O InstaGem.ai nunca tem acesso à sua senha")})]})]})]})]})]})})};export{le 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.