PageSourceSearch

https://hearclear-rebuild-2.emergent.host/static/js/2377.c4f35fe7.chunk.js

js hearclear-rebuild-2.emergent.host collected 2026-10-03 03:23:44 UTC 24,694 bytes, 3 lines download raw bytes

1/*! For license information please see 2377.c4f35fe7.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[2377],{22377(e,t,s){s.r(t),s.d(t,{default:()=>w});var a=s(65043),l=s(87975),n=s(56328),r=s(14939),o=s(50516),i=s(78384),d=s(37719),c=s(42574),x=s(7118),m=s(44919),h=s(28646),p=s(29350),b=s(40614);const u=(0,s(77784).A)("pen-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);var g=s(88693),j=s(35087),f=s(84669),N=s(35746),v=s(70579);const w=()=>{var e,t,s,w;const[y,k]=(0,a.useState)(null),[_,C]=(0,a.useState)([]),[A,S]=(0,a.useState)([]),[I,E]=(0,a.useState)([]),[R,L]=(0,a.useState)("overview"),[M,T]=(0,a.useState)(""),[D,F]=(0,a.useState)(null),[O,B]=(0,a.useState)("919999999999"),[W,P]=(0,a.useState)(!1),[q,H]=(0,a.useState)("all"),[V,z]=(0,a.useState)(null),[U,G]=(0,a.useState)(""),[Q,J]=(0,a.useState)(null),[K,X]=(0,a.useState)([]),[Y,Z]=(0,a.useState)(null),[$,ee]=(0,a.useState)(!1),te=(0,a.useCallback)(async()=>{P(!0);try{const[e,t,s,a,n]=await Promise.all([l.nC.get("/whatsapp-bot/stats"),l.nC.get("/whatsapp-bot/conversations?limit=50"),l.nC.get("/whatsapp-bot/logs?limit=100"),l.nC.get("/whatsapp-bot/flows"),l.nC.get("/whatsapp-bot/appointments?limit=20")]);k(e.data),C(t.data.conversations||[]),S(s.data.logs||[]),E(a.data.flows||[]),X(n.data.appointments||[])}catch(e){console.error("Error:",e)}P(!1)},[]),se=(0,a.useCallback)(async()=>{ee(!0);try{const e=await l.nC.get("/whatsapp-bot/diagnostics");Z(e.data)}catch(s){var e,t;Z({error:(null===s||void 0===s||null===(e=s.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"diagnostics failed"})}ee(!1)},[]);(0,a.useEffect)(()=>{te(),se()},[te,se]);const ae=async()=>{if(M.trim())try{const e=await l.nC.post("/whatsapp-bot/test-flow?message=".concat(encodeURIComponent(M),"&phone=").concat(O));F(e.data)}catch(e){n.oR.error("Test failed")}},le={price_quote:"Price Quote",home_visit:"Home Visit",emi_options:"EMI Options",expert_advice:"Expert Advice",find_aid:"Find Aid",order_status:"Track Order",book_appointment:"Book Appointment",callback:"Callback",greeting:"Greeting",details_received:"Details Received",appointment_booked:"Appt Booked",coupon_offer:"Coupon Offer"},ne={price_quote:"bg-blue-50 border-blue-200",home_visit:"bg-green-50 border-green-200",emi_options:"bg-amber-50 border-amber-200",expert_advice:"bg-purple-50 border-purple-200",find_aid:"bg-indigo-50 border-indigo-200",order_status:"bg-slate-50 border-slate-200",book_appointment:"bg-teal-50 border-teal-200",callback:"bg-red-50 border-red-200",greeting:"bg-emerald-50 border-emerald-200",details_received:"bg-cyan-50 border-cyan-200",appointment_booked:"bg-lime-50 border-lime-200",coupon_offer:"bg-orange-50 border-orange-200"},re="all"===q?A:A.filter(e=>e.direction===q);return(0,v.jsxs)("div",{className:"space-y-5","data-testid":"whatsapp-chatbot-dashboard",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between",children:[(0,v.jsxs)("div",{children:[(0,v.jsxs)("h1",{className:"text-2xl font-bold text-slate-900 flex items-center gap-2",children:[(0,v.jsx)(r.A,{className:"h-7 w-7 text-green-600"}),"WhatsApp AI Chatbot"]}),(0,v.jsx)("p",{className:"text-sm text-slate-500 mt-1",children:"AI-powered sales engine with auto appointment booking"})]}),(0,v.jsxs)("button",{onClick:te,disabled:W,className:"flex items-center gap-2 px-4 py-2 bg-slate-100 hover:bg-slate-200 rounded-lg text-sm font-medium","data-testid":"refresh-btn",children:[(0,v.jsx)(o.A,{className:"h-4 w-4 ".concat(W?"animate-spin":"")})," Refresh"]})]}),(0,v.jsxs)("div",{"data-testid":"wa-health-banner",children:[$&&!Y&&(0,v.jsxs)("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-3 text-sm text-slate-500 flex items-center gap-2",children:[(0,v.jsx)(o.A,{className:"h-4 w-4 animate-spin"})," Checking WhatsApp pipeline health\u2026"]}),Y&&Y.healthy&&(0,v.jsxs)("div",{className:"bg-emerald-50 border border-emerald-200 rounded-lg p-3 text-sm text-emerald-700 flex items-center gap-2","data-testid":"wa-health-ok",children:[(0,v.jsx)(i.A,{className:"h-4 w-4"}),"WhatsApp pipeline is healthy.",null!=(null===(e=Y.checks)||void 0===e?void 0:e.last_incoming_age_hours)&&(0,v.jsxs)("span",{className:"text-emerald-600 ml-2",children:["Last incoming: ",Y.checks.last_incoming_age_hours,"h ago"]}),(0,v.jsx)("button",{onClick:se,className:"ml-auto text-xs underline",children:"recheck"})]}),Y&&!Y.healthy&&(0,v.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4","data-testid":"wa-health-fail",children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)(d.A,{className:"h-5 w-5 text-red-600 flex-shrink-0 mt-0.5"}),(0,v.jsxs)("div",{className:"flex-1",children:[(0,v.jsxs)("p",{className:"font-semibold text-red-800 text-sm",children:["WhatsApp inbound pipeline is DEGRADED",null!=(null===(t=Y.checks)||void 0===t?void 0:t.last_incoming_age_hours)&&(0,v.jsxs)("span",{className:"text-red-600 ml-2 font-normal",children:["\xb7 No incoming for ",Y.checks.last_incoming_age_hours,"h"]})]}),(0,v.jsx)("ul",{className:"mt-2 space-y-1 text-sm text-red-700 list-disc pl-5",children:(Y.issues||[]).map((e,t)=>(0,v.jsx)("li",{children:e},t))}),(0,v.jsxs)("details",{className:"mt-3 text-xs text-red-800",children:[(0,v.jsxs)("summary",{className:"cursor-pointer font-medium",children:["Show raw diagnostics (",Object.keys(Y.checks||{}).length," checks)"]}),(0,v.jsx)("pre",{className:"mt-2 bg-white/70 p-2 rounded overflow-x-auto max-h-64 text-[10px]",children:JSON.stringify(Y.checks,null,2)})]}),(0,v.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,v.jsxs)("button",{onClick:se,disabled:$,"data-testid":"wa-recheck-btn",className:"text-xs px-3 py-1 rounded bg-red-600 hover:bg-red-700 text-white font-medium inline-flex items-center gap-1",children:[(0,v.jsx)(o.A,{className:"h-3 w-3 ".concat($?"animate-spin":"")})," Re-run check"]}),(0,v.jsx)("a",{href:"https://business.facebook.com/wa/manage/phone-numbers",target:"_blank",rel:"noreferrer",className:"text-xs px-3 py-1 rounded border border-red-300 hover:bg-red-100 text-red-700 font-medium",children:"Meta Business Suite \u2197"}),(0,v.jsx)("button",{onClick:async()=>{try{const e=await l.nC.post("/whatsapp-bot/subscribe-waba");n.oR.success("Subscribe attempted \u2014 check diagnostics"),console.log("subscribe-waba",e.data),se()}catch(e){n.oR.error("Subscribe failed")}},"data-testid":"wa-subscribe-btn",className:"text-xs px-3 py-1 rounded border border-red-300 hover:bg-red-100 text-red-700 font-medium",children:"Try auto-subscribe WABA"})]})]})]})})]}),y&&(0,v.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
2p-3","data-testid":"stats-cards",children:[{label:"Messages",value:y.total_messages,sub:"Total tracked",icon:c.A,color:"text-blue-600"},{label:"Conversations",value:y.total_conversations,sub:"Active chats",icon:x.A,color:"text-slate-600"},{label:"Bot Leads",value:y.total_leads,sub:"From chatbot",icon:m.A,color:"text-green-600"},{label:"Appointments",value:y.appointments_booked,sub:"Auto-booked",icon:h.A,color:"text-teal-600"},{label:"Coupons Sent",value:y.coupons_sent,sub:"Sales push",icon:p.A,color:"text-orange-600"}].map(e=>(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl p-4",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-slate-500 text-xs mb-1",children:[(0,v.jsx)(e.icon,{className:"h-3.5 w-3.5 ".concat(e.color)})," ",e.label]}),(0,v.jsx)("p",{className:"text-xl font-bold text-slate-900",children:e.value}),(0,v.jsx)("p",{className:"text-xs text-slate-400 mt-0.5",children:e.sub})]},e.label))}),(null===y||void 0===y?void 0:y.flow_distribution)&&(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl p-4","data-testid":"flow-distribution",children:[(0,v.jsx)("h3",{className:"font-semibold text-slate-900 text-sm mb-2",children:"Leads by Flow"}),(0,v.jsx)("div",{className:"grid grid-cols-4 md:grid-cols-8 gap-2",children:Object.entries(y.flow_distribution).map(e=>{let[t,s]=e;return(0,v.jsxs)("div",{className:"bg-slate-50 rounded-lg p-2 text-center",children:[(0,v.jsx)("p",{className:"text-xs text-slate-500 truncate",children:le[t]||t}),(0,v.jsx)("p",{className:"text-lg font-bold text-slate-900",children:s})]},t)})})]}),(0,v.jsx)("div",{className:"flex gap-1 bg-slate-100 p-1 rounded-lg overflow-x-auto",children:[{id:"overview",label:"Overview"},{id:"flows",label:"Flow Editor"},{id:"conversations",label:"Conversations"},{id:"appointments",label:"Appointments"},{id:"logs",label:"Logs"},{id:"test",label:"Test Bot"}].map(e=>(0,v.jsx)("button",{onClick:()=>L(e.id),className:"px-3 py-2 rounded-md text-sm font-medium whitespace-nowrap transition-colors ".concat(R===e.id?"bg-white text-slate-900 shadow-sm":"text-slate-600 hover:text-slate-900"),"data-testid":"tab-".concat(e.id),children:e.label},e.id))}),"overview"===R&&(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl p-5","data-testid":"overview-tab",children:[(0,v.jsx)("h3",{className:"font-semibold text-slate-900 mb-3",children:"AI Chatbot Features"}),(0,v.jsx)("div",{className:"grid md:grid-cols-2 gap-3",children:[{title:"AI-Powered Responses",desc:"Trained on all HearClear products, clinics, hearing care knowledge. Answers any question intelligently.",color:"border-blue-200 bg-blue-50"},{title:"Auto Appointment Booking",desc:"Automatically books clinic/home visits when user provides details. Creates appointment in system.",color:"border-green-200 bg-green-50"},{title:"Product Recommendations",desc:"Suggests specific products with prices, features, and direct links based on user needs.",color:"border-purple-200 bg-purple-50"},{title:"Discount Coupons",desc:"Offers WABOT10, WELCOME10, SENIOR15, FLAT5000 coupons to drive conversions.",color:"border-orange-200 bg-orange-50"},{title:"Lead Capture + CRM",desc:"Every interaction captures leads with source, intent, city. Admin notified instantly.",color:"border-teal-200 bg-teal-50"},{title:"Editable Flow Messages",desc:"All bot messages editable from Flow Editor tab. Customize responses without code changes.",color:"border-amber-200 bg-amber-50"}].map(e=>(0,v.jsxs)("div",{className:"border rounded-lg p-3 ".concat(e.color),children:[(0,v.jsx)("p",{className:"font-medium text-slate-900 text-sm",children:e.title}),(0,v.jsx)("p",{className:"text-xs text-slate-600 mt-1",children:e.desc})]},e.title))}),(0,v.jsxs)("div",{className:"mt-4 p-3 bg-amber-50 border border-amber-200 rounded-lg",children:[(0,v.jsx)("h4",{className:"font-medium text-amber-800 text-sm mb-1",children:"Webhook Setup"}),(0,v.jsx)("code",{className:"block p-2 bg-white rounded text-xs font-mono border",children:"https://hearclear.in/api/whatsapp-bot/webhook"}),(0,v.jsx)("p",{className:"text-xs text-amber-600 mt-1",children:"Configure your WhatsApp Business API to POST incoming messages here."})]})]}),"flows"===R&&(0,v.jsxs)("div",{className:"space-y-3","data-testid":"flows-tab",children:[(0,v.jsx)("p",{className:"text-sm text-slate-500",children:"Edit chatbot messages. Changes apply immediately to all conversations."}),I.map(e=>(0,v.jsx)("div",{className:"border rounded-xl overflow-hidden ".concat(ne[e.id]||"bg-white border-slate-200"),children:(0,v.jsxs)("div",{className:"p-4",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"font-semibold text-slate-900 text-sm",children:e.name||le[e.id]||e.id}
2),e.is_ai&&(0,v.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded",children:"AI"}),e.sub_flow&&(0,v.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-purple-100 text-purple-700 rounded",children:"Sub-options"}),e.collects_details&&(0,v.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-green-100 text-green-700 rounded",children:"Collects Details"}),e.creates_lead&&(0,v.jsx)("span",{className:"text-xs px-1.5 py-0.5 bg-red-100 text-red-700 rounded",children:"Creates Lead"})]}),(0,v.jsx)("button",{onClick:()=>{V===e.id?z(null):(z(e.id),G(e.message))},className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium rounded-lg bg-white border hover:bg-slate-50 transition-colors","data-testid":"edit-flow-".concat(e.id),children:V===e.id?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(b.A,{className:"h-3 w-3"})," Cancel"]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(u,{className:"h-3 w-3"})," Edit"]})})]}),e.trigger&&(0,v.jsxs)("p",{className:"text-xs text-slate-500 mb-2",children:["Triggers: ",(0,v.jsx)("span",{className:"font-mono",children:e.trigger})]}),V===e.id?(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)("textarea",{value:U,onChange:e=>G(e.target.value),rows:Math.min(15,U.split("\n").length+2),className:"w-full p-3 border border-slate-300 rounded-lg text-sm font-mono bg-white focus:border-green-500 focus:ring-2 focus:ring-green-200 outline-none","data-testid":"edit-textarea-".concat(e.id)}),(0,v.jsxs)("div",{className:"flex gap-2",children:[(0,v.jsxs)("button",{onClick:()=>(async e=>{try{await l.nC.put("/whatsapp-bot/flows/".concat(e),{message:U}),n.oR.success('Flow "'.concat(e,'" updated!')),z(null),te()}catch(t){n.oR.error("Save failed")}})(e.id),className:"flex items-center gap-1 px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium","data-testid":"save-flow-".concat(e.id),children:[(0,v.jsx)(g.A,{className:"h-3.5 w-3.5"})," Save Changes"]}),(0,v.jsx)("button",{onClick:()=>z(null),className:"px-4 py-2 bg-slate-100 hover:bg-slate-200 rounded-lg text-sm font-medium",children:"Cancel"})]})]}):(0,v.jsx)("pre",{className:"whitespace-pre-wrap text-sm text-slate-700 bg-white/50 rounded-lg p-3 border border-white/80 max-h-48 overflow-y-auto",children:e.message})]})},e.id))]}),"conversations"===R&&(0,v.jsxs)("div",{className:"space-y-3","data-testid":"conversations-tab",children:[Q&&(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl p-4",children:[(0,v.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,v.jsxs)("h3",{className:"font-semibold text-sm",children:["Chat: ",Q.phone]}),(0,v.jsx)("button",{onClick:()=>J(null),className:"text-slate-400 hover:text-slate-600",children:(0,v.jsx)(b.A,{className:"h-4 w-4"})})]}),(0,v.jsxs)("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:[(Q.history||[]).map((e,t)=>(0,v.jsx)("div",{className:"flex ".concat("user"===e.role?"justify-start":"justify-end"),children:(0,v.jsxs)("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-sm ".concat("user"===e.role?"bg-slate-100 text-slate-800":"bg-green-100 text-green-900"),children:[(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:e.text}),(0,v.jsx)("p",{className:"text-xs opacity-50 mt-1",children:e.at?new Date(e.at).toLocaleTimeString("en-IN"):""})]})},t)),(!Q.history||0===Q.history.length)&&(0,v.jsx)("p",{className:"text-center text-slate-400 text-sm py-4",children:"No messages yet"})]})]}),(0,v.jsx)("div",{className:"bg-white border border-slate-200 rounded-xl overflow-hidden",children:(0,v.jsxs)("table",{className:"w-full text-sm",children:[(0,v.jsx)("thead",{className:"bg-slate-50 border-b",children:(0,v.jsxs)("tr",{children:[(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Phone"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Flow"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"State"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"City"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Messages"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Updated"}),(0,v.jsx)("th",{className:"p-3"})]})}),(0,v.jsx)("tbody",{children:_.map((e,t)=>{var s;return(0,v.jsxs)("tr",{className:"border-b hover:bg-slate-50",children:[(0,v.jsx)("td",{className:"p-3 font-mono text-xs",children:e.phone}),(0,v.jsx)("td",{className:"p-3",children:(0,v.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(e.flow?"bg-green-100 text-green-700":"bg-slate-100 text-slate-500"),children:le[e.flow]||e.flow||"None"})}),(0,v.jsx)("td",{className:"p-3",children:(0,v.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs ".concat("complete"===e.state?"bg-green-100 text-green-700":"ai_conversation"===e.state?"bg-blue-100 text-blue-700":"awaiting_details"===e.state?"bg-amber-100 text-amber-700":"bg-slate-100 text-slate-500"),children:e.state||"initial"})}),(0,v.jsx)("td",{className:"p-3 text-slate-600",children:e.city||"-"}),(0,v.jsx)("td",{className:"p-3 text-slate-600",children:(null===(s=e.history)||void 0===s?void 0:s.length)||0}),(0,v.jsx)("td",{className:"p-3 text-xs text-slate-400",children:e.updated_at?new Date(e.updated_at).toLocaleStr
2ing("en-IN",{dateStyle:"short",timeStyle:"short"}):"-"}),(0,v.jsx)("td",{className:"p-3",children:(0,v.jsx)("button",{onClick:()=>(async e=>{try{const t=await l.nC.get("/whatsapp-bot/conversations/".concat(e));J(t.data.conversation)}catch(t){n.oR.error("Failed to load conversation")}})(e.phone),className:"p-1 hover:bg-slate-100 rounded",title:"View chat",children:(0,v.jsx)(j.A,{className:"h-4 w-4 text-slate-400"})})})]},t)})})]})})]}),"appointments"===R&&(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl overflow-hidden","data-testid":"appointments-tab",children:[(0,v.jsx)("div",{className:"p-4 border-b bg-slate-50",children:(0,v.jsx)("h3",{className:"font-semibold text-sm text-slate-900",children:"Auto-Booked Appointments (via Chatbot)"})}),(0,v.jsxs)("table",{className:"w-full text-sm",children:[(0,v.jsx)("thead",{className:"bg-slate-50 border-b",children:(0,v.jsxs)("tr",{children:[(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Phone"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Type"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Date"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Time"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"City"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Status"}),(0,v.jsx)("th",{className:"text-left p-3 font-medium text-slate-600",children:"Created"})]})}),(0,v.jsxs)("tbody",{children:[K.map((e,t)=>(0,v.jsxs)("tr",{className:"border-b hover:bg-slate-50",children:[(0,v.jsx)("td",{className:"p-3 font-mono text-xs",children:e.phone}),(0,v.jsx)("td",{className:"p-3",children:(0,v.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat("home"===e.appointment_type?"bg-green-100 text-green-700":"virtual"===e.appointment_type?"bg-blue-100 text-blue-700":"bg-slate-100 text-slate-600"),children:e.appointment_type||"clinic"})}),(0,v.jsx)("td",{className:"p-3",children:e.preferred_date}),(0,v.jsx)("td",{className:"p-3",children:e.preferred_time}),(0,v.jsx)("td",{className:"p-3",children:e.city||"-"}),(0,v.jsx)("td",{className:"p-3",children:(0,v.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs ".concat("confirmed"===e.status?"bg-green-100 text-green-700":"bg-amber-100 text-amber-700"),children:e.status||"pending"})}),(0,v.jsx)("td",{className:"p-3 text-xs text-slate-400",children:e.created_at?new Date(e.created_at).toLocaleString("en-IN",{dateStyle:"short",timeStyle:"short"}):"-"})]},t)),0===K.length&&(0,v.jsx)("tr",{children:(0,v.jsx)("td",{colSpan:7,className:"p-8 text-center text-slate-400",children:"No appointments booked yet"})})]})]})]}),"logs"===R&&(0,v.jsxs)("div",{className:"space-y-3","data-testid":"logs-tab",children:[(0,v.jsx)("div",{className:"flex gap-2",children:["all","incoming","outgoing"].map(e=>(0,v.jsx)("button",{onClick:()=>H(e),className:"px-3 py-1.5 rounded-lg text-xs font-medium ".concat(q===e?"bg-slate-900 text-white":"bg-slate-100 text-slate-600"),children:"all"===e?"All":e.charAt(0).toUpperCase()+e.slice(1)},e))}),(0,v.jsx)("div",{className:"bg-white border border-slate-200 rounded-xl overflow-hidden max-h-[500px] overflow-y-auto",children:re.map((e,t)=>(0,v.jsxs)("div",{className:"p-3 border-b text-sm flex gap-3 ".concat("incoming"===e.direction?"bg-white":"coupon_sent"===e.direction?"bg-orange-50":"bg-green-50"),children:[(0,v.jsx)("div",{className:"w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ".concat("incoming"===e.direction?"bg-blue-100":"coupon_sent"===e.direction?"bg-orange-100":"bg-green-100"),children:"incoming"===e.direction?(0,v.jsx)(f.A,{className:"h-3.5 w-3.5 text-blue-600"}):"coupon_sent"===e.direction?(0,v.jsx)(p.A,{className:"h-3.5 w-3.5 text-orange-600"}):(0,v.jsx)(N.A,{className:"h-3.5 w-3.5 text-green-600"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,v.jsx)("span",{className:"font-mono text-xs text-slate-500",children:e.from_phone||e.to_phone||"-"}),(0,v.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs ".concat("sent"===e.status?"bg-green-100 text-green-700":"failed"===e.status?"bg-red-100 text-red-700":"bg-slate-100 text-slate-500"),children:e.status||e.direction})]}),(0,v.jsx)("p",{className:"text-slate-700 text-xs line-clamp-2",children:e.message}),(0,v.jsx)("p",{className:"text-xs text-slate-400 mt-0.5",children:e.created_at?new Date(e.created_at).toLocaleStr
2ing("en-IN"):"-"})]})]},t))})]}),"test"===R&&(0,v.jsxs)("div",{className:"bg-white border border-slate-200 rounded-xl p-5 space-y-4","data-testid":"test-tab",children:[(0,v.jsxs)("div",{children:[(0,v.jsx)("h3",{className:"font-semibold text-slate-900",children:"Test AI Chatbot"}),(0,v.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Simulate conversations. AI responses are live (uses LLM for non-menu queries)."})]}),(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"flex-1",children:(0,v.jsx)("input",{type:"text",value:M,onChange:e=>T(e.target.value),onKeyDown:e=>"Enter"===e.key&&ae(),placeholder:"Type: 'hi', '1', 'What's the best hearing aid under 1 lakh?'...",className:"w-full px-4 py-2.5 rounded-lg border border-slate-200 focus:border-green-500 focus:ring-2 focus:ring-green-200 outline-none text-sm","data-testid":"test-message-input"})}),(0,v.jsx)("input",{type:"text",value:O,onChange:e=>B(e.target.value),className:"w-32 px-3 py-2.5 rounded-lg border border-slate-200 outline-none text-xs",placeholder:"Phone"}),(0,v.jsxs)("button",{onClick:ae,className:"px-5 py-2.5 bg-green-600 hover:bg-green-700 text-white rounded-lg font-medium flex items-center gap-2 text-sm","data-testid":"test-send-btn",children:[(0,v.jsx)(N.A,{className:"h-4 w-4"})," Send"]})]}),D&&(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsxs)("span",{className:"text-xs px-2 py-1 bg-slate-100 rounded-full",children:["Flow: ",(null===(s=D.conversation_state)||void 0===s?void 0:s.flow)||"none"]}),(0,v.jsxs)("span",{className:"text-xs px-2 py-1 bg-slate-100 rounded-full",children:["State: ",(null===(w=D.conversation_state)||void 0===w?void 0:w.state)||"initial"]})]}),(0,v.jsxs)("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:[(0,v.jsxs)("p",{className:"text-xs font-medium text-green-700 mb-2 flex items-center gap-1",children:[(0,v.jsx)(r.A,{className:"h-3 w-3"})," Bot Response:"]}),(0,v.jsx)("pre",{className:"whitespace-pre-wrap text-sm text-slate-800 font-sans",children:D.response})]})]}),(0,v.jsxs)("div",{className:"pt-3 border-t",children:[(0,v.jsx)("p",{className:"text-xs text-slate-500 mb-2",children:"Quick tests:"}),(0,v.jsx)("div",{className:"flex flex-wrap gap-2",children:["hi","1","2","3","4","5","6","7","8","menu","What hearing aid is best under 1 lakh?","I have mild hearing loss, what do you recommend?","Do you have clinics in Delhi?","I want to book appointment tomorrow 3pm","My number is 9876543210, I am in Noida"].map(e=>(0,v.jsx)("button",{onClick:()=>T(e),className:"px-2.5 py-1 bg-slate-100 hover:bg-slate-200 rounded-full text-xs text-slate-600",children:e.length>30?e.slice(0,30)+"...":e},e))})]})]})]})}},88693(e,t,s){s.d(t,{A:()=>a});const a=(0,s(77784).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])}}]);
3//# sourceMappingURL=2377.c4f35fe7.chunk.js.map

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.