1import{z as M,a as b,p as e,w as le}from"./chunk-PVWAREVJ-BHmcscvQ.js";import{c as ie}from"./index-B9qW2AMW.js";import{R as I}from"./index-B6R3W7vg.js";import{R as W}from"./index-CwXTEoBl.js";import{R as oe}from"./ResourceSelect-D8L7kVey.js";import{u as ce,a as de,b as K,c as me}from"./persona.service-TBvoTXmn.js";import{R as B,F as v,L as C,M as y,C as N,S as $}from"./index-DKbAJi_N.js";import{u as P}from"./text-field-HGdxFzYA.js";import{o as S}from"./button-OYnqekgi.js";import{a as Y,b as Z}from"./index-CdEheP63.js";import{b as _}from"./index-GrhI4SFx.js";import{c as E}from"./index-z1NdIjVd.js";import{r as T}from"./text-area-vpG3ZL9N.js";import{R as ee,T as te,P as se,C as ae}from"./common-0a0DtsXa.js";import{C as re,a as ne}from"./lead.table-Dwr6VCbK.js";import{I as ue,h as he,g as xe,v as q}from"./dropdown-menu-BhPE5ijf.js";import{s as R,p as k,g as z,D as L,n as pe}from"./dialog-BedzsTvg.js";import{u as fe}from"./useQuery-BP9egheb.js";import{f as je}from"./index-DWy-hy0D.js";import{b as ge}from"./index-Dliix5Tv.js";import{b as be}from"./index-jejOGXBS.js";import{o as ve}from"./icon-button-C07NeCqs.js";import{A as Ce}from"./Alert-DN6IHrhB.js";import{L as Ne}from"./Loading-Cg3chB1V.js";import{o as H}from"./card-Cav_5wtf.js";import{c as ye}from"./scroll-area-BKcIQ7ZF.js";import{m as we,d as Pe,P as Q,f as D,b as Se,T as O}from"./table-Bwl8iJMN.js";import{p as F}from"./base-button-CXFvgNCg.js";import{p as A}from"./text-VXotemzN.js";import{e as V}from"./badge-CozVyiZE.js";import{e as Fe}from"./tooltip-DoPXExzC.js";import"./iconBase-vl3rlweI.js";import"./create.list.dialog-Ccdn_lnn.js";import"./http.client-Dc_RKy8G.js";import"./list.service-CswU0RAH.js";import"./QueryClientProvider-CsZRcPnZ.js";import"./useMutation-DsGR_GPj.js";import"./select-BxkCpzJN.js";import"./theme-B11y-dkV.js";import"./index-BJKtwL7T.js";import"./index-CLVnsNlL.js";import"./index-e8c_hUw9.js";import"./index-D0_j2JJU.js";import"./index-k3VHSEOM.js";import"./index-BpeUqqnX.js";import"./index-CYvYPmZ_.js";import"./internal-CWaUqJaS.js";import"./index-Cj077132.js";import"./Pagination-DwqKUFkn.js";import"./avatar-CEp7qkfw.js";import"./index-2fnI5BWA.js";import"./query-D4JqRbWu.js";import"./alert-dialog-MuPWG7q2.js";const De=({onSuccess:t})=>{const{teamId:a}=M(),[i,x]=b.useState({}),[m,c]=b.useState({productId:"",numberOfPersonas:"",maleCount:"",femaleCount:""}),o=ce(),h=(n,u)=>{c(f=>({...f,[n]:u}))},d=(n,u)=>{const f=parseInt(m.numberOfPersonas)||0,j=n==="maleCount"?"femaleCount":"maleCount";if(u===""){c(l=>({...l,[n]:""}));return}if(u==="0"){c(l=>({...l,[n]:"0",[j]:f.toString()}));return}const g=parseInt(u);if(isNaN(g))return;if(g>f){c(l=>({...l,[n]:f.toString(),[j]:"0"}));return}const s=f-g;c(l=>({...l,[n]:u,[j]:s.toString()}))},r=n=>{if(!n||n==="0"){c(g=>({...g,numberOfPersonas:n,maleCount:"0",femaleCount:"0"}));return}const u=parseInt(n);if(isNaN(u))return;if(u===5){c(g=>({...g,numberOfPersonas:n,maleCount:"3",femaleCount:"2"}));return}const f=Math.floor(u/2),j=u%2;c(g=>({...g,numberOfPersonas:n,maleCount:(f+j).toString(),femaleCount:f.toString()}))},p=n=>
1{n.preventDefault();const u=m;x({});const f={};if(u.productId||(f.productId="Please select a product"),!u.numberOfPersonas)f.numberOfPersonas="Please enter number of personas";else{const j=parseInt(u.numberOfPersonas);(isNaN(j)||j<1||j>5)&&(f.numberOfPersonas="Please enter a number between 1 and 5")}if(!u.maleCount)f.maleCount="Male count is required";else{const j=parseInt(u.maleCount),g=parseInt(u.numberOfPersonas)||0;(isNaN(j)||j<0||j>g)&&(f.maleCount="Male count cannot exceed total personas")}if(!u.femaleCount)f.femaleCount="Female count is required";else{const j=parseInt(u.femaleCount),g=parseInt(u.numberOfPersonas)||0;(isNaN(j)||j<0||j>g)&&(f.femaleCount="Female count cannot exceed total personas")}if(Object.keys(f).length>0){x(f);return}a&&m.productId&&o.mutate({persona:{productId:Number(m.productId),numberOfPersonas:parseInt(u.numberOfPersonas),genderDistribution:{male:parseInt(u.maleCount),female:parseInt(u.femaleCount)}},teamId:Number(a)},{onSuccess:()=>{t==null||t()}})};return e.jsx("div",{className:"flex flex-col items-center overflow-hidden",children:e.jsxs(B,{onSubmit:p,className:"flex flex-col gap-6 w-full",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"productId",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Select Product ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please select a product"})]}),e.jsx(N,{asChild:!0,children:e.jsx(oe,{resource:"products",labelKey:"name",onValueChange:n=>{h("productId",n)}})}),i.productId&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.productId})]}),e.jsxs(v,{className:"FormField flex-1",name:"numberOfPersonas",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Number of Personas"," ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please enter number of personas"})]}),e.jsx(N,{asChild:!0,children:e.jsx(P,{type:"number",min:1,max:5,placeholder:"Enter...",size:"3",value:m.numberOfPersonas,onChange:n=>{r(n.target.value)},required:!0})}),i.numberOfPersonas&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.numberOfPersonas})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"maleCount",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Male Personas ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Required"})]}),e.jsx(N,{asChild:!0,children:e.jsx(P,{type:"number",min:0,placeholder:"Male count...",size:"3",value:m.maleCount,onChange:n=>d("maleCount",n.target.value),required:!0})}),i.maleCount&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.maleCount})]}),e.jsxs(v,{className:"FormField flex-1",name:"femaleCount",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Female Personas ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Required"})]}),e.jsx(N,{asChild:!0,children:e.jsx(P,{type:"number",min:0,placeholder:"Female count...",size:"3",value:m.femaleCount,onChange:n=>d("femaleCount",n.target.value),required:!0})}),i.femaleCount&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.femaleCount})]})]}),o.error&&e.jsx("div",{className:"text-xs text-red-500 text-center",children:o.error.message}),e.jsx($,{asChild:!0,children:e.jsx(S,{size:"3",className:"w-full !cursor-pointer",loading:o.isPending,children:"Generate Personas"})})]})})};var G=(t=>(t.FrontendDeveloper="Frontend Developer",t.BackendDeveloper="Backend Developer",t.FullStackDeveloper="Full-Stack Developer",t.DevOpsEngineer="DevOps Engineer",t.CloudArchitect="Cloud Architect",t.DataScientist="Data Scientist",t.DataAnalyst="Data Analyst",t.MachineLearningEngineer="Machine Learning Engineer",t.UIUXDesigner="UI/UX Designer",t.GraphicDesigner="Graphic Designer",t.ProductManager="Product Manager",t.ProjectManager="Project Manager",t.DigitalMarketingSpecialist="Digital Marketing Specialist",t.SEOExpert="SEO Expert",t.ContentWriter="Content Writer",t.TechnicalWriter="Technical Writer",t.QAEngineer="QA Engineer",t.CybersecurityAnalyst="Cybersecurity Analyst",t.NetworkAdministrator="Network Administrator",t.DatabaseAdministrator="Database Administrator",t.MobileDeveloper="Mobile Developer",t.SystemsAnalyst="Systems Analyst",t.BusinessAnalyst="Business Analyst",t.ScrumMaster="Scrum Master",t.AgileCoach="Agile Coach",t.SalesEngineer="Sales Engineer",t.CustomerSuccessManager="Customer Success Manager",t.ITSupportSpecialist="IT Support Specialist",t.SolutionsArchitect="Solutions Architect",t.EmbeddedSystemsEngineer="Embedded Systems Engineer",t.GameDeveloper="Game Developer",t.AIResearchScientist="AI Research Scie
1ntist",t.BlockchainDeveloper="Blockchain Developer",t.IoTEngineer="IoT Engineer",t.VRDeveloper="VR Developer",t.ARDeveloper="AR Developer",t.TechnicalRecruiter="Technical Recruiter",t.HRBusinessPartner="HR Business Partner",t.SocialMediaManager="Social Media Manager",t.Copywriter="Copywriter",t.VideoEditor="Video Editor",t.ThreeDArtist="3D Artist",t.Animator="Animator",t.DataEngineer="Data Engineer",t.BIDeveloper="BI Developer",t.AutomationEngineer="Automation Engineer",t.RoboticsEngineer="Robotics Engineer",t.UIDeveloper="UI Developer",t.UXResearcher="UX Researcher",t.ProductDesigner="Product Designer",t.GrowthHacker="Growth Hacker",t.CRMSpecialist="CRM Specialist",t.SalesExecutive="Sales Executive",t.EcommerceManager="E-commerce Manager",t.SupplyChainAnalyst="Supply Chain Analyst",t.FinancialAnalyst="Financial Analyst",t.LegalConsultant="Legal Consultant",t.ComplianceOfficer="Compliance Officer",t.EventPlanner="Event Planner",t.Educator="Educator",t.TechnicalTrainer="Technical Trainer",t.Others="Others",t))(G||{}),U=(t=>(t.Professional="Professional",t.Formal="Formal",t.Casual="Casual",t.Authoritative="Authoritative",t.Diplomatic="Diplomatic",t.Collaborative="Collaborative",t.Instructive="Instructive",t.Neutral="Neutral",t.Technical="Technical",t.Academic="Academic",t.Empathetic="Empathetic",t.Enthusiastic="Enthusiastic",t.Compassionate="Compassionate",t.Passionate="Passionate",t.Humorous="Humorous",t.Sarcastic="Sarcastic",t.Dramatic="Dramatic",t.Optimistic="Optimistic",t.Pessimistic="Pessimistic",t.Nostalgic="Nostalgic",t.Descriptive="Descriptive",t.Concise="Concise",t.Detailed="Detailed",t.Storytelling="Storytelling",t.Analytical="Analytical",t.Speculative="Speculative",t.Hypothetical="Hypothetical",t.Poetic="Poetic",t.Flowery="Flowery",t.Minimalist="Minimalist",t.Inclusive="Inclusive",t.Provocative="Provocative",t.Controversial="Controversial",t.Patriotic="Patriotic",t.Satirical="Satirical",t.Woke="Woke",t.Traditional="Traditional",t.Progressive="Progressive",t.Rebellious="Rebellious",t.Spiritual="Spiritual",t.Urgent="Urgent",t.Apologetic="Apologetic",t.Celebratory="Celebratory",t.Sympathetic="Sympathetic",t.Condescending="Condescending",t.Confrontational="Confrontational",t.Reassuring="Reassuring",t.Motivational="Motivational",t.Inspirational="Inspirational",t.Secretive="Secretive",t.Legalistic="Legalistic",t.Medical="Medical",t.Journalistic="Journalistic",t.Marketing="Marketing",t.Salesy="Salesy",t.Corporate="Corporate",t.Startup="Startup",t.TechSavvy="Tech-Savvy",t.AcademicResearch="Academic Research",t.GovernmentOfficial="Government Official",t.Conversational="Conversational",t.Friendly="Friendly",t.Warm="Warm",t.Cold="Cold",t.Quirky="Quirky",t.Whimsical="Whimsical",t.Suspenseful="Suspenseful",t.Mysterious="Mysterious",t.Romantic="Romantic",t.Scholarly="Scholarly",t.Others="Others",t))(U||{});const Oe=Object.entries(G).map(([t,a])=>({label:a,value:a})),Ae=Object.entries(U).map(([t,a])=>({label:a,value:a})),X=({options:t,value:a,onChange:i,placeholder:x,name:m})=>{const[c,o]=b.useState(!1),[h,d]=b.useState(""),r=b.useRef(null),p=b.useRef(null),n=t.filter(s=>s.label.toLowerCase().includes(h.toLowerCase())),u=s=>{const l=a.includes(s);i(l?a.filter(w=>w!==s):[...a,s]),setTimeout(()=>{r.current&&r.current.focus()},0)},f=s=>{i(a.filter(l=>l!==s))},j=s=>{o(s),s||d("")},g=t.filter(s=>a.includes(s.value));return e.jsxs(ee,{open:c,onOpenChange:j,children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{ref:p,className:"flex items-center flex-wrap gap-1 w-full rounded-lg border border-zinc-200 px-2 py-1.5 focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500 min-h-[40px] cursor-text",onClick:()=>{r.current&&(r.current.focus(),o(!0))},children:[g.map(s=>e.jsxs("div",{className:"flex items-center gap-1 bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs",children:[e.jsx("span",{children:s.label}),e.jsx("button",{onClick:l=>{l.stopPropagation(),f(s.value)},className:"hover:bg-blue-200 rounded-full p-0.5",type:"button",children:e.jsx(Y,{size:10})})]},s.value)),e.jsx("input",{ref:r,type:"text",value:h,onChange:s=>{d(s.target.value),c||o(!0)},placeholder:g.length>0?"":x,className:"flex-grow bg-transparent focus:outline-none p-1 text-sm min-w-[60px]",onFocus:()=>o(!0),onClick:s=>{s.stopPropagation(),o(!0)},onBlur:s=>{var l;(l=p.current)!=null&&l.contains(s.relatedTarget)||setTimeout(()=>
1o(!1),150)}}),e.jsx("div",{className:"ml-auto pl-1 cursor-pointer",onClick:s=>{s.stopPropagation(),r.current&&(r.current.focus(),o(!c))},children:e.jsx(_,{className:`text-gray-500 transition-transform ${c?"rotate-180":""}`})})]})}),e.jsx(se,{children:e.jsxs(ae,{onOpenAutoFocus:s=>{s.preventDefault()},onCloseAutoFocus:s=>{s.preventDefault()},side:"bottom",sideOffset:8,align:"start",className:"border border-zinc-200 flex flex-col gap-1 shadow focus:outline-none bg-white p-2 rounded-lg max-h-48 overflow-y-auto z-50 w-[var(--radix-popover-trigger-width)]",onPointerDownOutside:s=>{var l;(l=p.current)!=null&&l.contains(s.target)&&s.preventDefault()},children:[(h?n:t).map(s=>{const l=a.includes(s.value);return e.jsxs("button",{onMouseDown:w=>{w.preventDefault(),u(s.value)},className:E(["p-2 cursor-pointer flex justify-start items-center gap-3 rounded-lg w-full text-sm text-left",{"bg-blue-100":l,"hover:bg-gray-100":!l}]),type:"button",children:[e.jsx(re,{checked:l,className:"h-4 w-4 rounded border flex items-center justify-center border-gray-400 data-[state=checked]:bg-blue-500 data-[state=checked]:border-blue-500",children:e.jsx(ne,{children:e.jsx(Z,{className:"h-3 w-3 text-white"})})}),e.jsx("span",{children:s.label})]},s.value)}),n.length===0&&h&&e.jsx("div",{className:"p-2 text-sm text-zinc-500",children:"No results found"})]})})]})},Me=({onSuccess:t})=>{const{teamId:a}=M(),[i,x]=b.useState({}),[m,c]=b.useState({name:"",role:"",expertise:[],tone:[],about:""}),o=de(),h=r=>{r.preventDefault();const p=m;x({});const n={};if(p.name.trim()||(n.name="Please enter the persona name"),p.role.trim()||(n.role="Please enter the persona role"),p.expertise.length||(n.expertise="Please select at least one expertise"),p.tone.length||(n.tone="Please select at least one tone"),p.about.trim()||(n.about="Please enter the persona description"),Object.keys(n).length>0){x(n);return}a&&o.mutate({persona:{name:p.name,role:p.role,expertise:p.expertise,tone:p.tone,about:p.about},teamId:Number(a)},{onSuccess:()=>{t==null||t()}})},d=(r,p)=>{c(n=>({...n,[r]:p}))};return e.jsx("div",{className:"flex flex-col items-center overflow-hidden",children:e.jsxs(B,{onSubmit:h,className:"flex flex-col gap-6 w-full",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"name",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Name ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please enter the persona name"})]}),e.jsx(N,{asChild:!0,children:e.jsx(P,{placeholder:"Bahauddin",size:"3",value:m.name,onChange:r=>d("name",r.target.value),required:!0})}),i.name&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.name})]}),e.jsxs(v,{className:"FormField flex-1",name:"role",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Role ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please enter the persona role"})]}),e.jsx(N,{asChild:!0,children:e.jsx(P,{placeholder:"SaaS founder",size:"3",value:m.role,onChange:r=>d("role",r.target.value),required:!0})}),i.role&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.role})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"expertise",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Expertise ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please select at least one expertise"})]}),e.jsx(N,{asChild:!0,children:e.jsx("div",{children:e.jsx(X,{options:Oe,value:m.expertise,onChange:r=>d("expertise",r),placeholder:"Select expertise areas",name:"expertise"})})}),i.expertise&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.expertise})]}),e.jsxs(v,{className:"FormField flex-1",name:"tone",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["Tone ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please select at least one tone"})]}),e.jsx(N,{asChild:!0,children:e.jsx("div",{children:e.jsx(X,{options:Ae,value:m.tone,onChange:r=>d("tone",r),placeholder:"Select tone styles",name:"tone"})})}),i.tone&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.tone})]})]}),e.jsxs(v,{className:"FormField",name:"about",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs(C,{className:"FormLabel",children:["About ",e.jsx("span",{className:"text-red-500 text-xs",children:"*"})]}),e.jsx(y,{className:"text-xs text-red-500",match:"valueMissing",children:"Please enter the persona description"})]}),e.jsx(N,{asChild:!0,children:e.jsx(T,{size:"3",required:!0,placeholder:"e.g., Built and scaled an e-commerce brand from $0 to $10M ARR. Now advising other DTC founders while working on my next venture. Fitness enthusiast who starts every day with a 5am workout.",value:m.about,onChange:r=>d("about",r.target.value),resize:"vertical"})}),i.about&&e.jsx("div",{className:"text-xs text-red-500 mt-1",children:i.about})]}),o.error&&e.jsx("div",{className:"text-xs text-red-500 text-center",children:o.error.message}),e.jsx($,{asChild:!0,children:e.jsx(S,{size:"3",className:"w-full !cursor-pointer",loading:o.isPending,children:"Create persona"})})]})})},Ie=()=>{const[t,a]=b.useState(!1),[i,x]=b.useState(!1),[m,c]=b.useState(!1),o=()=>{a(!1),x(!0)},h=()=>{a(!1),c(!0)},d=()=>{x(!1)},r=()=>{c(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(ue,{open:t,onOpenChange:a,children:[e.jsx(he,{children:e.jsxs(S,{className:"!cursor-pointer",children:[e.jsx(W,{}),"Create Persona"]})}),e.jsxs(xe,{children:[e.jsx(q,{onClick:o,children:e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(W,{}),"Create Persona"]})}),e.jsx(q,{onClick:h,children:e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(ie,{}),"Generate with AI"]})})]})]}),e.jsx(R,{open:i,onOpenChange:x,children:e.jsxs(k,{className:"overflow-visible max-h-[90vh]",children:[e.jsx(z,{className:"text-lg font-medium mb-4 w-full",children:e.jsxs("div",{className:"flex justify-between items-center",children:["Create Persona",e.jsx(L,{children:e.jsx(S,{variant:"ghost",size:"2",className:"!cursor-pointer",children:e.jsx(I,{})})})]})}),e.jsx(Me,{onSuccess:d})]})}),e.jsx(R,{open:m,onOpenChange:c,children:e.jsxs(k,{className:"overflow-visible max-h-[90vh]",children:[e.jsx(z,{className:"text-lg font-medium mb-4 w-full",children:e.jsxs("div",{className:"flex justify-between items-center",children:["Generate AI Personas",e.jsx(L,{children:e.jsx(S,{variant:"ghost",size:"2",className:"!cursor-pointer",children:e.jsx(I,{})})})]})}),e.jsx(De,{onSuccess:r})]})})]})},Re=Object.entries(G).map(([t,a])=>({label:a,value:a})),ke=Object.entries(U).map(([t,a])=>({label:a,value:a})),J=({options:t,value:a,onChange:i,placeholder:x,name:m})=>{const[c,o]=b.useState(!1),[h,d]=b.useState(""),r=b.useRef(null),p=b.useRef(null),n=t.filter(s=>s.label.toLowerCase().includes(h.toLowerCase())),u=s=>{const l=a.includes(s);i(l?a.filter(w=>w!==s):[...a,s]),setTimeout(()=>{r.current&&r.current.focus()},0)},f=s=>{i(a.filter(l=>l!==s))},j=s=>{o(s),s||d("")},g=t.filter(s=>a.includes(s.value));return e.jsxs(ee,{open:c,onOpenChange:j,children:[e.jsx(te,{asChild:!0,children:e.jsxs("div",{ref:p,className:"flex items-center flex-wrap gap-1 w-full rounded-lg border border-zinc-200 px-2 py-1.5 focus-within:ring-2 focus-within:ring-blue-500 focus-within:border-blue-500 min-h-[40px] cursor-text",onClick:()=>{r.current&&(r.current.focus(),o(!0))},children:[g.map(s=>e.jsxs("div",{className:"flex items-center gap-1 bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs",children:[e.jsx("span",{children:s.label}),e.jsx("button",{onClick:l=>{l.stopPropagation(),f(s.value)},className:"hover:bg-blue-200 rounded-full p-0.5",type:"button",children:e.jsx(Y,{size:10})})]},s.value)),e.jsx("input",{ref:r,type:"text",value:h,onChange:s=>{d(s.target.value),c||o(!0)},placeholder:g.length>0?"":x,className:"flex-grow bg-transparent focus:outline-none p-1 text-sm min-w-[60px]",onFocus:()=>o(!0),onClick:s=>{s.stopPropagation(),o(!0)},onBlur:s=>{var l;(l=p.current)!=null&&l.contains(s.relatedTarget)||setTimeout(()=>
1o(!1),150)}}),e.jsx("div",{className:"ml-auto pl-1 cursor-pointer",onClick:s=>{s.stopPropagation(),r.current&&(r.current.focus(),o(!c))},children:e.jsx(_,{className:`text-gray-500 transition-transform ${c?"rotate-180":""}`})})]})}),e.jsx(se,{children:e.jsxs(ae,{onOpenAutoFocus:s=>{s.preventDefault()},onCloseAutoFocus:s=>{s.preventDefault()},side:"bottom",sideOffset:8,align:"start",className:"border border-zinc-200 flex flex-col gap-1 shadow focus:outline-none bg-white p-2 rounded-lg max-h-48 overflow-y-auto z-50 w-[var(--radix-popover-trigger-width)]",onPointerDownOutside:s=>{var l;(l=p.current)!=null&&l.contains(s.target)&&s.preventDefault()},children:[(h?n:t).map(s=>{const l=a.includes(s.value);return e.jsxs("button",{onMouseDown:w=>{w.preventDefault(),u(s.value)},className:E(["p-2 cursor-pointer flex justify-start items-center gap-3 rounded-lg w-full text-sm text-left",{"bg-blue-100":l,"hover:bg-gray-100":!l}]),type:"button",children:[e.jsx(re,{checked:l,className:"h-4 w-4 rounded border flex items-center justify-center border-gray-400 data-[state=checked]:bg-blue-500 data-[state=checked]:border-blue-500",children:e.jsx(ne,{children:e.jsx(Z,{className:"h-3 w-3 text-white"})})}),e.jsx("span",{children:s.label})]},s.value)}),n.length===0&&h&&e.jsx("div",{className:"p-2 text-sm text-zinc-500",children:"No results found"})]})})]})},ze=({onSuccess:t,persona:a})=>{const{teamId:i}=M(),[x,m]=b.useState({name:a.name,role:a.role,expertise:a.expertise,tone:a.tone,about:a.about}),c=K(),o=d=>{d.preventDefault();const r=x;i&&c.mutate({persona:{name:r.name,role:r.role,expertise:r.expertise,tone:r.tone,about:r.about},teamId:Number(i),id:Number(a.id)},{onSuccess:()=>{t==null||t()}})},h=(d,r)=>{m(p=>({...p,[d]:r}))};return e.jsx("div",{className:"flex flex-col items-center overflow-hidden",children:e.jsxs(B,{onSubmit:o,className:"flex flex-col gap-6 w-full",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"name",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx(C,{className:"FormLabel",children:"Name"})}),e.jsx(N,{asChild:!0,children:e.jsx(P,{placeholder:"Bahauddin",size:"3",value:x.name,onChange:d=>h("name",d.target.value)})})]}),e.jsxs(v,{className:"FormField flex-1",name:"role",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx(C,{className:"FormLabel",children:"Role"})}),e.jsx(N,{asChild:!0,children:e.jsx(P,{placeholder:"SaaS founder",size:"3",value:x.role,onChange:d=>h("role",d.target.value)})})]})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(v,{className:"FormField flex-1",name:"expertise",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx(C,{className:"FormLabel",children:"Expertise"})}),e.jsx(N,{asChild:!0,children:e.jsx("div",{children:e.jsx(J,{options:Re,value:x.expertise,onChange:d=>h("expertise",d),placeholder:"Select expertise areas",name:"expertise"})})})]}),e.jsxs(v,{className:"FormField flex-1",name:"tone",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx(C,{className:"FormLabel",children:"Tone"})}),e.jsx(N,{asChild:!0,children:e.jsx("div",{children:e.jsx(J,{options:ke,value:x.tone,onChange:d=>h("tone",d),placeholder:"Select tone styles",name:"tone"})})})]})]}),e.jsxs(v,{className:"FormField",name:"about",children:[e.jsx("div",{className:"flex items-baseline justify-between",children:e.jsx(C,{className:"FormLabel",children:"About"})}),e.jsx(N,{asChild:!0,children:e.jsx(T,{size:"3",placeholder:"e.g., Built and scaled an e-commerce brand from $0 to $10M ARR. Now advising other DTC founders while working on my next venture. Fitness enthusiast who starts every day with a 5am workout.",value:x.about,onChange:d=>h("about",d.target.value),resize:"vertical"})})]}),e.jsx($,{asChild:!0,children:e.jsx(S,{size:"3",className:"w-full !cursor-pointer",loading:c.isPending,children:"Update persona"})})]})})},Le=({persona:t})=>{const[a,i]=b.useState(!1),x=()=>{i(!1)};return e.jsxs(R,{open:a,onOpenChange:i,children:[e.jsx(pe,{children:e.jsx(ve,{variant:"ghost",className:"!cursor-pointer",children:e.jsx(be,{})})}),e.jsxs(k,{className:"overflow-visible max-h-[90vh]",children:[e.jsx(z,{className:"text-lg font-medium mb-4 w-full",children:e.jsxs("div",{className:"flex justify-between items-center",children:["Update Product",e.jsx(L,{children:e.jsx(S,{variant:"ghost",size:"2",className:"!cursor-pointer",children:e.jsx(I,{})})})]})}),e.jsx(ze,{onSuccess:x,persona:t})]})]})},Be=()=>e.jsxs(F,{direction:"column",align:"center",py:"9",px:"4",children:[e.jsx(F,{align:"center",justify:"center",width:"80px",height:"80px",mb:"6",style:{backgroundColor:"var(--color-primary-bg, #e6ebf5)",borderRadius:"50%"},children:e.jsx(ge,{size:40,color:"var(--color-primary, #3f51b5)"})}),e.jsx(A,{size:"5",weight:"bold",mb:"2",children:"No Personas Yet"}),e.jsx(A,{size:"3",color:"gray",align:"center",style:{maxWidth:"400px"},children:"Create your first persona to personalize your engagement strategy and connect with your target audience."})]});function $e(){const{teamId:t}=M(),{data:a,isLoading:i}=fe({queryKey:["personas",t]}),x=me();return K(),(a==null?void 0:a.length)===0?e.jsx(H,{children:e.jsx(Be,{})}):i?e.jsx(Ne,{}):e.jsx(e.Fragment,{children:e.jsx(H,{children:e.jsx(ye,{type:"always",scrollbars:"both",style:{height:"80vh"},children:e.jsxs(we,{children:[e.jsx(Pe,{children:e.jsxs(Q,{children:[e.jsx(D,{children:"Persona"}),e.jsx(D,{children:"About"}),e.jsx(D,{children:"Expertise"}),e.jsx(D,{children:"Tone"}),e.jsx(D,{width:"80px"})]})}),e.jsx(Se,{children:a==null?void 0:a.map(m=>{var c,o;return e.jsxs(Q,{children:[e.jsx(O,{children:e.jsxs(F,{direction:"column",gap:"1",children:[e.jsx(A,{weight:"medium",children:m.name}),e.jsx(A,{size:"2",color:"gray",children:m.role})]})}),e.jsx(O,{children:e.jsx(A,{wrap:"pretty",size:"2",style:{whiteSpace:"normal",overflowWrap:"break-word",wordBreak:"break-word",verticalAlign:"top"},children:m.about})}),e.jsx(O,{children:e.jsx(F,{wrap:"wrap",gap:"1",children:(c=m.expertise)==null?void 0:c.map(h=>e.jsx(V,{color:"blue",variant:"soft",children:h},h))})}),e.jsx(O,{children:e.jsx(F,{wrap:"wrap",gap:"1",children:(o=m.tone)==null?void 0:o.map(h=>e.jsx(V,{color:"purple",variant:"soft",children:h},h))})}),e.jsx(O,{children:e.jsxs(F,{gap:"1",align:"center",children:[e.jsx(Le,{persona:m}),e.jsx(Fe,{content:"Delete",children:e.jsx(Ce,{icon:e.jsx(je,{size:20,color:"red"}),onSuccess:()=>x.mutate({personaId:m.id,teamId:Number(t)}),successLoading:x.isPending,description:"Are you sure you want to delete this persona? This action cannot be undone.",title:"Delete persona?"})})]})})]},m.id)})})]})})})})}const $t=()=>[{title:"Personas"}],Gt=le(function(){return e.jsxs("div",{className:"p-4 pl-8 h-full flex flex-col gap-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Personas"}),e.jsx("p",{children:"Create and manage your AI personas for personalized outreach."})]}),e.jsx("div",{children:e.jsx(Ie,{})})]}),e.jsx("div",{className:" w-full h-full",children:e.jsx($e,{})})]})});export{Gt as default,$t as meta};
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.