1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,556831,e=>{"use strict";var t=e.i(931718),a=e.i(729386),n=e.i(632137),i=e.i(341965),r=e.i(599554),s=e.i(262406),o=e.i(459333),l=e.i(485954),c=e.i(439119),d=e.i(902769),u=e.i(857078),m=e.i(998518);e.i(339295);var p=e.i(625923),h=e.i(899409),g=e.i(869409),x=e.i(813911),f=e.i(768125),v=e.i(350975),j=e.i(504149),b=e.i(919986),y=e.i(38939),C=e.i(867357);let S=new Set(["instagram","youtube","youtube-channel","twitter","github","linkedin"]),_={"youtube-channel":b.YoutubeIcon};function N(e){let t=e.icon??(0,y.detectLinkIcon)(e.url);return{FallbackIcon:_[t]??j.iconComponents[t]??j.iconComponents.website,autoFaviconUrl:S.has(t)?void 0:e.faviconUrl??(0,C.getFaviconUrlForDisplay)(e.url),detectedIcon:t,faviconIconValue:e.iconData}}let k=/^www\./;function I(e){let i,r,s,o,c,u,b,y,C,S,_,I,A,L,T,D,B,M,P,E,z,U,O,F,G=(0,a.c)(90),{isEditable:$,item:q,onDeleteImage:Q,onTouchImage:V,onRemove:R,onUpdate:K,onUploadImage:J,uploadedImages:W}=e,[Y,H]=(0,l.useState)(q.title),[Z,X]=(0,l.useState)(q.url),[ee,et]=(0,l.useState)(q.description??"");G[0]!==q.description||G[1]!==q.title||G[2]!==q.url?(i=()=>{H(q.title),X(q.url),et(q.description??"")},r=[q.title,q.url,q.description],G[0]=q.description,G[1]=q.title,G[2]=q.url,G[3]=i,G[4]=r):(i=G[3],r=G[4]),(0,l.useEffect)(i,r),G[5]!==q?(s=N(q),G[5]=q,G[6]=s):s=G[6];let{faviconIconValue:ea,autoFaviconUrl:en,FallbackIcon:ei}=s,er=!$;G[7]!==q.id||G[8]!==er?(o={id:q.id,disabled:er},G[7]=q.id,G[8]=er,G[9]=o):o=G[9];let{attributes:es,listeners:eo,setNodeRef:el,transform:ec,transition:ed,isDragging:eu}=(0,d.useSortable)(o);G[10]!==ec?(c=m.CSS.Transform.toString(ec),G[10]=ec,G[11]=c):c=G[11],G[12]!==c||G[13]!==ed?(u={transform:c,transition:ed},G[12]=c,G[13]=ed,G[14]=u):u=G[14];let em=u;G[15]!==q.title||G[16]!==K||G[17]!==Y?(b=()=>{let e=Y.trim();e&&e!==q.title?K({title:e}):H(q.title)},G[15]=q.title,G[16]=K,G[17]=Y,G[18]=b):b=G[18];let ep=b;G[19]!==q.url||G[20]!==K||G[21]!==Z?(y=()=>{let e=Z.trim();e&&e!==q.url?K({url:e}):X(q.url)},G[19]=q.url,G[20]=K,G[21]=Z,G[22]=y):y=G[22];let eh=y;G[23]!==ee||G[24]!==q.description||G[25]!==K?(C=()=>{let e=ee.trim();(e||void 0)!==q.description&&K({description:e||void 0})},G[23]=ee,G[24]=q.description,G[25]=K,G[26]=C):C=G[26];let eg=C,ex=ei??j.iconComponents.website,ef=q.title||q.url;G[27]!==en||G[28]!==ea||G[29]!==ex||G[30]!==ef?(S=(0,t.jsx)(v.LinkFaviconDisplay,{autoFaviconUrl:en,avatarUrl:void 0,channelAvatarUrl:void 0,className:"size-4 text-foreground",FallbackIcon:ex,faviconIconValue:ea,isSpotifyArtist:!1,isYouTubeChannel:!1,linkTitle:ef,spotifyAvatarUrl:void 0}),G[27]=en,G[28]=ea,G[29]=ex,G[30]=ef,G[31]=S):S=G[31];let ev=S;G[32]!==ea||G[33]!==ev||G[34]!==$||G[35]!==Q||G[36]!==V||G[37]!==K||G[38]!==J||G[39]!==W?(_=$?(0,t.jsx)(p.IconPicker,{mode:"icon",onChange:e=>K({iconData:e}),onDeleteImage:Q,onTouchImage:V,onUploadImage:J,uploadedImages:W??j.EMPTY_UPLOADED_IMAGES,value:ea,children:(0,t.jsxs)("div",{className:(0,n.cn)("flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border bg-background","group/favicon relative cursor-pointer"),title:ea?"Change icon":"Choose icon (remove reverts to favicon)",children:[ev,(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-black/40 opacity-0 transition-opacity group-hover/favicon:opacity-100",children:(0,t.jsx)(x.ImagePlus,{className:"size-3.5 text-white"})})]})}):(0,t.jsx)("div",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border bg-background",children:ev}),G[32]=ea,G[33]=ev,G[34]=$,G[35]=Q,G[36]=V,G[37]=K,G[38]=J,G[39]=W,G[40]=_):_=G[40];let ej=_;if(!$){let e,a,i,r,s,o,l;G[41]===Symbol.for("react.memo_cache_sentinel")?(e=(0,n.cn)("group relative flex items-center gap-2 rounded-xl px-1.5 py-2 transition-colors hover:bg-muted/40 focu
1s-within:bg-muted/60","no-underline"),G[41]=e):e=G[41];let c=q.title||q.url;return G[42]!==c?(a=(0,t.jsx)("span",{className:"truncate font-medium text-foreground text-sm",children:c}),G[42]=c,G[43]=a):a=G[43],G[44]!==q.description||G[45]!==q.url?(i=q.description||function(e){try{return new URL(e).hostname.replace(k,"")}catch{return e}}(q.url),G[44]=q.description,G[45]=q.url,G[46]=i):i=G[46],G[47]!==i?(r=(0,t.jsx)("span",{className:"truncate text-muted-foreground text-xs",children:i}),G[47]=i,G[48]=r):r=G[48],G[49]!==a||G[50]!==r?(s=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[a,r]}),G[49]=a,G[50]=r,G[51]=s):s=G[51],G[52]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(h.ExternalLink,{className:"size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100"}),G[52]=o):o=G[52],G[53]!==ej||G[54]!==q.url||G[55]!==s?(l=(0,t.jsxs)("a",{className:e,href:q.url,rel:"noopener noreferrer",target:"_blank",children:[ej,s,o]}),G[53]=ej,G[54]=q.url,G[55]=s,G[56]=l):l
1=G[56],l}let eb=eu&&"z-10 opacity-60";return G[57]!==eb?(I=(0,n.cn)("group relative flex items-center gap-2 rounded-xl px-1.5 py-2 transition-colors hover:bg-muted/40 focus-within:bg-muted/60",eb),G[57]=eb,G[58]=I):I=G[58],G[59]===Symbol.for("react.memo_cache_sentinel")?(A=(0,t.jsx)(g.GripVertical,{className:"size-3.5"}),G[59]=A):A=G[59],G[60]!==es||G[61]!==eo?(L=(0,t.jsx)("button",{"aria-label":"Drag to reorder",className:"flex size-5 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 active:cursor-grabbing group-hover:opacity-100",type:"button",...es,...eo,children:A}),G[60]=es,G[61]=eo,G[62]=L):L=G[62],G[63]===Symbol.for("react.memo_cache_sentinel")?(T=e=>H(e.target.value),G[63]=T):T=G[63],G[64]!==ep||G[65]!==Y?(D=(0,t.jsx)("input",{className:"-mx-1 truncate rounded bg-transparent px-1 py-0.5 font-medium text-foreground text-sm outline-none placeholder:text-muted-foreground/60 focus:bg-background focus:ring-1 focus:ring-ring",onBlur:ep,onChange:T,onKeyDown:w,placeholder:"Title",value:Y}),G[64]=ep,G[65]=Y,G[66]=D):D=G[66],G[67]===Symbol.for("react.memo_cache_sentinel")?(B=e=>X(e.target.value),G[67]=B):B=G[67],G[68]!==eh||G[69]!==Z?(M=(0,t.jsx)("input",{className:"-mx-1 truncate rounded bg-transparent px-1 py-0.5 text-muted-foreground text-xs outline-none placeholder:text-muted-foreground/60 focus:bg-background focus:text-foreground focus:ring-1 focus:ring-ring",inputMode:"url",onBlur:eh,onChange:B,onKeyDown:w,placeholder:"https://â¦",spellCheck:!1,value:Z}),G[68]=eh,G[69]=Z,G[70]=M):M=G[70],G[71]===Symbol.for("react.memo_cache_sentinel")?(P=e=>et(e.target.value),G[71]=P):P=G[71],G[72]!==eg||G[73]!==ee?(E=(0,t.jsx)("input",{className:"-mx-1 truncate rounded bg-transparent px-1 py-0.5 text-muted-foreground text-xs outline-none placeholder:text-muted-foreground/60 focus:bg-background focus:text-foreground focus:ring-1 focus:ring-ring",onBlur:eg,onChange:P,onKeyDown:w,placeholder:"Subtitle (optional)",value:ee}),G[72]=eg,G[73]=ee,G[74]=E):E=G[74],G[75]!==D||G[76]!==M||G[77]!==E?(z=(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[D,M,E]}),G[75]=D,G[76]=M,G[77]=E,G[78]=z):z=G[78],G[79]===Symbol.for("react.memo_cache_sentinel")?(U=(0,t.jsx)(f.Trash2,{className:"size-3.5"}),G[79]=U):U=G[79],G[80]!==R?(O=(0,t.jsx)("button",{"aria-label":"Remove link",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100",onClick:R,title:"Remove",type:"button",children:U}),G[80]=R,G[81]=O):O=G[81],G[82]!==ej||G[83]!==el||G[84]!==em||G[85]!==I||G[86]!==L||G[87]!==z||G[88]!==O?(F=(0,t.jsxs)("div",{className:I,ref:el,style:em,children:[L,ej,z,O]}),G[82]=ej,G[83]=el,G[84]=em,G[85]=I,G[86]=L,G[87]=z,G[88]=O,G[89]=F):F=G[89],F}function w(e){"Enter"===e.key?e.currentTarget.blur():"Escape"===e.key&&e.currentTarget.blur()}var A=e.i(21079);function L(e){let r,s,o,c,d,u,m,p,h,g,x,f=(0,a.c)(32),{isLoading:v,onOpenChange:j,onSubmit:b,open:y,triggerAriaLabel:C,triggerChildren:S,triggerClassName:_}=e,[N,k]=(0,l.useState)("");f[0]!==b||f[1]!==N?(r=async e=>{e.preventDefault(),N.trim()&&(await b(N),k(""))},f[0]=b,f[1]=N,f[2]=r):r=f[2];let I=r;f[3]!==j?(s=e=>{"Escape"===e.key&&(k(""),j(!1))},f[3]=j,f[4]=s):s=f[4];let w=s;return f[5]!==j?(o=e=>{e||k(""),j(e)},f[5]=j,f[6]=o):o=f[6],f[7]!==_?(c=(0,n.cn)(_),f[7]=_,f[8]=c):c=f[8],f[9]!==c||f[10]!==C||f[11]!==S?(d=(0,t.jsx)(i.PopoverTrigger,{"aria-label":C,className:c,children:S}),f[9]=c,f[10]=C,f[11]=S,f[12]=d):d=f[12],f[13]===Symbol.for("react.memo_cache_sentinel")?(u=e=>k(e.target.value),f[13]=u):u=f[13],f[14]!==w||f[15]!==v||f[16]!==N?(m=(0,t.jsx)(A.Input,{className:"h-8 flex-1",disabled:v,inputMode:"url",onChange:u,onKeyDown:w,placeholder:"Paste link URL",value:N}),f[14]=w,f[15]=v,f[16]=N,f[17]=m):m=f[17],f[18]!==v||f[19]!==N?(p=v||!N.trim(),f[18]=v,f[19]=N,f[20]=p):p=f[20],f[21]!==p?(h=(0,t.jsx)("button",{className:"flex h-8 shrink-0 items-center justify-center rounded-md bg-foreground px-3 font-medium text-background text-xs disabled:opacity-50",disabled:p,type:"submit",children:"Add"}),f[21]=p,f[22]=h):h=f[22],f[23]!==I||f[24]!==m||f[25]!==h?(g=(0,t.jsx)(i.PopoverContent,{align:"start",className:"w-72 p-2",sideOffset:8,children:(0,t.jsxs)("form",{className:"flex items-center gap-1.5",onSubmit:I,children:[m,h]})}),f[23]=I,f[24]=m,f[25]=h,f[26]=g):g=f[26],f[27]!==y||f[28]!==g||f[29]!==o||f[30]!==d?(x=(0,t.jsxs)(i.Popover,{onOpenChange:o,open:y,children:[d,g]}),f[27]=y,f[28]=g,f[29]=o,f[30]=d,f[31]=x):x=f[31],x}function T(e){let n,i,r,s,m,p,h,g,x,f,v,j=(0,a.c)(43),{edit:b,isEditable:y,items:C,onDeleteImage:S,onTouchImage:_,onUploadImage:N,uploadedImages:k}=e,[w,A]=(0,l.useState)(!1);j[0]!==b?(n=async e=>{await b.addLink(e)&&A(!1)},j[0]=b,j[1]=n):n=j[1];let T=n;j[2]===Symbol.for("react.memo_cache_sentinel")?(i={activationConstraint:{distance:u.POINTER_SENSOR_DISTANCE}},j[2]=i):i=j[2],j[3]===Symbol.for("react.memo_cache_sentinel")?(r={activationConstraint:{delay:200,tolerance:5}},j[3]=r):r=j[3],j[4]===Symbol.for("react.memo_cache_sentinel")?(s={coordinateGetter:d.sortableKeyboardCoordinates},j[4]=s):s=j[4];let M=(0,c.useSensors)((0,c.useSensor)(u.SmartPointerSensor,i),(0,c.useSensor)(c.TouchSensor,r),(0,c.useSensor)(c.Ke
1yboardSensor,s));j[5]!==b||j[6]!==C?(m=e=>{let{active:t,over:a}=e;if(!a||t.id===a.id)return;let n=C.findIndex(e=>e.id===t.id),i=C.findIndex(e=>e.id===a.id);if(-1===n||-1===i)return;let r=C.slice(),[s]=r.splice(n,1);s&&(r.splice(i,0,s),b.reorderLinks(r.map(B)))},j[5]=b,j[6]=C,j[7]=m):m=j[7];let P=m;if(j[8]!==b||j[9]!==y||j[10]!==C||j[11]!==S||j[12]!==_||j[13]!==N||j[14]!==k){let e;j[16]!==b||j[17]!==y||j[18]!==S||j[19]!==_||j[20]!==N||j[21]!==k?(e=e=>(0,t.jsx)(I,{isEditable:y,item:e,onDeleteImage:S,onRemove:()=>b.removeLink(e.id),onUpdate:t=>b.updateLink(e.id,t),onTouchImage:_,onUploadImage:N,uploadedImages:k},e.id),j[16]=b,j[17]=y,j[18]=S,j[19]=_,j[20]=N,j[21]=k,j[22]=e):e=j[22],p=C.map(e),j[8]=b,j[9]=y,j[10]=C,j[11]=S,j[12]=_,j[13]=N,j[14]=k,j[15]=p}else p=j[15];let E=p;return j[23]!==y||j[24]!==C.length?(h=0===C.length&&(0,t.jsx)("p",{className:"px-3 py-6 text-center text-muted-foreground text-sm",children:y?"Add your first link below.":"No links yet."}),j[23]=y,j[24]=C.length,j[25]=h):h=j[25],j[26]!==P||j[27]!==y||j[28]!==C||j[29]!==E||j[30]!==M?(g=y?(0,t.jsx)(c.DndContext,{collisionDetection:c.closestCenter,onDragEnd:P,sensors:M,children:(0,t.jsx)(d.SortableContext,{items:C.map(D),strategy:d.verticalListSortingStrategy,children:E})}):E,j[26]=P,j[27]=y,j[28]=C,j[29]=E,j[30]=M,j[31]=g):g=j[31],j[32]!==h||j[33]!==g?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-0.5 overflow-y-auto p-1.5",children:[h,g]}),j[32]=h,j[33]=g,j[34]=x):x=j[34],j[35]!==b.isAdding||j[36]!==T||j[37]!==w||j[38]!==y?(f=y&&(0,t.jsx)("div",{className:"flex items-center justify-between border-t bg-muted/30 px-2 py-1.5",children:(0,t.jsx)(L,{isLoading:b.isAdding,onOpenChange:A,onSubmit:T,open:w,triggerAriaLabel:"Add link",triggerChildren:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Plus,{className:"size-3.5"}),"Add link"]}),triggerClassName:"inline-flex items-center gap-1.5 rounded-md px-2 py-1.5 font-medium text-foreground text-xs transition-colors hover:bg-muted"})}),j[35]=b.isAdding,j[36]=T,j[37]=w,j[38]=y,j[39]=f):f=j[39],j[40]!==f||j[41]!==x?(v=(0,t.jsxs)("div",{className:"flex max-h-[60vh] flex-col overflow-hidden rounded-xl border bg-popover shadow-lg backdrop-blur-xl",children:[x,f]}),j[40]=f,j[41]=x,j[42]=v):v=j[42],v}function D(e){return e.id}function B(e){return e.id}function M(e){let i,r,s,o,l=(0,a.c)(25),{isEditable:c,item:d,onDeleteImage:u,onTouchImage:m,onIconChange:h,onUploadImage:g,uploadedImages:f}=e;l[0]!==d?(i=N(d),l[0]=d,l[1]=i):i=l[1];let{faviconIconValue:v,autoFaviconUrl:b,FallbackIcon:y}=i,C=d.title||d.url;l[2]!==y||l[3]!==b||l[4]!==v||l[5]!==C?(r=(0,t.jsx)(P,{autoFaviconUrl:b,FallbackIcon:y,faviconIconValue:v,title:C}),l[2]=y,l[3]=b,l[4]=v,l[5]=C,l[6]=r):r=l[6];let S=r;if(c&&h){let e,a,n,i=v?`Change icon for ${d.title||d.url}`:`Choose icon for ${d.title||d.url}`,r=f??j.EMPTY_UPLOADED_IMAGES,s=v?`Change icon for ${d.title||d.url}`:`Choose icon for ${d.title||d.url}`;return l[7]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-black/40 opacity-0 transition-opacity group-hover/tile:opacity-100",children:(0,t.jsx)(x.ImagePlus,{className:"size-3.5 text-white"})}),l[7]=e):e=l[7],l[8]!==s||l[9]!==S?(a=(0,t.jsxs)("div",{"aria-hidden":!0,className:"group/tile relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-background transition-all hover:border-foreground
1/30 hover:shadow-sm",title:s,children:[S,e]}),l[8]=s,l[9]=S,l[10]=a):a=l[10],l[11]!==v||l[12]!==u||l[13]!==h||l[14]!==m||l[15]!==g||l[16]!==i||l[17]!==r||l[18]!==a?(n=(0,t.jsx)(p.IconPicker,{ariaLabel:i,mode:"icon",onChange:h,onDeleteImage:u,onTouchImage:m,onUploadImage:g,uploadedImages:r,value:v,children:a}),l[11]=v,l[12]=u,l[13]=h,l[14]=m,l[15]=g,l[16]=i,l[17]=r,l[18]=a,l[19]=n):n=l[19],n}let _=d.title||d.url;return l[20]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.cn)("group/tile relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border/70 bg-background transition-all hover:border-foreground/30 hover:shadow-sm","no-underline"),l[20]=s):s=l[20],l[21]!==d.url||l[22]!==_||l[23]!==S?(o=(0,t.jsx)("a",{"aria-label":_,className:s,href:d.url,rel:"noopener noreferrer",target:"_blank",children:S}),l[21]=d.url,l[22]=_,l[23]=S,l[24]=o):o=l[24],o}function P(e){let n,i=(0,a.c)(5),{autoFaviconUrl:r,FallbackIcon:s,faviconIconValue:o,title:l}=e,c=s??j.iconComponents.website;return i[0]!==r||i[1]!==o||i[2]!==c||i[3]!==l?(n=(0,t.jsx)(v.LinkFaviconDisplay,{autoFaviconUrl:r,avatarUrl:void 0,channelAvatarUrl:void 0,className:"size-3.5 text-foreground",FallbackIcon:c,faviconIconValue:o,isSpotifyArtist:!1,isYouTubeChannel:!1,linkTitle:l,spotifyAvatarUrl:void 0}),i[0]=r,i[1]=o,i[2]=c,i[3]=l,i[4]=n):n=i[4],n}e.s(["LinkBar",0,function(e){let c,d,u,m,p,h,g,x,f=(0,a.c)(44),{backendFetchMetadata:v,isEditable:j,links:b,onDeleteImage:S,onTouchImage:_,onLinksChange:N,onUploadImage:k,uploadedImages:I}=e;f[0]!==b?(c=b??[],f[0]=b,f[1]=c):c=f[1];let w=c,[A,D]=(0,l.useState)(!1),[B,P]=(0,l.useState)(!1);f[2]!==v||f[3]!==w||f[4]!==N?(d={backendFetchMetadata:v,items:w,onLinksChange:N},f[2]=v,f[3]=w,f[4]=N,f[5]=d):d=f[5];let E=function({backendFetchMetadata:e,items:t,onLinksChange:a}){let[n,i]=(0,l.useState)(!1),r=(0,l.useCallback)(async n=>{let r=n.trim();if(!(r&&a))return null;let s=(0,C.normalizeUrl)(r),o=(0,y.detectLinkIcon)(s),l={id:`lb_${Math.random().toString(36).slice(2,10)}`,url:s,title:(0,C.extractWebsiteName)(s)??s,icon:o};if(a([...t,l]),!e)return l;i(!0);try{let n=await e(s),i={...l,title:n.title?.trim()||l.title,description:n.description?.trim()||void 0,faviconUrl:n.faviconUrl||void 0};return a([...t,i]),i}catch{return l}finally{i(!1)}},[e,t,a]),s=(0,l.useCallback)((e,n)=>{a&&a(t.map(t=>t.id===e?{...t,...n}:t))},[t,a]);return{addLink:r,isAdding:n,removeLink:(0,l.useCallback)(e=>{a&&a(t.filter(t=>t.id!==e))},[t,a]),reorderLinks:(0,l.useCallback)(e=>{if(!a)return;let n=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e){let e=n.get(t);e&&i.push(e)}for(let a of t)e.includes(a.id)||i.push(a);a(i)},[t,a]),updateLink:s}}(d);f[6]!==E?(u=async e=>{await E.addLink(e)&&P(!1)},f[6]=E,f[7]=u):u=f[7];let z=u;if(!j&&0===w.length)return null;let U=w.length>0;if(f[8]!==E.isAdding||f[9]!==z||f[10]!==B||f[11]!==j?(m=j&&(0,t.jsx)(L,{isLoading:E.isAdding,onOpenChange:P,onSubmit:z,open:B,triggerAriaLabel:"Add link",triggerChildren:(0,t.jsx)(o.Plus,{className:"size-3.5",strokeWidth:2}),triggerClassName:"flex size-8 shrink-0 items-center justify-center rounded-lg border border-border/70 border-dashed text-muted-foreground transition-colors hover:border-foreground
1/40 hover:text-foreground"}),f[8]=E.isAdding,f[9]=z,f[10]=B,f[11]=j,f[12]=m):m=f[12],f[13]!==E||f[14]!==j||f[15]!==w||f[16]!==S||f[17]!==_||f[18]!==k||f[19]!==I){let e;f[21]!==E||f[22]!==j||f[23]!==S||f[24]!==_||f[25]!==k||f[26]!==I?(e=e=>(0,t.jsx)(M,{isEditable:j,item:e,onDeleteImage:S,onIconChange:t=>E.updateLink(e.id,{iconData:t}),onTouchImage:_,onUploadImage:k,uploadedImages:I},e.id),f[21]=E,f[22]=j,f[23]=S,f[24]=_,f[25]=k,f[26]=I,f[27]=e):e=f[27],p=w.map(e),f[13]=E,f[14]=j,f[15]=w,f[16]=S,f[17]=_,f[18]=k,f[19]=I,f[20]=p}else p=f[20];return f[28]!==p?(h=(0,t.jsx)("div",{className:"no-scrollbar -mx-1.5 flex min-w-0 items-center gap-1 overflow-x-auto overflow-y-hidden scroll-smooth px-1.5",children:p}),f[28]=p,f[29]=h):h=f[29],f[30]!==E||f[31]!==j||f[32]!==A||f[33]!==w||f[34]!==S||f[35]!==_||f[36]!==k||f[37]!==U||f[38]!==I?(g=U&&(0,t.jsxs)(i.Popover,{onOpenChange:D,open:A,children:[(0,t.jsxs)(i.PopoverTrigger,{"aria-label":A?"Collapse links":"Expand links",className:"relative flex size-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[(0,t.jsx)(r.Maximize2,{className:(0,n.cn)("absolute size-3.5 transition-all duration-300",A?"scale-75 opacity-0":"scale-100 opacity-100"),strokeWidth:2}),(0,t.jsx)(s.Minimize2,{className:(0,n.cn)("absolute size-3.5 transition-all duration-300",A?"scale-100 opacity-100":"scale-75 opacity-0"),strokeWidth:2})]}),(0,t.jsx)(i.PopoverContent,{align:"end",className:"w-[min(22rem,calc(100vw-2rem))] p-0",sideOffset:6,variant:"bare",children:(0,t.jsx)(T,{edit:E,isEditable:j,items:w,onDeleteImage:S,onTouchImage:_,onUploadImage:k,uploadedImages:I})})]}),f[30]=E,f[31]=j,f[32]=A,f[33]=w,f[34]=S,f[35]=_,f[36]=k,f[37]=U,f[38]=I,f[39]=g):g=f[39],f[40]!==m||f[41]!==h||f[42]!==g?(x=(0,t.jsxs)("nav",{"aria-label":"Quick links",className:"mt-3 mb-1 flex w-full max-w-md items-center @5xl:justify-start justify-center gap-1.5",children:[m,h,g]}),f[40]=m,f[41]=h,f[42]=g,f[43]=x):x=f[43],x}],556831)},238157,e=>{"use strict";var t=e.i(931718),a=e.i(729386);e.i(116233);var n=e.i(694541),i=e.i(341965),r=e.i(699597),s=e.i(867506),o=e.i(843161),l=e.i(459333),c=e.i(485954);e.s(["CompanyPicker",0,function({companies:e,value:a,onChange:d,onCreate:u,placeholder:m="Select company...",disabled:p=!1}){let[h,g]=(0,c.useState)(!1),[x,f]=(0,c.useState)(""),[v,j]=(0,c.useState)(!1),b=e.find(e=>e._id===a),y=x.trim(),C=e.some(e=>e.name.trim().toLowerCase()===y.toLowerCase()),S=!!u&&y.length>0&&!C,_=async()=>{if(u&&!v){j(!0);try{let e=await u(y);e&&(d(e),g(!1),f(""))}finally{j(!1)}}};return(0,t.jsxs)(i.Popover,{onOpenChange:g,open:h,children:[(0,t.jsxs)(i.PopoverTrigger,{className:"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",disabled:p,children:[(0,t.jsx)("span",{className:"truncate",children:b?.name??m}),(0,t.jsx)(o.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),(0,t.jsx)(i.PopoverContent,{align:"start",className:"w-[300px] p-0",children:(0,t.jsxs)(n.Command,{children:[(0,t.jsx)(n.CommandInput,{onValueChange:f,placeholder:"Search companies...",value:x}),(0,t.jsxs)(n.CommandList,{children:[!S&&(0,t.jsx)(n.CommandEmpty,{children:"No companies found."}),(0,t.jsxs)(n.CommandGroup,{children:[a&&(0,t.jsxs)(n.CommandItem,{onSelect:()=>{d(void 0),g(!1)},children:[(0,t.jsx)(s.Check,{className:"mr-2 h-4 w-4 opacity-0"}),(0,t.jsx)(r.Text,{as:"span",variant:"bodyMuted",children:"Clear selection"})]}),e.map(e=>(0,t.jsxs)(n.CommandItem,{onSelect:()=>{d(e._id),g(!1)},value:e.name,children:[(0,t.jsx)(s.Check,{className:`mr-2 h-4 w-4 ${a===e._id?"opacity-100":"opacity-0"}`}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{children:e.name}),e.industry&&(0,t.jsx)(r.Text,{as:"span",variant:"caption",children:e.industry})]})]},e._id))]}),S&&(0,t.jsx)(n.CommandGroup,{children:(0,t.jsxs)(n.CommandItem,{disabled:v,onSelect:_,value:`__create__ ${y}`,children:[(0,t.jsx)(l.Plus,{className:"mr-2 h-4 w-4"}),(0,t.jsxs)("span",{className:"truncate",children:["Create â",y,"â"]}
1)]})})]})]})})]})},"ContactPicker",0,function(e){let l,d,u,m,p,h,g,x,f,v,j=(0,a.c)(30),{contacts:b,value:y,onChange:C,placeholder:S,disabled:_}=e,N=void 0!==_&&_,[k,I]=(0,c.useState)(!1);if(j[0]!==b||j[1]!==y){let e;j[3]!==y?(e=e=>e._id===y,j[3]=y,j[4]=e):e=j[4],l=b.find(e),j[0]=b,j[1]=y,j[2]=l}else l=j[2];let w=l,A=w?.name??(void 0===S?"Select contact...":S);if(j[5]!==A?(d=(0,t.jsx)("span",{className:"truncate",children:A}),j[5]=A,j[6]=d):d=j[6],j[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(o.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"}),j[7]=u):u=j[7],j[8]!==N||j[9]!==d?(m=(0,t.jsxs)(i.PopoverTrigger,{className:"flex h-9 w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",disabled:N,children:[d,u]}),j[8]=N,j[9]=d,j[10]=m):m=j[10],j[11]===Symbol.for("react.memo_cache_sentinel")?(p=(0,t.jsx)(n.CommandInput,{placeholder:"Search contacts..."}),j[11]=p):p=j[11],j[12]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(n.CommandEmpty,{children:"No contacts found."}),j[12]=h):h=j[12],j[13]!==C||j[14]!==y?(g=y&&(0,t.jsxs)(n.CommandItem,{onSelect:()=>{C(void 0),I(!1)},children:[(0,t.jsx)(s.Check,{className:"mr-2 h-4 w-4 opacity-0"}),(0,t.jsx)(r.Text,{as:"span",variant:"bodyMuted",children:"Clear selection"})]}),j[13]=C,j[14]=y,j[15]=g):g=j[15],j[16]!==b||j[17]!==C||j[18]!==y){let e;j[20]!==C||j[21]!==y?(e=e=>(0,t.jsxs)(n.CommandItem,{onSelect:()=>{C(e._id),I(!1)},value:e.name,children:[(0,t.jsx)(s.Check,{className:`mr-2 h-4 w-4 ${y===e._id?"opacity-100":"opacity-0"}`}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{children:e.name}),e.email&&(0,t.jsx)(r.Text,{as:"span",variant:"caption",children:e.email})]})]},e._id),j[20]=C,j[21]=y,j[22]=e):e=j[22],x=b.map(e),j[16]=b,j[17]=C,j[18]=y,j[19]=x}else x=j[19];return j[23]!==g||j[24]!==x?(f=(0,t.jsx)(i.PopoverContent,{align:"start",className:"w-[300px] p-0",children:(0,t.jsxs)(n.Command,{children:[p,(0,t.jsxs)(n.CommandList,{children:[h,(0,t.jsxs)(n.CommandGroup,{children:[g,x]})]})]})}),j[23]=g,j[24]=x,j[25]=f):f=j[25],j[26]!==k||j[27]!==f||j[28]!==m?(v=(0,t.jsxs)(i.Popover,{onOpenChange:I,open:k,children:[m,f]}),j[26]=k,j[27]=f,j[28]=m,j[29]=v):v=j[29],v}])},406681,493797,e=>{"use strict";var t=e.i(729386),a=e.i(283164);e.i(857266);var n=e.i(246257),i=e.i(220023);e.s(["useCampaign",0,function(e){let r,s,o=(0,t.c)(6),{gate:l}=(0,i.useGuestGate)();o[0]!==e||o[1]!==l?(r=e?l({campaignId:e}):"skip",o[0]=e,o[1]=l,o[2]=r):r=o[2];let c=(0,n.useQuery)(a.api.crm.campaigns.queries.getCampaign,r),d=c??null,u=null!==e&&void 0===c;return o[3]!==d||o[4]!==u?(s={detail:d,isLoading:u},o[3]=d,o[4]=u,o[5]=s):s=o[5],s},"useCampaignActions",0,function(){let e,i=(0,t.c)(13),r=(0,n.useMutation)(a.api.crm.campaigns.mutations.createCampaign),s=(0,n.useMutation)(a.api.crm.campaigns.mutations.finalizeCampaign),o=(0,n.useMutation)(a.api.crm.campaigns.mutations.pauseCampaign),l=(0,n.useMutation)(a.api.crm.campaigns.mutations.reopenCampaignPrep),c=(0,n.useMutation)(a.api.crm.campaigns.trash.restoreCampaign),d=(0,n.useMutation)(a.api.crm.campaigns.mutations.resumeCampaign),u=(0,n.useMutation)(a.api.crm.campaigns.mutations.sendCampaign),m=(0,n.useMutation)(a.api.crm.campaigns.mutations.setCampaignArchived),p=(0,n.useMutation)(a.api.crm.campaigns.mutations.setCampaignPinned),h=(0,n.useMutation)(a.api.crm.campaigns.mutations.stopCampaign),g=(0,n.useMutation)(a.api.crm.campaigns.trash.trashCampaign),x=(0,n.useMutation)(a.api.crm.campaigns.mutations.updateCampaign);return i[0]!==r||i[1]!==s||i[2]!==g||i[3]!==x||i[4]!==o||i[5]!==l||i[6]!==c||i[7]!==d||i[8]!==u||i[9]!==m||i[10]!==p||i[11]!==h?(e={create:r,finalize:s,pause:o,reopen:l,restore:c,resume:d,send:u,setArchived:m,setPinned:p,stop:h,trash:g,update:x},i[0]=r,i[1]=s,i[2]=g,i[3]=x,i[4]=o,i[5]=l,i[6]=c,i[7]=d,i[8]=u,i[9]=m,i[10]=p,i[11]=h,i[12]=e):e=i[12],e},"useCampaignMessageAssist",0,function(){return(0,n.useAction)(a.api.crm.campaigns.assist.suggestCampaignMessage)},"useCampaignMessagePreview",0,function(e,i){let r,s,o=(0,t.c)(6);o[0]!==e||o[1]!==i?(r={campaignId:e,contactId:i},o[0]=e,o[1]=i,o[2]=r):r=o[2];let l=(0,n.useQuery)(a.api.crm.campaigns.queries.getCampaignMessagePreview,r),c=void 0===l,d=l??null;return o[3]!==c||o[4]!==d?(s={isLoading:c,preview:d},o[3]=c,o[4]=d,o[5]=s):s=o[5],s},"useCampaignPrep",0,function(e){let i,r,s=(0,t.c)(5);s[0]!==e?(i={campaignId:e},s[0]=e,s[1]=i):i=s[1];let o=(0,n.useQuery)(a.api.crm.campaigns.queries.getCampaignPrep,i),l=void 0===o,c=o??null;return s[2]!==l||s[3]!==c?(r={isLoading:l,prep:c},s[2]=l,s[3]=c,s[4]=r):r=s[4],r},"useCampaignRecipientCount",0,function(e){let i,r,s=(0,t.c)(5);s[0]!==e?(i={campaignId:e},s[0]=e,s[1]=i):i=s[1];let o=(0,n.useQuery)(a.api.crm.campaigns.queries.getCampaignRecipientCount,i),l=o??0,c=void 0===o;return s[2]!==l||s[3]!==c?(r={count:l,isLoading:c},s[2]=l,s[3]=c,s[4]=r):r=s[4],r}
1,"useCampaignSendReadiness",0,function(e){let i,r,s=(0,t.c)(5);s[0]!==e?(i={campaignId:e},s[0]=e,s[1]=i):i=s[1];let o=(0,n.useQuery)(a.api.crm.campaigns.queries.getCampaignSendReadiness,i),l=void 0===o,c=o??null;return s[2]!==l||s[3]!==c?(r={isLoading:l,readiness:c},s[2]=l,s[3]=c,s[4]=r):r=s[4],r},"useCampaignSends",0,function(e){let i,r,s,o=(0,t.c)(7);o[0]!==e?(i={campaignId:e},o[0]=e,o[1]=i):i=o[1];let l=(0,n.useQuery)(a.api.crm.campaigns.overview_queries.listCampaignSends,i),c=void 0===l;return o[2]!==l?(r=l??[],o[2]=l,o[3]=r):r=o[3],o[4]!==c||o[5]!==r?(s={isLoading:c,sends:r},o[4]=c,o[5]=r,o[6]=s):s=o[6],s},"useCampaignSimulation",0,function(e,i){let r,s,o=(0,t.c)(6);o[0]!==e||o[1]!==i?(r=i?{campaignId:e}:"skip",o[0]=e,o[1]=i,o[2]=r):r=o[2];let l=(0,n.useQuery)(a.api.crm.campaigns.queries.simulateCampaign,r),c=i&&void 0===l,d=l??null;return o[3]!==c||o[4]!==d?(s={isLoading:c,simulation:d},o[3]=c,o[4]=d,o[5]=s):s=o[5],s},"useCampaigns",0,function(e){let r,s,o,l=(0,t.c)(8),{gate:c}=(0,i.useGuestGate)();l[0]!==c||l[1]!==e?.includeArchived?(r=c(e?.includeArchived?{includeArchived:!0}:{}),l[0]=c,l[1]=e?.includeArchived,l[2]=r):r=l[2];let d=(0,n.useQuery)(a.api.crm.campaigns.queries.listCampaigns,r);l[3]!==d?(s=d??[],l[3]=d,l[4]=s):s=l[4];let u=void 0===d;return l[5]!==s||l[6]!==u?(o={campaigns:s,isLoading:u},l[5]=s,l[6]=u,l[7]=o):o=l[7],o},"useCampaignsOverview",0,function(){let e,r,s=(0,t.c)(5),{gate:o}=(0,i.useGuestGate)();s[0]!==o?(e=o({}),s[0]=o,s[1]=e):e=s[1];let l=(0,n.useQuery)(a.api.crm.campaigns.overview_queries.getCampaignsOverview,e),c=void 0===l,d=l??null;return s[2]!==c||s[3]!==d?(r={isLoading:c,overview:d},s[2]=c,s[3]=d,s[4]=r):r=s[4],r},"useTrashedCampaigns",0,function(){let e,r,s,o=(0,t.c)(7),{gate:l}=(0,i.useGuestGate)();o[0]!==l?(e=l({}),o[0]=l,o[1]=e):e=o[1];let c=(0,n.useQuery)(a.api.crm.campaigns.trash.listTrashedCampaigns,e);o[2]!==c?(r=c??[],o[2]=c,o[3]=r):r=o[3];let d=void 0===c;return o[4]!==r||o[5]!==d?(s={campaigns:r,isLoading:d},o[4]=r,o[5]=d,o[6]=s):s=o[6],s}],406681),e.s(["draftDefaults",0,function(){return{name:"Untitled campaign",audience:{kind:"contacts",contactIds:[]},content:{kind:"message",subject:"",body:""}}}],493797)},157590,e=>{"use strict";var t=e.i(931718),a=e.i(729386);e.i(116233);var n=e.i(25873),i=e.i(235893),r=e.i(66414),s=e.i(485954),o=e.i(283164);e.i(857266);var l=e.i(246257),c=e.i(913939);function d(e){return e.contactId}e.s(["OverrideConsentButton",0,function(e){let u,m,p,h,g,x,f,v,j,b,y,C,S=(0,a.c)(29),{grants:_,label:N}=e,k=void 0===N?"Override: mark sendable":N,{override:I,pending:w}=function(){let e=(0,l.useMutation)(o.api.crm.contacts.consent_grants.overrideSendable),[t,a]=(0,s.use
1State)(!1);return{override:async function(t){if(0!==t.length){a(!0);try{let a=await e({grants:t});if(0===a.granted)return void c.toast.warning(a.skippedSuppressed>0?"Nothing marked sendable â those contacts opted out and can't be overridden.":"Nothing to override.");let n=a.skippedSuppressed>0?` \xb7 ${a.skippedSuppressed} skipped (opted out)`:"";c.toast.success(`Marked ${a.granted} sendable.${n}`)}catch(e){c.toast.error(e instanceof Error?e.message:"Couldn't apply the override.")}finally{a(!1)}}},pending:t}}(),[A,L]=(0,s.useState)(!1);S[0]!==_?(u=new Set(_.map(d)),S[0]=_,S[1]=u):u=S[1];let T=u.size,D=T>1;S[2]!==_||S[3]!==I?(m=async function(){await I(_),L(!1)},S[2]=_,S[3]=I,S[4]=m):m=S[4];let B=m,M=w||0===_.length;S[5]!==M?(p=(0,t.jsx)(i.Button,{disabled:M,size:"sm",variant:"secondary"}),S[5]=M,S[6]=p):p=S[6],S[7]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(r.ShieldCheck,{className:"size-4"}),S[7]=h):h=S[7],S[8]!==k||S[9]!==p?(g=(0,t.jsxs)(n.AlertDialogTrigger,{render:p,children:[h,k]}),S[8]=k,S[9]=p,S[10]=g):g=S[10];let P=D?`Mark ${T} contacts sendable?`:"Mark this contact sendable?";S[11]!==P?(x=(0,t.jsx)(n.AlertDialogTitle,{children:P}),S[11]=P,S[12]=x):x=S[12];let E=D?"these drafts":"this draft";return S[13]!==E?(f=(0,t.jsxs)(n.AlertDialogDescription,{children:["This records a consent entry under your name â basis âmanual owner overrideâ â so ",E," can send through the normal pipeline. It's audit-logged. Contacts who opted out are never overridden, and your daily send limit still applies."]}),S[13]=E,S[14]=f):f=S[14],S[15]!==f||S[16]!==x?(v=(0,t.jsxs)(n.AlertDialogHeader,{children:[x,f]}),S[15]=f,S[16]=x,S[17]=v):v=S[17],S[18]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(n.AlertDialogCancel,{children:"Cancel"}),S[18]=j):j=S[18],S[19]!==B||S[20]!==w?(b=(0,t.jsxs)(n.AlertDialogFooter,{children:[j,(0,t.jsx)(n.AlertDialogAction,{disabled:w,onClick:B,children:"Override"})]}),S[19]=B,S[20]=w,S[21]=b):b=S[21],S[22]!==v||S[23]!==b?(y=(0,t.jsxs)(n.AlertDialogContent,{children:[v,b]}),S[22]=v,S[23]=b,S[24]=y):y=S[24],S[25]!==A||S[26]!==y||S[27]!==g?(C=(0,t.jsxs)(n.AlertDialog,{onOpenChange:L,open:A,children:[g,y]}),S[25]=A,S[26]=y,S[27]=g,S[28]=C):C=S[28],C}],157590)},605170,e=>{"use strict";var t=e.i(159197);e.s(["formatCampaignDay",0,function(e){return(0,t.formatDate)(e,{variant:"day"})},"formatContactDateTime",0,function(e){return(0,t.formatDateTime)(e)},"formatTouchDate",0,function(e){return(0,t.formatDate)(e)},"formatUtcSendDate",0,function(e){return(0,t.formatDate)(e,{timeZone:"UTC"})}])},422322,677406,388825,e=>{"use strict";var t=e.i(729386),a=e.i(283164);e.i(857266);var n=e.i(246257),i=e.i(220023),r=e.i(485954),s=e.i(366589),o=e.i(868280);let l=o.z.object({id:o.z.string().min(1),name:o.z.string(),email:o.z.string(),phone:o.z.string(),company:o.z.string(),notes:o.z.string(),createdAt:o.z.number().int().nonnegative(),updatedAt:o.z.number().int().nonnegative(),sortOrder:o.z.number()}),c=o.z.array(l);function d(e,t,a){return{id:e,name:a.name,email:a.email??"",phone:a.phone??"",company:a.company??"",notes:a.notes??"",createdAt:t,updatedAt:t,sortOrder:t}}function u(e){let t=c.safeParse(e);return t.success?t.data:[]}function m(e){let t=e.trim();return t.length>0?t:void 0}e.s(["createLocalContact",0,d,"parseLocalContacts",0,u,"stagedContactsToImportArgs",0,function(e){if(!e||0===e.length)return null;let t=[...e].sort((e,t)=>e.sortOrder-t.sortOrder),a=[];for(let e of t){let t=e.name.trim();0!==t.length&&a.push({name:t,email:m(e.email),phone:m(e.phone),company:m(e.company),notes:m(e.notes)})}return a.length>0?{contacts:a}:null}],677406);let p="contacts";function h(){return(0,s.loadVisitorKv)(p,u)}function g(e){return(0,s.saveVisitorKv)(p,e)}e.s(["clearLocalContacts",0,function(){return(0,s.clearVisitorKv)(p)},"loadLocalContacts",0,h,"saveLocalContacts",0,g],388825);let x=[],f=x,v=!1,j=!1,b=new Set;function y(){for(let e of b)e()}function C(e){return b.add(e),v||j||(j=!0,h().then(e=>{v=!0,j=!1,f=f.length>0?f:e,y()}).catch(e=>{console.warn("Local contacts could not be loaded",e),v=!0,j=!1})),()=>{b.delete(e)}}function S(){return f}function _(){return x}function N(e){g(f=e(f)),y()}function k(){return(0,r.useSyncExternalStore)(C,S,_)}var I=e.i(697979);function w(e){let t=e?.trim()??"";return t.length>0?t:void 0}function A(e){return{_id:e.id,_creationTime:e.createdAt,name:e.name,email:w(e.email),phone:w(e.phone),company:w(e.company),notes:w(e.notes),tags:[],userId:"",teamId:void 0,isArchived:!1,createdAt:e.createdAt,updatedAt:e.updatedAt}}e.s(["useContact",0,function(e){let r,s,o,l=(0,t.c)(11),{isGuest:c}=(0,i.useGuestGate)(),d=k();l[0]!==e||l[1]!==c?(r=!c&&e?{contactId:e}:"skip",l[0]=e,l[1]=c,l[2]=r):r=l[2];let u=(0,n.useQuery)(a.api.crm.contacts.queries.getById,r);l[3]!==e||l[4]!==d?(s=function(e,t){if(!t)return null;let a=e.find(e=>e.id===t);return a?A(a):null}(d,e),l[3]=e,l[4]=d,l[5]=s):s=l[5];let m=s;if(c){let e;return l[6]!==m?(e={contact:m,isLoading:!1}
1,l[6]=m,l[7]=e):e=l[7],e}let p=void 0===u;return l[8]!==u||l[9]!==p?(o={contact:u,isLoading:p},l[8]=u,l[9]=p,l[10]=o):o=l[10],o},"useContactBookCount",0,function(e){let r,s=(0,t.c)(3),{gate:o}=(0,i.useGuestGate)();return s[0]!==o||s[1]!==e?(r=o({teamId:e}),s[0]=o,s[1]=e,s[2]=r):r=s[2],(0,n.useQuery)(a.api.crm.contacts.queries.getBookCount,r)??null},"useContacts",0,function(e){let s,o,l,c,u,m,p,h,g,x,f,v,j,b=(0,t.c)(25),{gate:y,isGuest:C}=(0,i.useGuestGate)(),S=(g=k(),x=(0,r.useMemo)(()=>{let t=[...g].sort((e,t)=>e.sortOrder-t.sortOrder);return e?.includeArchived===!1&&(t=t.filter(()=>!0)),e?.search&&(t=t.filter(t=>{let a;return 0===(a=(e.search??"").trim().toLowerCase()).length||[t.name,t.email,t.phone,t.company,t.notes].join(" ").toLowerCase().includes(a)})),t.map(A)},[g,e?.includeArchived,e?.search]),f=(0,r.useCallback)(e=>{let t=e.name.trim();if(0===t.length)return Promise.resolve(null);let a=Date.now(),n=crypto.randomUUID(),i={name:t,email:e.email,phone:e.phone,company:e.company,notes:e.notes};return N(e=>{let t=e.reduce((e,t)=>Math.max(e,t.sortOrder),-1);return[...e,{...d(n,a,i),sortOrder:t+1}]}),(0,I.notifyGuestCreate)(),Promise.resolve(A({id:n,name:t,email:i.email??"",phone:i.phone??"",company:i.company??"",notes:i.notes??"",createdAt:a,updatedAt:a,sortOrder:a}))},[]),v=(0,r.useCallback)(e=>(N(t=>t.map(t=>{if(t.id!==e.contactId)return t;let a=e.name?.trim();return{...t,name:a&&a.length>0?a:t.name,email:e.email??t.email,phone:e.phone??t.phone,company:e.company??t.company,notes:e.notes??t.notes,updatedAt:Date.now()}})),Promise.resolve({success:!0})),[]),j=(0,r.useCallback)(e=>(N(t=>t.filter(t=>t.id!==e.contactId)),Promise.resolve({success:!0})),[]),{contacts:x,isLoading:!1,createContact:f,updateContact:v,removeContact:j,bulkArchive:(0,r.useCallback)(e=>Promise.resolve({archived:0}),[]),bulkAddTag:(0,r.useCallback)(e=>Promise.resolve({updated:0}),[])}),_=e?.teamId,w=e?.search,L=e?.includeArchived;b[0]!==y||b[1]!==_||b[2]!==w||b[3]!==L?(s=y({teamId:_,search:w,includeArchived:L}),b[0]=y,b[1]=_,b[2]=w,b[3]=L,b[4]=s):s=b[4];let T=(0,n.useQuery)(a.api.crm.contacts.queries.getAll,s),D=(0,n.useMutation)(a.api.crm.contacts.mutations.create),B=(0,n.useMutation)(a.api.crm.contacts.mutations.update),M=(0,n.useMutation)(a.api.crm.contacts.mutations.remove),P=(0,n.useMutation)(a.api.crm.contacts.mutations.bulkArchive),E=(0,n.useMutation)(a.api.crm.contacts.mutations.bulkAddTag);if(C)return S;b[5]!==T?(o=T??[],b[5]=T,b[6]=o):o=b[6];let z=void 0===T;return b[7]!==D?(l=e=>D(e),b[7]=D,b[8]=l):l=b[8],b[9]!==B?(c=e=>B(e),b[9]=B,b[10]=c):c=b[10],b[11]!==M?(u=e=>M(e),b[11]=M,b[12]=u):u=b[12],b[13]!==P?(m=e=>P(e),b[13]=P,b[14]=m):m=b[14],b[15]!==E?(p=e=>E(e),b[15]=E,b[16]=p):p=b[16],b[17]!==p||b[18]!==o||b[19]!==z||b[20]!==l||b[21]!==c||b[22]!==u||b[23]!==m?(h={contacts:o,isLoading:z,createContact:l,updateContact:c,removeContact:u,bulkArchive:m,bulkAddTag:p},b[17]=p,b[18]=o,b[19]=z,b[20]=l,b[21]=c,b[22]=u,b[23]=m,b[24]=h):h=b[24],h}],422322)},589477,e=>{"use strict";var t=e.i(729386),a=e.i(283164);e.i(857266);var n=e.i(246257),i=e.i(220023);e.s(["useCompanies",0,function(e){let{gate:t}=(0,i.useGuestGate)(),r=(0,n.useQuery)(a.api.crm.companies.queries.getAll,t({teamId:e?.teamId,search:e?.search,includeArchived:e?.includeArchived,parentCompanyId:e?.parentCompanyId}))??[];return{companies:r,isLoading:void 0===r,createCompany:(0,n.useMutation)(a.api.crm.companies.mutations.create),updateCompany:(0,n.useMutation)(a.api.crm.companies.mutations.update),removeCompany:(0,n.useMutation)(a.api.crm.companies.mutations.remove)}},"useCompaniesWithStats",0,function(e){let r,s,o,l=(0,t.c)(9),{gate:c}=(0,i.useGuestGate)(),d=e?.teamId,u=e?.includeArchived;l[0]!==c||l[1]!==d||l[2]!==u?(r=c({teamId:d,includeArchived:u}),l[0]=c,l[1]=d,l[2]=u,l[3]=r):r=l[3];let m=(0,n.useQuery)(a.api.crm.companies.queries.getAllWithStats,r);l[4]!==m?(s=m??[],l[4]=m,l[5]=s):s=l[5];let p=void 0===m;return l[6]!==s||l[7]!==p?(o={companies:s,isLoading:p},l[6]=s,l[7]=p,l[8]=o):o=l[8],o},"useCompany",0,function(e){let r,s,o=(0,t.c)(6),{gate:l}=(0,i.useGuestGate)();o[0]!==e||o[1]!==l?(r=e?l({companyId:e}):"skip",o[0]=e,o[1]=l,o[2]=r):r=o[2];let c=(0,n.useQuery)(a.api.crm.companies.queries.getById,r),d=void 0===c;return o[3]!==c||o[4]!==d?(s={company:c,isLoading:d},o[3]=c,o[4]=d,o[5]=s):s=o[5],s},"useCompanyProvenance",0,function(e){let r,s,o=(0,t.c)(6),{gate:l}=(0,i.useGuestGate)();o[0]!==e||o[1]!==l?(r=e?l({companyId:e}):"skip",o[0]=e,o[1]=l,o[2]=r):r=o[2];let c=(0,n.useQuery)(a.api.crm.companies.queries.getProvenance,r),d=void 0===c;return o[3]!==c||o[4]!==d?(s={provenance:c,isLoading:d},o[3]=c,o[4]=d,o[5]=s):s=o[5],s},"useCreateCompanyForPicker",0,function(e){let i,r=(0,t.c)(3),s=(0,n.useMutation)(a.api.crm.companies.mutations.create);return r[0]!==s||r[1]!==e?(i=async t=>{let a=t.trim();if(!a)return;let n=await s({name:a,teamId:e});return n?._id},r[0]=s,r[1]=e,r[2]=i):i=r[2],i},"useSyncCompaniesFromContacts",0,function(){return(0,n.useMutation)(a.api.crm.companies.mutations.syncFromContacts)}])},690204,47070,e=>{"use strict";var t=e.i(931718),a=e.i(729386);e.i(116233);var n=e.i(323490);let i=[{stage:"lead",label:"Lead",color:"gray",terminal:!1},{stage:"contacted",label:"Contacted",color:"blue",terminal:!1},{stage:"in_conversation",label:"In conversation",color:"amber",terminal:!1},{stage:"customer",label:"Customer",color:"green",terminal:!1},{stage:"friend",label:"Friend",color:"violet",terminal:!1},{stage:"suppressed",label:"Suppressed",color:"red",terminal:!0}],r=i.filter(e=>!e.terminal);function s(e){let t=i.find(t=>t.stage===e);if(!t)throw Error(`Unknown pipeline stage: ${e}`);return t}e.s(["LIFECYCLE_STAGE_COLUMNS",0,r,"STAGE_COLUMNS",0,i,"effectiveStage",0,function(e){return e.consent?.suppression?"suppressed":e.lifecycleStage??"lead"},"isLifecycleStage",0,function(e){return"suppressed"!==e},"stageMeta",0,s],47070),e.s(["StageBadge",0,function(e){let i,r,o=(0,a.c)(5),{stage:l}=e;o[0]!==l?(i=s(l),o[0]=l,o[1]=i):i=o[1];let c=i;return o[2]!==c.color||o[3]!==c.label?(r=(0,t.jsx)(n.Badge,{size:"sm",variant:c.color,children:c.label}),o[2]=c.color,o[3]=c.label,o[4]=r):r=o[4],r}],690204)},11150,e=>{"use strict";let t={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "};function a(e){return(!e.includes("&")?e:e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z]+);/gi,(e,a)=>{let n=a.toLowerCase(),i=t[n];if(void 0!==i)return i;if(n.startsWith("#")){let e="x"===n[1],t=Number.parseInt(n.slice(e?2:1),e?16:10);if(t>0&&t<=1114111)return String.fromCodePoint(t)}return e})).trim().toLowerCase()}let n="Client";e.s(["withClientMembership",0,function(e){var t;let i,r=new Map;for(let t of e){let e=t.trim();e&&r.set(a(e),e)}return t=[...r.values()],i=a(n),t.some(e=>a(e)===i)||r.set(a(n),n),[...r.values()]}],11150)},462285,e=>{"use strict";let t=["January","February","March","April","May","June","July","August","September","October","November","December"],a=[31,29,31,30,31,30,31,31,30,31,30,31];function n(e){return String(e).padStart(2,"0")}function i(e,t,i){return e<1||e>12||t<1||t>
1(a[e-1]??0)||2===e&&29===t&&void 0!==i&&(i%4!=0||i%100==0)&&i%400!=0?null:void 0===i?`--${n(e)}-${n(t)}`:`${i}-${n(e)}-${n(t)}`}let r=/^([A-Za-z]+)\s+(\d{1,2})(?:,?\s+(\d{4}))?$/,s=/^(\d{1,2})\s+([A-Za-z]+)(?:,?\s+(\d{4}))?$/,o=/^(\d{1,2})\/(\d{1,2})(?:\/(\d{4}))?$/,l=/^(?:(\d{4})-|--)(\d{2})-(\d{2})$/;e.s(["formatBirthday",0,function(e){if(!e)return"";let a=e.match(l);if(!a)return e;let[,n,i,r]=a,s=t[Number(i)-1];if(!s)return e;let o=`${s} ${Number(r)}`;return n?`${o}, ${Number(n)}`:o},"parseBirthdayInput",0,function(e){let a=e.trim();return""===a?"":function(e){let t=e.match(l);if(!t)return null;let[,a,n,r]=t;return i(Number(n),Number(r),a?Number(a):void 0)}(a)??function(e){let t=e.match(o);if(!t)return null;let[,a,n,r]=t;return i(Number(a),Number(n),r?Number(r):void 0)}(a)??function(e){let a,n,o=e.match(r),l=e.match(s),c=o??l;if(!c)return null;let[,d,u,m]=c,p=(a=(o?String(d):String(u)).toLowerCase(),n=t.findIndex(e=>e.toLowerCase().startsWith(a)),a.length>=3&&n>=0?n+1:0),h=Number(o?u:d);return 0===p?null:i(p,h,m?Number(m):void 0)}(a)}])},564205,170458,208252,549822,903337,456926,806235,254709,e=>{"use strict";var t=e.i(931718),a=e.i(235893),n=e.i(21079),i=e.i(433992),r=e.i(87352),s=e.i(214877),o=e.i(485954);e.i(553512);var l=e.i(108450),c=e.i(120381),d=e.i(384022),u=e.i(589477),m=e.i(238157),p=e.i(729386),h=e.i(913939),g=e.i(406681),x=e.i(493797),f=e.i(323490),v=e.i(694541),j=e.i(341965),b=e.i(459333),y=e.i(535352);function C(e){let n,i,r,s,l,c,d,u,m,h,g,x,C,S,_,N,k,I,w=(0,p.c)(63),{campaigns:A,value:L,onToggle:T,onCreate:D,disabled:B}=e,M=void 0!==B&&B,[P,E]=(0,o.useState)(!1),[z,U]=(0,o.useState)("");w[0]!==L?(n=new Set(L),w[0]=L,w[1]=n):n=w[1];let O=n;if(w[2]!==A||w[3]!==M||w[4]!==D||w[5]!==T||w[6]!==z||w[7]!==O){let e,a,n,o;w[13]!==O?(e=e=>
1O.has(e._id),w[13]=O,w[14]=e):e=w[14];let d=A.filter(e);if(w[15]!==A||w[16]!==z){let e;a=(c=z.trim()).length>0&&(e=c.trim().toLowerCase(),!A.some(t=>t.name.toLowerCase()===e)),w[15]=A,w[16]=z,w[17]=a,w[18]=c}else a=w[17],c=w[18];r=a,w[19]!==D||w[20]!==c?(n=()=>{D(c),U("")},w[19]=D,w[20]=c,w[21]=n):n=w[21],i=n,s="flex flex-wrap items-center gap-1.5",w[22]!==M||w[23]!==T?(o=e=>(0,t.jsxs)(f.Badge,{variant:"secondary",children:[e.name,!M&&(0,t.jsx)("button",{"aria-label":`Remove ${e.name}`,className:"-mr-0.5 ml-0.5 rounded-full opacity-70 hover:opacity-100",onClick:()=>T(e._id),type:"button",children:(0,t.jsx)(y.X,{className:"size-3"})})]},e._id),w[22]=M,w[23]=T,w[24]=o):o=w[24],l=d.map(o),w[2]=A,w[3]=M,w[4]=D,w[5]=T,w[6]=z,w[7]=O,w[8]=i,w[9]=r,w[10]=s,w[11]=l,w[12]=c}else i=w[8],r=w[9],s=w[10],l=w[11],c=w[12];w[25]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(b.Plus,{}),w[25]=d):d=w[25];let F=0===L.length?"Tag to a campaign":"Add";if(w[26]!==F?(u=(0,t.jsxs)(a.Button,{size:"xs",variant:"dashed",children:[d,F]}),w[26]=F,w[27]=u):u=w[27],w[28]!==M||w[29]!==u?(m=(0,t.jsx)(j.PopoverTrigger,{disabled:M,render:u}),w[28]=M,w[29]=u,w[30]=m):m=w[30],w[31]!==z?(h=(0,t.jsx)(v.CommandInput,{onValueChange:U,placeholder:"Search or create...",value:z}),w[31]=z,w[32]=h):h=w[32],w[33]!==r?(g=!r&&(0,t.jsx)(v.CommandEmpty,{children:"No campaigns yet."}),w[33]=r,w[34]=g):g=w[34],w[35]!==A||w[36]!==T||w[37]!==O){let e;w[39]!==T||w[40]!==O?(e=e=>
1(0,t.jsx)(v.CommandItem,{"data-checked":O.has(e._id),onSelect:()=>T(e._id),value:e.name,children:e.name},e._id),w[39]=T,w[40]=O,w[41]=e):e=w[41],x=A.map(e),w[35]=A,w[36]=T,w[37]=O,w[38]=x}else x=w[38];return w[42]!==x?(C=(0,t.jsx)(v.CommandGroup,{children:x}),w[42]=x,w[43]=C):C=w[43],w[44]!==g||w[45]!==C?(S=(0,t.jsxs)(v.CommandList,{children:[g,C]}),w[44]=g,w[45]=C,w[46]=S):S=w[46],w[47]!==i||w[48]!==r||w[49]!==c?(_=r&&(0,t.jsx)("div",{className:"border-border border-t p-1",children:(0,t.jsxs)(a.Button,{className:"w-full justify-start",onClick:i,size:"sm",variant:"ghost",children:[(0,t.jsx)(b.Plus,{}),"Create â",c,"â"]})}),w[47]=i,w[48]=r,w[49]=c,w[50]=_):_=w[50],w[51]!==S||w[52]!==_||w[53]!==h?(N=(0,t.jsx)(j.PopoverContent,{align:"start",className:"w-64 p-0",children:(0,t.jsxs)(v.Command,{children:[h,S,_]})}),w[51]=S,w[52]=_,w[53]=h,w[54]=N):N=w[54],w[55]!==P||w[56]!==N||w[57]!==m?(k=(0,t.jsxs)(j.Popover,{onOpenChange:E,open:P,children:[m,N]}),w[55]=P,w[56]=N,w[57]=m,w[58]=k):k=w[58],w[59]!==k||w[60]!==s||w[61]!==l?(I=(0,t.jsxs)("div",{className:s,children:[l,k]}),w[59]=k,w[60]=s,w[61]=l,w[62]=I):I=w[62],I}function S(e){let a,n,r,s,o=(0,p.c)(12),{value:l,onToggle:c,disabled:d}=e,u=void 0!==d&&d,{campaigns:m}=(0,g.useCampaigns)(),{create:h}=(0,g.useCampaignActions)();o[0]!==h||o[1]!==c?(a=e=>{h({...(0,x.draftDefaults)(),name:e}).then(e=>c(e._id)).catch(N)},o[0]=h,o[1]=c,o[2]=a):a=o[2];let f=a;return o[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(i.Label,{children:"Campaigns"}),o[3]=n):n=o[3],o[4]!==m?(r=m.map(_),o[4]=m,o[5]=r):r=o[5],o[6]!==u||o[7]!==f||o[8]!==c||o[9]!==r||o[10]!==l?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[n,(0,t.jsx)(C,{campaigns:r,disabled:u,onCreate:f,onToggle:c,value:l})]}),o[6]=u,o[7]=f,o[8]=c,o[9]=r,o[10]=l,o[11]=s):s=o[11],s}function _(e){return e.campaign}function N(e){h.toast.error(e instanceof Error?e.message:"Could not create campaign")}e.s(["ContactCampaignsField",0,S],170458),e.i(116233);var k=e.i(376942),I=e.i(283164);e.i(857266);var w=e.i(246257),A=e.i(220023);function L(e){let t,a,n,i=(0,p.c)(13),{gate:r}=(0,A.useGuestGate)();i[0]!==r||i[1]!==e?(t=r({teamId:e}),i[0]=r,i[1]=e,i[2]=t):t=i[2];let s=(0,w.useQuery)(I.api.crm.contact_labels.queries.list,t);i[3]!==s?(a=s??[],i[3]=s,i[4]=a):a=i[4];let o=void 0===s,l=(0,w.useMutation)(I.api.crm.contact_labels.mutations.create),c=(0,w.useMutation)(I.api.crm.contact_labels.mutations.update),d=(0,w.useMutation)(I.api.crm.contact_labels.mutations.remove),u=(0,w.useMutation)(I.api.crm.contact_labels.mutations.setLabels),m=(0,w.useMutation)(I.api.crm.contact_labels.mutations.seedDefaults);return i[5]!==a||i[6]!==o||i[7]!==l||i[8]!==c||i[9]!==d||i[10]!==u||i[11]!==m?(n={labels:a,isLoading:o,createLabel:l,updateLabel:c,removeLabel:d,setContactLabels:u,seedDefaultLabels:m},i[5]=a,i[6]=o,i[7]=l,i[8]=c,i[9]=d,i[10]=u,i[11]=m,i[12]=n):n=i[12],n}function T(e,t){h.toast.error(e instanceof Error?e.message:t)}function D(e){let a,n,r,s,l,c,d,u,m,h=(0,p.c)(30),{value:g,onChange:x,teamId:f}=e,{labels:v,isLoading:j,createLabel:b,updateLabel:y,removeLabel:C,seedDefaultLabels:S}=L(f),_=(0,o.useRef)(!1);h[0]!==j||h[1]!==v.length||h[2]!==S||h[3]!==f?(a=function(){j||_.current||v.length>0||(_.current=!0,S({teamId:f}).catch(z))},n=[j,v.length,S,f],h[0]=j,h[1]=v.length,h[2]=S,h[3]=f,h[4]=a,h[5]=n):(a=h[4],n=h[5]),(0,o.useEffect)(a,n),h[6]!==v?(r=v.map(E),h[6]=v,h[7]=r):r=h[7];let N=r;h[8]!==v||h[9]!==x?(s=e=>{x(v.filter(t=>e.includes(t._id)).map(P))},h[8]=v,h[9]=x,h[10]=s):s=h[10];let I=s;
1h[11]!==b||h[12]!==x||h[13]!==f||h[14]!==g?(l=async e=>{try{let t=await b({...e,teamId:f});x([...g,t._id])}catch(e){T(e,"Could not create label")}},h[11]=b,h[12]=x,h[13]=f,h[14]=g,h[15]=l):l=h[15];let w=l;h[16]!==v||h[17]!==y?(c=e=>{let t=v.find(t=>t._id===e.value);t&&y({labelId:t._id,name:e.name,color:e.color}).catch(M)},h[16]=v,h[17]=y,h[18]=c):c=h[18];let A=c;h[19]!==v||h[20]!==C?(d=e=>{let t=v.find(t=>t._id===e);t&&C({labelId:t._id}).catch(B)},h[19]=v,h[20]=C,h[21]=d):d=h[21];let D=d;return h[22]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(i.Label,{children:"Labels"}),h[22]=u):u=h[22],h[23]!==I||h[24]!==w||h[25]!==A||h[26]!==D||h[27]!==N||h[28]!==g?(m=(0,t.jsxs)("div",{className:"space-y-2",children:[u,(0,t.jsx)(k.MultiSelectChips,{onChange:I,onCreateOption:w,onEditOption:A,onRemoveOption:D,options:N,placeholder:"Add labels...",value:g})]}),h[23]=I,h[24]=w,h[25]=A,h[26]=D,h[27]=N,h[28]=g,h[29]=m):m=h[29],m}function B(e){return T(e,"Could not delete label")}function M(e){return T(e,"Could not save label")}function P(e){return e._id}function E(e){return{value:e._id,label:e.name,color:e.color}}function z(e){return T(e,"Could not add starter labels")}function U(e){return e.map(e=>({...e,id:crypto.randomUUID()}))}function O(e){let r,s,l,c,d,u,m,h,g,x,f,v=(0,p.c)(22),{onChange:j,properties:C}=e;v[0]!==C?(r=JSON.stringify(C),v[0]=C,v[1]=r):r=v[1];let S=r;v[2]!==C?(s=()=>U(C),v[2]=C,v[3]=s):s=v[3];let[_,N]=(0,o.useState)(s),[k,I]=(0,o.useState)(S);k!==S&&(I(S),N(U(C))),v[4]!==j||v[5]!==S?(l=e=>{let t=e.map(e=>({key:e.key.trim(),value:e.value.trim()})).filter(e=>e.key.length>0||e.value.length>0);JSON.stringify(t)!==S&&j(t)},v[4]=j,v[5]=S,v[6]=l):l=v[6];let w=l;v[7]===Symbol.for("react.memo_cache_sentinel")?(c=(e,t)=>{N(a=>a.map(a=>a.id===e?{...a,...t}:a))},v[7]=c):c=v[7];let A=c;v[8]!==w||v[9]!==_?(d=e=>{let t=_.filter(t=>t.id!==e);N(t),w(t)},v[8]=w,v[9]=_,v[10]=d):d=v[10];let L=d;return v[11]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(i.Label,{children:"Properties"}),v[11]=u):u=v[11],v[12]!==w||v[13]!==L||v[14]!==_?(m=_.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(n.Input,{onBlur:()=>w(_),onChange:t=>A(e.id,{key:t.target.value}),placeholder:"Name",value:e.key}),(0,t.jsx)(n.Input,{onBlur:()=>w(_),onChange:t=>A(e.id,{value:t.target.value}),placeholder:"Value",value:e.value}),(0,t.jsx)(a.Button,{"aria-label":"Remove property",onClick:()=>L(e.id),size:"icon-sm",type:"button",variant:"ghost",children:(0,t.jsx)(y.X,{className:"size-3.5"})})]},e.id)),v[12]=w,v[13]=L,v[14]=_,v[15]=m):m=v[15],v[16]!==m?(h=(0,t.jsx)("div",{className:"space-y-2",children:m}),v[16]=m,v[17]=h):h=v[17],v[18]===Symbol.for("react.memo_cache_sentinel")?(g=()=>N(F),v[18]=g):g=v[18],v[19]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsxs)(a.Button,{onClick:g,size:"sm",type:"button",variant:"surface",children:[(0,t.jsx)(b.Plus,{className:"size-3.5"}),"Add property"]}),v[19]=x):x=v[19],v[20]!==h?(f=(0,t.jsxs)("div",{className:"space-y-2",children:[u,h,x]}),v[20]=h,v[21]=f):f=v[21],f}function F(e){return[...e,{id:crypto.randomUUID(),key:"",value:""}]}function G(e){let t=e.line1.trim();if(t)return{line1:t,line2:e.line2?.trim()||void 0,city:e.city?.trim()||void 0,region:e.region?.trim()||void 0,postalCode:e.postalCode?.trim()||void 0,country:e.country?.trim()||void 0}}e.s(["useContactLabels",0,L],208252),e.s(["ContactLabelsField",0,D],549822),e.s(["ContactPropertiesEditor",0,O],903337),e.s(["compactPostalAddress",0,G],456926);let $={line1:""};function q(e){let a,r,s,l,c,d,u,m,h,g,x,f,v,j,b,y,C,S=(0,p.c)(52),{actions:_,value:N}=e,[k,I]=(0,o.useState)(N??$),[w,A]=(0,o.useState)(N);w!==N&&(A(N),I(N??$)),S[0]!==_||S[1]!==k?(a=(e,t)=>{let a={...k,[e]:t};I(a),_.onChange?.(a)},S[0]=_,S[1]=k,S[2]=a):a=S[2];let L=a;S[3]!==_||S[4]!==k?(r=()=>_.onCommit?.(G(k)),S[3]=_,S[4]=k,S[5]=r):r=S[5];let T=r;S[6]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(i.Label,{children:"Postal address"}),S[6]=s):s=S[6],S[7]!==L?(l=e=>L("line1",e.target.value),S[7]=L,S[8]=l):l=S[8],S[9]!==T||S[10]!==k.line1||S[11]!==l?(c=(0,t.jsx)(n.Input,{onBlur:T,onCh
1ange:l,placeholder:"Street address",value:k.line1}),S[9]=T,S[10]=k.line1,S[11]=l,S[12]=c):c=S[12],S[13]!==L?(d=e=>L("line2",e.target.value),S[13]=L,S[14]=d):d=S[14];let D=k.line2??"";S[15]!==T||S[16]!==d||S[17]!==D?(u=(0,t.jsx)(n.Input,{onBlur:T,onChange:d,placeholder:"Apartment, suite, or unit",value:D}),S[15]=T,S[16]=d,S[17]=D,S[18]=u):u=S[18],S[19]!==L?(m=e=>L("city",e.target.value),S[19]=L,S[20]=m):m=S[20];let B=k.city??"";S[21]!==T||S[22]!==B||S[23]!==m?(h=(0,t.jsx)(n.Input,{onBlur:T,onChange:m,placeholder:"City",value:B}),S[21]=T,S[22]=B,S[23]=m,S[24]=h):h=S[24],S[25]!==L?(g=e=>L("region",e.target.value),S[25]=L,S[26]=g):g=S[26];let M=k.region??"";S[27]!==T||S[28]!==g||S[29]!==M?(x=(0,t.jsx)(n.Input,{onBlur:T,onChange:g,placeholder:"State or region",value:M}),S[27]=T,S[28]=g,S[29]=M,S[30]=x):x=S[30],S[31]!==L?(f=e=>L("postalCode",e.target.value),S[31]=L,S[32]=f):f=S[32];let P=k.postalCode??"";S[33]!==T||S[34]!==f||S[35]!==P?(v=(0,t.jsx)(n.Input,{onBlur:T,onChange:f,placeholder:"Postal code",value:P}),S[33]=T,S[34]=f,S[35]=P,S[36]=v):v=S[36],S[37]!==L?(j=e=>L("country",e.target.value),S[37]=L,S[38]=j):j=S[38];let E=k.country??"";return S[39]!==T||S[40]!==j||S[41]!==E?(b=(0,t.jsx)(n.Input,{onBlur:T,onChange:j,placeholder:"Country",value:E}),S[39]=T,S[40]=j,S[41]=E,S[42]=b):b=S[42],S[43]!==h||S[44]!==x||S[45]!==v||S[46]!==b?(y=(0,t.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[h,x,v,b]}),S[43]=h,S[44]=x,S[45]=v,S[46]=b,S[47]=y):y=S[47],S[48]!==y||S[49]!==c||S[50]!==u?(C=(0,t.jsxs)("div",{className:"space-y-2",children:[s,c,u,y]}),S[48]=y,S[49]=c,S[50]=u,S[51]=C):C=S[51],C}e.s(["ContactPostalAddressFields",0,q],806235);let Q=[];e.s(["ContactForm",0,function({actions:e,companies:p=Q,entity:h}){let{contact:g,initialCompanyId:x,teamId:f}=h,v=h.noun??"Contact",j=!!g,b=(0,u.useCreateCompanyForPicker)(f),[y,C]=(0,o.useState)(!1),[_,N]=(0,o.useState)(()=>{var e;return e={companyId:x,teamId:f},{name:g?.name??"",email:g?.email??"",phone:g?.phone??"",postalAddress:g?.postalAddress??(g?.address?{line1:g.address}:{line1:""}),jobTitle:g?.jobTitle??"",birthday:g?.birthday??"",notes:g?.notes??"",tags:g?.tags??[],labelIds:g?.labelIds??[],properties:g?.properties??[],campaignIds:[],companyId:e?.companyId,teamId:e?.teamId}}),k=async t=>{if(t.preventDefault(),_.name.trim()){C(!0);try{await e.onSubmit(_),e.onBack()}finally{C(!1)}}},I=(e,t)=>{N(a=>({...a,[e]:t}))},w=j?g.name:`New ${v}`,A=j?`Update ${v.toLowerCase()} information`:void 0;return(0,t.jsxs)(l.AppLayout,{children:[(0,t.jsx)(c.AppTopBar,{standalone:!0,children:(0,t.jsxs)(c.AppTopBarLeading,{children:[(0,t.jsx)(c.AppTopBarBackButton,{onClick:e.onBack}),(0,t.jsx)(c.AppTopBarTitle,{subtitle:A,title:w})]})}),(0,t.jsx)(l.AppContent,{children:(0,t.jsxs)("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:k,children:[(0,t.jsx)(l.AppContentBody,{classNameViewport:"p-4",column:"sm",children:(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"name",children:"Name *"}),(0,t.jsx)(n.Input,{autoFocus:!0,id:"name",onChange:e=>I("name",e.target.value),placeholder:"John Doe",required:!0,value:_.name})]}),(0,t.jsx)(q,{actions:{onChange:e=>I("postalAddress",e)},value:_.postalAddress}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"email",children:"Email"}),(0,t.jsx)(n.Input,{id:"email",onChange:e=>I("email",e.target.value),placeholder:"[email protected]",type:"email",value:_.email})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"phone",children:"Phone"}),(0,t.jsx)(n.Input,{id:"phone",onChange:e=>I("phone",e.target.value),placeholder:"+1 (555) 123-4567",type:"tel",value:_.phone})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"jobTitle",children:"Job Title"}),(0,t.jsx)(n.Input,{id:"jobTitle",onChange:e=>I("jobTitle",e.target.value),placeholder:"Software Engineer",value:_.jobTitle})]}),(0,t.jsx)(r.Separator,{}),(0,t.jsx)(D,{onChange:e=>I("labelIds",e),teamId:f,value:_.labelIds}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{children:"Company"}),(0,t.jsx)(m.CompanyPicker,{companies:p,onChange:e=>I("companyId",e),onCreate:b,placeholder:"Select company...",value:_.companyId})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"birthday",children:"Birthday"}),(0,t.jsx)(n.Input,{id:"birthday",onChange:e=>I("birthday",e.target.value),placeholder:"July 29",value:_.birthday})]}),(0,t.jsx)(r.Separator,{}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{children:"Tags"}),(0,t.jsx)(d.TagInput,{onChange:e=>I("tags",e),placeholder:"Add tags...",tags:_.tags})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(i.Label,{htmlFor:"notes",children:"Notes"}),(0,t.jsx)(s.Textarea,{id:"notes",onChange:e=>I("notes",e.target.value),placeholder:"Additional notes...",rows:3,value:_.notes})]}),(0,t.jsx)(r.Separator,{}),(0,t.jsx)(S,{onToggle:e=>{N(t=>({...t,campaignIds:t.campaignIds.includes(e)?t.campaignIds.filter(t=>t!==e):[...t.campaignIds,e]}))},value:_.campaignIds}),(0,t.jsx)(r.Separator,{}),(0,t.jsx)(O,{onChange:e=>I("properties",e),properties:_.properties})]})}),(0,t.jsx)(r.Separator,{}),(0,t.jsx)(l.AppContentFooter,{className:"p-4 max-md:pb-[calc(var(--mobile-bottom-bar-height,4rem)+env(safe-area-inset-bottom,0px))]",children:(0,t.jsxs)("div",{className:"mx-auto flex w-full max-w-2xl gap-2",children:[(0,t.jsx)(a.Button,{className:"flex-1",disabled:y,onClick:e.onBack,type:"button",variant:"surface",children:"Cancel"}),(0,t.jsx)(a.Button,{className:"flex-1",disabled:y||!_.name.trim(),type:"submit",children:y?"Saving...":j?"Save Changes":`Create ${v}`})]})})]})})]})}],564205),e.s(["useContactStage",0,function(e){let t,a,n,i=(0,p.c)(9),{gate:r}=(0,A.useGuestGate)();i[0]!==e||i[1]!==r?(t=r({contactId:e}),i[0]=e,i[1]=r,i[2]=t):t=i[2];let s=(0,w.useQuery)(I.api.crm.contacts.stage.listStageTransitions,t),o=(0,w.useMutation)(I.api.crm.contacts.stage.setStage);i[3]!==s?(a=s??[],i[3]=s,i[4]=a):a=i[4];let l=void 0===s;return i[5]!==o||i[6]!==a||i[7]!==l?(n={transitions:a,isLoading:l,setStage:o},i[5]=o,i[6]=a,i[7]=l,i[8]=n):n=i[8],n}],254709)},451838,62789,184210,402229,e=>{"use strict";var t=e.i(931718),a=e.i(729386),n=e.i(699597),i=e.i(433992),r=e.i(708737),s=e.i(913939),o=e.i(254709),l=e.i(605170),c=e.i(690204),d=e.i(47070);let u={human:"Moved",suppression:"Suppressed",suppression_lifted:"Suppression lifted"};function m(e){let i,r,s,o,m,p,h,g,x=(0,a.c)(21),{transition:f}=e,v=f.reason?` \xb7 ${f.reason}`:"";x[0]!==f.toStage?(i=(0,t.jsx)(c.StageBadge,{stage:f.toStage}),x[0]=f.toStage,x[1]=i):i=x[1],x[2]!==f.fromStage?(r=(0,d.stageMeta)(f.fromStage),x[2]=f.fromStage,x[3]=r):r=x[3];let j=r.label;x[4]!==f.toStage?(s=(0,d.stageMeta)(f.toStage),x[4]=f.toStage,x[5]=s):s=x[5],x[6]!==r.label||x[7]!==s.label?(o=(0,t.jsxs)(n.Text,{as:"span",variant:"bodySmall",children:[j," â"," ",s.label]}),x[6]=r.label,x[7]=s.label,x[8]=o):o=x[8];let b=u[f.source];return x[9]!==f.at?(m=(0,l.formatContactDateTime)(f.at),x[9]=f.at,x[10]=m):m=x[10],x[11]!==v||x[12]!==b||x[13]!==m?(p=(0,t.jsxs)(n.Muted,{children:[b,v," · ",m]}
1),x[11]=v,x[12]=b,x[13]=m,x[14]=p):p=x[14],x[15]!==o||x[16]!==p?(h=(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[o,p]}),x[15]=o,x[16]=p,x[17]=h):h=x[17],x[18]!==i||x[19]!==h?(g=(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[i,h]}),x[18]=i,x[19]=h,x[20]=g):g=x[20],g}function p(e){let i,r,s=(0,a.c)(6),{transitions:o,isLoading:l}=e;if(l){let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex justify-center py-4"}),s[0]=e):e=s[0],e}if(0===o.length){let e;return s[1]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(n.Muted,{children:"No stage changes yet."}),s[1]=e):e=s[1],e}return s[2]!==o?(i=o.map(h),s[2]=o,s[3]=i):i=s[3],s[4]!==i?(r=(0,t.jsx)("div",{className:"space-y-2",children:i}),s[4]=i,s[5]=r):r=s[5],r}function h(e){return(0,t.jsx)(m,{transition:e},e._id)}function g(e){return(0,t.jsx)(r.SelectItem,{value:e.stage,children:e.label},e.stage)}function x(e){s.toast.error(e instanceof Error?e.message:"Could not move contact")}function f(e){return{label:e.label,value:e.stage}}e.s(["ContactStageSection",0,function(e){let s,l,u,m,h,v,j,b,y=(0,a.c)(18),{contact:C}=e;y[0]!==C?(s=(0,d.effectiveStage)(C),y[0]=C,y[1]=s):s=y[1];let S=s,{transitions:_,isLoading:N,setStage:k}=(0,o.useContactStage)(C._id);y[2]===Symbol.for("react.memo_cache_sentinel")?(l=d.LIFECYCLE_STAGE_COLUMNS.map(f),y[2]=l):l=y[2];let I=l;y[3]!==C._id||y[4]!==k||y[5]!==S?(u=e=>{if(!e)return;let t=d.STAGE_COLUMNS.find(t=>t.stage===e);if(!(t&&(0,d.isLifecycleStage)(t.stage))||t.stage===S)return;let a=t.stage;k({contactId:C._id,toStage:a}).catch(x)},y[3]=C._id,y[4]=k,y[5]=S,y[6]=u):u=y[6];let w=u;return y[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,t.jsx)(i.Label,{children:"Stage"}),y[7]=m):m=y[7],y[8]!==w||y[9]!==S?(h=(0,t.jsxs)("div",{className:"space-y-2",children:[m,"suppressed"===S?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(c.StageBadge,{stage:S}),(0,t.jsx)(n.Muted,{children:"Consent-driven · lift suppression to re-engage"})]}):(0,t.jsxs)(r.Select,{items:I,onValueChange:w,value:S,children:[(0,t.jsx)(r.SelectTrigger,{className:"w-full",children:(0,t.jsx)(r.SelectValue,{})}),(0,t.jsx)(r.SelectContent,{children:d.LIFECYCLE_STAGE_COLUMNS.map(g)})]})]}),y[8]=w,y[9]=S,y[10]=h):h=y[10],y[11]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)(i.Label,{children:"Stage history"}),y[11]=v):v=y[11],y[12]!==N||y[13]!==_?(j=(0,t.jsxs)("div",{className:"space-y-2",children:[v,(0,t.jsx)(p,{isLoading:N,transitions:_})]}),y[12]=N,y[13]=_,y[14]=j):j=y[14],y[15]!==h||y[16]!==j?(b=(0,t.jsxs)("div",{className:"space-y-3",children:[h,j]}),y[15]=h,y[16]=j,y[17]=b):b=y[17],b}],451838),e.i(339295);var v=e.i(625923),j=e.i(329268),b=e.i(729531),y=e.i(400810);e.s(["ContactAvatar",0,function(e){let n,i,r,s=(0,a.c)(8),{contact:o,onChange:l}=e;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={persistToLibrary:!1},s[0]=n):n=s[0];let{onUploadImage:c,onDeleteImage:d}=(0,b.useIconUpload)(n);return s[1]!==o.iconData?(i=(0,y.fromConvexIconData)(o.iconData),s[1]=o.iconData,s[2]=i):i=s[2],s[3]!==l||s[4]!==d||s[5]!==c||s[6]!==i?(r=(0,t.jsx)(v.IconPicker,{mode:"avatar",onChange:l,onDeleteImage:d,onUploadImage:c,placeholderIcon:j.User,skipUploadRecents:!0,triggerSize:56,value:i}),s[3]=l,s[4]=d,s[5]=c,s[6]=i,s[7]=r):r=s[7],r}],62789);var C=e.i(283164);e.i(857266);var S=e.i(246257),_=e.i(220023),N=e.i(170458);function k(e){return e.campaignId}function I(e){s.toast.error(e instanceof Error?e.message:"Could not update campaigns")}function w(e){return[e.campaignId,e]}e.s(["ContactCampaignsSection",0,function(e){let n,i,r,s,o=(0,a.c)(12),{contact:l}=e,{links:c,linkCampaign:d,unlinkCampaign:u}=function(e){let t,n,i,r=(0,a.c)(10),{gate:s}=(0,_.useGuestGate)();r[0]!==e||r[1]!==s?(t=s({contactId:e}),r[0]=e,r[1]=s,r[2]=t):t=r[2];let o=(0,S.useQuery)(C.api.crm.contact_campaign_links.queries.getByContact,t);r[3]!==o?(n=o??[],r[3]=o,r[4]=n):n=r[4];let l=void 0===o,c=(0,S.useMutation)(C.api.crm.contact_campaign_links.mutations.create),d=(0,S.useMutation)(C.api.crm.contact_campaign_links.mutations.remove);return r[5]!==n||r[6]!==l||r[7]!==c||r[8]!==d?(i={links:n,isLoading:l,linkCampaign:c,unlinkCampaign:d},r[5]=n,r[6]=l,r[7]=c,r[8]=d,r[9]=i):i=r[9],i}(l._id);o[0]!==c?(n=new Map(c.map(w)),o[0]=c,o[1]=n):n=o[1];let m=n;o[2]!==l._id||o[3]!==m||o[4]!==d||o[5]!==u?(i=e=>{let t=m.get(e);(t?u({linkId:t._id}):d({contactId:l._id,campaignId:e})).catch(I)},o[2]=l._id,o[3]=m,o[4]=d,o[5]=u,o[6]=i):i=o[6];let p=i;return o[7]!==c?(r=c.map(k),o[7]=c,o[8]=r):r=o[8],o[9]!==r||o[10]!==p?(s=(0,t.jsx)(N.ContactCampaignsField,{onToggle:p,value:r}),o[9]=r,o[10]=p,o[11]=s):s=o[11],s}],184210),e.i(116233);var A=e.i(323490),L=e.i(235893),T=e.i(76075),D=e.i(87352),B=e.i(483678),M=e.i(89364),P=e.i(485843);function E(e,t){return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e/100)}function z(e){let i,r,s,o,l,c=(0,a.c)(11),{detail:d}=e;if(!d.commerceAccount)return null;c[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(n.Text,{variant:"labelBold",children:"Commerce history"}),c[0]=i):i=c[0];let u=1===d.commerceAccount.orderCount?" order":" orders";return c[1]!==d.commerceAccount.orderCount||c[2]!==u?(r=(0,t.jsxs)("div",{children:[i,(0,t.jsxs)(n.Muted,{children:[d.commerceAccount.orderCount," settled",u]})]}),c[1]=d.commerceAccount.orderCount,c[2]=u,c[3]=r):r=c[3],c[4]!==d.commerceAccount.lifetimeByCurrency?(s=d.commerceAccount.lifetimeByCurrency.map(U),c[4]=d.commerceAccount.lifetimeByCurrency,c[5]=s):s=c[5],c[6]!==s?(o=(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:s}
1),c[6]=s,c[7]=o):o=c[7],c[8]!==r||c[9]!==o?(l=(0,t.jsx)(T.Card,{children:(0,t.jsx)(T.CardContent,{children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[r,o]})})}),c[8]=r,c[9]=o,c[10]=l):l=c[10],l}function U(e){return(0,t.jsxs)(A.Badge,{variant:"secondary",children:[E(e.minor,e.currency)," lifetime"]},e.currency)}function O(e){let i,r,s=(0,a.c)(8),{onOpenOrder:o,order:l}=e;if(!o){let e;return s[0]!==l.orderNumber?(e=(0,t.jsx)(n.Text,{className:"truncate",variant:"labelBold",children:l.orderNumber}),s[0]=l.orderNumber,s[1]=e):e=s[1],e}return s[2]!==o||s[3]!==l._id?(i=()=>o(l._id),s[2]=o,s[3]=l._id,s[4]=i):i=s[4],s[5]!==l.orderNumber||s[6]!==i?(r=(0,t.jsx)(L.Button,{className:"h-auto max-w-full truncate p-0",onClick:i,variant:"link",children:l.orderNumber}),s[5]=l.orderNumber,s[6]=i,s[7]=r):r=s[7],r}function F(e){let i,r,s,o=(0,a.c)(8),{detail:c,onOpenOrder:d}=e;if(0===c.orders.length)return null;if(o[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(n.H3,{variant:"panel",children:"Orders"}),o[0]=i):i=o[0],o[1]!==c.orders||o[2]!==d){let e;o[4]!==d?(e=e=>(0,t.jsx)(T.Card,{children:(0,t.jsx)(T.CardContent,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(M.Receipt,{}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)(O,{onOpenOrder:d,order:e}),(0,t.jsx)(n.Muted,{children:(0,l.formatTouchDate)(e.createdAt)})]}),(0,t.jsx)(n.Text,{variant:"labelBold",children:E(e.totalMinor,e.currency)}),(0,t.jsx)(A.Badge,{variant:"secondary",children:e.status})]})})},e._id),o[4]=d,o[5]=e):e=o[5],r=c.orders.map(e),o[1]=c.orders,o[2]=d,o[3]=r}else r=o[3];return o[6]!==r?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[i,r]}),o[6]=r,o[7]=s):s=o[7],s}function G(e){let i,r,s,o=(0,a.c)(5),{detail:l}=e;return 0===l.interactions.length?null:(o[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(n.H3,{variant:"panel",children:"Channel entries"}),o[0]=i):i=o[0],o[1]!==l.interactions?(r=l.interactions.map($),o[1]=l.interactions,o[2]=r):r=o[2],o[3]!==r?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[i,r]}),o[3]=r,o[4]=s):s=o[4],s)}function $(e){return(0,t.jsx)(T.Card,{children:(0,t.jsx)(T.CardContent,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(P.Workflow,{}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)(n.Text,{className:"truncate",variant:"labelBold",children:e.title}),(0,t.jsx)(n.Muted,{children:(0,l.formatTouchDate)(e.eventDate??e.createdAt)})]})]})})},e._id)}function q(e){let i,r,s,o=(0,a.c)(5),{detail:l}=e;return 0===l.paymentLinks.length?null:(o[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(n.H3,{variant:"panel",children:"Payment links"}),o[0]=i):i=o[0],o[1]!==l.paymentLinks?(r=l.paymentLinks.map(Q),o[1]=l.paymentLinks,o[2]=r):r=o[2],o[3]!==r?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[i,r]}),o[3]=r,o[4]=s):s=o[4],s)}function Q(e){return(0,t.jsx)(T.Card,{children:(0,t.jsx)(T.CardContent,{children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(B.FileText,{}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)(n.Text,{className:"truncate",variant:"labelBold",children:e.customerName??e.customerEmail}),(0,t.jsx)(n.Muted,{children:(0,l.formatTouchDate)(e.createdAt)})]}),(0,t.jsx)(n.Text,{variant:"labelBold",children:E(e.amountDueMinor,e.currency)}),(0,t.jsx)(A.Badge,{variant:"secondary",children:e.status})]})})},e._id)}e.s(["ContactCommerceHistory",0,function(e){let n,i,r,s,o,l,c,d=(0,a.c)(17),{contactId:u,onOpenOrder:m,teamId:p}=e;d[0]!==u||d[1]!==p?(n={clientId:u,teamId:p},d[0]=u,d[1]=p,d[2]=n):n=d[2];let h=(0,S.useQuery)(C.api.crm.clients.queries.getDetail,n);return h&&(h.commerceAccount||0!==h.orders.length||0!==h.paymentLinks.length||0!==h.interactions.length)?(d[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(D.Separator,{}),d[3]=i):i=d[3],d[4]!==h?(r=(0,t.jsx)(z,{detail:h}),d[4]=h,d[5]=r):r=d[5],d[6]!==h||d[7]!==m?(s=(0,t.jsx)(F,{detail:h,onOpenOrder:m}),d[6]=h,d[7]=m,d[8]=s):s=d[8],d[9]!==h?(o=(0,t.jsx)(q,{detail:h}),l=(0,t.jsx)(G,{detail:h}),d[9]=h,d[10]=o,d[11]=l):(o=d[10],l=d[11]),d[12]!==r||d[13]!==s||d[14]!==o||d[15]!==l?(c=(0,t.jsxs)(t.Fragment,{children:[i,(0,t.jsxs)("div",{className:"space-y-4",children:[r,s,o,l]})]}),d[12]=r,d[13]=s,d[14]=o,d[15]=l,d[16]=c):c=d[16],c):null}],402229)},861709,e=>{"use strict";var t=e.i(931718),a=e.i(729386),n=e.i(283164);e.i(857266);var i=e.i(246257),r=e.i(11150),s=e.i(467069),o=e.i(589477),l=e.i(422322),c=e.i(462285),d=e.i(564205),u=e.i(433992),m=e.i(87352),p=e.i(913939);e.i(553512);var h=e.i(108450),g=e.i(120381),x=e.i(220023),f=e.i(400810),v=e.i(36683),j=e.i(690204),b=e.i(47070),y=e.i(903337),C=e.i(451838),S=e.i(62789),_=e.i(184210),N=e.i(402229);e.i(116233);var k=e.i(323490),I=e.i(235893),w=e.i(699597),A=e.i(441266),L=e.i(867506),T=e.i(899409),D=e.i(367906),B=e.i(157590);let M="cold_outreach";function P(e){let n,i,r,s,o,l,c,d=(0,a.c)(19),{verification:m}=e,p="pending"===m.state?void 0:m.evidenceUrl;return(d[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(u.Label,{children:"Outreach verification"}),d[0]=n):n=d[0],d[1]!==m.state?(i="pending"===m.state&&(0,t.jsxs)(k.Badge,{variant:"outline",children:[(0,t.jsx)(D.Search,{className:"size-3"}),"Pending"]}),d[1]=m.state,d[2]=i):i=d[2],d[3]!==m.reason||d[4]!==m.state)?(r="failed"===m.state&&(0,t.jsxs)(k.Badge,{variant:"destructive",children:[(0,t.jsx)(A.Ban,{className:"size-3"}),m.reason.replaceAll("_"," ")]}),d[3]=m.reason,d[4]=m.state,d[5]=r):r=d[5],d[6]!==m.state?(s="consented"===m.state&&(0,t.jsxs)(k.Badge,{variant:"secondary",children:[(0,t.jsx)(L.Check,{className:"size-3"}),"Verified and consented"]}),d[6]=m.state,d[7]=s):s=d[7],d[8]!==m.confidence||d[9]!==m.state?(o="consented"===m.state&&(0,t.jsxs)(w.Muted,{as:"span",children:[Math.round(100*m.confidence),"% confidence"]}),d[8]=m.confidence,d[9]=m.state,d[10]=o):o=d[10],d[11]!==p?(l=p&&(0,t.jsxs)(I.Button,{onClick:()=>window.open(p,"_blank","noopener"),size:"sm",variant:"link",children:[(0,t.jsx)(T.ExternalLink,{className:"size-3"}),"View evidence"]}),d[11]=p,d[12]=l):l=d[12],d[13]!==i||d[14]!==r||d[15]!==s||d[16]!==o||d[17]!==l?(c=(0,t.jsxs)("div",{className:"space-y-2",children:[n,(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[i,r,s,o,l]})]}),d[13]=i,d[14]=r,d[15]=s,d[16]=o,d[17]=l,d[18]=c):c=d[18],c}function E(e){let r,s,o,l,c,d,m,p,h=(0,a.c)(20),{contact:g}=e,{gate:f}=(0,x.useGuestGate)();h[0]!==g._id||h[1]!==f?(r=f({contactId:g._id,action:M}),h[0]=g._id,h[1]=f,h[2]=r):r=h[2];let v=(0,i.useQuery)(n.api.crm.contacts.consent.allowed,r);if(void 0===v)return null;let j=g.consent?.suppression!=null,b=!(v.allowed||j);return h[3]!==g.outreachVerification?(s=g.outreachVerification&&(0,t.jsx)(P,{verification:g.outreachVerification}),h[3]=g.outreachVerification,h[4]=s):s=h[4],h[5]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(u.Label,{children:"Outreach consent"}),h[5]=o):o=h[5],h[6]!==v.allowed?(l=v.allowed?(0,t.jsxs)(k.Badge,{variant:"secondary",children:[(0,t.jsx)(L.Check,{className:"size-3"}),"Sendable"]}):(0,t.jsxs)(k.Badge,{variant:"destructive",children:[(0,t.jsx)(A.Ban,{className:"size-3"}),"Unsendable"]}),h[6]=v.allowed,h[7]=l):l=h[7],h[8]!==v.reason?(c=(0,t.jsx)(w.Muted,{as:"span",children:v.reason}),h[8]=v.reason,h[9]=c):c=h[9],h[10]!==g._id||h[11]!==b?(d=b&&(0,t.jsx)(B.OverrideConsentButton,{grants:[{contactId:g._id,scope:M}]}),h[10]=g._id,h[11]=b,h[12]=d):d=h[12],h[13]!==l||h[14]!==c||h[15]!==d?(m=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,c,d]}),h[13]=l,h[14]=c,h[15]=d,h[16]=m):m=h[16],h[17]!==s||h[18]!==m?(p=(0,t.jsxs)("div",{className:"space-y-4",children:[s,o,m]}),h[17]=s,h[18]=m,h[19]=p):p=h[19],p}var z=e.i(214877),U=e.i(485954),O=e.i(384022),F=e.i(238157),G=e.i(806235),$=e.i(21079);function q(e){let n,i,r,s,o,l=(0,a.c)(12),{onCommit:d,value:m}=e;l[0]!==m?(n=(0,c.formatBirthday)(m),l[0]=m,l[1]=n):n=l[1];let p=n,[h,g]=(0,U.useState)(p),[x,f]=(0,U.useState)(p);x!==p&&(f(p),g(p)),l[2]!==p||l[3]!==h||l[4]!==d||l[5]!==m?(i=()=>{let e=(0,c.parseBirthdayInput)(h);null===e||e===m||""===e&&""===m?g(p):d(e)},l[2]=p,l[3]=h,l[4]=d,l[5]=m,l[6]=i):i=l[6];let v=i;return l[7]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(u.Label,{children:"Birthday"}),l[7]=r):r=l[7],l[8]===Symbol.for("react.memo_cache_sentinel")?(s=e=>g(e.target.value),l[8]=s):s=l[8],l[9]!==v||l[10]!==h?(o=(0,t.jsxs)("div",{className:"space-y-2",children:[r,(0,t.jsx)($.Input,{onBlur:v,onChange:s,onKeyDown:Q,placeholder:"July 29",value:h})]}),l[9]=v,l[10]=h,l[11]=o):o=l[11],o}function Q(e){"Enter"===e.key&&e.currentTarget.blur()}function V(e){let n,i,r,s,o,l=(0,a.c)(15),{label:c,onCommit:d,placeholder:m,type:p,value:h}=e,g=void 0===p?"text":p,[x,f]=(0,U.useState)(h),[v,j]=(0,U.useState)(h);v!==h&&(j(h),f(h)),l[0]!==x||l[1]!==d||l[2]!==h?(n=()=>{let e=x.trim();e!==h&&d(e)},l[0]=x,l[1]=d,l[2]=h,l[3]=n):n=l[3];let b=n;return l[4]!==c?(i=(0,t.jsx)(u.Label,{children:c}),l[4]=c,l[5]=i):i=l[5],l[6]===Symbol.for("react.memo_cache_sentinel")?(r=e=>f(e.target.value),l[6]=r):r=l[6],l[7]!==b||l[8]!==x||l[9]!==m||l[10]!==g?(s=(0,t.jsx)($.Input,{onBlur:b,onChange:r,onKeyDown:R,placeholder:m,type:g,value:x}),l[7]=b,l[8]=x,l[9]=m,l[10]=g,l[11]=s):s=l[11],l[12]!==i||l[13]!==s?(o=(0,t.jsxs)("div",{className:"space-y-2",children:[i,s]}),l[12]=i,l[13]=s,l[14]=o):o=l[14],o}function R(e){"Enter"===e.key&&e.currentTarget.blur()}function K(e){let n,i,r,s,o=(0,a.c)(9),{value:l,onCommit:c}=e,[d,m]=(0,U.useState)(l),[p,h]=(0,U.useState)(l);return p!==l&&(h(l),m(l)),o[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(u.Label,{children:"Notes"}),o[0]=n):n=o[0],o[1]!==d||o[2]!==c||o[3]!==l?(i=()=>{d.trim()!==l&&c(d.trim())},o[1]=d,o[2]=c,o[3]=l,o[4]=i):i=o[4],o[5]===Symbol.for("react.memo_cache_sentinel")?(r=e=>m(e.target.value),o[5]=r):r=o[5],o[6]!==d||o[7]!==i?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[n,(0,t.jsx)(z.Textarea,{onBlur:i,onChange:r,placeholder:"Additional notes...",rows:3,value:d})]}),o[6]=d,o[7]=i,o[8]=s):s=o[8],s}function J(e){let n,i,r,s,o,l,c,d,u,m,p=(0,a.c)(28),{contact:h,onSave:g}=e;p[0]!==h.address||p[1]!==h.postalAddress?(n=h.postalAddress??(h.address?{line1:h.address}:void 0),p[0]=h.address,p[1]=h.postalAddress,p[2]=n):n=p[2];let x=n;p[3]!==g?(i=e=>g({email:e}),p[3]=g,p[4]=i):i=p[4];let f=h.email??"";p[5]!==i||p[6]!==f?(r=(0,t.jsx)(V,{label:"Email",onCommit:i,placeholder:"[email protected]",type:"email",value:f}),p[5]=i,p[6]=f,p[7]=r):r=p[7],p[8]!==g?(s={onCommit:e=>g(e?{postalAddress:e}:{clearPostalAddress:!0})},p[8]=g,p[9]=s):s=p[9],p[10]!==x||p[11]!==s?(o=(0,t.jsx)(G.ContactPostalAddressFields,{actions:s,value:x}),p[10]=x,p[11]=s,p[12]=o):o=p[12],p[13]!==g?(l=e=>g({phone:e}),p[13]=g,p[14]=l):l=p[14];let v=h.phone??"";p[15]!==l||p[16]!==v?(c=(0,t.jsx)(V,{label:"Phone",onCommit:l,placeholder:"+1 (555) 123-4567",type:"tel",value:v}),p[15]=l,p[16]=v,p[17]=c):c=p[17],p[18]!==g?(d=e=>g({jobTitle:e}),p[18]=g,p[19]=d):d=p[19];let j=h.jobTitle??"";return p[20]!==d||p[21]!==j?(u=(0,t.jsx)(V,{label:"Job Title",onCommit:d,placeholder:"Software Engineer",value:j}),p[20]=d,p[21]=j,p[22]=u):u=p[22],p[23]!==u||p[24]!==r||p[25]!==o||p[26]!==c?(m=(0,t.jsxs)(t.Fragment,{children:[r,o,c,u]}),p[23]=u,p[24]=r,p[25]=o,p[26]=c,p[27]=m):m=p[27],m}function W(e){let n,i=(0,a.c)(6),{actions:r,contact:s,data:l}=e,c=(0,o.useCreateCompanyForPicker)(s.teamId);return i[0]!==r||i[1]!==s.company||i[2]!==c||i[3]!==l.companies||i[4]!==l.companyId?(n=l.companies.length>0?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(u.Label,{children:"Company"}),(0,t.jsx)(F.CompanyPicker,{companies:l.companies,onChange:r.onCompanyChange,onCreate:c,placeholder:"Select company...",value:l.companyId})]}):(0,t.jsx)(V,{label:"Company",onCommit:e=>r.onSave({company:e}),placeholder:"Analytical Engines",value:s.company??""}),i[0]=r,i[1]=s.company,i[2]=c,i[3]=l.companies,i[4]=l.companyId,i[5]=n):n=i[5],n}function Y(e){let n,i,r,s,o,l,c,d=(0,a.c)(18),{contact:m,onSave:p,onTagsChange:h}=e;d[0]!==p?(n=e=>p({birthday:e}),d[0]=p,d[1]=n):n=d[1];let g=m.birthday??"";d[2]!==n||d[3]!==g?(i=(0,t.jsx)(q,{onCommit:n,value:g}),d[2]=n,d[3]=g,d[4]=i):i=d[4],d[5]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(u.Label,{children:"Tags"}),d[5]=r):r=d[5],d[6]!==m.tags||d[7]!==h?(s=(0,t.jsxs)("div",{className:"space-y-2",children:[r,(0,t.jsx)(O.TagInput,{onChange:h,placeholder:"Add tags...",tags:m.tags})]}),d[6]=m.tags,d[7]=h,d[8]=s):s=d[8],d[9]!==p?(o=e=>p({notes:e}),d[9]=p,d[10]=o):o=d[10];let x=m.notes??"";return d[11]!==o||d[12]!==x?(l=(0,t.jsx)(K,{onCommit:o,value:x}),d[11]=o,d[12]=x,d[13]=l):l=d[13],d[14]!==i||d[15]!==s||d[16]!==l?(c=(0,t.jsxs)(t.Fragment,{children:[i,s,l]}),d[14]=i,d[15]=s,d[16]=l,d[17]=c):c=d[17],c}function H(e){let n,i,r,s,o,l=(0,a.c)(18),{actions:c,contact:d,data:u}=e;return l[0]!==c.onSave||l[1]!==d?(n=(0,t.jsx)(J,{contact:d,onSave:c.onSave}),l[0]=c.onSave,l[1]=d,l[2]=n):n=l[2],l[3]!==c.onCompanyChange||l[4]!==c.onSave?(i={onCompanyChange:c.onCompanyChange,onSave:c.onSave},l[3]=c.onCompanyChange,l[4]=c.onSave,l[5]=i):i=l[5],l[6]!==d||l[7]!==u||l[8]!==i?(r=(0,t.jsx)(W,{actions:i,contact:d,data:u}),l[6]=d,l[7]=u,l[8]=i,l[9]=r):r=l[9],l[10]!==c.onSave||l[11]!==c.onTagsChange||l[12]!==d?(s=(0,t.jsx)(Y,{contact:d,onSave:c.onSave,onTagsChange:c.onTagsChange}),l[10]=c.onSave,l[11]=c.onTagsChange,l[12]=d,l[13]=s):s=l[13],l[14]!==n||l[15]!==r||l[16]!==s?(o=(0,t.jsxs)("div",{className:"space-y-4",children:[n,r,s]}),l[14]=n,l[15]=r,l[16]=s,l[17]=o):o=l[17],o}var Z=e.i(208252),X=e.i(549822);function ee(e){let n,i,r,s=(0,a.c)(9),{contact:o,teamId:l}=e,{setContactLabels:c}=(0,Z.useContactLabels)(l);s[0]!==o._id||s[1]!==c?(n=e=>{c({contactId:o._id,labelIds:e}).catch(et)},s[0]=o._id,s[1]=c,s[2]=n):n=s[2];let d=n;return s[3]!==o.labelIds?(i=o.labelIds??[],s[3]=o.labelIds,s[4]=i):i=s[4],s[5]!==d||s[6]!==i||s[7]!==l?(r=(0,t.jsx)(X.ContactLabelsField,{onChange:d,teamId:l,value:i}),s[5]=d,s[6]=i,s[7]=l,s[8]=r):r=s[8],r}function et(e){return p.toast.error(e instanceof Error?e.message:"Could not update labels")}var ea=e.i(439779),en=e.i(308402),ei=e.i(735826);function er({contact:e}){let a=(0,i.useAction)(n.api.crm.outreach.send.sendContactEmail),[r,s]=(0,U.useState)(!1),[o,l]=(0,U.useState)(""),[c,d]=(0,U.useState)(""),[m,h]=(0,U.useState)(!1),g=async()=>{h(!0);try{let t=await a({contactId:e._id,subject:o,body:c});switch(t.kind){case"sent":p.toast.success(`Email sent to ${e.name}.`),s(!1),l(""),d("");break;case"blocked":case"rail_unconfigured":case"failed":p.toast.error(t.reason)}}catch(e){p.toast.error(e instanceof Error?e.message:"Could not send email")}finally{h(!1)}};return(0,t.jsxs)(ea.Dialog,{onOpenChange:s,open:r,children:[(0,t.jsx)(ea.DialogTrigger,{render:(0,t.jsxs)(I.Button,{size:"sm",variant:"secondary",children:[(0,t.jsx)(ei.Mail,{}),"Email"]})}),(0,t.jsxs)(ea.DialogContent,{children:[(0,t.jsxs)(ea.DialogHeader,{children:[(0,t.jsxs)(ea.DialogTitle,{children:["Email ",e.name]}),(0,t.jsxs)(ea.DialogDescription,{children:["Sends from your connected Gmail to ",e.email,"."]})]}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(u.Label,{htmlFor:"quick-email-subject",children:"Subject"}),(0,t.jsx)($.Input,{id:"quick-email-subject",onChange:e=>l(e.target.value),placeholder:"Subject",value:o})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(u.Label,{htmlFor:"quick-email-body",children:"Message"}),(0,t.jsx)(z.Textarea,{id:"quick-email-body",onChange:e=>d(e.target.value),placeholder:"Write your message...",rows:6,value:c})]})]}),(0,t.jsx)(ea.DialogFooter,{children:(0,t.jsx)(I.Button,{disabled:m||!o.trim()||!c.trim(),onClick:g,children:"Send"})})]})]})}function es(e){let n,i=(0,a.c)(2),{contact:r}=e;return i[0]!==r?(n=(0,t.jsx)(en.TooltipProvider,{children:(0,t.jsx)("div",{className:"flex items-center gap-2",children:r.email?(0,t.jsx)(er,{contact:r}):(0,t.jsxs)(en.Tooltip,{children:[(0,t.jsx)(en.TooltipTrigger,{render:(0,t.jsx)("span",{className:"inline-flex"}),children:(0,t.jsxs)(I.Button,{disabled:!0,size:"sm",variant:"secondary",children:[(0,t.jsx)(ei.Mail,{}),"Email"]})}),(0,t.jsx)(en.TooltipContent,{children:"Add an email address first"})]})})}),i[0]=r,i[1]=n):n=i[1],n}var eo=e.i(605170);let el={bounced:{label:"Bounced",v
1ariant:"destructive"},opted_out:{label:"Opted out",variant:"red"},needs_daniel:{label:"Needs Daniel",variant:"amber"},replied_ack:{label:"Acknowledged",variant:"emerald"},replied_info_request:{label:"Info requested",variant:"sky"}};function ec(e){let n,i,r=(0,a.c)(6),{contact:s}=e,{responseType:o,lastResponseAt:l,lastResponseGist:c,lastThreadRef:d}=s;return r[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)(u.Label,{children:"Response status"}),r[0]=n):n=r[0],r[1]!==l||r[2]!==c||r[3]!==d||r[4]!==o?(i=(0,t.jsxs)("div",{className:"space-y-2",children:[n,o?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(k.Badge,{size:"sm",variant:el[o].variant,children:el[o].label}),l?(0,t.jsx)(w.Muted,{as:"span",children:(0,eo.formatContactDateTime)(l)}):null,d?(0,t.jsxs)(I.Button,{onClick:()=>{let e;return window.open((e=encodeURIComponent(d.account),`https://mail.google.com/mail/u/?authuser=${e}#all/${d.threadId}`),"_blank","noopener")},size:"sm",variant:"link",children:[(0,t.jsx)(T.ExternalLink,{className:"size-3"}),"View thread"]}):null]}),c?(0,t.jsx)(w.Text,{as:"p",variant:"bodySmall",children:c}):null]}):(0,t.jsx)(w.Muted,{children:"No response observed yet."})]}),r[1]=l,r[2]=c,r[3]=d,r[4]=o,r[5]=i):i=r[5],i}var ed=e.i(729531),eu=e.i(556831);let em=[];function ep(e){return{id:e.id,title:e.title,url:e.url,icon:e.icon,description:e.description,faviconUrl:e.faviconUrl,iconData:(0,f.fromConvexIconData)(e.iconData)}}function eh(e){return{id:e.id,title:e.title,url:e.url,icon:e.icon,description:e.description,faviconUrl:e.faviconUrl,iconData:(0,f.toConvexIconData)(e.iconData)}}function eg(e){let n,i,r,s=(0,a.c)(11),{contact:o,onLinksChange:l}=e,{uploadedImages:c,onUploadImage:d,onDeleteImage:u,onTouchImage:m}=(0,ed.useIconUpload)(),p=o.links??em;s[0]!==p?(n=p.map(ep),s[0]=p,s[1]=n):n=s[1];let h=n;return s[2]!==l?(i=e=>l(e.map(eh)),s[2]=l,s[3]=i):i=s[3],s[4]!==h||s[5]!==u||s[6]!==m||s[7]!==d||s[8]!==i||s[9]!==c?(r=(0,t.jsx)(eu.LinkBar,{isEditable:!0,links:h,onDeleteImage:u,onLinksChange:i,onTouchImage:m,onUploadImage:d,uploadedImages:c}),s[4]=h,s[5]=u,s[6]=m,s[7]=d,s[8]=i,s[9]=c,s[10]=r):r=s[10],r}function ex(e){let r,s,c,d,k,I,w,A,L,T,D,B,M,P,z,U,O,F,G,$,q,Q,R,K,J,W,Y,Z,X,et,ea,en,ei,er,eo,el,ed,eu,em,ep,eh,ex,ej,eb,ey=(0,a.c)(114),{contact:eC,context:eS,onBack:e_}=e,eN=eS?.teamId,ek=eS?.noun??"Contact",{gate:eI,isGuest:ew}=(0,x.useGuestGate)();ey[0]!==eN?(r={teamId:eN},ey[0]=eN,ey[1]=r):r=ey[1];let{updateContact:eA}=(0,l.useContacts)(r);ey[2]!==eN?(s={teamId:eN},ey[2]=eN,ey[3]=s):s=ey[3];let{companies:eL}=(0,o.useCompanies)(s),eT=(0,i.useMutation)(n.api.crm.contact_company_links.mutations.create);ey[4]!==eC._id||ey[5]!==eI?(c=eI({contactId:eC._id}),ey[4]=eC._id,ey[5]=eI,ey[6]=c):c=ey[6];let eD=(0,i.useQuery)(n.api.crm.contact_company_links.queries.getByContact,c);ey[7]!==eD?(d=eD?.find(ev)?.companyId??eD?.at(0)?.companyId,ey[7]=eD,ey[8]=d):d=ey[8];let eB=d;ey[9]!==eC._id||ey[10]!==ek||ey[11]!==eA?(k=e=>{eA({contactId:eC._id,...e}).catch(e=>{p.toast.error(e instanceof Error?e.message:`Could not save ${ek.toLowerCase()}`)})},ey[9]=eC._id,ey[10]=ek,ey[11]=eA,ey[12]=k):k=ey[12];let eM=k;ey[13]!==eC._id||ey[14]!==eT||ey[15]!==ew||ey[16]!==eB?(I=e=>{!ew&&e&&e!==eB&&eT({contactId:eC._id,companyId:e,isPrimary:!0}).catch(ef)},ey[13]=eC._id,ey[14]=eT,ey[15]=ew,ey[16]=eB,ey[17]=I):I=ey[17];let eP=I;ey[18]!==eM?(w=e=>{eM({iconData:(0,f.toConvexIconData)(e)})},ey[18]=eM,ey[19]=w):w=ey[19];let eE=w;ey[20]!==e_?(A=(0,t.jsx)(g.AppTopBarBackButton,{onClick:e_}),ey[20]=e_,ey[21]=A):A=ey[21];let ez=`${ek} details`;ey[22]!==eC.name||ey[23]!==ez?(L=(0,t.jsx)(g.AppTopBarTitle,{subtitle:ez,title:eC.name}),ey[22]=eC.name,ey[23]=ez,ey[24]=L):L=ey[24],ey[25]!==L||ey[26]!==A?(T=(0,t.jsx)(g.AppTopBar,{standalone:!0,children:(0,t.jsxs)(g.AppTopBarLeading,{children:[A,L]})}),ey[25]=L,ey[26]=A,ey[27]=T):T=ey[27],ey[28]!==eC||ey[29]!==eE?(D=(0,t.jsx)(S.ContactAvatar,{contact:eC,onChange:eE}),ey[28]=eC,ey[29]=eE,ey[30]=D):D=ey[30],ey[31]!==eC?(B=(0,b.effectiveStage)(eC),ey[31]=eC,ey[32]=B):B=ey[32],ey[33]!==B?(M=(0,t.jsx)(j.StageBadge,{stage:B}),ey[33]=B,ey[34]=M):M=ey[34],ey[35]!==eC?(P=(0,t.jsx)(es,{contact:eC}),ey[35]=eC,ey[36]=P):P=ey[36],ey[37]!==M||ey[38]!==P?(z=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[M,P]}),ey[37]=M,ey[38]=P,ey[39]=z):z=ey[39],ey[40]!==D||ey[41]!==z?(U=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[D,z]}),ey[40]=D,ey[41]=z,ey[42]=U):U=ey[42],ey[43]!==eM?(O=e=>{e&&eM({name:e})},ey[43]=eM,ey[44]=O):O=ey[44],ey[45]!==eC.name||ey[46]!==O?(F=(0,t.jsx)(V,{label:"Name",onCommit:O,placeholder:"John Doe",value:eC.name}),ey[45]=eC.name,ey[46]=O,ey[47]=F):F=ey[47],ey[48]!==eC||ey[49]!==eN?(G=(0,t.jsx)(ee,{contact:eC,teamId:eN}),ey[48]=eC,ey[49]=eN,ey[50]=G):G=ey[50],ey[51]===Symbol.for("react.memo_cache_sentinel")?($=(0,t.jsx)(m.Separator,{}),ey[51]=$):$=ey[51],ey[52]===Symbol.for("react.memo_cache_sentinel")?(q=(0,t.jsx)(u.Label,{children:"Links"}),ey[52]=q):q=ey[52],ey[53]!==eM?(Q=e=>eM({links:e}),ey[53]=eM,ey[54]=Q):Q=ey[54],ey[55]!==eC||ey[56]!==Q?(R=(0,t.jsxs)("div",{className:"space-y-2",children:[q,(0,t.jsx)(eg,{c
1ontact:eC,onLinksChange:Q})]}),ey[55]=eC,ey[56]=Q,ey[57]=R):R=ey[57],ey[58]===Symbol.for("react.memo_cache_sentinel")?(K=(0,t.jsx)(m.Separator,{}),ey[58]=K):K=ey[58],ey[59]!==eM?(J=e=>eM({tags:e}),ey[59]=eM,ey[60]=J):J=ey[60],ey[61]!==eP||ey[62]!==eM||ey[63]!==J?(W={onCompanyChange:eP,onSave:eM,onTagsChange:J},ey[61]=eP,ey[62]=eM,ey[63]=J,ey[64]=W):W=ey[64],ey[65]!==eL||ey[66]!==eB?(Y={companies:eL,companyId:eB},ey[65]=eL,ey[66]=eB,ey[67]=Y):Y=ey[67],ey[68]!==eC||ey[69]!==W||ey[70]!==Y?(Z=(0,t.jsx)(H,{actions:W,contact:eC,data:Y}),ey[68]=eC,ey[69]=W,ey[70]=Y,ey[71]=Z):Z=ey[71],ey[72]===Symbol.for("react.memo_cache_sentinel")?(X=(0,t.jsx)(m.Separator,{}),ey[72]=X):X=ey[72];let eU=eS?.onOpenOrder;return ey[73]!==eC._id||ey[74]!==eU||ey[75]!==eN?(et=(0,t.jsx)(N.ContactCommerceHistory,{contactId:eC._id,onOpenOrder:eU,teamId:eN}),ey[73]=eC._id,ey[74]=eU,ey[75]=eN,ey[76]=et):et=ey[76],ey[77]!==eC._id?(ea=(0,t.jsx)(v.TextThread,{source:{kind:"client",clientId:eC._id}}),ey[77]=eC._id,ey[78]=ea):ea=ey[78],ey[79]!==eC?(en=(0,t.jsx)(_.ContactCampaignsSection,{contact:eC}),ey[79]=eC,ey[80]=en):en=ey[80],ey[81]===Symbol.for("react.memo_cache_sentinel")?(ei=(0,t.jsx)(m.Separator,{}),ey[81]=ei):ei=ey[81],ey[82]!==eC?(er=(0,t.jsx)(E,{contact:eC}),ey[82]=eC,ey[83]=er):er=ey[83],ey[84]===Symbol.for("react.memo_cache_sentinel")?(eo=(0,t.jsx)(m.Separator,{}),ey[84]=eo):eo=ey[84],ey[85]!==eM?(el=e=>eM({properties:e}),ey[85]=eM,ey[86]=el):el=ey[86],ey[87]!==eC.properties?(ed=eC.properties??[],ey[87]=eC.properties,ey[88]=ed):ed=ey[88],ey[89]!==el||ey[90]!==ed?(eu=(0,t.jsx)(y.ContactPropertiesEditor,{onChange:el,properties:ed}),ey[89]=el,ey[90]=ed,ey[91]=eu):eu=ey[91],ey[92]===Symbol.for("react.memo_cache_sentinel")?(em=(0,t.jsx)(m.Separator,{}),ey[92]=em):em=ey[92],ey[93]!==eC?(ep=(0,t.jsx)(ec,{contact:eC}),ey[93]=eC,ey[94]=ep):ep=ey[94],ey[95]===Symbol.for("react.memo_cache_sentinel")?(eh=(0,t.jsx)(m.Separator,{}),ey[95]=eh):eh=ey[95],ey[96]!==eC?(ex=(0,t.jsx)(C.ContactStageSection,{contact:eC}),ey[96]=eC,ey[97]=ex):ex=ey[97],ey[98]!==U||ey[99]!==F||ey[100]!==G||ey[101]!==R||ey[102]!==Z||ey[103]!==et||ey[104]!==ea||ey[105]!==en||ey[106]!==er||ey[107]!==eu||ey[108]!==ep||ey[109]!==ex?(ej=(0,t.jsx)(h.AppContent,{children:(0,t.jsx)(h.AppContentBody,{classNameViewport:"p-4 max-md:pb-[calc(var(--mobile-bottom-bar-height,4rem)+env(safe-area-inset-bottom,0px))]",column:"sm",children:(0,t.jsxs)("div",{className:"space-y-6",children:[U,F,G,$,R,K,Z,X,et,ea,en,ei,er,eo,eu,em,ep,eh,ex]})})}),ey[98]=U,ey[99]=F,ey[100]=G,ey[101]=R,ey[102]=Z,ey[103]=et,ey[104]=ea,ey[105]=en,ey[106]=er,ey[107]=eu,ey[108]=ep,ey[109]=ex,ey[110]=ej):ej=ey[110],ey[111]!==T||ey[112]!==ej?(eb=(0,t.jsxs)(h.AppLayout,{children:[T,ej]}),ey[111]=T,ey[112]=ej,ey[113]=eb):eb=ey[113],eb}function ef(e){p.toast.error(e instanceof Error?e.message:"Could not link company")}function ev(e){return e.isPrimary}var ej=e.i(456926);function eb(e){let u,m,p,h,g,x,f=(0,a.c)(20),{context:v,onBack:j}=e,b=v?.teamId;f[0]!==b?(u={teamId:b},f[0]=b,f[1]=u):u=f[1];let{createContact:y}=(0,l.useContacts)(u);f[2]!==b?(m={teamId:b},f[2]=b,f[3]=m):m=f[3];let{companies:C}=(0,o.useCompanies)(m),S=(0,i.useMutation)(n.api.crm.contact_company_links.mutations.create),_=(0,i.useMutation)(n.api.crm.contact_campaign_links.mutations.create);f[4]!==v?.noun||f[5]!==y||f[6]!==S||f[7]!==_||f[8]!==b?(p=async e=>{let t=await y({name:e.name,email:e.email||void 0,phone:e.phone||void 0,jobTitle:e.jobTitle||void 0,postalAddress:e.postalAddress?(0,ej.compactPostalAddress)(e.postalAddress):void 0,birthday:(0,c.parseBirthdayInput)(e.birthday??"")||void 0,notes:e.notes||void 0,tags:v?.noun==="Client"?(0,r.withClientMembership)(e.tags):e.tags,labelIds:e.labelIds.length>0?e.labelIds:void 0,properties:e.properties.length>0?e.properties:void 0,teamId:b});(0,s.trackEvent)(s.ANALYTICS_EVENTS.contactCreated),t&&(e.companyId&&await S({contactId:t._id,companyId:e.companyId,isPrimary:!0}),e.campaignIds.length>0&&await Promise.all(e.campaignIds.map(e=>_({contactId:t._id,campaignId:e}))))},f[4]=v?.noun,f[5]=y,f[6]=S,f[7]=_,f[8]=b,f[9]=p):p=f[9];let N=p;f[10]!==N||f[11]!==j?(h={onBack:j,onSubmit:N},f[10]=N,f[11]=j,f[12]=h):h=f[12];let k=v?.noun;return f[13]!==k||f[14]!==b?(g={noun:k,teamId:b}
1,f[13]=k,f[14]=b,f[15]=g):g=f[15],f[16]!==C||f[17]!==h||f[18]!==g?(x=(0,t.jsx)(d.ContactForm,{actions:h,companies:C,entity:g}),f[16]=C,f[17]=h,f[18]=g,f[19]=x):x=f[19],x}e.s(["ContactDetailPage",0,function(e){let n,i=(0,a.c)(7),{contact:r,context:s,onBack:o}=e;if(r){let e;return i[0]!==r||i[1]!==s||i[2]!==o?(e=(0,t.jsx)(ex,{contact:r,context:s,onBack:o}),i[0]=r,i[1]=s,i[2]=o,i[3]=e):e=i[3],e}return i[4]!==s||i[5]!==o?(n=(0,t.jsx)(eb,{context:s,onBack:o}),i[4]=s,i[5]=o,i[6]=n):n=i[6],n}],861709)},106240,e=>{"use strict";var t=e.i(931718),a=e.i(729386);e.i(116233);var n=e.i(323490),i=e.i(76075),r=e.i(243930),s=e.i(699597),o=e.i(632137),l=e.i(735826),c=e.i(103370),d=e.i(400810),u=e.i(690204),m=e.i(47070);function p(e){return(0,t.jsx)(n.Badge,{variant:"secondary",children:e},e)}e.s(["ContactCard",0,function(e){let h,g,x,f,v,j,b,y,C,S,_,N,k,I,w,A,L=(0,a.c)(49),{contact:T,onClick:D,onDragStart:B,selected:M}=e;L[0]!==T.iconData?(h=(0,d.fromConvexIconData)(T.iconData),L[0]=T.iconData,L[1]=h):h=L[1];let P=h,E=!!D,z=E?!!M:void 0,U=E&&"cursor-pointer transition-colors hover:bg-surface-hover",O=M&&"bg-surface-hover";L[2]!==U||L[3]!==O?(g=(0,o.cn)(U,O),L[2]=U,L[3]=O,L[4]=g):g=L[4];let F=!!B||void 0;L[5]!==E||L[6]!==D?(x=E?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),D?.())}:void 0,L[5]=E,L[6]=D,L[7]=x):x=L[7];let G=E?"button":void 0,$=E?0:void 0;return L[8]!==T.name||L[9]!==P?(f=(0,t.jsx)(r.IconDataAvatar,{className:"size-10",icon:P,name:T.name}),L[8]=T.name,L[9]=P,L[10]=f):f=L[10],L[11]!==T.name?(v=(0,t.jsx)(s.H3,{className:"truncate",variant:"panel",children:T.name}),L[11]=T.name,L[12]=v):v=L[12],L[13]!==T?(j=(0,m.effectiveStage)(T),L[13]=T,L[14]=j):j=L[14],L[15]!==j?(b=(0,t.jsx)(u.StageBadge,{stage:j}),L[15]=j,L[16]=b):b=L[16],L[17]!==v||L[18]!==b?(y=(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[v,b]}),L[17]=v,L[18]=b,L[19]=y):y=L[19],L[20]!==T.jobTitle?(C=T.jobTitle&&(0,t.jsx)(s.Muted,{className:"truncate",children:T.jobTitle}),L[20]=T.jobTitle,L[21]=C):C=L[21],L[22]!==T.email?(S=T.email&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground text-xs",children:[(0,t.jsx)(l.Mail,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"truncate",children:T.email})]}),L[22]=T.email,L[23]=S):S=L[23],L[24]!==T.phone?(_=T.phone&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground text-xs",children:[(0,t.jsx)(c.Phone,{className:"h-3 w-3"}),(0,t.jsx)("span",{children:T.phone})]}),L[24]=T.phone,L[25]=_):_=L[25],L[26]!==S||L[27]!==_?(N=(0,t.jsxs)("div",{className:"mt-2 space-y-1",children:[S,_]}),L[26]=S,L[27]=_,L[28]=N):N=L[28],L[29]!==T.tags?(k=T.tags.length>0&&(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1",children:[T.tags.slice(0,3).map(p),T.tags.length>3&&(0,t.jsxs)(n.Badge,{variant:"outline",children:["+",T.tags.length-3]})]}),L[29]=T.tags,L[30]=k):k=L[30],L[31]!==y||L[32]!==C||L[33]!==N||L[34]!==k?(I=(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[y,C,N,k]}),L[31]=y,L[32]=C,L[33]=N,L[34]=k,L[35]=I):I=L[35],L[36]!==f||L[37]!==I?(w=(0,t.jsx)(i.CardContent,{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[f,I]})}),L[36]=f,L[37]=I,L[38]=w):w=L[38],L[39]!==D||L[40]!==B||L[41]!==z||L[42]!==w||L[43]!==g||L[44]!==F||L[45]!==x||L[46]!==G||L[47]!==$?(A=(0,t.jsx)(i.Card,{"aria-pressed":z,className:g,draggable:F,onClick:D,onDragStart:B,onKeyDown:x,role:G,tabIndex:$,children:w}),L[39]=D,L[40]=B,L[41]=z,L[42]=w,L[43]=g,L[44]=F,L[45]=x,L[46]=G,L[47]=$,L[48]=A):A=L[48],A}])}]);
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.