PageSourceSearch

https://boombam.app/assets/business-profile-D-NYvFJa.js

js boombam.app collected 2026-10-04 13:32:53 UTC 96,525 bytes, 20 lines download raw bytes

1import{_ as He,r as l,aM as st,u as tt,a6 as Fe,l as Qe,j as e,C as pe,b as be,S as Ne,e as he,$ as at,a0 as nt,a1 as rt,a2 as it,a3 as lt,aN as ot,aO as ks,B as L,R as Ts,s as ye,T as ct,E as Ze,aP as dt,a7 as Ve,aQ as De,aR as ve,aS as Le,aT as mt,aU as ut,aV as xt,aW as pt,c as ge,aE as $s,a5 as os,N as Ls,aI as ht,a as ts,aX as as,aD as As,d as Re,aY as Os,aF as ce,aZ as gt,a4 as $e,h as ft,a_ as ns,a$ as q,b0 as U,b1 as z,b2 as G,b3 as Y,b4 as Ps,ap as oe,k as Bs,b5 as jt,m as qs,b6 as _e,a8 as Us,a9 as zs,aK as cs,aa as Gs,ak as vt,al as yt,am as bt,an as Nt,b7 as wt,aq as Ct,ac as St,b8 as I,b9 as kt,v as At,au as Pt,ba as Et,bb as It,f as fe,w as Mt,bc as Ft,bd as Vt,be as Ys,bf as rs,Z as Dt,F as Rt,V as Tt,Y as $t,Q as Lt,X as Ot,bg as Ye,L as Es,U as Bt,z as qt}from"./index-CuSEeJFb.js";import{T as Ut,a as zt,b as Ke,c as We}from"./tabs-CcPOXtvT.js";import{B as Gt}from"./bot-ecRnbbNU.js";import{C as Yt}from"./copy-Ctw93tQ7.js";import{C as Is}from"./check-check-BVDNI4mA.js";import{W as ne}from"./wand-sparkles-Cnc6tXs_.js";import{M as Kt}from"./map-pin-DOxfmRxb.js";import{S as Wt}from"./square-pen-Wwme7SiP.js";import{A as Qt}from"./arrow-right-left-B_tMOH_y.js";import{M as Ht}from"./minus-LVFLuFlS.js";import{T as Zt}from"./trending-down-C0n_6ywh.js";import{P as _t}from"./progress-B2eMqtVV.js";import{u as Jt,a as Xt,O as ea}from"./inline-connection-components-CHMT89t0.js";import{L as Ks}from"./link-2-B6OMy1mi.js";import{S as sa}from"./share-B5BYf7qZ.js";import{S as Ms}from"./save-DMqvNvzo.js";import{U as ta}from"./upload-rep3KVPL.js";function aa({businessProfile:s,onContentGenerated:r,selectedField:a,onFieldChange:j}){const{toast:m}=He(),[d,o]=l.useState(a||"tagline");st.useEffect(()=>{a&&a!==d&&o(a)},[a,d]);const[v,P]=l.useState(""),[p,u]=l.useState(""),[A,y]=l.useState(""),[k,J]=l.useState(!1),K=tt(),w=(K==null?void 0:K.subscriptionInfo)||{plan:"solopreneur",aiCreditsRemaining:1e3},b=(K==null?void 0:K.aiPowerLevel)||"balanced",g=(K==null?void 0:K.setAiPowerLevel)||(()=>{}),N=[{value:"tagline",label:"Tagline",icon:Qe,description:"A memorable slogan that captures your brand essence"},{value:"motto",label:"Motto",icon:ct,description:"Your guiding principle or philosophy"},{value:"vision",label:"Vision",icon:Ze,description:"Your aspirational future state"},{value:"beliefs",label:"Core Beliefs",icon:dt,description:"What your company stands for"}],M=Fe({mutationFn:async h=>{var ee,se,X,ue,xe;J(!0);const x={companyName:((ee=h.businessContext)==null?void 0:ee.companyName)||"Your Business",industry:((se=h.businessContext)==null?void 0:se.industry)||"General Business",description:((X=h.businessContext)==null?void 0:X.description)||"",targetMarket:((ue=h.businessContext)==null?void 0:ue.targetMarket)||"",services:((xe=h.businessContext)==null?void 0:xe.services)||[]},H=`You are a brand voice expert helping create compelling ${h.field} content. 
2      Context about the business:
3      - Company: ${x.companyName}
4      - Industry: ${x.industry}
5      - Description: ${x.description}
6      - Target Market: ${x.targetMarket}
7      - Services: ${x.services.join(", ")}
8      
9      Generate a ${h.field} that is authentic, memorable, and aligned with their brand. ${h.prompt?`Additional requirements: ${h.prompt}`:""}`;return await(await Ve("/api/brand-voice-generate",{method:"POST",body:JSON.stringify({field:h.field,prompt:H,businessContext:x,aiPowerLevel:h.aiPowerLevel})})).json()},onSuccess:h=>{const x=(h==null?void 0:h.content)||(h==null?void 0:h.generatedContent)||"";x&&x!=="Generated successfully"?(u(x),y(x),m({title:"Brand Voice Generated",description:`Your ${d} has been created successfully. Review and apply when ready.`})):m({title:"Generation Error",description:"No content was generated. Please try again.",variant:"destructive"})},onError:h=>{m({title:"Generation Failed",description:h.message||"Failed to generate brand voice content. Please try again.",variant:"destructive"})},onSettled:()=>{J(!1)}}),R=()=>{if(!(s!=null&&s.companyName)){m({title:"Business Information Needed",description:"Please fill in your company name and description first to generate better brand voice content.",variant:"destructive"});return}const h={tagline:(s==null?void 0:s.tagline)||"",motto:(s==null?void 0:s.motto)||"",vision:(s==null?void 0:s.vision)||"",coreBeliefs:(s==null?void 0:s.coreBeliefs)||""};M.mutate({field:d,prompt:v,businessContext:s,aiPowerLevel:b,existingV
9alues:h})},C=()=>{const h=A||p;h&&(r(d,h),m({title:"Content Applied",description:`Your ${d} has been updated with the content.`}),u(""),y(""))},V=()=>{const h=A||p;h&&(navigator.clipboard.writeText(h),m({title:"Copied",description:"Content copied to clipboard."}))},i=N.find(h=>h.value===d),T=(i==null?void 0:i.icon)||Qe;return e.jsxs(pe,{className:"border-orange-200 bg-gradient-to-br from-orange-50 to-amber-50",children:[e.jsxs(be,{className:"text-center pb-3 px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(Gt,{className:"w-5 h-5 sm:w-6 sm:h-6 text-orange-600"}),e.jsx(Ne,{className:"w-3 h-3 sm:w-4 sm:h-4 text-amber-500"})]}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-gray-800",children:"Brand Voice AI Assistant"}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-600",children:"Generate compelling brand voice content tailored to your business"})]}),e.jsxs(he,{className:"space-y-3 sm:space-y-4 px-4 pb-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium text-gray-700 mb-2 block",children:"What would you like to create?"}),e.jsxs(at,{value:d,onValueChange:h=>{o(h),j==null||j(h)},children:[e.jsx(nt,{className:"text-xs sm:text-sm",children:e.jsx(rt,{children:i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(i.icon,{className:"w-4 h-4"}),e.jsx("span",{children:i.label})]})})}),e.jsx(it,{children:N.map(h=>{const x=h.icon;return e.jsx(lt,{value:h.value,children:e.jsxs("div",{className:"flex items-center gap-2 py-1",children:[e.jsx(x,{className:"w-4 h-4 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-sm",children:h.label}),e.jsx("div",{className:"text-xs text-gray-500 line-clamp-1",children:h.description})]})]})},h.value)})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs sm:text-sm font-medium text-gray-700 mb-2 block",children:"AI Quality Level"}),e.jsx("div",{className:"w-full",children:e.jsx(ot,{value:b,onChange:g,baseCredits:2,availableCredits:(w==null?void 0:w.aiCreditsRemaining)||1e3,showDetails:!0})})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs sm:text-sm font-medium text-gray-700 mb-2 block",children:["Additional Requirements ",e.jsx("span",{className:"text-xs text-gray-500",children:"(optional)"})]}),e.jsx(ks,{value:v,onChange:h=>P(h.target.value),placeholder:`Describe any specific requirements for your ${d}. For example: "Should be playful and energetic" or "Focus on sustainability and innovation"`,rows:3,className:"text-xs sm:text-sm resize-none"})]}),e.jsx(L,{onClick:R,disabled:k||M.isPending,className:"w-full bg-orange-600 hover:bg-orange-700 text-white py-3 text-sm sm:text-base",children:k?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"w-4 h-4 mr-2 animate-spin"}),e.jsx("span",{className:"truncate",children:"Generating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"w-4 h-4 mr-2 flex-shrink-0"}),e.jsxs("span",{className:"truncate",children:["Generate ",i==null?void 0:i.label]})]})}),p&&e.jsxs("div",{className:"border rounded-lg p-3 sm:p-4 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3 gap-2",children:[e.jsxs(ye,{variant:"secondary",className:"text-xs flex-shrink-0",children:["Generated ",i==null?void 0:i.label]}),e.jsxs("div",{className:"flex gap-1 sm:gap-2 flex-shrink-0",children:[e.jsxs(L,{size:"sm",variant:"outline",onClick:V,className:"text-xs px-2 sm:px-3",children:[e.jsx(Yt,{className:"w-3 h-3 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]}),e.jsxs(L,{size:"sm",onClick:C,className:"text-xs bg-green-600 hover:bg-green-700 text-white px-2 sm:px-3",children:[e.jsx(Qe,{className:"w-3 h-3 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Use This"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs text-gray-600 font-medium",children:"Review and edit before applying:"}),e.jsx(ks,{value:A,onChange:h=>{var x;return y(((x=h==null?void 0:h.target)==null?void 0:x.value)||"")},className:"text-xs sm:text-sm bg-gray-50 border-gray-300 focus:border-orange-500 focus:ring-orange-500 resize-none",rows:d==="tagline"||d==="motto"?2:4,placeholder:`Edit your ${d}...`})]})]}),(!(s!=null&&s.companyName)||!(s!=null&&s.description))&&e.jsx("div",{className:"hidden sm:block text-xs text-amber-600 bg-amber-50 p-3 rounded-lg border border-amber-200",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-sm flex-shrink-0",children:"💡"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Tip:"})," Fill in your company name and description above for more personalized brand voice suggestions."]})]})})]})]})}var Fs=1,na=.9,ra=.8,ia=.17,Xe=.1,es=.999,la=.9999,oa=.99,ca=/[\\\/_+.#"@\[\(\{&]/,da=/[\\\/_+.#"@\[\(\{&]/g,ma=/[\s-]/,Ws=/[\s-]/g;function is(s,r,a,j,m,d,o){if(d===r.length)return m===s.length?Fs:oa;var v=`${m},${d}`;if(o[v]!==void 0)return o[v];for(var P=j.charAt(d),p=a.indexOf(P,m),u=0,A,y,k,J;p>=0;)A=is(s,r,a,j,p+1,d+1,o),A>u&&(p===m?A*=Fs:ca.test(s.charAt(p-1))?(A*=ra,k=s.slice(m,p-1).match(da),k&&m>0&&(A*=Math.pow(es,k.length))):ma.test(s.charAt(p-1))?(A*=na,J=s.slice(m,p-1).match(Ws),J&&m>0&&(A*=Math.pow(es,J.length))):(A*=ia,m>0&&(A*=Math.pow(es,p-m))),s.charAt(p)!==r.charAt(d)&&(A*=la)),(A<Xe&&a.charAt(p-1)===j.charAt(d+1)||j.charAt(d+1)===j.charAt(d)&&a.charAt(p-1)!==j.charAt(d))&&
vendor: 10,645 bytes, line 9
9(y=is(s,r,a,j,p+1,d+2,o),y*Xe>A&&(A=y*Xe)),A>u&&(u=A),p=a.indexOf(P,p+1);return o[v]=u,u}function Vs(s){return s.toLowerCase().replace(Ws," ")}function ua(s,r,a){return s=a&&a.length>0?`${s+" "+a.join(" ")}`:s,is(s,r,Vs(s),Vs(r),0,0,{})}var Te='[cmdk-group=""]',ss='[cmdk-group-items=""]',xa='[cmdk-group-heading=""]',Qs='[cmdk-item=""]',Ds=`${Qs}:not([aria-disabled="true"])`,ls="cmdk-item-select",Ie="data-value",pa=(s,r,a)=>ua(s,r,a),Hs=l.createContext(void 0),Oe=()=>l.useContext(Hs),Zs=l.createContext(void 0),ds=()=>l.useContext(Zs),_s=l.createContext(void 0),Js=l.forwardRef((s,r)=>{let a=Me(()=>{var c,S;return{search:"",value:(S=(c=s.value)!=null?c:s.defaultValue)!=null?S:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),j=Me(()=>new Set),m=Me(()=>new Map),d=Me(()=>new Map),o=Me(()=>new Set),v=Xs(s),{label:P,children:p,value:u,onValueChange:A,filter:y,shouldFilter:k,loop:J,disablePointerSelection:K=!1,vimBindings:w=!0,...b}=s,g=De(),N=De(),M=De(),R=l.useRef(null),C=Sa();we(()=>{if(u!==void 0){let c=u.trim();a.current.value=c,V.emit()}},[u]),we(()=>{C(6,W)},[]);let V=l.useMemo(()=>({subscribe:c=>(o.current.add(c),()=>o.current.delete(c)),snapshot:()=>a.current,setState:(c,S,D)=>{var f,O,B,n;if(!Object.is(a.current[c],S)){if(a.current[c]=S,c==="search")H(),h(),C(1,x);else if(c==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let t=document.getElementById(M);t?t.focus():(f=document.getElementById(g))==null||f.focus()}if(C(7,()=>{var t;a.current.selectedItemId=(t=re())==null?void 0:t.id,V.emit()}),D||C(5,W),((O=v.current)==null?void 0:O.value)!==void 0){let t=S??"";(n=(B=v.current).onValueChange)==null||n.call(B,t);return}}V.emit()}},emit:()=>{o.current.forEach(c=>c())}}),[]),i=l.useMemo(()=>({value:(c,S,D)=>{var f;S!==((f=d.current.get(c))==null?void 0:f.value)&&(d.current.set(c,{value:S,keywords:D}),a.current.filtered.items.set(c,T(S,D)),C(2,()=>{h(),V.emit()}))},item:(c,S)=>(j.current.add(c),S&&(m.current.has(S)?m.current.get(S).add(c):m.current.set(S,new Set([c]))),C(3,()=>{H(),h(),a.current.value||x(),V.emit()}),()=>{d.current.delete(c),j.current.delete(c),a.current.filtered.items.delete(c);let D=re();C(4,()=>{H(),(D==null?void 0:D.getAttribute("id"))===c&&x(),V.emit()})}),group:c=>(m.current.has(c)||m.current.set(c,new Set),()=>{d.current.delete(c),m.current.delete(c)}),filter:()=>v.current.shouldFilter,label:P||s["aria-label"],getDisablePointerSelection:()=>v.current.disablePointerSelection,listId:g,inputId:M,labelId:N,listInnerRef:R}),[]);function T(c,S){var D,f;let O=(f=(D=v.current)==null?void 0:D.filter)!=null?f:pa;return c?O(c,a.current.search,S):0}function h(){if(!a.current.search||v.current.shouldFilter===!1)return;let c=a.current.filtered.items,S=[];a.current.filtered.groups.forEach(f=>{let O=m.current.get(f),B=0;O.forEach(n=>{let t=c.get(n);B=Math.max(t,B)}),S.push([f,B])});let D=R.current;ee().sort((f,O)=>{var B,n;let t=f.getAttribute("id"),$=O.getAttribute("id");return((B=c.get($))!=null?B:0)-((n=c.get(t))!=null?n:0)}).forEach(f=>{let O=f.closest(ss);O?O.appendChild(f.parentElement===O?f:f.closest(`${ss} > *`)):D.appendChild(f.parentElement===D?f:f.closest(`${ss} > *`))}),S.sort((f,O)=>O[1]-f[1]).forEach(f=>{var O;let B=(O=R.current)==null?void 0:O.querySelector(`${Te}[${Ie}="${encodeURIComponent(f[0])}"]`);B==null||B.parentElement.appendChild(B)})}function x(){let c=ee().find(D=>D.getAttribute("aria-disabled")!=="true"),S=c==null?void 0:c.getAttribute(Ie);V.setState("value",S||void 0)}function H(){var c,S,D,f;if(!a.current.search||v.current.shouldFilter===!1){a.current.filtered.count=j.current.size;return}a.current.filtered.groups=new Set;let O=0;for(let B of j.current){let n=(S=(c=d.current.get(B))==null?void 0:c.value)!=null?S:"",t=(f=(D=d.current.get(B))==null?void 0:D.keywords)!=null?f:[],$=T(n,t);a.current.filtered.items.set(B,$),$>0&&O++}for(let[B,n]of m.current)for(let t of n)if(a.current.filtered.items.get(t)>0){a.current.filtered.groups.add(B);break}a.current.filtered.count=O}function W(){var c,S,D;let f=re();f&&(((c=f.parentElement)==null?void 0:c.firstChild)===f&&((D=(S=f.closest(Te))==null?void 0:S.querySelector(xa))==null||D.scrollIntoView({block:"nearest"})),f.scrollIntoView({block:"nearest"}))}function re(){var c;return(c=R.current)==null?void 0:c.querySelector(`${Qs}[aria-selected="true"]`)}function ee(){var c;return Array.from(((c=R.current)==null?void 0:c.querySelectorAll(Ds))||[])}function se(c){let S=ee()[c];S&&V.setState("value",S.getAttribute(Ie))}function X(c){var S;let D=re(),f=ee(),O=f.findIndex(n=>n===D),B=f[O+c];(S=v.current)!=null&&S.loop&&(B=O+c<0?f[f.length-1]:O+c===f.length?f[0]:f[O+c]),B&&V.setState("value",B.getAttribute(Ie))}function ue(c){let S=re(),D=S==null?void 0:S.closest(Te),f;for(;D&&!f;)D=c>0?wa(D,Te):Ca(D,Te),f=D==null?void 0:D.querySelector(Ds);f?V.setState("value",f.getAttribute(Ie)):X(c)}let xe=()=>se(ee().length-1),Be=c=>{c.preventDefault(),c.metaKey?xe():c.altKey?ue(1):X(1)},qe=c=>{c.preventDefault(),c.metaKey?se(0):c.altKey?ue(-1):X(-1)};return l.createElement(ve.div,{ref:r,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:c=>{var S;(S=b.onKeyDown)==null||S.call(b,c);let D=c.nativeEvent.isComposing||c.keyCode===229;if(!(c.defaultPrevented||D))switch(c.key){case"n":case"j":{w&&c.ctrlKey&&Be(c);break}case"ArrowDown":{Be(c);break}case"p":case"k":{w&&c.ctrlKey&&qe(c);break}case"ArrowUp":{qe(c);break}case"Home":{c.preventDefault(),se(0);break}case"End":{c.preventDefault(),xe();break}case"Enter":{c.preventDefault();let f=re();if(f){let O=new Event(ls);f.dispatchEvent(O)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:i.inputId,id:i.labelId,style:Aa},P),Je(s,c=>l.createElement(Zs.Provider,{value:V},l.createElement(Hs.Provider,{value:i},c))))}),ha=l.forwardRef((s,r)=>{var a,j;let m=De(),d=l.useRef(null),o=l.useContext(_s),v=Oe(),P=Xs(s),p=(j=(a=P.current)==null?void 0:a.forceMount)!=null?j:o==null?void 0:o.forceMount;we(()=>{if(!p)return v.item(m,o==null?void 0:o.id)},[p]);let u=et(m,d,[s.value,s.children,d],s.keywords),A=ds(),y=je(C=>C.value&&C.value===u.current),k=je(C=>p||v.filter()===!1?!0:C.search?C.filtered.items.get(m)>0:!0);l.useEffect(()=>{let C=d.current;if(!(!C||s.disabled))return C.addEventListener(ls,J),()=>C.removeEventListener(ls,J)},[k,s.onSelect,s.disabled]);function J(){var C,V;K(),(V=(C=P.current).onSelect)==null||V.call(C,u.current)}function K(){A.setState("value",u.current,!0)}if(!k)return null;let{disabled:w,value:b,onSelect:g,forceMount:N,keywords:M,...R}=s;return l.createElement(ve.div,{ref:Le(d,r),...R,id:m,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!y,"data-disabled":!!w,"data-selected":!!y,onPointerMove:w||v.getDisablePointerSelection()?void 0:K,onClick:w?void 0:J},s.children)}),ga=l.forwardRef((s,r)=>{let{heading:a,children:j,forceMount:m,...d}=s,o=De(),v=l.useRef(null),P=l.useRef(null),p=De(),u=Oe(),A=je(k=>m||u.filter()===!1?!0:k.search?k.filtered.groups.has(o):!0);we(()=>u.group(o),[]),et(o,v,[s.value,s.heading,P]);let y=l.useMemo(()=>({id:o,forceMount:m}),[m]);return l.createElement(ve.div,{ref:Le(v,r),...d,"cmdk-group":"",role:"presentation",hidden:A?void 0:!0},a&&l.createElement("div",{ref:P,"cmdk-group-heading":"","aria-hidden":!0,id:p},a),Je(s,k=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?p:void 0},l.createElement(_s.Provider,{value:y},k))))}),fa=l.forwardRef((s,r)=>{let{alwaysRender:a,...j}=s,m=l.useRef(null),d=je(o=>!o.search);return!a&&!d?null:l.createElement(ve.div,{ref:Le(m,r),...j,"cmdk-separator":"",role:"separator"})}),ja=l.forwardRef((s,r)=>{let{onValueChange:a,...j}=s,m=s.value!=null,d=ds(),o=je(p=>p.search),v=je(p=>p.selectedItemId),P=Oe();return l.useEffect(()=>{s.value!=null&&d.setState("search",s.value)},[s.value]),l.createElement(ve.input,{ref:r,...j,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":P.listId,"aria-labelledby":P.labelId,"aria-activedescendant":v,id:P.inputId,type:"text",value:m?s.value:o,onChange:p=>{m||d.setState("search",p.target.value),a==null||a(p.target.value)}})}),va=l.forwardRef((s,r)=>{let{children:a,label:j="Suggestions",...m}=s,d=l.useRef(null),o=l.useRef(null),v=je(p=>p.selectedItemId),P=Oe();return l.useEffect(()=>{if(o.current&&d.current){let p=o.current,u=d.current,A,y=new ResizeObserver(()=>{A=requestAnimationFrame(()=>{let k=p.offsetHeight;u.style.setProperty("--cmdk-list-height",k.toFixed(1)+"px")})});return y.observe(p),()=>{cancelAnimationFrame(A),y.unobserve(p)}}},[]),l.createElement(ve.div,{ref:Le(d,r),...m,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":v,"aria-label":j,id:P.listId},Je(s,p=>l.createElement("div",{ref:Le(o,P.listInnerRef),"cmdk-list-sizer":""},p)))}),ya=l.forwardRef((s,r)=>{let{open:a,onOpenChange:j,overlayClassName:m,contentClassName:d,container:o,...v}=s;return l.createElement(mt,{open:a,onOpenChange:j},l.createElement(ut,{container:o},l.createElement(xt,{"cmdk-overlay":"",className:m}),l.createElement(pt,{"aria-label":s.label,"cmdk-dialog":"",className:d},l.createElement(Js,{ref:r,...v}))))}),ba=l.forwardRef((s,r)=>je(a=>a.filtered.count===0)?l.createElement(ve.div,{ref:r,...s,"cmdk-empty":"",role:"presentation"}):null),Na=l.forwardRef((s,r)=>{let{progress:a,children:j,label:m="Loading...",...d}=s;return l.createElement(ve.div,{ref:r,...d,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":m},Je(s,o=>l.createElement("div",{"aria-hidden":!0},o)))}),le=Object.assign(Js,{List:va,Item:ha,Input:ja,Group:ga,Separator:fa,Dialog:ya,Empty:ba,Loading:Na});function wa(s,r){let a=s.nextElementSibling;for(;a;){if(a.matches(r))return a;a=a.nextElementSibling}}function Ca(s,r){let a=s.previousElementSibling;for(;a;){if(a.matches(r))return a;a=a.previousElementSibling}}function Xs(s){let r=l.useRef(s);return we(()=>{r.current=s}),r}var we=typeof window>"u"?l.useEffect:l.useLayoutEffect;function Me(s){let r=l.useRef();return r.current===void 0&&(r.current=s()),r}function je(s){let r=ds(),a=()=>s(r.snapshot());return l.useSyncExternalStore(r.subscribe,a,a)}function et(s,r,a,j=[]){let m=l.useRef(),d=Oe();return we(()=>{var o;let v=(()=>{var p;for(let u of a){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(p=u.current.textContent)==null?void 0:p.trim():m.current}})(),P=j.map(p=>p.trim());d.value(s,v,P),(o=r.current)==null||o.setAttribute(Ie,v),m.current=v}),m}var Sa=()=>{let[s,r]=l.useState(),a=Me(()=>new Map);return we(()=>{a.current.forEach(j=>
9j()),a.current=new Map},[s]),(j,m)=>{a.current.set(j,m),r({})}};function ka(s){let r=s.type;return typeof r=="function"?r(s.props):"render"in r?r.render(s.props):s}function Je({asChild:s,children:r},a){return s&&l.isValidElement(r)?l.cloneElement(ka(r),{ref:r.ref},a(r.props.children)):a(r)}var Aa={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const ms=l.forwardRef(({className:s,...r},a)=>e.jsx(le,{ref:a,className:ge("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",s),...r}));ms.displayName=le.displayName;const us=l.forwardRef(({className:s,...r},a)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx($s,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(le.Input,{ref:a,className:ge("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",s),...r})]}));us.displayName=le.Input.displayName;const Pa=l.forwardRef(({className:s,...r},a)=>e.jsx(le.List,{ref:a,className:ge("max-h-[300px] overflow-y-auto overflow-x-hidden",s),...r}));Pa.displayName=le.List.displayName;const xs=l.forwardRef((s,r)=>e.jsx(le.Empty,{ref:r,className:"py-6 text-center text-sm",...s}));xs.displayName=le.Empty.displayName;const ps=l.forwardRef(({className:s,...r},a)=>e.jsx(le.Group,{ref:a,className:ge("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",s),...r}));ps.displayName=le.Group.displayName;const Ea=l.forwardRef(({className:s,...r},a)=>e.jsx(le.Separator,{ref:a,className:ge("-mx-1 h-px bg-border",s),...r}));Ea.displayName=le.Separator.displayName;const hs=l.forwardRef(({className:s,...r},a)=>e.jsx(le.Item,{ref:a,className:ge("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s),...r}));hs.displayName=le.Item.displayName;function Ia({value:s,onChange:r,placeholder:a}){const[j,m]=l.useState(!1),[d,o]=l.useState(""),v=Da.filter(u=>u.toLowerCase().includes(d.toLowerCase())),P=u=>{r(u),m(!1),o("")},p=u=>{u.key==="Enter"&&d&&!v.length&&(u.preventDefault(),r(d),m(!1),o(""))};return e.jsxs(Us,{open:j,onOpenChange:m,children:[e.jsx(zs,{asChild:!0,children:e.jsxs(L,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between text-left font-normal","data-testid":"input-service-category",children:[s||a||"Select or type category...",e.jsx(cs,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Gs,{className:"w-full p-0",align:"start",children:e.jsxs(ms,{children:[e.jsx(us,{placeholder:"Search categories or type custom...",value:d,onValueChange:o,onKeyDown:p}),e.jsx(xs,{children:e.jsxs("div",{className:"p-2 text-sm text-muted-foreground",children:['No category found. Press Enter to use "',d,'" as custom category.']})}),e.jsx(ps,{className:"max-h-64 overflow-auto",children:v.map(u=>e.jsx(hs,{onSelect:()=>P(u),className:"cursor-pointer",children:u},u))})]})})]})}function Ma({value:s,onChange:r,placeholder:a}){const[j,m]=l.useState(!1),[d,o]=l.useState(""),v=Ra.filter(u=>u.toLowerCase().includes(d.toLowerCase())),P=u=>{r(u),m(!1),o("")},p=u=>{u.key==="Enter"&&d&&!v.length&&(u.preventDefault(),r(d),m(!1),o(""))};return e.jsxs(Us,{open:j,onOpenChange:m,children:[e.jsx(zs,{asChild:!0,children:e.jsxs(L,{variant:"outline",role:"combobox","aria-expanded":j,className:"w-full justify-between text-left font-normal","data-testid":"input-delivery-method",children:[s||a||"Select delivery method...",e.jsx(cs,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Gs,{className:"w-full p-0",align:"start",children:e.jsxs(ms,{children:[e.jsx(us,{placeholder:"Search methods or type custom...",value:d,onValueChange:o,onKeyDown:p}),e.jsx(xs,{children:e.jsxs("div",{className:"p-2 text-sm text-muted-foreground",children:['No method found. Press Enter to use "',d,'" as custom method.']})}),e.jsx(ps,{className:"max-h-64 overflow-auto",children:v.map(u=>e.jsx(hs,{onSelect:()=>P(u),className:"cursor-pointer",children:u},u))})]})})]})}function Fa({marketingScore:s,improvementSuggestions:r}){if(!s)return null;const a=o=>o>=80?"text-green-600 bg-green-100":o>=60?"text-yellow-600 bg-yellow-100":"text-orange-600 bg-orange-100",j=o=>o>=80?"bg-green-500":o>=60?"bg-yellow-500":"bg-orange-500",m=o=>{const v={high:"bg-red-100 text-red-800 border-red-200",medium:"bg-yellow-100 text-yellow-800 border-yellow-200",low:"bg-blue-100 text-blue-800 border-blue-200"};return v[o]||v.low},d=o=>{switch(o){case"completeness":return e.jsx(Rt,{className:"w-4 h-4"});case"clarity":return e.jsx(Ze,{className:"w-4 h-4"});case"persuasiveness":return e.jsx(Dt,{className:"w-4 h-4"});default:return e.jsx(Ys,{className:"w-4 h-4"})}};return e.jsxs("div",{className:"space-y-4 mb-6 p-4 bg-gradient-to-r from-orange-50 to-amber-50 rounded-lg border border-orange-200",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center text-2xl font-bold ${a(s.overall)}`,children:s.overall}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Marketing Quality Score"}),e.jsx("p",{className:"text-sm text-gray-600",children:"AI-powered analysis of your service marketing content"})]})]}),e.jsx(ye,{variant:"outline",className:"text-sm",children:s.overall>=80?"🎯 Excellent":s.overall>=60?"👍 Good":"🔧 Needs Improvement"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Completeness"}),e.jsxs("span",{className:"text-sm font-bold",children:[s.completeness,"/100"]})]}),e.jsx("div",{className:"h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${j(s.completeness)} transition-all`,style:{width:`${s.completeness}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Clarity"}),e.jsxs("span",{className:"text-sm font-bold",children:[s.clarity,"/100"]})]}),e.jsx("div",{className:"h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${j(s.clarity)} transition-all`,style:{width:`${s.clarity}%`}})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Persuasiveness"}),e.jsxs("span",{className:"text-sm font-bold",children:[s.persuasiveness,"/100"]})]}),e.jsx("div",{className:"h-2 bg-gray-200 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${j(s.persuasiveness)} transition-all`,style:{width:`${s.persuasiveness}%`}})})]})]}),r&&r.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("h4",{className:"font-medium text-sm mb-3 flex items-center gap-2",children:[e.jsx(Qe,{className:"w-4 h-4 text-amber-600"}),"Improvement Suggestions"]}),e.jsx("div",{className:"space-y-2",children:r.slice(0,3).map((o,v)=>e.jsxs("div",{className:"p-3 bg-white rounded-md border border-gray-200",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(ye,{variant:"outline",className:`text-xs ${m(o.priority)}`,children:o.priority.toUpperCase()}),e.jsxs(ye,{variant:"secondary",className:"text-xs flex items-center gap-1",children:[d(o.category),o.category]})]}),e.jsx("p",{className:"text-sm font-medium text-gray-900 mb-1",children:o.issue}),e.jsx("p",{className:"text-sm text-gray-700 mb-2",children:o.suggestion}),o.example&&e.jsxs("div",{className:"p-2 bg-gray-50 rounded border-l-2 border-amber-500",children:[e.jsx("p",{className:"text-xs text-gray-600 font-medium mb-1",children:"Example:"}),e.jsx("p",{className:"text-xs text-gray-700 italic",children:o.example})]})]},v))}),r.length>3&&e.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["+",r.length-3," more suggestions"]})]})]})}function Va({isOpen:s,onClose:r,previewData:a,analysisResult:j,onApplySelected:m}){var K;const[d,o]=l.useState({}),[v,P]=l.useState({});l.useEffect(()=>{if(a){const w={},b={};
9Object.entries(a.basicInfo).forEach(([g,N])=>{var M;N&&(b[`basicInfo.${g}`]=((M=N.value)==null?void 0:M.toString())||"",N.quality==="high"&&N.confidence>.8&&(w[`basicInfo.${g}`]=!0))}),Object.entries(a.advancedDetails).forEach(([g,N])=>{var M;N&&(b[`advancedDetails.${g}`]=((M=N.value)==null?void 0:M.toString())||"",N.quality==="high"&&N.confidence>.8&&(w[`advancedDetails.${g}`]=!0))}),o(w),P(b)}},[a]);const p=(w,b)=>{const g={high:"bg-green-100 text-green-800 border-green-200",medium:"bg-yellow-100 text-yellow-800 border-yellow-200",low:"bg-red-100 text-red-800 border-red-200"},N={high:e.jsx(Tt,{className:"w-3 h-3"}),medium:e.jsx(Ht,{className:"w-3 h-3"}),low:e.jsx(Zt,{className:"w-3 h-3"})};return e.jsxs(ye,{variant:"outline",className:`text-xs ${g[w]} flex items-center gap-1`,children:[N[w],Math.round(b*100),"%"]})},u=(w,b,g)=>{var C;const N=`${g}.${w}`,M=d[N],R=b.currentValue!==null&&b.currentValue!==void 0&&b.currentValue!=="";return e.jsx("div",{className:"p-2 sm:p-3 bg-gray-50 rounded-lg border",children:e.jsx("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:e.jsxs("div",{className:"flex items-start gap-2 sm:gap-3 flex-1 min-w-0",children:[e.jsx(Vt,{id:N,checked:M,onCheckedChange:V=>o(i=>({...i,[N]:!!V})),"data-testid":`checkbox-field-${N}`,className:"mt-1 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-1 sm:gap-2 mb-2",children:[e.jsx("label",{htmlFor:N,className:"font-medium text-xs sm:text-sm capitalize cursor-pointer",children:w.replace(/([A-Z])/g," $1").toLowerCase()}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[p(b.quality,b.confidence),b.source&&e.jsxs(ye,{variant:"secondary",className:"text-xs",children:[e.jsx(Ys,{className:"w-3 h-3 mr-1"}),b.source]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Extracted Value (editable):"}),e.jsx("textarea",{value:v[N]||"",onChange:V=>P(i=>({...i,[N]:V.target.value})),className:"w-full text-xs sm:text-sm font-mono bg-white p-2 rounded border break-words resize-none min-h-[60px] focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent",placeholder:"Enter value...","data-testid":`textarea-edit-${N}`})]}),R&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Current Form Value:"}),e.jsx("div",{className:"text-xs sm:text-sm font-mono bg-yellow-50 p-2 rounded border border-yellow-200 break-words",children:(C=b.currentValue)==null?void 0:C.toString()}),v[N]!==b.currentValue&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-orange-600 mt-1",children:[e.jsx(Qt,{className:"w-3 h-3 flex-shrink-0"}),"Will replace existing value"]})]})]})]})]})})},N)},A=w=>{const b={};Object.keys(a.basicInfo).forEach(g=>{a.basicInfo[g]&&(b[`basicInfo.${g}`]=w)}),Object.keys(a.advancedDetails).forEach(g=>{a.advancedDetails[g]&&(b[`advancedDetails.${g}`]=w)}),o(b)},y=()=>{const w={};return Object.entries(d).forEach(([b,g])=>{if(g){const[N,M]=b.split("."),R=v[b];R!==void 0&&R!==""&&(w[M]=R)}}),w},k=Object.values(d).filter(Boolean).length,J=Object.values(a.basicInfo).filter(Boolean).length+Object.values(a.advancedDetails).filter(Boolean).length;return e.jsx(vt,{open:s,onOpenChange:w=>{w||r()},children:e.jsxs(yt,{className:"w-full max-w-full sm:max-w-2xl md:max-w-4xl max-h-[90vh] overflow-hidden flex flex-col p-4 sm:p-6","data-testid":"preview-modal",children:[e.jsxs(bt,{className:"flex-shrink-0 px-0 sm:px-0",children:[e.jsxs(Nt,{className:"flex items-center gap-2 text-lg sm:text-xl",children:[e.jsx(Ze,{className:"w-4 h-4 sm:w-5 sm:h-5 text-blue-600 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:"Preview Service Data"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mt-3",children:[e.jsx("p",{className:"text-xs sm:text-sm text-gray-600",children:"Review and select the data you'd like to apply to your form"}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-4 text-xs sm:text-sm",children:[e.jsxs("span",{className:"text-gray-600 whitespace-nowrap",children:[k," of ",J," selected"]}),e.jsxs("div",{className:"flex gap-2 w-full sm:w-auto",children:[e.jsx(L,{variant:"outline",size:"sm",onClick:()=>A(!0),"data-testid":"button-select-all",className:"text-xs flex-1 sm:flex-none",children:"All"}),e.jsx(L,{variant:"outline",size:"sm",onClick:()=>A(!1),"data-testid":"button-select-none",className:"text-xs flex-1 sm:flex-none",children:"None"})]})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3 sm:space-y-6 py-4 px-0",children:[e.jsx("div",{className:"px-0",children:e.jsx(Fa,{marketingScore:a.marketingScore,improvementSuggestions:a.improvementSuggestions})}
9),e.jsxs("div",{className:"bg-blue-50 p-3 sm:p-4 rounded-lg border border-blue-200 mx-0",children:[e.jsxs("h3",{className:"font-medium text-blue-900 mb-2 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(Os,{className:"w-4 h-4 flex-shrink-0"}),"Analysis Summary"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 sm:gap-4 text-xs sm:text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-blue-700 font-medium",children:"Website"}),e.jsx("div",{className:"text-blue-600 truncate",children:j.extractedContent.title})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-blue-700 font-medium",children:"Fields Extracted"}),e.jsx("div",{className:"text-blue-600",children:((K=j.extractionMetadata)==null?void 0:K.totalFieldsExtracted)||J})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-blue-700 font-medium",children:"Overall Confidence"}),e.jsxs("div",{className:"text-blue-600",children:[Math.round(j.analysis.confidence||0),"%"]})]})]})]}),Object.keys(a.basicInfo).length>0&&e.jsxs("div",{className:"px-0",children:[e.jsxs("h3",{className:"font-medium text-gray-900 mb-3 flex items-center gap-2 text-sm sm:text-base",children:[e.jsx(_e,{className:"w-4 h-4 flex-shrink-0"}),"Basic Service Information"]}),e.jsx("div",{className:"space-y-2 sm:space-y-3",children:Object.entries(a.basicInfo).map(([w,b])=>b?u(w,b,"basicInfo"):null)})]}),Object.keys(a.advancedDetails).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wt,{}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4"}),"Advanced Service Details"]}),e.jsx("div",{className:"space-y-3",children:Object.entries(a.advancedDetails).map(([w,b])=>b?u(w,b,"advancedDetails"):null)})]})]})]}),e.jsx(Ct,{className:"flex-shrink-0 border-t pt-4",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsx("div",{className:"text-sm text-gray-500",children:k>0?`${k} field${k!==1?"s":""} will be applied`:"No fields selected"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(L,{variant:"outline",onClick:r,"data-testid":"button-cancel-preview",children:"Cancel"}),e.jsxs(L,{onClick:()=>{m(y()),r()},disabled:k===0,className:"flex items-center gap-2","data-testid":"button-apply-selected",children:[e.jsx(St,{className:"w-4 h-4"}),"Apply Selected (",k,")"]})]})]})})]})})}const Da=["Service","Product","Consulting","Repair/Maintenance","Design/Creative","Training/Education","Installation","Analysis/Assessment","Support","Custom"],Ra=["In-Person","Remote","Hybrid","Digital Product","Physical Product"],Ta=I.object({name:I.string().min(1,"Service name is required"),category:I.string().optional(),deliveryMethod:I.string().min(1,"Delivery method is required"),basePrice:I.number().min(0,"Price must be positive").optional(),estimatedDuration:I.string().optional(),shortDescription:I.string().max(200,"Keep de
9scription under 200 characters").optional(),detailedDescription:I.string().optional(),targetAudience:I.string().optional(),deliverables:I.string().optional(),prerequisites:I.string().optional(),pricingNotes:I.string().optional(),processSteps:I.string().optional(),successMetrics:I.string().optional(),competitiveAdvantages:I.string().optional(),keyFeatures:I.string().optional(),keyBenefits:I.string().optional(),uniqueValueProposition:I.string().optional(),painPointsSolved:I.string().optional()}),$a=I.object({url:I.string().url("Please enter a valid URL").refine(s=>s.startsWith("http://")||s.startsWith("https://"),{message:"URL must start with http:// or https://"})});function La({service:s,onEdit:r,onDelete:a,shouldCollapse:j}){const[m,d]=l.useState(!1),o=s.advancedDetails||{};l.useEffect(()=>{j&&d(!1)},[j]);const v=[o.detailedDescription,o.targetAudience,o.deliverables,o.prerequisites,o.pricingNotes,o.processSteps,o.successMetrics,o.competitiveAdvantages],P=v.filter(u=>u&&(typeof u=="string"?u.trim():Array.isArray(u)?u.length>0:!0)).length,p=Math.round(P/v.length*100);return e.jsxs(pe,{className:"border-l-4 border-l-orange-500","data-testid":`service-card-${s.id}`,children:[e.jsx(be,{className:"pb-3",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-start md:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Re,{className:"text-lg break-words",children:s.name}),e.jsxs("div",{className:"grid grid-cols-2 md:flex md:items-center md:flex-wrap gap-2 md:gap-4 mt-2 text-xs md:text-sm text-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap overflow-hidden",children:[e.jsx(_e,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s.category})]}),e.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap overflow-hidden",children:[e.jsx(Kt,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s.deliveryMethod})]}),s.basePrice&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 whitespace-nowrap overflow-hidden",children:[e.jsx(kt,{className:"w-4 h-4 flex-shrink-0"}),e.jsxs("span",{className:"truncate",children:["$",s.basePrice.toLocaleString()]})]}),s.estimatedDuration&&e.jsxs("span",{className:"flex items-center gap-1 whitespace-nowrap overflow-hidden",children:[e.jsx(At,{className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s.estimatedDuration})]})]}),s.shortDescription&&e.jsx("p",{className:"text-xs md:text-sm text-gray-700 mt-2",children:s.shortDescription})]}),e.jsxs("div",{className:"flex items-center gap-2 md:ml-4 flex-shrink-0",children:[e.jsx(L,{variant:"ghost",size:"sm",onClick:()=>r(s),"data-testid":`button-edit-service-${s.id}`,children:e.jsx(Wt,{className:"w-4 h-4"})}),e.jsx(L,{variant:"ghost",size:"sm",onClick:()=>a(s.id),className:"text-red-600 hover:text-red-700","data-testid":`button-delete-service-${s.id}`,children:e.jsx(Pt,{className:"w-4 h-4"})})]})]})}),e.jsxs(Et,{open:m,onOpenChange:d,children:[e.jsx(It,{asChild:!0,children:e.jsxs(L,{variant:"ghost",className:"w-full justify-between px-6 py-2 h-auto border-t","data-testid":`button-expand-service-${s.id}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 text-orange-500"}),e.jsx("span",{children:"Advanced Details"}),e.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[e.jsx("div",{className:"w-16 bg-gray-200 rounded-full h-2",children:e.jsx("div",{className:"bg-orange-500 h-2 rounded-full transition-all duration-300",style:{width:`${p}%`}})}),e.jsxs("span",{className:"text-xs text-gray-500",children:[p,"%"]}),p===100&&e.jsx(fe,{className:"w-4 h-4 text-green-500"})]})]}),m?e.jsx(cs,{className:"w-4 h-4"}):e.jsx(Mt,{className:"w-4 h-4"})]})}),e.jsx(Ft,{children:e.jsxs(he,{className:"pt-4 space-y-4 bg-gray-50",children:[o.detailedDescription&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm text-gray-700 mb-1",children:"Detailed Description"}),e.jsx("p",{className:"text-sm text-gray-600",children:o.detailedDescription})]}),o.targetAudience&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm text-gray-700 mb-1",children:"Target Audience"}),e.jsx("p",{className:"text-sm text-gray-600",children:o.targetAudience})]}),o.deliverables&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm text-gray-700 mb-1",children:"Deliverables"}),e.jsx("p",{className:"text-sm text-gray-600",children:o.deliverables})]}),o.competitiveAdvantages&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-sm text-gray-700 mb-1",children:"Competitive Advantages"}),e.jsx("p",{className:"text-sm text-gray-600",children:o.competitiveAdvantages})]}),p<100&&e.jsx("div",{className:"pt-2 border-t border-gray-200",children:e.jsxs(L,{type:"button",variant:"outline",size:"sm",onClick:u=>{u.preventDefault(),u.stopPropagation(),console.log("[COMPLETE SERVICE] Button clicked for service:",s.id,s.name),r(s)},className:"text-orange-600 hover:text-orange-700 whitespace-normal text-left h-auto py-2 w-full justify-start","data-testid":`button-complete-service-${s.id}`,children:[e.jsx(Ne,{className:"w-4 h-4 mr-2 flex-shrink-0"}),e.jsxs("span",{className:"break-words",children:["Complete Service Details (",8-P," fields remaining)"]})]})})]})})]})]})}function Oa({companyId:s}){var O,B;const{toast:r}=He(),a=os(),{activeCompanyId:j}=Ls(),{isAuthenticated:m,isLoading:d,error:o}=ht(),v=m&&!d&&!o,[P,p]=l.useState(!1),[u,A]=l.useState(null),[y,k]=l.useState(null),[J,K]=l.useState(!1),[w,b]=l.useState(null),[g,N]=l.useState(new Set),[M,R]=l.useState({isOpen:!1,data:null,analysisResult:null,hasChanges:!1,selectedFieldsCount:0}),C=s||j;l.useEffect(()=>{if(y){const n=setTimeout(()=>{k(null)},100);return()=>clearTimeout(n)}},[y]);const{data:V=[],isLoading:i,error:T}=ts({queryKey:["/api/business-services",C],queryFn:async()=>{const n=await fetch("/api/business-services");if(!n.ok)throw new Error(`Failed to fetch services: ${n.statusText}`);return n.json()},enabled:!!C,retry:3,staleTime:0});l.useEffect(()=>{C&&a.invalidateQueries({queryKey:["/api/business-services"]})},[C,a]);const h=Array.isArray(V)?V:[],x=as({resolver:rs(Ta),defaultValues:{name:"",category:"",deliveryMethod:"",basePrice:void 0,estimatedDuration:"",shortDe
9scription:"",detailedDescription:"",targetAudience:"",deliverables:"",prerequisites:"",pricingNotes:"",processSteps:"",successMetrics:"",competitiveAdvantages:"",keyFeatures:"",keyBenefits:"",uniqueValueProposition:"",painPointsSolved:""}}),H=as({resolver:rs($a),mode:"onChange",defaultValues:{url:""}}),W=n=>!n||n.trim()===""?[]:n.split(/[\n,]+/).map(t=>t.trim()).filter(t=>t.length>0),re=Fe({mutationFn:async n=>{const{detailedDescription:t,targetAudience:$,deliverables:Z,prerequisites:te,pricingNotes:F,processSteps:ae,successMetrics:Q,competitiveAdvantages:de,keyFeatures:Ce,keyBenefits:Se,uniqueValueProposition:ke,painPointsSolved:Ae,...Pe}=n;return Ve("/api/business-services",{method:"POST",body:JSON.stringify({...Pe,companyId:C,advancedDetails:{detailedDescription:t,targetAudience:$,deliverables:W(Z),prerequisites:te,pricingNotes:F,processSteps:ae,successMetrics:W(Q),competitiveAdvantages:W(de),keyFeatures:W(Ce),keyBenefits:W(Se),uniqueValueProposition:ke,painPointsSolved:W(Ae)}})})},onSuccess:()=>{a.invalidateQueries({queryKey:["/api/business-services",C]}),x.reset(),H.reset(),p(!1),K(!1),b(null),N(new Set),R({isOpen:!1,data:null,analysisResult:null,hasChanges:!1,selectedFieldsCount:0}),r({description:"Service created successfully!"})},onError:()=>{r({description:"Failed to create service",variant:"destructive"})}}),ee=Fe({mutationFn:async n=>{const{id:t,detailedDescription:$,targetAudience:Z,deliverables:te,prerequisites:F,pricingNotes:ae,processSteps:Q,successMetrics:de,competitiveAdvantages:Ce,keyFeatures:Se,keyBenefits:ke,uniqueValueProposition:Ae,painPointsSolved:Pe,...Ue}=n;return Ve(`/api/business-services/${t}`,{method:"PATCH",body:JSON.stringify({...Ue,advancedDetails:{detailedDescription:$,targetAudience:Z,deliverables:W(te),prerequisites:F,pricingNotes:ae,processSteps:Q,successMetrics:W(de),competitiveAdvantages:W(Ce),keyFeatures:W(Se),keyBenefits:W(ke),uniqueValueProposition:Ae,painPointsSolved:W(Pe)}})})},onSuccess:(n,t)=>{a.invalidateQueries({queryKey:["/api/business-services",C]}),x.reset(),H.reset(),A(null),K(!1),b(null),N(new Set),R({isOpen:!1,data:null,analysisResult:null,hasChanges:!1,selectedFieldsCount:0}),k(t.id),r({description:"Service updated successfully!"})},onError:()=>{r({description:"Failed to update service",variant:"destructive"})}}),se=Fe({mutationFn:n=>Ve(`/api/business-services/${n}`,{method:"DELETE"}),onSuccess:()=>{a.invalidateQueries({queryKey:["/api/business-services",C]}),r({description:"Service deleted successfully!"})},onError:()=>{r({description:"Failed to delete service",variant:"destructive"})}}),X=Fe({mutationFn:async n=>{const{url:t,_cacheKey:$}=n;return(await Ve(`/api/business-services/analyze-webpage?t=${$||Date.now()}`,{method:"POST",body:JSON.stringify({url:t,focusArea:"all"})})).json()},onSuccess:n=>{var t,$,Z,te,F;if(console.log("🔍 [ANALYZER DEBUG] Raw data received:",n),console.log("🔍 [ANALYZER DEBUG] Data type:",typeof n),console.log("🔍 [ANALYZER DEBUG] Data keys:",Object.keys(n)),console.log("🔍 [ANALYZER DEBUG] API Response:",JSON.stringify({success:n.success,hasAnalysis:!!n.analysis,analysisKeys:n.analysis?Object.keys(n.analysis):[],hasServices:!!((t=n.analysis)!=null&&t.services),servicesLength:(Z=($=n.analysis)==null?void 0:$.services)==null?void 0:Z.length,servicesData:(te=n.analysis)==null?void 0:te.services},null,2)),b(n),n.success)if((F=n.analysis)!=null&&F.services&&n.analysis.services.length>0){const ae=c(n);console.log("🔍 [ANALYZER DEBUG] Preview Data:",JSON.stringify({basicInfoKeys:Object.keys(ae.basicInfo),basicInfoValues:Object.values(ae.basicInfo).map(de=>de?"HAS_VALUE":"NULL"),advancedDetailsKeys:Object.keys(ae.advancedDetails),advancedDetailsValues:Object.values(ae.advancedDetails).map(de=>de?"HAS_VALUE":"NULL"),sampleBasicField:ae.basicInfo.name,sampleAdvancedField:ae.advancedDetails.targetAudience},null,2));const Q=Object.values(ae.basicInfo).some(de=>de)||Object.values(ae.advancedDetails).some(de=>de);console.log("🔍 [ANALYZER DEBUG] hasExtractedData:",Q),Q?(R({isOpen:!0,data:ae,analysisResult:n,hasChanges:!1,selectedFieldsCount:0}),r({description:"Website analyzed successfully! Review the extracted data in the preview window.",duration:4e3})):(console.error("🔴 [ANALYZER DEBUG] No extractable data found despite having services!"),r({description:"Website analysis completed, but no service information could be extracted.",variant:"default"}))}else r({description:"Website analysis completed, but no service information was found.",variant:"default"});else r({title:"Analysis Failed",description:"The website analysis did not complete successfully.",variant:"destructive"})},onError:n=>{const t=(n==null?void 0:n.message)||"Failed to analyze website";t.includes("401")||t.includes("Unauthorized")||t.includes("authentication")?r({title:"Session Expired",description:"Your session may have expired. Please refresh the page and try again.",variant:"destructive",duration:7e3}):t.includes("security")?r({title:"Security Restriction",description:"This URL cannot be analyzed for security reasons. Please try a different website.",variant:"destructive",duration:7e3}):t.includes("credits")?r({title:"Insufficient Credits",description:"You don't have enough AI credits to analyze this website. Please upgrade your plan.",variant:"destructive",duration:7e3}):t.includes("timeout")?r({title:"Request Timeout",description:"The website took too long to respond. Please try again with a different URL.",variant:"destructive",duration:7e3}):r({title:"Analysis Failed",description:"Unable to analyze the website. Please check the URL and try again.",variant:"destructive",duration:7e3})}}),ue=n=>{console.log("[HANDLE EDIT] Called with service:",n.id,n.name);const t=n.advancedDetails||{},$=te=>Array.isArray(te)?te.join(`
10`):te||"",Z={name:n.name||"",category:n.category||"",deliveryMethod:n.deliveryMethod||"Standard",basePrice:n.basePrice?Number(n.basePrice):void 0,estimatedDuration:n.estimatedDuration||"",shortDe
10scription:n.shortDescription||"",detailedDescription:t.detailedDescription||"",targetAudience:t.targetAudience||"",deliverables:$(t.deliverables),prerequisites:t.prerequisites||"",pricingNotes:t.pricingNotes||"",processSteps:t.processSteps||"",successMetrics:$(t.successMetrics),competitiveAdvantages:$(t.competitiveAdvantages),keyFeatures:$(t.keyFeatures),keyBenefits:$(t.keyBenefits),uniqueValueProposition:t.uniqueValueProposition||"",painPointsSolved:$(t.painPointsSolved)};console.log("[HANDLE EDIT] Resetting form with values:",Z),x.reset(Z),A(n),p(!0)},xe=n=>{console.log("[SERVICE FORM] handleSubmit called with:",{data:n,editingService:u?{id:u.id,name:u.name}:null,formErrors:x.formState.errors}),u?(console.log("[SERVICE FORM] Calling updateMutation.mutate with id:",u.id),ee.mutate({...n,id:u.id})):(console.log("[SERVICE FORM] Calling createMutation.mutate"),re.mutate(n))},Be=n=>{console.log("[SERVICE FORM] Form validation FAILED:",n);const t=Object.entries(n)[0];if(t){const[$,Z]=t,te=(Z==null?void 0:Z.message)||"Invalid value";r({description:`Please fix: ${$} - ${te}`,variant:"destructive"})}},qe=()=>{x.reset(),H.reset(),p(!1),A(null),K(!1),b(null),N(new Set),R({isOpen:!1,data:null,analysisResult:null,hasChanges:!1,selectedFieldsCount:0})},c=n=>{var Ce,Se,ke,Ae,Pe,Ue,gs,fs,js,vs,ys,bs,Ns,ws,Cs,Ss;const t=(Ce=n.analysis.services)==null?void 0:Ce[0],$=n.analysis.fieldConfidences||{},Z=n.analysis.fieldSources||{},te=n.analysis.fieldQualities||{},F=(E,_,ie)=>{if(_==null||_==="")return;const me=$[E]||.7,Ee=Z[E]||"webpage content",ze=te[E]||(me>=.8?"high":me>=.5?"medium":"low");return{value:_,confidence:me,source:Ee,quality:ze,selected:!1,currentValue:ie}},Q={name:x.getValues("name"),category:x.getValues("category"),deliveryMethod:x.getValues("deliveryMethod"),basePrice:x.getValues("basePrice"),estimatedDuration:x.getValues("estimatedDuration"),shortDescription:x.getValues("shortDescription"),detailedDescription:x.getValues("detailedDescription"),targetAudience:x.getValues("targetAudience"),deliverables:x.getValues("deliverables"),prerequisites:x.getValues("prerequisites"),pricingNotes:x.getValues("pricingNotes"),processSteps:x.getValues("processSteps"),successMetrics:x.getValues("successMetrics"),competitiveAdvantages:x.getValues("competitiveAdvantages"),keyFeatures:x.getValues("keyFeatures"),keyBenefits:x.getValues("keyBenefits"),uniqueValueProposition:x.getValues("uniqueValueProposition"),painPointsSolved:x.getValues("painPointsSolved")};return{basicInfo:{name:F("name",t==null?void 0:t.name,Q.name),category:F("category",t==null?void 0:t.category,Q.category),deliveryMethod:F("deliveryMethod",t==null?void 0:t.deliveryMethod,Q.deliveryMethod),basePrice:F("basePrice",t==null?void 0:t.basePrice,Q.basePrice),estimatedDuration:F("estimatedDuration",t==null?void 0:t.estimatedDuration,Q.estimatedDuration),shortDescription:F("shortDescription",(t==null?void 0:t.shortDescription)||(t==null?void 0:t.description),Q.shortDescription)},advancedDetails:{detailedDescription:F("detailedDescription",((Se=t==null?void 0:t.advancedDetails)==null?void 0:Se.detailedDescription)||(t==null?void 0:t.description),Q.detailedDescription),targetAudience:F("targetAudience",((ke=t==null?void 0:t.advancedDetails)==null?void 0:ke.targetAudience)||((Ae=t==null?void 0:t.advancedDetails)==null?void 0:Ae.targetCustomer),Q.targetAudience),deliverables:F("deliverables",Array.isArray((Pe=t==null?void 0:t.advancedDetails)==null?void 0:Pe.deliverables)?(Ue=t==null?void 0:t.advancedDetails)==null?void 0:Ue.deliverables.join(`
11`):(gs=t==null?void 0:t.advancedDetails)==null?void 0:gs.deliverables,Q.deliverables),prerequisites:F("prerequisites",(fs=t==null?void 0:t.advancedDetails)==null?void 0:fs.prerequisites,Q.prerequisites),pricingNotes:F("pricingNotes",(()=>{var ie,me;const E=(ie=t==null?void 0:t.advancedDetails)==null?void 0:ie.pricing,_=(me=t==null?void 0:t.advancedDetails)==null?void 0:me.pricingNotes;if(_&&typeof _=="string")return _;if(E&&typeof E=="object"){const Ee=[];if(E.model&&Ee.push(`Model: ${E.model}`),E.notes&&Ee.push(E.notes),E.packages&&Array.isArray(E.packages)){const ze=E.packages.map(Ge=>`${Ge.name}: ${Ge.price}${Ge.features?` (${Ge.features.join(", ")})`:""}`).join(`
12`);ze&&Ee.push(ze)}return Ee.join(`
13`)}return E})(),Q.pricingNotes),processSteps:F("processSteps",((js=t==null?void 0:t.advancedDetails)==null?void 0:js.processSteps)||((vs=t==null?void 0:t.advancedDetails)==null?void 0:vs.process),Q.processSteps),successMetrics:F("successMetrics",Array.isArray((ys=t==null?void 0:t.advancedDetails)==null?void 0:ys.successMetrics)?(bs=t==null?void 0:t.advancedDetails)==null?void 0:bs.successMetrics.join(`
14`):(Ns=t==null?void 0:t.advancedDetails)==null?void 0:Ns.successMetrics,Q.successMetrics),competitiveAdvantages:F("competitiveAdvantages",(()=>{var _,ie;const E=(_=t==null?void 0:t.advancedDetails)==null?void 0:_.competitiveAdvantages;return Array.isArray(E)&&E.length>0?E.join(`
15`):typeof E=="string"&&E?E:(ie=t==null?void 0:t.advancedDetails)==null?void 0:ie.expertise})(),Q.competitiveAdvantages),keyFeatures:F("keyFeatures",(()=>{var ie,me;const E=(ie=t==null?void 0:t.advancedDetails)==null?void 0:ie.keyFeatures;if(Array.isArray(E)&&E.length>0)return E.join(`
16`);if(typeof E=="string"&&E)return E;const _=(me=t==null?void 0:t.advancedDetails)==null?void 0:me.tools;if(Array.isArray(_)&&_.length>0)return _.join(`
17`)})(),Q.keyFeatures),keyBenefits:F("keyBenefits",(()=>{var ie,me;const E=(ie=t==null?void 0:t.advancedDetails)==null?void 0:ie.keyBenefits;if(Array.isArray(E)&&E.length>0)return E.join(`
18`);if(typeof E=="string"&&E)return E;const _=(me=t==null?void 0:t.advancedDetails)==null?void 0:me.commonResults;if(Array.isArray(_)&&_.length>0)return _.join(`
19`)})(),Q.keyBenefits),uniqueValueProposition:F("uniqueValueProposition",(()=>{var _,ie;const E=(_=t==null?void 0:t.advancedDetails)==null?void 0:_.uniqueValueProposition;return E&&typeof E=="string"?E:(ie=t==null?void 0:t.advancedDetails)==null?void 0:ie.expertise})(),Q.uniqueValueProposition),painPointsSolved:F("painPointsSolved",Array.isArray((ws=t==null?void 0:t.advancedDetails)==null?void 0:ws.painPointsSolved)?(Cs=t==null?void 0:t.advancedDetails)==null?void 0:Cs.painPointsSolved.join(`
20`):(Ss=t==null?void 0:t.advancedDetails)==null?void 0:Ss.painPointsSolved,Q.painPointsSolved)},marketingScore:t==null?void 0:t.marketingScore,improvementSuggestions:t==null?void 0:t.improvementSuggestions}},S=n=>{const t=new Set,$={shouldValidate:!0,shouldDirty:!0};
20Object.entries(n).forEach(([te,F])=>{if(F!=null&&F!=="")if(te==="description")x.setValue("shortDescription",F,$),t.add("shortDescription");else if(te==="basePrice"){const ae=typeof F=="string"?parseFloat(F.replace(/[$,\s]/g,"")):typeof F=="number"?F:void 0;Number.isFinite(ae)&&ae>=0?(x.setValue("basePrice",ae,$),t.add("basePrice")):x.setValue("basePrice",void 0,$)}else x.setValue(te,F,$),t.add(te)}),N(t);const Z=Object.keys(n).length;r({description:`Successfully applied ${Z} field${Z!==1?"s":""} to your form`,duration:3e3})},D=async()=>{if(!v){r({title:"Authentication required",description:"Please wait for authentication to complete or log in again.",variant:"destructive"});return}if(!C){r({title:"Company required",description:"Please select a company before analyzing a webpage.",variant:"destructive"});return}if(!await H.trigger("url"))return;R({isOpen:!1,data:{basicInfo:{},advancedDetails:{},marketingScore:void 0,improvementSuggestions:void 0},analysisResult:null,hasChanges:!1,selectedFieldsCount:0}),N(new Set),b(null);const t=H.getValues();X.mutate({...t,_cacheKey:Date.now()})},f=(n,t="")=>g.has(n)?`${t} bg-green-50 border-green-200`:t;return i?e.jsx("div",{className:"text-center py-8",children:"Loading services..."}):e.jsxs("div",{className:"space-y-6","data-testid":"business-services-manager",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Business Services"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Define your services with detailed descriptions to improve AI-generated content"})]}),e.jsxs(L,{onClick:()=>p(!0),className:"flex items-center gap-2","data-testid":"button-add-service",children:[e.jsx(As,{className:"w-4 h-4"}),"Add Service"]})]}),P&&e.jsxs(pe,{className:"border-blue-200 bg-blue-50 mb-4",children:[e.jsxs(be,{className:"pb-3",children:[e.jsxs(Re,{className:"text-lg flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-blue-600"}),"Smart Service Analyzer"]}),e.jsx("p",{className:"text-sm text-blue-700",children:"Enter a business website URL to automatically extract service information and fill the form below."})]}),e.jsxs(he,{children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ce,{placeholder:"https://example.com/services",value:H.watch("url"),onChange:n=>{H.setValue("url",n.target.value),H.trigger("url")},className:`pl-10 ${H.formState.errors.url?"border-red-300 focus:border-red-500":""}`,"data-testid":"input-website-url"}),e.jsx(gt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"})]}),H.formState.errors.url&&e.jsx("p",{className:"text-sm text-red-600 mt-1",children:H.formState.errors.url.message})]}),e.jsx(L,{onClick:D,disabled:X.isPending||!H.watch("url")||!!H.formState.errors.url||!v||!C,className:"flex items-center gap-2 min-w-fit","data-testid":"button-analyze-website",children:X.isPending?e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"w-4 h-4 animate-spin"}),"Analyzing..."]}):d?e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"w-4 h-4 animate-spin"}),"Loading..."]}):e.jsxs(e.Fragment,{children:[e.jsx($s,{className:"w-4 h-4"}),"Analyze"]})})]}),w&&e.jsx("div",{className:"mt-4 p-3 bg-white rounded-lg border",children:w.success?e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx(Is,{className:"w-5 h-5 text-green-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-green-800 mb-1",children:"Analysis Completed"}),e.jsxs("p",{className:"text-sm text-green-700 mb-2",children:["Successfully analyzed: ",((O=w.extractedContent)==null?void 0:O.title)||"Website"]}),g.size>0&&e.jsxs("div",{className:"text-xs text-green-600 flex items-center gap-1",children:[e.jsx(ne,{className:"w-3 h-3"}),"Applied ",g.size," field",g.size!==1?"s":""," to form"]})]})]}),((B=w.analysis)==null?void 0:B.services)&&w.analysis.services.length>0&&g.size===0&&e.jsxs(L,{variant:"outline",size:"sm",onClick:()=>{const n=c(w);R({isOpen:!0,data:n,analysisResult:w,hasChanges:!1,selectedFieldsCount:0})},className:"flex items-center gap-2","data-testid":"button-show-
20preview",children:[e.jsx(Ze,{className:"w-4 h-4"}),"Preview Data"]})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ft,{className:"w-5 h-5 text-orange-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-orange-800 mb-1",children:"No Service Information Found"}),e.jsx("p",{className:"text-sm text-orange-700",children:"The website was accessible, but we couldn't extract clear service information. You can fill out the form manually below."})]})]})}),X.isPending&&e.jsx("div",{className:"mt-4 p-3 bg-blue-100 rounded-lg border border-blue-200",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($e,{className:"w-5 h-5 animate-spin text-blue-600"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-blue-800",children:"Analyzing Website..."}),e.jsx("p",{className:"text-sm text-blue-700",children:"This may take a few seconds to extract service information."})]})]})})]})]}),P&&e.jsxs(pe,{className:"border-orange-200 bg-orange-50",children:[e.jsx(be,{children:e.jsx(Re,{className:"text-lg",children:u?"Edit Service":"Add New Service"})}),e.jsx(he,{children:e.jsx(ns,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(xe,Be),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(q,{control:x.control,name:"name",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Service Name *",g.has("name")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(ce,{...n,placeholder:"e.g., Website Design","data-testid":"input-service-name",className:f("name")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"category",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Category",g.has("category")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(Ia,{value:n.value||"",onChange:n.onChange,placeholder:"Select or type category..."})}),e.jsx(Ps,{children:"Choose from suggestions or type your own category"}),e.jsx(Y,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(q,{control:x.control,name:"deliveryMethod",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Delivery Method *",g.has("deliveryMethod")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(Ma,{value:n.value||"",onChange:n.onChange,placeholder:"How is this delivered?"})}),e.jsx(Ps,{children:"Choose from suggestions or type your own delivery method"}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"basePrice",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Base Price ($)",g.has("basePrice")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(ce,{type:"text",placeholder:"$53.59 or 2500",value:n.value||"",onChange:t=>{n.onChange(t.target.value)},onBlur:t=>{const $=t.target.value.replace(/[$,\s]/g,""),Z=parseFloat($);!isNaN(Z)&&Z>0?n.onChange(Z):t.target.value===""&&n.onChange(void 0)},"data-testid":"input-service-price",className:f("basePrice")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"estimatedDuration",render:({field:n})=>e.jsxs(U,{children:[e.jsx(z,{children:"Duration"}),e.jsx(G,{children:e.jsx(ce,{...n,placeholder:"2-3 weeks","data-testid":"input-service-duration"})}),e.jsx(Y,{})]})})]}),e.jsx(q,{control:x.control,name:"shortDescription",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Short Description",g.has("shortDescription")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"Brief overview of what this service includes...",rows:2,"data-testid":"textarea-short-description",className:f("shortDescription")})}),e.jsx(Y,{})]})}),e.jsxs("div",{className:"border-t pt-4 mt-6",children:[e.jsxs("h4",{className:"font-medium text-gray-700 mb-4 flex items-center gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 text-orange-500"}),"Advanced Details (Optional - Improves AI Content)"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(q,{control:x.control,name:"detailedDescription",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Detailed Description",g.has("detailedDescription")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"Comprehensive description of the service, process, and value delivered...",rows:3,"data-testid":"textarea-detailed-description",className:f("detailedDescription")})}),e.jsx(Y,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(q,{control:x.control,name:"targetAudience",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Target Audience",g.has("targetAudience")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"Who is this service ideal for?",rows:2,"data-testid":"textarea-target-audience",className:f("targetAudience")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"deliverables",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Deliverables",g.has("deliverables")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"What exactly does the client receive?",rows:2,"data-testid":"textarea-deliverables",className:f("deliverables")})}),e.jsx(Y,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(q,{control:x.control,name:"prerequisites",render:({field:n})=>e.jsxs(U,{children:[e.jsx(z,{children:"Prerequisites"}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"What does the client need to provide or have ready?",rows:2,"data-testid":"textarea-prerequisites"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"competitiveAdvantages",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Competitive Advantages",g.has("competitiveAdvantages")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"What makes your service unique or better?",rows:2,"data-testid":"textarea-competitive-advantages",className:f("competitiveAdvantages")})}),e.jsx(Y,{})]})})]}),e.jsxs("div",{className:"mt-6 pt-6 border-t",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-1",children:"Marketing Intelligence"}),e.jsxs("p",{className:"text-sm text-gray-600",children:[e.jsx("strong",{children:"Features"}),' are what your service includes (the "what").',e.jsx("strong",{children:" Benefits"}),' are the customer outcomes (the "why it matters").']})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(q,{control:x.control,name:"keyFeatures",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Key Features",g.has("keyFeatures")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"What's included: tools, deliverables, capabilities (e.g., '5 blog posts per month', 'SEO keyword research')",rows:3,"data-testid":"textarea-key-features",className:f("keyFeatures")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"keyBenefits",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Key Benefits",g.has("keyBenefits")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"Customer outcomes and value (e.g., 'Increase traffic 40%', 'Save 10 hours/week', 'Look professional')",rows:3,"data-testid":"textarea-key-benefits",className:f("keyBenefits")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"uniqueValueProposition",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Unique Value Proposition",g.has("uniqueValueProposition")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"The single most compelling reason to choose this service (e.g., 'Only AI tool built for local businesses')",rows:2,"data-testid":"textarea-unique-value-proposition",className:f("uniqueValueProposition")})}),e.jsx(Y,{})]})}),e.jsx(q,{control:x.control,name:"painPointsSolved",render:({field:n})=>e.jsxs(U,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:["Pain Points Solved",g.has("painPointsSolved")&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full",children:[e.jsx(ne,{className:"w-3 h-3"}),"Auto-filled"]})]}),e.jsx(G,{children:e.jsx(oe,{...n,placeholder:"Problems this solves (e.g., 'Stop wasting time', 'No more expensive agencies', 'Eliminate guesswork')",rows:2,"data-testid":"textarea-pain-points-solved",className:f("painPointsSolved")})}),e.jsx(Y,{})]})})]})]})]})]}),g.size>0&&e.jsxs(Bs,{className:"bg-green-50 border-green-200",children:[e.jsx(Is,{className:"h-4 w-4 text-green-600"}),e.jsx(jt,{className:"text-green-800",children:"Smart Analysis Applied"}),e.jsxs(qs,{className:"text-green-700",children:[g.size," field",g.size!==1?"s":""," automatically filled from website analysis. Review and modify as needed before saving."]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(L,{type:"submit",disabled:re.isPending||ee.isPending,"data-testid":"button-save-service",className:"flex items-center gap-2",children:re.isPending||ee.isPending?e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"w-4 h-4 animate-spin"}),u?"Updating...":"Adding..."]}):e.jsx(e.Fragment,{children:u?"Update Service":"Add Service"})}),e.jsx(L,{type:"button",variant:"outline",onClick:qe,"data-testid":"button-cancel-service",children:"Cancel"}),g.size>0&&e.jsxs(L,{type:"button",variant:"ghost",onClick:()=>{g.forEach(n=>
20{n==="basePrice"?x.setValue("basePrice",void 0,{shouldValidate:!1,shouldDirty:!0}):x.setValue(n,"",{shouldValidate:!1,shouldDirty:!0})}),N(new Set),r({description:"Auto-filled data cleared"})},className:"text-red-600 hover:text-red-700","data-testid":"button-clear-autofill",children:[e.jsx(Ts,{className:"w-4 h-4 mr-2"}),"Clear Auto-Fill"]})]})]})})})]}),e.jsx("div",{className:"space-y-4",children:h.length===0?e.jsx(pe,{className:"border-dashed border-2 border-gray-200",children:e.jsxs(he,{className:"text-center py-8",children:[e.jsx(_e,{className:"w-12 h-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No services yet"}),e.jsx("p",{className:"text-gray-500 mb-4",children:"Add your first service to get started with detailed AI-powered content generation"}),e.jsxs(L,{onClick:()=>p(!0),className:"flex items-center gap-2",children:[e.jsx(As,{className:"w-4 h-4"}),"Add Your First Service"]})]})}):h.map(n=>e.jsx(La,{service:n,onEdit:ue,onDelete:t=>se.mutate(t),shouldCollapse:y===n.id},n.id))}),M.data&&M.analysisResult&&e.jsx(Va,{isOpen:M.isOpen,onClose:()=>R(n=>({...n,isOpen:!1})),previewData:M.data,analysisResult:M.analysisResult,onApplySelected:S})]})}const Rs={facebook:{name:"Facebook",icon:"📘",color:"bg-blue-600",description:"Connect your Facebook business page",authType:"oauth",features:{reviews:"Import customer reviews and ratings",posting:"Schedule posts and manage content",analytics:"Track engagement and performance"}},instagram:{name:"Instagram",icon:"📷",color:"bg-pink-500",description:"Connect your Instagram business account",authType:"oauth",features:{reviews:"Monitor mentions and comments",posting:"Share photos, videos, and stories",analytics:"View reach and engagement metrics"}},linkedin:{name:"LinkedIn",icon:"💼",color:"bg-blue-700",description:"Connect your LinkedIn company page",authType:"oauth",features:{reviews:"Collect professional recommendations",posting:"Share professional content and updates",analytics:"Track follower growth and engagement"}},google_my_business:{name:"Google My Business",icon:"🔍",color:"bg-red-500",description:"Connect your Google Business Profile",authType:"oauth",features:{reviews:"Import Google reviews and respond",posting:"Create local posts and offers",analytics:"View search performance and customer actions"}},yelp:{name:"Yelp",icon:"⭐",color:"bg-red-600",description:"Connect your Yelp business account",authType:"oauth",features:{reviews:"Import Yelp reviews and ratings",posting:"Update business information",analytics:"Monitor review trends"}},twitter:{name:"Twitter/X",icon:"🐦",color:"bg-blue-400",description:"Connect your Twitter account",authType:"oauth",features:{reviews:"Monitor mentions and replies",posting:"Share updates and engage with customers",analytics:"Track tweet performance and followers"}},youtube:{name:"YouTube",icon:"📺",color:"bg-red-500",description:"Connect your YouTube channel",authType:"oauth",features:{reviews:"Monitor comments and engagement",posting:"Schedule video uploads and premieres",analytics:"Track views, subscribers, and engagement"}},wordpress:{name:"WordPress",icon:"📝",color:"bg-blue-800",description:"Connect your WordPress site",authType:"oauth",features:{reviews:"Display customer testimonials",posting:"Publish blog posts automatically",analytics:"Monitor website traffic"}}};function Ba({className:s}){l.useState(""),l.useState(!1);const[r,a]=l.useState(""),[j,m]=l.useState(!1),{toast:d}=He();os();const{data:o,isLoading:v}=Jt(),{invalidateConnections:P}=Xt(),p=(o==null?void 0:o.platforms)||[],u=g=>{a(g),m(!0)},A=(g,N)=>{P(),d({title:"Platform Connected",description:`Successfully connected your ${g} account. You can now use it for reviews and auto-posting.`}),m(!1),a("")},y=(g,N)=>{d({title:"Connection Failed",description:`Failed to connect ${g}: ${N}`,variant:"destructive"}),m(!1),a("")},k=()=>{m(!1),a("")},J=g=>p.find(N=>N.platform===g),K=(g,N)=>{const M=J(g),R=(M==null?void 0:M.isConnected)||!1,C=M==null?void 0:M.accountInfo,V=M==null?void 0:M.capabilities;return e.jsxs(pe,{className:"relative overflow-hidden",children:[e.jsx(be,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:ge("w-12 h-12 rounded-full flex items-center justify-center text-white text-xl",N.color),children:N.icon}),e.jsxs("div",{children:[e.jsx(Re,{className:"text-lg",children:N.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:N.description})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:R?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"w-5 h-5 text-green-600"}),e.jsx(ye,{variant:"secondary",className:"text-green-700 bg-green-100 dark:bg-green-900/20",children:"Connected"})]}):e.jsxs(L,{onClick:()=>u(g),className:"flex items-center gap-2",size:"sm","data-testid":`button-connect-${g}`,children:[e.jsx(Ks,{className:"w-4 h-4"}),"Connect"]})})]})}),e.jsxs(he,{className:"space-y-4",children:[R&&C&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 p-3 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx($t,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"text-sm font-medium text-green-800 dark:text-green-200",children:C.accountName})]}),C.businessId&&e.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300",children:["Business ID: ",C.businessId]}),C.lastSynced&&e.jsxs("p",{className:"text-xs text-green-700 dark:text-green-300",children:["Last synced: ",new Date(C.lastSynced).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Available Features:"}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:Object.entries(N.features).map(([i,T])=>{const h={reviews:e.jsx(Lt,{className:"w-4 h-4"}),posting:e.jsx(sa,{className:"w-4 h-4"}),analytics:e.jsx(Ot,{className:"w-4 h-4"})};return e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[e.jsx("div",{className:ge("w-6 h-6 rounded-full flex items-center justify-center text-xs",R?"bg-green-100 text-green-600 dark:bg-green-900/30":"bg-gray-200 text-gray-500"),children:h[i]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium capitalize text-gray-900 dark:text-gray-100",children:i}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:T})]}),R&&e.jsx(fe,{className:"w-4 h-4 text-green-500 flex-shrink-0"})]},i)})})]}),R&&V&&e.jsxs("div",{className:"pt-3 border-t",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Platform Capabilities:"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[V.supportsTextPosts&&e.jsxs("div",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[e.jsx(fe,{className:"w-3 h-3"}),"Text posts"]}),V.supportsImagePosts&&e.jsxs("div",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[e.jsx(fe,{className:"w-3 h-3"}),"Image posts"]}),V.supportsVideoPosts&&e.jsxs("div",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[e.jsx(fe,{className:"w-3 h-3"}),"Video posts"]}),V.supportsScheduledPosts&&e.jsxs("div",{className:"flex items-center gap-1 text-green-700 dark:text-green-300",children:[e.jsx(fe,{className:"w-3 h-3"}),"Scheduled posts"]})]}),V.maxTextLength&&e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:["Max text: ",V.maxTextLength," characters"]})]})]})]},g)},w=p.filter(g=>g.isConnected).length,b=Object.keys(Rs).length;return e.jsxs("div",{className:ge("space-y-6",s),children:[e.jsxs("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-gray-100",children:"Platform Connections"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Connect your business accounts to enable reviews import and auto-posting"})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-lg font-semibold text-orange-500",children:[w," / ",b]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Platforms Connected"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 p-4 rounded-lg border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Setup Progress"}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[Math.round(w/b*100),"%"]})]}),e.jsx(_t,{value:w/b*100,className:"h-2"}),e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 mt-1",children:"Connect more platforms to unlock additional marketing features"})]}),w>0&&e.jsxs(Bs,{children:[e.jsx(fe,{className:"h-4 w-4"}),e.jsxs(qs,{children:["Great! You have ",w," platform",w>1?"s":""," connected. You can now schedule content and import reviews from the"," ",e.jsx("a",{href:"/marketing-calendar",className:"font-medium text-orange-500 hover:underline",children:"marketing calendar"})," ","and"," ",e.jsx("a",{href:"/platform-integration",className:"font-medium text-orange-500 hover:underline",children:"reviews section"}),"."]})]}),v?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx($e,{className:"w-6 h-6 animate-spin text-orange-500"}),e.jsx("span",{className:"ml-2 text-gray-600 dark:text-gray-400",children:"Loading platforms..."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Object.entries(Rs).map(([g,N])=>K(g,N))}),e.jsx(ea,{isOpen:j,onClose:k,onSuccess:A,onError:y,platform:r,"data-testid":"oauth-popup-handler"})]})}const qa=I.object({companyName:I.string().min(1,"Company name is required"),email:I.string().optional(),phone:I.string().optional(),address:I.string().optional(),websiteUrl:I.str
20ing().optional(),industry:I.string().optional(),description:I.string().optional(),targetMarket:I.array(I.string()).default([]),services:I.array(I.string()).default([]),tagline:I.string().optional(),motto:I.string().optional(),vision:I.string().optional(),beliefs:I.string().optional()});function rn(){var V;const{toast:s}=He(),r=os(),{activeCompanyId:a}=Ls();l.useState("");const[j,m]=l.useState(""),[d,o]=l.useState(""),[v,P]=l.useState(!1),[p,u]=l.useState("tagline"),A=i=>{u(i),setTimeout(()=>{const T=document.querySelector('[data-testid="brand-voice-assistant"]');T&&T.scrollIntoView({behavior:"smooth",block:"start"})},100)},y=as({resolver:rs(qa),defaultValues:{companyName:"",email:"",phone:"",address:"",websiteUrl:"",industry:"",description:"",targetMarket:[],services:[],tagline:"",motto:"",vision:"",beliefs:""}}),{data:k}=ts({queryKey:[`/api/business-profile/${a}`],enabled:!!a}),{data:J=[]}=ts({queryKey:["/api/companies"],enabled:!!a}),K=(V=J.find)==null?void 0:V.call(J,i=>i.id===a),w=K&&!K.isAgencyOwn;l.useEffect(()=>{if(k){const i=k.contactInfo||{},T=k.contentLibrary||{};y.reset({companyName:k.companyName||"",email:i.email||"",phone:i.phone||"",address:i.address||"",websiteUrl:k.websiteUrl||"",industry:k.industry||"",description:k.description||"",targetMarket:Array.isArray(k.targetMarket)?k.targetMarket:[],services:k.services||[],tagline:T.tagline||"",motto:T.motto||"",vision:T.vision||"",beliefs:T.beliefs||""}),o(k.logoUrl||"")}},[k,y]);const b=Fe({mutationFn:async i=>Ve("/api/business-profile",{method:"PATCH",body:JSON.stringify({...i,companyId:a,websiteUrl:i.websiteUrl||"",targetMarket:Array.isArray(i.targetMarket)?i.targetMarket:[],contactInfo:{email:i.email||"",phone:i.phone||"",address:i.address||""},contentLibrary:{tagline:i.tagline||"",motto:i.motto||"",vision:i.vision||"",beliefs:i.beliefs||""}})}),onSuccess:()=>{s({title:"Success",description:"Business profile saved successfully"}),r.invalidateQueries({queryKey:[`/api/business-profile/${a}`]})},onError:i=>{s({title:"Save failed",description:"Changes couldn't be saved. Please try again.",variant:"destructive"})}}),g=(i,T,h,x)=>new Promise(H=>{const W=document.createElement("canvas"),re=W.getContext("2d"),ee=new Image;ee.onload=()=>{let{width:se,height:X}=ee;se>X?se>T&&(X=X*T/se,se=T):X>h&&(se=se*h/X,X=h),W.width=se,W.height=X,re.drawImage(ee,0,0,se,X),W.toBlob(ue=>{const xe=new File([ue],i.name,{type:"image/jpeg",lastModified:Date.now()});H(xe)},"image/jpeg",x)},ee.src=URL.createObjectURL(i)}),N=async i=>{if(i){P(!0);try{if(!i.type.startsWith("image/")){s({title:"Invalid file",description:"Please select an image file",variant:"destructive"});return}if(i.size>5*1024*1024){s({title:"File too large",description:"Please select an image under 5MB",variant:"destructive"});return}const T=await g(i,400,400,.8),h=new FileReader,H={fileData:await new Promise((ee,se)=>{h.onload=()=>{const ue=h.result.split(",")[1];ee(ue)},h.onerror=se,h.readAsDataURL(T)}),fileName:i.name,companyId:a},W=await fetch("/api/logo/upload-direct",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)});if(!W.ok)throw new Error(`Upload failed: ${W.status}`);const re=await W.json();if(re.success)o(re.logoUrl),s({title:"Logo uploaded successfully!",description:"Your company logo has been saved."}),r.invalidateQueries({queryKey:[`/api/business-profile/${a}`]});else throw new Error("Upload failed")}catch{s({title:"Upload failed",description:"Could not upload your logo. Please try again.",variant:"destructive"})}finally{P(!1)}}},M=()=>{if(j.trim()&&!y.getValues("targetMarket").includes(j.trim())){const i=[...y.getValues("targetMarket"),j.trim()];y.setValue("targetMarket",i),m("")}},R=i=>{const T=y.getValues("targetMarket").filter(h=>h!==i);y.setValue("targetMarket",T)},C=i=>{b.mutate(i)};return e.jsxs("div",{className:"container mx-auto py-4 sm:py-8 px-4 max-w-4xl",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between mb-6 sm:mb-8 gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl sm:text-2xl md:text-3xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(Ye,{className:"h-6 w-6 sm:h-8 sm:w-8"}),"Business Profile"]}),e.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 mt-2",children:"Set up your business information with AI-powered assistance"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[w&&e.jsx(Es,{href:"/client-management",children:e.jsxs(L,{variant:"outline",className:"border-orange-200 text-orange-700 hover:bg-orange-50 w-full sm:w-auto","data-testid":"button-manage-client",size:"sm",children:[e.jsx(Bt,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Manage Client"}),e.jsx("span",{className:"sm:hidden",children:"Client"})]})}),e.jsx(Es,{href:"/business-profile-guide",children:e.jsxs(L,{variant:"outline",className:"border-blue-200 text-blue-700 hover:bg-blue-50 w-full sm:w-auto","data-testid":"button-business-profile-guide",size:"sm",children:[e.jsx(qt,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Profile Guide"}),e.jsx("span",{className:"sm:hidden",children:"Guide"})]})})]})]}
20),e.jsxs("div",{className:"space-y-4 sm:space-y-6",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(L,{onClick:()=>C(y.getValues()),disabled:b.isPending,className:"w-full sm:w-auto","data-testid":"button-save-profile",children:[e.jsx(Ms,{className:"w-4 h-4 mr-2"}),b.isPending?"Saving...":"Save Profile"]})}),e.jsxs(Ut,{defaultValue:"company",className:"w-full",children:[e.jsxs(zt,{className:"grid w-full grid-cols-4",children:[e.jsxs(Ke,{value:"company",className:"flex items-center gap-1 sm:gap-2 px-2 sm:px-4",children:[e.jsx(Ye,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Company Info"}),e.jsx("span",{className:"sm:hidden text-xs",children:"Info"})]}),e.jsxs(Ke,{value:"services",className:"flex items-center gap-1 sm:gap-2 px-2 sm:px-4",children:[e.jsx(_e,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Services"}),e.jsx("span",{className:"sm:hidden text-xs",children:"Services"})]}),e.jsxs(Ke,{value:"brand",className:"flex items-center gap-1 sm:gap-2 px-2 sm:px-4",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Brand Voice"}),e.jsx("span",{className:"sm:hidden text-xs",children:"Brand"})]}),e.jsxs(Ke,{value:"platforms",className:"flex items-center gap-1 sm:gap-2 px-2 sm:px-4",children:[e.jsx(Ks,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Platform Connections"}),e.jsx("span",{className:"sm:hidden text-xs",children:"Platforms"})]})]}),e.jsx(We,{value:"company",children:e.jsxs(pe,{children:[e.jsx(be,{children:e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(Ye,{className:"h-5 w-5"}),"Company Information"]})}),e.jsxs(he,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-3",children:"Company Logo"}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("div",{className:"w-24 h-24 border-2 border-dashed border-gray-300 rounded-xl flex items-center justify-center bg-gray-50",children:d?e.jsx("img",{src:d,alt:"Company Logo",className:"w-full h-full object-cover rounded-xl"}):e.jsxs("div",{className:"text-center p-2",children:[e.jsx(Ye,{className:"h-8 w-8 mx-auto text-gray-400 mb-1"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Logo"})]})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:i=>{var h;const T=(h=i.target.files)==null?void 0:h[0];T&&N(T)},style:{display:"none"},id:"new-logo-upload","data-testid":"input-logo-upload"}),e.jsxs(L,{type:"button",onClick:()=>{var i;return(i=document.getElementById("new-logo-upload"))==null?void 0:i.click()},disabled:v,className:"flex items-center gap-2",variant:"outline",children:[e.jsx(ta,{className:"w-4 h-4"}),v?"Uploading...":"Upload Logo"]}),e.jsx("p",{className:"text-xs text-gray-500",children:"PNG, JPG or SVG, max 5MB"})]})]})]}),e.jsx(ns,{...y,children:e.jsxs("form",{onSubmit:y.handleSubmit(C),className:"space-y-4",children:[e.jsx(q,{control:y.control,name:"companyName",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Company Name *"}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"e.g., Authenticity Media","data-testid":"input-company-name"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:y.control,name:"industry",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Industry"}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"e.g., Marketing Technology","data-testid":"input-industry"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:y.control,name:"description",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Business Description"}),e.jsx(G,{children:e.jsx(oe,{...i,placeholder:"Describe what your business does, your unique value proposition, and what makes you different from competitors...",rows:4,"data-testid":"textarea-description"})}),e.jsx(Y,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Target Market"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ce,{value:j,onChange:i=>m(i.target.value),placeholder:"Add a target market (e.g., Small Business Owners)",onKeyPress:i=>i.key==="Enter"&&(i.preventDefault(),M()),"data-testid":"input-new-target-market"}),e.jsx(L,{type:"button",onClick:M,variant:"outline",children:"Add"})]}),y.watch("targetMarket").length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:y.watch("targetMarket").map((i,T)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1 bg-green-100 text-green-800 rounded-full text-sm",children:[i,e.jsx("button",{type:"button",onClick:()=>R(i),className:"ml-1 text-green-600 hover:text-green-800",children:"×"})]},T))})]}),e.jsx(q,{control:y.control,name:"websiteUrl",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Website URL"}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"https://yourwebsite.com","data-testid":"input-website-url"})}),e.jsx(Y,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Contact Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(q,{control:y.control,name:"email",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Email"}),e.jsx(G,{children:e.jsx(ce,{...i,type:"email",placeholder:"business@c
20ompany.com","data-testid":"input-email"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:y.control,name:"phone",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Phone"}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"(555) 123-4567","data-testid":"input-phone"})}),e.jsx(Y,{})]})})]}),e.jsx(q,{control:y.control,name:"address",render:({field:i})=>e.jsxs(U,{children:[e.jsx(z,{children:"Address"}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"123 Business St, City, State 12345","data-testid":"input-address"})}),e.jsx(Y,{})]})})]})]})})]})]})}),e.jsx(We,{value:"services",children:e.jsx(Oa,{companyId:a})}),e.jsx(We,{value:"brand",children:e.jsxs(pe,{children:[e.jsx(be,{children:e.jsxs(Re,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5"}),"Brand Foundation"]})}),e.jsxs(he,{className:"space-y-6",children:[e.jsx("div",{"data-testid":"brand-voice-assistant",children:e.jsx(aa,{businessProfile:{companyName:y.watch("companyName"),industry:y.watch("industry"),description:y.watch("description"),targetMarket:y.watch("targetMarket"),services:y.watch("services")},selectedField:p,onFieldChange:u,onContentGenerated:(i,T)=>{y.setValue(i,T),s({title:"Content Applied",description:`Your ${i} has been updated with AI-generated content.`})}})}),e.jsx(ns,{...y,children:e.jsxs("form",{onSubmit:y.handleSubmit(C),className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(q,{control:y.control,name:"tagline",render:({field:i})=>e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{children:"Tagline"}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-orange-600 hover:text-orange-700 hover:bg-orange-50",onClick:()=>A("tagline"),title:"Generate with AI",children:e.jsx(ne,{className:"h-4 w-4"})})]}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"Your memorable tagline","data-testid":"input-tagline"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:y.control,name:"motto",render:({field:i})=>e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{children:"Motto"}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-orange-600 hover:text-orange-700 hover:bg-orange-50",onClick:()=>A("motto"),title:"Generate with AI",children:e.jsx(ne,{className:"h-4 w-4"})})]}),e.jsx(G,{children:e.jsx(ce,{...i,placeholder:"Your guiding motto","data-testid":"input-motto"})}),e.jsx(Y,{})]})})]}),e.jsx(q,{control:y.control,name:"vision",render:({field:i})=>e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{children:"Vision"}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-orange-600 hover:text-orange-700 hover:bg-orange-50",onClick:()=>A("vision"),title:"Generate with AI",children:e.jsx(ne,{className:"h-4 w-4"})})]}),e.jsx(G,{children:e.jsx(oe,{...i,placeholder:"Your company's vision for the future",rows:2,"data-testid":"textarea-vision"})}),e.jsx(Y,{})]})}),e.jsx(q,{control:y.control,name:"beliefs",render:({field:i})=>e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(z,{children:"Core Beliefs"}),e.jsx(L,{type:"button",variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-orange-600 hover:text-orange-700 hover:bg-orange-50",onClick:()=>A("beliefs"),title:"Generate with AI",children:e.jsx(ne,{className:"h-4 w-4"})})]}),e.jsx(G,{children:e.jsx(oe,{...i,placeholder:"What your company believes in and stands for",rows:2,"data-testid":"textarea-beliefs"})}),e.jsx(Y,{})]})})]})})]})]})}),e.jsx(We,{value:"platforms",children:e.jsx(pe,{children:e.jsx(he,{className:"p-6",children:e.jsx(Ba,{})})})})]}),e.jsx("div",{className:"flex justify-center sm:justify-end px-4 sm:px-0",children:e.jsxs(L,{onClick:()=>C(y.getValues()),disabled:b.isPending,className:"w-full sm:w-auto py-3 sm:py-2 text-sm sm:text-base","data-testid":"button-save-profile-bottom",children:[e.jsx(Ms,{className:"w-4 h-4 mr-2"}),b.isPending?"Saving...":"Save Profile"]})})]})]})}export{rn 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.