PageSourceSearch

https://app.wazappy.com/assets/OwnerCopilot-kU4JxQCT.js

js wazappy.com collected 2026-10-09 22:20:18 UTC 10,707 bytes, 1 lines download raw bytes

1import{r as d,a0 as e,ay as S,aQ as A,cu as E,cx as L,br as M,aq as W,bz as B,cc as H,bq as P,bc as $,fy as q}from"./vendor-BoZeCkxh.js";import{g as D,b as U,c as g,A as f,I,B as O}from"./index-5vXX_dOL.js";const z=["How many leads came in today?","What did Priya say about the quote?","How many orders are pending?","What are this month's sales?","Which flow is losing the most people?"];function _(){const{toast:a}=D(),{activeNumberId:c,numbers:l}=U(),[t,u]=d.useState(null),[x,m]=d.useState(!0),[n,j]=d.useState(!1),[y,v]=d.useState(!1),[h,k]=d.useState(""),o=String(c||""),p=d.useCallback(async()=>{if(!o){m(!1);return}m(!0);try{const{data:s}=await g.get(f.copilot.root,{params:{phoneId:o}});u(s?.config||null)}catch(s){a({title:"Could not load the settings",description:s?.response?.data?.error||"",variant:"destructive"})}finally{m(!1)}},[o,a]);d.useEffect(()=>{p()},[p]);const i=async s=>{if(o){j(!0);try{const{data:r}=await g.put(f.copilot.root,{phoneId:o,...s});u(r?.config||null)}catch(r){a({title:"Could not save",description:r?.response?.data?.error||"",variant:"destructive"}),p()}finally{j(!1)}}},C=()=>{const s=h.trim();if(!(!s||!t)){if((t.ownerNumbers||[]).length>=t.maxOwnerNumbers){a({title:`Up to ${t.maxOwnerNumbers} numbers`,variant:"destructive"});return}i({ownerNumbers:[...t.ownerNumbers||[],s]}),k("")}},T=async()=>{v(!0);try{const{data:s}=await g.post(f.copilot.testBrief,{phoneId:o});s?.ok?a({title:"Brief sent",description:`Delivered to ${s.sent} number${s.sent===1?"":"s"}.`}):a({title:"Not sent",description:(s?.problems||[]).join(" ")||s?.message||"Nothing to report yet.",variant:"destructive"})}catch(s){a({title:"Could not send",description:s?.response?.data?.error||"",variant:"destructive"})}finally{v(!1)}},b=l.find(s=>String(s.phoneNumberId)===o);return x?e.jsxs("div",{className:"p-6 flex items-center justify-center text-muted-foreground min-h-64",children:[e.jsx(S,{className:"h-5 w-5 animate-spin mr-2"})," Loading…"]}):!o||!t?e.jsxs("div",{className:"w-full p-4 sm:p-5 text-center py-16",children:[e.jsx(A,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-bold text-foreground mb-1",children:"Pick a number first"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The copilot is set up per WhatsApp number."})]}):e.jsxs("div",{className:"w-full p-4 sm:p-5 space-y-5",children:[e.jsx("div",{className:"flex flex-wrap items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(A,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Owner Copilot"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Message ",b?e.jsx("b",{children:b.label||b.phone}):"your own number"," and ask the account anything."]})]})]})}),e.jsxs("div",{className:"rounded-xl border border-border bg-muted/40 p-3",children:[e.jsxs("p",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(E,{className:"h-3.5 w-3.5"})," Things you can type"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Write in English, Hindi, Hinglish — whatever you use. It answers the way you asked."}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(s=>e.jsx("span",{className:"text-[11px] rounded-lg border border-border bg-background px-2 py-1 text-muted-foreground",children:s},s))})]}),e.jsxs(N,{icon:e.jsx(W,{className:"h-4 w-4"}),title:"Whose number is the owner's",hint:"Only these numbers get the copilot. Everyone else messaging this number is still treated as a customer, exactly as before.",children:[(t.ownerNumbers||[]).length===0?e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"No numbers yet."}):e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:t.ownerNumbers.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-lg border border-border bg-background pl-2.5 pr-1 h-8",children:[e.jsxs("code",{className:"text-xs font-semibold text-foreground",children:["+",s]}),e.jsx("button",{onClick:()=>i({ownerNumbers:t.ownerNumbers.filter(r=>r!==s)}),className:"h-6 w-6 rounded-md text-muted-foreground hover:text-destructive flex items-center justify-center",title:"Remove",children:e.jsx(L,{className:"h-3 w-3"})})]},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{value:h,onChange:s=>k(s.target.value),onKeyDown:s=>s.key==="Enter"&&C(),placeholder:"+91 98765 43210",className:"flex-1"}),e.jsxs(O,{onClick:C,disabled:n||!h.trim(),variant:"outline",className:"gap-1.5",children:[e.jsx(M,{className:"h-4 w-4"})," Add"]})]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:["Include the country code. Up to ",t.maxOwnerNumbers," numbers."]})]}),e.jsx(w,{on:t.enabled,disabled:n,onChange:s=>i({enabled:s}),title:"Turn the copilot on",hint:"When on, a message from one of the numbers above goes to the copilot instead of your flows and customer AI."}),e.jsx(w,{on:t.allowActions,disabled:n||!t.enabled,onChange:s=>i({allowActions:s}),title:"Let it act, not just answer",danger:t.allowActions,hint:"Off, it can read everything and change nothing. On, it can reply to customers and switch flows — but it always asks first and does nothing until you type YES."}),t.allowActions&&e.jsxs("div",{className:"-mt-1 mb-3 rounded-xl border border-amber-200 dark:border-amber-900/50 bg-amber-50 dark:bg-amber-950/20 px-3 py-2.5 flex items-start gap-2",children:[e.jsx(B,{className:"h-4 w-4 text-amber-600 shrink-0 mt-0.5"}),e.jsxs("p",{className:"text-[11px] text-amber-800 dark:text-amber-300 leading-relaxed",children:["Every action is proposed first. The copilot tells you exactly who it is about to message and what it will say, and waits for ",e.jsx("b",{children:"YES"}),'. A proposal you ignore expires after ten minutes, so an old "haan" can never set something off later. It cannot broadcast to your whole contact list from here at all.']})]}),e.jsxs(N,{icon:e.jsx(q,{className:"h-4 w-4"}),title:"Morning brief",hint:"Once a day the copilot messages you first — what happened, what is waiting, what needs you.",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(w,{inline:!0,on:t.briefEnabled,disabled:n||!t.enabled,onChange:s=>i({briefEnabled:s}),title:"Send it"}),e.jsxs("label",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:["at",e.jsx("select",{value:t.briefHour,disabled:n||!t.briefEnabled,onChange:s=>i({briefHour:Number(s.target.value)}),className:"h-8 px-2 rounded-lg border border-input bg-background text-xs focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",children:Array.from({length:24},(s,r)=>e.jsx("option",{value:r,children:String(r).padStart(2,"0")},r))}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsx("select",{value:t.briefMinute??0,disabled:n||!t.briefEnabled,onChange:s=>i({briefMinute:Number(s.target.value)}),className:"h-8 px-2 rounded-lg border border-input bg-background text-xs focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50",children:Array.from({length:12},(s,r)=>r*5).map(s=>e.jsx("option",{value:s,children:String(s).padStart(2,"0")},s))}),"your local time"]}),e.jsxs(O,{variant:"outline",size:"sm",onClick:T,disabled:y||!(t.ownerNumbers||[]).length,className:"gap-1.5 ml-auto",children:[y?e.jsx(S,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(H,{className:"h-3.5 w-3.5"}),"Send one now"]})]}),e.jsxs("div",{className:"mt-2.5 rounded-lg border border-border bg-muted/40 px-2.5 py-2 flex items-start gap-2",children:[e.jsx(P,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:"WhatsApp only lets a business start a chat within 24 hours of the other person writing. So message your business number once from your own phone — after that the brief arrives on its own each morning."})]}),t.briefLastSentOn&&e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1.5 flex items-center gap-1",children:[e.jsx($,{className:"h-3 w-3 text-emerald-600"})," Last sent ",t.briefLastSentOn]})]}),e.jsx(N,{icon:e.jsx(E,{className:"h-4 w-4"}),title:"Daily limit",hint:"A chat window invites a conversation, which is what it is for — and also how one curious afternoon becomes a bill. The counter resets every day.",children:e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(I,{t
1ype:"number",min:10,max:1e3,value:t.dailyMessageCap,onChange:s=>u({...t,dailyMessageCap:Number(s.target.value)}),onBlur:()=>i({dailyMessageCap:t.dailyMessageCap}),className:"w-28"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"replies a day"}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["Used today: ",e.jsx("b",{className:"text-foreground",children:t.usedToday})]})]})}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-4",children:"Everything the copilot does is recorded in the AI Activity Log, alongside anything Claude or another connected assistant did."})]})}function N({icon:a,title:c,hint:l,children:t}){return e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3.5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-muted-foreground",children:a}),e.jsx("h2",{className:"text-sm font-bold text-foreground",children:c})]}),l&&e.jsx("p",{className:"text-[11px] text-muted-foreground mb-2.5 leading-relaxed",children:l}),t]})}function w({on:a,onChange:c,title:l,hint:t,disabled:u,danger:x,inline:m}){const n=e.jsx("button",{type:"button",role:"switch","aria-checked":!!a,disabled:u,onClick:()=>c(!a),className:`relative h-6 w-11 rounded-full transition-colors shrink-0 disabled:opacity-40 ${a?x?"bg-amber-500":"bg-emerald-500":"bg-muted-foreground/30"}`,children:e.jsx("span",{className:`absolute top-0.5 h-5 w-5 rounded-full bg-white shadow transition-all ${a?"left-[22px]":"left-0.5"}`})});return m?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[n,e.jsx("span",{className:"text-xs font-semibold text-foreground",children:l})]}):e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3.5 flex items-start gap-3",children:[n,e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-bold text-foreground",children:l}),t&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5 leading-relaxed",children:t})]})]})}export{_ 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.