1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[51572],{423213:function(e,t,s){s.d(t,{mL:function(){return r},ud:function(){return i}});let n=["class","department","project","expenseAccount"],a={class:"class",department:"department",project:"project",expenseAccount:"expense account"},l={class:"hasClass",department:"hasDepartment",project:"hasProject",expenseAccount:"hasExpenseAccount"};function r(e,t){if(0===e.length)return[];let s=new Set;for(let a of n){if(!t[a])continue;let n=l[a];e.some(e=>!e[n])&&s.add(a)}return n.filter(e=>s.has(e))}function i(e){if(0===e.length)return"";let t=e.map(e=>a[e]);if(1===t.length)return"Warning: ".concat(t[0]," is blank. Continue anyway?");let s=2===t.length?"".concat(t[0]," and ").concat(t[1]):"".concat(t.slice(0,-1).join(", "),", and ").concat(t[t.length-1]);return"Warning: ".concat(s," are blank. Continue anyway?")}},125109:function(e,t,s){function n(e,t,s){let n=e.length>0?e:t,a=s.filter(e=>!n.includes(e));return[...n,...a].map(e=>({value:e,label:e}))}function a(e,t){return e&&"Tags"===t?"Product Tags":t}s.d(t,{A:function(){return a},G:function(){return n}})},323843:function(e,t,s){s.d(t,{H:function(){return l},H6:function(){return c},L8:function(){return i},N1:function(){return a},Oq:function(){return o},Pp:function(){return p},SN:function(){return m},fh:function(){return x},jd:function(){return r},q2:function(){return u},sn:function(){return d},zP:function(){return h}});var n=s(586248);let a="PROJECT_NUMBER_USES_PROPERTY_TYPE_AND_PM",l="ESTIMATE_NEEDS_APPROVAL",r={all:["leads"],inboundLeads:e=>["leads","inbound",e],manualLeads:e=>["leads","manual",e],lead:e=>["leads","detail",e],leadLogs:e=>["leads","logs",e],productRequirements:e=>["leads","product-requirements",e],emailThread:e=>["leads","email-thread",e]},i=10,o=20,c={HIGH:{className:"bg-state-error-lighter text-state-error border-state-error",label:"High"},MEDIUM:{className:"bg-state-warning-lighter text-state-warning border-state-warning",label:"Medium"},LOW:{className:"bg-state-success-lighter text-state-success border-state-success",label:"Low"}},d={NEW:{className:"bg-state-info-lighter text-state-info",label:"New"},CONTACTED:{className:"bg-brand-primary-alpha-10 text-brand-primary",label:"Contacted"},QUALIFIED:{className:"bg-state-success-lighter text-state-success",label:"Qualified"},DISQUALIFIED:{className:"bg-state-error-lighter text-state-error",label:"Disqualified"},CONVERTED:{className:"bg-state-success-lighter text-state-success",label:"Converted"}},u={INDIVIDUAL:{className:"bg-bg-soft-200 text-text-sub-600",label:"Individual"},COMPANY:{className:"bg-brand-primary-alpha-10 text-brand-primary",label:"Company"}},m={AI_EMAIL:"AI Email",WEB_FORM:"Web Form",PHONE:"Phone",REFERRAL:"Referral",TRADE_SHOW:"Trade Show",MANUAL:"Manual"};function x(e){let t=(null!=e?e:"").trim().toLowerCase();return"referral"===t||"vendor referral"===t}let p=[{value:n.Rt.INDIVIDUAL,label:"Individual"},{value:n.Rt.COMPANY,label:"Company"}],h={EXACT_SKU:{className:"bg-state-success-lighter text-state-success border-state-success",label:"Exact SKU"},MPN:{className:"bg-state-info-lighter text-state-info border-state-info",label:"MPN"},SEMANTIC:{className:"bg-bg-soft-200 text-text-sub-600 border-stroke-soft-200",label:"Semantic"}}},586248:function(e,t,s){s.d(t,{DJ:function(){return c},PT:function(){return n},Ri:function(){return i},Rt:function(){return o},SF:function(){return b},Se:function(){return r},WS:function(){return a},_L:function(){return f},cy:function(){return x},f2:function(){return l},p_:function(){return g},z2:function(){return p},zu:function(){return h}});let n={NEW:"NEW",CONTACTED:"CONTACTED",QUALIFIED:"QUALIFIED",DISQUALIFIED:"DISQUALIFIED",CONVERTED:"CONVERTED"};function a(e,t){if(!e)return!1;let s=t.find(t=>t.name===e);return s?s.isConverted:"CONVERTED"===e.toUpperCase()}function l(e,t){if(!e)return!1;let s=t.find(t=>t.name===e);if(s)return s.isLost;let n=e.toUpperCase();return"DISQUALIFIED"===n||"UNQUALIFIED"===n||"LOST"===n}let r={NEW:["CONTACTED","QUALIFIED","DISQUALIFIED","CONVERTED"],CONTACTED:["QUALIFIED","DISQUALIFIED"],QUALIFIED:["CONVERTED","DISQUALIFIED"],DISQUALIFIED:[],CONVERTED:[]},i={AI_EMAIL:"AI_EMAIL",WEB_FORM:"WEB_FORM",PHONE:"PHONE",REFERRAL:"REFERRAL",TRADE_SHOW:"TRADE_SHOW",MANUAL:"MANUAL",JOTFORM:"JOTFORM"},o={INDIVIDUAL:"INDIVIDUAL",COMPANY:"COMPANY"},c=[{value:"PHONE",label:"Phone Call"},{value:"EMAIL",label:"Email"},{value:"IN_PERSON",label:"In Person"},{value:"VIDEO_CALL",label:"Video Call"},{value:"TEXT_MESSAGE",label:"Text Message"}],d="NOT_REACHABLE",u="NO_ANSWER",m="VOICEMAIL",x=new Set([d,u,m]),p=[{value:"REACHED",label:"Reached"},{value:m,label:"Left Voicemail"},{value:u,label:"No Answer"},{value:d,label:"Not Reachable"},{value:"CALLBACK_SCHEDULED",label:"Callback Scheduled"},{value:"NOT_INTERESTED",label:"Not Interested"}],h={enabled:!1,deadlineMinutes:1440,reminders:[{minutesBeforeDeadline:60},{minutesBeforeDeadline:30},{minutesBeforeDeadline:10}],deadlineMissAction:"REASSIGN",maxReassignAttempts:3,permanentExclusionOnMiss:!0,escalationTargets:[{t
1ype:"SALES_ADMINS",userIds:[]}],completionRequirements:{notesRequired:!1,minNotesLength:0},leadFilter:{sources:[],projectTypes:[]}},f={ACTIVE_CUSTOMER:"ACTIVE_CUSTOMER",INACTIVE_CUSTOMER:"INACTIVE_CUSTOMER",VENDOR:"VENDOR",PROSPECT:"PROSPECT"},g={NEW:"NEW",VERIFIED:"VERIFIED",ON_HOLD:"ON_HOLD",CLOSED:"CLOSED"},b={A:"A",B:"B",C:"C",D:"D"}},676379:function(e,t,s){s.d(t,{$p:function(){return u},H:function(){return c},SW:function(){return d},aP:function(){return r},fu:function(){return i},in:function(){return o},ul:function(){return a},zb:function(){return l}});let n=["bg-state-info","bg-purple-500","bg-orange-500","bg-cyan-500","bg-pink-500","bg-state-success","bg-state-warning","bg-red-500","bg-indigo-500","bg-teal-500"];function a(e){return n[e%n.length]}let l="__all__",r=[{value:"newest",label:"Newest First"},{value:"oldest",label:"Oldest First"},{value:"amount_high",label:"Amount: High to Low"},{value:"amount_low",label:"Amount: Low to High"},{value:"alphabetical",label:"Alphabetical"},{value:"close_date_asc",label:"Close Date: Soonest"},{value:"close_date_desc",label:"Close Date: Latest"},{value:"next_action_asc",label:"Next Action: Soonest"},{value:"next_action_desc",label:"Next Action: Latest"},{value:"last_activity",label:"Last Activity"},{value:"updated",label:"Recently Updated"},{value:"created_newest",label:"Newest Created"},{value:"created_oldest",label:"Oldest Created"}];function i(e){switch(e){case"newest":return{sortBy:void 0,sortOrder:void 0};case"oldest":case"created_oldest":return{sortBy:"createdAt",sortOrder:"asc"};case"amount_high":return{sortBy:"estimatedValue",sortOrder:"desc"};case"amount_low":return{sortBy:"estimatedValue",sortOrder:"asc"};case"alphabetical":return{sortBy:"title",sortOrder:"asc"};case"close_date_asc":return{sortBy:"expectedCloseDate",sortOrder:"asc"};case"close_date_desc":return{sortBy:"expectedCloseDate",sortOrder:"desc"};case"next_action_asc":return{sortBy:"nextActionDate",sortOrder:"asc"};case"next_action_desc":return{sortBy:"nextActionDate",sortOrder:"desc"};case"last_activity":return{sortBy:"lastActivityDate",sortOrder:"desc"};case"updated":return{sortBy:"updatedAt",sortOrder:"desc"};case"created_newest":return{sortBy:"createdAt",sortOrder:"desc"}}}let o=[{label:"$0-5K",min:0,max:5e3},{label:"$5-10K",min:5e3,max:1e4},{label:"$10-20K",min:1e4,max:2e4},{label:"$20K+",min:2e4,max:null}],c={all:["pipeline-v2"],board:()=>[...c.all,"board"],boardScoped:e=>[...c.board(),null!=e?e:"all"],boardView:(e,t)=>[...c.boardScoped(e),t],stages:()=>[...c.all,"stages"],saleStatesConfig:()=>[...c.all,"sale-states-config"],saleStatesConfigScoped:e=>[...c.saleStatesConfig(),null!=e?e:"all"],users:()=>[...c.all,"users"],customAttributes:()=>[...c.all,"custom-attributes"],saleDetail:e=>[...c.all,"sale-detail",e],projectFormData:()=>[...c.all,"project-form-data"],opportunityList:e=>[...c.all,"opportunity-list",e]},d={COLUMN_WIDTH:300,COLUMN_MIN_HEIGHT:400,CARD_GAP:12,SCROLL_THRESHOLD:100},u={cardsPerPage:20,loadMoreIncrement:20,serverPageSize:50}},917595:function(e,t,s){s.d(t,{P:function(){return a}});var n=s(921156);let a={async list(){var e,t;let s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=await n.ZP.get("/api/v1/crm/product-line-tags",{params:s?{includeInactive:!0}:void 0});return null!==(t=null==a?void 0:null===(e=a.data)||void 0===e?void 0:e.data)&&void 0!==t?t:[]},async create(e){var t;let s=await n.ZP.post("/api/v1/crm/product-line-tags",{name:e});return null==s?void 0:null===(t=s.data)||void 0===t?void 0:t.data},async setActive(e,t){var s;let a=await n.ZP.patch("/api/v1/crm/product-line-tags/".concat(e),{active:t});return null==a?void 0:null===(s=a.data)||void 0===s?void 0:s.data}}},52916:function(e,t,s){s.d(t,{s_:function(){return c},us:function(){return o},wj:function(){return d}});var n=s(878551),a=s(430202),l=s(720249),r=s(917595);let i={all:["product-line-tags"],list:e=>["product-line-tags","list",e]};function o(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(0,n.a)({queryKey:i.list(e),queryFn:()=>r.P.list(e)})}function c(){let e=(0,a.NL)();return(0,l.D)({mutationFn:e=>r.P.create(e),onSuccess:()=>e.invalidateQueries({queryKey:i.all}),meta:{successToast:"Tag added",errorToast:e=>(null==e?void 0:e.message)||"Failed to add tag"}})}function d(){let e=(0,a.NL)();return(0,l.D)({mutationFn:e=>{let{id:t,active:s}=e;return r.P.setActive(t,s)},onSuccess:()=>e.invalidateQueries({queryKey:i.all}),meta:{successToast:(e,t)=>
1t.active?"Tag reactivated":"Tag retired",errorToast:e=>(null==e?void 0:e.message)||"Failed to update tag"}})}},904068:function(e,t,s){s.d(t,{a:function(){return i}});var n=s(785893),a=s(808971),l=s(605541),r=s(363548);function i(e){let{title:t,count:s,defaultOpen:i=!0,persistKey:o,userConfigKey:c,headerActions:d,headerLeading:u,children:m,className:x,icon:p,iconBgColor:h}=e,[f,g]=(0,l.H)(o,c,i);return(0,n.jsxs)("div",{className:(0,r.cn)("w-full flex flex-col items-start bg-white border border-stroke-soft-200 rounded-[12px] overflow-hidden",x),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 w-full px-4 py-3 bg-bg-white-0",children:[u,(0,n.jsxs)("button",{type:"button",onClick:()=>g(!f),className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:opacity-80 transition-opacity",children:[p&&(0,n.jsx)("div",{className:(0,r.cn)("flex shrink-0 items-center justify-center w-8 h-8 rounded-lg",h),children:p}),(0,n.jsx)("span",{className:"truncate text-sm font-medium text-text-strong-950",children:t}),void 0!==s&&s>0&&(0,n.jsx)("span",{className:"shrink-0 text-xs text-text-sub-600 bg-bg-weak-50 px-1.5 py-0.5 rounded border border-stroke-soft-200",children:s})]}),d&&(0,n.jsx)("div",{onClick:e=>e.stopPropagation(),className:"flex shrink-0 items-center gap-1",children:d}),(0,n.jsx)("button",{type:"button","aria-label":f?"Collapse ".concat(t):"Expand ".concat(t),"aria-expanded":f,onClick:()=>g(!f),className:"shrink-0 p-1 rounded hover:bg-bg-soft-200 transition-colors",children:(0,n.jsx)(a.Z,{className:(0,r.cn)("h-5 w-5 text-text-sub-600 transition-transform duration-200",f&&"rotate-180")})})]}),f&&(0,n.jsx)("div",{className:"w-full border-t border-stroke-soft-200",children:m})]})}},398069:function(e,t,s){s.d(t,{n:function(){return v}});var n=s(785893),a=s(667294),l=s(287536),r=s(808971),i=s(636316),o=s(554976),c=s(807490),d=s(14066),u=s(558068),m=s(982201),x=s(843509),p=s(983689),h=s(987950);let f={billing:{label:"Billing Address",prefix:"billingAddress"},shipping:{label:"Shipping Address",prefix:"shippingAddress"},mailing:{label:"Mailing Address",prefix:"mailingAddress"},company:{label:"Company Address",prefix:"companyAddress"},job:{label:"Job Address",prefix:"jobAddress"},other:{label:"Other Address",prefix:"otherAddress"}};function g(e){var t;return{addressLine1:(null==e?void 0:e.addressLine1)||"",addressLine2:(null==e?void 0:e.addressLine2)||"",city:(null==e?void 0:e.city)||"",state:(null==e?void 0:e.state)||"",zip:(null==e?void 0:e.zip)||"",country:(null==e?void 0:e.country)||"",county:(null==e?void 0:e.county)||"",lat:(null==e?void 0:e.lat)||"",long:(null==e?void 0:e.long)||"",displayName:(null==e?void 0:e.displayName)||"",countryCode:(null==e?void 0:e.countryCode)||"",placeId:(null==e?void 0:e.placeId)||"",coordinatesApproximate:null!==(t=null==e?void 0:e.coordinatesApproximate)&&void 0!==t&&t}}function b(e){var t,s,n,a;return{addressLine1:e.addressLine1.trim()||null,addressLine2:e.addressLine2.trim()||null,city:e.city.trim()||null,state:e.state.trim()||null,zip:e.zip.trim()||null,country:e.country.trim()||null,county:e.county.trim()||null,lat:e.lat.trim()||null,long:e.long.trim()||null,displayName:(null===(t=e.displayName)||void 0===t?void 0:t.trim())||null,countryCode:(null===(s=e.countryCode)||void 0===s?void 0:s.trim())||null,placeId:(null===(n=e.placeId)||void 0===n?void 0:n.trim())||null,coordinatesApproximate:null!==(a=e.coordinatesApproximate)&&void 0!==a?a:null}}function v(e){let{type:t,address:s,highlightedFieldId:v,onSave:j,disabled:y,lockReason:N,headerContent:w,defaultExpanded:C=!0,enableAutocomplete:k=!1,defaultCountryCode:I=null,variant:S="default",onDirtyChange:E}=e,D=!!N,A=y||D,[T,L]=(0,a.useState)(C),[_,O]=(0,a.useState)(!1),[P,Z]=(0,a.useState)(null),[F,R]=(0,a.useState)(!1),{label:z,prefix:M}=f[t],{register:U,reset:B,watch:V,handleSubmit:J,setValue:W,formState:{isDirty:G}}=(0,l.cI)({defaultValues:g(s)});(0,a.useEffect)(()=>{B(g(s))},[null==s?void 0:s.addressLine1,null==s?void 0:s.addressLine2,null==s?void 0:s.city,null==s?void 0:s.state,null==s?void 0:s.zip,null==s?void 0:s.country,null==s?void 0:s.county,null==s?void 0:s.lat,null==s?void 0:s.long,null==s?void 0:s.displayName,null==s?void 0:s.countryCode,null==s?void 0:s.placeId,null==s?void 0:s.coordinatesApproximate,B]),(0,a.useEffect)(()=>{null==E||E(G)},[G,E]);let Q=V("addressLine1").length,H=V("countryCode"),K=V("country"),q=H||(0,x.k4)(K)||I,{setInput:X,predictions:Y,isLoading:$,error:ee,selectPrediction:et}=(0,u.a)({countryCode:q}),[es,en]=(0,a.useState)(-1),[ea,el]=(0,a.useState)(!1),er=k&&!ea&&Y.length>0,ei=(0,a.useCallback)(()=>{W("placeId","",{shouldDirty:!0}),W("displayName","",{shouldDirty:!0})},[W]),eo=(0,a.useCallback)(async e=>{let t=await et(e);if(!t)return;let s=(0,m.I)(t);
1Object.keys(s).forEach(e=>W(e,s[e],{shouldDirty:!0})),el(!0),en(-1)},[et,W]),ec=(0,a.useCallback)(e=>{ei(),el(!1),en(-1),X(e.target.value)},[ei,X]),ed=(0,a.useCallback)(()=>{el(!0),en(-1)},[]),eu=(0,a.useCallback)(e=>{if(er){if("ArrowDown"===e.key)e.preventDefault(),en(e=>(e+1)%Y.length);else if("ArrowUp"===e.key)e.preventDefault(),en(e=>e<=0?Y.length-1:e-1);else if("Enter"===e.key){e.preventDefault();let t=es>=0?Y[es]:Y[0];t&&eo(t.placeId)}else"Escape"===e.key&&(e.preventDefault(),el(!0),en(-1))}},[er,Y,es,eo]),em=k?{onChange:ei}:{},ex=(0,a.useCallback)(()=>{ei(),W("countryCode","",{shouldDirty:!0})},[ei,W]),ep=(0,a.useMemo)(()=>(0,x.hn)(q),[q]),eh=k&&ep.length>0,ef=V("state"),eg=(0,a.useCallback)(()=>{B(g(s)),el(!0)},[s,B]),eb=(0,a.useCallback)(async e=>{O(!0),Z(null);try{let t=await j(b(e));B(g(null!=t?t:b(e)))}catch(e){Z("Failed to save address. Please try again.")}finally{O(!1)}},[j,B]),ev=(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[null!=w?w:(0,n.jsx)(d.__J,{className:"text-sm font-semibold text-text-strong-950",children:z}),D&&N&&(0,n.jsx)(h.f,{reason:N})]}),ej=(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".addressLine1")&&"animate-label-blink"),children:"Address Line 1"}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(d.gxH,{...U("addressLine1",{maxLength:200,...k?{onChange:ec,onBlur:ed}:{}}),onKeyDown:k?eu:void 0,"aria-autocomplete":k?"list":void 0,"aria-expanded":k?er:void 0,autoComplete:k?"off":void 0,placeholder:k?"Start typing an address...":"Street address, P.O. box...",className:"min-h-[80px] resize-none",disabled:A||_}),(0,n.jsxs)("span",{className:"absolute bottom-2 right-3 text-xs text-text-soft-400",children:[Q,"/",200]}),k&&$&&(0,n.jsx)(i.Z,{className:"absolute right-3 top-3 h-4 w-4 animate-spin text-text-soft-400"}),er&&(0,n.jsx)(p.$,{predictions:Y,activeIndex:es,onHover:en,onSelect:e=>void eo(e)})]}),k&&ee&&(0,n.jsx)("p",{className:"text-xs text-text-sub-600",children:ee})]}),ey=(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".addressLine2")&&"animate-label-blink"),children:"Address Line 2"}),(0,n.jsx)(d.IIB,{type:"text",...U("addressLine2",{maxLength:200,...em}),placeholder:"Apartment, suite, unit, building...",className:"h-10",disabled:y||_})]}),eN=(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".city")&&"animate-label-blink"),children:"City"}),(0,n.jsx)(d.IIB,{type:"text",...U("city",em),placeholder:"City...",className:"h-10",disabled:A||_})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".state")&&"animate-label-blink"),children:"State/Province"}),eh?(0,n.jsxs)(d.PhF,{value:ef||void 0,onValueChange:e=>{W("state",e,{shouldDirty:!0}),ei()},disabled:A||_,children:[(0,n.jsx)(d.i4d,{className:"h-10","aria-label":"State/Province",children:(0,n.jsx)(d.kik,{placeholder:"State/Province..."})}),(0,n.jsx)(d.Bwz,{children:ep.map(e=>(0,n.jsx)(d.QlF,{value:e.shortCode,children:e.name},e.shortCode))})]}):(0,n.jsx)(d.IIB,{type:"text",...U("state",em),placeholder:"State/Province...",className:"h-10",disabled:A||_})]})]}),ew=(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".zip")&&"animate-label-blink"),children:"Zip/Postal Code"}),(0,n.jsx)(d.IIB,{type:"text",...U("zip",em),placeholder:"Zip/Postal Code...",className:"h-10",disabled:A||_})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".country")&&"animate-label-blink"),children:"Country"}),(0,n.jsx)(d.IIB,{type:"text",...U("country",k?{onChange:ex}:{}),placeholder:"Country...",className:"h-10",disabled:A||_})]})]}),eC=(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,
1c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".county")&&"animate-label-blink"),children:"County"}),(0,n.jsx)(d.IIB,{type:"text",...U("county",em),placeholder:"County...",className:"h-10",disabled:A||_})]}),ek=(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".lat")&&"animate-label-blink"),children:"Latitude"}),(0,n.jsx)(d.IIB,{type:"text",...U("lat"),placeholder:"Latitude...",className:"h-10",disabled:A||_})]}),(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsx)(d.__J,{className:(0,c.cn)("text-sm font-medium text-text-strong-950",v==="".concat(M,".long")&&"animate-label-blink"),children:"Longitude"}),(0,n.jsx)(d.IIB,{type:"text",...U("long"),placeholder:"Longitude...",className:"h-10",disabled:A||_})]})]}),eI=(0,n.jsxs)(d.zF9,{open:F,onOpenChange:R,children:[(0,n.jsx)(d.wy4,{asChild:!0,children:(0,n.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between rounded-md py-1.5 text-sm font-medium text-text-sub-600 transition-colors hover:text-text-strong-950",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(o.Z,{className:"h-3.5 w-3.5"}),"Coordinates (advanced)"]}),(0,n.jsx)(r.Z,{className:(0,c.cn)("h-4 w-4 transition-transform duration-200",F&&"rotate-180")})]})}),(0,n.jsx)(d.FwI,{className:"pt-3",children:ek})]}),eS=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)(d.zxk,{type:"submit",size:"sm",disabled:_,className:"h-8",children:[_&&(0,n.jsx)(i.Z,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Save Address"]}),(0,n.jsx)(d.zxk,{type:"button",variant:"outline",size:"sm",onClick:eg,disabled:_,className:"h-8",children:"Cancel"})]}),P&&(0,n.jsx)("p",{className:"text-xs text-destructive",children:P})]});return"popover"===S?(0,n.jsxs)("form",{onSubmit:J(eb),className:"flex min-h-0 flex-1 flex-col",children:[(0,n.jsxs)("div",{className:"shrink-0 space-y-3 border-b border-border p-4",children:[ev,ej]}),(0,n.jsxs)("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto p-4",children:[ey,eN,ew,eC,eI]}),G&&(0,n.jsx)("div",{className:"shrink-0 space-y-1.5 border-t border-border bg-popover p-3",children:eS})]}):(0,n.jsx)(d.zF9,{open:T,onOpenChange:L,children:(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[ev,(0,n.jsx)(d.wy4,{asChild:!0,children:(0,n.jsx)("button",{type:"button",className:"p-1 rounded hover:bg-bg-soft-200 transition-colors",children:(0,n.jsx)(r.Z,{className:(0,c.cn)("h-4 w-4 text-text-sub-600 transition-transform duration-200",T&&"rotate-180")})})})]}),(0,n.jsx)(d.FwI,{children:(0,n.jsxs)("form",{onSubmit:J(eb),className:"space-y-4",children:[ej,ey,eN,ew,eC,eI,G&&(0,n.jsx)("div",{className:"space-y-1.5 pt-1",children:eS})]})})]})})}},377296:function(e,t,s){s.d(t,{f:function(){return m}});var n=s(785893),a=s(667294),l=s(956989),r=s(490869),i=s(807490),o=s(987950),c=s(144631),d=s(14066);let u=/^\+?[0-9]+$/;function m(e){let{id:t,label:s,value:m,type:x,onSave:p,options:h=[],placeholder:f="Placeholder text...",allowClear:g=!1,isHighlighted:b=!1,disabled:v=!1,infoTooltip:j,labelAction:y,lockReason:N,minRows:w=3,maxRows:C=30,layout:k="stacked"}=e,[I,S]=(0,a.useState)(m||""),[E,D]=(0,a.useState)(!1),A=!!N;(0,a.useEffect)(()=>{S(m||"")},[m]);let[T,L]=(0,a.useState)(null),_=e=>e?"fax"!==x||u.test(e)?"phone"!==x||i._D.test(e)?null:"Please enter a valid phone number":"Please enter a valid fax number (digits only, optionally starting with +)":null,O=async()=>{let e=I.trim();if(e===(null!=m?m:"")){L(null);return}let t=_(e);if(t){L(t);return}L(null),D(!0);try{await p(e||null)}finally{D(!1)}}
1,P=async e=>{if(e!==m){D(!0);try{await p(e)}finally{D(!1)}}},Z=()=>(0,n.jsxs)("div",{className:(0,i.cn)("flex items-center gap-1","inline"===k&&"w-full min-w-0"),children:[(0,n.jsx)(d.__J,{className:(0,i.cn)((0,c.y)(k),b&&"animate-label-blink"),children:s}),j&&(0,n.jsx)(d.pnl,{children:(0,n.jsxs)(d.ua7,{children:[(0,n.jsx)(d.aJU,{asChild:!0,children:(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5 text-text-soft-400 cursor-help"})}),(0,n.jsx)(d._vU,{side:"top",className:"max-w-xs",children:j})]})}),A&&N&&(0,n.jsx)(o.f,{reason:N}),y&&(0,n.jsx)("span",{className:"ml-auto flex items-center",children:y})]});if("select"===x){let e=h.find(e=>e.value===m);return(0,n.jsx)(c.z,{id:"field-".concat(t),layout:k,label:Z(),children:(0,n.jsxs)(d.PhF,{value:m||"",onValueChange:e=>P(e||null),disabled:v||E||A,children:[(0,n.jsx)(d.i4d,{className:"h-10 text-sm",children:(0,n.jsx)(d.kik,{placeholder:f,children:(null==e?void 0:e.label)||f})}),(0,n.jsx)(d.Bwz,{children:h.map(e=>(0,n.jsx)(d.QlF,{value:e.value,children:e.label},e.value))})]})})}return"searchable-select"===x?(0,n.jsx)(c.z,{id:"field-".concat(t),layout:k,label:Z(),children:(0,n.jsx)(d.VcW,{options:h,value:m,onChange:e=>P(e),disabled:v||E||A,placeholder:f,allowClear:g,className:"h-10 text-sm"})}):"textarea"===x?(0,n.jsx)(c.z,{id:"field-".concat(t),layout:k,label:Z(),children:(0,n.jsx)(r.Z,{value:I,onChange:e=>{S(e.target.value),T&&L(null)},onBlur:O,disabled:v||E||A,placeholder:f,minRows:w,maxRows:C,className:(0,i.cn)("flex min-h-[80px] w-full rounded-md border border-stroke-soft-200 bg-bg-white-0 px-3 py-2 text-sm text-text-strong-950 ring-offset-bg-white-0 placeholder:text-text-soft-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-400 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 resize-none max-h-[min(600px,60vh)] overflow-y-auto",E&&"opacity-50")})}):(0,n.jsxs)(c.z,{id:"field-".concat(t),layout:k,label:Z(),children:[(0,n.jsx)(d.IIB,{type:"url"===x?"url":"phone"===x||"fax"===x?"tel":"text",value:I,onChange:e=>{S(e.target.value),T&&L(null)},onBlur:O,disabled:v||E||A,placeholder:f,className:(0,i.cn)("h-10 text-sm",E&&"opacity-50",T&&"border-state-error")}),T&&(0,n.jsx)("p",{className:"text-xs text-state-error",children:T})]})}},269061:function(e,t,s){s.d(t,{G:function(){return u}});var n=s(785893),a=s(667294),l=s(931012),r=s(14066),i=s(390835),o=s(987950),c=s(144631),d=s(582822);function u(e){var t;let{entries:s,onSave:u,label:m="Phone Numbers",disabled:x=!1,lockReason:p,manualCommit:h=!1,onCancel:f,layout:g="stacked"}=e,[b,v]=(0,a.useState)(()=>(0,d.$A)(s,h)),[j,y]=(0,a.useState)(!1),N=(0,a.useRef)(b);(0,a.useEffect)(()=>{N.current=b},[b]),(0,a.useEffect)(()=>{h||v(e=>{let t=e.length!==s.length,n=s.map((s,n)=>{var a,l;let r=e[n],i=null!==(a=s.type)&&void 0!==a?a:"WORK";return r&&r.value===s.value&&r.type===i&&r.isPrimary===s.isPrimary?r:(t=!0,{id:null!==(l=null==r?void 0:r.id)&&void 0!==l?l:crypto.randomUUID(),value:s.value,type:i,isPrimary:s.isPrimary,error:null})});return t?n:e})},[s,h]);let w=async e=>{let t=e.some(e=>null!==e.error);if(!t){y(!0);try{await u((0,d.y3)(e))}finally{y(!1)}}},C=(e,t)=>{v(s=>s.map((s,n)=>n===e?{...s,value:t,error:null}:s))},k=e=>{let t=N.current,s=t[e],n=(0,d.wm)(s.value);if(n){v(t=>t.map((t,s)=>s===e?{...t,error:n}:t));return}if(h){v(t=>t.map((t,s)=>s===e?{...t,error:null}:t));return}w(t.map((t,s)=>s===e?{...t,error:null}:t))},I=(e,t)=>{let s=b.map((s,n)=>n===e?{...s,type:t}:s);if(v(s),h)return;let n=(0,d.wm)(s[e].value);n||w(s)},S=e=>{let t=b.map((t,s)=>({...t,isPrimary:s===e}));if(v(t),h)return;let s=t.some(e=>null!==e.error);s||w(t)},E=()=>{let e=0===b.length;v(t=>[...t,{id:crypto.randomUUID(),value:"",type:"MOBILE",isPrimary:e,error:null}])},D=e=>{let t=b[e].isPrimary,s=b.filter((t,s)=>s!==e),n=t&&s.length>0?s.map((e,t)=>0===t?{...e,isPrimary:!0}:e):s;if(v(n),h)return;let a=n.some(e=>""!==e.value.trim()&&null!==e.error);a||w(n)},A=async()=>{let e=b.filter(e=>""!==e.value.trim()),t=b.map(e=>""===e.value.trim()?e:{...e,error:(0,d.wm)(e.value)});if(t.some(e=>null!==e.error)){v(t);return}y(!0);try{await u((0,d.y3)(e))}finally{y(!1)}},T=()=>{v((0,d.wG)(s)),null==f||f()},L=!!p,_=x||j||L;return(0,n.jsxs)(c.z,{layout:g,stackedClassName:"space-y-2",label:(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(r.__J,{className:"inline"===g?(0,c.y)(g):void 0,children:m}),L&&p&&(0,n.jsx)(o.f,{reason:p})]}),children:[(0,n.jsx)("div",{className:"space-y-2",children:b.map((e,s)=>(0,n.jsx)(i.l,{value:e.value,type:e.type,isPrimary:e.isPrimary,error:null!==(t=e.error)&&void 0!==t?t:void 0,disabled:_,canRemove:b.length>1,onValueChange:e=>C(s,e),onBlur:()=>k(s),onTypeChange:e=>I(s,e),onSetPrimary:()=>S(s),onRemove:()=>D(s)},e.id))}),(0,n.jsxs)(r.zxk,{type:"button",variant:"outline",size:"sm",onClick:E,disabled:_,className:"mt-1",children:[(0,n.jsx)(l.Z,{className:"h-4 w-4 mr-1"}),"Add Phone"]}),h&&(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-stroke-soft-200",children:[(0,n.jsx)(r.zxk,{type:"button",variant:"ghost",size:"sm",onClick:T,disabled:j,className:"h-8",children:"Cancel"}),(0,n.jsx)(r.zxk,{type:"button",size:"sm",onClick:A,disabled:_,className:"h-8",children:"Save"})]})]})}},987950:function(e,t,s){s.d(t,{f:function(){return r}});var n=s(785893),a=s(545977),l=s(14066);function r(e){let{reason:t}=e;return(0,n.jsx)(l.pnl,{children:(0,n.jsxs)(l.ua7,{children:[(0,n.jsx)(l.aJU,{asChild:!0,children:(0,n.jsx)(a.Z,{className:"h-3.5 w-3.5 text-text-soft-400 cursor-help","aria-label":"Locked field"})}),(0,n.jsx)(l._vU,{side:"top",className:"max-w-xs",children:t})]})})}},144631:function(e,t,s){s.d(t,{y:function(){return l},z:function(){return r}});var n=s(785893),a=s(807490);let l=e=>"inline"===e?"text-xs font-medium text-text-sub-600 leading-tight break-words":"text-sm font-medium text-text-strong-950";function r(e){let{id:t,layout:s="stacked",label:l,children:r,stackedClassName:i="space-y-1.5"}=e;return"inline"===s?(0,n.jsxs)("div",{id:t,className:"flex items-start gap-3",children:[(0,n.jsx)("div",{className:"flex min-h-10 w-32 shrink-0 items-center",children:l}),(0,n.jsx)("div",{className:(0,a.cn)("min-w-0 flex-1",i),children:r})]}):(0,n.jsxs)("div",{id:t,className:i,children:[l,r]})}},847090:function(e,t,s){s.d(t,{Gf:function(){return r.G},Lu:function(){return a.L},af:function(){return i.a},fJ:function(){return n.f},nq:function(){return l.n}});var n=s(377296),a=s(450598),l=s(398069),r=s(269061),i=s(904068)},582822:function(e,t,s){s.d(t,{$A:function(){return l},wG:function(){return a},wm:function(){return i},y3:function(){return r}});var n=s(807490);function a(e){var t;return e.map(e=>({id:crypto.randomUUID(),value:e.value,type:null!==(t=e.type)&&void 0!==t?t:"WORK",isPrimary:e.isPrimary,error:null}))}function l(e,t){let s=a(e);return t&&0===s.length?[{id:crypto.randomUUID(),value:"",type:"MOBILE",isPrimary:!0,error:null}]:s}function r(e){return e.map(e=>({value:e.value,type:e.type,isPrimary:e.isPrimary}))}function i(e){var t,s;let a=n.IB.shape.value.safeParse(e.trim());return a.success?null:null!==(s=null===(t=a.error.issues[0])||void 0===t?void 0:t.message)&&void 0!==s?s:"Invalid phone number"}},450598:function(e,t,s){s.d(t,{L:function(){return o}});var n=s(785893),a=s(807490),l=s(14066),r=s(576282),i=s(144631);function o(e){let{id:t,label:s,value:o,options:c,onSave:d,placeholder:u="Select tags...",isHighlighted:m=!1,disabled:x=!1,layout:p="stacked"}=e,h=e=>{d(e)};return(0,n.jsx)(i.z,{id:"field-".concat(t),layout:p,label:(0,n.jsx)(l.__J,{className:(0,a.cn)((0,i.y)(p),m&&"animate-label-blink"),
1children:s}),children:(0,n.jsx)(r.N,{options:c,selected:o,onChange:h,placeholder:u,disabled:x})})}},533057:function(e,t,s){s.d(t,{e:function(){return d}});var n=s(785893),a=s(667294),l=s(14066),r=s(633958);function i(e){let{value:t,onChange:s,label:i,placeholder:o="Select account or type new company...",error:c,disabled:d=!1,required:u=!1,allowClear:m=!0,className:x,initialAccountName:p}=e,{options:h,isLoading:f,setSearch:g,accounts:b}=(0,r.g)(),[v,j]=(0,a.useState)(null!=p?p:null);(0,a.useEffect)(()=>{p&&j(p)},[p]);let y=(0,a.useMemo)(()=>{if(!t.accountId||!v)return h;let e=h.some(e=>e.value===t.accountId);return e?h:[{value:t.accountId,label:v},...h]},[h,t.accountId,v]),N=(0,a.useMemo)(()=>t.accountId?t.accountId:t.company?t.company:null,[t.accountId,t.company]),w=e=>{if(g(""),!e){j(null),s({accountId:null,accountName:null,company:null});return}let t=null==b?void 0:b.find(t=>t.id===e);t?(j(t.name),s({accountId:t.id,accountName:t.name,company:null})):(j(null),s({accountId:null,accountName:null,company:e}))},C=e=>{j(null),s({accountId:null,accountName:null,company:e})},k=e=>{g(e)};return(0,n.jsxs)("div",{className:x,children:[i&&(0,n.jsxs)(l.__J,{className:"mb-2",children:[i,u&&(0,n.jsx)("span",{className:"text-state-error-default ml-0.5",children:"*"})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(l.a7y,{options:y,value:N,onChange:w,onCreate:C,onSearchChange:k,placeholder:o,searchPlaceholder:"Search accounts...",emptyMessage:f?"Loading...":"No accounts found",noOptionsMessage:f?"Loading...":"Type to search accounts",createLabel:e=>'Add "'.concat(e,'" as new company'),allowCreate:!0,allowClear:m,disabled:d}),c&&(0,n.jsx)("p",{className:"text-xs text-state-error-default",children:c})]})]})}function o(e){let{selectedId:t,onSelectId:s,label:i,placeholder:o="Select an account...",error:c,disabled:d=!1,required:u=!1,allowClear:m=!0,prefilledAccountName:x,selectedLabel:p,className:h}=e,{options:f,isLoading:g,setSearch:b}=(0,r.g)(),v=(0,a.useMemo)(()=>!t||!p||f.some(e=>e.value===t)?f:[{value:t,label:p},...f],[f,t,p]);if(x)return(0,n.jsxs)("div",{className:h,children:[i&&(0,n.jsxs)(l.__J,{className:"mb-2",children:[i,u&&(0,n.jsx)("span",{className:"text-state-error-default ml-0.5",children:"*"})]}),(0,n.jsx)("div",{className:"h-10 px-3 py-2 rounded-md border border-input bg-bg-soft-50 text-sm flex items-center",children:x})]});let j=e=>{b(""),s(e)};return(0,n.jsxs)("div",{className:h,children:[i&&(0,n.jsxs)(l.__J,{className:"mb-2",children:[i,u&&(0,n.jsx)("span",{className:"text-state-error-default ml-0.5",children:"*"})]}),(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(l.VcW,{options:v,value:t,onChange:j,onSearchChange:b,placeholder:o,searchPlaceholder:"Search accounts...",emptyMessage:"No accounts found",isLoading:g,disabled:d,allowClear:m}),c&&(0,n.jsx)("p",{className:"text-xs text-state-error-default",children:c})]})]})}function c(e){let{toggleOption:t,onToggleChange:s,selectedId:i,onSelectId:o,newEntityName:c,onNewEntityNameChange:d,label:u,placeholder:m="Select an account",error:x,disabled:p=!1,className:h,selectedLabel:f}=e,{options:g,isLoading:b,setSearch:v}=(0,r.g)(),j=(0,a.useMemo)(()=>{if(!i||!f)return g;let e=g.some(e=>e.value===i);return e?g:[{value:i,label:f},...g]},[g,i,f]),y=e=>{v(""),o(e)};return(0,n.jsxs)("div",{className:h,children:[u&&(0,n.jsx)(l.__J,{className:"mb-2",children:u}),(0,n.jsxs)("div",{className:"space-y-3",children:[(0,n.jsxs)("div",{className:"flex gap-4",children:[(0,n.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,n.jsx)("input",{type:"radio",name:"accountOption",checked:"CREATE_NEW"===t,onChange:()=>s("CREATE_NEW"),disabled:p,className:"h-4 w-4 text-brand-primary border-stroke-soft-200 focus:ring-brand-primary"}),(0,n.jsx)("span",{className:"text-sm text-text-strong-950",children:"Create New"})]}),(0,n.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,n.jsx)("input",{type:"radio",name:"accountOption",checked:"EXISTING"===t,onChange:()=>s("EXISTING"),disabled:p,className:"h-4 w-4 text-brand-primary border-stroke-soft-200 focus:ring-brand-primary"}),(0,n.jsx)("span",{className:"text-sm text-text-strong-950",children:"Choose Existing"})]})]}),"CREATE_NEW"===t?(0,n.jsx)(l.IIB,{value:c,onChange:e=>null==d?void 0:d(e.target.value),placeholder:"Enter company name",disabled:p}):(0,n.jsxs)("div",{className:"space-y-1",children:[(0,n.jsx)(l.VcW,{options:j,value:i,onChange:y,onSearchChange:v,placeholder:m,emptyMessage:"No accounts found",isLoading:b,disabled:p}),x&&(0,n.jsx)("p",{className:"text-xs text-state-error-default",children:x})]})]})]})}function d(e){switch(e.mode){case"creatable":return(0,n.jsx)(i,{...e});case"searchable":return(0,n.jsx)(o,{...e});case"toggle":return(0,n.jsx)(c,{...e});default:return null}}},510824:function(e,t,s){s.d(t,{e:function(){return n.e}});var n=s(533057);s(633958)},633958:function(e,t,s){s.d(t,{g:function(){return l}});var n=s(667294),a=s(407800);function l(){let e=arguments.length>
10&&void 0!==arguments[0]?arguments[0]:"",[t,s]=(0,n.useState)(e),[l,r]=(0,n.useState)(e),[i,o]=(0,n.useState)(new Map);(0,n.useEffect)(()=>{let e=setTimeout(()=>{r(t)},300);return()=>clearTimeout(e)},[t]);let{data:c,isLoading:d}=(0,a.EC)(l);(0,n.useEffect)(()=>{c&&o(e=>{let t=new Map(e);return c.forEach(e=>{t.set(e.id,{value:e.id,label:e.name})}),t})},[c]);let u=(0,n.useMemo)(()=>{var e;let t=Array.from(i.values());if(!l.trim())return t;let s=l.toLowerCase();return t.filter(t=>(null!==(e=t.label)&&void 0!==e?e:"").toLowerCase().includes(s))},[i,l]);return{options:u,isLoading:d,search:t,setSearch:s,accounts:c}}},467223:function(e,t,s){s.d(t,{$:function(){return r}});var n=s(785893),a=s(554976),l=s(807490);function r(e){let{predictions:t,activeIndex:s,onHover:r,onSelect:i}=e;return 0===t.length?null:(0,n.jsx)("ul",{role:"listbox",onMouseDown:e=>e.preventDefault(),className:"absolute z-50 mt-1 max-h-60 w-full overflow-y-auto overscroll-contain rounded-lg border border-stroke-soft-200 bg-white shadow-lg",children:t.map((e,t)=>(0,n.jsx)("li",{role:"option","aria-selected":t===s,children:(0,n.jsxs)("button",{type:"button",onMouseEnter:()=>r(t),onClick:()=>i(e.placeId),className:(0,l.cn)("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors",t===s?"bg-bg-weak-50":"bg-white"),children:[(0,n.jsx)(a.Z,{className:"mt-0.5 h-4 w-4 shrink-0 text-text-soft-400"}),(0,n.jsxs)("span",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"block truncate text-sm text-text-strong-950",children:e.mainText}),e.secondaryText&&(0,n.jsx)("span",{className:"block truncate text-xs text-text-sub-600",children:e.secondaryText})]})]})},e.placeId))})}},983689:function(e,t,s){s.d(t,{$:function(){return n.$}});var n=s(467223)},370129:function(e,t,s){s.d(t,{x:function(){return m}});var n=s(785893),a=s(741664),l=s.n(a),r=s(811163),i=s(53219),o=s(807490);let c="flex flex-row items-center gap-1.5 hover:opacity-70 transition-opacity";function d(){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Z,{className:"w-5 h-5 text-text-sub-600",strokeWidth:1.5}),(0,n.jsx)("span",{className:"font-medium text-sm leading-5 text-text-sub-600 tracking-[-0.006em]",children:"Back"})]})}function u(e){let{onClick:t}=e,s=(0,r.useRouter)(),a=()=>{t?t():s.back()};return(0,n.jsx)("button",{type:"button",onClick:a,className:c,children:(0,n.jsx)(d,{})})}function m(e){let{className:t,onClick:s,href:a}=e;return(0,n.jsx)("div",{className:(0,o.cn)("flex flex-col items-start justify-center","w-full h-10","px-8 py-2.5","bg-white",t),children:a?(0,n.jsx)(l(),{href:a,className:c,children:(0,n.jsx)(d,{})}):(0,n.jsx)(u,{onClick:s})})}},228001:function(e,t,s){s.d(t,{f:function(){return r}});var n=s(407800),a=s(676379),l=s(323843);function r(e,t,s){if(s)return s;switch(e){case"account":return n.pL.accountDetail(t);case"contact":return n.pL.contactDetail(t);case"sale":return a.H.saleDetail(t);case"lead":return l.jd.lead(t);default:return["unknown"]}}},117329:function(e,t,s){s.d(t,{K7:function(){return g},Nm:function(){return f},SR:function(){return m},Tb:function(){return d},g2:function(){return x},ki:function(){return h},kl:function(){return u}});var n=s(209194),a=s(105019),l=s(313766),r=s(399801),i=s(375283),o=s(995554),c=s(266784);let d=2147483648,u="2GB",m=3,x="*",p=new Set(["exe","bat","cmd","com","msi","scr","sh","bash","app","dmg","pkg","deb","rpm","jar","vbs","js","ps1","dll","sys"]);function h(e){let t=e.name.toLowerCase().split(".");if(t.length<2)return!1;let s=t[t.length-1];return p.has(s)}function f(e){if(!e)return"unknown";let t=e.toLowerCase();return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"application/pdf"===t?"pdf":t.includes("word")||t.includes("msword")?"word":t.includes("excel")||t.includes("spreadsheet")||t.includes("xml")?"excel":"text/csv"===t?"csv":t.startsWith("text/")?"text":"unknown"}let g={image:{icon:i.Z,bg:"bg-purple-100",text:"text-purple-600",label:"IMG"},pdf:{icon:l.Z,bg:"bg-red-100",text:"text-red-600",label:"PDF"},word:{icon:r.Z,bg:"bg-blue-100",text:"text-blue-600",label:"DOC"},excel:{icon:a.Z,bg:"bg-green-100",text:"text-green-600",label:"XLS"},csv:{icon:a.Z,bg:"bg-green-50",text:"text-green-700",label:"CSV"},video:{icon:c.Z,bg:"bg-orange-100",text:"text-orange-600",label:"VID"},audio:{icon:o.Z,bg:"bg-yellow-100",text:"text-yellow-600",label:"AUD"},text:{icon:l.Z,bg:"bg-gray-100",text:"text-gray-600",label:"TXT"},unknown:{icon:n.Z,bg:"bg-gray-100",text:"text-gray-500",label:"FILE"}}},368135:function(e,t,s){s.d(t,{j:function(){return m}});var n=s(785893),a=s(667294),l=s(313025),r=s(613718),i=s(636316),o=s(14066),c=s(807490),d=s(970112),u=s(117329);function m(e){let{file:t,onDelete:s,onPreview:m,isReadOnly:x=!1,isDeleting:p=!1,actions:h}=e,f=(0,u.Nm)(t.type),g=u.K7[f],b=g.icon,v=(0,a.useCallback)(()=>
1{if(("image"===f||"pdf"===f)&&m){m(t);return}window.open(t.url,"_blank","noopener,noreferrer")},[f,t,m]),j=(0,a.useCallback)(e=>{e.stopPropagation(),(0,c.kB)(t.url,t.name)},[t.url,t.name]),y=(0,a.useCallback)(e=>{e.stopPropagation(),null==s||s(t.id,t.activityId)},[t.id,t.activityId,s]);return(0,n.jsxs)("div",{className:"group relative flex items-center gap-3 p-3 rounded-lg border border-stroke-soft-200 bg-bg-white-0 hover:bg-bg-soft-50 transition-colors",children:[(0,n.jsxs)("button",{type:"button",onClick:v,className:"flex items-center gap-3 flex-1 min-w-0 text-left",children:[(0,n.jsx)("div",{className:(0,c.cn)("flex items-center justify-center h-9 w-9 rounded-lg shrink-0",g.bg),children:(0,n.jsx)(b,{className:(0,c.cn)("h-4 w-4",g.text)})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block text-sm font-medium text-text-strong-950 truncate",children:t.name}),t.size&&(0,n.jsx)("span",{className:"text-xs text-text-soft-400",children:(0,d.sS)(t.size)})]})]}),(0,n.jsx)(o.zxk,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:j,title:"Download",children:(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-text-strong-950"})}),h,!x&&s&&(0,n.jsx)(o.zxk,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",disabled:p,onClick:y,children:p?(0,n.jsx)(i.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(r.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-red-500"})})]})}},882653:function(e,t,s){s.d(t,{J:function(){return d}});var n=s(785893),a=s(667294),l=s(313025),r=s(718814),i=s(14066),o=s(807490),c=s(117329);function d(e){let{file:t,onClose:s}=e,d=t?(0,c.Nm)(t.type):"unknown",u=(0,a.useRef)(null),m=(0,a.useCallback)(()=>{t&&window.open(t.url,"_blank","noopener,noreferrer")},[t]),x=(0,a.useCallback)(()=>{t&&(0,o.kB)(t.url,t.name)},[t]),p=(0,a.useCallback)(()=>{t&&window.open(t.url,"_blank","noopener,noreferrer"),s()},[t,s]);(0,a.useEffect)(()=>{if("pdf"===d)return u.current=setTimeout(p,4e3),()=>{u.current&&(clearTimeout(u.current),u.current=null)}},[d,p]);let h=(0,a.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]);return(0,n.jsx)(i.VqE,{open:!!t,onOpenChange:e=>!e&&s(),children:t&&(0,n.jsxs)(i.cZJ,{className:"max-w-[90vw] max-h-[90vh] p-0 overflow-hidden flex flex-col gap-0",children:[(0,n.jsxs)(i.fKu,{className:"flex-row items-center justify-between gap-3 border-b border-stroke-soft-200 px-4 py-3 pr-12 space-y-0",children:[(0,n.jsx)(i.$N8,{className:"truncate text-sm font-medium text-text-strong-950",children:t.name}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,n.jsxs)(i.zxk,{variant:"outline",size:"sm",onClick:x,className:"gap-1.5",children:[(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5"}),"Download"]}),(0,n.jsxs)(i.zxk,{variant:"outline",size:"sm",onClick:m,className:"gap-1.5",children:[(0,n.jsx)(r.Z,{className:"h-3.5 w-3.5"}),"Open in new tab"]})]})]}),(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center overflow-auto bg-bg-soft-100",children:"image"===d?(0,n.jsx)("img",{src:t.url,alt:t.name,className:"max-h-[80vh] max-w-full object-contain",onError:p}):(0,n.jsx)("iframe",{src:t.url,title:t.name,className:"h-[80vh] w-full border-0",onLoad:h})})]})})}},987821:function(e,t,s){s.d(t,{c:function(){return m}});var n=s(785893),a=s(667294),l=s(950582),r=s(808971),i=s(884979),o=s(368135),c=s(882653),d=s(942878),u=s(117329);function m(e){let{files:t,initialLimit:s=u.SR,onDelete:m,isReadOnly:x=!1,deletingFileId:p}=e,[h,f]=(0,a.useState)(!1),[g,b]=(0,a.useState)(null),v=(0,a.useMemo)(()=>t.map(d.g),[t]),j=h||0===s?v:v.slice(0,s),y=s>0&&v.length>s,N=v.length-s;return 0===v.length?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,n.jsx)("div",{className:"p-3 bg-bg-soft-100 rounded-full mb-3",children:(0,n.jsx)(l.Z,{className:"w-6 h-6 text-text-soft-400"})}),(0,n.jsx)("p",{className:"text-sm font-medium text-text-strong-950",children:"No files"}),(0,n.jsx)("p",{className:"text-xs text-text-sub-600 mt-1",children:"Click upload to add files"}),(0,n.jsxs)("p",{className:"text-xs text-text-soft-400 mt-1",children:["Most file types supported (max ",u.kl,")"]})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[j.map(e=>(0,n.jsx)(o.j,{file:e,onDelete:m,onPreview:b,isReadOnly:x,isDeleting:p===e.id},e.id)),(0,n.jsx)(c.J,{file:g,onClose:()=>b(null)}),y&&(0,n.jsx)("button",{type:"button",onClick:()=>f(!h),className:"w-full flex items-center justify-center gap-1.5 py-2 mt-1 text-sm text-brand-primary hover:text-brand-primary/80 font-medium rounded-md hover:bg-brand-primary-alpha-10 transition-colors",children:h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Z,{className:"h-4 w-4"}),"Show less"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.Z,{className:"h-4 w-4"}),"View ",N," more ",1===N?"file":"files"]})})]})}},276630:function(e,t,s){s.d(t,{P:function(){return v}});var n=s(785893),a=s(667294),l=s(430202),r=s(720249),i=s(950582),o=s(428142),c=s(636316),d=s(808971),u=s(14066),m=s(407800),x=s(829971),p=s(363548),h=s(987821),f=s(117329),g=s(228001);
1function b(e){e.invalidateQueries({queryKey:m.pL.accountActivitiesPaginatedPrefix})}function v(e){var t;let{entityType:s,entityId:v,files:j=[],initialLimit:y=f.SR,isReadOnly:N=!1,className:w,queryKeyToInvalidate:C}=e,[k,I]=(0,a.useState)(!0),[S,E]=(0,a.useState)(null),D=(0,a.useRef)(null),{toast:A}=(0,m.pm)(),T=function(e,t,s,n){let a=(0,l.NL)(),{toast:i}=(0,m.pm)();return(0,r.D)({mutationFn:async s=>{let a=[],l=s.reduce((e,t)=>e+t.size,0),r=0;for(let e of s){let t=await x.Zc.getUploadUrl(e.name);await x.Zc.uploadFileToS3(e,t.uploadUrl,e=>{l>0&&(null==n||n(Math.min(100,Math.round((r+e.loaded)/l*100))))}),r+=e.size,a.push({id:t.attachmentId,fileName:t.fileName,fileSize:e.size,contentType:e.type,s3Key:t.s3Key})}await x.Zc.createFileAttachment(e,t,a)},onSuccess:(n,l)=>{a.invalidateQueries({queryKey:(0,g.f)(e,t,s)}),b(a),i({title:"Success",description:"".concat(l.length," file").concat(l.length>1?"s":""," uploaded successfully")})},onError:e=>{i({title:"Upload Failed",description:e.message||"Failed to upload files. Please try again.",variant:"destructive"})}})}(s,v,C,E),L=function(e,t,s){let n=(0,l.NL)(),{toast:a}=(0,m.pm)();return(0,r.D)({mutationFn:e=>{let{activityId:t,attachmentId:s}=e;return t?x.Zc.deleteAttachment(t,s):x.Zc.deleteActivity(s)},onSuccess:()=>{n.invalidateQueries({queryKey:(0,g.f)(e,t,s)}),b(n),a({title:"Success",description:"File deleted successfully"})},onError:e=>{a({title:"Delete Failed",description:e.message||"Failed to delete file. Please try again.",variant:"destructive"})}})}(s,v,C),_=(0,a.useCallback)((e,t)=>{L.mutate({activityId:t,attachmentId:e})},[L]),O=(0,a.useCallback)(()=>{var e;I(!0),null===(e=D.current)||void 0===e||e.click()},[]),P=(0,a.useCallback)(async e=>{let t=e.target.files;if(!t||0===t.length)return;let s=Array.from(t);e.target.value="";let{valid:n,errors:a}=function(e){let t=[],s=[];for(let n of e){if((0,f.ki)(n)){s.push("".concat(n.name,": This file type is not allowed"));continue}if(n.size>f.Tb){s.push("".concat(n.name,": File exceeds ").concat(f.kl," limit"));continue}t.push(n)}return{valid:t,errors:s}}(s);if(a.length>0&&A({title:"Some files were not uploaded",description:a.join("\n"),variant:"destructive"}),n.length>0){E(0);try{await T.mutateAsync(n)}catch(e){}finally{E(null)}}},[T,A]),Z=T.isPending;return(0,n.jsx)(u.zF9,{open:k,onOpenChange:I,children:(0,n.jsxs)("div",{className:(0,p.cn)("border border-stroke-soft-200 rounded-xl overflow-hidden bg-bg-white-0",w),children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 bg-bg-white-0",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>I(!k),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,n.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-blue-50",children:(0,n.jsx)(i.Z,{className:"w-4 h-4 text-blue-500"})}),(0,n.jsx)("span",{className:"text-sm font-medium text-text-strong-950",children:"Files"}),(0,n.jsx)(d.Z,{className:(0,p.cn)("w-4 h-4 text-text-soft-400 transition-transform duration-200",k&&"rotate-180")})]}),(0,n.jsx)("input",{ref:D,type:"file",accept:f.g2,multiple:!0,className:"hidden",onChange:P,disabled:Z}),!N&&(0,n.jsx)(u.zxk,{variant:"ghost",size:"sm",onClick:O,disabled:Z,className:"h-7 gap-1 text-text-sub-600 hover:text-text-strong-950",children:Z?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 animate-spin"}),null!==S?"Uploading... ".concat(S,"%"):"Uploading..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Z,{className:"h-4 w-4"}),"Upload"]})})]}),(0,n.jsx)(u.FwI,{children:(0,n.jsx)("div",{className:"border-t border-stroke-soft-200 p-3 max-h-[280px] overflow-y-auto",children:(0,n.jsx)(h.c,{files:j,initialLimit:y,onDelete:_,isReadOnly:N,deletingFileId:L.isPending?null===(t=L.variables)||void 0===t?void 0:t.attachmentId:void 0})})})]})})}},90873:function(e,t,s){s.d(t,{P6:function(){return n.P}});var n=s(276630);s(987821),s(368135),s(117329)},942878:function(e,t,s){s.d(t,{g:function(){return n}});function n(e){var t,s,n,a;return"fileName"in e&&"fileUrl"in e?{id:null!==(t=e.id)&&void 0!==t?t:"",name:null!==(s=e.fileName)&&void 0!==s?s:"",type:null!==(n=e.fileType)&&void 0!==n?n:"",size:null,url:null!==(a=e.fileUrl)&&void 0!==a?a:"",uploadedAt:null}:{id:e.id,activityId:e.activityId,name:e.name,type:e.type,size:e.size,url:e.url,uploadedAt:e.uploadedAt}}},253635:function(e,t,s){s.d(t,{b:function(){return c}});var n=s(785893),a=s(667294),l=s(14066),r=s(558068),i=s(982201),o=s(983689);function c(e){let{prefix:t,register:s,errors:c,enableAutocomplete:d=!1,defaultCountryCode:u=null,setValue:m}=e,x=e=>{var s;let n=null==c?void 0:c[t];return null==n?void 0:null===(s=n[e])||void 0===s?void 0:s.message},{setInput:p,predictions:h,selectPrediction:f}=(0,r.a)({countryCode:u}
1),[g,b]=(0,a.useState)(-1),[v,j]=(0,a.useState)(!1),y=d&&!v&&h.length>0,N=(e,s)=>null==m?void 0:m("".concat(t,".").concat(e),s,{shouldDirty:!0}),w=async e=>{let t=await f(e);if(t){for(let[e,s]of Object.entries((0,i.I)(t)))N(e,s);j(!0),b(-1)}},C=s("".concat(t,".addressLine1"),{...d?{onChange:e=>{N("placeId",""),N("displayName",""),j(!1),b(-1),p(e.target.value)},onBlur:()=>{j(!0),b(-1)}}:{}});return(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"Address Line 1"}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)(l.IIB,{placeholder:"123 Main Street",autoComplete:d?"off":void 0,...C,error:x("addressLine1")}),y&&(0,n.jsx)(o.$,{predictions:h,activeIndex:g,onHover:b,onSelect:e=>void w(e)})]})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"Address Line 2"}),(0,n.jsx)(l.IIB,{placeholder:"Suite 100",...s("".concat(t,".addressLine2")),error:x("addressLine2")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"City"}),(0,n.jsx)(l.IIB,{placeholder:"New York",...s("".concat(t,".city")),error:x("city")})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"State"}),(0,n.jsx)(l.IIB,{placeholder:"NY",...s("".concat(t,".state")),error:x("state")})]})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"ZIP Code"}),(0,n.jsx)(l.IIB,{placeholder:"10001",...s("".concat(t,".zip")),error:x("zip")})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"Country"}),(0,n.jsx)(l.IIB,{placeholder:"United States",...s("".concat(t,".country")),error:x("country")})]})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"County"}),(0,n.jsx)(l.IIB,{placeholder:"County",...s("".concat(t,".county")),error:x("county")})]}),(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"Latitude"}),(0,n.jsx)(l.IIB,{placeholder:"Latitude",...s("".concat(t,".lat")),error:x("lat")})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)(l.__J,{children:"Longitude"}),(0,n.jsx)(l.IIB,{placeholder:"Longitude",...s("".concat(t,".long")),error:x("long")})]})]})]})}},398585:function(e,t,s){s.d(t,{b:function(){return n.b}});var n=s(253635)},390835:function(e,t,s){s.d(t,{l:function(){return c}});var n=s(785893),a=s(667294),l=s(809560),r=s(541352),i=s(14066),o=s(807490);let c=(0,a.memo)(function(e){let{value:t,type:s,isPrimary:a,error:c,disabled:d=!1,canRemove:u=!0,onValueChange:m,onBlur:x,onTypeChange:p,onSetPrimary:h,onRemove:f}=e;return(0,n.jsxs)("div",{className:"grid grid-cols-[minmax(88px,100px)_minmax(0,1fr)_auto_auto] items-start gap-2 max-sm:grid-cols-[minmax(88px,100px)_minmax(0,1fr)]",children:[(0,n.jsxs)(i.PhF,{value:s,onValueChange:e=>p(e),disabled:d,children:[(0,n.jsx)(i.i4d,{className:"w-[100px] shrink-0 h-10 text-sm",children:(0,n.jsx)(i.kik,{})}),(0,n.jsx)(i.Bwz,{className:"z-[1100]",children:o.Fh.map(e=>(0,n.jsx)(i.QlF,{value:e.value,children:e.label},e.value))})]}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:(0,n.jsx)(i.IIB,{type:"tel",placeholder:"555-123-4567",value:t,onChange:e=>m((0,o.un)(e.target.value)),onBlur:x,disabled:d,error:c,className:"h-10 text-sm"})}),(0,n.jsxs)(i.pnl,{delayDuration:150,children:[(0,n.jsxs)(i.ua7,{children:[(0,n.jsx)(i.aJU,{asChild:!0,children:(0,n.jsx)("button",{type:"button",onClick:h,disabled:d,"aria-label":a?"Primary phone ".concat(t||"number"):"Set ".concat(t||"phone number"," as primary"),"aria-pressed":a,className:(0,o.cn)("mt-2 shrink-0 transition-colors max-sm:col-start-1 max-sm:row-start-2 max-sm:justify-self-start",a?"text-yellow-500":"text-gray-300 hover:text-yellow-400"),children:(0,n.jsx)(l.Z,{className:"h-4 w-4",fill:a?"currentColor":"none"})})}),(0,n.jsx)(i._vU,{children:a?"Primary phone":"Set as primary"})]}),(0,n.jsxs)(i.ua7,{children:[(0,n.jsx)(i.aJU,{asChild:!0,children:(0,n.jsx)(i.zxk,{type:"button",variant:"ghost",size:"icon",onClick:f,disabled:d||!u,className:"shrink-0 h-9 w-9 mt-0.5","aria-label":"Remove ".concat(t||"phone number"),children:(0,n.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,n.jsx)(i._vU,{children:"Remove phone"})]})]})]})})},686181:function(e,t,s){s.d(t,{G$N:function(){return o.G$},IzZ:function(){return l.I},J2e:function(){return m.J2e},OkG:function(){return r.O},P6F:function(){return c.P6},TTj:function(){return o.TT},VcW:function(){return m.VcW},W0U:function(){return d.W0},XT8:function(){return i.X},XZJ:function(){return m.XZJ},Xgh:function(){return n.Xg},_vU:function(){return m._vU},aJU:function(){return m.aJU},eTj:function(){return u.e}
1,pnl:function(){return m.pnl},s1R:function(){return m.s1R},ua7:function(){return m.ua7},xEo:function(){return a.x},xol:function(){return m.xol},yky:function(){return m.yky},zxk:function(){return m.zxk}});var n=s(464745);s(47372);var a=s(370129),l=s(339414),r=s(262964);s(398585);var i=s(24661),o=s(334474),c=s(90873),d=s(385305),u=s(510824),m=s(14066);s(269789)},47372:function(e,t,s){s(785893),s(673124)},674825:function(e,t,s){s.d(t,{M:function(){return u}});var n=s(785893),a=s(667294),l=s(373510),r=s(956989),i=s(762888),o=s(14066),c=s(281556),d=s(117462);function u(e){let{accountId:t,pinned:s,value:u,onChange:m,disabled:x}=e,{data:p,isLoading:h,isError:f,refetch:g}=(0,d.gW)({accountId:t,page:1,pageSize:200},Boolean(t)),b=(0,a.useMemo)(()=>{var e,t;let n=(null!==(e=null==p?void 0:p.content)&&void 0!==e?e:[]).map(e=>({value:e.id,label:e.contactPerson||[e.firstName,e.lastName].filter(Boolean).join(" ")||"Unnamed contact",tag:null!==(t=e.title)&&void 0!==t?t:void 0}));return s&&!n.some(e=>e.value===s.id)&&n.unshift({value:s.id,label:s.name,tag:void 0}),n},[p,s]),v=e=>m(s&&!e.includes(s.id)?[s.id,...e]:e);return(0,n.jsxs)("div",{className:"space-y-1.5",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-text-sub-600",children:"Contacts"}),(0,n.jsx)(c.pn,{children:(0,n.jsxs)(c.u,{children:[(0,n.jsx)(c.aJ,{asChild:!0,children:(0,n.jsx)("button",{type:"button","aria-label":"About contacts",className:"text-icon-soft-400 hover:text-icon-sub-600",children:(0,n.jsx)(r.Z,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(c._v,{side:"top",className:"max-w-xs",children:"Who at the customer this was with. It shows on each person's contact page as well as here."})]})})]}),t&&f?(0,n.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-state-error-lighter px-3 py-2 text-sm text-state-error",children:[(0,n.jsx)(l.Z,{className:"h-4 w-4 shrink-0"}),(0,n.jsx)("span",{className:"flex-1",children:"Couldn't load this account's contacts."}),(0,n.jsx)(o.zxk,{type:"button",variant:"ghost",size:"sm","aria-label":"Retry loading contacts",onClick:()=>g(),children:(0,n.jsx)(i.Z,{className:"h-4 w-4"})})]}):(0,n.jsx)(o.csf,{options:b,selected:u,onChange:v,placeholder:"Add a contactâ¦",emptyMessage:t?"No contacts on this account.":"No account to pick contacts from.",emptyHint:"None picked â optional.",isLoading:Boolean(t)&&h,disabled:x})]})}},499112:function(e,t,s){s.d(t,{X:function(){return l},f:function(){return a.f}});var n=s(407800),a=s(228001);function l(e){e.invalidateQueries({queryKey:n.pL.accountNotesTimelinePrefix}),e.invalidateQueries({queryKey:n.pL.accountActivitiesPaginatedPrefix})}},924377:function(e,t,s){s.d(t,{c:function(){return a}});var n=s(785893);function a(e){let{message:t}=e;return t?(0,n.jsx)("p",{role:"alert",className:"-mt-1 text-xs text-state-error",children:t}):null}},334474:function(e,t,s){s.d(t,{G$:function(){return a.G},TT:function(){return n.T},pG:function(){return n.p}});var n=s(759860);s(171375);var a=s(535224);s(855527)},750417:function(e,t,s){s.d(t,{k:function(){return d}});var n=s(785893),a=s(956989),l=s(14066),r=s(191386),i=s(281556),o=s(847090),c=s(924377);function d(e){let{isJointCall:t,vendors:s,options:d,error:u,disabled:m,onJointCallChange:x,onVendorsChange:p}=e;return(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(r.X,{id:"interaction-joint-call",checked:t,disabled:m,onCheckedChange:e=>x(!0===e)}),(0,n.jsx)(l.__J,{htmlFor:"interaction-joint-call",className:"text-sm text-text-strong-950",children:"Joint call"}),(0,n.jsx)(i.pn,{children:(0,n.jsxs)(i.u,{children:[(0,n.jsx)(i.aJ,{asChild:!0,children:(0,n.jsx)("button",{type:"button","aria-label":"About joint calls",className:"text-icon-soft-400 hover:text-icon-sub-600",children:(0,n.jsx)(a.Z,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(i._v,{side:"top",className:"max-w-xs",children:"Tick when a vendor's rep came along. Pick the vendor so the call counts toward that vendor's joint sales calls."})]})})]}),t&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Lu,{id:"interaction-joint-call-vendors",label:"Vendor",value:s,options:d,placeholder:"Select the vendor who came along...",disabled:m,onSave:async e=>p(e)}),(0,n.jsx)(c.c,{message:u})]})]})}},535224:function(e,t,s){s.d(t,{G:function(){return g}});var n=s(785893),a=s(667294),l=s(430202),r=s(720249),i=s(14066),o=s(209023),c=s(407800),d=s(829971),u=s(499112),m=s(674825),x=s(949323),p=s(458057),h=s(46258),f=s(144786);function g(e){let{entityType:t,entityId:s,queryKeyToInvalidate:g,accountId:b,pinnedContact:v}=e,[j,y]=(0,a.useState)(null),[N,w]=(0,a.useState)([]),C=function(e,t,s){let n=(0,l.NL)(),{toast:a}=(0,c.pm)();return(0,r.D)({mutationFn:s=>d.Zc.createCall(e,t,s),onSuccess:()=>{n.invalidateQueries({queryKey:(0,u.f)(e,t,s)}),(0,u.X)(n),a({title:"Success",description:"Call logged successfully"})},onError:e=>{a({title:"Error",description:e.message||"Failed to log call",variant:"destructive"})}})}(t,s,g),k=(0,f.Y)(t,s,g),I=(0,a.useCallback)(e=>{w(v?[v.id]:[]),y(e)},[v]),S=(0,a.useCallback)(()=>y(null),[]),E=(0,a.useCallback)(async e=>{try{var t,s,n;await C.mutateAsync({subject:e.subject.trim(),description:(null===(t=e.description)||void 0===t?void 0:t.trim())||void 0,direction:e.direction,outcome:(null===(s=e.outcome)||void 0===s?void 0:s.trim())||void 0,phoneNumber:(null===(n=e.phoneNumber)||void 0===n?void 0:n.trim())||void 0,occurredOn:e.occurredOn,contactIds:N})}catch(e){return}S()},[S,N,C]),D=(0,a.useCallback)(async e=>{if(j&&"CALL"!==j){try{await k.mutateAsync((0,f.S)(j,e,N))}catch(e){return}S()}},[S,N,j,k]),A=(0,a.useRef)(null),T=(0,a.useCallback)(e=>{var t;(null===(t=A.current)||void 0===t?void 0:t.querySelector("[".concat(o.w5,"]")))&&e.preventDefault()},[]),L="CALL"===j?C.isPending:k.isPending,_=(0,n.jsx)(m.M,{accountId:null!=b?b:"account"===t?s:void 0,pinned:v,value:N,onChange:w,disabled:L});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x._,{onSelect:I}),(0,n.jsx)(i.yoO,{open:null!==j,onOpenChange:e=>{e||S()},children:(0,n.jsxs)(i.uei,{ref:A,side:"right",className:"w-full sm:max-w-md flex flex-col",onPointerDownOutside:T,onInteractOutside:T,children:[(0,n.jsx)(i.Tuv,{children:(0,n.jsx)(i.bCQ,{children:"CALL"===j?"Call":j?h.B4[j].title:""})}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto py-4",children:["CALL"===j&&(0,n.jsx)(p.Y,{isSubmitting:C.isPending,onSubmit:E,onCancel:S,contactsField:_}),j&&"CALL"!==j&&(0,n.jsx)(h.zC,{kind:j,isSubmitting:k.isPending,onSubmit:D,onCancel:S,contactsField:_},j)]})]})})]})}},949323:function(e,t,s){s.d(t,{_:function(){return u}});var n=s(785893),a=s(808971),l=s(556953),r=s(554976),i=s(319769),o=s(931012),c=s(266784),d=s(14066);function u(e){let{onSelect:t}=e;return(0,n.jsxs)(d.h_2,{children:[(0,n.jsx)(d.$FS,{asChild:!0,children:(0,n.jsxs)(d.zxk,{variant:"ghost",size:"sm",className:"h-7 gap-1 text-text-sub-600 hover:text-text-strong-950",children:[(0,n.jsx)(o.Z,{className:"h-4 w-4"}),"Log Activity",(0,n.jsx)(a.Z,{className:"h-3 w-3"})]})}),(0,n.jsxs)(d.AWV,{align:"end",children:[(0,n.jsxs)(d.Xiv,{onSelect:()=>t("CALL"),children:[(0,n.jsx)(i.Z,{className:"h-4 w-4 mr-2"}),"Call"]}),(0,n.jsxs)(d.Xiv,{onSelect:()=>t("ONLINE_MEETING"),children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 mr-2"}),"Online meeting"]}),(0,n.jsxs)(d.Xiv,{onSelect:()=>t("VISIT"),children:[(0,n.jsx)(r.Z,{className:"h-4 w-4 mr-2"}),"Visit"]}),(0,n.jsxs)(d.Xiv,{onSelect:()=>t("EMAIL"),children:[(0,n.jsx)(l.Z,{className:"h-4 w-4 mr-2"}),"Email"]})]})]})}},458057:function(e,t,s){s.d(t,{Y:function(){return x}});var n=s(785893),a=s(287536),l=s(563201),r=s(636316),i=s(541352),o=s(14066),c=s(209023),d=s(829971),u=s(46258),m=s(855527);function x(e){let{isSubmitting:t,onSubmit:s,onCancel:x,contactsField:p}=e,{register:h,handleSubmit:f,watch:g,setValue:b,formState:{isValid:v,isDirty:j}}=(0,a.cI)({resolver:(0,l.F)(m.aC),defaultValues:{subject:"",description:"",direction:d.kw.OUTBOUND,outcome:"",phoneNumber:"",occurredOn:(0,d.lr)()},mode:"onChange"});return(0,n.jsxs)("form",{"aria-label":"Log a call",onSubmit:f(s),className:"space-y-4",...(0,c.Ut)(j),children:[(0,n.jsx)(o.IIB,{placeholder:"Subject",...h("subject"),disabled:t,className:"h-9"}),(0,n.jsx)(u.$s,{value:g("occurredOn"),onChange:e=>b("occurredOn",e,{shouldValidate:!0,shouldDirty:!0}),disabled:t}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("select",{...h("direction"),disabled:t,className:u.Cl,children:[(0,n.jsx)("option",{value:d.kw.OUTBOUND,children:"Outbound"}),(0,n.jsx)("option",{value:d.kw.INBOUND,children:"Inbound"})]}),(0,n.jsx)(o.IIB,{placeholder:"Phone number",...h("phoneNumber"),disabled:t,className:"h-9 flex-1"})]}),(0,n.jsx)(o.IIB,{placeholder:"Outcome (e.g. Connected, Left voicemail, No answer)",...h("outcome"),disabled:t,className:"h-9"}),p,(0,n.jsx)("textarea",{placeholder:"Notes about the call...",...h("description"),disabled:t,className:u.dy}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(o.zxk,{type:"button",variant:"ghost",size:"sm",onClick:x,disabled:t,className:"h-8",children:[(0,n.jsx)(i.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(o.zxk,{type:"submit",size:"sm",disabled:!v||t,className:"h-8",children:t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):"Log Call"})]})]})}},46258:function(e,t,s){s.d(t,{$s:function(){return k},B4:function(){return C},Cl:function(){return w},dy:function(){return N},zC:function(){return I}});var n=s(785893),a=s(667294),l=s(287536),r=s(209023),i=s(563201),o=s(956989),c=s(636316),d=s(541352),u=s(14066),m=s(281556),x=s(829971),p=s(363548),h=s(847090),f=s(52916),g=s(125109),b=s(816080),v=s(750417),j=s(924377),y=s(855527);let N="w-full min-h-[80px] p-2 text-sm rounded-md border border-stroke-soft-200 bg-bg-white-0 resize-none focus:outline-none focus:ring-2 focus:ring-brand-primary focus:border-transparent disabled:opacity-50",w="h-9 flex-1 rounded-md border border-stroke-soft-200 bg-bg-white-0 px-2 text-sm focus:outline-none focus:ring-2 focus:ring-brand-primary disabled:opacity-50",C={VISIT:{title:"Log a visit",submit:"Log Visit",notes:"What happened on the visit..."},ONLINE_MEETING:{title:"Log an online meeting",submit:"Log Meeting",notes:"What was discussed..."},EMAIL:{title:"Log an email",submit:"Log Email",notes:"Paste or summarise the email..."}};function k(e){let{value:t,onChange:s,disabled:a}=e;return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"text-xs text-text-sub-600",children:"Date"}),(0,n.jsx)(m.pn,{children:(0,n.jsxs)(m.u,{children:[(0,n.jsx)(m.aJ,{asChild:!0,children:(0,n.jsx)("button",{type:"button","aria-label":"About the date",className:"text-icon-soft-400 hover:text-icon-sub-600",children:(0,n.jsx)(o.Z,{className:"h-3.5 w-3.5"})})}),(0,n.jsx)(m._v,{side:"top",className:"max-w-xs",children:"The day it happened. It is the date this shows under on the account timeline."})]})}),(0,n.jsx)(u.Blo,{value:(0,p._Z)(t),onChange:e=>s(e?(0,x.jJ)(e):""),maxDate:new Date,disabled:a,className:"h-9 w-44"})]})}function I(e){var t,s,o,m,p,I,S;let{kind:E,isSubmitting:D,onSubmit:A,onCancel:T,contactsField:L}=e,_=(0,a.useMemo)(()=>(0,i.F)((0,y.Ho)(E)),[E]),{register:O,handleSubmit:P,watch:Z,setValue:F,formState:{errors:R,isValid:z,isDirty:M}}=(0,l.cI)({resolver:_,mode:"onChange",defaultValues:{subject:"",occurredOn:(0,x.lr)(),description:"",location:"",link:"",direction:"SENT",addresses:"",tags:[],isJointCall:!1,jointCallVendors:[]}}),U=Z("occurredOn"),B=Z("direction"),V=C[E],J=Z("tags"),{data:W}=(0,f.us)(),G=(0,a.useMemo)(()=>(null!=W?W:[]).map(e=>({value:e.name,label:e.name})),[W]),{user:Q}=(0,b.Z)(),H=Z("isJointCall"),K=Z("jointCallVendors"),q=(0,a.useMemo)(()=>{var e;return(0,g.G)((null!=W?W:[]).map(e=>e.name),null!==(S=null==Q?void 0:null===(e=Q.crmConfig)||void 0===e?void 0:e.tags)&&void 0!==S?S:[],[])},[W,null==Q?void 0:null===(t=Q.crmConfig)||void 0===t?void 0:t.tags]),X="EMAIL"!==E&&q.length>0;return(0,n.jsxs)("form",{"aria-label":V.title,onSubmit:P(A),className:"space-y-4",...(0,r.Ut)(M),children:[(0,n.jsx)(u.IIB,{placeholder:"Subject","aria-required":"true",...O("subject"),disabled:D,className:"h-9"}),(0,n.jsx)(j.c,{message:null===(s=R.subject)||void 0===s?void 0:s.message}),(0,n.jsx)(k,{value:U,onChange:e=>F("occurredOn",e,{shouldValidate:!0,shouldDirty:!0}),disabled:D}),"VISIT"===E&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.IIB,{placeholder:"Where (customer site, office, trade show...)","aria-required":"true",...O("location"),disabled:D,className:"h-9"}),(0,n.jsx)(j.c,{message:null===(o=R.location)||void 0===o?void 0:o.message})]}),"ONLINE_MEETING"===E&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(u.IIB,{placeholder:"Meeting link (optional)",...O("link"),disabled:D,className:"h-9"}),(0,n.jsx)(j.c,{message:null===(m=R.link)||void 0===m?void 0:m.message})]}),"EMAIL"===E&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("select",{"aria-label":"Email direction",...O("direction"),disabled:D,className:w,children:[(0,n.jsx)("option",{value:"SENT",children:"Sent to them"}),(0,n.jsx)("option",{value:"RECEIVED",children:"Received from them"})]}),(0,n.jsx)(u.IIB,{placeholder:"SENT"===B?"To (email address, optional)":"From (email address, optional)",...O("addresses"),disabled:D,className:"h-9 flex-1"})]}),(0,n.jsx)(j.c,{message:null===(p=R.addresses)||void 0===p?void 0:p.message})]}),L,X&&(0,n.jsx)(v.k,{isJointCall:H,vendors:K,options:q,error:null===(I=R.jointCallVendors)||void 0===I?void 0:I.message,disabled:D,onJointCallChange:e=>{F("isJointCall",e,{shouldValidate:!0,shouldDirty:!0}),F("jointCallVendors",[],{shouldValidate:!0,shouldDirty:!0})},onVendorsChange:e=>F("jointCallVendors",e,{shouldValidate:!0,shouldDirty:!0})}),(0,n.jsx)("textarea",{placeholder:V.notes,...O("description"),disabled:D,className:N}),("VISIT"===E||"ONLINE_MEETING"===E)&&G.length>0&&(0,n.jsx)(h.Lu,{id:"interaction-tags",label:"Product Tags",value:J,options:G,placeholder:"Select product lines (optional)...",disabled:D,onSave:async e=>F("tags",e,{shouldDirty:!0})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(u.zxk,{type:"button",variant:"ghost",size:"sm",onClick:T,disabled:D,className:"h-8",children:[(0,n.jsx)(d.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(u.zxk,{type:"submit",size:"sm",disabled:!z||D,className:"h-8",children:D?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):V.submit})]})]})}},870012:function(e,t,s){s.d(t,{e3:function(){return l}});var n=s(785893),a=s(667294);function l(e){let{noteId:t,description:s}=e,[l,r]=(0,a.useState)(!1),i=s.replace(/\r\n?/g,"\n"),o=/[\r\n]/.test(i)||i.length>140;return(0,n.jsxs)("div",{className:"mt-1",children:[(0,n.jsx)("p",{"data-testid":"note-description-".concat(t),"data-expanded":l?"true":"false",className:l?"text-xs text-text-sub-600 whitespace-pre-wrap break-words":"text-xs text-text-sub-600 line-clamp-2 break-words",children:i}),o&&(0,n.jsx)("button",{type:"button","aria-expanded":l,"aria-label":l?"Show less of note":"Show full note",onClick:e=>{e.stopPropagation(),r(e=>!e)},className:"mt-1 text-[11px] font-medium text-brand-primary hover:text-brand-primary/80 transition-colors",children:l?"Show less":"Show more"})]})}},171375:function(e,t,s){s.d(t,{z:function(){return w}});var n=s(785893),a=s(667294),l=s(287536),r=s(209023),i=s(563201),o=s(313766),c=s(808971),d=s(884979),u=s(613718),m=s(636316),x=s(390470),p=s(541352),h=s(313742),f=s(762888),g=s(14066),b=s(24661),v=s(855527),j=s(870012),y=s(970112);let N={ACCOUNT:{label:"Account",className:"bg-bg-soft-100 text-text-sub-600 ring-1 ring-stroke-soft-200"},LEAD:{label:"Lead",className:"bg-blue-50 text-blue-700 ring-1 ring-blue-200"},OPPORTUNITY:{label:"Opportunity",className:"bg-purple-50 text-purple-700 ring-1 ring-purple-200"},PROJECT:{label:"Project",className:"bg-emerald-50 text-emerald-700 ring-1 ring-emerald-200"}};function w(e){let{notes:t,initialLimit:s=3,onDelete:w,onEdit:C,isReadOnly:k=!1,isDeleting:I=!1,isEditing:S=!1,isLoading:E=!1,isError:D=!1,onRetry:A,compactEmptyState:T=!1}=e,[L,_]=(0,a.useState)(!1),[O,P]=(0,a.useState)(null),{register:Z,handleSubmit:F,reset:R,formState:{isValid:z,isDirty:M}}=(0,l.cI
1)({resolver:(0,i.F)(v.mM),defaultValues:{subject:"",description:""},mode:"onChange"}),U=(0,a.useMemo)(()=>t.map(v.zF).sort((e,t)=>t.createdAt.getTime()-e.createdAt.getTime()),[t]),B=L||0===s?U:U.slice(0,s),V=s>0&&U.length>s,J=U.length-s,W=(0,a.useCallback)(e=>{P(e.id),R({subject:e.subject,description:e.description})},[R]),G=(0,a.useCallback)(()=>{P(null),R({subject:"",description:""})},[R]),Q=(0,a.useCallback)(async e=>{O&&C&&(await C({id:O,subject:e.subject.trim(),description:e.description.trim()}),G())},[O,C,G]),H=A?(0,n.jsxs)(g.zxk,{variant:"ghost",size:"sm",onClick:A,className:"mt-1 h-7 gap-1 text-text-sub-600 hover:text-text-strong-950",children:[(0,n.jsx)(f.Z,{className:"h-4 w-4"}),"Retry"]}):(0,n.jsx)("p",{className:"text-xs text-text-sub-600 mt-1",children:"Try refreshing the page."});return 0===U.length?E?(0,n.jsx)("div",{className:"flex items-center justify-center py-6 text-center",children:(0,n.jsx)(m.Z,{className:"w-5 h-5 text-text-soft-400 animate-spin"})}):D?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,n.jsx)("div",{className:"p-3 bg-red-50 rounded-full mb-3",children:(0,n.jsx)(o.Z,{className:"w-6 h-6 text-red-500"})}),(0,n.jsx)("p",{className:"text-sm font-medium text-text-strong-950",children:"Couldn't load notes"}),H]}):T?(0,n.jsx)("p",{className:"py-2 text-center text-sm text-text-soft-400",children:"No notes"}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,n.jsx)("div",{className:"p-3 bg-bg-soft-100 rounded-full mb-3",children:(0,n.jsx)(o.Z,{className:"w-6 h-6 text-text-soft-400"})}),(0,n.jsx)("p",{className:"text-sm font-medium text-text-strong-950",children:"No notes"}),(0,n.jsx)("p",{className:"text-xs text-text-sub-600 mt-1",children:'Click "Add Note" to create your first note.'})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[D&&(0,n.jsxs)("div",{role:"alert",className:"flex flex-wrap items-center justify-between gap-2 rounded-md bg-state-error-lighter px-3 py-1.5",children:[(0,n.jsx)("p",{className:"text-xs font-medium text-text-strong-950",children:"Couldn't refresh notes. Showing the last loaded list."}),H]}),B.map(e=>{let t=O===e.id;return t?(0,n.jsxs)("form",{onSubmit:F(Q),className:"p-3 rounded-lg border border-brand-primary bg-bg-soft-50 space-y-3",...(0,r.Ut)(M),children:[(0,n.jsx)(g.IIB,{...Z("subject"),placeholder:"Subject",disabled:S,className:"h-9"}),(0,n.jsx)("textarea",{...Z("description"),placeholder:"Description",disabled:S,className:"w-full min-h-[60px] p-2 text-sm rounded-md border border-stroke-soft-200 bg-bg-white-0 resize-none focus:outline-none focus:ring-2 focus:ring-brand-primary focus:border-transparent disabled:opacity-50"}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(g.zxk,{type:"button",variant:"ghost",size:"sm",onClick:G,disabled:S,className:"h-8",children:[(0,n.jsx)(p.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(g.zxk,{type:"submit",size:"sm",disabled:S||!z,className:"h-8",children:S?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(h.Z,{className:"h-4 w-4 mr-1"}),"Save"]})})]})]},e.id):(0,n.jsx)("div",{className:"group p-3 rounded-lg border border-stroke-soft-200 border-l-[3px] border-l-orange-300 bg-bg-white-0 hover:bg-bg-soft-50 transition-colors",children:(0,n.jsx)("div",{className:"flex items-start justify-between gap-2",children:(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[e.sourceType&&"ACCOUNT"!==e.sourceType&&(0,n.jsxs)("div",{className:"mb-1.5 flex items-center gap-1.5 flex-wrap",children:[(0,n.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-medium uppercase tracking-wide ".concat(N[e.sourceType].className),children:N[e.sourceType].label}),e.sourceName&&(0,n.jsx)("span",{className:"text-[11px] text-text-sub-600 truncate",children:e.sourceName})]}),(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsx)("h4",{className:"text-sm font-semibold text-text-strong-950 truncate",children:e.subject}),(0,n.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[!k&&C&&(0,n.jsx)(g.zxk,{variant:"ghost",size:"icon","aria-label":"Edit note",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:t=>{t.stopPropagation(),W(e)},children:(0,n.jsx)(x.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-brand-primary"})}),!k&&w&&(0,n.jsx)(g.zxk,{variant:"ghost",size:"icon","aria-label":"Delete note",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",disabled:I,onClick:t=>{t.stopPropagation(),w(e.id)},children:I?(0,n.jsx)(m.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-red-500"})})]})]}),e.description&&(0,n.jsx)(j.e3,{noteId:e.id,description:e.description}),(0,n.jsxs)("div",{className:"flex items-center gap-1.5 mt-2 text-[11px] text-text-soft-400",children:[(0,n.jsx)("span",{children:function(e){let t=new Date,s=e.toDateString()===t.toDateString(),n=e.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});if(s)return"Today at ".concat(n);let a=e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return"".concat(a," at ").concat(n)}(e.createdAt)}),e.createdByName&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:"\xb7"}),(0,n.jsx)(b.X,{name:e.createdByName,size:"xs",variant:"neutral"}),(0,n.jsx)("span",{children:(0,y.bG)(e.createdByName)})]})]})]})})},e.id)}),V&&(0,n.jsx)("button",{type:"button",onClick:()=>_(!L),className:"w-full flex items-center justify-center gap-1.5 py-2 mt-1 text-sm text-brand-primary hover:text-brand-primary/80 font-medium rounded-md hover:bg-brand-primary-alpha-10 transition-colors",children:L?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.Z,{className:"h-4 w-4"}),"Show less"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.Z,{className:"h-4 w-4"}),"View ",J," more ",1===J?"note":"notes"]})})]})}},759860:function(e,t,s){s.d(t,{T:function(){return D},p:function(){return E}});var n=s(785893),a=s(667294),l=s(287536),r=s(563201),i=s(430202),o=s(720249),c=s(313766),d=s(931012),u=s(541352),m=s(636316),x=s(808971),p=s(14066),h=s(407800),f=s(605541),g=s(829971),b=s(363548),v=s(209023),j=s(440769),y=s(847090),N=s(52916),w=s(171375),C=s(499112),k=s(46258),I=s(535224),S=s(855527);function E(e,t,s,n){let a=(0,i.NL)(),{toast:l}=(0,h.pm)();return(0,o.D)({mutationFn:s=>
1n?n.create(s):g.Zc.createNote(e,t,s),onSuccess:()=>{a.invalidateQueries({queryKey:(0,C.f)(e,t,s)}),(0,C.X)(a),l({title:"Success",description:"Note added successfully"})},onError:e=>{l({title:"Error",description:e.message||"Failed to add note",variant:"destructive"})}})}function D(e){let{entityType:t,entityId:s,notes:D=[],initialLimit:A=3,isReadOnly:T=!1,className:L,queryKeyToInvalidate:_,defaultExpanded:O=!0,expanded:P,onExpandedChange:Z,persistKey:F,userConfigKey:R,isLoading:z=!1,isError:M=!1,onRetry:U,compactEmptyState:B=!1,headerLeading:V,openCreateSignal:J=0,showLogCall:W=!1,logActivityAccountId:G,title:Q="Notes",writeAdapter:H}=e,[K,q]=(0,f.H)(F,R,O),X=null!=P?P:K,Y=(0,a.useCallback)(e=>{void 0===P&&q(e),null==Z||Z(e)},[P,Z,q]),[$,ee]=(0,a.useState)(!1);(0,a.useEffect)(()=>{J&&(Y(!0),ee(!0))},[J,Y]);let{register:et,handleSubmit:es,reset:en,watch:ea,setValue:el,formState:{isValid:er,isDirty:ei}}=(0,l.cI)({resolver:(0,r.F)(S.R8),defaultValues:{subject:"",description:"",tags:[]},mode:"onChange"}),eo=ea("tags"),{data:ec}=(0,N.us)(),ed=(0,a.useMemo)(()=>(null!=ec?ec:[]).map(e=>({value:e.name,label:e.name})),[ec]),eu=ea("description"),em=ea("subject"),ex=(0,a.useRef)("");(0,a.useEffect)(()=>{let e=setTimeout(()=>{let e=""!==em.trim()&&em!==ex.current;if(e)return;let t=(0,j.G)(eu);t!==em&&(ex.current=t,el("subject",t,{shouldValidate:!0,shouldDirty:!1}))},250);return()=>clearTimeout(e)},[eu,em,el]);let ep=E(t,s,_,H),eh=function(e,t,s,n){let a=(0,i.NL)(),{toast:l}=(0,h.pm)();return(0,o.D)({mutationFn:e=>n?n.remove(e):g.Zc.deleteActivity(e),onSuccess:()=>{a.invalidateQueries({queryKey:(0,C.f)(e,t,s)}),(0,C.X)(a),l({title:"Success",description:"Note deleted successfully"})}})}(t,s,_,H),ef=function(e,t,s,n){let a=(0,i.NL)(),{toast:l}=(0,h.pm)();return(0,o.D)({mutationFn:e=>n?n.update(e):g.Zc.updateActivity(e.id,{subject:e.subject,description:e.description}),onSuccess:()=>{a.invalidateQueries({queryKey:(0,C.f)(e,t,s)}),(0,C.X)(a),l({title:"Success",description:"Note updated successfully"})},onError:e=>{l({title:"Error",description:e.message||"Failed to update note",variant:"destructive"})}})}(t,s,_,H),eg=(0,a.useCallback)(e=>{eh.mutate(e)},[eh]),eb=(0,a.useCallback)(async e=>{await ef.mutateAsync(e)},[ef]),ev=(0,a.useCallback)(()=>{Y(!0),ee(!0)},[]),ej=(0,a.useCallback)(()=>{ee(!1),en(),ex.current=""},[en]),ey=(0,a.useCallback)(async e=>{await ep.mutateAsync({subject:e.subject.trim(),description:e.description.trim(),tags:e.tags}),ej()},[ep,ej]),eN=ep.isPending,ew=(0,a.useRef)(null),eC=(0,a.useCallback)(e=>{var t;(null===(t=ew.current)||void 0===t?void 0:t.querySelector("[".concat(v.w5,"]")))&&e.preventDefault()},[]);return(0,n.jsxs)(p.zF9,{open:X,onOpenChange:Y,children:[(0,n.jsxs)("div",{className:(0,b.cn)("border border-stroke-soft-200 rounded-xl overflow-hidden bg-bg-white-0",L),children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-x-2 gap-y-1 px-4 py-3 bg-bg-white-0",children:[(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[V,(0,n.jsxs)("button",{type:"button",onClick:()=>Y(!X),className:"flex items-center gap-2 hover:opacity-80 transition-opacity",children:[(0,n.jsx)("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-orange-50",children:(0,n.jsx)(c.Z,{className:"w-4 h-4 text-orange-500"})}),(0,n.jsx)("span",{className:"text-sm font-medium text-text-strong-950",children:Q}),!z&&!M&&(0,n.jsx)("span",{className:"flex items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium text-text-sub-600 bg-bg-weak-50 border border-stroke-soft-200 rounded-full",children:D.length})]})]}),(0,n.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[!T&&!$&&(0,n.jsxs)(n.Fragment,{children:[W&&(0,n.jsx)(I.G,{entityType:t,entityId:s,queryKeyToInvalidate:_,accountId:G}),(0,n.jsxs)(p.zxk,{variant:"ghost",size:"sm",onClick:ev,className:"h-7 gap-1 text-text-sub-600 hover:text-text-strong-950",children:[(0,n.jsx)(d.Z,{className:"h-4 w-4"}),"Add Note"]})]}),(0,n.jsx)("button",{type:"button","aria-label":X?"Collapse notes":"Expand notes","aria-expanded":X,onClick:()=>Y(!X),className:"shrink-0 p-1 rounded hover:bg-bg-soft-200 transition-colors",children:(0,n.jsx)(x.Z,{className:(0,b.cn)("h-5 w-5 text-text-sub-600 transition-transform duration-200",X&&"rotate-180")}
1)})]})]}),(0,n.jsx)(p.FwI,{children:(0,n.jsx)("div",{className:"border-t border-stroke-soft-200 p-3 max-h-[280px] overflow-y-auto",children:(0,n.jsx)(w.z,{notes:D,initialLimit:A,onDelete:eg,onEdit:eb,isReadOnly:T,isDeleting:eh.isPending,isEditing:ef.isPending,isLoading:z,isError:M,onRetry:U,compactEmptyState:B})})})]}),(0,n.jsx)(p.yoO,{open:$,onOpenChange:e=>{e||ej()},children:(0,n.jsxs)(p.uei,{ref:ew,side:"right",className:"w-full sm:max-w-md flex flex-col",onPointerDownOutside:eC,onInteractOutside:eC,children:[(0,n.jsx)(p.Tuv,{children:(0,n.jsx)(p.bCQ,{children:"Add Note"})}),(0,n.jsx)("div",{className:"flex-1 overflow-y-auto py-4",children:$&&(0,n.jsxs)("form",{onSubmit:es(ey),className:"space-y-4",...(0,v.Ut)(ei),children:[(0,n.jsx)(p.IIB,{placeholder:"Subject",...et("subject"),disabled:eN,className:"h-9"}),(0,n.jsx)("textarea",{placeholder:"Write your note...",...et("description"),disabled:eN,className:k.dy}),!H&&ed.length>0&&(0,n.jsx)(y.Lu,{id:"note-tags",label:"Product Tags",value:eo,options:ed,placeholder:"Select product lines (optional)...",disabled:eN,onSave:async e=>el("tags",e,{shouldDirty:!0})}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(p.zxk,{type:"button",variant:"ghost",size:"sm",onClick:ej,disabled:eN,className:"h-8",children:[(0,n.jsx)(u.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(p.zxk,{type:"submit",size:"sm",disabled:!(er&&!eN),className:"h-8",children:eN?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(m.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):"Save Note"})]})]})})]})})]})}},855527:function(e,t,s){s.d(t,{Ho:function(){return p},R8:function(){return r},Sp:function(){return x},aC:function(){return c},mM:function(){return i},zF:function(){return l}});var n=s(73894),a=s(829971);function l(e){var t,s;return"sourceType"in e&&"string"==typeof e.sourceType?{id:e.id,subject:null!==(t=e.title)&&void 0!==t?t:"",description:null!==(s=e.content)&&void 0!==s?s:"",createdAt:new Date(e.createdAt?e.createdAt:0),createdByName:e.createdByName,sourceType:e.sourceType,sourceName:e.sourceName}:"title"in e&&"number"==typeof e.createdAt?{id:e.id,subject:e.title,description:e.description,createdAt:new Date(e.createdAt),createdByName:e.createdByName||null,sourceType:null,sourceName:null}:{id:e.id,subject:e.subject,description:e.description,createdAt:new Date(e.createdAt),createdByName:e.createdByName,sourceType:null,sourceName:null}}let r=n.Ryn({subject:n.Z_8().min(1,"Subject is required"),description:n.Z_8().min(1,"Description is required"),tags:n.IXX(n.Z_8()).default([])}),i=n.Ryn({subject:n.Z_8().min(1,"Subject is required"),description:n.Z_8()}),o=n.Z_8().regex(/^\d{4}-\d{2}-\d{2}$/,"Pick the day it happened"),c=n.Ryn({subject:n.Z_8().min(1,"Subject is required"),description:n.Z_8().optional(),direction:n.jbo(a.kw),outcome:n.Z_8().optional(),phoneNumber:n.Z_8().optional(),occurredOn:o}),d=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,u=/^https?:\/\/\S+$/i,m=n.Ryn({subject:n.Z_8().trim().min(1,"Subject is required"),occurredOn:o,description:n.Z_8().optional(),location:n.Z_8().optional(),link:n.Z_8().optional(),direction:n.KmV(["SENT","RECEIVED"]),addresses:n.Z_8().optional(),tags:n.IXX(n.Z_8()).default([]),isJointCall:n.O72().default(!1),jointCallVendors:n.IXX(n.Z_8()).default([])});function x(e){return(null!=e?e:"").split(/[\s,;]+/).map(e=>e.trim()).filter(Boolean)}function p(e){return m.superRefine((t,s)=>{var n,l;if("VISIT"===e){let e=null===(n=t.location)||void 0===n?void 0:n.trim();e?e.toLowerCase()===a.as.toLowerCase()&&s.addIssue({code:"custom",path:["location"],message:'Use the "Online meeting" option above for an online meeting'}):s.addIssue({code:"custom",path:["location"],message:"Where was the visit?"})}if("EMAIL"!==e&&t.isJointCall&&0===t.jointCallVendors.length&&s.addIssue({code:"custom",path:["jointCallVendors"],message:"Pick the vendor who came along"}),"ONLINE_MEETING"===e){let e=null===(l=t.link)||void 0===l?void 0:l.trim();e&&!u.test(e)&&s.addIssue({code:"custom",path:["link"],message:"Enter the full link, starting with https://"})}if("EMAIL"===e){let e=x(t.addresses);e.some(e=>!d.test(e))?s.addIssue({code:"custom",path:["addresses"],message:"Enter valid email addresses"}):"RECEIVED"===t.direction&&e.length>1&&s.addIssue({code:"custom",path:["addresses"],message:"A received email has one sender"})}})}},144786:function(e,t,s){s.d(t,{S:function(){return u},Y:function(){return m}});var n=s(430202),a=s(720249),l=s(407800),r=s(829971),i=s(499112),o=s(855527);let c={VISIT:"Visit logged successfully",ONLINE_MEETING:"Meeting logged successfully",EMAIL:"Email logged successfully"},d={VISIT:"Failed to log visit",ONLINE_MEETING:"Failed to log meeting",EMAIL:"Failed to log email"};function u(e,t){var s,n,a,l,r;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],c=t.subject.trim(),d=(null===(s=t.description)||void 0===s?void 0:s.trim())||void 0,u=t.occurredOn;return"EMAIL"===e?{kind:e,email:{subject:c,description:d,direction:t.direction,addresses:(0,o.Sp)(t.addresses),occurredOn:u,contactIds:i}}:{kind:e,meeting:{subject:c,description:d,mode:"VISIT"===e?"VISIT":"ONLINE",location:(null===(n=t.location)||void 0===n?void 0:n.trim())||void 0,link:(null===(a=t.link)||void 0===a?void 0:a.trim())||void 0,occurredOn:u,tags:(null===(l=t.tags)||void 0===l?void 0:l.length)?t.tags:void 0,jointCallVendors:t.isJointCall&&(null===(r=t.jointCallVendors)||void 0===r?void 0:r.length)?t.jointCallVendors:void 0,contactIds:i}}}function m(e,t,s){let o=(0,n.NL)(),{toast:u}=(0,l.pm)();return(0,a.D)({mutationFn:s=>"EMAIL"===s.kind?r.Zc.createEmail(e,t,s.email):r.Zc.createMeeting(e,t,s.meeting),onSuccess:(n,a)=>{o.invalidateQueries({queryKey:(0,i.f)(e,t,s)}),(0,i.X)(o),u({title:"Success",description:c[a.kind]})},onError:(e,t)=>
1{u({title:"Error",description:e.message||d[t.kind],variant:"destructive"})}})}},464745:function(e,t,s){s.d(t,{DI:function(){return l},Xg:function(){return r}});var n=s(785893);let a={none:"",sm:"p-4",md:"p-6",lg:"p-8"},l={none:"",sm:"px-4",md:"px-6",lg:"px-8"},r=Object.assign(function(e){let{children:t}=e;return(0,n.jsx)("div",{className:"h-full flex flex-col",children:t})},{Header:function(e){let{children:t}=e;return(0,n.jsx)("div",{className:"flex-shrink-0",children:t})},Content:function(e){let{children:t,padding:s="md",scroll:l=!0}=e,r=a[s];return(0,n.jsx)("div",{className:"flex-1 min-h-0 ".concat(l?"overflow-auto":"overflow-hidden"," ").concat(r),children:t})}})},339414:function(e,t,s){s.d(t,{I:function(){return i}});var n=s(785893),a=s(140116),l=s(14066),r=s(423213);function i(e){let{missingFields:t,onProceed:s,onDismiss:i,isSubmitting:o=!1}=e;return 0===t.length?null:(0,n.jsxs)("div",{role:"status",className:"flex items-start justify-between gap-3 rounded-lg border border-state-warning-light bg-state-warning-lighter p-3",children:[(0,n.jsxs)("div",{className:"flex items-start gap-2 text-text-strong-950",children:[(0,n.jsx)(a.Z,{className:"mt-0.5 h-4 w-4 shrink-0 text-state-warning-dark","aria-hidden":!0}),(0,n.jsx)("span",{className:"text-sm font-medium",children:(0,r.ud)(t)})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[i&&(0,n.jsx)(l.zxk,{type:"button",variant:"outline",size:"sm",onClick:i,children:"Go back"}),(0,n.jsx)(l.zxk,{type:"button",size:"sm",onClick:s,disabled:o,children:"Continue anyway"})]})]})}},269789:function(e,t,s){s(785893)},516786:function(e,t,s){s.d(t,{JY:function(){return l},NA:function(){return r},yx:function(){return n}});let n=5,a={URGENT:{label:"Urgent",bg:"bg-red-100",text:"text-red-700",border:"border-red-200"},HIGH:{label:"High",bg:"bg-orange-100",text:"text-orange-700",border:"border-orange-200"},MEDIUM:{label:"Medium",bg:"bg-yellow-100",text:"text-yellow-700",border:"border-yellow-200"},LOW:{label:"Low",bg:"bg-gray-100",text:"text-gray-600",border:"border-gray-200"}},l=[{value:"LOW",label:"Low"},{value:"MEDIUM",label:"Medium"},{value:"HIGH",label:"High"},{value:"URGENT",label:"Urgent"}];function r(e){let t=e.toUpperCase();return a[t]||a.MEDIUM}},385305:function(e,t,s){s.d(t,{W0:function(){return n.W},vn:function(){return a.v},vs:function(){return l.v}});var n=s(987823);s(870440),s(938335);var a=s(733517);s(295652);var l=s(783294);s(720256),s(475370),s(516786)},733517:function(e,t,s){s.d(t,{v:function(){return f}});var n=s(785893),a=s(667294),l=s(287536),r=s(563201),i=s(636316),o=s(931012),c=s(541352),d=s(803424),u=s(14066),m=s(674175),x=s(582794),p=s(295652),h=s(720256);function f(e){let{parentId:t,subtasks:s,onCreate:f,onStatusChange:g,onDelete:b,isReadOnly:v,isCreating:j,isUpdating:y,isDeleting:N,isAdding:w,onIsAddingChange:C}=e,[k,I]=(0,a.useState)(!1),S=null!=w?w:k,E=(0,a.useCallback)(e=>{void 0===w&&I(e),null==C||C(e)},[w,C]),{data:D=[]}=(0,x.Z4)(),{register:A,handleSubmit:T,setValue:L,watch:_,reset:O,formState:{isValid:P}}=(0,l.cI)({resolver:(0,r.F)(h.RJ),defaultValues:{title:"",dueDate:null,assignedToId:""},mode:"onChange"}),Z=_("dueDate"),F=_("assignedToId"),R=(0,a.useCallback)(e=>{e.stopPropagation(),E(!1),O()},[O,E]),z=(0,a.useCallback)(async e=>{f&&(await f({parentId:t,title:e.title.trim(),dueDate:e.dueDate?(0,d.WU)(e.dueDate,"yyyy-MM-dd"):void 0,assignedToId:e.assignedToId||void 0}),O())},[f,t,O]),M=!v&&!!f;return 0!==s.length||M?(0,n.jsxs)("div",{className:"mt-2 pl-2 border-l-2 border-stroke-soft-200",children:[s.map(e=>(0,n.jsx)(p.Y,{subtask:e,onStatusChange:g,onDelete:b,isReadOnly:v,isUpdating:y,isDeleting:N},e.id)),M&&!S&&(0,n.jsxs)(u.zxk,{variant:"ghost",size:"sm",onClick:e=>{e.stopPropagation(),E(!0)},className:"h-6 mt-1 gap-1 px-2 text-xs text-text-sub-600 hover:text-brand-primary",children:[(0,n.jsx)(o.Z,{className:"h-3 w-3"}),"Add sub-task"]}),M&&S&&(0,n.jsxs)("form",{onSubmit:T(z),className:"mt-1.5 space-y-2 rounded-md border border-stroke-soft-200 bg-bg-soft-50 p-2",children:[(0,n.jsx)(u.IIB,{...A("title"),placeholder:"Sub-task title *",disabled:j,autoFocus:!0,className:"h-8 text-xs"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("div",{className:"flex-1 min-w-[130px]",children:(0,n.jsx)(u.Blo,{value:Z,onChange:e=>L("dueDate",e),placeholder:"Due date",disabled:j,className:"w-full"})}),(0,n.jsx)("div",{className:"flex-1 min-w-[130px]",children:(0,n.jsx)(m.V,{value:F||null,onChange:e=>L("assignedToId",e||""),options:D.map(e=>({value:e.id,label:e.name})),placeholder:"Assignee",searchPlaceholder:"Search assignees...",disabled:j,className:"h-8",allowClear:!0})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,n.jsxs)(u.zxk,{type:"button",variant:"ghost",size:"sm",onClick:R,disabled:j,className:"h-7 text-xs",children:[(0,n.jsx)(c.Z,{className:"h-3 w-3 mr-1"}),"Cancel"]}),(0,n.jsx)(u.zxk,{type:"submit",size:"sm",disabled:!P||j,className:"h-7 text-xs",children:j?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Z,{className:"h-3 w-3 mr-1 animate-spin"}),"Saving..."]}):"Add"})]})]})]}):null}},783294:function(e,t,s){s.d(t,{v:function(){return r}});var n=s(785893),a=s(808971),l=s(363548);
1function r(e){let{completed:t,total:s,isExpanded:r,onToggle:i,isDimmed:o}=e;return(0,n.jsxs)("button",{type:"button",onClick:e=>{e.stopPropagation(),i()},"aria-expanded":r,"aria-label":r?"Collapse sub-tasks":"Expand ".concat(s," sub-tasks"),className:(0,l.cn)("flex items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium transition-colors","bg-bg-soft-100 text-text-sub-600 hover:bg-bg-soft-200 hover:text-text-strong-950",o&&"opacity-50"),children:[(0,n.jsx)(a.Z,{className:(0,l.cn)("h-3 w-3 transition-transform",r&&"rotate-180")}),t,"/",s]})}},295652:function(e,t,s){s.d(t,{Y:function(){return u}});var n=s(785893),a=s(613718),l=s(636316),r=s(313742),i=s(14066),o=s(24661),c=s(363548),d=s(475370);function u(e){let{subtask:t,onStatusChange:s,onDelete:u,isReadOnly:m,isUpdating:x,isDeleting:p}=e,h="COMPLETED"===t.status.toUpperCase(),{text:f,isOverdue:g}=(0,d.l)(t.dueDate);return(0,n.jsxs)("div",{className:"group/subtask flex items-center gap-2 py-1.5 pl-2 pr-1 rounded-md hover:bg-bg-soft-50 transition-colors",children:[(0,n.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),!s||m||x||s(t.id,!h)},disabled:m||x||!s,className:(0,c.cn)("shrink-0 flex items-center justify-center h-4 w-4 rounded-full border-2 transition-all",h?"bg-state-success border-state-success":"border-stroke-sub-300 hover:border-state-success",(m||!s)&&"cursor-default",x&&"opacity-50"),"aria-label":h?"Mark sub-task as incomplete":"Mark sub-task as complete",children:h&&(0,n.jsx)(r.Z,{className:"h-2.5 w-2.5 text-white",strokeWidth:3})}),(0,n.jsx)(i.s1R,{content:t.title,className:"flex-1 min-w-0",children:(0,n.jsx)("span",{className:(0,c.cn)("block truncate text-xs text-text-strong-950",h&&"line-through text-text-soft-400"),children:t.title})}),t.assignedToName&&(0,n.jsx)("div",{className:"shrink-0 flex items-center gap-1",children:(0,n.jsx)(o.X,{name:t.assignedToName,size:"xs",variant:"primary"})}),f&&(0,n.jsx)("span",{className:(0,c.cn)("shrink-0 text-[11px]",g&&!h?"text-state-error font-medium":"text-text-sub-600",h&&"text-text-soft-400"),children:f}),!m&&u&&(0,n.jsx)(i.zxk,{variant:"ghost",size:"icon",className:"h-5 w-5 shrink-0 opacity-0 group-hover/subtask:opacity-100 transition-opacity",disabled:p,onClick:e=>{e.stopPropagation(),u(t.id)},"aria-label":"Delete sub-task",children:p?(0,n.jsx)(l.Z,{className:"h-3 w-3 animate-spin"}):(0,n.jsx)(a.Z,{className:"h-3 w-3 text-text-soft-400 hover:text-red-500"})})]})}},689283:function(e,t,s){s.d(t,{h:function(){return g}});var n=s(785893),a=s(667294),l=s(287536),r=s(563201),i=s(636316),o=s(313742),c=s(541352),d=s(14066),u=s(218003),m=s(674175),x=s(803424),p=s(516786),h=s(720256),f=s(582794);function g(e){let{task:t,onEdit:s,isEditing:g,onCancel:b}=e,{data:v=[]}=(0,f.Z4)(),{register:j,handleSubmit:y,setValue:N,watch:w,formState:{isValid:C}}=(0,l.cI)({resolver:(0,r.F)(h.Gh),defaultValues:{title:t.title,description:t.description||"",priority:t.priority,dueDate:t.dueDate,assignedToId:t.assignedToId||""},mode:"onChange"}),k=w("priority"),I=w("dueDate"),S=w("assignedToId"),E=(0,a.useCallback)(async e=>{var n;await s({id:t.id,title:e.title.trim(),description:(null===(n=e.description)||void 0===n?void 0:n.trim())||void 0,priority:e.priority,dueDate:e.dueDate?(0,x.WU)(e.dueDate,"yyyy-MM-dd"):void 0,assignedToId:e.assignedToId||void 0}),b()},[t.id,s,b]);return(0,n.jsxs)("form",{onSubmit:y(E),className:"p-3 rounded-lg border border-brand-primary bg-bg-soft-50 space-y-3",children:[(0,n.jsx)(d.IIB,{...j("title"),placeholder:"Task title *",disabled:g,className:"h-9"}),(0,n.jsx)("textarea",{...j("description"),placeholder:"Description (optional)",disabled:g,className:"w-full min-h-[60px] p-2 text-sm rounded-md border border-stroke-soft-200 bg-bg-white-0 resize-none focus:outline-none focus:ring-2 focus:ring-brand-primary focus:border-transparent disabled:opacity-50"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("div",{className:"w-full sm:w-auto sm:min-w-[120px]",children:(0,n.jsxs)(u.Ph,{value:k,onValueChange:e=>N("priority",e),disabled:g,children:[(0,n.jsx)(u.i4,{className:"h-9",children:(0,n.jsx)(u.ki,{placeholder:"Priority"})}),(0,n.jsx)(u.Bw,{children:p.JY.map(e=>(0,n.jsx)(u.Ql,{value:e.value,children:e.label},e.value))})]})}),(0,n.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,n.jsx)(d.Blo,{value:
1I,onChange:e=>N("dueDate",e),placeholder:"Due date",disabled:g,className:"w-full"})}),(0,n.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,n.jsx)(m.V,{value:S||null,onChange:e=>N("assignedToId",e||""),options:v.map(e=>({value:e.id,label:e.name})),placeholder:"Assignee",searchPlaceholder:"Search assignees...",disabled:g,className:"h-9",allowClear:!0})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(d.zxk,{type:"button",variant:"ghost",size:"sm",onClick:b,disabled:g,className:"h-8",children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(d.zxk,{type:"submit",size:"sm",disabled:g||!C,className:"h-8",children:g?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Z,{className:"h-4 w-4 mr-1"}),"Save"]})})]})]})}},938335:function(e,t,s){s.d(t,{U:function(){return y}});var n=s(785893),a=s(667294),l=s(613718),r=s(636316),i=s(313742),o=s(808971),c=s(884979),d=s(390470),u=s(723579),m=s(14066),x=s(24661),p=s(363548),h=s(516786),f=s(475370),g=s(970112),b=s(689283),v=s(733517),j=s(783294);function y(e){let{task:t,onDelete:s,onEdit:y,onStatusChange:N,isDeleting:w,isUpdating:C,isEditing:k=!1,isReadOnly:I,onCreateSubtask:S,onSubtaskStatusChange:E,onDeleteSubtask:D,isCreatingSubtask:A}=e,[T,L]=(0,a.useState)(!1),[_,O]=(0,a.useState)(!1),[P,Z]=(0,a.useState)(!1),[F,R]=(0,a.useState)(!1),[z,M]=(0,a.useState)(!1),U=(0,a.useRef)(null),B="COMPLETED"===t.status.toUpperCase(),V=!t.parentActivityId&&!!S,J=t.subtaskTotal>0,W=(0,h.NA)(t.priority),{text:G,isOverdue:Q}=(0,f.y)(t.dueDate);(0,a.useEffect)(()=>{let e=U.current;e&&t.description&&O(e.scrollHeight>e.clientHeight)},[t.description]);let H=e=>{e.stopPropagation(),!N||I||C||N(t.id,!B)},K=e=>{e.stopPropagation(),L(!T)};return P&&y?(0,n.jsx)(b.h,{task:t,onEdit:y,isEditing:k,onCancel:()=>Z(!1)}):(0,n.jsxs)("div",{className:(0,p.cn)("group flex items-start gap-3 p-3","border border-stroke-soft-200 rounded-lg transition-colors",B?"bg-state-success-lighter/40 hover:bg-state-success-lighter/60":"bg-bg-white-0 hover:bg-bg-soft-50"),children:[(0,n.jsx)("button",{type:"button",onClick:H,disabled:I||C||!N,className:(0,p.cn)("mt-0.5 shrink-0 flex items-center justify-center","h-5 w-5 rounded-full border-2 transition-all",B?"bg-state-success border-state-success":"border-stroke-sub-300 hover:border-state-success",(I||!N)&&"cursor-default",C&&"opacity-50"),"aria-label":B?"Mark as incomplete":"Mark as complete",children:B&&(0,n.jsx)(i.Z,{className:"h-3 w-3 text-white",strokeWidth:3})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsx)("span",{className:(0,p.cn)("text-sm font-medium text-text-strong-950",B&&"line-through text-text-sub-600"),children:t.title}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[J&&(0,n.jsx)(j.v,{completed:t.subtaskCompletedCount,total:t.subtaskTotal,isExpanded:F,onToggle:()=>R(e=>!e),isDimmed:B}),(0,n.jsx)("span",{className:(0,p.cn)("px-2 py-0.5 text-xs font-medium rounded",W.bg,W.text,B&&"opacity-50"),children:W.label})]})]}),t.description&&(0,n.jsxs)("div",{className:"mt-1.5",children:[(0,n.jsx)("p",{ref:U,className:(0,p.cn)("text-xs text-text-sub-600",!T&&"line-clamp-2",B&&"text-text-soft-400"),children:t.description}),_&&(0,n.jsx)("button",{type:"button",onClick:K,className:"flex items-center gap-0.5 mt-1 text-xs text-brand-primary hover:text-brand-primary/80 font-medium transition-colors",children:T?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.Z,{className:"h-3 w-3"}),"Show less"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(o.Z,{className:"h-3 w-3"}),"Show more"]})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between mt-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[t.assignedToName&&(0,n.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,n.jsx)(x.X,{name:t.assignedToName,size:"xs",variant:"primary"}),(0,n.jsx)("span",{className:"text-text-sub-600 truncate max-w-[100px]",children:t.assignedToName})]}),t.assignedToName&&G&&(0,n.jsx)("span",{className:"text-text-soft-400",children:"â¢"}),G&&(0,n.jsx)("span",{className:(0,p.cn)(Q&&!B?"text-state-error font-medium":"text-text-sub-600",B&&"text-text-soft-400"),children:G}),t.createdByName&&(0,n.jsxs)(n.Fragment,{children:[(t.assignedToName||G)&&(0,n.jsx)("span",{className:"text-text-soft-400",children:"â¢"}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(x.X,{name:t.createdByName,size:"xs",variant:"neutral"}),(0,n.jsx)("span",{className:"text-text-soft-400",children:(0,g.bG)(t.createdByName)})]})]})]}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[V&&!I&&!B&&(0,n.jsx)(m.zxk,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:e=>{e.stopPropagation(),R(!0),M(!0)},"aria-label":"Add sub-task",children:(0,n.jsx)(u.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-brand-primary"})}),!I&&y&&!B&&(0,n.jsx)(m.zxk,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",onClick:e=>{e.stopPropagation(),Z(!0)},"aria-label":"Edit task",children:(0,n.jsx)(d.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-brand-primary"})}),!I&&s&&(0,n.jsx)(m.zxk,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",disabled:w,onClick:e=>{e.stopPropagation(),s(t.id)},"aria-label":"Delete task",children:w?(0,n.jsx)(r.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,n.jsx)(l.Z,{className:"h-3.5 w-3.5 text-text-soft-400 hover:text-red-500"})})]})]}),(V||J)&&F&&(0,n.jsx)(v.v,{parentId:t.id,subtasks:t.subtasks,onCreate:S,onStatusChange:E,onDelete:D,isReadOnly:I||B,isCreating:A,isUpdating:C,isDeleting:w,isAdding:z,onIsAddingChange:M})]})]})}},870440:function(e,t,s){s.d(t,{Z:function(){return x}});var n=s(785893),a=s(667294),l=s(63125),r=s(808971),i=s(884979),o=s(636316),c=s(363548),d=s(938335),u=s(720256),m=s(516786);function x(e){let{tasks:t,initialLimit:s=m.yx,onDelete:x,onEdit:p,onStatusChange:h,isReadOnly:f=!1,isDeleting:g=!1,isUpdating:b=!1,isEditing:v=!1,showCompleted:j=!0,isLoading:y=!1,isError:N=!1,compactEmptyState:w=!1,onCreateSubtask:C,onSubtaskStatusChange:k,onDeleteSubtask:I,isCreatingSubtask:S}=e,[E,D]=(0,a.useState)(!1),[A,T]=(0,a.useState)(!1),{pendingTasks:L,completedTasks:_}=(0,a.useMemo)(()=>{let e=t.map(u.RK),s=e.filter(e=>"COMPLETED"!==e.status.toUpperCase()).sort((e,t)=>
1e.dueDate&&t.dueDate?e.dueDate.getTime()-t.dueDate.getTime():e.dueDate?-1:t.dueDate?1:t.createdAt.getTime()-e.createdAt.getTime()),n=e.filter(e=>"COMPLETED"===e.status.toUpperCase()).sort((e,t)=>e.completedAt&&t.completedAt?t.completedAt.getTime()-e.completedAt.getTime():t.createdAt.getTime()-e.createdAt.getTime());return{pendingTasks:s,completedTasks:n}},[t]),O=E||0===s?L:L.slice(0,s),P=s>0&&L.length>s,Z=L.length-s;return 0===L.length&&0===_.length?y?(0,n.jsx)("div",{className:"flex items-center justify-center py-6 text-center",children:(0,n.jsx)(o.Z,{className:"w-5 h-5 text-text-soft-400 animate-spin"})}):N?(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,n.jsx)("div",{className:"p-3 bg-red-50 rounded-full mb-3",children:(0,n.jsx)(l.Z,{className:"w-6 h-6 text-red-500"})}),(0,n.jsx)("p",{className:"text-sm font-medium text-text-strong-950",children:"Couldn't load tasks"}),(0,n.jsx)("p",{className:"text-xs text-text-sub-600 mt-1",children:"Try refreshing the page."})]}):w?(0,n.jsx)("p",{className:"py-2 text-center text-sm text-text-soft-400",children:"No tasks yet"}):(0,n.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,n.jsx)("div",{className:"p-3 bg-bg-soft-100 rounded-full mb-3",children:(0,n.jsx)(l.Z,{className:"w-6 h-6 text-text-soft-400"})}),(0,n.jsx)("p",{className:"text-sm font-medium text-text-strong-950",children:"No tasks yet"}),(0,n.jsx)("p",{className:"text-xs text-text-sub-600 mt-1",children:'Click "Add Task" to create your first task.'})]}):(0,n.jsxs)("div",{className:"space-y-2",children:[O.map(e=>(0,n.jsx)(d.U,{task:e,onDelete:x,onEdit:p,onStatusChange:h,isDeleting:g,isUpdating:b,isEditing:v,isReadOnly:f,onCreateSubtask:C,onSubtaskStatusChange:k,onDeleteSubtask:I,isCreatingSubtask:S},e.id)),0===L.length&&_.length>0&&(0,n.jsx)("p",{className:"text-sm text-text-sub-600 py-2",children:"No pending tasks"}),P&&(0,n.jsx)("button",{type:"button",onClick:()=>D(!E),className:"w-full flex items-center justify-center gap-1.5 py-2 mt-1 text-sm text-brand-primary hover:text-brand-primary/80 font-medium rounded-md hover:bg-brand-primary-alpha-10 transition-colors",children:E?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.Z,{className:"h-4 w-4"}),"Show less"]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.Z,{className:"h-4 w-4"}),"View ",Z," more ",1===Z?"task":"tasks"]})}),j&&_.length>0&&(0,n.jsxs)("div",{className:"mt-3 pt-3 border-t border-stroke-soft-200",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>T(!A),className:"flex items-center gap-2 text-sm text-text-sub-600 hover:text-text-strong-950 transition-colors mb-2",children:[(0,n.jsx)(i.Z,{className:(0,c.cn)("h-4 w-4 transition-transform",!A&&"rotate-180")}),(0,n.jsxs)("span",{children:["Completed (",_.length,")"]})]}),A&&(0,n.jsx)("div",{className:"space-y-2",children:_.map(e=>(0,n.jsx)(d.U,{task:e,onDelete:x,onEdit:p,onStatusChange:h,isDeleting:g,isUpdating:b,isEditing:v,isReadOnly:f,onCreateSubtask:C,onSubtaskStatusChange:k,onDeleteSubtask:I,isCreatingSubtask:S},e.id))})]})]})}},65617:function(e,t,s){s.d(t,{CO:function(){return p},Ls:function(){return m},Mo:function(){return x},eP:function(){return d},jQ:function(){return u}});var n=s(430202),a=s(720249),l=s(407800),r=s(829971),i=s(222672),o=s(228001);function c(e){e.invalidateQueries({queryKey:l.pL.accountActivitiesPaginatedPrefix})}function d(e,t,s){let i=(0,n.NL)(),{toast:d}=(0,l.pm)();return(0,a.D)({mutationFn:s=>r.Zc.createTask(e,t,s),onSuccess:()=>{i.invalidateQueries({queryKey:(0,o.f)(e,t,s)}),c(i),d({title:"Success",description:"Task created successfully"})},onError:e=>{d({title:"Error",description:e.message||"Failed to create task",variant:"destructive"})}})}function u(e,t,s){let i=(0,n.NL)(),{toast:d}=(0,l.pm)();return(0,a.D)({mutationFn:s=>{let{parentId:n,title:a,dueDate:l,assignedToId:i}=s;return r.Zc.createTask(e,t,{title:a,priority:"MEDIUM",dueDate:l,assignedToId:i,parentActivityId:n})},onSuccess:()=>{i.invalidateQueries({queryKey:(0,o.f)(e,t,s)}),c(i),d({title:"Success",description:"Sub-task added"})},onError:e=>{d({title:"Error",description:e.message||"Failed to add sub-task",variant:"destructive"})}})}function m(e,t,s){let i=(0,n.NL)(),{toast:d}=(0,l.pm)();return(0,a.D)({mutationFn:e=>r.Zc.deleteActivity(e),onSuccess:()=>{i.invalidateQueries({queryKey:(0,o.f)(e,t,s)}),c(i),d({title:"Success",description:"Task deleted successfully"})}})}function x(e,t,s){let l=(0,n.NL)();return(0,a.D)({mutationFn:e=>{let{taskId:t,completed:s}=e;return r.Zc.updateActivity(t,{status:s?i.fU.COMPLETED:i.fU.OPEN})},onSuccess:()=>
1{l.invalidateQueries({queryKey:(0,o.f)(e,t,s)}),c(l)}})}function p(e,t,s){let i=(0,n.NL)(),{toast:d}=(0,l.pm)();return(0,a.D)({mutationFn:e=>r.Zc.updateActivity(e.id,{subject:e.title,description:e.description,priority:e.priority,dueDate:e.dueDate,assignedToId:e.assignedToId}),onSuccess:()=>{i.invalidateQueries({queryKey:(0,o.f)(e,t,s)}),c(i),d({title:"Success",description:"Task updated successfully"})},onError:e=>{d({title:"Error",description:e.message||"Failed to update task",variant:"destructive"})}})}},987823:function(e,t,s){s.d(t,{W:function(){return C}});var n=s(785893),a=s(667294),l=s(287536),r=s(563201),i=s(63125),o=s(931012),c=s(541352),d=s(636316),u=s(808971),m=s(14066),x=s(218003),p=s(674175),h=s(803424),f=s(582794),g=s(605541),b=s(363548),v=s(870440),j=s(516786),y=s(720256),N=s(222672),w=s(65617);function C(e){let{entityType:t,entityId:s,tasks:C=[],initialLimit:k=j.yx,isReadOnly:I=!1,className:S,queryKeyToInvalidate:E,showCompleted:D=!0,defaultExpanded:A=!0,expanded:T,onExpandedChange:L,persistKey:_,userConfigKey:O,isLoading:P=!1,isError:Z=!1,compactEmptyState:F=!1,headerLeading:R,enableSubtasks:z=!0}=e,[M,U]=(0,g.H)(_,O,A),B=null!=T?T:M,V=(0,a.useCallback)(e=>{void 0===T&&U(e),null==L||L(e)},[T,L,U]),[J,W]=(0,a.useState)(!1),{register:G,handleSubmit:Q,setValue:H,watch:K,reset:q,formState:{isValid:X}}=(0,l.cI)({resolver:(0,r.F)(y.kn),defaultValues:{title:"",description:"",priority:"MEDIUM",dueDate:null,assignedToId:""},mode:"onChange"}),Y=K("priority"),$=K("dueDate"),ee=K("assignedToId"),{data:et=[]}=(0,f.Z4)(),es=(0,w.eP)(t,s,E),en=(0,w.jQ)(t,s,E),ea=(0,w.Ls)(t,s,E),el=(0,w.Mo)(t,s,E),er=(0,w.CO)(t,s,E),ei=C.filter(e=>e.status.toUpperCase()!==N.fU.COMPLETED).length,eo=(0,a.useCallback)(e=>{ea.mutate(e)},[ea]),ec=(0,a.useCallback)((e,t)=>{el.mutate({taskId:e,completed:t})},[el]),ed=(0,a.useCallback)(async e=>{await er.mutateAsync(e)},[er]),eu=(0,a.useCallback)(async e=>{await en.mutateAsync(e)},[en]),em=(0,a.useCallback)(()=>{V(!0),W(!0)},[]),ex=(0,a.useCallback)(()=>{W(!1),q()},[q]),ep=(0,a.useCallback)(async e=>{var t;await es.mutateAsync({title:e.title.trim(),description:(null===(t=e.description)||void 0===t?void 0:t.trim())||void 0,priority:e.priority,dueDate:e.dueDate?(0,h.WU)(e.dueDate,"yyyy-MM-dd"):void 0,assignedToId:e.assignedToId||void 0}),ex()},[es,ex]),eh=es.isPending;return(0,n.jsx)(m.zF9,{open:B,onOpenChange:V,children:(0,n.jsxs)("div",{className:(0,b.cn)("border border-stroke-soft-200 rounded-xl overflow-hidden bg-bg-white-0",S),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 bg-bg-white-0",children:[R,(0,n.jsxs)("button",{type:"button",onClick:()=>V(!B),className:"flex min-w-0 flex-1 items-center gap-2 text-left hover:opacity-80 transition-opacity",children:[(0,n.jsx)("div",{className:"flex shrink-0 items-center justify-center w-8 h-8 rounded-lg bg-green-50",children:(0,n.jsx)(i.Z,{className:"w-4 h-4 text-green-500"})}),(0,n.jsx)("span",{className:"text-sm font-medium text-text-strong-950",children:"Tasks"}),ei>0&&(0,n.jsx)("span",{className:"flex shrink-0 items-center justify-center min-w-[20px] h-5 px-1.5 text-xs font-medium text-white bg-state-success rounded-full",children:ei})]}),(0,n.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[!I&&!J&&(0,n.jsxs)(m.zxk,{variant:"ghost",size:"sm",onClick:em,className:"h-7 gap-1 text-text-sub-600 hover:text-text-strong-950",children:[(0,n.jsx)(o.Z,{className:"h-4 w-4"}),"Add Task"]}),(0,n.jsx)("button",{type:"button","aria-label":B?"Collapse tasks":"Expand tasks","aria-expanded":B,onClick:()=>V(!B),className:"shrink-0 p-1 rounded hover:bg-bg-soft-200 transition-colors",children:(0,n.jsx)(u.Z,{className:(0,b.cn)("h-5 w-5 text-text-sub-600 transition-transform duration-200",B&&"rotate-180")})})]})]}),(0,n.jsx)(m.FwI,{children:(0,n.jsxs)("div",{className:"border-t border-stroke-soft-200 p-3 max-h-[400px] overflow-y-auto",children:[J&&(0,n.jsxs)("form",{onSubmit:Q(ep),className:"mb-3 p-3 rounded-lg border border-stroke-soft-200 bg-bg-soft-50 space-y-3",children:[(0,n.jsx)(m.IIB,{placeholder:"Task title *",...G("title"),disabled:eh,className:"h-9"}),(0,n.jsx)("textarea",{placeholder:"Description (optional)",...G("description"),disabled:eh,className:"w-full min-h-[60
1px] p-2 text-sm rounded-md border border-stroke-soft-200 bg-bg-white-0 resize-none focus:outline-none focus:ring-2 focus:ring-brand-primary focus:border-transparent disabled:opacity-50"}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,n.jsx)("div",{className:"w-full sm:w-auto sm:min-w-[120px]",children:(0,n.jsxs)(x.Ph,{value:Y,onValueChange:e=>H("priority",e),disabled:eh,children:[(0,n.jsx)(x.i4,{className:"h-9",children:(0,n.jsx)(x.ki,{placeholder:"Priority"})}),(0,n.jsx)(x.Bw,{children:j.JY.map(e=>(0,n.jsx)(x.Ql,{value:e.value,children:e.label},e.value))})]})}),(0,n.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,n.jsx)(m.Blo,{value:$,onChange:e=>H("dueDate",e),placeholder:"Due date",disabled:eh,className:"w-full"})}),(0,n.jsx)("div",{className:"flex-1 min-w-[140px]",children:(0,n.jsx)(p.V,{value:ee||null,onChange:e=>H("assignedToId",e||""),options:et.map(e=>({value:e.id,label:e.name})),placeholder:"Assignee (optional)",searchPlaceholder:"Search assignees...",disabled:eh,className:"h-9",allowClear:!0})})]}),(0,n.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,n.jsxs)(m.zxk,{type:"button",variant:"ghost",size:"sm",onClick:ex,disabled:eh,className:"h-8",children:[(0,n.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),"Cancel"]}),(0,n.jsx)(m.zxk,{type:"submit",size:"sm",disabled:!(X&&!eh),className:"h-8",children:eh?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(d.Z,{className:"h-4 w-4 mr-1 animate-spin"}),"Saving..."]}):"Save Task"})]})]}),(0,n.jsx)(v.Z,{tasks:C,initialLimit:k,onDelete:eo,onEdit:ed,onStatusChange:ec,isReadOnly:I,isDeleting:ea.isPending,isUpdating:el.isPending,isEditing:er.isPending,showCompleted:D,isLoading:P,isError:Z,compactEmptyState:F,onCreateSubtask:z?eu:void 0,onSubtaskStatusChange:z?ec:void 0,onDeleteSubtask:z?eo:void 0,isCreatingSubtask:en.isPending})]})})]})})}},720256:function(e,t,s){s.d(t,{Gh:function(){return c},RJ:function(){return i},RK:function(){return r},kn:function(){return o}});var n=s(73894),a=s(363548);function l(e){var t,s,n;let a=(null!==(t=e.subtasks)&&void 0!==t?t:[]).map(e=>r(e));return{subtasks:a,subtaskTotal:null!==(s=e.subtaskTotal)&&void 0!==s?s:a.length,subtaskCompletedCount:null!==(n=e.subtaskCompletedCount)&&void 0!==n?n:a.filter(e=>"COMPLETED"===e.status.toUpperCase()).length}}function r(e){var t,s;return"number"==typeof e.createdAt?{id:e.id,title:e.title,description:e.description||null,status:e.status,priority:e.priority,dueDate:(0,a._Z)(e.dueDate),completedAt:e.completedAt?new Date(e.completedAt):null,assignedToId:e.assignedToId,assignedToName:e.assignedToName,createdById:e.createdById,createdByName:e.createdByName||null,createdAt:new Date(e.createdAt),parentActivityId:null!==(t=e.parentActivityId)&&void 0!==t?t:null,...l(e)}:{id:e.id,title:e.title,description:e.description,status:e.status,priority:e.priority,dueDate:(0,a._Z)(e.dueDate),completedAt:e.completedAt?new Date(e.completedAt):null,assignedToId:e.assignedToId,assignedToName:e.assignedToName,createdById:e.createdById,createdByName:e.createdByName,createdAt:new Date(e.createdAt),parentActivityId:null!==(s=e.parentActivityId)&&void 0!==s?s:null,...l(e)}}let i=n.Ryn({title:n.Z_8().min(1,"Title is required"),dueDate:n.hTZ().nullable(),assignedToId:n.Z_8().optional()}),o=n.Ryn({title:n.Z_8().min(1,"Title is required"),description:n.Z_8().optional(),priority:n.Z_8(),dueDate:n.hTZ().nullable(),assignedToId:n.Z_8().optional()}),c=n.Ryn({title:n.Z_8().min(1,"Title is required"),description:n.Z_8().optional(),priority:n.Z_8(),dueDate:n.hTZ().nullable(),assignedToId:n.Z_8().optional()})},475370:function(e,t,s){s.d(t,{l:function(){return r},y:function(){return l}});var n=s(363548);function a(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function l(e){if(!e)return{text:"",isOverdue:!1};let t=e.getDate(),s=e.toLocaleDateString("en-US",{month:"short"});return{text:"".concat(s," ").concat(t).concat((0,n.Qo)(t)," ").concat(e.getFullYear()),isOverdue:a(e).getTime()<a(new Date).getTime()}}function r(e){if(!e)return{text:"",isOverdue:!1};let t=new Date,s=e.getDate(),l=e.toLocaleDateString("en-US",{month:"short"}),r=e.getFullYear()===t.getFullYear()?"":" ".concat(e.getFullYear());return{text:"".concat(l," ").concat(s).concat((0,n.Qo)(s)).concat(r),isOverdue:a(e).getTime()<a(t).getTime()}}},605541:function(e,t,s){s.d(t,{H:function(){return l}});var n=s(204139),a=s(478551);function l(e,t,s){let[l,r]=(0,n.R)(t?void 0:e,s),[i,o]=(0,a.eT)(t,s);return t?[i,o]:[l,r]}},982201:function(e,t,s){var n,a;s.d(t,{I:function(){return o},v:function(){return c}});let l=(e,t)=>
1e.find(e=>e.types.includes(t)),r=(e,t)=>{var s;return null!==(n=null===(s=l(e,t))||void 0===s?void 0:s.long_name)&&void 0!==n?n:null},i=(e,t)=>{var s;return null!==(a=null===(s=l(e,t))||void 0===s?void 0:s.short_name)&&void 0!==a?a:null};function o(e){var t,s,n,a,l,r,i,o,c,d,u,m;return{addressLine1:null!==(t=e.addressLine1)&&void 0!==t?t:"",addressLine2:null!==(s=e.addressLine2)&&void 0!==s?s:"",city:null!==(n=e.city)&&void 0!==n?n:"",state:null!==(a=e.state)&&void 0!==a?a:"",zip:null!==(l=e.zip)&&void 0!==l?l:"",county:null!==(r=e.county)&&void 0!==r?r:"",country:null!==(i=e.country)&&void 0!==i?i:"",countryCode:null!==(o=e.countryCode)&&void 0!==o?o:"",lat:null!==(c=e.lat)&&void 0!==c?c:"",long:null!==(d=e.long)&&void 0!==d?d:"",displayName:null!==(u=e.displayName)&&void 0!==u?u:"",placeId:null!==(m=e.placeId)&&void 0!==m?m:"",coordinatesApproximate:e.coordinatesApproximate}}function c(e){var t,s,n,a,l,o,c,d;let u=null!==(n=e.address_components)&&void 0!==n?n:[],m=r(u,"street_number"),x=i(u,"route"),p=[m,x].filter(Boolean).join(" ")||null,h=r(u,"administrative_area_level_2"),f=h?h.replace(/\s+County$/i,""):null,g=(null!==(a=e.types)&&void 0!==a?a:[]).includes("establishment"),b=(null===(t=e.name)||void 0===t?void 0:t.trim())||null,v=null!==(l=r(u,"subpremise"))&&void 0!==l?l:g?b:null,j=null===(s=e.geometry)||void 0===s?void 0:s.location,y="function"==typeof(null==j?void 0:j.lat)?String(j.lat()):null,N="function"==typeof(null==j?void 0:j.lng)?String(j.lng()):null;return{addressLine1:p,addressLine2:v,city:null!==(o=r(u,"locality"))&&void 0!==o?o:r(u,"sublocality_level_1"),state:i(u,"administrative_area_level_1"),zip:r(u,"postal_code"),county:f,country:r(u,"country"),countryCode:i(u,"country"),lat:y,long:N,displayName:null!==(c=e.formatted_address)&&void 0!==c?c:null,placeId:null!==(d=e.place_id)&&void 0!==d?d:null,coordinatesApproximate:!m}}},440014:function(e,t,s){s.d(t,{D:function(){return r},Q:function(){return l}});var n=s(820621),a=s(734155);let l=a.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY||n.N.mapsKey,r=["places"]},843509:function(e,t,s){s.d(t,{K4:function(){return r},hn:function(){return a},k4:function(){return l}});var n=s(477158);function a(e){if(!e)return[];let t=e.toUpperCase(),s=n.rS.find(e=>{let[,s]=e;return s===t});return s?s[2].filter(e=>{let[,t]=e;return Boolean(t)}).map(e=>{let[t,s]=e;return{name:t,shortCode:s}}):[]}function l(e){var t,s;let a=null==e?void 0:e.trim();if(!a)return null;if(2===a.length){let e=a.toUpperCase();if(n.Vk.some(t=>{let[,s]=t;return s===e}))return e}let l=a.toLowerCase();return null!==(s=null===(t=n.Vk.find(e=>{let[t]=e;return t.toLowerCase()===l}))||void 0===t?void 0:t[1])&&void 0!==s?s:null}function r(e){return l(e)}},558068:function(e,t,s){s.d(t,{a:function(){return o}});var n=s(667294),a=s(337054),l=s(982201),r=s(440014);let i="Address lookup unavailable â you can enter the address manually.";function o(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{countryCode:t,debounceMs:s=300}=e,{isLoaded:o,loadError:c}=(0,a.Ji)({googleMapsApiKey:r.Q,libraries:r.D}
1),[d,u]=(0,n.useState)(""),[m,x]=(0,n.useState)([]),[p,h]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),b=(0,n.useRef)(null),v=(0,n.useRef)(null),j=(0,n.useRef)(null),y=(0,n.useMemo)(()=>o&&"undefined"!=typeof google?{autocomplete:new google.maps.places.AutocompleteService,places:new google.maps.places.PlacesService(document.createElement("div"))}:null,[o]),N=(0,n.useCallback)(()=>{var e;return b.current||"undefined"==typeof google||(b.current=new google.maps.places.AutocompleteSessionToken),null!==(e=b.current)&&void 0!==e?e:void 0},[]),w=(0,n.useCallback)(()=>{u(""),x([]),g(null),b.current=null},[]),C=(0,n.useCallback)(e=>{var s;if(!y){j.current=e,h(!0);return}j.current=null,h(!0),y.autocomplete.getPlacePredictions({input:e,sessionToken:null!==(s=b.current)&&void 0!==s?s:void 0,...t?{region:t.toLowerCase()}:{}},(e,t)=>{var s,n;if(h(!1),t!==google.maps.places.PlacesServiceStatus.OK||!e){x([]),t!==google.maps.places.PlacesServiceStatus.ZERO_RESULTS&&g(i);return}x(e.slice(0,5).map(e=>{var t,a;return{placeId:e.place_id,description:e.description,mainText:null!==(s=null===(t=e.structured_formatting)||void 0===t?void 0:t.main_text)&&void 0!==s?s:e.description,secondaryText:null!==(n=null===(a=e.structured_formatting)||void 0===a?void 0:a.secondary_text)&&void 0!==n?n:""}}))})},[y,t]),k=(0,n.useCallback)(e=>{if(u(e),g(null),v.current&&clearTimeout(v.current),!e.trim()){j.current=null,x([]);return}N(),v.current=setTimeout(()=>C(e),s)},[s,N,C]);(0,n.useEffect)(()=>{y&&j.current&&(N(),C(j.current))},[y,N,C]);let I=(0,n.useCallback)(e=>new Promise(t=>{var s;if(!y)return t(null);y.places.getDetails({placeId:e,sessionToken:null!==(s=b.current)&&void 0!==s?s:void 0,fields:["address_components","formatted_address","geometry","place_id","name","types"]},(e,s)=>{if(b.current=null,s!==google.maps.places.PlacesServiceStatus.OK||!e)return g("Could not load that address â you can enter it manually."),t(null);x([]),t((0,l.v)(e))})}),[y]);return(0,n.useEffect)(()=>{c&&(j.current=null,h(!1),g(i))},[c]),(0,n.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]),{input:d,setInput:k,predictions:m,isLoading:p,error:f,selectPrediction:I,reset:w}}},440769:function(e,t,s){s.d(t,{G:function(){return l}});var n=s(517200);let a=e=>e.replace(/[.!?,;:\s]+$/,"").trim();function l(e){if(!e)return"";let t=e.replace(/\s+/g," ").trim();if(!t)return"";let s=(0,n.Z)(t).sentences().out("array"),l=s.length?s:[t],r="";for(let e of l)if(a(r=r?"".concat(r," ").concat(e.trim()):e.trim()).length>=40)break;let i=a(r);if(i.length<=72)return i;let o=i.slice(0,72),c=o.lastIndexOf(" ");return(c>0?o.slice(0,c):o).trim()}},108246:function(e,t,s){var n,a;s.d(t,{Yd:function(){return l}}),(a=n||(n={})).DEBUG="DEBUG",a.INFO="INFO",a.WARN="WARN",a.ERROR="ERROR";class l{static debug(e,t){}static info(e,t){this.log(n.INFO,e,t)}static warn(e,t){this.log(n.WARN,e,t)}static error(e,t,s){this.log(n.ERROR,e,{...s,error:{message:t.message,stack:t.stack,name:t.name,...t}})}static apiCall(e,t,s,a,l){let r=a>=500?n.ERROR:a>=400?n.WARN:n.INFO;this.log(r,"API ".concat(e," ").concat(t),{type:"api_call",method:e,endpoint:t,duration:s,status:a,...l})}static userAction(e,t){this.log(n.INFO,e,{type:"user_action",...t})}static performance(e,t,s){this.log(n.INFO,"Performance: ".concat(e),{type:"performance",operation:e,duration:t,...s})}static log(e,t,s){let a={level:e,timestamp:new Date().toISOString(),message:t,...s};switch(JSON.stringify(a),e){case n.DEBUG:case n.INFO:case n.WARN:case n.ERROR:}}}}}]);
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.