PageSourceSearch

https://app.markopolo.ai/assets/index-Tch7Af06.js

js markopolo.ai collected 2026-09-24 18:40:31 UTC 38,664 bytes, 1 lines download raw bytes

1import{j as e,r as c,e as te,l as xe,N as fe}from"./vendor-react-BN8-jPqf.js";import{f as N,c3 as oe,bI as ye,c4 as D,B as v,ba as se,c5 as X,c6 as re,c7 as be,u as V,Y as ve,z as ne,Z as L,F as B,H as C,k as je,g as ae,C as _e,c8 as P,y as we,c9 as Ne,ca as Se,cb as ke,cc as Ce,cd as Ee,ce as Ae,cf as ee,cg as Le,ch as Te}from"./index-V1zIfw7Q.js";import{C as Y}from"./index-Cfb9Whha.js";import{C as H}from"./index-D93HubYX.js";import{u as x}from"./vendor-i18n-CnMO7MKm.js";import{s as ie}from"./vendor-redux-DiHVN3TZ.js";import{F as Pe}from"./RefreshCw01-YihGfpUj.js";import{S as Oe}from"./Spinner-B4zCc1eb.js";import{C as Re}from"./index-BW7zOLMJ.js";import{C as Ie}from"./index-Ccaa6g5H.js";import{u as De,A as Be,a as k}from"./useDefaultEmailTemplate-B22rAdPy.js";import{u as Me}from"./file.api-BviXxSET.js";import{n as ze}from"./emailTemplateHelpers-DLN_Gktw.js";import{c as Fe,a as le,d as Ge,u as de,e as Ve}from"./onboardingV2.api-CoGAXrY8.js";import{M as ce}from"./index-DKOIsVX2.js";import{T as Ue}from"./index-DJaRazud.js";import{U as Ye}from"./index-gKkFrRQn.js";import{E as He}from"./index-Kmc2gBjN.js";import{S as We}from"./index-CqaOzfsl.js";import{d as $e,m as Ke,g as qe,h as Je,j as Qe}from"./emailTemplate.api-C7IklDvA.js";import{v as Ze}from"./security-CQuVOq4N.js";import{S as b}from"./Skeleton-bmPPgpIK.js";import{C as Xe}from"./CanvasFlow-Dg8X6-_L.js";import{P as et}from"./Progress-ChPS5RHE.js";import"./vendor-utils-CS7fQHMJ.js";import"./vendor-icons-DrvWjlOJ.js";import"./vendor-motion-2T9_tTTe.js";import"./EmailTemplatePreview-Cbk9EmID.js";import"./index-C27F7PNp.js";import"./knowledge-base.api-CeLW8Byq.js";import"./vendor-editor-C9PTgfKO.js";import"./vendor-fontawesome-Cc38dhgk.js";import"./vendor-color-VSv0QChT.js";import"./vendor-antd-Bf2RPcTA.js";import"./sseAuth-BwdNLBcW.js";import"./index-4GryHGbl.js";import"./index-C1IG9jKa.js";import"./index-DglqSlEV.js";import"./index-C5gib6wQ.js";import"./vendor-flow-6KIgW2Lm.js";const tt=({color:t="#12B76A",size:o=10,strokeWidth:s=1.5,onClick:r,style:a})=>e.jsx("svg",{strokeWidth:s,style:{...a},onClick:i=>r&&r(i),width:o,height:o,viewBox:"0 0 10 10",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M1.5 5H8.5M8.5 5L5 1.5M8.5 5L5 8.5",stroke:t})}),ot=({color:t="#7A5AF8",size:o=12,strokeWidth:s=1.5,onClick:r,style:a})=>e.jsx("svg",{style:{...a},onClick:i=>r&&r(i),width:o,height:o,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5.65101 10.8074C5.7617 10.872 5.81705 10.9043 5.89516 10.9211C5.95578 10.9341 6.04422 10.9341 6.10484 10.9211C6.18295 10.9043 6.2383 10.872 6.349 10.8074C7.32302 10.2392 10 8.45422 10 6V4.1C10 3.56306 10 3.29458 9.91723 3.104C9.83311 2.9103 9.74929 2.80726 9.57678 2.68546C9.40704 2.56562 9.07431 2.49642 8.40885 2.35801C7.6754 2.20547 7.11214 1.93002 6.59719 1.53166C6.35025 1.34064 6.22679 1.24512 6.13017 1.21907C6.02822 1.19158 5.97178 1.19158 5.86983 1.21907C5.77321 1.24512 5.64975 1.34064 5.40281 1.53166C4.88786 1.93002 4.3246 2.20547 3.59115 2.35801C2.92569 2.49642 2.59296 2.56562 2.42322 2.68546C2.25071 2.80726 2.16689 2.9103 2.08277 3.104C2 3.29458 2 3.56306 2 4.1V6C2 8.45422 4.67698 10.2392 5.65101 10.8074Z",fill:t,stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"})}),st=({color:t="currentColor",size:o=22,strokeWidth:s=2,onClick:r,style:a})=>e.jsx("svg",{style:{...a},onClick:i=>r&&r(i),width:o,height:o,viewBox:"0 0 22 22",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M15 7V4L18 1L19 3L21 4L18 7H15ZM15 7L11 10.9999M21 11C21 16.5228 16.5228 21 11 21C5.47715 21 1 16.5228 1 11C1 5.47715 5.47715 1 11 1M16 11C16 13.7614 13.7614 16 11 16C8.23858 16 6 13.7614 6 11C6 8.23858 8.23858 6 11 6",stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"})}),rt=({size:t=132,className:o})=>e.jsxs("div",{"aria-hidden":!0,className:N("relative",o),style:{width:t,height:t},children:[[1,.66,.33].map(s=>e.jsx("div",{className:"absolute inset-0 m-auto rounded-full border border-border",style:{width:t*s,height:t*s}},s)),e.jsx("div",{className:"absolute inset-0 animate-brand-spin rounded-full",style:{animationDuration:"3.2s",background:"conic-gradient(from 0deg, rgb(var(--primary) / 0.32) 0deg, rgb(var(--primary) / 0) 70deg)"}}),e.jsx("span",{className:"absolute inset-0 m-auto animate-ring-pulse rounded-full bg-primary/15",style:{width:14,height:14}}),e.jsx("span",{className:"absolute inset-0 m-auto rounded-full bg-primary",style:{width:8,height:8}})]}),nt=({index:t,label:o,caption:s,state:r,disabled:a,onClick:i})=>{const n=r==="active",l=r==="done";return e.jsxs("button",{type:"button",onClick:i,disabled:a,"aria-current":n?"step":void 0,className:N("group flex w-full items-start gap-3 rounded-xl px-3 py-2.5 text-left transition-colors",n&&"bg-primary/10",!n&&!a&&"hover:bg-accent/60",a&&"cursor-not-allowed opacity-45"),children:[e.jsx("span",{className:N("mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-xs font-medium",l&&"border-transparent bg-primary text-primary-foreground",n&&"border-primary text-primary",!l&&!n&&"border-border text-muted-foreground"),children:l?e.jsx(H,{size:14}):t+1}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:N("text-sm font-medium leading-tight",n||l?"text-foreground":"text-muted-foreground"),children:o}),e.jsx("span",{className:"mt-0.5 text-xs text-muted-foreground",children:s})]})]})},at=({currentStage:t,maxReachableIndex:o,onNavigate:s,shopDomain:r})=>{const{t:a}=x(),i=oe(t);return e.jsxs("aside",{className:"flex h-full w-64 shrink-0 flex-col justify-between border-r border-border bg-background px-4 py-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-8 px-2",children:e.jsx("img",{src:ye,alt:"Markopolo",className:"w-36"})}),e.jsx("p",{className:"mb-3 px-3 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:a("shopify_onboarding.guided_setup","Guided setup")}),e.jsx("nav",{className:"flex flex-col gap-1",children:D.map((n,l)=>{const d=l<i?"done":l===i?"active":"upcoming",u=l<=o;return e.jsx(nt,{index:l,label:a(n.labelKey,n.labelDefault),caption:a(n.captionKey,n.captionDefault),state:d,disabled:!u,onClick:u?()=>s(n.slug):void 0},n.slug)})})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-border bg-card px-3 py-2.5",children:[e.jsx(Y,{size:16,color:"rgb(var(--success))"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:a("shopify_onboarding.progress_saved","Progress saved")}),r&&e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:r})]})]})]})},it=({onSupport:t})=>{const{t:o}=x();return e.jsx("header",{className:"flex h-14 shrink-0 items-center justify-end gap-1 border-b border-border px-6",children:e.jsx(v,{variant:"link",size:"sm",onClick:t,children:o("shopify_onboarding.support","Support")})})},lt=({currentStage:t,maxReachableIndex:o,onNavigate:s,onSupport:r,shopDomain:a,children:i})=>(c.useEffect(()=>{const n=document.documentElement,l=n.classList.contains("dark");return n.classList.add("dark"),()=>{l||n.classList.remove("dark")}},[]),e.jsxs("div",{className:"flex h-screen w-full overflow-hidden bg-background text-foreground",children:[e.jsx(at,{currentStage:t,maxReachableIndex:o,onNavigate:s,shopDomain:a}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx(it,{onSupport:r}),e.jsx("main",{className:"flex flex-1 flex-col overflow-y-auto",children:i})]})]})),T=({variant:t,title:o,description:s,actionLabel:r,onAction:a,actionLoading:i,onSupport:n,icon:l,className:d})=>{const{t:u}=x(),m=t==="loading",p=t==="error"||t==="timeout",h=m?e.jsx(rt,{size:96}):p?e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-primary/10",children:e.jsx(se,{size:26,color:"rgb(var(--primary))"})}):null;return e.jsxs("div",{className:`flex flex-col items-center justify-center gap-4 py-14 text-center ${d??""}`,children:[l??h,o&&e.jsx("p",{className:"text-xl font-medium leading-tight text-foreground",children:o}),s&&e.jsx("p",{className:"max-w-md text-sm text-muted-foreground",children:s}),r&&a||p&&n?e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[r&&a&&e.jsx(v,{variant:"secondary",loading:i,onClick:a,leadingIcon:p?e.jsx(Pe,{size:16}):void 0,children:r}),p&&n&&e.jsx(v,{variant:"link",onClick:n,children:u("shopify_onboarding.contact_support","Contact support")})]}):null,m&&!o&&e.jsx(Oe,{size:"md"})]})}
1,M=({onBack:t,onNext:o,nextLabel:s,nextDisabled:r,nextLoading:a,showBack:i=!0})=>{const{t:n}=x();return e.jsxs("div",{className:"flex items-center justify-between border-t border-border px-8 py-4",children:[e.jsx("div",{children:i&&t&&e.jsx(v,{variant:"ghost",onClick:t,leadingIcon:e.jsx(Ie,{size:16}),children:n("shopify_onboarding.back","Back")})}),o&&e.jsx(v,{onClick:o,disabled:r,loading:a,trailingIcon:e.jsx(Re,{size:16}),children:s??n("shopify_onboarding.next","Continue")})]})},j=({children:t,footer:o,wide:s})=>e.jsxs("div",{className:"flex min-h-full flex-col",children:[e.jsx("div",{className:`animate-fade-in mx-auto w-full flex-1 px-8 py-10 ${s?"max-w-5xl":"max-w-3xl"}`,children:t}),o&&e.jsx("div",{className:"mx-auto w-full max-w-5xl",children:o})]}),dt=[{id:"preset-email",type:"communication",channel:"email",provider:"AUTOSEND",contentGenerationMode:"autonomous",label:"Recovery email",purpose:"Bring the shopper back to the exact cart they left",target:["preset-delay"]},{id:"preset-delay",type:"delay",delayTime:"1d",label:"Wait 1 day",target:["preset-purchase-check"]},{id:"preset-purchase-check",type:"condition",label:"Purchased?",purpose:"Skip the follow-up email if the shopper already completed the purchase",expressions:[{event:"Purchase",operator:"gte",value:1}],target:["preset-exit","preset-email-2"]},{id:"preset-email-2",type:"communication",channel:"email",provider:"AUTOSEND",contentGenerationMode:"autonomous",label:"Follow-up email",purpose:"A final nudge by email if still no purchase",target:["preset-exit"]},{id:"preset-exit",type:"exit",label:"Exit journey",target:[]}],ct=[{id:"preset-email",channel:"email",order:1,delayLabel:"As soon as the cart is abandoned",rationale:"Email the shopper the exact items they left, grounded in your real catalog — the fastest, highest-intent recovery.",stopRule:"Skips if the order completes on its own.",sourceLabel:"Observed catalog fact"},{id:"preset-email-2",channel:"email",order:2,delayLabel:"After 1 day, if still no purchase",rationale:"A second, final email nudge grows recovery without discounting.",stopRule:"Stops on purchase, reply, or unsubscribe.",sourceLabel:"Observed catalog fact"}],O=()=>{const t=te(),{stage:o}=xe(),s=X(o)?o:re,r=oe(s),a=c.useCallback((l,d=!1)=>{t(`${be}/${l}`,{replace:d})},[t]),i=c.useCallback(()=>{const l=D[r+1];l&&a(l.slug)},[r,a]),n=c.useCallback(()=>{const l=D[r-1];l&&a(l.slug)},[r,a]);return{currentStage:s,currentIndex:r,isFirstStage:r===0,isLastStage:r===D.length-1,goTo:a,goNext:i,goBack:n,isValidParam:X(o)}},ut=10*1024*1024,pt="image/png,image/jpeg,image/jpg",mt=()=>{const{t}=x(),o=V(g=>g.companyV2),s=o?.settings?.senderProfile,r=o?.resourceId??"",a=s?.logoImage??"",i=a.trim().length>0,[n,{isLoading:l}]=ve(),[d,u]=c.useState(!1),m=c.useCallback(async g=>{const f=g?t("messages.success.logo_uploaded","Logo uploaded successfully!"):t("messages.success.logo_removed","Logo removed successfully!"),E={logoImage:g,cartPath:s?.cartPath??"",brandColor:s?.brandColor??"",heroBanner:s?.heroBanner??"",footerBanner:s?.footerBanner??"",address:s?.address??"",tagline:s?.tagline??"",navigationLinks:ze(s?.navigationLinks),socialLinks:{facebook:s?.socialLinks?.facebook??null,twitter:s?.socialLinks?.twitter??null,instagram:s?.socialLinks?.instagram??null,linkedin:s?.socialLinks?.linkedin??null,tiktok:s?.socialLinks?.tiktok??null,youtube:s?.socialLinks?.youtube??null}};try{return await n({senderProfile:E,successMessage:f}).unwrap(),!0}catch{return!1}},[s,n]),p=c.useCallback(async g=>{if(!g)return!1;if(g.size>ut)return ne.error(t("settings.image_too_large","Image must be under 10 MB.")),!1;u(!0);const f=await Me(g,r);return u(!1),f?.url?m(f.url):!1},[r,m,t]),h=c.useCallback(()=>m(""),[m]);return{logoImage:a,hasLogo:i,usesAccountPhotoAsLogo:!i&&(o?.user?.profilePhoto??"").trim().length>0,uploadLogo:p,removeLogo:h,isBusy:d||l}},gt={email:e.jsx(ce,{size:15,color:"rgb(var(--primary))"}),sms:e.jsx(L,{size:15,color:"rgb(var(--primary))"}),whatsapp:e.jsx(L,{size:15,color:"rgb(var(--primary))"}),push:e.jsx(L,{size:15,color:"rgb(var(--primary))"})},ht=({step:t,isLast:o})=>{const{t:s}=x();return e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-border bg-card",children:gt[t.channel]}),!o&&e.jsx("span",{className:"my-1 w-px flex-1 bg-border"})]}),e.jsxs("div",{className:"pb-6",children:[t.delayLabel&&e.jsx("p",{className:"text-xs font-medium text-primary",children:t.delayLabel}),e.jsx("p",{className:"mt-1 text-sm text-foreground",children:t.rationale}),t.stopRule&&e.jsxs("p",{className:"mt-1.5 text-xs text-muted-foreground",children:[s("shopify_onboarding.agent.stops_when","Stops when:")," ",t.stopRule]}),t.sourceLabel&&e.jsx("span",{className:"mt-2 inline-block rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:t.sourceLabel})]})]})},xt=({steps:t})=>{const{t:o}=x(),s=[...t].sort((r,a)=>r.order-a.order);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-4 text-sm font-medium text-foreground",children:o("shopify_onboarding.agent.plan_title","Agent plan")}),e.jsx("div",{className:"flex flex-col",children:s.map((r,a)=>e.jsx(ht,{step:r,isLast:a===s.length-1},r.id))})]})}
1,ft=({hasLogo:t,isBusy:o,onPick:s,onRemove:r})=>{const{t:a}=x(),i=c.useRef(null);return e.jsxs("div",{className:"flex flex-none items-center gap-2",children:[e.jsx("input",{ref:i,type:"file",className:"hidden",accept:pt,onChange:n=>{const l=n.target.files?.[0];n.target.value="",s(l)}}),e.jsx(v,{variant:"primary",size:"sm",loading:o,onClick:()=>i.current?.click(),leadingIcon:e.jsx(Ye,{size:14}),className:t?void 0:"motion-safe:animate-brand-glow",children:t?a("shopify_onboarding.agent.replace_logo","Replace logo"):a("shopify_onboarding.agent.add_logo","Add logo")}),t&&e.jsx(v,{variant:"ghost",size:"sm",disabled:o,onClick:r,className:"h-8 w-8 p-0 text-muted-foreground hover:bg-transparent hover:text-destructive","aria-label":a("shopify_onboarding.agent.remove_logo","Remove logo"),children:e.jsx(Ue,{size:14,color:"currentColor"})})]})},yt=({companyId:t,merchantEmail:o,template:s,companyState:r,emailProducts:a,kbProductsPending:i})=>{const{t:n}=x(),l=B(),[d,{isLoading:u,isSuccess:m,data:p}]=Fe(),[h]=$e(),[g,f]=c.useState(!1),E=u||g,[_,w]=c.useState(o??""),[S,z]=c.useState(!1),[$,K]=c.useState(""),[ue,A]=c.useState(null),q=c.useRef(!1),J=c.useRef(null);c.useEffect(()=>{q.current||w(o??"")},[o]),c.useEffect(()=>{S&&J.current?.focus()},[S]);const pe=()=>{K(_),A(null),z(!0)},Q=()=>{z(!1),A(null)},Z=()=>{const y=$.trim();if(!y||!Ze.isValidEmail(y)){A(n("shopify_onboarding.agent.invalid_test_email","Enter a valid email address"));return}q.current=!0,w(y),z(!1),A(null)};c.useEffect(()=>{m&&l(C.SHOPIFY_ONBOARDING.AGENT_TEST_EMAIL_SENT,{company_id:t,sent_to:p?.sentTo??_})},[m]);const me=async()=>{const y=_.trim()||void 0,R=s?.resourceId;if(!s||!R){d({companyId:t,toEmail:y,templateId:R});return}f(!0);try{const F=Ke(s.emailRawJson,s)??qe(),ge=Je(F,r,a,{knowledgeBaseProductsLoading:i}),he=Qe({name:s.name,description:s.description,payload:ge,contentMode:"autonomous",company:r,tags:s.tags,isActive:s.isActive,isAutoCreated:s.isAutoCreated});await h({companyId:t,templateId:R,body:he}).unwrap()}catch(F){ne.error(ae(F,n("messages.error.email_template_save_failed"))),f(!1);return}f(!1),d({companyId:t,toEmail:y,templateId:R})};return e.jsxs("div",{className:"flex flex-col gap-2",children:[S?e.jsx("div",{className:"flex flex-col gap-1.5",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(je,{ref:J,type:"email",value:$,onChange:y=>{K(y.target.value),A(null)},onKeyDown:y=>{y.key==="Enter"&&Z(),y.key==="Escape"&&Q()},placeholder:n("shopify_onboarding.agent.test_email_placeholder","[email protected]"),leftSection:e.jsx(ce,{size:16}),error:ue,wrapperClassName:"flex-1",className:"h-9"}),e.jsx(v,{size:"sm",variant:"secondary",onClick:Z,children:n("shopify_onboarding.agent.save_test_email","Save")}),e.jsx(v,{size:"sm",variant:"ghost",onClick:Q,children:n("shopify_onboarding.agent.cancel_test_email","Cancel")})]})}):e.jsxs("button",{type:"button",onClick:pe,className:"flex w-fit items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[_?n("shopify_onboarding.agent.test_email_target","Sending test to {{email}}",{email:_}):n("shopify_onboarding.agent.test_email_target_empty","Add a test email address"),e.jsx(He,{size:12})]}),e.jsx(v,{variant:"secondary",loading:E,disabled:S,onClick:me,leadingIcon:e.jsx(We,{size:16}),children:n("shopify_onboarding.agent.send_test","Send a safe test")}),m&&e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-success-600",children:[e.jsx(Y,{size:14}),n("shopify_onboarding.agent.test_confirmed","Sent to {{email}} successfully",{email:p?.sentTo??_??"you"})]})]})},U=({children:t,className:o,emphasis:s})=>e.jsx(_e,{className:N("shadow-none",s&&"border-primary/30",o),children:t}),bt=({product:t})=>{const{t:o}=x();return e.jsx(U,{emphasis:!0,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(st,{size:18,color:"rgb(var(--primary))"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:o("shopify_onboarding.agent.real_scenario_top_product","Based on real abandoned checkouts")}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-foreground",children:o("shopify_onboarding.agent.top_product_scenario","{{count}} shoppers recently abandoned checkout with the {{product}} in their cart. Here is what your agent would do.",{count:t.abandonedCount,product:t.title})})]})]})})},vt=({onSupport:t})=>{const{t:o}=x(),{companyId:s,merchantEmail:r,hasRealShopify:a}=P(),{goNext:i,goBack:n}=O(),l=le(s?{companyId:s}:ie),d=De(s,a),u=mt(),m=l.isLoading||d.isLoading,p=e.jsx(M,{onBack:n,onNext:i,nextLabel:o("shopify_onboarding.agent.continue","Review & activate")});if(m)return e.jsx(j,{footer:p,wide:!0,children:e.jsx(T,{variant:"loading",title:o("shopify_onboarding.agent.generating","Preparing your recovery agent preview")})});if(l.isError)return e.jsx(j,{footer:p,wide:!0,children:e.jsx(T,{variant:"error",title:o("shopify_onboarding.agent.error_title","We couldn't build the preview"),description:o("shopify_onboarding.agent.error_desc","Retry to rebuild the agent plan and email from your store data."),actionLabel:o("shopify_onboarding.retry","Retry"),onAction:()=>l.refetch(),onSupport:t})});const h=l.data?.topProducts?.[0]??null,g=d.htmlContent?{templateHtml:"",markopoloDocumentHtml:d.htmlContent}:null;return e.jsxs(j,{footer:p,wide:!0,children:[e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:o("shopify_onboarding.agent.eyebrow","Agent in action")}),e.jsx("h1",{className:"display-md max-w-2xl font-medium text-foreground",children:o("shopify_onboarding.agent.title","This is how Markopolo decides — not just what it writes")}),e.jsxs("div",{className:"mt-8 grid gap-6 lg:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-6",children:[h?e.jsx(bt,{product:h}):e.jsxs("div",{className:"flex items-start gap-3 rounded border border-dashed border-border px-5 py-4",children:[e.jsx(L,{size:18,color:"rgb(var(--primary))",className:"mt-0.5 shrink-0"}),e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:o("shopify_onboarding.agent.waiting_note","No abandoned checkout yet — here is exactly what your agent will run for the first shopper who leaves one. Nothing is sent before you activate.")})]}),e.jsx(xt,{steps:ct}),e.jsx("div",{className:"border-t border-border pt-5",children:s&&e.jsx(yt,{companyId:s,merchantEmail:r,template:d.template,companyState:d.companyState,emailProducts:d.emailProducts,kbProductsPending:d.kbProductsPending})})]}),e.jsx("div",{children:g?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:o("shopify_onboarding.agent.email_title","Your recovery email")}),e.jsx(ft,{hasLogo:u.hasLogo,isBusy:u.isBusy,onPick:f=>void u.uploadLogo(f),onRemove:()=>void u.removeLogo()})]}),e.jsx(Be,{email:g}),!u.hasLogo&&e.jsx("p",{className:"mt-2.5 text-xs leading-relaxed text-muted-foreground",children:u.usesAccountPhotoAsLogo?o("shopify_onboarding.agent.logo_hint_account_photo","Your account photo is standing in as the header. Add a PNG or JPG logo to replace it."):o("shopify_onboarding.agent.logo_hint","No logo yet — your store name is used as the header. Add a PNG or JPG to replace it.")})]}):e.jsx("div",{className:"flex h-full min-h-[320px] items-center justify-center rounded border border-border bg-card p-6 text-center",children:e.jsx("p",{className:"max-w-xs text-sm leading-relaxed text-muted-foreground",children:o("shopify_onboarding.agent.no_template","Your recovery email is being prepared and will fill with the exact cart when a shopper leaves one.")})})})]})]})},W=({children:t,onClick:o,loading:s,disabled:r,className:a,withArrow:i=!0})=>e.jsx(v,{variant:"primary",size:"default",onClick:o,loading:s,disabled:r,className:a,trailingIcon:i?e.jsx(tt,{size:16,color:"currentColor"}):void 0,children:t}),jt=({catalogSize:t,simulationProduct:o,onContinue:s})=>{const{t:r}=x();return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:r("shopify_onboarding.opportunity.new_store_eyebrow","New store — no checkout history yet")}),e.jsxs("span",{className:"mt-4 inline-flex items-center gap-2 rounded-full border border-primary/30 bg-primary/10 px-3.5 py-1.5 text-xs font-semibold uppercase tracking-wide text-primary",children:[e.jsx(H,{size:13}),r("shopify_onboarding.opportunity.shopify_connected","Shopify connected")]}),e.jsxs("h1",{className:"display-md mt-6 max-w-2xl font-medium text-foreground",children:[r("shopify_onboarding.opportunity.new_store_title","Your recovery agent is ready for the next shopper who")," ",e.jsx("span",{className:"font-title italic",children:r("shopify_onboarding.opportunity.new_store_title_accent","leaves.")})]}),e.jsx("p",{className:"mt-5 max-w-2xl text-[15px] leading-relaxed text-muted-foreground",children:r("shopify_onboarding.opportunity.new_store_desc","There isn't enough checkout history yet to calculate a trustworthy opportunity — so we won't invent one. We connected your catalog, brand, and storefront events; let's preview exactly how Markopolo will respond to the first eligible visit.")}),e.jsxs("div",{className:"mt-8 grid gap-4 md:grid-cols-3",children:[e.jsx(k,{label:r("shopify_onboarding.opportunity.tile_products","Products"),value:t&&t>
10?String(t):r("shopify_onboarding.opportunity.synced","Synced"),caption:r("shopify_onboarding.opportunity.catalog_synced","catalog items synced")}),e.jsx(k,{label:r("shopify_onboarding.opportunity.tile_events","Storefront events"),value:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-primary"}),r("shopify_onboarding.opportunity.live","Live")]}),caption:r("shopify_onboarding.opportunity.listening","listening for visits")}),e.jsx(k,{label:r("shopify_onboarding.opportunity.tile_brand","Brand voice"),value:r("shopify_onboarding.opportunity.ready","Ready"),caption:r("shopify_onboarding.opportunity.built_from_store","built from your store")})]}),e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded border border-dashed border-border px-5 py-4",children:[e.jsx(L,{size:18,color:"rgb(var(--primary))",className:"mt-0.5 shrink-0"}),e.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:[r("shopify_onboarding.opportunity.sim_prefix","Next, you'll see a")," ",e.jsx("span",{className:"font-medium text-foreground",children:r("shopify_onboarding.opportunity.sim_label","clearly labeled simulation")})," ",o?r("shopify_onboarding.opportunity.sim_body_product","— a shopper leaving the {{product}} at checkout — built with your real catalog. Nothing is sent.",{product:o}):r("shopify_onboarding.opportunity.sim_body","— built with your real catalog. Nothing is sent.")]})]}),e.jsx("div",{className:"mt-8",children:e.jsx(W,{onClick:s,children:r("shopify_onboarding.opportunity.new_store_cta","See how the agent will respond")})}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:r("shopify_onboarding.nothing_sent","Nothing has been sent to anyone.")})]})},G=()=>e.jsxs("div",{className:"flex flex-col rounded border border-border bg-card px-4 py-3",children:[e.jsx(b,{className:"h-3 w-20"}),e.jsx(b,{className:"mt-2 h-6 w-14"}),e.jsx(b,{className:"mt-2 h-3 w-28"})]}),_t=()=>e.jsxs("div",{children:[e.jsx(b,{className:"h-14 w-44"}),e.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[e.jsx(b,{className:"h-6 w-full max-w-2xl"}),e.jsx(b,{className:"h-6 w-1/3"})]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-2",children:[e.jsx(b,{className:"h-4 w-full max-w-2xl"}),e.jsx(b,{className:"h-4 w-2/3 max-w-2xl"})]}),e.jsx(b,{className:"mt-5 h-3 w-72"}),e.jsxs("div",{className:"mt-8 grid gap-4 md:grid-cols-3",children:[e.jsx(G,{}),e.jsx(G,{}),e.jsx(G,{})]}),e.jsx(b,{className:"mt-8 h-9 w-56"}),e.jsx(b,{className:"mt-4 h-3 w-40"})]}),wt=t=>{const o=new Date,s=new Date;s.setDate(o.getDate()-t);const r=a=>a.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${r(s)} – ${r(o)}, ${o.getFullYear()}`},Nt=(t,o,s)=>{try{return new Intl.NumberFormat("en-US",{style:"currency",currency:(o||"USD").toUpperCase(),maximumFractionDigits:s?.withCents?2:0}).format(t||0)}catch{return`${(t||0).toLocaleString()} ${o||""}`.trim()}},St=({recoverableValue:t,currency:o,credibility:s})=>{const{t:r}=x(),[a,i]=c.useState(!1);return e.jsxs("div",{children:[e.jsx("h1",{className:"display-xl font-medium leading-none text-foreground",children:Nt(t,o)}),e.jsx("p",{className:"display-xs mt-4 max-w-2xl font-medium text-foreground",children:r("shopify_onboarding.opportunity.headline","was left behind in carts and checkouts in the last {{days}} days.",{days:s.windowDays})}),e.jsx("p",{className:"mt-5 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:r("shopify_onboarding.opportunity.subtitle","Markopolo can watch for the same high-intent behavior and help recover those shoppers — with messages written for the person, the product, and the moment.")}),e.jsxs("p",{className:"mt-5 text-xs text-muted-foreground",children:[r("shopify_onboarding.opportunity.cred_line","Estimated opportunity, not guaranteed revenue")," · ",r("shopify_onboarding.opportunity.cred_source","Shopify data, {{range}}",{range:wt(s.windowDays)})," · ",e.jsx("button",{type:"button",onClick:()=>i(n=>!n),className:"font-medium text-primary hover:underline",children:r("shopify_onboarding.opportunity.how_calculated","How this was calculated")})]}),a&&e.jsx("p",{className:"mt-3 max-w-2xl rounded border border-border bg-card px-4 py-3 text-xs leading-relaxed text-muted-foreground",children:r("shopify_onboarding.opportunity.calc_detail","Summed from {{count}} abandoned checkouts observed in your Shopify store over the last {{days}} days. This is the value left in carts — not a revenue guarantee.",{count:s.sampleSize,days:s.windowDays})})]})},kt=({onSupport:t})=>{const{t:o}=x(),{companyId:s}=P(),{goNext:r,goBack:a}=O(),i=le(s?{companyId:s}:ie),n=i.data,l=i.isLoading,d=i.isError,u=i.refetch,m=e.jsx(M,{onBack:a,showBack:!0});if(l||!n)return e.jsx(j,{footer:m,children:e.jsx(_t,{})});if(d)return e.jsx(j,{footer:m,children:e.jsx(T,{variant:"error",title:o("shopify_onboarding.opportunity.error_title","We couldn't load your opportunity"),description:o("shopify_onboarding.opportunity.error_desc","Your data is safe. Retry to recalculate from your store history."),actionLabel:o("shopify_onboarding.retry","Retry"),onAction:u,onSupport:t})});if(!n.hasData)return e.jsx(j,{footer:m,children:e.jsx(jt,{catalogSize:n.catalogSize,simulationProduct:n.topProducts[0]?.title,onContinue:r})});const p=n.topProducts[0];return e.jsxs(j,{footer:m,children:[e.jsx(St,{recoverableValue:n.recoverableValue,currency:n.currency,credibility:n.credibility}),e.jsxs("div",{className:"mt-8 grid gap-4 md:grid-cols-3",children:[e.jsx(k,{label:o("shopify_onboarding.opportunity.tile_high_intent","High-intent exits"),value:String(n.shoppersLeftCheckout),caption:o("shopify_onboarding.opportunity.unrecovered","unrecovered checkouts")}),e.jsx(k,{label:o("shopify_onboarding.opportunity.tile_reachable","Reachable now"),value:String(n.reachableCount),caption:o("shopify_onboarding.opportunity.with_consent","with email consent")}),e.jsx(k,{label:o("shopify_onboarding.opportunity.tile_top_product","Top lost product"),value:p?e.jsx(we,{label:p.title,position:"top",children:e.jsx("span",{children:p.title})}):o("shopify_onboarding.opportunity.none","—"),valueClassName:"truncate",caption:p?o("shopify_onboarding.opportunity.abandoned_checkouts","{{count}} abandoned checkouts",{count:p.abandonedCount}):""})]}),e.jsx("div",{className:"mt-8",children:e.jsx(W,{onClick:r,children:o("shopify_onboarding.opportunity.cta","Show me my recovery agent")})}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:o("shopify_onboarding.nothing_sent","Nothing has been sent to anyone.")})]})},Ct=()=>{},Et=()=>{const{t}=x(),o=te(),{goBack:s}=O(),r=B(),[a,{isLoading:i}]=Ge(),[n]=de(),[l,d]=c.useState(null),u=[{label:t("shopify_onboarding.review.gr_channels","Channels"),value:t("shopify_onboarding.review.gr_channels_v","Email, then a follow-up email")},{label:t("shopify_onboarding.review.gr_timing","Timing"),value:t("shopify_onboarding.review.gr_timing_v","Immediately, then after 1 day")},{label:t("shopify_onboarding.review.gr_consent","Consent"),value:t("shopify_onboarding.review.gr_consent_v","Only contacts with email consent")},{label:t("shopify_onboarding.review.gr_quiet","Quiet hours"),value:t("shopify_onboarding.review.gr_quiet_v","9 PM – 8 AM store-local")},{label:t("shopify_onboarding.review.gr_discount","Discounts"),value:t("shopify_onboarding.review.gr_discount_v","None — off by default")},{label:t("shopify_onboarding.review.gr_stops","Stops on"),value:t("shopify_onboarding.review.gr_stops_v","Purchase, reply, or unsubscribe")}],m=async()=>{d(null);try{await a().unwrap(),r(C.SHOPIFY_ONBOARDING.AGENT_ACTIVATED),await n({step:"launched"}).unwrap().catch(()=>{}),Ne(),o("/")}catch(h){const g=ae(h,"Could not activate the agent. Connect your email channel first, then retry.");r(C.SHOPIFY_ONBOARDING.AGENT_ACTIVATION_FAILED,{error_message:g}),d(g)}},p=e.jsx(M,{onBack:s,showBack:!0});return e.jsxs(j,{footer:p,wide:!0,children:[e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:t("shopify_onboarding.review.eyebrow","Review & activate")}),e.jsx("h1",{className:"display-md max-w-2xl font-medium text-foreground",children:t("shopify_onboarding.review.title","Turn on your Cart + Checkout Recovery agent")}),e.jsx("p",{className:"mt-4 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:t("shopify_onboarding.review.subtitle","One combined recovery agent, email-first with a follow-up email. Review the exact steps and guardrails, then turn it on.")}),e.jsxs("div",{className:"mt-8 grid gap-6 lg:grid-cols-[1.4fr_1fr]",children:[e.jsx(U,{className:"!p-3",children:e.jsx("div",{className:"overflow-hidden rounded-xl",children:e.jsx(Xe,{steps:dt,onNodeSelect:Ct,height:420,fitToTop:!0})})}),e.jsxs(U,{children:[e.jsx("p",{className:"mb-4 text-sm font-medium text-foreground",children:t("shopify_onboarding.review.guardrails","Guardrails")}),e.jsx("div",{className:"flex flex-col",children:u.map(h=>e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-border py-2.5 last:border-b-0",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:h.label}),e.jsx("span",{className:"max-w-[60%] text-right text-xs text-foreground",children:h.value})]},h.label))})]})]}),l&&e.jsx("div",{className:"mt-6",children:e.jsx(T,{variant:"error",title:t("shopify_onboarding.review.activate_failed","A
1ctivation could not complete"),description:l})}),e.jsxs("div",{className:"mt-8 flex items-center gap-4",children:[e.jsxs(W,{onClick:m,loading:i,withArrow:!1,children:[e.jsx(Y,{size:16}),t("shopify_onboarding.review.activate_cta","Turn on my recovery agent")]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t("shopify_onboarding.review.consequence","Your agent goes live and starts recovering real carts.")})]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:t("shopify_onboarding.nothing_sent","Nothing has been sent to anyone.")})]})},At=t=>{const[o,s]=c.useState(!0),[r,a]=c.useState(!1),i=c.useRef(Date.now()),n=Ve({companyId:t},{skip:!t,pollingInterval:o?Se:0}),l=n.data?.overallStatus,d=l==="ready",u=l==="failed",m=d||u;c.useEffect(()=>{m&&s(!1)},[m]),c.useEffect(()=>{if(!t||m||r)return;const h=ke-(Date.now()-i.current),g=setTimeout(()=>{a(!0),s(!1)},Math.max(0,h));return()=>clearTimeout(g)},[t,m,r]);const p=c.useCallback(()=>{i.current=Date.now(),a(!1),s(!0),n.refetch()},[n]);return{...n,isReady:d,isFailed:u,timedOut:r,retry:p}},Lt=()=>e.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-border",style:{borderTopColor:"rgb(var(--primary))"}}),Tt=({task:t})=>{const{t:o}=x(),s=Ce[t.id],r=t.label??o(s.key,s.label),a=t.detail??o(s.detailKey,s.detail),i=t.status==="done",n=t.status==="in_progress",l=t.status==="failed",d=i?e.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-primary",children:e.jsx(H,{size:16,color:"rgb(var(--primary-foreground))"})}):l?e.jsx("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-destructive/15",children:e.jsx(se,{size:15,color:"rgb(var(--destructive))"})}
1):n?e.jsx(Lt,{}):e.jsx("span",{className:"h-7 w-7 rounded-full border border-border"}),u=i?o("shopify_onboarding.status.done","Done"):l?o("shopify_onboarding.status.failed","Failed"):n?o("shopify_onboarding.status.working","Working"):o("shopify_onboarding.status.queued","Queued");return e.jsxs("div",{className:N("flex items-center justify-between gap-4 rounded border px-5 py-4 transition-colors",n?"border-primary/40 bg-primary/10":"border-border bg-card"),children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[d,e.jsxs("div",{children:[e.jsx("p",{className:N("text-sm font-medium",i||n?"text-foreground":"text-muted-foreground"),children:r}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]})]}),e.jsx("span",{className:N("text-xs font-semibold uppercase tracking-wide",i?"text-primary":l?"text-destructive":"text-muted-foreground"),children:u})]})},Pt=({onSupport:t})=>{const{t:o}=x(),{companyId:s,shopDomain:r}=P(),{goNext:a}=O(),i=B(),{data:n,isLoading:l,isError:d,isReady:u,isFailed:m,timedOut:p,retry:h}=At(s),g=n?.tasks??[],f=g.filter(w=>w.status==="done").length,E=g.length?Math.round(f/g.length*100):0;c.useEffect(()=>{u&&i(C.SHOPIFY_ONBOARDING.SETUP_READY,{company_id:s})},[u]),c.useEffect(()=>{p&&i(C.SHOPIFY_ONBOARDING.SETUP_TIMEOUT,{company_id:s})},[p]);const _=e.jsx(M,{showBack:!1,onNext:a,nextDisabled:!u,nextLabel:o("shopify_onboarding.setup.continue","See your opportunity")});return d||m||p?e.jsx(j,{footer:_,children:e.jsx(T,{variant:p?"timeout":"error",title:p?o("shopify_onboarding.setup.timeout_title","Still setting things up"):o("shopify_onboarding.setup.error_title","We couldn't finish setup"),description:p?o("shopify_onboarding.setup.timeout_desc","This is taking longer than usual. It keeps running in the background — retry to check again."):o("shopify_onboarding.setup.error_desc","One of the setup steps failed. Your progress is saved — retry the remaining steps."),actionLabel:o("shopify_onboarding.retry","Retry"),onAction:h,onSupport:t})}):e.jsxs(j,{footer:_,children:[e.jsx("h1",{className:"display-md max-w-2xl font-medium text-foreground",children:r?o("shopify_onboarding.setup.title_shop","Setting up Markopolo for {{shop}}",{shop:r}):o("shopify_onboarding.setup.title","Setting up your recovery agent")}),e.jsx("p",{className:"mt-5 max-w-xl text-sm leading-relaxed text-muted-foreground",children:o("shopify_onboarding.setup.subtitle","We're syncing your catalog, recent orders, customer consent, and storefront events — so your first recovery agent is built from real store data.")}),e.jsx("div",{className:"mt-9",children:e.jsx(et,{value:E,color:"primary"})}),e.jsx("div",{className:"mt-8 flex flex-col gap-3",children:l&&!g.length?Array.from({length:Ee}).map((w,S)=>e.jsx("div",{className:"h-[76px] animate-pulse rounded border border-border bg-card"},S)):g.map(w=>e.jsx(Tt,{task:w},w.id))}),e.jsxs("div",{className:"mt-6 flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ot,{size:14}),o("shopify_onboarding.setup.no_script","No code or tag setup needed — everything is provisioned through Shopify permissions.")]})]})},Ot=t=>{const[o]=de(),s=V(l=>l.companyV2?.resourceId),r=V(l=>l.companyV2?.onboardingFlags?.shopify?.step),{isIntegrationsResolved:a,isShopifyConnected:i}=P(),n=Le[t];c.useEffect(()=>{s&&(!a||!i||Ae(r)||ee(n)<=ee(r)||o({step:n}))},[n,r,s,a,i,o])},I=()=>{const t=window.Intercom;t?t("show"):window.open("mailto:[email protected]","_blank")},jo=()=>{const{currentStage:t,currentIndex:o,isValidParam:s,goTo:r}=O(),{companyId:a,shopDomain:i,isShopifyConnected:n,isIntegrationsResolved:l}=P(),d=B();if(Ot(t),c.useEffect(()=>{!a||!l||!n||d(C.SHOPIFY_ONBOARDING.STAGE_VIEWED,{stage:t})},[a,l,n,t]),c.useEffect(()=>{s||r(re,!0)},[s,r]),!a||!l)return e.jsx(Te,{});if(!n)return e.jsx(fe,{to:"/integrations",replace:!0});const u=()=>{switch(t){case"opportunity":return e.jsx(kt,{onSupport:I});case"agent-preview":return e.jsx(vt,{onSupport:I});case"review":return e.jsx(Et,{});case"setup":default:return e.jsx(Pt,{onSupport:I})}};return e.jsx(lt,{currentStage:t,maxReachableIndex:o,onNavigate:m=>r(m),onSupport:I,shopDomain:i,children:u()})};export{jo as ShopifyOnboardingPage,jo 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.