PageSourceSearch

https://boombam.app/assets/avatar-worksheet-RO4KhsSe.js

js boombam.app collected 2026-10-04 13:33:11 UTC 50,306 bytes, 13 lines download raw bytes

1import{r as $,u as Sa,N as Aa,bo as Ca,a5 as ka,cp as Pa,a as ta,j as e,a4 as j,L as Ta,B as y,bk as Ia,aN as La,au as $a,C as O,e as U,T as ra,b as W,d as q,ab as A,aF as le,$ as Z,a0 as Y,a1 as _,a2 as J,a3 as F,cq as Da,S as P,U as Fa,n as Ea,ap as X,R as Ma,Q as Ra,E as Ba,ak as za,al as Oa,am as Ua,an as Ga,a7 as re,c2 as f}from"./index-CuSEeJFb.js";import{W as Wa}from"./wand-sparkles-Cnc6tXs_.js";import{C as qa}from"./circle-user-Bw7gCNQp.js";import{U as Va}from"./upload-rep3KVPL.js";import{S as Ha}from"./save-DMqvNvzo.js";const T={name:"",targetService:"",targetMarket:"",avatarType:"",gender:"",maritalStatus:"",childrenAgeNumber:"",annualIncome:"",educationLevel:"",ethnicity:"",occupation:"",roleAtCompany:"",jobTitle:"",demographics:{age:"",gender:"",maritalStatus:"",hasChildren:"",income:"",education:"",location:"",ethnicity:""},professional:{industry:"",roleAtCompany:"",jobTitle:"",companySize:"",businessType:"",decisionMakingAuthority:"",shoppingPreference:"",purchaseDriver:"",customerLifecycleStage:"",spendingPattern:"",decisionMakingStyle:"",consumerCategory:""},psychographics:{lifestyle:"",values:[],interests:[],communicationStyle:""},painPoints:[],painPointsData:{primary:"",secondary:"",all:[]},goals:[],goalsList:[],behavior:{shoppingBehavior:"",decisionMaking:"",preferredChannels:[],budgetConsciousness:"",buyingTriggers:"",objections:""},serviceContext:{experience:"",urgency:""},beforeState:{haveSituation:"",feelEmotions:"",avgDayLooks:"",statusCurrent:"",goodEvil:""},afterState:{haveDesired:"",feelDesired:"",avgDayDesired:"",statusDesired:"",goodEvilDesired:""},books:"",magazines:"",blogsWebsites:"",conferences:"",gurus:"",otherSources:"",informationSources:{books:"",magazines:"",websites:"",conferences:"",gurus:"",otherSources:""},infoSources:{whereDoTheyGo:"",whoDoTheyTrust:"",researchProcess:""},salesProcess:{howDoTheyBuy:"",buyingCriteria:"",decisionProcess:""},quote:"",objections:"",values:"",challenges:"",serviceToPromote:"",purchaseRole:"",imageUrl:"",imageDescription:"",avatarImage:"",channels:[],tags:[],systemStatus:"active",deploymentStatus:"draft",sharingState:"private"},Qa={age:["18-24","25-34","35-44","45-54","55-64","65+"],gender:["Male","Female","Non-binary","Prefer not to say"],maritalStatus:["Single","Married","Divorced","Widowed","Partnered"],hasChildren:["0 children","Young children (0-5)","School age (6-12)","Teenagers (13-17)","Adult children"],education:["High school","Some college","Bachelor's degree","Master's degree","Doctorate","Trade certification"],income:["Under $25k","$25k-$50k","$50k-$75k","$75k-$100k","$100k-$150k","$150k-$250k","$250k+"],ethnicity:["White/Caucasian","Black/African American","Hispanic/Latino","Asian/Pacific Islander","Native American","Middle Eastern","Mixed/Other"],location:["Urban","Suburban","Rural","Small town"]},Za={companySize:["1-10 employees","11-50 employees","50-200 employees","200-1000 employees","1000-5000 employees","5000+ employees"],businessType:["b2b","b2c","b2b2c"],decisionMakingAuthority:["Final decision maker","Influences budget decisions","Recommends solutions","Researches options","End user only"]},Ya={shoppingPreference:["Online primarily","In-store primarily","Mix of both","Mobile/app preferred","Research online, buy offline"],purchaseDriver:["Best price/value","Premium quality","Convenience/speed","Brand loyalty","Social proof/reviews","Sustainability/ethics"],customerLifecycleStage:["New to category","Exploring options","Regular customer","Loyal advocate","Lapsed/win-back"],spendingPattern:["Budget conscious","Value seeker","Mid-range spender","Premium buyer","Luxury focused"],decisionMakingStyle:["Quick/impulsive","Research intensive","Socially influenced","Expert/review driven","Brand loyal"]};function ns(){var je,be;const[a,V]=$.useState(T),[ia,ce]=$.useState(!1),[de,ie]=$.useState(!1),[na,pe]=$.useState(!1),[d,H]=$.useState({}),[oa,ue]=$.useState(!1),[Q,M]=$.useState({isActive:!1,currentField:"",currentFieldLabel:"",completed:0,total:0,percentage:0}),{subscriptionInfo:_a,aiPowerLevel:ge,setAiPowerLevel:Ja}=Sa(),{activeCompanyId:R,isHydrated:me}=Aa(),[Xa,he]=Ca(),B=ka(),ne=Pa(),D=$.useMemo(()=>{const n=new URLSearchParams(ne).get("edit");return n?parseInt(n,10):null},[ne]),xe=$.useMemo(()=>{const n=new URLSearchParams(ne).get("folderId");return n?parseInt(n,10):null},[ne]),g=D!==null,{data:G,isLoading:Ka}=ta({queryKey:["/api/business-profile",R],enabled:me&&!!R,retry:!1}),{data:E,isLoading:ve}=ta({queryKey:[`/api/business-services?companyId=${R}`],enabled:me&&!!R,retry:!1}),fe=$.useCallback(async s=>{ce(!0);try{localStorage.setItem("avatar-worksheet-draft",JSON.stringify(s)),await new Promise(n=>setTimeout(n,500)),ce(!1)}catch(n){console.error("Auto-save failed:",n),ce(!1)}},[]),u=$.useCallback(s=>{V(n=>{const l={...n,...s};return fe(l),l})},[fe]);$.useEffect(()=>{(async()=>{var n,l,C,h,w,m,b,N,x,c,p,S,v,L,K,ee,ae,se;if(g&&D&&R){ue(!0);try{const o=await(await re(`/api/client-avatars/${D}?companyId=${R}`)).json();if(o.error)throw new Error(o.error);if(o){localStorage.removeItem("avatar-worksheet-draft");const k={...T,name:o.name||"",targetService:o.targetService||"",targetMarket:o.targetMarket||"",avatarType:o.avatarType||"",gender:o.gender||((n=o.demographics)==null?void 0:n.gender)||"",maritalStatus:o.maritalStatus||((l=o.demographics)==null?void 0:l.maritalStatus)||"",childrenAgeNumber:o.childrenAgeNumber||((C=o.demographics)==null?void 0:C.hasChildren)||"",annualIncome:o.annualIncome||((h=o.demographics)==null?void 0:h.income)||"",educationLevel:o.educationLevel||((w=o.demographics)==null?void 0:w.education)||"",ethnicity:o.ethnicity||((m=o.demographics)==null?void 0:m.ethnicity)||"",occupation:o.occupation||"",roleAtCompany:o.roleAtCompany||((b=o.professional)==null?void 0:b.roleAtCompany)||((N=o.professional)==null?void 0:N.jobTitle)||"",jobTitle:o.jobTitle||((x=o.professional)==null?void 0:x.jobTitle)||"",demographics:{...T.demographics,...o.demographics||{},age:((c=o.demographics)==null?void 0:c.age)||o.age||"",gender:((p=o.demographics)==null?void 0:p.gender)||o.gender||"",ethnicity:((S=o.demographics)==null?void 0:S.ethnicity)||o.ethnicity||"",maritalStatus:((v=o.demographics)==null?void 0:v.maritalStatus)||o.maritalStatus||""},professional:o.professional||T.professional,psychographics:o.psychographics||T.psychographics,painPoints:o.painPoints||[],painPointsData:o.painPointsData||T.painPointsData,goals:o.goals||[],goalsList:o.goalsList||o.goals||[],behavior:o.behavior||T.behavior,serviceContext:o.serviceContext||T.serviceContext,beforeState:o.beforeState||T.beforeState,afterState:o.afterState||T.afterState,transformation:o.transformation||T.transformation,messagingAngle:o.messagingAngle||"",persona:o.persona||"",avatarImage:o.avatarImage||"",imageDescription:o.imageDescription||""};
1console.log("🔍 [AVATAR DEBUG] Loading avatar from API:",{id:D,name:k.name,"=== WORK CONTEXT ===":"---",occupation:k.occupation,roleAtCompany:k.roleAtCompany,jobTitle:k.jobTitle,"professional.industry":(L=k.professional)==null?void 0:L.industry,"professional.roleAtCompany":(K=k.professional)==null?void 0:K.roleAtCompany,"professional.jobTitle":(ee=k.professional)==null?void 0:ee.jobTitle,"professional.companySize":(ae=k.professional)==null?void 0:ae.companySize,"professional.businessType":(se=k.professional)==null?void 0:se.businessType,"=== RAW API RESPONSE ===":"---",rawOccupation:o.occupation,rawRoleAtCompany:o.roleAtCompany,rawJobTitle:o.jobTitle,rawProfessional:o.professional,"=== DEMOGRAPHICS ===":"---",demographics:k.demographics,"=== FULL WORKSHEET ===":k}),V(k),f({title:"Avatar Loaded",description:`Editing "${o.name}" - all fields populated from existing data.`})}}catch(te){console.error("Failed to load avatar for editing:",te),f({title:"Failed to Load Avatar",description:"Could not load the avatar data. Starting with empty form.",variant:"destructive"}),V(T)}finally{ue(!1)}}else g||(localStorage.removeItem("avatar-worksheet-draft"),V(T))})()},[g,D,R]);const I=async(s,n)=>{if(!a.targetService){f({title:"Service Required",description:"Please select a target service first to get AI suggestions.",variant:"destructive"});return}H(l=>({...l,[s]:!0}));try{const l={service:a.targetService,demographics:a.demographics,professional:a.professional,avatarType:a.avatarType,existingV
1alues:Object.fromEntries(Object.entries(a).filter(([w,m])=>m&&typeof m=="string"&&m.trim()!==""))},h=await(await re("/api/avatars/ai-suggest",{method:"POST",body:JSON.stringify({fieldKey:s,fieldLabel:n,context:l,aiPowerLevel:ge})})).json();if(h.suggestion){const m=((c,p)=>{const S=p.split(".");let v=c;for(const L of S)v=v==null?void 0:v[L];return v})(a,s);if(["childrenAgeNumber","gender","maritalStatus","annualIncome","demographics.age","demographics.gender","demographics.maritalStatus","demographics.hasChildren","demographics.income","demographics.education","demographics.location","demographics.ethnicity"].some(c=>s.includes(c))?m!==""&&m!==void 0&&m!==null:!!m)f({title:"Field Already Has Data",description:"This field already has your entered data. AI suggestion not applied to preserve your input.",variant:"default"});else{if(s.includes(".")){const[c,p]=s.split(".");let S=h.suggestion;if(p==="businessType"){const v=(S||"").toLowerCase().trim();S=v.includes("b2b2c")||v.includes("both")?"b2b2c":v.includes("b2b")||v.includes("business to business")||v.includes("businesses")?"b2b":v.includes("b2c")||v.includes("consumer")?"b2c":"b2b"}u({[c]:{...a[c],[p]:S}})}else if(s==="goals"||s==="painPoints"){const c=typeof h.suggestion=="string"?h.suggestion.split(`
2`).filter(p=>p.trim()):Array.isArray(h.suggestion)?h.suggestion:[];s==="goals"?u({goals:c,goalsList:c}):s==="painPoints"&&u({painPoints:c,painPointsData:{primary:c[0]||"",secondary:c[1]||"",all:c}})}else u({[s]:h.suggestion});f({title:"AI Suggestion Applied",description:`Generated ${n.toLowerCase()} based on your context.`})}}}catch(l){console.error("AI suggestion failed:",l),f({title:"AI Suggestion Failed",description:"Please try again or fill in manually.",variant:"destructive"})}finally{H(l=>({...l,[s]:!1}))}},la=async()=>{var s,n,l,C,h,w,m,b,N,x,c,p,S,v,L,K,ee,ae,se,te,o,k,we,Ne,Se,Ae,Ce,ke,Pe,Te,Ie,Le,$e,De,Fe,Ee,Me,Re,Be,ze,Oe,Ue,Ge,We,qe,Ve,He,Qe,Ze,Ye,_e,Je,Xe,Ke;if(!a.targetService){f({title:"Service Required",description:"Please select a target service before using AI Generate All.",variant:"destructive"});return}H(z=>({...z,generateAll:!0})),M({isActive:!0,currentField:"complete-generation",currentFieldLabel:"Generating complete avatar profile...",completed:0,total:7,percentage:10});try{M(i=>({...i,completed:1,percentage:14,currentFieldLabel:"Step 1: Initializing AI analysis..."}));const z={age:((s=a.demographics)==null?void 0:s.age)||a.age||"",gender:((n=a.demographics)==null?void 0:n.gender)||a.gender||"",ethnicity:((l=a.demographics)==null?void 0:l.ethnicity)||a.ethnicity||"",maritalStatus:((C=a.demographics)==null?void 0:C.maritalStatus)||a.maritalStatus||"",hasChildren:((h=a.demographics)==null?void 0:h.hasChildren)||a.childrenAgeNumber||"",income:((w=a.demographics)==null?void 0:w.income)||a.annualIncome||"",education:((m=a.demographics)==null?void 0:m.education)||a.educationLevel||"",location:((b=a.demographics)==null?void 0:b.location)||a.location||""},ua=Date.now(),ga=re("/api/avatars/generate-worksheet",{method:"POST",body:JSON.stringify({existingData:{...a,serviceToPromote:a.targetService},lockedDemographics:z,generateImage:!0})});await new Promise(i=>setTimeout(i,1500)),M(i=>({...i,completed:2,percentage:28,currentFieldLabel:"Step 2: AI generating demographics..."})),await new Promise(i=>setTimeout(i,2e3)),M(i=>({...i,completed:3,percentage:42,currentFieldLabel:"Step 3: AI analyzing psychographics..."})),await new Promise(i=>setTimeout(i,2200)),M(i=>({...i,completed:4,percentage:57,currentFieldLabel:"Step 4: AI processing business context..."})),await new Promise(i=>setTimeout(i,2e3)),M(i=>({...i,completed:5,percentage:71,currentFieldLabel:"Step 5: AI mapping behavioral patterns..."})),await new Promise(i=>setTimeout(i,1800)),M(i=>({...i,completed:6,percentage:85,currentFieldLabel:"Step 6: AI synthesizing complete profile..."}));const ea=Date.now()-ua,aa=8e3;ea<aa&&await new Promise(i=>setTimeout(i,aa-ea));const t=await(await ga).json();if(t.error)throw new Error(t.details||t.error);console.log("Generated worksheet data from backend:",t),console.log("DEBUG - Goals from backend:",{goals:t.goals,goalsList:t.goalsList}),console.log("DEBUG - Pain Points from backend:",{painPoints:t.painPoints,painPointsData:t.painPointsData});const ha=i=>{if(!i)return"";const r=i.toLowerCase();return r.includes("female")||r==="woman"?"Female":r.includes("male")||r==="man"?"Male":r.includes("non-binary")||r.includes("nonbinary")?"Non-binary":"Prefer not to say"},xa=i=>{if(!i)return"";const r=i.toLowerCase();return r==="married"?"Married":r==="single"?"Single":r==="divorced"?"Divorced":r==="widowed"?"Widowed":r.includes("partner")?"Partnered":i},sa=i=>{if(!i)return"";const r=i.toLowerCase();
2return r==="0"||r==="0 children"||r.includes("no")||r==="none"?"0 children":r.includes("teen")||r.includes("13-17")?"Teenagers (13-17)":r.includes("6-12")||r.includes("school")?"School age (6-12)":r.includes("0-5")||r.includes("young")?"Young children (0-5)":r.includes("adult")?"Adult children":i},va=i=>i?i.includes("75k-100k")?"$75k-$100k":i.includes("50k-75k")?"$50k-$75k":i.includes("100k-150k")?"$100k-$150k":i.includes("25k-50k")?"$25k-$50k":i.includes("150k-250k")?"$150k-$250k":i.includes("250k")?"$250k+":i.includes("25k")||i.includes("under")?"Under $25k":i:"",fa=i=>{if(!i)return"";const r=i.toLowerCase();return r==="bachelors"||r.includes("bachelor")?"Bachelor's degree":r==="masters"||r.includes("master")?"Master's degree":r==="doctorate"||r.includes("phd")?"Doctorate":r.includes("high school")?"High school":r.includes("some college")?"Some college":r.includes("trade")?"Trade certification":i},ya=i=>{if(!i)return"";const r=i.toLowerCase();return r.includes("urban")||r.includes("city")?"Urban":r.includes("suburban")||r.includes("suburb")?"Suburban":r.includes("rural")||r.includes("country")?"Rural":r.includes("small town")?"Small town":i},ja=i=>{if(!i)return"";const r=i.toLowerCase();return r.includes("caucasian")||r.includes("white")?"White/Caucasian":r.includes("black")||r.includes("african")?"Black/African American":r.includes("hispanic")||r.includes("latino")?"Hispanic/Latino":r.includes("asian")||r.includes("pacific")?"Asian/Pacific Islander":r.includes("native american")?"Native American":r.includes("middle eastern")?"Middle Eastern":r.includes("mixed")||r.includes("other")?"Mixed/Other":i},ba=i=>{if(!i)return"";const r=i.toLowerCase();return r==="1-10"||r==="1-10 employees"?"1-10 employees":r==="11-50"||r==="11-50 employees"?"11-50 employees":r==="50-200"||r==="50-200 employees"?"50-200 employees":r==="200-1000"||r==="200-1000 employees"?"200-1000 employees":r==="1000-5000"||r==="1000-5000 employees"?"1000-5000 employees":r==="5000+"||r.includes("5000")||r==="over 5000"?"5000+ employees":i},wa=i=>{if(!i)return"";const r=i.toLowerCase();return r.includes("final")||r.includes("makes final")?"Final decision maker":r.includes("influences")||r.includes("influence")?"Influences budget decisions":r.includes("recommends")||r.includes("recommend")?"Recommends solutions":r.includes("researches")||r.includes("research")?"Researches options":r.includes("end user")||r.includes("user only")?"End user only":i},Na=i=>{if(!i)return"";const r=i.toLowerCase();return r.includes("professional")&&r.includes("direct")?"Professional and direct":r.includes("relationship")||r.includes("consultative")?"Relationship-focused and consultative":r.includes("data")||r.includes("analytical")?"Data-driven and analytical":r.includes("creative")||r.includes("innovative")?"Creative and innovative":i},oe={...a,name:a.name||t.name,targetService:a.targetService,age:a.age||t.age||"",gender:a.gender||t.gender||"",maritalStatus:a.maritalStatus||t.maritalStatus||"",childrenAgeNumber:a.childrenAgeNumber!==""&&a.childrenAgeNumber!==void 0&&a.childrenAgeNumber!==null?a.childrenAgeNumber:sa(t.childrenAgeNumber||""),annualIncome:a.annualIncome||t.annualIncome||"",educationLevel:a.educationLevel||t.educationLevel||"",location:a.location||t.location||"",ethnicity:a.ethnicity||t.ethnicity||"",industry:a.industry||t.industry||"",roleAtCompany:a.roleAtCompany||a.jobTitle||t.roleAtCompany||t.jobTitle||"",jobTitle:a.jobTitle||t.jobTitle||"",occupation:a.occupation||t.occupation||"",goals:a.goals&&a.goals.length>0?a.goals:t.goalsList||t.goals||[],goalsList:a.goalsList&&a.goalsList.length>0?a.goalsList:t.goalsList||t.goals||[],values:a.values||t.values||"",challenges:a.challenges||t.challenges||"",painPoints:a.painPoints&&a.painPoints.length>0?a.painPoints:(((N=t.painPoints)==null?void 0:N.length)>0?t.painPoints:null)||(((c=(x=t.painPointsData)==null?void 0:x.all)==null?void 0:c.length)>0?t.painPointsData.all:null)||[],painPointsData:{all:(p=a.painPointsData)!=null&&p.all&&a.painPointsData.all.length>0?a.painPointsData.all:(((S=t.painPoints)==null?void 0:S.length)>0?t.painPoints:null)||(((L=(v=t.painPointsData)==null?void 0:v.all)==null?void 0:L.length)>0?t.painPointsData.all:null)||[],primary:((K=t.painPointsData)==null?void 0:K.primary)||"",secondary:((ee=t.painPointsData)==null?void 0:ee.secondary)||""},quote:a.quote||t.quote||"",books:a.books||t.books||"",magazines:a.magazines||t.magazines||"",blogsWebsites:a.blogsWebsites||t.blogsWebsites||"",conferences:a.conferences||t.conferences||"",gurus:a.gurus||t.gurus||"",otherSources:a.otherSources||t.otherSources||"",objections:a.objections||t.objections||"",purchaseRole:a.purchaseRole||t.purchaseRole||"",beforeState:{...a.beforeState,...t.beforeState},afterState:{...a.afterState,...t.afterState},avatarImage:t.avatarImage||t.imageUrl||a.avatarImage||"",avatarType:t.avatarType||a.avatarType||"",avatarTypeContext:t.avatarTypeContext||"",businessModelContext:t.businessModelContext||"",demographics:{...a.demographics,age:(ae=a.demographics)!=null&&ae.age&&a.demographics.age!==""?a.demographics.age:a.age&&a.age!==""?a.age:t.age||"",gender:(se=a.demographics)!=null&&se.gender&&a.demographics.gender!==""?a.demographics.gender:a.gender&&a.gender!==""?a.gender:ha(t.gender||""),maritalStatus:(te=a.demographics)!=null&&te.maritalStatus&&a.demographics.maritalStatus!==""?a.demographics.maritalStatus:a.maritalStatus&&a.maritalStatus!==""?a.maritalStatus:xa(t.maritalStatus||""),hasChildren:(o=a.demographics)!=null&&o.hasChildren&&a.demographics.hasChildren!==""?a.demographics.hasChildren:a.childrenAgeNumber!==""&&a.childrenAgeNumber!==void 0&&a.childrenAgeNumber!==null?a.childrenAgeNumber:sa(t.childrenAgeNumber||""),income:(k=a.demographics)!=null&&k.income&&a.demographics.income!==""?a.demographics.income:a.annualIncome&&a.annualIncome!==""?a.annualIncome:va(t.annualIncome||""),education:(we=a.demographics)!=null&&we.education&&a.demographics.education!==""?a.demographics.education:a.educationLevel&&a.educationLevel!==""?a.educationLevel:fa(t.educationLevel||""),location:(Ne=a.demographics)!=null&&Ne.location&&a.demographics.location!==""?a.demographics.location:a.location&&a.location!==""?a.location:ya(t.location||""),ethnicity:(Se=a.demographics)!=null&&Se.ethnicity&&a.demographics.ethnicity!==""?a.demographics.ethnicity:a.ethnicity&&a.ethnicity!==""?a.ethnicity:ja(t.ethnicity||"")},professional:{...a.professional,industry:((Ae=a.professional)==null?void 0:Ae.industry)||a.industry||t.industry||"",roleAtCompany:((Ce=a.professional)==null?void 0:Ce.roleAtCompany)||a.roleAtCompany||((ke=a.professional)==null?void 0:ke.jobTitle)||a.jobTitle||((Pe=t.professional)==null?void 0:Pe.roleAtCompany)||t.roleAtCompany||((Te=t.professional)==null?void 0:Te.jobTitle)||t.jobTitle||"",jobTitle:((Ie=a.professional)==null?void 0:Ie.jobTitle)||a.jobTitle||t.jobTitle||"",occupation:((Le=a.professional)==null?void 0:Le.occupation)||a.occupation||t.occupation||"",companySize:(($e=a.professional)==null?void 0:$e.companySize)||ba(((De=t.professional)==null?void 0:De.companySize)||t.companySize||t.company_
2size||""),decisionMakingAuthority:((Fe=a.professional)==null?void 0:Fe.decisionMakingAuthority)||wa(((Ee=t.professional)==null?void 0:Ee.decisionMakingAuthority)||t.decisionMakingAuthority||t.decision_authority||""),communicationStyle:((Me=a.professional)==null?void 0:Me.communicationStyle)||Na(((Re=t.professional)==null?void 0:Re.communicationStyle)||t.communicationStyle||""),consumerCategory:((Be=a.professional)==null?void 0:Be.consumerCategory)||((ze=t.professional)==null?void 0:ze.consumerCategory)||t.consumerCategory||"",shoppingPreference:((Oe=a.professional)==null?void 0:Oe.shoppingPreference)||((Ue=t.professional)==null?void 0:Ue.shoppingPreference)||t.shoppingPreference||"",purchaseDriver:((Ge=a.professional)==null?void 0:Ge.purchaseDriver)||((We=t.professional)==null?void 0:We.purchaseDriver)||t.purchaseDriver||"",customerLifecycleStage:((qe=a.professional)==null?void 0:qe.customerLifecycleStage)||((Ve=t.professional)==null?void 0:Ve.customerLifecycleStage)||t.customerLifecycleStage||"",spendingPattern:((He=a.professional)==null?void 0:He.spendingPattern)||((Qe=t.professional)==null?void 0:Qe.spendingPattern)||t.spendingPattern||"",decisionMakingStyle:((Ze=a.professional)==null?void 0:Ze.decisionMakingStyle)||((Ye=t.professional)==null?void 0:Ye.decisionMakingStyle)||t.decisionMakingStyle||""}
2,psychographics:{...a.psychographics,lifestyle:t.lifestyle||(typeof t.values=="string"?t.values.substring(0,200):"")||a.lifestyle||((_e=a.psychographics)==null?void 0:_e.lifestyle)||"",values:Array.isArray(t.values)?t.values:(typeof t.values=="string"?[t.values]:[])||a.values||((Je=a.psychographics)==null?void 0:Je.values)||[],interests:t.interests||a.interests||((Xe=a.psychographics)==null?void 0:Xe.interests)||[],communicationStyle:t.communicationStyle||t.communication_style||a.communicationStyle||((Ke=a.psychographics)==null?void 0:Ke.communicationStyle)||""}};console.log("Final mapped worksheet for frontend:",oe),console.log("DEBUG AFTER MAPPING - Goals:",oe.goals),console.log("DEBUG AFTER MAPPING - Pain Points:",oe.painPoints),M(i=>({...i,completed:7,percentage:100,currentField:"complete",currentFieldLabel:"Complete avatar profile generated!"})),V(oe),f({title:"Avatar Generated!",description:'Avatar profile has been filled. Review the details and click "Save Avatar" when ready.'})}catch(z){console.error("Sophisticated avatar generation failed:",z),f({title:"AI Generation Failed",description:z.message||"Please try again or fill in manually.",variant:"destructive"})}finally{H(z=>({...z,generateAll:!1})),setTimeout(()=>{M({isActive:!1,currentField:"",currentFieldLabel:"",completed:0,total:0,percentage:0})},2e3)}},ca=()=>{V(T),localStorage.removeItem("avatar-worksheet-draft"),f({title:"Form Cleared",description:"All fields reset to empty. Ready for AI generation."})},ye=s=>s.replace(/([A-Z])/g," $1").trim().split(" ").map(n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase()).join(" "),da=s=>{var l;const n=(l=s.target.files)==null?void 0:l[0];if(n){if(n.size>2*1024*1024){f({title:"File Too Large",description:"Please choose an image under 2MB.",variant:"destructive"});return}const C=new FileReader;C.onload=h=>{var w;u({avatarImage:(w=h.target)==null?void 0:w.result})},C.readAsDataURL(n)}},ma=async()=>{var C,h,w;if(!a.name){f({title:"Name Required",description:"Please enter an avatar name before generating a photo.",variant:"destructive"});return}const s=((C=a.demographics)==null?void 0:C.age)||a.age||"35-44",n=((h=a.demographics)==null?void 0:h.gender)||a.gender||"person",l=((w=a.demographics)==null?void 0:w.ethnicity)||a.ethnicity||"";H(m=>({...m,photoGeneration:!0})),f({title:"Generating Photo...",description:"Creating a professional headshot with AI. This takes 20–30 seconds."});try{const b=await(await re("/api/avatars/generate-photo",{method:"POST",body:JSON.stringify({name:a.name,demographics:{...a.demographics,age:s,gender:n,ethnicity:l},aiPowerLevel:ge})})).json(),N=b.imageUrl||b.imageBase64;if(!N)throw new Error("No image returned from server");let x=N;if(N.startsWith("http")){f({title:"Almost There...",description:"AI is rendering your headshot — hang tight."});const c=await fetch(N);if(!c.ok)throw new Error(`Failed to retrieve generated image (HTTP ${c.status})`);const p=await c.blob();x=await new Promise((S,v)=>{const L=new FileReader;L.onload=()=>S(L.result),L.onerror=v,L.readAsDataURL(p)})}u({avatarImage:x,imageDescription:b.description}),f({title:"Avatar Photo Generated",description:"AI created a professional headshot for your avatar."})}catch(m){console.error("AI photo generation failed:",m);const b=(m==null?void 0:m.message)||String(m)||"Unknown error";f({title:"Photo Generation Failed",description:b.length>120?b.substring(0,117)+"...":b,variant:"destructive"})}finally{H(m=>({...m,photoGeneration:!1}))}},pa=async()=>{var C,h,w,m,b;if(de)return;if(!a.name||!a.targetService){f({title:"Required Fields Missing",description:"Please provide at least an avatar name and target service.",variant:"destructive"});return}ie(!0);const s=R,n=g?`/api/client-avatars/${D}`:"/api/client-avatars",l=g?"PATCH":"POST";try{console.log("🔍 [AVATAR DEBUG] Saving avatar with fields:",{mode:g?"UPDATE":"CREATE",avatarId:D,name:a.name,"=== WORK CONTEXT BEING SAVED ===":"---",occupation:a.occupation,roleAtCompany:a.roleAtCompany,jobTitle:a.jobTitle,"professional.industry":(C=a.professional)==null?void 0:C.industry,"professional.roleAtCompany":(h=a.professional)==null?void 0:h.roleAtCompany,"professional.jobTitle":(w=a.professional)==null?void 0:w.jobTitle,"professional.companySize":(m=a.professional)==null?void 0:m.companySize,"professional.businessType":(b=a.professional)==null?void 0:b.businessType,"=== DEMOGRAPHICS ===":"---",demographics:a.demographics,"=== FULL WORKSHEET PAYLOAD ===":a});const x=await(await re(n,{method:l,body:JSON.stringify({...a,companyId:s,...xe&&!g?{folderId:xe}:{}}),headers:{"X-Company-Id":(s==null?void 0:s.toString())||""}})).json();if(console.log("🔍 [AVATAR DEBUG] Save response:",x),x&&(x.id||x.avatarId||x.success)){const c=x.id||x.avatarId;c&&B.setQueryData(["/api/avatars",{companyId:s}],p=>g&&Array.isArray(p)?p.map(S=>S.id===c?x:S):p?Array.isArray(p)?[...p,x]:p:[x]),localStorage.removeItem("avatar-worksheet-draft"),f({title:g?"Avatar Updated":"Avatar Saved",description:g?"Your changes have been saved successfully.":"Your avatar has been added to the library."}),ie(!1),he("/client-avatars"),s?B.invalidateQueries({queryKey:["/api/avatars",{companyId:s}]}):B.invalidateQueries({queryKey:["/api/avatars"]}),g&&D&&B.invalidateQueries({queryKey:["/api/client-avatars",D]});return}else{console.warn("Avatar saved but no ID in response:",x);const c={...a,id:Date.now(),companyId:s,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};s&&B.setQueryData(["/api/avatars",{companyId:s}],p=>p?[...p,c]:[c]),localStorage.removeItem("avatar-worksheet-draft"),f({title:g?"Avatar Updated":"Avatar Saved",description:g?"Your changes have been saved successfully.":"Your avatar has been added to the library."}),ie(!1),he("/client-avatars"),s?B.invalidateQueries({queryKey:["/api/avatars",{companyId:s}]}):B.invalidateQueries({queryKey:["/api/avatars"]}),g&&D&&B.invalidateQueries({queryKey:["/api/client-avatars",D]});return}}catch(N){console.error("Save failed:",N),f({title:"Save Failed",description:N instanceof Error?N.message:"Please try again.",variant:"destructive"}),ie(!1)}};return!me||!R?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-orange-50 to-amber-50 dark:from-gray-900 dark:to-gray-800 p-3 sm:p-4 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(j,{className:"w-8 h-8 animate-spin text-orange-500 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading avatar worksheet..."})]})}):g&&oa?e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-orange-50 to-amber-50 dark:from-gray-900 dark:to-gray-800 p-3 sm:p-4 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(j,{className:"w-8 h-8 animate-spin text-orange-500 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading avatar for editing..."})]})}):e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-orange-50 to-amber-50 dark:from-gray-900 dark:to-gray-800 p-3 sm:p-4",children:[e.jsxs("div",{className:"max-w-4xl mx-auto 
2space-y-4 sm:space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4",children:[e.jsx(Ta,{href:"/client-avatars",children:e.jsxs(y,{variant:"outline",size:"sm","data-testid":"button-back",children:[e.jsx(Ia,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Back to Avatars"}),e.jsx("span",{className:"sm:hidden",children:"Back"})]})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-white",children:g?"Edit Avatar":"Avatar Worksheet"}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-400",children:g?"Update your avatar profile with all fields":"Complete avatar profile with AI assistance"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[ia&&e.jsxs("div",{className:"flex items-center gap-2 text-xs sm:text-sm text-gray-500",children:[e.jsx(j,{className:"w-3 h-3 sm:w-4 sm:h-4 animate-spin"}),e.jsx("span",{className:"hidden sm:inline",children:"Auto-saving..."}),e.jsx("span",{className:"sm:hidden",children:"Saving..."})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(La,{})}),e.jsxs(y,{onClick:ca,variant:"outline",className:"text-xs sm:text-sm px-2 sm:px-3 py-2","data-testid":"button-clear-all",children:[e.jsx($a,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-1 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Clear All"}),e.jsx("span",{className:"sm:hidden",children:"Clear"})]}),e.jsxs(y,{onClick:la,disabled:d.generateAll,className:"bg-purple-600 hover:bg-purple-700 text-white text-sm px-3 py-2","data-testid":"button-ai-generate-all",children:[d.generateAll?e.jsx(j,{className:"w-3 h-3 sm:w-4 sm:h-4 animate-spin mr-2"}):e.jsx(Wa,{className:"w-3 h-3 sm:w-4 sm:h-4 mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"AI Generate All"}),e.jsx("span",{className:"sm:hidden",children:"AI Fill"})]})]})]}),!ve&&!(E!=null&&E.length)&&e.jsx(O,{className:"border-orange-200 bg-orange-50 dark:bg-orange-900/20",children:e.jsx(U,{className:"pt-4 sm:pt-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ra,{className:"w-4 h-4 sm:w-5 sm:h-5 text-orange-600 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm sm:text-base font-medium text-orange-900 dark:text-orange-200",children:"Add Business Services First"}),e.jsx("p",{className:"text-xs sm:text-sm text-orange-700 dark:text-orange-300 mt-1",children:"Go to Business Profile → Services tab to add your services for better AI suggestions."})]})]})})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(qa,{className:"w-5 h-5"}),"Basic Information"]})}),e.jsx(U,{className:"space-y-4 p-4 sm:p-6",children:e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{htmlFor:"name",className:"text-sm font-medium",children:"Avatar Name *"}),e.jsx(le,{id:"name",value:a.name,onChange:s=>u({name:s.target.value}),placeholder:"e.g. Busy Business Owner Bob","data-testid":"input-avatar-name",className:"text-base"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{htmlFor:"targetService",className:"text-sm font-medium",children:"Target Service *"}),e.jsxs(Z,{value:a.targetService,onValueChange:s=>u({targetService:s}),children:[e.jsx(Y,{"data-testid":"select-target-service",className:"text-base",children:e.jsx(_,{placeholder:ve?"Loading services...":"Select service to target"})}),e.jsxs(J,{children:[g&&a.targetService&&!(E!=null&&E.some(s=>s.name===a.targetService))&&e.jsxs(F,{value:a.targetService,children:[a.targetService," (current)"]},"current-stored"),E!=null&&E.length?E.map(s=>e.jsx(F,{value:s.name,children:s.name},s.id)):a.targetService?null:e.jsx(F,{value:"no-services-available",disabled:!0,children:"No services found - add in Business Profile → Services"},"no-services")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{htmlFor:"targetMarket",className:"text-sm font-medium",children:"Target Market"}),e.jsxs(Z,{value:a.targetMarket,onValueChange:s=>u({targetMarket:s}),children:[e.jsx(Y,{"data-testid":"select-target-market",className:"text-base",children:e.jsx(_,{placeholder:"Select target market"})}),e.jsxs(J,{children:[g&&a.targetMarket&&!((je=G==null?void 0:G.targetMarket)!=null&&je.includes(a.targetMarket))&&e.jsxs(F,{value:a.targetMarket,children:[a.targetMarket," (current)"]},"current-stored-market"),(be=G==null?void 0:G.targetMarket)!=null&&be.length?G.targetMarket.map((s,n)=>e.jsx(F,{value:s,children:s},n)):a.targetMarket?null:e.jsx(F,{value:"no-markets-available",disabled:!0,children:"No target markets found - add to business profile"},"no-markets")]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{htmlFor:"avatarType",className:"text-sm font-medium",children:"Avatar Type"}),e.jsxs(Z,{value:a.avatarType,onValueChange:s=>u({avatarType:s}),children:[e.jsx(Y,{"data-testid":"select-avatar-type",className:"text-base",children:e.jsx(_,{placeholder:"Select avatar type"})}),e.jsxs(J,{children:[e.jsx(F,{value:"commercial",children:"Commercial (B2B)"}),e.jsx(F,{value:"residential",children:"Residential (B2C)"})]})]})]})]})})]}),e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Da,{className:"w-5 h-5"}),"Avatar Photo"]})}),e.jsxs(U,{className:"space-y-4 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[a.avatarImage&&e.jsx("img",{src:a.avatarImage,alt:"Avatar",className:"w-24 h-24 rounded-full object-cover border-4 border-orange-200"}),e.jsxs("div",{className:"space-y-3 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>{var s;return(s=document.getElementById("photo-upload"))==null?void 0:s.click()},"data-testid":"button-upload-photo",className:"w-full sm:w-auto",children:[e.jsx(Va,{className:"w-4 h-4 mr-2"}),"Upload Photo"]}),e.jsxs(y,{variant:"outline",onClick:ma,disabled:d.photoGeneration,"data-testid":"button-generate-ai-photo",className:"w-full sm:w-auto",children:[d.photoGeneration?e.jsx(j,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(P,{className:"w-4 h-4 mr-2"}),"Generate AI Photo"]})]}),e.jsx("p",{className:"text-xs text-gray-500",children:'300 DPI, printer-friendly up to 2x2"'})]})]}),e.jsx("input",{id:"photo-upload",type:"file",accept:"image/*",onChange:da,className:"hidden"})]})]}),e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Fa,{className:"w-5 h-5"}),"Demographics"]})}),e.jsx(U,{className:"space-y-4 p-4 sm:p-6",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:Object.entries(Qa).map(([s,n])=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize text-sm font-medium",children:s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`demographics.${s}`,s),disabled:d[`demographics.${s}`],"data-testid":`button-ai-suggest-${s}`,className:"h-8 w-8 p-0",children:d[`demographics.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsxs(Z,{value:a.demographics[s],onValueChange:l=>u({demographics:{...a.demographics,[s]:l}}),children:[e.jsx(Y,{"data-testid":`select-${s}`,className:"text-base",children:e.jsx(_,{placeholder:`Select ${s}`})}),e.jsx(J,{children:n.map(l=>e.jsx(F,{value:l,children:l},l))})]})]},s))})})]}),a.avatarType&&e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(ra,{className:"w-5 h-5"}),a.avatarType==="commercial"?"Professional":"Consumer"," Context"]})}),e.jsx(U,{className:"space-y-4 p-4 sm:p-6",children:a.avatarType==="commercial"?e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(A,{htmlFor:"industry",className:"text-sm font-medium",children:["Target Industry ",e.jsx("span",{className:"text-orange-600",children:"*"})]}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I("professional.industry","industry"),disabled:d["professional.industry"],"data-testid":"button-ai-suggest-industry",className:"h-8 w-8 p-0",children:d["professional.industry"]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(le,{id:"industry",value:a.professional.industry||"",onChange:s=>u({professional:{...a.professional,industry:s.target.value}}),placeholder:"e.g., Real Estate, Lawn Care, Beauty Salons, Restaurants","data-testid":"input-industry",className:"text-base"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Which industry does this avatar represent? This helps AI generate relevant context."})]}),["roleAtCompany"].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize text-sm font-medium",children:s==="roleAtCompany"?"Role in Company":s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`professional.${s}`,s),disabled:d[`professional.${s}`],"data-testid":`button-ai-suggest-${s}`,className:"h-8 w-8 p-0",children:d[`professional.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(le,{id:s,value:a.professional[s]||"",onChange:n=>u({professional:{...a.professional,[s]:n.target.value}}),placeholder:s==="roleAtCompany"?"Enter role in company":`Enter ${s.replace(/([A-Z])/g," $1").trim().toLowerCase()}`,"data-testid":`input-${s}`,className:"text-base"})]},s)),Object.entries(Za).map(([s,n])=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize text-sm font-medium",children:s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`professional.${s}`,s),disabled:d[`professional.${s}`],"data-testid":`button-ai-suggest-${s}`,className:"h-8 w-8 p-0",children:d[`professional.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsxs(Z,{value:a.professional[s]||"",onValueChange:l=>u({professional:{...a.professional,[s]:l}}),children:[e.jsx(Y,{"data-testid":`select-${s}`,className:"text-base",children:e.jsx(_,{placeholder:`Select ${s.replace(/([A-Z])/g," $1").trim().toLowerCase()}`})}),e.jsx(J,{children:n.map(l=>e.jsx(F,{value:l,children:s==="businessType"?l==="b2b"?"B2B (Business to Business)":l==="b2c"?"B2C (Business to Consumer)":l==="b2b2c"?"B2B2C (Both)":l:l},l))})]})]},s))]}):e.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:"consumerCategory",className:"text-sm font-medium",children:"Consumer Category"}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I("professional.consumerCategory","consumerCategory"),disabled:d["professional.consumerCategory"],"data-testid":"button-ai-suggest-consumerCategory",className:"h-8 w-8 p-0",children:d["professional.consumerCategory"]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(le,{id:"consumerCategory",value:a.professional.consumerCategory||"",onChange:s=>u({professional:{...a.professional,consumerCategory:s.target.value}}),placeholder:"E.g., Family diner, Fashion forward shopper, Fitness enthusiast","data-testid":"input-consumerCategory",className:"text-base"})]}),Object.entries(Ya).map(([s,n])=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize text-sm font-medium",children:s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`professional.${s}`,s),disabled:d[`professional.${s}`],"data-testid":`button-ai-suggest-${s}`,className:"h-8 w-8 p-0",children:d[`professional.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsxs(Z,{value:a.professional[s]||"",onValueChange:l=>u({professional:{...a.professional,[s]:l}}),children:[e.jsx(Y,{"data-testid":`select-${s}`,className:"text-base",children:e.jsx(_,{placeholder:`Select ${s.replace(/([A-Z])/g," $1").trim().toLowerCase()}`})}),e.jsx(J,{children:n.map(l=>e.jsx(F,{value:l,children:l},l))})]})]},s))]})})]}),e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Ea,{className:"w-5 h-5"}
2),"Psychographics & Values"]})}),e.jsxs(U,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:["lifestyle","communicationStyle"].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize",children:s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`psychographics.${s}`,s),disabled:d[`psychographics.${s}`],"data-testid":`button-ai-suggest-${s}`,children:d[`psychographics.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:s,value:a.psychographics[s]||"",onChange:n=>u({psychographics:{...a.psychographics,[s]:n.target.value}}),placeholder:`Describe their ${s.replace(/([A-Z])/g," $1").trim().toLowerCase()}`,rows:3,"data-testid":`textarea-${s}`})]},s))}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:"goals",className:"text-base font-medium",children:"Goals & Aspirations"}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I("goals","goals"),disabled:d.goals,"data-testid":"button-ai-suggest-goals",children:d.goals?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:"goals",value:Array.isArray(a.goals)?a.goals.join(`
3`):"",onChange:s=>u({goals:s.target.value.split(`
4`).filter(n=>n.trim()),goalsList:s.target.value.split(`
5`).filter(n=>n.trim())}),placeholder:`Enter goals (one per line):
6• What do they want to achieve?
7• What are their aspirations?
8• What success looks like to them`,rows:4,"data-testid":"textarea-goals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter each goal on a new line"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:"painPoints",className:"text-base font-medium",children:"Pain Points & Challenges"}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I("painPoints","pain points"),disabled:d.painPoints,"data-testid":"button-ai-suggest-painPoints",children:d.painPoints?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:"painPoints",value:Array.isArray(a.painPoints)?a.painPoints.join(`
9`):"",onChange:s=>{const n=s.target.value.split(`
10`).filter(l=>l.trim());u({painPoints:n,painPointsData:{primary:n[0]||"",secondary:n[1]||"",all:n}})},placeholder:`Enter pain points (one per line):
11• What frustrations do they face?
12• What problems keep them up at night?
13• What obstacles prevent their success?`,rows:4,"data-testid":"textarea-painPoints"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter each pain point on a new line"})]})]})]}),e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Ma,{className:"w-5 h-5"}),"Before/After Transformation"]})}),e.jsx(U,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-medium text-red-700 dark:text-red-400",children:"Before Using Your Services"}
13),Object.entries(a.beforeState).map(([s,n])=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:`before-${s}`,className:"text-sm",children:ye(s)}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`beforeState.${s}`,`before ${s}`),disabled:d[`beforeState.${s}`],"data-testid":`button-ai-suggest-before-${s}`,children:d[`beforeState.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:`before-${s}`,value:n||"",onChange:l=>u({beforeState:{...a.beforeState,[s]:l.target.value}}),placeholder:"What they have/feel/experience before...",rows:2,"data-testid":`textarea-before-${s}`})]},s))]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-medium text-green-700 dark:text-green-400",children:"After Using Your Services"}),Object.entries(a.afterState).map(([s,n])=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:`after-${s}`,className:"text-sm",children:ye(s)}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(`afterState.${s}`,`after ${s}`),disabled:d[`afterState.${s}`],"data-testid":`button-ai-suggest-after-${s}`,children:d[`afterState.${s}`]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:`after-${s}`,value:n||"",onChange:l=>u({afterState:{...a.afterState,[s]:l.target.value}}),placeholder:"What they desire/will have after...",rows:2,"data-testid":`textarea-after-${s}`})]},s))]})]})})]}),e.jsxs(O,{children:[e.jsx(W,{children:e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Ra,{className:"w-5 h-5"}),"Information Sources"]})}),e.jsx(U,{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:["books","magazines","blogsWebsites","conferences","gurus","otherSources"].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:s,className:"capitalize",children:s.replace(/([A-Z])/g," $1").trim()}),e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>I(s,s),disabled:d[s],"data-testid":`button-ai-suggest-${s}`,children:d[s]?e.jsx(j,{className:"w-3 h-3 animate-spin"}):e.jsx(P,{className:"w-3 h-3"})})]}),e.jsx(X,{id:s,value:a[s]||"",onChange:n=>u({[s]:n.target.value}),placeholder:`List relevant ${s.replace(/([A-Z])/g," $1").trim().toLowerCase()}`,rows:3,"data-testid":`textarea-${s}`})]},s))})})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between items-stretch sm:items-center gap-3 pt-6",children:[e.jsxs(y,{variant:"outline",onClick:()=>pe(!0),"data-testid":"button-preview",className:"w-full sm:w-auto",children:[e.jsx(Ba,{className:"w-4 h-4 mr-2"}),"Preview"]}),e.jsx(y,{onClick:pa,disabled:!a.name||!a.targetService||de,className:"bg-orange-600 hover:bg-orange-700 text-white w-full sm:w-auto","data-testid":"button-save-avatar",children:de?e.jsxs(e.Fragment,{children:[e.jsx(j,{className:"w-4 h-4 mr-2 animate-spin"}),g?"Updating...":"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ha,{className:"w-4 h-4 mr-2"}),g?"Update Avatar":"Save Avatar"]})})]})]})]}),e.jsx(za,{open:na,onOpenChange:pe,children:e.jsxs(Oa,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[e.jsx(Ua,{children:e.jsx(Ga,{children:"Avatar Preview"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Name:"})," ",a.name]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Service:"})," ",a.targetService]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Type:"})," ",a.avatarType]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Demographics:"})," ",Object.values(a.demographics).filter(Boolean).join(", ")]})]}),a.avatarImage&&e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:a.avatarImage,alt:"Avatar preview",className:"w-32 h-32 rounded-full object-cover border-4 border-orange-200"})})]})]})}),Q.isActive&&e.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm z-[9999] flex items-center justify-center p-4",style:{position:"fixed",width:"100vw",height:"100vh",margin:0},children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl p-6 w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-purple-100 dar
13k:bg-purple-900/30 rounded-full mx-auto mb-3 flex items-center justify-center",children:e.jsx(P,{className:"w-6 h-6 text-purple-600 animate-pulse"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-1",children:"AI Generating Content"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Creating personalized avatar content..."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex justify-between text-sm text-gray-600 dark:text-gray-400 mb-2",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{children:[Q.completed," / ",Q.total," fields"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-purple-600 h-2 rounded-full transition-all duration-300 ease-out",style:{width:`${Q.percentage}%`}})})]}),Q.currentFieldLabel&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-1",children:"Currently working on:"}),e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white",children:Q.currentFieldLabel})]})]})})]})}export{ns 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.