1import{K as as,_ as Oe,a5 as Ee,r as g,a as te,a6 as A,aX as fe,j as e,a4 as E,C as v,b as S,d as P,s as B,f as z,h as He,e as f,o as J,D as V,B as o,q as is,ar as Xe,aD as es,ak as we,al as be,am as Ne,an as ye,ao as Fe,a_ as Ce,a$ as w,b0 as b,b1 as N,b2 as y,aF as q,b3 as R,aq as Se,V as ve,b8 as m,a7 as C,bf as Pe,N as ns,u as rs,L as ls,z as os,b6 as pe,X as cs,aY as je,Q as oe,x as Ue,ad as ds,aE as ms,$ as ce,a0 as de,a1 as me,a2 as xe,a3 as x,J as xs,S as ze,E as us,au as hs,Z as Je,cV as gs,k as ps,l as js,b5 as vs,m as fs,bU as ws,ap as Ve,bj as bs,aN as Ns,U as ys,bg as Cs}from"./index-CuSEeJFb.js";import{T as Ss,a as Ps,b as X,c as ee}from"./tabs-CcPOXtvT.js";import{P as ue}from"./progress-B2eMqtVV.js";import{f as Te}from"./formatDistanceToNow-JmSQUCLK.js";import{A as Rs}from"./ai-credit-costs-wxLAjEq7.js";import{L as Qe}from"./link-2-B6OMy1mi.js";import{M as Is}from"./map-pin-DOxfmRxb.js";import{P as ks}from"./pen-line-Ys7SVokk.js";import{C as Ae}from"./code-CIzDqzq1.js";import{C as Ke}from"./copy-Ctw93tQ7.js";import"./constructNow-CAQUuh76.js";import"./en-US-BOoww7nS.js";import"./differenceInCalendarMonths-CdYt3YUn.js";import"./endOfDay-CTvcx9iE.js";import"./endOfMonth-DMtDxPW7.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const As=as("MessageSquareHeart",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M14.8 7.5a1.84 1.84 0 0 0-2.6 0l-.2.3-.3-.3a1.84 1.84 0 1 0-2.4 2.8L12 13l2.7-2.7c.9-.9.8-2.1.1-2.8",key:"1blaws"}]]),se={google_my_business:{name:"Google My Business",icon:"ð",description:"Import reviews from your Google Business Profile with full review text and ratings.",authType:"oauth",color:"bg-blue-500",features:["Full review text","Customer photos","Multiple locations","Real-time sync"],limitations:["Requires Google Business Profile","OAuth setup required"]},facebook:{name:"Facebook Pages",icon:"ð",description:"Connect your Facebook business page to import ratings and limited review data.",authType:"oauth",color:"bg-blue-600",features:["Page ratings","Aggregate data","Page insights","Multiple pages"],limitations:["Limited review text access","Facebook approval required"]},instagram:{name:"Instagram Business",icon:"ð¸",description:"Connect your Instagram Business account to manage comments and engagement.",authType:"oauth",color:"bg-gradient-to-r from-purple-500 to-pink-500",features:["Comment management","Engagement insights","Story mentions","Business account data"],limitations:["Requires Instagram Business account","Connected to Facebook Page"]},yelp:{name:"Yelp",icon:"â",description:"Import business information and sample reviews from your Yelp business page.",authType:"api_key",color:"bg-red-500",features:["Business info","Sample reviews","Rating data","Category information"],limitations:["Only 3 reviews per API call","API key required"]},wordpress:{name:"WordPress",icon:"ð",description:"Connect your WordPress site to import comments and testimonials as reviews.",authType:"api_key",color:"bg-blue-800",features:["Comment import","Testimonial sync","Custom post types","WooCommerce reviews"],limitations:["Requires Application Password","WordPress 5.6+ required"]},linkedin:{name:"LinkedIn",icon:"ð¼",description:"Connect your LinkedIn Company Page to manage recommendations and engagement.",authType:"oauth",color:"bg-blue-700",features:["Company page access","Recommendations","Post engagement","Follower insights"],limitations:["Requires LinkedIn Company Page","OAuth setup required"]}},Fs=m.object({apiKey:m.string().min(1,"API key is required"),businessId:m.string().min(1,"Business ID is required")}),Ts=m.object({siteUrl:m.string().url("Please enter a valid URL").min(1,"Site URL is required"),username:m.string().min(1,"Username is required"),applicationPassword:m.string().min(1,"Application Password is required")});function Os(){const{toast:c}=Oe(),r=Ee(),[n,ae]=g.useState(null),[Y,F]=g.useState(!1),[T,Q]=g.useState(null),[I,M]=g.useState(null),{data:p=[],isLoading:K}=te({queryKey:["/api/review-import/integrations"],refetchInterval:3e4}),Z=A({mutationFn:async t=>C("/api/review-import/test-connection",{method:"POST",body:JSON.stringify(t)}),onSuccess:(t,h)=>{t.success?c({title:"Connection Successful",description:t.message}):c({title:"Connection Failed",description:t.message,variant:"destructive"}),Q(null)},onError:t=>{c({title:"Connection Test Failed",description:t.message||"Failed to test c
6onnection",variant:"destructive"}),Q(null)}}),L=A({mutationFn:async t=>se[t.platform].authType==="oauth"?C(`/api/review-import/${t.platform}/oauth/start`,{method:"POST",body:JSON.stringify({redirectUri:`${window.location.origin}/integrations/callback/${t.platform}`})}):C("/api/review-import/integrations",{method:"POST",body:JSON.stringify({platform:t.platform,displayName:`${se[t.platform].name} Integration`,apiKey:t.apiKey,businessId:t.businessId,config:{authMethod:"api_key"}})}),onSuccess:(t,h)=>{se[h.platform].authType==="oauth"?window.location.href=t.authUrl:(r.invalidateQueries({queryKey:["/api/review-import/integrations"]}),F(!1),M(null),c({title:"Platform Connected",description:`Successfully connected to ${se[h.platform].name}`}))},onError:t=>{M(null),c({title:"Connection Failed",description:t.message||"Failed to connect platform",variant:"destructive"})}}),k=A({mutationFn:async t=>C(`/api/review-import/integrations/${t}`,{method:"DELETE"}),onSuccess:()=>{r.invalidateQueries({queryKey:["/api/review-import/integrations"]}),c({title:"Platform Disconnected",description:"Successfully disconnected platform integration"})},onError:t=>{c({title:"Disconnect Failed",description:t.message||"Failed to disconnect platform",variant:"destructive"})}}),D=fe({resolver:Pe(Fs),defaultValues:{apiKey:"",businessId:""}}),W=fe({resolver:Pe(Ts),defaultValues:{siteUrl:"",username:"",applicationPassword:""}}),_=t=>p.find(h=>h.platform===t),ie=t=>{switch(t){case"active":return"text-green-600 bg-green-100";case"error":return"text-red-600 bg-red-100";case"paused":return"text-yellow-600 bg-yellow-100";default:return"text-gray-600 bg-gray-100"}},ne=t=>{ae(t),M(t),se[t].authType==="api_key"?(F(!0),M(null)):L.mutate({platform:t})},i=t=>{Q(t.platform),Z.mutate({platform:t.platform,businessId:t.businessId})},u=t=>{M("yelp"),L.mutate({platform:"yelp",apiKey:t.apiKey,businessId:t.businessId})},G=t=>{M("wordpress"),L.mutate({platform:"wordpress",apiKey:`${t.username}:${t.applicationPassword}`,businessId:t.siteUrl})};return K?e.jsxs("div",{className:"flex items-center justify-center p-8","data-testid":"loading-connections",children:[e.jsx(E,{className:"h-8 w-8 animate-spin"}),e.jsx("span",{className:"ml-2",children:"Loading platform connections..."})]}):e.jsxs("div",{className:"space-y-6","data-testid":"review-platform-connections",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Review Platform Connections"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Connect your review platforms to import and manage customer reviews."})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Object.entries(se).map(([t,h])=>{var a;const d=_(t),O=!!d;return e.jsxs(v,{className:"relative","data-testid":`platform-card-${t}`,children:[e.jsx(S,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-lg ${h.color} flex items-center justify-center text-white text-xl`,children:h.icon}),e.jsxs("div",{children:[e.jsx(P,{className:"text-lg",children:h.name}),e.jsx(B,{className:O?ie(d.syncStatus):"bg-gray-100 text-gray-600","data-testid":`status-${t}`,children:O?e.jsxs(e.Fragment,{children:[d.syncStatus==="active"&&e.jsx(z,{className:"w-3 h-3 mr-1"}),d.syncStatus==="error"&&e.jsx(He,{className:"w-3 h-3 mr-1"}),d.syncStatus.toUpperCase()]}):"Not Connected"})]})]})})}),e.jsxs(f,{className:"space-y-4",children:[e.jsx(J,{children:h.description}),O&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:"Reviews"}),e.jsx("span",{className:"font-medium","data-testid":`review-count-${t}`,children:d.totalReviews})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:"Average Rating"}),e.jsxs("div",{className:"flex items-center","data-testid":`rating-${t}`,children:[e.jsx(V,{className:"w-4 h-4 fill-yellow-400 text-yellow-400 mr-1"}),e.jsx("span",{className:"font-medium",children:((a=d.averageRating)==null?void 0:a.toFixed(1))||"N/A"})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600",children:"Last Sync"}),e.jsx("span",{className:"text-gray-500","data-testid":`last-sync-${t}`,children:d.lastSyncedAt?Te(new Date(d.lastSyncedAt),{addSuffix:!0}):"Never"})]}),d.errorMessage&&e.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("p",{className:"text-sm text-red-600","data-testid":`error-${t}`,children:d.errorMessage})})]}),!O&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-sm text-gray-600",children:[e.jsx("div",{className:"font-medium mb-1",children:"Features:"}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:h.features.map((H,U)=>e.jsx("li",{children:H},U))})]}),e.jsxs("div",{className:"text-sm text-gray-500",children:[e.jsx("div",{className:"font-medium mb-1",children:"Limitations:"}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:h.limitations.map((H,U)=>e.jsx("li",{children:H},U))})]})]}),e.jsx("div",{className:"flex space-x-2 pt-4 border-t",children:O?e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>i(d),disabled:T===t,"data-testid":`test-connection-${t}`,children:[T===t?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(is,{className:"h-4 w-4 mr-2"}),"Test"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>k.mutate(d.id),"data-testid":`disconnect-${t}`,children:[e.jsx(Xe,{className:"h-4 w-4 mr-2"}),"Disconnect"]})]}):e.jsxs(o,{onClick:()=>ne(t),disabled:I===t,className:"w-full","data-testid":`connect-${t}`,children:[I===t?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(es,{className:"h-4 w-4 mr-2"}),"Connect"]})})]})]},t)})}),e.jsx(we,{open:Y&&n==="yelp",onOpenChange:F,children:e.jsxs(be,{className:"sm:max-w-md","data-testid":"yelp-connect-dialog",children:[e.jsxs(Ne,{children:[e.jsx(ye,{children:"Connect Yelp"}),e.jsx(Fe,{children:"Enter your Yelp Fusion API key and business ID to connect your Yelp business page."})]}),e.jsx(Ce,{...D,children:e.jsxs("form",{onSubmit:D.handleSubmit(u),className:"space-y-4",children:[e.jsx(w,{control:D.control,name:"apiKey",render:({field:t})=>e.jsxs(b,{children:[e.jsx(N,{children:"Yelp Fusion API Key"}),e.jsx(y,{children:e.jsx(q,{type:"password",placeholder:"Enter your API key...",...t,"data-testid":"yelp-api-key-input"})}),e.jsx(R,{}),e.jsxs("p",{className:"text-xs text-gray-600",children:["Get your API key from ",e.jsx("a",{href:"https://www.yelp.com/developers/v3/manage_app",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"Yelp Developers"})]})]})}),e.jsx(w,{control:D.control,name:"businessId",render:({field:t})=>e.jsxs(b,{children:[e.jsx(N,{children:"Yelp Business ID"}),e.jsx(y,{children:e.jsx(q,{placeholder:"business-name-city",...t,"data-testid":"yelp-business-id-input"})}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-gray-600",children:'Found in your Yelp business URL after "/biz/"'})]})}),e.jsxs(Se,{children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>F(!1),"data-testid":"yelp-cancel-button",children:"Cancel"}),e.jsxs(o,{type:"submit",disabled:I==="yelp","data-testid":"yelp-connect-button",children:[I==="yelp"?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]})]})})]})}),e.jsx(we,{open:Y&&n==="wordpress",onOpenChange:F,children:e.jsxs(be,{className:"sm:max-w-md","data-testid":"wordpress-connect-dialog",children:[e.jsxs(Ne,{children:[e.jsx(ye,{children:"Connect WordPress"}),e.jsx(Fe,{children:"Connect your WordPress site to import comments and testimonials as reviews."})]}),e.jsx(Ce,{...W,children:e.jsxs("form",{onSubmit:W.handleSubmit(G),className:"space-y-4",children:[e.jsx(w,{control:W.control,name:"siteUrl",render:({field:t})=>e.jsxs(b,{children:[e.jsx(N,{children:"WordPress Site URL"}),e.jsx(y,{children:e.jsx(q,{type:"url",placeholder:"https://yoursite.com",...t,"data-testid":"wordpress-site-url-input"})}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-gray-600",children:"Your WordPress site's full URL (e.g., https://mybusiness.com)"})]})}),e.jsx(w,{control:W.control,name:"username",render:({field:t})=>e.jsxs(b,{children:[e.jsx(N,{children:"WordPress Username"}),e.jsx(y,{children:e.jsx(q,{placeholder:"admin",...t,"data-testid":"wordpress-username-input"})}),e.jsx(R,{})]})}),e.jsx(w,{control:W.control,name:"applicationPassword",render:({field:t})=>e.jsxs(b,{children:[e.jsx(N,{children:"Application Password"}),e.jsx(y,{children:e.jsx(q,{type:"password",placeholder:"xxxx xxxx xxxx xxxx xxxx",...t,"data-testid":"wordpress-app-password-input"})}),e.jsx(R,{}),e.jsx("p",{className:"text-xs text-gray-600",children:"Generate in WordPress: Users â Profile â Application Passwords"})]})}),e.jsxs(Se,{children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>F(!1),"data-testid":"wordpress-cancel-button",children:"Cancel"}),e.jsxs(o,{type:"submit",disabled:I==="wordpress","data-testid":"wordpress-connect-button",children:[I==="wordpress"?e.jsx(E,{className:"h-4 w-4 animate-spin mr-2"}):null,"Connect"]})]})]})})]})}),p.length>0&&e.jsxs(v,{"data-testid":"integration-stats",children:[e.jsx(S,{children:e.jsxs(P,{className:"flex items-center",children:[e.jsx(ve,{className:"h-5 w-5 mr-2"}),"Integration Summary"]})}),e.jsx(f,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-blue-600","data-testid":"total-reviews",children:p.reduce((t,h)=>t+h.totalReviews,0)}),e.jsx("div",{className:"text-sm text-gray-600",children:"Total Reviews"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold text-green-600","data-testid":"connected-platforms",children:p.filter(t=>t.isActive).length}),e.jsx("div",{className:"text-sm text-gray-600",children:"Connected Platforms"})]}),e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"text-2xl font-bold text-yellow-600 flex items-center justify-center","data-testid":"average-rating",children:[e.jsx(V,{className:"h-5 w-5 fill-current mr-1"}),p.length>0?(p.reduce((t,h)=>t+(h.averageRating||0),0)/p.length).toFixed(1):"N/A"]}),e.jsx("div",{className:"text-sm text-gray-600",children:"Average Rating"})]})]})})]})]})}var Ze={};function Es(){const c=Ee(),{toast:r}=Oe(),{data:n=[],isLoading:ae,error:Y,refetch:F}=te({queryKey:["/api/review-import/integrations"],refetchInterval:3e4}),{data:T=[],isLoading:Q,refetch:I}=te({queryKey:["/api/review-import/jobs"],refetchInterval:1e4}),M=i=>n.find(u=>u.platform===i),p=()=>T.filter(i=>i.status==="running"||i.status==="pending"),K=A({mutationFn:async({platform:i,redirectUri:u})=>C(`/api/review-import/${i}/oauth/start`,{method:"POST",body:JSON.stringify({redirectUri:u||`${window.location.origin}/integrations/callback/${i}`})}),onSuccess:i=>{window.location.href=i.authUrl},onError:i=>{r({title:"OAuth Start Failed",description:i.message||"Failed to start OAuth flow",variant:"destructive"})}}),Z=A({mutationFn:async({platform:i,apiKey:u,businessId:G,integrationId:t})=>t?C(`/api/review-import/integrations/${t}/test`,{method:"POST"}):C("/api/review-import/test-connection",{method:"POST",body:JSON.stringify({platform:i,apiKey:u,businessId:G})}),onSuccess:i=>{i.success?r({title:"Connection Successful",description:i.message}):r({title:"Connection Failed",description:i.message,variant:"destructive"})},onError:i=>{r({title:"Connection Test Failed",description:i.message||"Failed to test c
6onnection",variant:"destructive"})}}),L=A({mutationFn:async i=>C("/api/review-import/integrations",{method:"POST",body:JSON.stringify(i)}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/review-import/integrations"]}),r({title:"Integration Created",description:"Platform integration has been successfully created"})},onError:i=>{r({title:"Integration Creation Failed",description:i.message||"Failed to create integration",variant:"destructive"})}}),k=A({mutationFn:async({id:i,updates:u})=>C(`/api/review-import/integrations/${i}`,{method:"PATCH",body:JSON.stringify(u)}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/review-import/integrations"]}),r({title:"Integration Updated",description:"Platform integration has been successfully updated"})},onError:i=>{r({title:"Integration Update Failed",description:i.message||"Failed to update integration",variant:"destructive"})}}),D=A({mutationFn:async i=>C(`/api/review-import/integrations/${i}`,{method:"DELETE"}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/review-import/integrations"]}),c.invalidateQueries({queryKey:["/api/review-import/jobs"]}),r({title:"Integration Removed",description:"Platform integration has been successfully removed"})},onError:i=>{r({title:"Integration Removal Failed",description:i.message||"Failed to remove integration",variant:"destructive"})}}),W=A({mutationFn:async({integrationId:i,config:u})=>C(`/api/review-import/integrations/${i}/sync`,{method:"POST",body:JSON.stringify({config:u})}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/review-import/jobs"]}),r({title:"Sync Started",description:"Review import has been started. You can monitor progress below."})},onError:i=>{r({title:"Sync Failed",description:i.message||"Failed to start review sync",variant:"destructive"})}}),_=A({mutationFn:async i=>C(`/api/review-import/jobs/${i}/cancel`,{method:"POST"}),onSuccess:()=>{c.invalidateQueries({queryKey:["/api/review-import/jobs"]}),r({title:"Job Cancelled",description:"Import job has been cancelled"})},onError:i=>{r({title:"Cancel Failed",description:i.message||"Failed to cancel job",variant:"destructive"})}});return{integrations:n,importJobs:T,integrationsLoading:ae,jobsLoading:Q,integrationsError:Y,getIntegrationByPlatform:M,getActiveJobs:p,checkPlatformAvailability:i=>({google_my_business:{isAvailable:!!Ze.VITE_GOOGLE_OAUTH_CLIENT_ID,requiresOAuth:!0,description:"Requires Google OAuth setup"},facebook:{isAvailable:!!Ze.VITE_FACEBOOK_APP_ID,requiresOAuth:!0,description:"Requires Facebook App setup"},yelp:{isAvailable:!0,requiresOAuth:!1,description:"Requires Yelp Fusion API key"}})[i]||{isAvailable:!1,requiresOAuth:!1,description:"Platform not supported"},getSummaryStats:()=>{const i=n.reduce((d,O)=>d+O.totalReviews,0),u=n.filter(d=>d.isActive).length,G=n.length>0?n.reduce((d,O)=>d+(O.averageRating||0),0)/n.length:0,t=p().length,h=n.filter(d=>d.syncStatus==="error").length;return{totalReviews:i,connectedPlatforms:u,averageRating:G,activeJobs:t,errorCount:h,totalPlatforms:n.length}},startOAuth:K.mutate,testConnection:Z.mutate,createIntegration:L.mutate,updateIntegration:k.mutate,deleteIntegration:D.mutate,startSync:W.mutate,cancelJob:_.mutate,isStartingOAuth:K.isPending,isTestingConnection:Z.isPending,isCreatingIntegration:L.isPending,isUpdatingIntegration:k.isPending,isDeletingIntegration:D.isPending,isStartingSync:W.isPending,isCancellingJob:_.isPending,refetchIntegrations:F,refetchJobs:I}}const Ls=m.object({customerName:m.string().min(1,"Customer name is required"),content:m.string().min(10,"Review content must be at least 10 characters"),rating:m.number().min(1).max(5),platform:m.string().min(1,"Platform is required"),isPublic:m.boolean(),location:m.string().optional(),customerEmail:m.string().email().optional().or(m.literal("")),dateReceived:m.string(),tags:m.array(m.string()).optional()}
6),$s=m.object({tone:m.enum(["professional","friendly","empathetic","casual"]),platform:m.string(),customInstructions:m.string().optional()});function Xs(){var qe,Me,De,We,Be,Ye;const{toast:c}=Oe(),r=Ee(),{activeCompanyId:n}=ns(),ae=()=>{if(typeof window<"u"){const l=new URLSearchParams(window.location.search).get("tab");if(l&&["overview","connections","customer-reviews","responses","analytics","widgets"].includes(l))return l}return"overview"},[Y,F]=g.useState(ae),[T,Q]=g.useState(""),[I,M]=g.useState("all"),[p,K]=g.useState("all"),[Z,L]=g.useState(!1),[k,D]=g.useState(null);g.useState(!1);const[W,_]=g.useState(!1),[ie,ne]=g.useState(null),[i,u]=g.useState(null),{subscriptionInfo:G,aiPowerLevel:t,setAiPowerLevel:h}=rs();Es();const{data:d=[],isLoading:O}=te({queryKey:["/api/customer-reviews",{companyId:n,platform:I,sentiment:p,search:T}],refetchInterval:3e4,enabled:!!n}),{data:a,isLoading:H}=te({queryKey:["/api/customer-reviews/analytics",{companyId:n}],refetchInterval:6e4,enabled:!!n}),{data:U=[],isLoading:ss}=te({queryKey:["/api/review-widgets",{companyId:n}],enabled:!!n});g.useEffect(()=>{n!==null&&(console.log("ð REVIEWS PAGE: Company changed to",n,"- clearing cache and refetching"),r.invalidateQueries({queryKey:["/api/customer-reviews"],exact:!1}),r.invalidateQueries({queryKey:["/api/customer-reviews/analytics"],exact:!1}),r.invalidateQueries({queryKey:["/api/review-widgets"],exact:!1}))},[n,r]),g.useEffect(()=>{if(typeof window<"u"){const s=new URL(window.location.href);Y!=="overview"?s.searchParams.set("tab",Y):s.searchParams.delete("tab"),window.history.replaceState({},"",s.toString())}},[Y]),g.useEffect(()=>{if(U.length>0&&!ie){const s=[...U].sort((l,j)=>new Date(j.updatedAt||j.createdAt).getTime()-new Date(l.updatedAt||l.createdAt).getTime());ne(s[0])}},[U,ie]);const $=fe({resolver:Pe(Ls),defaultValues:{rating:5,platform:"google",isPublic:!0,dateReceived:new Date().toISOString().split("T")[0],tags:[]}}),re=fe({resolver:Pe($s),defaultValues:{tone:"professional",platform:"google"}}),Re=A({mutationFn:async s=>C("/api/customer-reviews",{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{r.invalidateQueries({queryKey:["/api/customer-reviews",{companyId:n}],exact:!1}),r.invalidateQueries({queryKey:["/api/customer-reviews/analytics",{companyId:n}]}),L(!1),$.reset(),c({title:"Review Added",description:"Customer review has been successfully added to your library."})},onError:s=>{c({title:"Error",description:s.message||"Failed to add review",variant:"destructive"})}}),Ie=A({mutationFn:async s=>C(`/api/customer-reviews/${s.reviewId}/generate-response`,{method:"POST",body:JSON.stringify({...s,aiPowerLevel:t})}),onSuccess:s=>{r.invalidateQueries({queryKey:["/api/customer-reviews",{companyId:n}],exact:!1}),_(!1),c({title:"AI Response Generated",description:"A professional response has been generated and saved as a draft."})},onError:s=>{c({title:"Error",description:s.message||"Failed to generate AI response",variant:"destructive"})}}),ts=A({mutationFn:async s=>C(`/api/customer-reviews/${s}`,{method:"DELETE"}),onSuccess:()=>{r.invalidateQueries({queryKey:["/api/customer-reviews",{companyId:n}],exact:!1}),r.invalidateQueries({queryKey:["/api/customer-reviews/analytics",{companyId:n}]}),c({title:"Review Deleted",description:"Customer review has been removed from your library."})},onError:s=>{c({title:"Error",description:s.message||"Failed to delete review",variant:"destructive"})}});A({mutationFn:async s=>C("/api/review-widgets",{method:"POST",body:JSON.stringify(s)}),onSuccess:s=>{c({title:"Widget Created Successfully! ð¨",description:`Your ${s.widgetType} widget is ready to embed on your website.`}),r.invalidateQueries({queryKey:["/api/review-widgets",{companyId:n}]}),ne(s)},onError:s=>{var l,j;c({title:"Widget Creation Failed",description:(l=s.message)!=null&&l.includes("reviews")?"No suitable reviews found. Make sure you have positive reviews (4+ stars) available.":(j=s.message)!=null&&j.includes("design")?"Widget design configuration failed. Try with default settings.":"Failed to create widget. Check that you have reviews available and try again.",variant:"destructive"})}});const Le=s=>{navigator.clipboard.writeText(s),c({title:"Copied!",description:"Code copied to your clipboard."})},he=s=>Array.from({length:5},(l,j)=>e.jsx(V,{className:`w-4 h-4 ${j<s?"fill-yellow-400 text-yellow-400":"text-gray-300"}`},j)),$e=s=>{switch(s){case"positive":return"text-green-600 bg-green-50 border-green-200";case"negative":return"text-red-600 bg-red-50 border-red-200";default:return"text-yellow-600 bg-yellow-50 border-yellow-200"}},ke=s=>{switch(s.toLowerCase()){case"google":return e.jsx(je,{className:"w-4 h-4"});case"yelp":return e.jsx(Cs,{className:"w-4 h-4"});case"facebook":return e.jsx(ys,{className:"w-4 h-4"});default:return e.jsx(oe,{className:"w-4 h-4"})}},le=d.filter(s=>{const l=T===""||s.customerName.toLowerCase().includes(T.toLowerCase())||s.content.toLowerCase().includes(T.toLowerCase()),j=I==="all"||s.platform===I,ge=p==="all"||s.sentiment===p;return l&&j&&ge});return e.jsxs("div",{className:"container mx-auto p-4 sm:p-6 max-w-7xl","data-testid":"reviews-library-page",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between mb-6 gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:"Reviews Library"}),e.jsx("p",{className:"text-muted-foreground text-sm sm:text-base",children:"Manage customer reviews with AI-powered response generation"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3",children:[e.jsx(ls,{href:"/reviews-guide-introduction",children:e.jsxs(o,{variant:"outline",className:"border-blue-200 text-blue-700 hover:bg-blue-50 w-full sm:w-auto","data-testid":"button-reviews-guide",size:"sm",children:[e.jsx(os,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reviews Guide"}),e.jsx("span",{className:"sm:hidden",children:"Guide"})]})}),e.jsxs(o,{onClick:()=>F("widgets"),variant:"outline",className:"border-orange-200 text-orange-700 hover:bg-orange-50 w-full sm:w-auto","data-testid":"button-review-widget",size:"sm",children:[e.jsx(pe,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"+ Review Widget"}),e.jsx("span",{className:"sm:hidden",children:"+ Widget"})]}),e.jsxs(o,{onClick:()=>L(!0),"data-testid":"button-add-review",className:"bg-orange-600 hover:bg-orange-700 w-full sm:w-auto",size:"sm",children:[e.jsx(es,{className:"w-4 h-4 mr-2"}),"Add Review"]})]})]}),e.jsxs(Ss,{value:Y,onValueChange:F,className:"space-y-6",children:[e.jsxs(Ps,{className:"grid w-full grid-cols-3 sm:grid-cols-6 gap-1 h-auto p-1",children:[e.jsxs(X,{value:"overview","data-testid":"tab-overview",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(cs,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Overview"}),e.jsx("span",{className:"sm:hidden",children:"Stats"})]}),e.jsxs(X,{value:"connections","data-testid":"tab-connections",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(je,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Connections"}),e.jsx("span",{className:"sm:hidden",children:"Connect"})]}),e.jsxs(X,{value:"customer-reviews","data-testid":"tab-customer-reviews",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:"Reviews"})]}),e.jsxs(X,{value:"responses","data-testid":"tab-responses",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(Ue,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Responses"}),e.jsx("span",{className:"sm:hidden",children:"Reply"})]}),e.jsxs(X,{value:"analytics","data-testid":"tab-analytics",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(ve,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Analytics"}),e.jsx("span",{className:"sm:hidden",children:"Data"})]}),e.jsxs(X,{value:"widgets","data-testid":"tab-widgets",className:"flex flex-col sm:flex-row items-center justify-center gap-1 sm:gap-2 text-xs sm:text-sm px-2 py-2",children:[e.jsx(pe,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Widgets"}),e.jsx("span",{className:"sm:hidden",children:"Widgets"})]})]}),e.jsxs(ee,{value:"overview",className:"space-y-6",children:[H?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(E,{className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6",children:[e.jsxs(v,{children:[e.jsxs(S,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(P,{className:"text-sm font-medium",children:"Total Reviews"}),e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(f,{children:[e.jsx("div",{className:"text-2xl font-bold",children:(a==null?void 0:a.totalReviews)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(()=>{var _e,Ge;const s=(a==null?void 0:a.recentTrends)||[];
6if(s.length<2)return"No trend data yet";const l=((_e=s[s.length-1])==null?void 0:_e.count)||0,j=((Ge=s[s.length-2])==null?void 0:Ge.count)||0;if(j===0)return l>0?`+${l} new this month`:"No reviews last month";const ge=(l-j)/j*100;return`${ge>=0?"+":""}${ge.toFixed(0)}% from last month`})()})]})]}),e.jsxs(v,{children:[e.jsxs(S,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(P,{className:"text-sm font-medium",children:"Average Rating"}),e.jsx(V,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(f,{children:[e.jsx("div",{className:"text-2xl font-bold",children:((qe=a==null?void 0:a.averageRating)==null?void 0:qe.toFixed(1))||"0.0"}),e.jsx("div",{className:"flex items-center mt-1",children:he(Math.round((a==null?void 0:a.averageRating)||0))})]})]}),e.jsxs(v,{children:[e.jsxs(S,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(P,{className:"text-sm font-medium",children:"Response Rate"}),e.jsx(Ue,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(f,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[((Me=a==null?void 0:a.responseRate)==null?void 0:Me.toFixed(0))||0,"%"]}),e.jsx(ue,{value:(a==null?void 0:a.responseRate)||0,className:"mt-2"})]})]}),e.jsxs(v,{children:[e.jsxs(S,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(P,{className:"text-sm font-medium",children:"Positive Reviews"}),e.jsx(ds,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(f,{children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:((De=a==null?void 0:a.sentimentBreakdown)==null?void 0:De.positive)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a!=null&&a.totalReviews?(a.sentimentBreakdown.positive/a.totalReviews*100).toFixed(0):0,"% of total"]})]})]})]}),e.jsxs(v,{children:[e.jsxs(S,{children:[e.jsx(P,{children:"Recent Reviews"}),e.jsx(J,{children:"Latest customer feedback"})]}),e.jsx(f,{children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(E,{className:"w-6 h-6 animate-spin"})}):le.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"No reviews yet. Add your first customer review!"}),e.jsxs("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4 mx-auto max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(Qe,{className:"w-5 h-5 text-orange-600 dark:text-orange-400"}),e.jsx("h4",{className:"text-sm font-medium text-orange-900 dark:text-orange-100",children:"Connect Review Platforms"})]}),e.jsx("p",{className:"text-sm text-orange-700 dark:text-orange-300 mb-3 text-center",children:"Automatically import reviews from Google, Yelp, Facebook and more platforms."}),e.jsxs(o,{size:"sm",className:"bg-orange-600 hover:bg-orange-700 text-white w-full","data-testid":"button-setup-review-connections",onClick:()=>F("connections"),children:[e.jsx(Qe,{className:"w-4 h-4 mr-2"}),"Set Up Platform Connections"]})]})]}):e.jsx("div",{className:"space-y-4",children:le.slice(0,3).map(s=>e.jsxs("div",{className:"flex items-start space-x-4 p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"font-medium",children:s.customerName}),e.jsx("div",{className:"flex items-center space-x-1",children:he(s.rating)}),e.jsx(B,{variant:"outline",className:$e(s.sentiment),children:s.sentiment})]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.content}),e.jsxs("div",{className:"flex items-center space-x-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center space-x-1",children:[ke(s.platform),e.jsx("span",{children:s.platform})]}),e.jsxs("span",{children:[Te(new Date(s.createdAt))," ago"]})]})]}),s.hasResponse&&e.jsxs(B,{variant:"secondary",className:"text-green-600",children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),"Responded"]})]},s.id))})})]})]}),e.jsx(ee,{value:"connections",className:"space-y-6",children:e.jsx(Os,{})}),e.jsxs(ee,{value:"customer-reviews",className:"space-y-6",children:[e.jsx(v,{children:e.jsx(f,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"relative",children:[e.jsx(ms,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),e.jsx(q,{placeholder:"Search reviews...",value:T,onChange:s=>Q(s.target.value),className:"pl-10","data-testid":"input-search-reviews"})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-4",children:[e.jsxs(ce,{value:I,onValueChange:M,children:[e.jsx(de,{className:"w-full sm:w-40","data-testid":"select-platform-filter",children:e.jsx(me,{placeholder:"Platform"})}),e.jsxs(xe,{children:[e.jsx(x,{value:"all",children:"All Platforms"}),e.jsx(x,{value:"google",children:"Google"}),e.jsx(x,{value:"yelp",children:"Yelp"}),e.jsx(x,{value:"facebook",children:"Facebook"}),e.jsx(x,{value:"other",children:"Other"})]})]}),e.jsxs(ce,{value:p,onValueChange:K,children:[e.jsx(de,{className:"w-full sm:w-40","data-testid":"select-sentiment-filter",children:e.jsx(me,{placeholder:"Sentiment"})}),e.jsxs(xe,{children:[e.jsx(x,{value:"all",children:"All Sentiments"}),e.jsx(x,{value:"positive",children:"Positive"}),e.jsx(x,{value:"neutral",children:"Neutral"}),e.jsx(x,{value:"negative",children:"Negative"})]})]})]})]})})}),e.jsxs(v,{children:[e.jsx(S,{children:e.jsxs(P,{children:["Customer Reviews (",le.length,")"]})}),e.jsx(f,{children:O?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(E,{className:"w-6 h-6 animate-spin"})}):le.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{className:"w-12 h-12 text-muted-foreground mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:T||I!=="all"||p!=="all"?"No reviews match your filters":"No reviews yet. Add your first customer review!"})]}):e.jsx("div",{className:"space-y-4",children:le.map(s=>e.jsxs("div",{className:"border rounded-lg p-4 sm:p-6 space-y-4",children:[e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 mb-2",children:[e.jsx("h3",{className:"font-semibold text-base sm:text-lg truncate",children:s.customerName}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center space-x-1",children:[he(s.rating),e.jsxs("span",{className:"text-sm text-muted-foreground ml-1",children:["(",s.rating,"/5)"]}
6)]}),e.jsx(B,{variant:"outline",className:$e(s.sentiment),children:s.sentiment})]})]}),e.jsx("p",{className:"text-gray-700 mb-3 text-sm sm:text-base",children:s.content}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 text-xs sm:text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center space-x-1",children:[ke(s.platform),e.jsx("span",{className:"capitalize",children:s.platform})]}),e.jsxs("span",{className:"flex items-center space-x-1",children:[e.jsx(xs,{className:"w-4 h-4"}),e.jsxs("span",{children:[Te(new Date(s.createdAt))," ago"]})]}),s.location&&e.jsxs("span",{className:"flex items-center space-x-1",children:[e.jsx(Is,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:s.location})]})]})]}),e.jsx("div",{className:"flex sm:flex-col items-start sm:items-end gap-2",children:s.hasResponse?e.jsxs(B,{variant:"secondary",className:"text-green-600 text-xs",children:[e.jsx(z,{className:"w-3 h-3 mr-1"}),s.responseCount," response",s.responseCount!==1?"s":""]}):e.jsxs(B,{variant:"outline",className:"text-orange-600 text-xs",children:[e.jsx(He,{className:"w-3 h-3 mr-1"}),"No response"]})})]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 pt-4 border-t",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-2 sm:flex-1",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>{D(s),_(!0)},"data-testid":`button-ai-response-${s.id}`,className:"w-full sm:w-auto text-xs sm:text-sm",children:[e.jsx(ze,{className:"w-4 h-4 mr-1 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate AI Response"}),e.jsx("span",{className:"sm:hidden",children:"AI Response"})]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>D(s),"data-testid":`button-view-review-${s.id}`,className:"w-full sm:w-auto text-xs sm:text-sm",children:[e.jsx(us,{className:"w-4 h-4 mr-1 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"View Details"}),e.jsx("span",{className:"sm:hidden",children:"View"})]})]}),e.jsxs("div",{className:"flex gap-2 sm:gap-2",children:[e.jsxs(o,{variant:"outline",size:"sm","data-testid":`button-edit-review-${s.id}`,className:"flex-1 sm:flex-none",children:[e.jsx(ks,{className:"w-4 h-4 sm:mr-0"}),e.jsx("span",{className:"ml-1 sm:hidden",children:"Edit"})]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>ts.mutate(s.id),"data-testid":`button-delete-review-${s.id}`,className:"flex-1 sm:flex-none",children:[e.jsx(hs,{className:"w-4 h-4 sm:mr-0"}),e.jsx("span",{className:"ml-1 sm:hidden",children:"Delete"})]})]})]})]},s.id))})})]})]}),e.jsx(ee,{value:"responses",className:"space-y-6",children:e.jsxs(v,{children:[e.jsxs(S,{children:[e.jsx(P,{children:"Review Responses"}),e.jsx(J,{children:"Manage AI-generated and manual responses"})]}),e.jsx(f,{children:e.jsx("p",{className:"text-muted-foreground",children:"Response management interface coming soon..."})})]})}),e.jsx(ee,{value:"analytics",className:"space-y-6",children:H?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(E,{className:"w-6 h-6 animate-spin"})}):e.jsxs(e.Fragment,{children:[e.jsxs(v,{children:[e.jsxs(S,{children:[e.jsx(P,{children:"Sentiment Analysis"}),e.jsx(J,{children:"Customer satisfaction breakdown"})]}),e.jsx(f,{children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-green-600 mb-2",children:((We=a==null?void 0:a.sentimentBreakdown)==null?void 0:We.positive)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Positive Reviews"}),e.jsx(ue,{value:a!=null&&a.totalReviews?a.sentimentBreakdown.positive/a.totalReviews*100:0,className:"mt-2 h-2"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-yellow-600 mb-2",children:((Be=a==null?void 0:a.sentimentBreakdown)==null?void 0:Be.neutral)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Neutral Reviews"}),e.jsx(ue,{value:a!=null&&a.totalReviews?a.sentimentBreakdown.neutral/a.totalReviews*100:0,className:"mt-2 h-2"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-3xl font-bold text-red-600 mb-2",children:((Ye=a==null?void 0:a.sentimentBreakdown)==null?void 0:Ye.negative)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Negative Reviews"}),e.jsx(ue,{value:a!=null&&a.totalReviews?a.sentimentBreakdown.negative/a.totalReviews*100:0,className:"mt-2 h-2"})]})]})})]}),e.jsxs(v,{children:[e.jsxs(S,{children:[e.jsx(P,{children:"Platform Distribution"}),e.jsx(J,{children:"Reviews by platform"})]}),e.jsx(f,{children:e.jsx("div",{className:"space-y-4",children:Object.entries((a==null?void 0:a.platformBreakdown)||{}).map(([s,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[ke(s),e.jsx("span",{className:"capitalize",children:s})]}),e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("span",{className:"font-medium",children:l}),e.jsx(ue,{value:a!=null&&a.totalReviews?l/a.totalReviews*100:0,className:"w-32"})]})]},s))})})]})]})}),e.jsxs(ee,{value:"widgets",className:"space-y-6 sm:space-y-8",children:[e.jsxs("div",{className:"relative overflow-hidden rounded-xl bg-gradient-to-br from-orange-500 via-orange-600 to-amber-600 p-6 sm:p-8 text-white","data-testid":"widgets-hero-section",children:[e.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRoLTJ2LTRoMnYtMmgtNHYyaC0ydjRoMnYyaDR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-20"}),e.jsx("div",{className:"relative z-10",children:e.jsx("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(As,{className:"h-8 w-8"}),e.jsx(B,{className:"bg-white/20 text-white border-white/30 hover:bg-white/30",children:"Social Proof Engine"})]}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold mb-2",children:"Turn Reviews Into a 24/7 Sales Machine"}),e.jsx("p",{className:"text-orange-100 text-base sm:text-lg mb-4 max-w-2xl",children:"Embed powerful review widgets on your website to build instant trust and boost conversions. Your happy customers become your best salespeople."}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-white/10 rounded-lg px-3 py-2",children:[e.jsx(ve,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium",children:"93% of consumers read reviews before buying"})]}),e.jsxs("div",{className:"flex items-center gap-2 bg-white/10 rounded-lg px-3 py-2",children:[e.jsx(Je,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium",children:"2x higher conversion rates"})]})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6","data-testid":"widget-type-cards",children:[e.jsxs(v,{className:`curs
6or-pointer transition-all duration-200 hover:shadow-lg ${i==="bubble"?"ring-2 ring-orange-500 border-orange-500":"hover:border-orange-300"}`,onClick:()=>u("bubble"),"data-testid":"card-bubble-widget",children:[e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(P,{className:"flex items-center gap-2 text-lg",children:[e.jsx(gs,{className:"h-5 w-5 text-orange-500"}),"Floating Review Bubble"]}),i==="bubble"&&e.jsx(B,{className:"bg-orange-500",children:"Selected"})]}),e.jsx(J,{children:"A subtle popup that appears in the corner of your website, showing rotating reviews"})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsx("div",{className:"relative bg-gray-100 dark:bg-gray-800 rounded-lg p-4 h-40 overflow-hidden",children:e.jsxs("div",{className:"absolute inset-0 bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-800 dark:to-gray-900",children:[e.jsx("div",{className:"absolute top-4 left-4 text-xs text-gray-400",children:"Your Website"}),e.jsxs("div",{className:"absolute bottom-4 right-4 bg-white dark:bg-gray-700 rounded-xl shadow-lg p-3 max-w-[200px] animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 rounded-full flex items-center justify-center",children:e.jsx(V,{className:"h-4 w-4 text-orange-500 fill-orange-500"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-2 bg-gray-200 dark:bg-gray-600 rounded w-16 mb-1"}),e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(s=>e.jsx(V,{className:"h-2 w-2 text-yellow-400 fill-yellow-400"},s))})]})]}),e.jsx("div",{className:"h-2 bg-gray-200 dark:bg-gray-600 rounded w-full mb-1"}),e.jsx("div",{className:"h-2 bg-gray-200 dark:bg-gray-600 rounded w-3/4"})]})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Benefits:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}),"Non-intrusive, always visible"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}),"Perfect for all pages"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}),"Auto-rotates through reviews"]})]})]}),e.jsxs(o,{className:"w-full bg-orange-600 hover:bg-orange-700",onClick:s=>{s.stopPropagation(),u("bubble")},"data-testid":"button-select-bubble-widget",children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),i==="bubble"?"Bubble Widget Selected":"Get Embed Code"]})]})]}),e.jsxs(v,{className:`cursor-pointer transition-all duration-200 hover:shadow-lg ${i==="fullpage"?"ring-2 ring-orange-500 border-orange-500":"hover:border-orange-300"}`,onClick:()=>u("fullpage"),"data-testid":"card-fullpage-widget",children:[e.jsxs(S,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(P,{className:"flex items-center gap-2 text-lg",children:[e.jsx(je,{className:"h-5 w-5 text-orange-500"}),"Full Reviews Page"]}),i==="fullpage"&&e.jsx(B,{className:"bg-orange-500",children:"Selected"})]}),e.jsx(J,{children:"A dedicated page showing all your reviews from your library"})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsx("div",{className:"relative bg-gray-100 dark:bg-gray-800 rounded-lg p-4 h-40 overflow-hidden",children:e.jsxs("div",{className:"bg-white dark:bg-gray-700 rounded-lg shadow-sm p-3 h-full",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 mb-3",children:[[1,2,3,4,5].map(s=>e.jsx(V,{className:"h-4 w-4 text-yellow-400 fill-yellow-400"},s)),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"4.9 avg"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[1,2,3,4].map(s=>e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-600 rounded p-2",children:[e.jsx("div",{className:"flex gap-0.5 mb-1",children:[1,2,3,4,5].map(l=>e.jsx(V,{className:"h-2 w-2 text-yellow-400 fill-yellow-400"},l))}),e.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-500 rounded w-full mb-1"}),e.jsx("div",{className:"h-1.5 bg-gray-200 dark:bg-gray-500 rounded w-2/3"})]},s))})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium text-sm",children:"Benefits:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}),"Complete social proof display"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}
6),"SEO benefits from review content"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4 text-green-500"}),"Dedicated testimonials page"]})]})]}),e.jsxs(o,{className:"w-full bg-orange-600 hover:bg-orange-700",onClick:s=>{s.stopPropagation(),u("fullpage")},"data-testid":"button-select-fullpage-widget",children:[e.jsx(Ae,{className:"h-4 w-4 mr-2"}),i==="fullpage"?"Full Page Widget Selected":"Get Embed Code"]})]})]})]}),i&&e.jsxs(v,{"data-testid":"card-embed-code-section",className:"border-orange-200 dark:border-orange-800",children:[e.jsxs(S,{className:"bg-orange-50 dark:bg-orange-900/20 border-b border-orange-100 dark:border-orange-800",children:[e.jsxs(P,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ae,{className:"h-5 w-5 text-orange-500"}),i==="bubble"?"Floating Bubble":"Full Reviews Page"," - Embed Code"]}),e.jsx(J,{children:"Copy this code and paste it into your website's HTML"})]}),e.jsxs(f,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"p-4 bg-gray-900 text-gray-100 rounded-lg text-sm overflow-x-auto font-mono",children:e.jsx("code",{children:i==="bubble"?`<script src="${typeof window<"u"?window.location.origin:""}/api/widget/bubble/${n||"YOUR_COMPANY_ID"}"><\/script>`:`<div id="boom-bam-reviews"></div> 7<script src="${typeof window<"u"?window.location.origin:""}/api/widget/fullpage/${n||"YOUR_COMPANY_ID"}"><\/script>`})}),e.jsxs(o,{size:"sm",className:"absolute top-2 right-2 bg-orange-600 hover:bg-orange-700",onClick:()=>{const s=i==="bubble"?`<script src="${typeof window<"u"?window.location.origin:""}/api/widget/bubble/${n||"YOUR_COMPANY_ID"}"><\/script>`:`<div id="boom-bam-reviews"></div> 8<script src="${typeof window<"u"?window.location.origin:""}/api/widget/fullpage/${n||"YOUR_COMPANY_ID"}"><\/script>`;Le(s)},"data-testid":"button-copy-widget-embed-code",children:[e.jsx(Ke,{className:"h-4 w-4 mr-1"}),"Copy Code"]})]}),e.jsxs(ps,{className:"bg-orange-50 dark:bg-orange-900/20 border-orange-200 dark:border-orange-800",children:[e.jsx(js,{className:"h-4 w-4 text-orange-600"}),e.jsx(vs,{className:"text-orange-800 dark:text-orange-200",children:"Installation Tips"}),e.jsx(fs,{className:"text-orange-700 dark:text-orange-300",children:e.jsxs("ul",{className:"mt-2 space-y-1 text-sm",children:[i==="bubble"?e.jsxs(e.Fragment,{children:[e.jsxs("li",{children:["⢠Paste before the closing ",e.jsx("code",{className:"bg-orange-100 dark:bg-orange-800 px-1 rounded",children:"</body>"})," tag"]}),e.jsx("li",{children:"⢠The bubble will appear in the bottom-right corner automatically"}),e.jsx("li",{children:"⢠Works on all pages without additional configuration"})]}):e.jsxs(e.Fragment,{children:[e.jsx("li",{children:"⢠Add the code where you want the reviews to appear"}),e.jsx("li",{children:"⢠Great for dedicated testimonials or reviews pages"}),e.jsx("li",{children:"⢠Automatically displays all your approved reviews"})]}),e.jsx("li",{children:"⢠Compatible with WordPress, Shopify, Wix, Squarespace, and custom sites"}),e.jsx("li",{children:"⢠Updates automatically when you receive new reviews"})]})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(o,{variant:"outline",className:"flex-1",onClick:()=>u(null),"data-testid":"button-clear-widget-selection",children:[e.jsx(Xe,{className:"h-4 w-4 mr-2"}),"Clear Selection"]}),e.jsxs(o,{variant:"outline",className:"flex-1",onClick:()=>{const s=i==="bubble"?`${typeof window<"u"?window.location.origin:""}/api/widget/bubble/${n}/preview`:`${typeof window<"u"?window.location.origin:""}/api/widget/fullpage/${n}/preview`;window.open(s,"_blank")},"data-testid":"button-preview-widget",children:[e.jsx(ws,{className:"h-4 w-4 mr-2"}),"Preview Widget"]})]})]})]}),e.jsxs(v,{"data-testid":"card-active-widgets",children:[e.jsxs(S,{children:[e.jsxs(P,{className:"flex items-center gap-2 text-lg",children:[e.jsx(pe,{className:"h-5 w-5"}),"Your Active Widgets"]}),e.jsx(J,{children:"Previously created widgets embedded on your website"})]}),e.jsx(f,{children:ss?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm py-8 justify-center",children:[e.jsx(E,{className:"h-5 w-5 animate-spin"}),"Loading your widgets..."]}):U.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(pe,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h4",{className:"font-medium mb-2",children:"No Active Widgets Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4 max-w-md mx-auto",children:"Select a widget type above to get your embed code and start showcasing reviews on your website."}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Je,{className:"h-3 w-3 text-orange-500"}),"Instant setup"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3 text-green-500"}),"Boost conversions"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"h-3 w-3 text-blue-500"}),"Works everywhere"]})]})]}):e.jsx("div",{className:"space-y-3",children:U.map(s=>{var l;return e.jsx("div",{className:"p-4 border rounded-lg hover:bg-gray-50 dark:hover:bg-gray-900 transition-colors","data-testid":`active-widget-item-${s.id}`,children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"font-medium truncate",children:s.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.widgetType," ⢠",((l=s.displaySettings)==null?void 0:l.maxReviews)||"Multiple"," reviews"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{variant:s.status==="published"?"default":"secondary",children:s.status==="published"?"â Live":s.status}),e.jsxs(o,{size:"sm",variant:"outline",onClick:()=>{const j=s.widgetCode||`<script src="${typeof window<"u"?window.location.origin:""}/api/widget/${s.id}"><\/script> 9<div id="review-widget-${s.id}"></div>`;Le(j)},"data-testid":`button-copy-active-widget-code-${s.id}`,children:[e.jsx(Ke,{className:"h-4 w-4 mr-1"}),"Copy Code"]})]})]})},s.id)})})})]})]})]}),e.jsx(we,{open:Z,onOpenChange:L,children:e.jsxs(be,{className:"max-w-2xl",children:[e.jsx(Ne,{children:e.jsx(ye,{children:"Add Customer Review"})}),e.jsx(Ce,{...$,children:e.jsxs("form",{onSubmit:$.handleSubmit(s=>Re.mutate(s)),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(w,{control:$.control,name:"customerName",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Customer Name"}),e.jsx(y,{children:e.jsx(q,{placeholder:"John Doe",...s,"data-testid":"input-customer-name"})}),e.jsx(R,{})]})}),e.jsx(w,{control:$.control,name:"rating",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Rating (1-5)"}),e.jsx(y,{children:e.jsx(q,{type:"number",min:"1",max:"5",...s,onChange:l=>s.onChange(parseInt(l.target.value)),"data-testid":"input-rating"})}),e.jsx(R,{})]})})]}),e.jsx(w,{control:$.control,name:"content",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Review Content"}),e.jsx(y,{children:e.jsx(Ve,{placeholder:"The customer's review content...",className:"min-h-[100px]",...s,"data-testid":"textarea-review-content"})}),e.jsx(R,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(w,{control:$.control,name:"platform",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Platform"}),e.jsxs(ce,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(y,{children:e.jsx(de,{"data-testid":"select-platform",children:e.jsx(me,{placeholder:"Select platform"})})}),e.jsxs(xe,{children:[e.jsx(x,{value:"google",children:"Google"}),e.jsx(x,{value:"yelp",children:"Yelp"}),e.jsx(x,{value:"facebook",children:"Facebook"}),e.jsx(x,{value:"trustpilot",children:"Trustpilot"}),e.jsx(x,{value:"other",children:"Other"})]})]}),e.jsx(R,{})]})}),e.jsx(w,{control:$.control,name:"dateReceived",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Date Received"}),e.jsx(y,{children:e.jsx(q,{type:"date",...s,"data-testid":"input-date-received"})}),e.jsx(R,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(w,{control:$.control,name:"customerEmail",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Customer Email (Optional)"}),e.jsx(y,{children:e.jsx(q,{type:"email",placeholder:"[email protected]",...s,"data-testid":"input-customer-email"})}),e.jsx(R,{})]})}),e.jsx(w,{control:$.control,name:"location",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Location (Optional)"}),e.jsx(y,{children:e.jsx(q,{placeholder:"City, State",...s,"data-testid":"input-location"})}),e.jsx(R,{})]})})]}),e.jsx(w,{control:$.control,name:"isPublic",render:({field:s})=>e.jsxs(b,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(N,{className:"text-base",children:"Public Review"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make this review visible in your public reviews showcase"})]}),e.jsx(y,{children:e.jsx(bs,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"switch-is-public"})})]})}),e.jsxs(Se,{children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>L(!1),"data-testid":"button-cancel-review",children:"Cancel"}),e.jsx(o,{type:"submit",disabled:Re.isPending,"data-testid":"button-save-review",className:"bg-orange-600 hover:bg-orange-700",children:Re.isPending?e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Review"})]})]})})]})}),e.jsx(we,{open:W,onOpenChange:_,children:e.jsxs(be,{className:"max-w-2xl",children:[e.jsxs(Ne,{children:[e.jsx(ye,{children:"Generate AI Response"}),e.jsxs(Fe,{children:["Generate a professional response to ",k==null?void 0:k.customerName,"'s review"]})]}),k&&e.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg mb-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[e.jsx("span",{className:"font-medium",children:k.customerName}),e.jsx("div",{className:"flex items-center space-x-1",children:he(k.rating)})]}),e.jsx("p",{className:"text-sm text-gray-700",children:k.content})]}),e.jsx(Ce,{...re,children:e.jsxs("form",{onSubmit:re.handleSubmit(s=>{k&&Ie.mutate({...s,reviewId:k.id})}),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(w,{control:re.control,name:"tone",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Response Tone"}),e.jsxs(ce,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(y,{children:e.jsx(de,{"data-testid":"select-tone",children:e.jsx(me,{placeholder:"Select tone"})})}),e.jsxs(xe,{children:[e.jsx(x,{value:"professional",children:"Professional"}),e.jsx(x,{value:"friendly",children:"Friendly"}),e.jsx(x,{value:"empathetic",children:"Empathetic"}),e.jsx(x,{value:"casual",children:"Casual"})]})]}),e.jsx(R,{})]})}),e.jsx(w,{control:re.control,name:"platform",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Target Platform"}),e.jsxs(ce,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(y,{children:e.jsx(de,{"data-testid":"select-response-platform",children:e.jsx(me,{placeholder:"Select platform"})})}),e.jsxs(xe,{children:[e.jsx(x,{value:"google",children:"Google"}),e.jsx(x,{value:"yelp",children:"Yelp"}),e.jsx(x,{value:"facebook",children:"Facebook"}),e.jsx(x,{value:"trustpilot",children:"Trustpilot"})]})]}),e.jsx(R,{})]})})]}
9),e.jsx(w,{control:re.control,name:"customInstructions",render:({field:s})=>e.jsxs(b,{children:[e.jsx(N,{children:"Custom Instructions (Optional)"}),e.jsx(y,{children:e.jsx(Ve,{placeholder:"Any specific points to address or tone adjustments...",...s,"data-testid":"textarea-custom-instructions"})}),e.jsx(R,{})]})}),e.jsx("div",{children:e.jsx(Ns,{value:t,onChange:h,baseCredits:Rs.REVIEW_RESPONSE_GENERATION,availableCredits:G==null?void 0:G.creditsRemaining,showDetails:!0})}),e.jsxs(Se,{children:[e.jsx(o,{type:"button",variant:"outline",onClick:()=>_(!1),"data-testid":"button-cancel-ai-response",children:"Cancel"}),e.jsx(o,{type:"submit",disabled:Ie.isPending,"data-testid":"button-generate-response",className:"bg-orange-600 hover:bg-orange-700",children:Ie.isPending?e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"w-4 h-4 mr-2"}),"Generate Response"]})})]})]})})]})})]})}export{Xs 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.