1import{r as n,j as e}from"./vendor-framework-Bjre_v1e.js";import{S as Te,a as U,b as ne}from"./SuperAdminPageShell-0mwlo2EQ.js";import{S as Ae,a as De,b as Ie,c as Le,e as Pe}from"./sheet-Cx4MWPgd.js";import{c as pe,w as x}from"./index-tgcaWuQ_.js";import{L as ee}from"./label-DwLMdHNH.js";import{T as We}from"./textarea-BjvfWxjd.js";import{I as L}from"./input-CRsdQrBw.js";import{S as Q,a as Y,b as G,c as X,d as J}from"./select-bt9Lxv41.js";import{a as xe,s as Fe}from"./csv-tXd4puT8.js";import{i as Oe,d as ze,b as re,n as Ee}from"./platformPlan-BG25ZqXA.js";import{p as ue,f as ie,v as oe,W as Z,a as he,b as A,w as fe,c as V,d as I,e as Me,u as Ue,i as $e,g as H,h as Be,j as qe}from"./useSaWhatsApp-Cvle-OSX.js";import{y as B,aB as se,t as je,bM as Ke,aG as Re,af as He,bD as Qe,aq as de,U as Ye,a1 as Ge}from"./vendor-icons-CVWhOcp_.js";import{C as Xe}from"./checkbox-DUIApuY8.js";import{T as Je,a as Ze,b as P,c as W}from"./tabs-C_rpVvqj.js";import{D as be,a as ge,b as ye,c as Ne,e as ve}from"./dialog-DotgOLQm.js";import{u as Ve}from"./useAllUsers-Djdylgon.js";import{n as es}from"./phone-Bsca7oo3.js";import{d as ce}from"./format-B6x9fEpB.js";import"./vendor-jspdf-rF5n3AFh.js";import"./vendor-recharts-iVzMPvfN.js";import"./vendor-query-D5YMtxtG.js";import"./data-marketing-landers-CcSWm7Lg.js";import"./formatDistanceToNow-MOje6dsQ.js";import"./differenceInCalendarMonths-BH3Lw9A3.js";import"./en-US-CLdVey28.js";import"./endOfDay-Zvz1d385.js";import"./endOfMonth-BfkdzsJE.js";import"./addDays-B30PAnQe.js";function ss({contact:t,open:d,onOpenChange:y,sends:f,sending:h,onSend:N,onStatus:c,onFollowUp:o,extraVars:m}){const[v,r]=n.useState("cold_1"),[j,_]=n.useState(""),[i,b]=n.useState(""),g=t?ue(t.playbook_key):null,C=g==null?void 0:g.steps[(t==null?void 0:t.playbook_step)??0];n.useEffect(()=>{if(!t)return;const l=(C==null?void 0:C.templateKey)||(t.user_id?"user_360":"cold_1");r(l);const u=I[l];_(u?ie(u.body,oe(t,m)):""),b(t.next_follow_up_at?Oe(t.next_follow_up_at):"")},[t==null?void 0:t.id,t==null?void 0:t.playbook_step,t==null?void 0:t.playbook_key,m==null?void 0:m.days_left,m==null?void 0:m.plan]);const q=n.useMemo(()=>{const l=t!=null&&t.user_id?"customer":"prospect";return Object.keys(I).filter(z=>Z.some(D=>D.audience===l&&D.steps.some(E=>E.templateKey===z))||z==="user_360")},[t==null?void 0:t.user_id]);if(!t)return null;const k=he(t.next_follow_up_at),O=l=>{r(l);const u=I[l];u&&_(ie(u.body,oe(t,m)))};return e.jsx(Ae,{open:d,onOpenChange:y,children:e.jsxs(De,{className:"w-full overflow-y-auto sm:max-w-md",children:[e.jsxs(Ie,{children:[e.jsx(Le,{className:"text-[18px] leading-tight",children:t.studio_name||t.first_name||A(t.phone)}),e.jsxs(Pe,{className:"text-[12px]",children:[t.first_name?`${t.first_name} · `:"",A(t.phone),t.city?` · ${t.city}`:""]})]}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:pe("text-[10px] font-semibold px-2 py-0.5 rounded-md border",fe(t.status)),children:V[t.status]}),g&&e.jsxs("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-md border bg-secondary text-muted-foreground",children:[g.label,C?` · ${C.label}`:" · done"]}),k&&e.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-md border bg-amber-500/15 text-amber-900 border-amber-500/30",children:k})]}),(t.email||t.instagram)&&e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[t.email,t.email&&t.instagram?" · ":"",t.instagram]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground/70",children:"Message"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ee,{className:"text-[11px] text-muted-foreground",children:"Script"}),e.jsxs(Q,{value:v,onValueChange:O,children:[e.jsx(Y,{className:"h-9 text-xs",children:e.jsx(G,{})}),e.jsx(X,{children:q.map(l=>{var u;return e.jsx(J,{value:l,className:"text-xs",children:((u=I[l])==null?void 0:u.name)||l},l)})})]})]}),e.jsx(We,{value:j,onChange:l=>_(l.target.value),rows:8,className:"text-xs leading-relaxed resize-y min-h-[140px]"}),e.jsxs(x,{className:"w-full h-10 gap-1.5",disabled:!j.trim()||h,onClick:()=>{const l=j.trim(),u=Me(t.phone,l);u&&window.open(u,"_blank","noopener,noreferrer"),N(l,v)},children:[h?e.jsx(B,{className:"w-4 h-4 animate-spin"}):e.jsx(se,{className:"w-4 h-4"}),"Open WhatsApp & log"]}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"Opens WhatsApp with this text. Tap send on your phone. We log it here so follow-up does not depend on memory."})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground
1/70",children:"Outcome"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(x,{size:"sm",variant:"outline",className:"h-8 text-xs gap-1",onClick:()=>c("talking"),children:[e.jsx(je,{className:"w-3.5 h-3.5"}),"They replied"]}),e.jsx(x,{size:"sm",variant:"outline",className:"h-8 text-xs gap-1",onClick:()=>c("signed_up"),children:"Signed up"}),e.jsxs(x,{size:"sm",variant:"outline",className:"h-8 text-xs gap-1",onClick:()=>c("not_interested"),children:[e.jsx(Ke,{className:"w-3.5 h-3.5"}),"Not interested"]}),e.jsx(x,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>c("dnd"),children:"Never again"}),e.jsx(x,{size:"sm",variant:"outline",className:"h-8 text-xs",onClick:()=>c("invalid"),children:"Bad number"})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground/70",children:"Next follow-up"}),t.next_follow_up_at&&e.jsx(x,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>{b(""),o(null)},children:"Clear"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx(L,{type:"date",className:"h-9 text-xs",value:i,onChange:l=>b(l.target.value)}),e.jsx(x,{size:"sm",variant:"outline",className:"h-9 text-xs shrink-0",disabled:!i,onClick:()=>o(ze(i)),children:"Save"})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground/70",children:["Thread (",f.length,")"]}),f.length===0?e.jsx("p",{className:"text-[12px] text-muted-foreground py-3",children:"No messages logged yet."}):e.jsx("ul",{className:"space-y-2",children:f.map(l=>{var u;return e.jsxs("li",{className:"rounded-xl border border-border/60 bg-secondary/30 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-[10px] text-muted-foreground",children:[e.jsx("span",{children:l.template_key?((u=I[l.template_key])==null?void 0:u.name)||l.template_key:"Custom"}),e.jsx("span",{children:xe(l.created_at)||Fe(l.created_at)})]}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[12px] leading-relaxed text-foreground",children:l.body})]},l.id)})})]})]})]})})}const ts=[{value:"all",label:"All"},{value:"open",label:"Open"},{value:"new",label:"New"},{value:"queued",label:"Queued"},{value:"contacted",label:"Contacted"},{value:"talking",label:"Talking"},{value:"signed_up",label:"Signed up"},{value:"already_user",label:"Already users"},{value:"not_interested",label:"Stopped"}];function Ws(){const t=Ue(),{users:d}=Ve(),[y,f]=n.useState("today"),[h,N]=n.useState(""),[c,o]=n.useState("open"),[m,v]=n.useState(new Set),[r,j]=n.useState(null),[_,i]=n.useState(!1),[b,g]=n.useState(!1),[C,q]=n.useState("cold_studio"),k=h.trim().toLowerCase(),O=n.useMemo(()=>t.contacts.filter(s=>c==="open"&&!$e(s.status)||c==="not_interested"&&!["not_interested","dnd","invalid"].includes(s.status)||c!=="all"&&c!=="open"&&c!=="not_interested"&&s.status!==c?!1:k?[s.first_name,s.studio_name,s.city,s.email,s.phone,s.instagram,s.list_name].filter(Boolean).join(" ").toLowerCase().includes(k):!0),[t.contacts,c,k]),l=n.useMemo(()=>{const s=new Set;
1return t.contacts.forEach(a=>{a.city&&s.add(a.city)}),[...s].sort()},[t.contacts]),u=t.contacts.filter(s=>s.status==="talking").length,z=t.contacts.filter(s=>s.status==="signed_up").length,K=n.useMemo(()=>d.filter(s=>s.role==="admin"&&!s.teamMember&&!!es(s.phone)),[d]),D=k,E=n.useMemo(()=>K.filter(s=>D?[s.full_name,s.business_name,s.email,s.phone].filter(Boolean).join(" ").toLowerCase().includes(D):!0),[K,D]),te=n.useMemo(()=>{const s=new Map;return t.contacts.forEach(a=>{a.user_id&&s.set(a.user_id,a)}),s},[t.contacts]),we=n.useMemo(()=>new Set(t.contacts.map(s=>s.phone)),[t.contacts]),R=s=>j(s),_e=async s=>{var p;const a=s.id?te.get(s.id):null;if(a){j(a);return}try{const w=await t.upsertFromUser.mutateAsync({userId:s.id,phone:s.phone||"",email:s.email,first_name:((p=s.full_name)==null?void 0:p.split(/\s+/)[0])||null,studio_name:s.business_name});j(w)}catch(w){console.warn(w)}},Se=s=>{v(a=>{const p=new Set(a);return p.has(s)?p.delete(s):p.add(s),p})},Ce=s=>{var S;if(!s.user_id)return;const a=d.find(T=>T.id===s.user_id),p=(S=a==null?void 0:a.subscription)!=null&&S.expires_at?new Date(a.subscription.expires_at):null;return{days_left:p?ce(p,new Date):null,plan:a!=null&&a.subscription?re(a.subscription):null}},ke=t.sentToday>=H?"rose":t.sentToday>=30?"amber":"emerald";return e.jsxs(Te,{title:"WhatsApp",subtitle:"Outreach, reminders, follow-ups â one thread per photographer. You send from your phone; we remember.",actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(x,{size:"sm",variant:"outline",className:"h-9",onClick:()=>g(!0),children:[e.jsx(He,{className:"mr-1.5 h-3.5 w-3.5"}),"Add"]}),e.jsxs(x,{size:"sm",className:"h-9",onClick:()=>i(!0),children:[e.jsx(Qe,{className:"mr-1.5 h-3.5 w-3.5"}),"Import sheet"]})]}),children:[t.tableMissing&&e.jsxs("div",{className:"rounded-xl border border-amber-500/40 bg-amber-50 px-4 py-3 text-[13px] text-amber-950",children:["WhatsApp tables are not in the database yet. In Supabase SQL Editor, run"," ",e.jsx("code",{className:"rounded bg-white px-1 text-[12px]",children:"scripts/sa-whatsapp-hq-PROD-SAFE.sql"}),", then refresh this page."]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-4",children:[e.jsx(U,{label:"Due today",value:t.dueToday.length,hint:"Follow-ups waiting",tone:t.dueToday.length?"amber":"default",onClick:()=>f("today")}),e.jsx(U,{label:"Sent today",value:t.sentToday,hint:`Soft cap ${H}/day`,tone:ke}),e.jsx(U,{label:"Talking",value:u,hint:`${z} signed up`,tone:u?"emerald":"default"}),e.jsx(U,{label:"In list",value:t.contacts.length,hint:`${l.length} cities`,tone:"violet"})]}),e.jsxs(Je,{value:y,onValueChange:f,children:[e.jsxs(Ze,{className:"w-full sm:w-auto",children:[e.jsx(P,{value:"today",children:"Today"}),e.jsx(P,{value:"prospects",children:"Prospects"}),e.jsx(P,{value:"customers",children:"Customers"}),e.jsx(P,{value:"log",children:"Log"}),e.jsx(P,{value:"scripts",children:"Scripts"})]}),e.jsx(W,{value:"today",className:"mt-4 space-y-3",children:t.isLoading?e.jsx(me,{}):t.dueToday.length===0?e.jsx($,{title:"Nothing due",body:"Import your sheet, queue a cold sequence, or set a follow-up on a contact."}):e.jsx("ul",{className:"divide-y divide-border/60 overflow-hidden rounded-2xl border border-border/90 bg-card",children:t.dueToday.map(s=>e.jsx(as,{contact:s,onOpen:()=>R(s),sending:t.sendWhatsApp.isPending},s.id))})}),e.jsxs(W,{value:"prospects",className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(de,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(L,{value:h,onChange:s=>N(s.target.value),placeholder:"Search name, studio, city, phoneâ¦",className:"h-9 pl-9 text-sm"})]}),e.jsxs(Q,{value:c,onValueChange:o,children:[e.jsx(Y,{className:"h-9 w-full text-xs sm:w-40",children:e.jsx(G,{})}),e.jsx(X,{children:ts.map(s=>e.jsx(J,{value:s.value,className:"text-xs",children:s.label},s.value))})]})]}),m.size>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-xl border border-border/80 bg-secondary/40 px-3 py-2",children:[e.jsxs("span",{className:"text-[12px] font-medium",children:[m.size," selected"]}),e.jsxs(Q,{value:C,onValueChange:q,children:[e.jsx(Y,{className:"h-8 w-[200px] text-xs",children:e.jsx(G,{})}),e.jsx(X,{children:Z.filter(s=>s.audience==="prospect").map(s=>e.jsx(J,{value:s.key,className:"text-xs",children:s.label},s.key))})]}),e.jsx(x,{size:"sm",className:"h-8 text-xs",disabled:t.enroll.isPending,onClick:()=>{t.enroll.mutate({ids:[...m],playbookKey:C}),v(new Set)},children:"Queue sequence"}),e.jsx(x,{size:"sm",variant:"ghost",className:"h-8 text-xs",onClick:()=>v(new Set),children:"Clear"})]}),t.isLoading?e.jsx(me,{}):O.length===0?e.jsx($,{title:"No photographers in this view",body:"Import the verified sheet (needs a phone column) or add one contact."}):e.jsx("ul",{className:"divide-y divide-border/60 overflow-hidden rounded-2xl border border-border/90 bg-card",children:O.map(s=>e.jsxs("li",{className:"flex items-center gap-2 px-3 py-2.5 sm:px-4",children:[e.jsx(Xe,{checked:m.has(s.id),onCheckedChange:()=>Se(s.id),"aria-label":`Select ${s.studio_name||s.phone}`}),e.jsxs("button",{type:"button",className:"min-w-0 flex-1 text-left",onClick:()=>R(s),children:[e.jsx("span",{className:"block truncate text-[14px] font-medium text-foreground",children:s.studio_name||s.first_name||A(s.phone)}),e.jsxs("span",{className:"block truncate text-[12px] text-muted-foreground",children:[s.first_name?`${s.first_name} · `:"",A(s.phone),s.city?` · ${s.city}`:""]})]}),e.jsx("span",{className:pe("hidden shrink-0 rounded-md border px-1.5 py-0.5 text-[10px] font-semibold sm:inline",fe(s.status)),children:V[s.status]})]},s.id))})]}),e.jsxs(W,{value:"customers",className:"mt-4 space-y-3",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Photographers who already have a Studio Mithra account and a mobile. Use this for trial, expiry, upgrade â not the scraped list."}),e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(L,{value:h,onChange:s=>N(s.target.value),placeholder:"Search customersâ¦",className:"h-9 pl-9 text-sm"})]}),E.length===0?e.jsx($,{title:"No customers with a mobile",body:"Users without a valid +91 number cannot be WhatsApped from here."}):e.jsx("ul",{className:"divide-y divide-border/60 overflow-hidden rounded-2xl border border-border/90 bg-card",children:E.map(s=>{var T,M,ae,le;const a=te.get(s.id),p=s.subscription?re(s.subscription):"â",w=Ee((T=s.subscription)==null?void 0:T.plan_name,(M=s.subscription)==null?void 0:M.plan_type),S=(ae=s.subscription)!=null&&ae.expires_at?ce(new Date(s.subscription.expires_at),new Date):null;return e.jsxs("li",{className:"flex items-center gap-3 px-3 py-2.5 sm:px-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[14px] font-medium",children:s.business_name||s.full_name||s.email}),e.jsxs("p",{className:"truncate text-[12px] text-muted-foreground",children:[A(s.phone||"")," · ",p,S!=null?` · ${S}d`:"",a?` · ${V[a.status]}`:""]})]}),e.jsxs(x,{size:"sm",variant:"outline",className:"h-8 shrink-0 text-xs",disabled:t.upsertFromUser.isPending,onClick:()=>void _e(s),children:[e.jsx(se,{className:"mr-1 h-3.5 w-3.5"}),w==="trial"&&S!=null&&S<=7?"Trial":((le=s.subscription)==null?void 0:le.status)==="expired"?"Win-back":"Message"]})]},s.id)})})]}),e.jsx(W,{value:"log",className:"mt-4",children:t.sends.length===0?e.jsx($,{title:"No sends yet",body:"When you tap Open WhatsApp, the message is stored here."}):e.jsx("ul",{className:"divide-y divide-border/60 overflow-hidden rounded-2xl border border-border/90 bg-card",children:t.sends.slice(0,80).map(s=>{const a=t.contacts.find(p=>p.id===s.contact_id);return e.jsxs("li",{className:"px-3 py-2.5 sm:px-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{type:"button",className:"truncate text-[13px] font-medium text-left",onClick:()=>a&&R(a),children:(a==null?void 0:a.studio_name)||(a==null?void 0:a.first_name)||A((a==null?void 0:a.phone)||"")}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:xe(s.created_at)})]}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-[12px] text-muted-foreground",children:s.body})]},s.id)})})}),e.jsxs(W,{value:"scripts",className:"mt-4 space-y-3",children:[e.jsx(ne,{title:"How sending works",description:"WhatsApp will ban a number that auto-blasts scraped lists. This HQ opens the chat on your phone â you tap Send â we track the thread.",children:e.jsxs("ol",{className:"list-decimal space-y-1.5 pl-4 text-[13px] text-muted-foreground",children:[e.jsx("li",{children:"Import CSV with a phone column (10-digit Indian mobile)."}),e.jsx("li",{children:"Select a Hyderabad batch, queue âCold â wedding studiosâ."}),e.jsxs("li",{children:["Open Today. Cap around ",H," chats a day from one number."]}),e.jsx("li",{children:"If they reply, tap âThey repliedâ. Sequence stops."})]})}),Z.map(s=>e.jsx(ne,{title:s.label,description:`${s.hint} · ${s.audience}`,children:e.jsx("ol",{className:"space-y-3",children:s.steps.map((a,p)=>{var w;return e.jsxs("li",{className:"text-[13px]",children:[e.jsxs("p",{className:"font-medium text-foreground",children:[p===0?"First message":`+${a.delayDays}d`," · ",a.label]}),e.jsx("p",{className:"mt-1 whitespace-pre-wrap text-[12px] leading-relaxed text-muted-foreground",children:(w=I[a.templateKey])==null?void 0:w.body})]},a.templateKey+p)})})},s.key))]})]}),e.jsx(ss,{contact:r,open:!!r,onOpenChange:s=>{s||j(null)},sends:r?t.sendsFor(r.id):[],sending:t.sendWhatsApp.isPending,extraVars:r?
1Ce(r):void 0,onSend:(s,a)=>{if(!r)return;const p=r.id;t.sendWhatsApp.mutate({contact:r,body:s,templateKey:a},{onSuccess:()=>{t.refetch().then(w=>{var T;const S=(T=w.data)==null?void 0:T.rows.find(M=>M.id===p);S&&j(S)})}})},onStatus:s=>{r&&(t.updateStatus.mutate({id:r.id,status:s}),j({...r,status:s}))},onFollowUp:s=>{r&&t.setFollowUp.mutate({id:r.id,next_follow_up_at:s})}}),e.jsx(ls,{open:_,onOpenChange:i,pending:t.importRows.isPending,existingPhones:we.size,onImport:(s,a)=>t.importRows.mutateAsync({rows:s,listName:a})}),e.jsx(ns,{open:b,onOpenChange:g,pending:t.saveContact.isPending,onSave:s=>t.saveContact.mutateAsync(s)})]})}function me(){return e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-muted-foreground",children:[e.jsx(B,{className:"h-4 w-4 animate-spin"}),"Loadingâ¦"]})}function $({title:t,body:d}){return e.jsxs("div",{className:"rounded-2xl border border-dashed border-border px-4 py-12 text-center",children:[e.jsx(Ye,{className:"mx-auto mb-2 h-6 w-6 text-muted-foreground/50"}),e.jsx("p",{className:"text-[14px] font-medium",children:t}),e.jsx("p",{className:"mx-auto mt-1 max-w-sm text-[12px] text-muted-foreground",children:d})]})}function as({contact:t,onOpen:d,sending:y}){const f=ue(t.playbook_key),h=f==null?void 0:f.steps[t.playbook_step],N=he(t.next_follow_up_at);return e.jsxs("li",{className:"flex items-center gap-3 px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-[14px] font-medium",children:t.studio_name||t.first_name||A(t.phone)}),e.jsxs("p",{className:"truncate text-[12px] text-muted-foreground",children:[h?h.label:"Follow-up",N?` · ${N}`:"",t.city?` · ${t.city}`:""]})]}),e.jsxs(x,{size:"sm",className:"h-8 shrink-0 text-xs",disabled:y,onClick:d,children:[e.jsx(se,{className:"mr-1 h-3.5 w-3.5"}),"Open"]})]})}function ls({open:t,onOpenChange:d,pending:y,existingPhones:f,onImport:h}){const[N,c]=n.useState("Hyderabad week 1"),[o,m]=n.useState(null),[v,r]=n.useState(""),j=async i=>{if(!i)return;r(i.name);const b=await i.text();m(Be(b))},_=()=>{const i=new Blob([qe],{type:"text/csv;charset=utf-8"}),b=URL.createObjectURL(i),g=document.createElement("a");g.href=b,g.download="studiomithra-whatsapp-import.csv",g.click(),URL.revokeObjectURL(b)};return e.jsx(be,{open:t,onOpenChange:i=>{d(i),i||(m(null),r(""))},children:e.jsxs(ge,{className:"max-w-md",children:[e.jsx(ye,{children:e.jsx(Ne,{children:"Import photographers"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-[12px] text-muted-foreground leading-relaxed",children:["Need a ",e.jsx("strong",{children:"phone"})," column (10-digit Indian mobile). Email-only rows are skipped. Duplicate numbers are ignored. ",f," already in the list."]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{className:"text-[11px]",children:"List name"}),e.jsx(L,{className:"h-9 text-sm",value:N,onChange:i=>c(i.target.value),placeholder:"Hyderabad week 1"})]}),e.jsx(L,{type:"file",accept:".csv,text/csv",className:"h-9 text-xs",onChange:i=>{var b;return void j(((b=i.target.files)==null?void 0:b[0])||null)}}),v&&o&&e.jsxs("div",{className:"rounded-lg border border-border/70 bg-secondary/40 px-3 py-2 text-[12px]",children:[e.jsx("p",{className:"font-medium",children:v}),e.jsxs("p",{className:"mt-1 text-muted-foreground",children:[o.rows.length," ready · ",o.skippedNoPhone," no phone ·"," ",o.skippedInvalidPhone," invalid · ",o.skippedDuplicateInFile," dupes in file"]})]}),e.jsxs(x,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-0 text-xs",onClick:_,children:[e.jsx(Ge,{className:"mr-1 h-3.5 w-3.5"}),"Download CSV template"]})]}),e.jsxs(ve,{children:[e.jsx(x,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(x,{disabled:!(o!=null&&o.rows.length)||y,onClick:async()=>{o&&(await h(o.rows,N),d(!1))},children:[y?e.jsx(B,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(je,{className:"mr-1.5 h-3.5 w-3.5"}),"Import ",(o==null?void 0:o.rows.length)||0]})]})]})})}function ns({open:t,onOpenChange:d,pending:y,onSave:f}){const[h,N]=n.useState(""),[c,o]=n.useState(""),[m,v]=n.useState(""),[r,j]=n.useState(""),[_,i]=n.useState(""),b=()=>{N(""),o(""),v(""),j(""),i("")};return e.jsx(be,{open:t,onOpenChange:g=>{d(g),g||b()},children:e.jsxs(ge,{className:"max-w-md",children:[e.jsx(ye,{children:e.jsx(Ne,{children:"Add photographer"})}),e.jsxs("div",{className:"grid gap-2.5",children:[e.jsx(F,{label:"Mobile *",value:h,onChange:N,placeholder:"98765 43210"}),e.jsx(F,{label:"First name",value:c,onChange:o}),e.jsx(F,{label:"Studio",value:m,onChange:v}),e.jsx(F,{label:"City",value:r,onChange:j,placeholder:"Hyderabad"}
1),e.jsx(F,{label:"Email",value:_,onChange:i})]}),e.jsxs(ve,{children:[e.jsx(x,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e.jsxs(x,{disabled:!h.trim()||y,onClick:async()=>{await f({phone:h,first_name:c,studio_name:m,city:r,email:_}),d(!1)},children:[y&&e.jsx(B,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Save"]})]})]})})}function F({label:t,value:d,onChange:y,placeholder:f}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ee,{className:"text-[11px]",children:t}),e.jsx(L,{className:"h-9 text-sm",value:d,placeholder:f,onChange:h=>y(h.target.value)})]})}export{Ws 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.