PageSourceSearch

https://www.ecomdroptv.com/assets/ShopifyEmbeddedApp-w0e9RRUX.js

js ecomdroptv.com collected 2026-10-02 01:29:26 UTC 6,689 bytes, 1 lines download raw bytes

1import{u as P,h as V,j as e,v as H,V as O,q as b,w as T}from"./index-D_T1XJ3U.js";import{u as _,r as o}from"./vendor-react-Bxgxa9T6.js";import{AuthScreen as F}from"./AuthScreen-8P8u8IBN.js";import{LandingPageTab as $}from"./LandingPageTab-Cm6TzLes.js";import"./CieloLumy-Br0FDAhQ.js";import"./NucleoLumy-C4o1wLT-.js";import"./Pricing-DHmyOZ1T.js";import"./periodo-plan-NC4xkV1W.js";import"./PlanesSection-n8rukr3T.js";import"./Banderas-D2N83YVf.js";import"./WhatsAppInboxTab-D4YoHJGX.js";import"./TemplatesPanel-Sec3ZcMK.js";import"./formato-moneda-B-myNs4h.js";import"./tasa-de-entrega-Ddtfuka5.js";import"./useCollapsible-CQvzgLKu.js";import"./semaforo-1n3dRRyu.js";import"./pedidos-por-pauta-BwD_YLFQ.js";import"./coDates-BxYjNlB-.js";import"./pais-ventas-YDkuBTEL.js";import"./vendor-recharts-BYQpxUtL.js";import"./serialized-save-DxU5JriH.js";function R(a){return!!(a&&a.role!=="admin"&&!a.email_verified_at)}function pe(){const a=_(),r=P(),{user:s,token:u,loading:B,refresh:p,logout:M}=V(),[n,h]=o.useState(null),[v,S]=o.useState(""),[w,k]=o.useState(!1),[E,z]=o.useState(""),[f,m]=o.useState(""),[x,C]=o.useState(!1),y=o.useCallback(async()=>{S(""),h(null);try{const i=await r("/api/shopify/embedded/bootstrap",{method:"POST"}),t=await i.json().catch(()=>({}));if(!i.ok)throw new Error((t==null?void 0:t.message)||"No pudimos abrir la sesión de Shopify.");h({linked:!!t.linked,shop:String(t.shop||""),nonce:t.nonce?String(t.nonce):void 0}),t.linked&&await p()}catch(i){S((i==null?void 0:i.message)||"No pudimos abrir la sesión de Shopify.")}},[r,p]);o.useEffect(()=>{y()},[y]),o.useEffect(()=>{if(!n||n.linked||!n.nonce||!s||!u||R(s))return;let i=!0;return k(!0),z(""),r("/api/shopify/oauth/claim",{method:"POST",headers:{"X-Lumy-Authorization":`Bearer ${u}`},body:JSON.stringify({nonce:n.nonce})}).then(async t=>({response:t,body:await t.json().catch(()=>({}))})).then(async({response:t,body:c})=>{if(!t.ok)throw new Error((c==null?void 0:c.message)||"No pudimos asociar esta tienda con tu cuenta.");i&&(h(d=>d&&{...d,linked:!0,nonce:void 0}),await p())}).catch(t=>{i&&z((t==null?void 0:t.message)||"No pudimos asociar esta tienda con tu cuenta.")}).finally(()=>{i&&k(!1)}),()=>{i=!1}},[n,s,u,r,p]);const I=async()=>{C(!0),m("");try{const t=await(await r("/api/shopify/oauth/connections")).json().catch(()=>({})),c=Array.isArray(t==null?void 0:t.connections)?t.connections.find(L=>L.shop_domain===(n==null?void 0:n.shop)&&L.status!=="disconnected"):null;if(!c)throw new Error("No encontramos la conexión activa de esta tienda.");const d=await r(`/api/shopify/oauth/connections/${c.id}/sync`,{method:"POST"}),l=await d.json().catch(()=>({}));if(!d.ok)throw new Error((l==null?void 0:l.message)||"Shopify no pudo sincronizar los pedidos.");m(`Listo: ${Number(l.imported||0)} pedidos nuevos y ${Number(l.updated||0)} actualizados.`)}catch(i){m((i==null?void 0:i.message)||"No se pudo sincronizar. Intenta nuevamente.")}finally{C(!1)}};if(v)return e.jsx("div",{style:j,children:e.jsx(g,{title:"No pudimos abrir Lumy CRM",text:v,children:e.jsx("button",{type:"button",onClick:()=>void y(),style:A,children:"Reintentar"})})});if(!n||w||n.linked&&B)return e.jsx("div",{style:j,children:e.jsx(g,{title:"Abriendo Lumy CRM",text:w?"Estamos asociando esta tienda e importando sus pedidos.":"Validando la sesión segura de Shopify.",children:e.jsx(H,{})})});if(!n.linked&&R(s))return e.jsx(O,{});if(!n.linked&&!s){const i=a.pathname.endsWith("/registro")?"register":"login";return e.jsxs("div",{style:{minHeight:"100vh",background:"#f4f6f8"},children:[e.jsxs("div",{style:{maxWidth:560,margin:"0 auto",padding:"22px 18px 0",textAlign:"center"},children:[e.jsx(b,{size:42}),e.jsx("h1",{style:{color:"#172033",fontSize:23,margin:"10px 0 6px"},children:"Vincula tu tienda con Lumy CRM"}),e.jsxs("p",{style:{color:"#637083",fontSize:13.5,lineHeight:1.5,margin:0},children:["Ingresa o crea una cuenta gratuita para que los pedidos de ",n.shop," se importen automáticamente."]})]}),e.jsx(F,{initialMode:i})]})}return E||!s?e.jsx("div",{style:j,children:e.jsxs(g,{title:"Falta terminar la conexión",text:E||"Actualiza la sesión para continuar.",children:[e.jsx("button",{type:"button",onClick:()=>window.location.reload(),style:A,children:"Reintentar"}),e.jsx("button",{type:"button",onClick:M,style:N,children:"Usar otra cuenta"})]})}):e.jsx(T,{children:e.jsxs("div",{style:{minHeight:"100vh",background:"var(--bg-primary, #f6f7f9)",color:"var(--text-primary, #172033)"},children:[e.jsxs("header",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px clamp(14px, 2vw, 24px)",borderBottom:"1px solid var(--border, #e2e8f0)",background:"var(--bg-card, #fff)",flexWrap:"wrap"},children:[e.jsx(b,{size:31}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontWeight:800,fontSize:16},children:"Lumy CRM para Shopify"}),e.jsx("div",{style:{fontSize:11.5,color:"var(--text-muted, #64748b)",overflow:"hidden",textOverflow:"ellipsis"},children:n.shop})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[f&&e.jsx("span",{role:"status",style:{fontSize:11.5,color:f.startsWith("Listo")?"#047857":"#b91c1c"},children:f}),e.jsx("button",{type:"button",onClick:()=>void I(),disabled:x,style:{...N,opacity:x?.6:1},children:x?"Sincronizando...":"Sincronizar ahora"}),e.jsx("a",{href:"/privacidad",target:"_blank",rel:"noopener noreferrer",style:W,children:"Privacidad"}),e.jsx("a",{href:"/contacto",target:"_blank",rel:"noopener noreferrer",style:W,children:"Soporte"})]})]}),e.jsx($,{initialView:"crm",shopifyEmbedded:!0})]})})}function g({title:a,text:r,children:s}){return e.jsxs("div",{style:{width:"min(480px, 100%)",background:"#fff",border:"1px solid #dfe3e8",borderRadius:16,padding:28,boxShadow:"0 14px 40px rgba(23,32,51,.08)",textAlign:"center"},children:[e.jsx("div",{style:{marginBottom:10},children:e.jsx(b,{size:42})}),e.jsx("h1",{style:{margin:"0 0 8px",color:"#172033",fontSize:23},children:a}),e.jsx("p",{role:"status",style:{color:"#637083",fontSize:13.5,lineHeight:1.55,margin:"0 0 18px"},children:r}),e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:9,flexWrap:"wrap"},children:s})]})}const j={minHeight:"100vh",display:"grid",placeItems:"center",padding:22,background:"#f4f6f8"},A={border:0,borderRadius:9,padding:"10px 16px",background:"#5E8
1E3E",color:"#fff",fontWeight:750,cursor:"pointer",fontFamily:"inherit"},N={border:"1px solid #cbd5e1",borderRadius:9,padding:"9px 13px",background:"#fff",color:"#334155",fontWeight:700,cursor:"pointer",fontFamily:"inherit"},W={color:"#4f7d35",textDecoration:"none",fontWeight:700,fontSize:12};export{pe as ShopifyEmbeddedApp};

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.