1import{j as e,a9 as f,ab as r,a7 as a,T as t,N as m,ao as z,ae as F,aD as Y,z as Z,X as ge,ai as pe,Z as fe,O as me}from"./mui-CRsYZxVY.js";import{r as b}from"./vendor-Dwao9eNC.js";import{m as M,aK as P,cg as C,T as ee,bJ as be,bN as ae,aM as je,eb as ye,cR as ve,dd as Ce,df as Ae}from"./index-TALscxEc.js";import{d as we}from"./ErrorOutline-DrJfys9F.js";import{M as Pe,d as Se}from"./MenuButton-CKMh6N5q.js";import{d as te}from"./OpenInNew-C51BFPIz.js";import{d as ke}from"./Pix-B95Oe5Gl.js";import{u as Re}from"./useAsaasDirectStatus-Dsf5IQ01.js";import{a as S,b as k}from"./query-8ViTdhdk.js";import{u as Ie}from"./usePaymentConfig-wna7msVS.js";import{u as We}from"./useMercadoPagoAccount-B4jrpfm_.js";import{u as _e}from"./useUpdateProviderPreference-CqMwIXec.js";import{r as qe,a as De}from"./resolveEffectiveProviders-CiAyVzdl.js";import{L as A}from"./lab-DSem1Osk.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new n.Error().stack;i&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[i]="6b1310f8-316c-4e60-9fb2-8514ccb050e5",n._sentryDebugIdIdentifier="sentry-dbid-6b1310f8-316c-4e60-9fb2-8514ccb050e5")})()}catch{}const Te=()=>{const n=S(),{triggerRevalidation:i}=M();return k({mutationFn:async({apiKey:c})=>(await P.post("/asaas-direct/connect",{apiKey:c})).data,onSuccess:()=>{n.invalidateQueries({queryKey:["asaas-direct-status"]}),i()}})},Ee=()=>{const n=S(),{triggerRevalidation:i}=M();return k({mutationFn:async()=>(await P.post("/asaas-direct/flapp/connect")).data,onSuccess:()=>{n.invalidateQueries({queryKey:["asaas-direct-status"]}),i()}})},ze=()=>{const n=S(),{triggerRevalidation:i}=M();return k({mutationFn:async()=>(await P.post("/asaas-direct/disconnect")).data,onSuccess:()=>{n.invalidateQueries({queryKey:["asaas-direct-status"]}),i()}})},Fe=()=>{const n=S();return k({mutationFn:async i=>(await P.post("/asaas-direct/toggle",{habilitado:i})).data,onSuccess:()=>{n.invalidateQueries({queryKey:["asaas-direct-status"]})}})},l="#1a4fba",u="#0d3a8a",Me="https://flappstore.asaas.com/";function aa(){var X;const[n,i]=b.useState(""),[c,d]=b.useState(null),[ne,w]=b.useState(!1),[g,O]=b.useState(null),[$,R]=b.useState(!1),{data:o,isLoading:oe}=Re(),{data:p}=Ie(),{data:I}=We(),W=Te(),_=Ee(),K=ze(),B=Fe(),j=_e(),L=(o==null?void 0:o.connected)&&o.status==="ativo",se=(o==null?void 0:o.connected)&&o.status==="invalido",x=L&&((o==null?void 0:o.habilitado)??!0),y=(o==null?void 0:o.authMode)==="flapp_partner",N=(o==null?void 0:o.flappPartnerAvailable)===!0;b.useEffect(()=>{d(null)},[o==null?void 0:o.status]);const q=(I==null?void 0:I.status)==="ativo",H=((X=p==null?void 0:p.creditCard)==null?void 0:X.enabled)??!0,Q=p==null?void 0:p.providerPreferences,V={asaasEnabled:x,mpConnected:q},re=qe(Q,V),ie=De(Q,V),D=re==="asaas",T=H&&ie==="asaas",ce=async()=>{const s=D?q?"mercadopago":null:"asaas";await j.mutateAsync({provedor_pix:s})},de=async()=>{if(T){const s=q?"mercadopago":null;await j.mutateAsync({provedor_cartao_credito:s})}else await j.mutateAsync({provedor_cartao_credito:"asaas",...!H&&{cartao_credito_habilitado:!0}})},G=async()=>{var s,h;if(!n.trim()){d("Cole sua API key do Asaas");return}d(null);try{await W.mutateAsync({apiKey:n.trim()}),i("")}catch(v){const E=((h=(s=v.response)==null?void 0:s.data)==null?void 0:h.error)||"Erro ao conectar. Tente novamente.";d(E)}},U=async()=>{var s,h;d(null),O(null);try{await _.mutateAsync()}catch(v){const E=(h=(s=v.response)==null?void 0:s.data)==null?void 0:h.reason;O(E==="permission_required"?"permission_required":"connection_failed")}},le=async()=>{var s,h;try{d(null),await B.mutateAsync(!x)}catch(v){d(((h=(s=v.response)==null?void 0:s.data)==null?void 0:h.error)||"Erro ao atualizar status.")}},he=async()=>{try{await K.mutateAsync(),w(!1)}catch(s){console.error("Error disconnecting:",s),d("Erro ao desconectar conta")}},xe=e.jsx(f,{sx:{p:2.5},children:e.jsxs(r,{spacing:2.5,alignItems:"center",children:[e.jsx(a,{component:"img",src:C,alt:"Asaas",sx:{height:40}}),e.jsx(t,{variant:"h6",fontWeight:700,textAlign:"center",children:"Conecte com um clique"}),e.jsx(t,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Aceite Pix e cartão de crédito no checkout da sua loja. à só ativar, sem precisar configurar nada."}),e.jsx(A,{variant:"contained",onClick:U,fullWidth:!0,loading:_.isPending,sx:{textTransform:"none",py:1.5,fontWeight:700,fontSize:"1rem",bgcolor:l,"&:hover":{bgcolor:u}},children:"Ativar pagamentos Asaas"}),c&&e.jsx(a,{sx:{p:2,borderRadius:2,bgcolor:"#fee",width:"100%"},children:e.jsx(t,{variant:"body2",color:"error",fontWeight:500,children:c})})]})}),ue=e.jsx(f,{sx:{p:2.5},children:e.jsxs(r,{spacing:2.5,children:[e.jsxs(r,{spacing:1,alignItems:"center",children:[e.jsx(a,{component:"img",src:C,alt:"Asaas",sx:{height:40}}),e.jsx(t,{variant:"h6",fontWeight:700,textAlign:"center",children:g==="permission_required"?"Falta só um passo na Flapp Store":"Não foi possÃvel ativar"})]}),g==="permission_required"?e.jsxs(a,{sx:{p:2,borderRadius:2,bgcolor:"grey.50",border:"1px solid",borderColor:"divider"},children:[e.jsx(t,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"Para ativar os pagamentos automaticamente, autorize o acesso da integração na Flapp Store:"}),e.jsxs(a,{component:"ol",sx:{pl:2.5,m:0,color:"text.secondary","& li":{mb:.75,typography:"body2"}},children:[e.jsx("li",{children:"Toque em âAbrir Flapp Storeâ e vá em âMeus Flappsâ"}),e.jsx("li",{children:"Encontre o Stoqui e toque em âGerenciar assinaturaâ"}),e.jsx("li",{children:"Em âPermita a integração e automatize sua gestãoâ, toque em âPermitir acessoâ"}),e.jsx("li",{children:"Retorne a esta tela e toque em âTentar novamenteâ"})]})]}):e.jsx(t,{variant:"body2",color:"text.secondary",textAlign:"center",children:"Não foi possÃvel ativar os pagamentos no momento. Tente novamente em instantes ou conecte a sua conta Asaas de outra forma."}),g==="permission_required"&&e.jsx(m,{variant:"contained",onClick:()=>window.open(`${Me}installed-flapp`,"_blank"),fullWidth:!0,endIcon:e.jsx(te,{}),sx:{textTransform:"none",py:1.5,fontWeight:700,bgcolor:l,"&:hover":{bgcolor:u}},children:"Abrir Flapp Store"}),e.jsx(A,{variant:g==="permission_required"?"text":"contained",onClick:U,fullWidth:!0,loading:_.isPending,sx:{textTransform:"none",py:1.5,fontWeight:700,...g!=="permission_required"&&{bgcolor:l,"&:hover":{bgcolor:u}}},children:"Tentar novamente"}),e.jsx(m,{variant:"text",onClick:()=>R(!0),sx:{textTransform:"none",fontWeight:600,color:"text.secondary"},children:"Prefiro conectar de outra forma"})]})}),J=g?ue:xe;return oe?e.jsxs(a,{sx:{display:"flex",flexDirection:"column"}
1,children:[e.jsx(ee,{title:"Asaas",navigateBack:!0}),e.jsx(a,{sx:{flex:1,p:2},children:e.jsxs(r,{spacing:2,children:[e.jsx(z,{variant:"rectangular",height:200,sx:{borderRadius:2}}),e.jsx(z,{variant:"rectangular",height:80,sx:{borderRadius:2}}),e.jsx(z,{variant:"rectangular",height:80,sx:{borderRadius:2}})]})})]}):e.jsxs(a,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(ee,{title:"Asaas",navigateBack:!0,children:o!=null&&o.connected&&!y?e.jsx(Pe,{options:[{label:"Desconectar",icon:e.jsx(Se,{fontSize:"small",color:"error"}),onClick:()=>w(!0)}]}):null}),e.jsx(a,{sx:{flex:1,pb:8},children:L?e.jsxs(a,{sx:{p:2},children:[e.jsxs(a,{sx:{background:`linear-gradient(135deg, ${l} 0%, ${u} 100%)`,borderRadius:3,p:3,mb:3,color:"white"},children:[e.jsx(a,{component:"img",src:C,alt:"Asaas",sx:{height:24,mb:2,filter:"brightness(0) invert(1)"}}),e.jsxs(r,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(a,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(be,{sx:{fontSize:28}})}),e.jsxs(a,{sx:{flex:1},children:[e.jsx(t,{variant:"h6",fontWeight:700,children:"Conta conectada!"}),e.jsx(t,{variant:"body2",sx:{opacity:.9},children:x?"Pagamentos via Asaas habilitados na sua loja":"Pagamentos via Asaas desabilitados"})]}),e.jsx(F,{checked:x,onChange:le,disabled:B.isPending,sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"white"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{bgcolor:"rgba(255,255,255,0.3)"},"& .MuiSwitch-track":{bgcolor:"rgba(255,255,255,0.2)"}}})]}),e.jsx(m,{variant:"contained",fullWidth:!0,href:"https://www.asaas.com/dashboard/home",target:"_blank",endIcon:e.jsx(te,{}),sx:{mt:2.5,textTransform:"none",py:1,fontWeight:600,bgcolor:"rgba(255,255,255,0.2)",color:"white",boxShadow:"none",borderRadius:2,"&:hover":{bgcolor:"rgba(255,255,255,0.3)",boxShadow:"none"}},children:"Acessar painel do Asaas"})]}),x&&e.jsx(f,{sx:{mb:3},children:e.jsxs(a,{sx:{p:2},children:[e.jsx(t,{variant:"body1",fontWeight:600,sx:{mb:2},children:"Padrão no checkout"}),e.jsxs(r,{spacing:1.5,children:[e.jsxs(r,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(r,{direction:"row",alignItems:"center",spacing:1.5,children:[e.jsx(ke,{sx:{fontSize:22}}),e.jsx(t,{variant:"body1",children:"Pix"})]}),e.jsx(F,{checked:D,onChange:ce,disabled:j.isPending||!D&&!x})]}),e.jsxs(r,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[e.jsxs(r,{direction:"row",alignItems:"center",spacing:1.5,children:[e.jsx(ae,{style:{fontSize:22}}),e.jsx(t,{variant:"body1",children:"Cartão de crédito"})]}),e.jsx(F,{checked:T,onChange:de,disabled:j.isPending||!T&&!x})]})]})]})}),c&&e.jsx(a,{sx:{p:2,mb:3,borderRadius:2,bgcolor:"#fee"},children:e.jsx(t,{variant:"body2",color:"error",fontWeight:500,children:c})}),e.jsx(f,{component:je,to:"/profile/checkout-settings",sx:{textDecoration:"none",color:"inherit",display:"block"},children:e.jsx(a,{sx:{p:2},children:e.jsxs(r,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(a,{sx:{p:1.5,borderRadius:2,bgcolor:"grey.100",display:"flex"},children:e.jsx(ye,{})}),e.jsxs(a,{sx:{flex:1},children:[e.jsx(t,{variant:"body1",fontWeight:600,children:"Configurações do checkout"}),e.jsx(t,{variant:"body2",color:"text.secondary",children:"Parcelamento, desconto Pix e mais"})]}),e.jsx(ve,{sx:{color:"action.active"}})]})})})]}):se?e.jsxs(a,{sx:{p:2},children:[e.jsxs(a,{sx:{background:"linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%)",borderRadius:3,p:3,mb:3,color:"white"},children:[e.jsx(a,{component:"img",src:C,alt:"Asaas",sx:{height:28,mb:2,filter:"brightness(0) invert(1)"}}),e.jsxs(r,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(a,{sx:{width:48,height:48,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(we,{sx:{fontSize:28}})}),e.jsxs(a,{sx:{flex:1},children:[e.jsx(t,{variant:"h6",fontWeight:700,children:y?"Conexão expirada":"API key inválida"}),e.jsx(t,{variant:"body2",sx:{opacity:.9},children:y?"Sua conexão com o Asaas expirou. Reative os pagamentos.":"Sua API key não é mais válida. Reconecte com uma nova key."})]})]})]}),y&&!$?J:e.jsx(f,{sx:{p:2.5},children:e.jsxs(r,{spacing:3,children:[e.jsx(t,{variant:"h6",fontWeight:700,textAlign:"center",children:"Reconectar conta Asaas"}),e.jsx(a,{sx:{p:2,borderRadius:2,bgcolor:"grey.50",border:"1px solid",borderColor:"divider"},children:e.jsxs(t,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line"},children:["1. Acesse ou crie ",e.jsx(Y,{href:"https://www.asaas.com/config/index",target:"_blank",rel:"noopener",sx:{color:l,fontWeight:600},children:"sua conta Asaas"}),` 22. Vá em Minha Conta â Integrações â Chaves de API 3`,`3. Clique em Gerar chave de API 4`,`4. Em nome, coloque "Stoqui" 5`,"5. ",e.jsx("b",{children:"NÃO marque"}),' o checkbox de "Permitir que esta chave execute operações de saque via API" e ',e.jsx("b",{children:"NÃO preencha"}),` os campos de "Data de expiração" e "Hora de expiração". 6`,"6. Copie a chave gerada e cole aqui"]})}),e.jsx(Z,{label:"API Key do Asaas",placeholder:"$aact_...",value:n,onChange:s=>i(s.target.value),fullWidth:!0,type:"password",autoComplete:"off"}),e.jsx(A,{variant:"contained",onClick:G,fullWidth:!0,loading:W.isPending,disabled:!n.trim(),sx:{textTransform:"none",py:1.5,fontWeight:700,fontSize:"1rem",bgcolor:l,"&:hover":{bgcolor:u}},children:"Reconectar conta"}),c&&e.jsx(a,{sx:{p:2,borderRadius:2,bgcolor:"#fee",width:"100%"},children:e.jsx(t,{variant:"body2",color:"error",fontWeight:500,children:c})}),y&&e.jsx(m,{variant:"text",onClick:()=>R(!1),sx:{textTransform:"none",fontWeight:600,color:"text.secondary"},children:"Conectar automaticamente"})]})})]}):e.jsxs(a,{sx:{p:2},children:[e.jsxs(a,{sx:{background:`linear-gradient(135deg, ${l} 0%, ${u} 100%)`,borderRadius:3,p:4,mb:3,color:"white",position:"relative",overflow:"hidden"},children:[e.jsxs(a,{sx:{position:"relative",zIndex:1},children:[e.jsx(a,{component:"img",src:C,alt:"Asaas",sx:{height:36,mb:2,filter:"brightness(0) invert(1)"}}),e.jsxs(t,{variant:"h5",fontWeight:700,gutterBottom:!0,children:["Receba pagamentos",e.
6jsx("br",{}),"com sua conta Asaas"]}),e.jsx(t,{variant:"body2",sx:{opacity:.95,mb:3,maxWidth:400},children:"Conecte sua conta e aceite Pix e cartão de crédito diretamente no checkout da sua loja"}),e.jsxs(r,{spacing:1.5,children:[e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(a,{sx:{width:24,height:24,minWidth:24,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ce,{style:{fontSize:14}})}),e.jsx(t,{variant:"body2",fontWeight:600,children:"Pix com QR Code no checkout"})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(a,{sx:{width:24,height:24,minWidth:24,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(ae,{style:{fontSize:14}})}),e.jsx(t,{variant:"body2",fontWeight:600,children:"Cartão de crédito com parcelamento"})]}),e.jsxs(r,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(a,{sx:{width:24,height:24,minWidth:24,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(Ae,{style:{fontSize:14}})}),e.jsx(t,{variant:"body2",fontWeight:600,children:"Pedidos atualizados automaticamente"})]})]})]}),e.jsx(a,{sx:{position:"absolute",top:-50,right:-50,width:200,height:200,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.1)"}}),e.jsx(a,{sx:{position:"absolute",bottom:-30,right:50,width:100,height:100,borderRadius:"50%",bgcolor:"rgba(255,255,255,0.08)"}})]}),N&&!$?J:e.jsx(f,{sx:{p:2.5},children:e.jsxs(r,{spacing:3,children:[e.jsx(t,{variant:"h6",fontWeight:700,textAlign:"center",children:"Conecte sua conta do Asaas"}),e.jsx(a,{sx:{p:2,borderRadius:2,bgcolor:"grey.50",border:"1px solid",borderColor:"divider"},children:e.jsxs(t,{variant:"body2",color:"text.secondary",sx:{whiteSpace:"pre-line"},children:["1. Acesse ou crie ",e.jsx(Y,{href:"https://www.asaas.com/config/index",target:"_blank",rel:"noopener",sx:{color:l,fontWeight:600},children:"sua conta Asaas"}),` 72. Vá em Minha Conta â Integrações â Chaves de API 8`,`3. Clique em Gerar chave de API 9`,`4. Em nome, coloque "Stoqui" 10`,"5. ",e.jsx("b",{children:"NÃO marque"}),' o checkbox de "Permitir que esta chave execute operações de saque via API" e ',e.jsx("b",{children:"NÃO preencha"}),` os campos de "Data de expiração" e "Hora de expiração". 11`,"6. Copie a chave gerada e cole aqui"]})}),e.jsx(Z,{label:"API Key do Asaas",placeholder:"$aact_...",value:n,onChange:s=>i(s.target.value),fullWidth:!0,type:"password",autoComplete:"off"}),e.jsx(A,{variant:"contained",onClick:G,fullWidth:!0,loading:W.isPending,disabled:!n.trim(),sx:{textTransform:"none",py:1.5,fontWeight:700,fontSize:"1rem",bgcolor:l,"&:hover":{bgcolor:u}},children:"Conectar conta"}),c&&e.jsx(a,{sx:{p:2,borderRadius:2,bgcolor:"#fee",width:"100%"},children:e.jsx(t,{variant:"body2",color:"error",fontWeight:500,children:c})}),N&&e.jsx(m,{variant:"text",onClick:()=>R(!1),sx:{textTransform:"none",fontWeight:600,color:"text.secondary"},children:"Conectar automaticamente"})]})})]})}),e.jsxs(ge,{open:ne,onClose:()=>w(!1),children:[e.jsx(pe,{children:"Desconectar Asaas"}),e.jsx(fe,{children:e.jsx(t,{variant:"body2",color:"text.secondary",children:"Tem certeza que deseja desconectar sua conta do Asaas? Seus clientes não poderão mais realizar pagamentos via Pix e cartão no checkout."})}),e.jsxs(me,{children:[e.jsx(m,{onClick:()=>w(!1),children:"Cancelar"}),e.jsx(A,{onClick:he,variant:"contained",color:"error",loading:K.isPending,children:"Desconectar"})]})]})]})}export{aa 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.