realtimex-crm 0.9.8 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DealList-Dxd6Tt9n.js → DealList-Bfe4r2OW.js} +2 -2
- package/dist/assets/{DealList-Dxd6Tt9n.js.map → DealList-Bfe4r2OW.js.map} +1 -1
- package/dist/assets/{index-CGJPhLfC.js → index-Dat6OHMH.js} +3 -3
- package/dist/assets/{index-CGJPhLfC.js.map → index-Dat6OHMH.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/src/components/atomic-crm/contacts/TagsListEdit.tsx +4 -4
|
@@ -102,7 +102,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
102
102
|
border-radius: 50%;
|
|
103
103
|
}
|
|
104
104
|
`}),d.jsxs(_a,{children:[d.jsx(Wr,{children:d.jsx(Gr,{children:"Upload and resize image"})}),d.jsxs("div",{className:"flex flex-col gap-2 justify-center",children:[d.jsxs("div",{className:"flex flex-row justify-center bg-gray-50 cursor-pointer p-4 border-2 border-dashed border-gray-300 rounded-lg hover:bg-gray-100 transition-colors",...g(),children:[d.jsx("input",{...b()}),d.jsx("p",{className:"text-gray-600",children:"Drop a file to upload, or click to select it."})]}),l&&d.jsx(YDe,{ref:r,src:l,aspectRatio:1,guides:!1,cropBoxResizable:!1})]}),d.jsxs(Yo,{className:"flex justify-between w-full",children:[d.jsx(ze,{type:"button",onClick:p,children:"Update Image"}),d.jsx(ze,{type:"button",variant:"destructive",onClick:m,children:"Delete"})]})]})]})},"ImageEditorDialog"),QMe=/^http(?:s)?:\/\/(?:www\.)?linkedin.com\//,ste=i(e=>{if(e)try{if(!new URL(e).href.match(QMe))return"URL must be from linkedin.com"}catch{return"Must be a valid URL"}},"isLinkedinUrl"),lte=i(e=>{if(!e)return;if(!new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i).test(e))return"Must be a valid URL"},"isUrl"),cte=i(()=>{const e=hd();return d.jsxs("div",{className:"flex flex-col gap-4 p-1",children:[d.jsx(XMe,{}),d.jsxs("div",{className:`flex gap-6 ${e?"flex-col":"flex-row"}`,children:[d.jsxs("div",{className:"flex flex-col gap-10 flex-1",children:[d.jsx(ZMe,{}),d.jsx(JMe,{})]}),d.jsx(pd,{orientation:e?"horizontal":"vertical"}),d.jsxs("div",{className:"flex flex-col gap-8 flex-1",children:[d.jsx(e4e,{}),d.jsx(t4e,{}),d.jsx(n4e,{})]})]})]})},"CompanyInputs"),XMe=i(()=>{const e=Wt();return d.jsxs("div",{className:"flex gap-4 flex-1 flex-row",children:[d.jsx(ote,{source:"logo",type:"avatar",width:60,height:60,emptyText:e?.name.charAt(0),linkPosition:"bottom"}),d.jsx(ln,{source:"name",className:"w-full h-fit",validate:nr(),helperText:!1,placeholder:"Company name"})]})},"CompanyDisplayInputs"),ZMe=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Contact"}),d.jsx(ln,{source:"website",helperText:!1,validate:lte}),d.jsx(ln,{source:"linkedin_url",helperText:!1,validate:ste}),d.jsx(ln,{source:"phone_number",helperText:!1})]}),"CompanyContactInputs"),JMe=i(()=>{const{companySectors:e}=Va();return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Context"}),d.jsx(Zs,{source:"sector",choices:e.map(t=>({id:t,name:t})),helperText:!1}),d.jsx(Zs,{source:"size",choices:j4,helperText:!1}),d.jsx(ln,{source:"revenue",helperText:!1}),d.jsx(ln,{source:"tax_identifier",helperText:!1})]})},"CompanyContextInputs"),e4e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Address"}),d.jsx(ln,{source:"address",helperText:!1}),d.jsx(ln,{source:"city",helperText:!1}),d.jsx(ln,{source:"zipcode",helperText:!1}),d.jsx(ln,{source:"stateAbbr",helperText:!1}),d.jsx(ln,{source:"country",helperText:!1})]}),"CompanyAddressInputs"),t4e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Additional information"}),d.jsx(ln,{source:"description",multiline:!0,helperText:!1}),d.jsx(cN,{source:"context_links",helperText:!1,children:d.jsx(uN,{disableReordering:!0,fullWidth:!0,getItemLabel:!1,children:d.jsx(ln,{source:"",label:!1,helperText:!1,validate:lte})})})]}),"CompanyAdditionalInformationInputs"),n4e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Account manager"}),d.jsx(Ry,{source:"sales_id",reference:"sales",filter:{"disabled@neq":!0},children:d.jsx(Zs,{label:"Account manager",helperText:!1,optionText:r4e})})]}),"CompanyAccountManagerInput"),r4e=i(e=>`${e.first_name} ${e.last_name}`,"saleOptionRenderer$1"),a4e=i(()=>{const{identity:e}=Zn();return d.jsx(Lw,{redirect:"show",transform:i(t=>(t.website&&!t.website.startsWith("http")&&(t.website=`https://${t.website}`),t),"transform"),children:d.jsx("div",{className:"mt-2 flex lg:mr-72",children:d.jsx("div",{className:"flex-1",children:d.jsx(ra,{defaultValues:{sales_id:e?.id},children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(cte,{}),d.jsx(q1,{children:d.jsxs("div",{className:"flex flex-row gap-2 justify-end",children:[d.jsx($1,{}),d.jsx(yd,{label:"Create Company"})]})})]})})})})})})},"CompanyCreate");var W1="Tabs",[i4e,BUe]=da(W1,[Ip]),ute=Ip(),[o4e,N4]=i4e(W1),dte=y.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:o,orientation:s="horizontal",dir:l,activationMode:f="automatic",...c}=e,p=xy(l),[m,g]=eo({prop:r,onChange:a,defaultProp:o??"",caller:W1});return d.jsx(o4e,{scope:n,baseId:Kr(),value:m,onValueChange:g,orientation:s,dir:p,activationMode:f,children:d.jsx(yt.div,{dir:p,"data-orientation":s,...c,ref:t})})});dte.displayName=W1;var fte="TabsList",hte=y.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,o=N4(fte,n),s=ute(n);return d.jsx(JM,{asChild:!0,...s,orientation:o.orientation,dir:o.dir,loop:r,children:d.jsx(yt.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:t})})});hte.displayName=fte;var pte="TabsTrigger",mte=y.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...o}=e,s=N4(pte,n),l=ute(n),f=yte(s.baseId,r),c=bte(s.baseId,r),p=r===s.value;return d.jsx(e4,{asChild:!0,...l,focusable:!a,active:p,children:d.jsx(yt.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":c,"data-state":p?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:f,...o,ref:t,onMouseDown:tt(e.onMouseDown,m=>{!a&&m.button===0&&m.ctrlKey===!1?s.onValueChange(r):m.preventDefault()}),onKeyDown:tt(e.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&s.onValueChange(r)}),onFocus:tt(e.onFocus,()=>{const m=s.activationMode!=="manual";!p&&!a&&m&&s.onValueChange(r)})})})});mte.displayName=pte;var vte="TabsContent",gte=y.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:o,...s}=e,l=N4(vte,n),f=yte(l.baseId,r),c=bte(l.baseId,r),p=r===l.value,m=y.useRef(p);return y.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),d.jsx(Ea,{present:a||p,children:i(({present:g})=>d.jsx(yt.div,{"data-state":p?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":f,hidden:!g,id:c,tabIndex:0,...s,ref:t,style:{...e.style,animationDuration:m.current?"0s":void 0},children:g&&o}),"children")})});gte.displayName=vte;function yte(e,t){return`${e}-trigger-${t}`}i(yte,"makeTriggerId");function bte(e,t){return`${e}-content-${t}`}i(bte,"makeContentId");var s4e=dte,l4e=hte,c4e=mte,u4e=gte;function xte({className:e,...t}){return d.jsx(s4e,{"data-slot":"tabs",className:Se("flex flex-col gap-2",e),...t})}i(xte,"Tabs");function wte({className:e,...t}){return d.jsx(l4e,{"data-slot":"tabs-list",className:Se("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...t})}i(wte,"TabsList");function Cu({className:e,...t}){return d.jsx(c4e,{"data-slot":"tabs-trigger",className:Se("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...t})}i(Cu,"TabsTrigger");function Ou({className:e,...t}){return d.jsx(u4e,{"data-slot":"tabs-content",className:Se("flex-1 outline-none",e),...t})}i(Ou,"TabsContent");const d4e=Rp("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function ai({className:e,variant:t,...n}){return d.jsx("div",{"data-slot":"alert",role:"alert",className:Se(d4e({variant:t}),e),...n})}i(ai,"Alert");function _te({className:e,...t}){return d.jsx("div",{"data-slot":"alert-title",className:Se("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),...t})}i(_te,"AlertTitle");function ki({className:e,...t}){return d.jsx("div",{"data-slot":"alert-description",className:Se("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",e),...t})}i(ki,"AlertDescription");const Ste=y.createContext("all"),Ay=i(()=>y.useContext(Ste),"useActivityLogContext"),jte="company.created",Ete="contact.created",Cte="contactNote.created",Ote="deal.created",kte="dealNote.created",Tr=i(e=>{const{loading:t,error:n,empty:r,render:a,...o}=e,s=oi(e),l=xt();return s==null?typeof r=="string"?d.jsx(d.Fragment,{children:r&&l(r,{_:r})}):r:d.jsx(Cpe,{...o,children:d.jsx(h4e,{render:a,loading:t,error:n,...o})})},"ReferenceField"),f4e=i(e=>e.stopPropagation(),"stopPropagation$4"),h4e=i(e=>{const{children:t,className:n,empty:r,error:a,render:o,reference:s,loading:l}=e,f=Spe(),{error:c,link:p,isPending:m,referenceRecord:g}=f,b=Ec(s),w=xt();if(c&&a!==!1)return a;if(m&&l!==!1)return l;if(!g&&r!==!1)return typeof r=="string"?d.jsx(d.Fragment,{children:r&&w(r,{_:r})}):r;const S=o?o(f):t||d.jsx("span",{children:b(g)});return p?d.jsx("div",{className:n,children:d.jsx(fn,{to:p,onClick:f4e,children:S})}):d.jsx(d.Fragment,{children:S})},"ReferenceFieldView");function vc({date:e}){return WY(new Date(e),new Date)}i(vc,"RelativeDate");const wd=i(({sale:e})=>{const{identity:t,isPending:n}=Zn(),r=Wt(),a=e||r;return n||!a?null:a.id===t?.id?"You":`${a.first_name} ${a.last_name}`},"SaleName");function p4e({activity:e}){const t=Ay(),{company:n}=e;return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-row space-x-1 items-center w-full",children:[d.jsx(qp,{width:20,height:20,record:n}),d.jsxs("div",{className:"text-sm text-muted-foreground flex-grow",children:[d.jsx("span",{className:"text-muted-foreground text-sm inline-flex",children:d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})})})," added company ",d.jsx(fn,{to:`/companies/${n.id}/show`,children:n.name}),t==="all"&&d.jsx(d.Fragment,{children:d.jsx(vc,{date:e.date})})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})})}i(p4e,"ActivityLogCompanyCreated");function m4e({activity:e}){const t=Ay(),{contact:n}=e;return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-row gap-2 items-center w-full",children:[d.jsx(is,{width:20,height:20,record:n}),d.jsxs("span",{className:"text-muted-foreground text-sm inline-flex flex-grow",children:[d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})})," added ",d.jsxs(fn,{to:`/contacts/${n.id}/show`,children:[n.first_name," ",n.last_name]})," ",t!=="company"&&d.jsxs(d.Fragment,{children:["to company ",e.company_id]})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})})}i(m4e,"ActivityLogContactCreated");const na=i(({defaultValue:e,source:t,record:n,empty:r,...a})=>{const o=oi({defaultValue:e,source:t,record:n}),s=xt();return o==null?r?d.jsx("span",{...a,children:typeof r=="string"?s(r,{_:r}):r}):null:d.jsx("span",{...a,children:typeof o!="string"?o.toString():o})},"TextField");function Rte({header:e,text:t}){if(!t)return null;const n=t.split(`
|
|
105
|
-
`);return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-col space-y-2 w-full",children:[d.jsx("div",{className:"flex flex-row space-x-1 items-center w-full",children:e}),d.jsx("div",{children:d.jsx("div",{className:"text-sm line-clamp-3 overflow-hidden",children:n.map((r,a)=>d.jsxs(y.Fragment,{children:[r,a<n.length-1&&d.jsx("br",{})]},a))})})]})})}i(Rte,"ActivityLogNote");function v4e(){const e=Wt();return d.jsx(is,{width:20,height:20,record:e})}i(v4e,"ContactAvatar");function g4e({activity:e}){const t=Ay(),{contactNote:n}=e;return d.jsx(Rte,{header:d.jsxs("div",{className:"flex items-center gap-2 w-full",children:[d.jsx(Tr,{source:"contact_id",reference:"contacts",record:e.contactNote,children:d.jsx(v4e,{})}),d.jsxs("div",{className:"flex flex-row flex-grow",children:[d.jsx("div",{className:"text-sm text-muted-foreground flex-grow",children:d.jsxs("span",{className:"text-muted-foreground text-sm inline-flex",children:[d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})}),d.jsxs(Tr,{source:"contact_id",reference:"contacts",record:e.contactNote,children:[" added a note about ",d.jsx(na,{source:"first_name"})," ",d.jsx(na,{source:"last_name"})]})]})}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})]}),text:n.text})}i(g4e,"ActivityLogContactNoteCreated");function y4e({activity:e}){const t=Ay(),{deal:n}=e;return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-row space-x-1 items-center w-full",children:[d.jsx("div",{className:"w-5 h-5 bg-gray-300 rounded-full"}),d.jsxs("div",{className:"text-sm text-muted-foreground flex-grow",children:[d.jsxs("span",{className:"text-muted-foreground text-sm",children:["Sales ID: ",e.sales_id]})," ","added deal ",d.jsx(fn,{to:`/deals/${n.id}/show`,children:n.name})," ",t!=="company"&&d.jsxs(d.Fragment,{children:["to company ",e.company_id," ",d.jsx(vc,{date:e.date})]})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})})}i(y4e,"ActivityLogDealCreated");function b4e({activity:e}){const t=Ay(),{dealNote:n}=e;return d.jsx(Rte,{header:d.jsxs("div",{className:"flex flex-row items-center gap-2 flex-grow",children:[d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:!1,children:d.jsx(Tr,{source:"company_id",reference:"companies",link:!1,children:d.jsx(qp,{width:20,height:20})})}),d.jsxs("span",{className:"text-sm text-muted-foreground flex-grow inline-flex",children:[d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,link:!1,children:d.jsx(wd,{})})," added a note about deal ",d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:"show"}),t!=="company"&&d.jsxs(d.Fragment,{children:[" at ",d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:!1,children:d.jsx(Tr,{source:"company_id",reference:"companies",link:"show"})})," "]})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]}),text:n.text})}i(b4e,"ActivityLogDealNoteCreated");function x4e({activities:e,pageSize:t}){const[n,r]=y.useState(t),a=e.slice(0,n);return d.jsxs("div",{className:"space-y-4",children:[a.map((o,s)=>d.jsxs(y.Fragment,{children:[d.jsx(w4e,{activity:o},o.id),d.jsx(pd,{})]},s)),n<e.length&&d.jsx("a",{href:"#",onClick:i(o=>{o.preventDefault(),r(s=>s+t)},"onClick"),className:"flex w-full justify-center text-sm underline hover:no-underline",children:"Load more activity"})]})}i(x4e,"ActivityLogIterator");function w4e({activity:e}){return e.type===jte?d.jsx(p4e,{activity:e}):e.type===Ete?d.jsx(m4e,{activity:e}):e.type===Cte?d.jsx(g4e,{activity:e}):e.type===Ote?d.jsx(y4e,{activity:e}):e.type===kte?d.jsx(b4e,{activity:e}):null}i(w4e,"ActivityItem");function Ate({companyId:e,pageSize:t=20,context:n="all"}){const r=_n(),{data:a,isPending:o,error:s}=Qr({queryKey:["activityLog",e],queryFn:i(()=>r.getActivityLog(e),"queryFn")});return o?d.jsx("div",{className:"mt-1",children:Array.from({length:5}).map((l,f)=>d.jsxs("div",{className:"space-y-2 mt-1",children:[d.jsxs("div",{className:"flex flex-row space-x-2 items-center",children:[d.jsx(sn,{className:"w-5 h-5 rounded-full"}),d.jsx(sn,{className:"w-full h-4"})]}),d.jsx(sn,{className:"w-full h-12"}),d.jsx(pd,{})]},f))}):s?d.jsx(ai,{children:"Failed to load activity log"}):d.jsx(Ste.Provider,{value:n,children:d.jsx(x4e,{activities:a,pageSize:t})})}i(Ate,"ActivityLog");const _4e=Rp("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Pr({className:e,variant:t,asChild:n=!1,...r}){const a=n?a1:"span";return d.jsx(a,{"data-slot":"badge",className:Se(_4e({variant:t}),e),...r})}i(Pr,"Badge");const Ux=i(({children:e,render:t,className:n})=>{const{data:r}=Gn();return d.jsx("div",{className:`flex gap-2 ${n}`,children:r?.map((a,o)=>d.jsx(Ba,{value:a,children:t?t(a,o):e||d.jsx(S4e,{})},o))})},"SingleFieldList"),S4e=i(()=>d.jsx(Pr,{variant:"outline",children:d.jsx(CK,{})}),"DefaultChildren"),j4e=i(e=>{const{filter:t,page:n=1,perPage:r,reference:a,resource:o,sort:s,source:l,queryOptions:f,render:c,...p}=e;return d.jsx(Eme,{filter:t,page:n,perPage:r,reference:a,resource:o,sort:s,source:l,queryOptions:f,render:c,children:d.jsx(O4e,{...p})})},"ReferenceArrayField"),E4e=i(e=>{const{children:t=C4e,className:n,empty:r,error:a,loading:o,pagination:s}=e,{isPending:l,error:f,total:c,hasPreviousPage:p,hasNextPage:m,data:g,filterValues:b}=Gn();return d.jsx("div",{className:n,children:l&&o!==!1?o:f&&a!==!1?a:(c===0||c==null&&p===!1&&m===!1&&g.length===0&&!Object.keys(b).length)&&r!==!1?r:d.jsxs("span",{children:[t,s&&c!==void 0?s:null]})})},"ReferenceArrayFieldView"),C4e=d.jsx(Ux,{}),O4e=y.memo(E4e),k4e=i(e=>{const t=Wt();return t?d.jsx(Pr,{...e,style:{backgroundColor:t.color,border:0},variant:"outline",className:Se("text-black font-normal",e.className),children:t.name}):null},"ColoredBadge"),Tte=i(()=>d.jsx(j4e,{className:"inline-block",resource:"contacts",source:"tags",reference:"tags",children:d.jsx(Ux,{children:d.jsx(k4e,{source:"name"})})}),"TagsList"),R4e=i((e,t)=>e.find(n=>n.value===t)?.label,"findDealLabel"),Ty=i(({status:e,className:t})=>{const{noteStatuses:n}=Va();if(!e||!n)return null;const r=n.find(a=>a.value===e);return r?d.jsxs("div",{className:Se("group relative inline-block mr-2",t),children:[d.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full",style:{backgroundColor:r.color}}),d.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10",children:r.label})]}):null},"Status"),Pte=i(e=>{const t=Ht(e),n=Wt(e),a=nl()({resource:t,type:"edit",id:n?.id});return d.jsxs(fn,{className:kc({variant:"outline"}),to:a,onClick:A4e,children:[d.jsx(OQ,{}),d.jsx(lr,{i18nKey:e.label??"ra.action.edit",children:e.label??"Edit"})]})},"EditButton"),A4e=i(e=>e.stopPropagation(),"stopPropagation$3"),D4=i(e=>{const{label:t,onClick:n,size:r,mutationOptions:a,redirect:o="list",successMessage:s,variant:l="outline",className:f="cursor-pointer hover:bg-destructive/10! text-destructive! border-destructive! focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40"}=e,c=Wt(e),p=Ht(e),{isPending:m,handleDelete:g}=mK({record:c,resource:p,redirect:o,onClick:n,mutationOptions:a,successMessage:s}),b=xt();let S=Ec(p)(c);const _=b(`resources.${p}.forcedCaseName`,{smart_count:1,_:Gv.humanize(b(`resources.${p}.name`,{smart_count:1,_:p?Gv.singularize(p):void 0}),!0)});y.isValidElement(S)&&(S=`#${c?.id}`);const j=sfe({resourceI18nKey:`resources.${p}.action.delete`,baseI18nKey:"ra.action.delete",options:{name:_,recordRepresentation:S},userText:t});return d.jsxs(ze,{variant:l,type:"button",onClick:g,disabled:m,"aria-label":typeof j=="string"?j:void 0,size:r,className:f,children:[d.jsx(MM,{}),j]})},"DeleteButton"),Nte=i(e=>{const t=Ht(),n=Wt(),a=nl()({resource:t,type:"show",id:n?.id}),{label:o,icon:s,...l}=e;return d.jsxs(fn,{className:kc({variant:"outline"}),to:a,onClick:T4e,...l,children:[s??d.jsx(Mwe,{}),d.jsx(lr,{i18nKey:o??"ra.action.show",children:o??"Show"})]})},"ShowButton"),T4e=i(e=>e.stopPropagation(),"stopPropagation$2");function G1(e){const t=y.memo(e);return t.displayName=e.displayName?.replace("Impl",""),t}i(G1,"genericMemo");const Dte=i(e=>{const{empty:t,locales:n,options:r,showTime:a=!1,showDate:o=!0,transform:s=P4e,source:l,record:f,defaultValue:c,...p}=e,m=xt();if(!a&&!o)throw new Error("<DateField> cannot have showTime and showDate false at the same time");const g=oi({source:l,record:f,defaultValue:c});if(g==null||g==="")return t?d.jsx("span",{...p,children:typeof t=="string"?m(t,{_:t}):t}):null;const b=s(g);let w="";if(b)if(a&&o)w=yA?b.toLocaleString(n,r):b.toLocaleString();else if(o){const S=r??(typeof g=="string"&&g.length<=10?{timeZone:"UTC"}:void 0);w=yA?b.toLocaleDateString(n,S):b.toLocaleDateString()}else a&&(w=yA?b.toLocaleTimeString(n,r):b.toLocaleTimeString());return d.jsx("span",{...p,children:w})},"DateFieldImpl");Dte.displayName="DateFieldImpl";const Bx=G1(Dte),P4e=i(e=>e instanceof Date?e:typeof e=="string"||typeof e=="number"?new Date(e):void 0,"defaultTransform$1"),yA=(()=>{try{new Date().toLocaleString("i")}catch(e){return e instanceof RangeError}return!1})(),Mte=i(e=>{const{empty:t,className:n,defaultValue:r,source:a,record:o,resource:s,...l}=e,f=oi({defaultValue:r,source:a,record:o}),c=xt();return f==null?t?d.jsx("span",{className:n,...l,children:typeof t=="string"?c(t,{_:t}):t}):null:d.jsx("a",{className:Se("underline hover:no-underline",n),href:f,onClick:D4e,...l,children:f})},"UrlFieldImpl");Mte.displayName="UrlFieldImpl";const N4e=G1(Mte),D4e=i(e=>e.stopPropagation(),"stopPropagation$1"),Ite=i(e=>{const{className:t,empty:n,choices:r,defaultValue:a,source:o,record:s,optionValue:l="id",optionText:f="name",translateChoice:c=!0,...p}=e,m=oi({defaultValue:a,source:o,record:s}),{getChoiceText:g,getChoiceValue:b}=Jw({optionText:f,optionValue:l,translateChoice:c}),w=xt(),S=r?r.find(j=>b(j)===m):null;if(!S)return n?d.jsx("span",{className:t,...p,children:typeof n=="string"?w(n,{_:n}):n}):null;const _=g(S);return d.jsx("span",{className:t,...p,children:_})},"SelectFieldImpl");Ite.displayName="SelectFieldImpl";const M4e=G1(Ite);function rc({title:e,children:t,noGap:n}){return d.jsxs("div",{className:"mb-6 text-sm",children:[d.jsx("h3",{className:"font-medium pb-1",children:e}),d.jsx(pd,{}),d.jsx("div",{className:Se("pt-2 flex flex-col",{"gap-1":!n}),children:t})]})}i(rc,"AsideSection");const Fte=i(({link:e="edit"})=>{const t=Wt();return t?d.jsxs("div",{className:"hidden sm:block w-[250px] min-w-[250px] space-y-4",children:[d.jsx("div",{className:"flex flex-row space-x-1",children:e==="edit"?d.jsx(Pte,{label:"Edit Company"}):d.jsx(Nte,{label:"Show Company"})}),d.jsx(I4e,{record:t}),d.jsx(L4e,{record:t}),d.jsx(F4e,{record:t}),d.jsx($4e,{record:t}),e!=="edit"&&d.jsx("div",{className:"mt-6 pt-6 border-t hidden sm:flex flex-col gap-2 items-start",children:d.jsx(D4,{className:"h-6 cursor-pointer hover:bg-destructive/10! text-destructive! border-destructive! focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",size:"sm"})})]}):null},"CompanyAside"),I4e=i(({record:e})=>!e.website&&!e.linkedin_url&&!e.phone_number?null:d.jsxs(rc,{title:"Company Info",children:[e.website&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(Bwe,{className:"w-4 h-4"}),d.jsx(N4e,{source:"website",target:"_blank",rel:"noopener",content:e.website.replace("http://","").replace("https://","")})]}),e.linkedin_url&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(jQ,{className:"w-4 h-4"}),d.jsx("a",{className:"underline hover:no-underline",href:e.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:e.linkedin_url,children:"LinkedIn"})]}),e.phone_number&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(NM,{className:"w-4 h-4"}),d.jsx(na,{source:"phone_number"})]})]}),"CompanyInfo"),F4e=i(({record:e})=>!e.revenue&&!e.id?null:d.jsxs(rc,{title:"Context",children:[e.sector&&d.jsxs("span",{children:["Sector: ",d.jsx(na,{source:"sector"})]}),e.size&&d.jsxs("span",{children:["Size: ",d.jsx(M4e,{source:"size",choices:j4})]}),e.revenue&&d.jsxs("span",{children:["Revenue: ",d.jsx(na,{source:"revenue"})]}),e.tax_identifier&&d.jsxs("span",{children:["Tax Identifier: ",d.jsx(na,{source:"tax_identifier"})]})]}),"ContextInfo"),L4e=i(({record:e})=>!e.address&&!e.city&&!e.zipcode&&!e.stateAbbr?null:d.jsxs(rc,{title:"Main Address",noGap:!0,children:[d.jsx(na,{source:"address"}),d.jsx(na,{source:"city"}),d.jsx(na,{source:"zipcode"}),d.jsx(na,{source:"stateAbbr"}),d.jsx(na,{source:"country"})]}),"AddressInfo"),$4e=i(({record:e})=>{if(!e.created_at&&!e.sales_id&&!e.description&&!e.context_links)return null;const t=i(n=>new URL(n.startsWith("http")?n:`https://${n}`).hostname,"getBaseURL");return d.jsxs(rc,{title:"Additional Info",children:[e.description&&d.jsx("p",{className:"text-sm mb-1",children:e.description}),e.context_links&&d.jsx("div",{className:"flex flex-col",children:e.context_links.map((n,r)=>n?d.jsx("a",{className:"text-sm underline hover:no-underline mb-1",href:n.startsWith("http")?n:`https://${n}`,target:"_blank",rel:"noopener noreferrer",title:n,children:t(n)},r):null)}),e.sales_id!==null&&d.jsxs("div",{className:"inline-flex text-sm text-muted-foreground mb-1",children:["Followed by ",d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})})]}),e.created_at&&d.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:["Added on"," ",d.jsx(Bx,{source:"created_at",record:e,options:{year:"numeric",month:"long",day:"numeric"}})]})]})},"AdditionalInfo"),q4e=i(()=>d.jsx(lY,{children:d.jsx(z4e,{})}),"CompanyShow"),z4e=i(()=>{const{record:e,isPending:t}=cY(),n=Sa(),a=bD("/companies/:id/show/:tab")?.params?.tab||"activity",o=i(s=>{if(s!==a){if(s==="activity"){n(`/companies/${e?.id}/show`);return}n(`/companies/${e?.id}/show/${s}`)}},"handleTabChange");return t||!e?null:d.jsxs("div",{className:"mt-2 flex pb-2 gap-8",children:[d.jsx("div",{className:"flex-1",children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsxs("div",{className:"flex mb-3",children:[d.jsx(qp,{}),d.jsx("h5",{className:"text-xl ml-2 flex-1",children:e.name})]}),d.jsxs(xte,{defaultValue:a,onValueChange:o,children:[d.jsxs(wte,{className:"grid w-full grid-cols-3",children:[d.jsx(Cu,{value:"activity",children:"Activity"}),d.jsx(Cu,{value:"contacts",children:e.nb_contacts?e.nb_contacts===1?"1 Contact":`${e.nb_contacts} Contacts`:"No Contacts"}),e.nb_deals?d.jsx(Cu,{value:"deals",children:e.nb_deals===1?"1 deal":`${e.nb_deals} deals`}):null]}),d.jsx(Ou,{value:"activity",className:"pt-2",children:d.jsx(Ate,{companyId:e.id,context:"company"})}),d.jsx(Ou,{value:"contacts",children:e.nb_contacts?d.jsx(mg,{reference:"contacts_summary",target:"company_id",sort:{field:"last_name",order:"ASC"},children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex flex-row justify-end space-x-2 mt-1",children:[!!e.nb_contacts&&d.jsx(x4,{fields:["last_name","first_name","last_seen"]}),d.jsx(iV,{})]}),d.jsx(U4e,{})]})}):d.jsx("div",{className:"flex flex-col gap-4",children:d.jsx("div",{className:"flex flex-row justify-end space-x-2 mt-1",children:d.jsx(iV,{})})})}),d.jsx(Ou,{value:"deals",children:e.nb_deals?d.jsx(mg,{reference:"deals",target:"company_id",sort:{field:"name",order:"ASC"},children:d.jsx(B4e,{})}):null})]})]})})}),d.jsx(Fte,{})]})},"CompanyShowContent"),U4e=i(()=>{const e=Dr(),{data:t,error:n,isPending:r}=Gn();if(r||n)return null;const a=Date.now();return d.jsx("div",{className:"pt-0",children:t.map(o=>d.jsx(Ba,{value:o,children:d.jsx("div",{className:"p-0 text-sm",children:d.jsxs(fn,{to:`/contacts/${o.id}/show`,state:{from:e.pathname},className:"flex items-center justify-between hover:bg-muted py-2 transition-colors",children:[d.jsx("div",{className:"mr-4",children:d.jsx(is,{})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium",children:`${o.first_name} ${o.last_name}`}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.title,o.nb_tasks?` - ${o.nb_tasks} task${o.nb_tasks>1?"s":""}`:""," ",d.jsx(Tte,{})]})]}),o.last_seen&&d.jsx("div",{className:"text-right",children:d.jsxs("div",{className:"text-sm text-muted-foreground",children:["last activity ",wM(o.last_seen,a)," ago"," ",d.jsx(Ty,{status:o.status})]})})]})})},o.id))})},"ContactsIterator"),iV=i(()=>{const e=Wt();return d.jsx(ze,{variant:"outline",asChild:!0,size:"sm",className:"h-9",children:d.jsxs(fn,{to:"/contacts/create",state:e?{record:{company_id:e.id}}:void 0,className:"flex items-center gap-2",children:[d.jsx(a_e,{className:"h-4 w-4"}),"Add contact"]})})},"CreateRelatedContactButton"),B4e=i(()=>{const{data:e,error:t,isPending:n}=Gn(),{dealStages:r}=Va();if(n||t)return null;const a=Date.now();return d.jsx("div",{children:d.jsx("div",{children:e.map(o=>d.jsx("div",{className:"p-0 text-sm",children:d.jsxs(fn,{to:`/deals/${o.id}/show`,className:"flex items-center justify-between hover:bg-muted py-2 px-4 transition-colors",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium",children:o.name}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:[R4e(r,o.stage),","," ",o.amount.toLocaleString("en-US",{notation:"compact",style:"currency",currency:"USD",currencyDisplay:"narrowSymbol",minimumSignificantDigits:3}),o.category?`, ${o.category}`:""]})]}),d.jsx("div",{className:"text-right",children:d.jsxs("div",{className:"text-sm text-muted-foreground",children:["last activity ",wM(o.updated_at,a)," ago"," "]})})]})},o.id))})})},"DealsIterator"),Lte=i(()=>d.jsxs("div",{role:"toolbar",className:"sticky flex pt-4 pb-4 md:pb-0 bottom-0 bg-linear-to-b from-transparent to-card to-10% flex-row justify-end gap-2",children:[d.jsx($1,{}),d.jsx(yd,{})]}),"FormToolbar"),V4e=i(()=>d.jsx(aM,{actions:!1,redirect:"show",transform:i(e=>(e.website&&!e.website.startsWith("http")&&(e.website=`https://${e.website}`),e),"transform"),children:d.jsxs("div",{className:"mt-2 flex gap-8",children:[d.jsx(ra,{className:"flex flex-1 flex-col gap-4 pb-2",children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(cte,{}),d.jsx(Lte,{})]})})}),d.jsx(Fte,{link:"show"})]})}),"CompanyEdit"),H4e={list:BPe,create:a4e,edit:V4e,show:q4e};var K1="Switch",[W4e,VUe]=da(K1),[G4e,K4e]=W4e(K1),$te=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:o,required:s,disabled:l,value:f="on",onCheckedChange:c,form:p,...m}=e,[g,b]=y.useState(null),w=Zt(t,O=>b(O)),S=y.useRef(!1),_=g?p||!!g.closest("form"):!0,[j,E]=eo({prop:a,defaultProp:o??!1,onChange:c,caller:K1});return d.jsxs(G4e,{scope:n,checked:j,disabled:l,children:[d.jsx(yt.button,{type:"button",role:"switch","aria-checked":j,"aria-required":s,"data-state":Bte(j),"data-disabled":l?"":void 0,disabled:l,value:f,...m,ref:w,onClick:tt(e.onClick,O=>{E(C=>!C),_&&(S.current=O.isPropagationStopped(),S.current||O.stopPropagation())})}),_&&d.jsx(Ute,{control:g,bubbles:!S.current,name:r,value:f,checked:j,required:s,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});$te.displayName=K1;var qte="SwitchThumb",zte=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=K4e(qte,n);return d.jsx(yt.span,{"data-state":Bte(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});zte.displayName=qte;var Y4e="SwitchBubbleInput",Ute=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const s=y.useRef(null),l=Zt(s,o),f=N1(n),c=v1(t);return y.useEffect(()=>{const p=s.current;if(!p)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(f!==n&&b){const w=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(w)}},[f,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ute.displayName=Y4e;function Bte(e){return e?"checked":"unchecked"}i(Bte,"getState$2");var Q4e=$te,X4e=zte;function Vte({className:e,...t}){return d.jsx(Q4e,{"data-slot":"switch",className:Se("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(X4e,{"data-slot":"switch-thumb",className:Se("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}i(Vte,"Switch");const CN=i(e=>{const{className:t,defaultValue:n=!1,format:r,label:a,helperText:o,onBlur:s,onChange:l,onFocus:f,readOnly:c,disabled:p,parse:m,resource:g,source:b,validate:w,...S}=e,{id:_,field:j,isRequired:E}=Cc({defaultValue:n,format:r,parse:m,resource:g,source:b,onBlur:s,onChange:l,type:"checkbox",validate:w,disabled:p,readOnly:c,...S}),O=y.useCallback(C=>{j.onChange(C),j.onBlur()},[j]);return d.jsxs(Wo,{className:t,id:_,name:j.name,children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Vte,{id:_,checked:!!j.value,onFocus:f,onCheckedChange:O}),d.jsx(Xs,{htmlFor:_,children:d.jsx(ca,{label:a,source:b,resource:g,isRequired:E})})]}),d.jsx(Go,{helperText:o}),d.jsx(il,{})]})},"BooleanInput");var M4="Radio",[Z4e,Hte]=da(M4),[J4e,e3e]=Z4e(M4),Wte=y.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:a=!1,required:o,disabled:s,value:l="on",onCheck:f,form:c,...p}=e,[m,g]=y.useState(null),b=Zt(t,_=>g(_)),w=y.useRef(!1),S=m?c||!!m.closest("form"):!0;return d.jsxs(J4e,{scope:n,checked:a,disabled:s,children:[d.jsx(yt.button,{type:"button",role:"radio","aria-checked":a,"data-state":Qte(a),"data-disabled":s?"":void 0,disabled:s,value:l,...p,ref:b,onClick:tt(e.onClick,_=>{a||f?.(),S&&(w.current=_.isPropagationStopped(),w.current||_.stopPropagation())})}),S&&d.jsx(Yte,{control:m,bubbles:!w.current,name:r,value:l,checked:a,required:o,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});Wte.displayName=M4;var Gte="RadioIndicator",Kte=y.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...a}=e,o=e3e(Gte,n);return d.jsx(Ea,{present:r||o.checked,children:d.jsx(yt.span,{"data-state":Qte(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t})})});Kte.displayName=Gte;var t3e="RadioBubbleInput",Yte=y.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const s=y.useRef(null),l=Zt(s,o),f=N1(n),c=v1(t);return y.useEffect(()=>{const p=s.current;if(!p)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(f!==n&&b){const w=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(w)}},[f,n,r]),d.jsx(yt.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Yte.displayName=t3e;function Qte(e){return e?"checked":"unchecked"}i(Qte,"getState$1");var n3e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Y1="RadioGroup",[r3e,HUe]=da(Y1,[Ip,Hte]),Xte=Ip(),Zte=Hte(),[a3e,i3e]=r3e(Y1),Jte=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:a,value:o,required:s=!1,disabled:l=!1,orientation:f,dir:c,loop:p=!0,onValueChange:m,...g}=e,b=Xte(n),w=xy(c),[S,_]=eo({prop:o,defaultProp:a??null,onChange:m,caller:Y1});return d.jsx(a3e,{scope:n,name:r,required:s,disabled:l,value:S,onValueChange:_,children:d.jsx(JM,{asChild:!0,...b,orientation:f,dir:w,loop:p,children:d.jsx(yt.div,{role:"radiogroup","aria-required":s,"aria-orientation":f,"data-disabled":l?"":void 0,dir:w,...g,ref:t})})})});Jte.displayName=Y1;var ene="RadioGroupItem",tne=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...a}=e,o=i3e(ene,n),s=o.disabled||r,l=Xte(n),f=Zte(n),c=y.useRef(null),p=Zt(t,c),m=o.value===a.value,g=y.useRef(!1);return y.useEffect(()=>{const b=i(S=>{n3e.includes(S.key)&&(g.current=!0)},"handleKeyDown"),w=i(()=>g.current=!1,"handleKeyUp");return document.addEventListener("keydown",b),document.addEventListener("keyup",w),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",w)}},[]),d.jsx(e4,{asChild:!0,...l,focusable:!s,active:m,children:d.jsx(Wte,{disabled:s,required:o.required,checked:m,...f,...a,name:o.name,ref:p,onCheck:i(()=>o.onValueChange(a.value),"onCheck"),onKeyDown:tt(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:tt(a.onFocus,()=>{g.current&&c.current?.click()})})})});tne.displayName=ene;var o3e="RadioGroupIndicator",nne=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,a=Zte(n);return d.jsx(Kte,{...a,...r,ref:t})});nne.displayName=o3e;var s3e=Jte,l3e=tne,c3e=nne;function u3e({className:e,...t}){return d.jsx(s3e,{"data-slot":"radio-group",className:Se("grid gap-3",e),...t})}i(u3e,"RadioGroup");function d3e({className:e,...t}){return d.jsx(l3e,{"data-slot":"radio-group-item",className:Se("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(c3e,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(uP,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}i(d3e,"RadioGroupItem");const f3e=i(e=>{const{choices:t,isFetching:n,isLoading:r,isPending:a,resource:o,source:s,format:l,onBlur:f,onChange:c,parse:p,validate:m,disabled:g,readOnly:b,optionText:w,optionValue:S="id",translateChoice:_,disableValue:j="disabled",className:E,helperText:O,label:C,row:T,...R}=e,{allChoices:A,isPending:P,error:D,resource:M,source:I}=yM({choices:t,isFetching:n,isLoading:r,isPending:a,resource:o,source:s});if(I===void 0)throw new Error("If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the source prop");if(!P&&!D&&A===void 0)throw new Error("If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop");const{id:F,field:L,isRequired:q}=Cc({format:l,onBlur:f,onChange:c,parse:p,resource:M,source:I,validate:m,disabled:g,readOnly:b,...R}),{getChoiceText:U,getChoiceValue:$,getDisableValue:V}=Jw({optionText:w,optionValue:S,translateChoice:_,disableValue:j});return P?d.jsx(sn,{className:"w-full h-9"}):d.jsxs(Wo,{id:F,className:E,name:L.name,children:[C&&d.jsx(Xs,{children:d.jsx(ca,{label:C,source:I,resource:M,isRequired:q})}),d.jsx(jy,{children:d.jsx(u3e,{...R,value:L.value||"",onValueChange:L.onChange,className:Se("flex",T?"flex-row gap-4":"flex-col gap-2"),disabled:g||b,children:A?.map(z=>{const W=$(z),H=g||b||V(z);return d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(d3e,{value:W,id:`${F}-${W}`,disabled:H}),d.jsx(Hn,{htmlFor:`${F}-${W}`,className:Se("text-sm font-normal cursor-pointer",H&&"opacity-50 cursor-not-allowed"),children:U(z)})]},W)})})}),d.jsx(Go,{helperText:O}),d.jsx(il,{})]})},"RadioButtonGroupInput"),h3e=i(({validate:e})=>{const[t]=vM(),{identity:n}=Zn(),r=Vt(),a=i(async o=>{if(o)try{return await t("companies",{data:{name:o,sales_id:n?.id,created_at:new Date().toISOString()}},{returnPromise:!0})}catch{r("An error occurred while creating the company",{type:"error"})}},"handleCreateCompany");return d.jsx(B1,{optionText:"name",helperText:!1,onCreate:a,createItemLabel:"Create %{item}",createLabel:"Start typing to create a new company",validate:e})},"AutocompleteCompanyInput"),rne=i(()=>{const e=hd();return d.jsxs("div",{className:"flex flex-col gap-2 p-1",children:[d.jsx(is,{}),d.jsxs("div",{className:`flex gap-6 ${e?"flex-col":"flex-row"}`,children:[d.jsxs("div",{className:"flex flex-col gap-10 flex-1",children:[d.jsx(p3e,{}),d.jsx(m3e,{})]}),d.jsx(pd,{orientation:e?"horizontal":"vertical",className:"flex-shrink-0"}),d.jsxs("div",{className:"flex flex-col gap-10 flex-1",children:[d.jsx(v3e,{}),d.jsx(g3e,{})]})]})]})},"ContactInputs"),p3e=i(()=>{const{contactGender:e}=Va();return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Identity"}),d.jsx(f3e,{label:!1,row:!0,source:"gender",choices:e,helperText:!1,optionText:"label",optionValue:"value",defaultValue:e[0].value}),d.jsx(ln,{source:"first_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:nr(),helperText:!1})]})},"ContactIdentityInputs"),m3e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Position"}),d.jsx(ln,{source:"title",helperText:!1}),d.jsx(Ry,{source:"company_id",reference:"companies",perPage:10,children:d.jsx(h3e,{})})]}),"ContactPositionInputs"),v3e=i(()=>{const{getValues:e,setValue:t}=ua(),n=i(o=>{const{first_name:s,last_name:l}=e();if(s||l||!o)return;const[f,c]=o.split("@")[0].split(".");t("first_name",f.charAt(0).toUpperCase()+f.slice(1)),t("last_name",c?c.charAt(0).toUpperCase()+c.slice(1):"")},"handleEmailChange"),r=i(o=>{const s=o.clipboardData?.getData("text/plain");n(s)},"handleEmailPaste"),a=i(o=>{const s=o.target.value;n(s)},"handleEmailBlur");return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Personal info"}),d.jsx(cN,{source:"email_jsonb",label:"Email addresses",helperText:!1,children:d.jsxs(uN,{inline:!0,disableReordering:!0,disableClear:!0,className:"[&>ul>li]:border-b-0 [&>ul>li]:pb-0",children:[d.jsx(ln,{source:"email",className:"w-full",helperText:!1,label:!1,placeholder:"Email",validate:JK(),onPaste:r,onBlur:a}),d.jsx(Zs,{source:"type",helperText:!1,label:!1,optionText:"id",choices:oV,defaultValue:"Work",className:"w-24 min-w-24"})]})}),d.jsx(cN,{source:"phone_jsonb",label:"Phone numbers",helperText:!1,children:d.jsxs(uN,{inline:!0,disableReordering:!0,disableClear:!0,className:"[&>ul>li]:border-b-0 [&>ul>li]:pb-0",children:[d.jsx(ln,{source:"number",className:"w-full",helperText:!1,label:!1,placeholder:"Phone number"}),d.jsx(Zs,{source:"type",helperText:!1,label:!1,optionText:"id",choices:oV,defaultValue:"Work",className:"w-24 min-w-24"})]})}),d.jsx(ln,{source:"linkedin_url",label:"Linkedin URL",helperText:!1,validate:ste})]})},"ContactPersonalInformationInputs"),oV=[{id:"Work"},{id:"Home"},{id:"Other"}],g3e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Misc"}),d.jsx(ln,{source:"background",label:"Background info (bio, how you met, etc)",multiline:!0,helperText:!1}),d.jsx(CN,{source:"has_newsletter",helperText:!1}),d.jsx(Ry,{reference:"sales",source:"sales_id",sort:{field:"last_name",order:"ASC"},filter:{"disabled@neq":!0},children:d.jsx(Zs,{helperText:!1,label:"Account manager",optionText:y3e,validate:nr()})})]}),"ContactMiscInputs"),y3e=i(e=>`${e.first_name} ${e.last_name}`,"saleOptionRenderer"),b3e=i(()=>{const{identity:e}=Zn();return d.jsx(Lw,{redirect:"show",transform:i(t=>({...t,first_seen:new Date().toISOString(),last_seen:new Date().toISOString(),tags:[]}),"transform"),children:d.jsx("div",{className:"mt-2 flex lg:mr-72",children:d.jsx("div",{className:"flex-1",children:d.jsx(ra,{defaultValues:{sales_id:e?.id},children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(rne,{}),d.jsx(q1,{})]})})})})})})},"ContactCreate"),sV=i(e=>{const{children:t,resource:n,perPage:r,sort:a,filter:o}=e,s=oi(e)||x3e,l=zw({data:s,resource:n,perPage:r,sort:a,filter:o});return d.jsx(ny,{value:l,children:t})},"ArrayField"),x3e=[],w3e=i(({icon:e=_3e,label:t,className:n,...r})=>{const{handleDelete:a,isPending:o}=ape(r);return d.jsxs(ze,{variant:"destructive",type:"button",onClick:a,disabled:o,className:Se("h-9",n),children:[e,d.jsx(lr,{i18nKey:t??"ra.action.delete",children:t??"Delete"})]})},"BulkDeleteButton"),_3e=d.jsx(MM,{}),S3e=i(({icon:e=j3e,label:t="ra.action.export",onClick:n,...r})=>{const a=Kpe(r),o=i(s=>{a(),n?.(s)},"handleClick");return d.jsxs(ze,{onClick:o,role:"button",variant:"outline",size:"sm",className:"flex items-center gap-2 h-9",...E3e(r),children:[e,t&&d.jsx(lr,{i18nKey:t,children:t})]})},"BulkExportButton"),j3e=d.jsx(TM,{className:"h-4 w-4"}),E3e=i(({resource:e,exporter:t,onClick:n,label:r,icon:a,meta:o,...s})=>s,"sanitizeRestProps");function ane(){return d.jsxs(d.Fragment,{children:[d.jsx(S3e,{}),d.jsx(w3e,{})]})}i(ane,"BulkActionsToolbarChildren");const ine=i(({children:e=d.jsx(ane,{})})=>{const{selectedIds:t,onUnselectItems:n}=Gn();if(!t?.length)return null;const r=i(a=>{a.stopPropagation(),n()},"handleUnselectAll");return d.jsxs(pn,{className:"flex flex-col gap-2 md:gap-6 md:flex-row items-stretch sm:items-center p-2 px-4 w-[90%] sm:w-fit mx-auto fixed bottom-2 left-0 right-0 z-10 bg-zinc-100 dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ze,{variant:"ghost",className:"has-[>svg]:px-0",onClick:r,children:d.jsx(Tp,{})}),d.jsx("span",{className:"text-sm text-muted-foreground",children:d.jsxs(lr,{i18nKey:"ra.action.bulk_actions",options:{smart_count:t.length},children:[t.length," rows selected"]})})]}),e]})},"BulkActionsToolbar");var bA={exports:{}},lV;function C3e(){return lV||(lV=1,(function(e){(function(t,n){e.exports?e.exports=n():this[t]=n()})("Diacritics",function(){for(var t={map:{}},n=[{base:" ",letters:" "},{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"Th",letters:"Þ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"ff",letters:"ff"},{base:"fi",letters:"fi"},{base:"fl",letters:"fl"},{base:"ffi",letters:"ffi"},{base:"ffl",letters:"ffl"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nñnⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ"},{base:"nj",letters:"nj"},{base:"o",letters:"߀oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oe",letters:"Œœ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"ss",letters:"ß"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"th",letters:"þ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],r=0,a=n.length;r<a;r++)for(var o=n[r].letters.split(""),s=0,l=o.length;s<l;s++)t.map[o[s]]=n[r].base;return t.clean=function(f){if(!f||!f.length||f.length<1)return"";for(var c="",p=f.split(""),m=0,g=p.length,b;m<g;m++)b=p[m],c+=b in t.map?t.map[b]:b;return c},t})})(bA)),bA.exports}i(C3e,"requireDiacritics");var cV=C3e();const O3e=i(e=>{const{selected:t,label:n,onToggle:r,onMove:a,source:o,index:s}=e,l=Ht(),f=y.useRef(null),c=y.useRef(null),p=y.useRef(null),m=y.useCallback(_=>{c.current=_.clientX,p.current=_.clientY},[]),g=i(()=>{document.addEventListener("dragover",m)},"handleDragStart"),b=i(_=>{const j=_.target;j.dataset.dragActive="true";const E=j.closest("ul");if(c.current==null||p.current==null)return;const O=document.elementFromPoint(c.current,p.current);let C=O===null?j:O.closest("li");if(!C)return;if(C.classList.contains("dragIcon")){const R=C.parentNode;R instanceof HTMLElement&&(C=R)}if(C===j)return;const T=C.parentNode;if(E&&T instanceof HTMLElement&&E===T.closest("ul")){const R=C.dataset.index;R&&(f.current=parseInt(R,10)),C===j.nextSibling&&(C=C.nextSibling),E.insertBefore(j,C)}},"handleDrag"),w=i(_=>{const j=_.target,E=j.closest("ul"),O=c.current!=null&&p.current!=null?document.elementFromPoint(c.current,p.current):null;let C=c.current==null||p.current==null||O===null?j:O.closest("li");if(p.current!==null&&E&&!C){const T=j.closest("ul");T&&p.current>T.getBoundingClientRect().bottom?C=E.lastChild:C=E.firstChild}C&&E&&C.closest("ul")===E?a&&a(j.dataset.index,f.current):(_.preventDefault(),_.stopPropagation()),j.dataset.dragActive="false",document.removeEventListener("dragover",m)},"handleDragEnd"),S=i(_=>{_.preventDefault(),_.dataTransfer.dropEffect="move"},"handleDragOver");return d.jsxs("li",{role:"option",draggable:a?"true":void 0,onDrag:a?b:void 0,onDragStart:a?g:void 0,onDragEnd:a?w:void 0,onDragOver:a?S:void 0,"data-index":s,className:Se("flex justify-between items-center py-1","data-[drag-active=true]:bg-transparent data-[drag-active=true]:text-transparent data-[drag-active=true]:outline data-[drag-active=true]:outline-1 data-[drag-active=true]:outline-border"),children:[d.jsxs("label",{htmlFor:`switch_${s}`,className:"flex items-center gap-2 cursor-pointer",children:[d.jsx(Vte,{id:`switch_${s}`,checked:t,onCheckedChange:r,name:`${s}`}),d.jsx("span",{className:"text-sm",children:d.jsx(ca,{label:n,source:o,resource:l})})]}),a&&d.jsx(Hwe,{className:"cursor-move dragIcon w-4 h-4 text-muted-foreground"})]},o)},"FieldToggle"),k3e=i(({children:e})=>{const t=xt(),{storeKey:n,defaultHiddenColumns:r}=Zw(),[a,o]=ba(`${n}_columnRanks`),[s,l]=ba(n,r),f=`${n}-columnsSelector`,[c,p]=y.useState(()=>typeof document<"u"?document.getElementById(f):null);y.useEffect(()=>{if(c&&typeof document<"u"&&document.body.contains(c))return;const _=setInterval(()=>{const E=document.getElementById(f);E&&p(E)},100),j=setTimeout(()=>clearInterval(_),500);return()=>{clearInterval(_),clearTimeout(j)}},[f,c]);const[m,g]=y.useState("");if(!c)return null;const b=y.Children.toArray(e),w=ON(a??[],b.length),S=b.length>5;return el.createPortal(d.jsxs("ul",{className:"max-h-[50vh] p-1 overflow-auto",children:[S?d.jsx("li",{className:"pb-2",tabIndex:-1,children:d.jsxs("div",{className:"relative",children:[d.jsx(_r,{value:m,onChange:i(_=>{g(_.target.value)},"onChange"),placeholder:t("ra.action.search_columns",{_:"Search columns"}),className:"pr-8"}),d.jsx(DM,{className:"absolute right-2 top-2 h-4 w-4 text-muted-foreground"}),m&&d.jsx("button",{onClick:i(()=>g(""),"onClick"),className:"absolute right-8 top-2 h-4 w-4 text-muted-foreground","aria-label":"Clear",children:"×"})]})}):null,w.map((_,j)=>d.jsx(PY.Provider,{value:_,children:d.jsx(NY.Provider,{value:m,children:b[_]},j)},j)),d.jsx("li",{className:"text-center mt-2 px-3",children:d.jsx(ze,{variant:"outline",size:"sm",onClick:i(()=>{o(void 0),l(r)},"onClick"),children:"Reset"})})]}),c)},"ColumnsSelector"),R3e=i(({source:e,label:t})=>{const n=Ht(),{storeKey:r,defaultHiddenColumns:a}=Zw(),[o,s]=ba(r,a),l=Zge(),[f,c]=ba(`${r}_columnRanks`),p=Jge(),m=Yw();if(!e&&!t)return null;const g=m({label:typeof t=="string"?t:void 0,resource:n,source:e}),b=o.includes(e),w=A3e(g,p),S=i((_,j)=>{const E=f?Math.max(Number(_),Number(j||0))>f.length-1?ON(f,Math.max(Number(_),Number(j||0))+1):f:ON([],Math.max(Number(_),Number(j||0))+1),O=E.findIndex(R=>R==Number(_)),C=E.findIndex(R=>R==Number(j));if(O===-1||C===-1)return;let T;O>C?T=[...E.slice(0,C),E[O],...E.slice(C,O),...E.slice(O+1)]:T=[...E.slice(0,O),...E.slice(O+1,C+1),E[O],...E.slice(C+1)],c(T)},"handleMove");return w?d.jsx(O3e,{source:e,label:g,index:String(l),selected:!b,onToggle:i(()=>s(b?o.filter(_=>_!==e):[...o,e]),"onToggle"),onMove:S},l):null},"ColumnsSelectorItem"),ON=i((e,t)=>e.concat(Array.from({length:t-e.length},(n,r)=>e.length+r)),"padRanks"),A3e=i((e,t)=>t?cV.clean(e).toLowerCase().includes(cV.clean(t).toLowerCase()):!0,"fieldLabelMatchesFilter");function T3e({className:e,...t}){return d.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:d.jsx("table",{"data-slot":"table",className:Se("w-full caption-bottom text-sm",e),...t})})}i(T3e,"Table");function P3e({className:e,...t}){return d.jsx("thead",{"data-slot":"table-header",className:Se("[&_tr]:border-b",e),...t})}i(P3e,"TableHeader");function N3e({className:e,...t}){return d.jsx("tbody",{"data-slot":"table-body",className:Se("[&_tr:last-child]:border-0",e),...t})}i(N3e,"TableBody");function one({className:e,...t}){return d.jsx("tr",{"data-slot":"table-row",className:Se("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}i(one,"TableRow");function sne({className:e,...t}){return d.jsx("th",{"data-slot":"table-head",className:Se("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}i(sne,"TableHead");function lne({className:e,...t}){return d.jsx("td",{"data-slot":"table-cell",className:Se("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}i(lne,"TableCell");var Q1="Checkbox",[D3e,WUe]=da(Q1),[M3e,I4]=D3e(Q1);function I3e(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:o,form:s,name:l,onCheckedChange:f,required:c,value:p="on",internal_do_not_use_render:m}=e,[g,b]=eo({prop:n,defaultProp:a??!1,onChange:f,caller:Q1}),[w,S]=y.useState(null),[_,j]=y.useState(null),E=y.useRef(!1),O=w?!!s||!!w.closest("form"):!0,C={checked:g,disabled:o,setChecked:b,control:w,setControl:S,name:l,form:s,value:p,hasConsumerStoppedPropagationRef:E,required:c,defaultChecked:dc(a)?!1:a,isFormControl:O,bubbleInput:_,setBubbleInput:j};return d.jsx(M3e,{scope:t,...C,children:F3e(m)?m(C):r})}i(I3e,"CheckboxProvider");var cne="CheckboxTrigger",une=y.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:o,value:s,disabled:l,checked:f,required:c,setControl:p,setChecked:m,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:w}=I4(cne,e),S=Zt(a,p),_=y.useRef(f);return y.useEffect(()=>{const j=o?.form;if(j){const E=i(()=>m(_.current),"reset");return j.addEventListener("reset",E),()=>j.removeEventListener("reset",E)}},[o,m]),d.jsx(yt.button,{type:"button",role:"checkbox","aria-checked":dc(f)?"mixed":f,"aria-required":c,"data-state":vne(f),"data-disabled":l?"":void 0,disabled:l,value:s,...r,ref:S,onKeyDown:tt(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:tt(n,j=>{m(E=>dc(E)?!0:!E),w&&b&&(g.current=j.isPropagationStopped(),g.current||j.stopPropagation())})})});une.displayName=cne;var dne=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:o,required:s,disabled:l,value:f,onCheckedChange:c,form:p,...m}=e;return d.jsx(I3e,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:l,required:s,onCheckedChange:c,name:r,form:p,value:f,internal_do_not_use_render:i(({isFormControl:g})=>d.jsxs(d.Fragment,{children:[d.jsx(une,{...m,ref:t,__scopeCheckbox:n}),g&&d.jsx(mne,{__scopeCheckbox:n})]}),"internal_do_not_use_render")})});dne.displayName=Q1;var fne="CheckboxIndicator",hne=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,o=I4(fne,n);return d.jsx(Ea,{present:r||dc(o.checked)||o.checked===!0,children:d.jsx(yt.span,{"data-state":vne(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});hne.displayName=fne;var pne="CheckboxBubbleInput",mne=y.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:s,required:l,disabled:f,name:c,value:p,form:m,bubbleInput:g,setBubbleInput:b}=I4(pne,e),w=Zt(n,b),S=N1(o),_=v1(r);y.useEffect(()=>{const E=g;if(!E)return;const O=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(O,"checked").set,R=!a.current;if(S!==o&&T){const A=new Event("click",{bubbles:R});E.indeterminate=dc(o),T.call(E,dc(o)?!1:o),E.dispatchEvent(A)}},[g,S,o,a]);const j=y.useRef(dc(o)?!1:o);return d.jsx(yt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??j.current,required:l,disabled:f,name:c,value:p,form:m,...t,tabIndex:-1,ref:w,style:{...t.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});mne.displayName=pne;function F3e(e){return typeof e=="function"}i(F3e,"isFunction");function dc(e){return e==="indeterminate"}i(dc,"isIndeterminate");function vne(e){return dc(e)?"indeterminate":e?"checked":"unchecked"}i(vne,"getState");function Up({className:e,...t}){return d.jsx(dne,{"data-slot":"checkbox",className:Se("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(hne,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(uc,{className:"size-3.5"})})})}i(Up,"Checkbox");const L3e=i(({defaultValue:e,source:t,record:n,empty:r,transform:a=$3e,locales:o,options:s,...l})=>{let f=oi({defaultValue:e,source:t,record:n});const c=xt();return f==null?r?d.jsx("span",{...l,children:typeof r=="string"?c(r,{_:r}):r}):null:(a&&(f=a(f)),d.jsx("span",{...l,children:q3e&&typeof f=="number"?f.toLocaleString(o,s):f}))},"NumberField"),$3e=i(e=>e&&typeof e=="string"&&!isNaN(e)?+e:e,"defaultTransform"),q3e=!!(typeof Intl=="object"&&Intl&&typeof Intl.NumberFormat=="function"),uV=d.jsx(ane,{});function Fs(e){const{children:t,className:n,rowClassName:r,bulkActionButtons:a=uV,bulkActionsToolbar:o,...s}=e,l=!!o||a!==!1,f=Ht(e),c=e.storeKey||`${f}.datatable`,[p]=ba(`${c}_columnRanks`),m=p?W3e(t,p):t;return d.jsxs(Qge,{hasBulkActions:l,loading:null,empty:d.jsx(H3e,{}),...s,children:[d.jsx("div",{className:Se("rounded-md border",n),children:d.jsxs(T3e,{children:[d.jsx(nP.Provider,{value:"header",children:d.jsx(z3e,{children:m})}),d.jsx(U3e,{rowClassName:r,children:m})]})}),o??(a!==!1&&d.jsx(ine,{children:y.isValidElement(a)?a:uV})),d.jsx(nP.Provider,{value:"columnsSelector",children:d.jsx(k3e,{children:t})})]})}i(Fs,"DataTable");Fs.Col=gne;Fs.NumberCol=Q3e;const z3e=i(({children:e})=>{const t=OY(),{hasBulkActions:n=!1}=EY(),{onSelect:r}=gM(),a=RY(),o=i(l=>{!r||!t||!a||r(l?a.concat(t.filter(f=>!a.includes(f.id)).map(f=>f.id)):[])},"handleToggleSelectAll"),s=Array.isArray(t)?t.map(l=>l.id):[];return d.jsx(P3e,{children:d.jsxs(one,{children:[n?d.jsx(sne,{className:"w-8",children:d.jsx(Up,{onCheckedChange:o,checked:a&&a.length>0&&s.length>0&&s.every(l=>a.includes(l)),className:"mb-2"})}):null,e]})})},"DataTableHead"),U3e=i(({children:e,rowClassName:t})=>{const n=OY();return d.jsx(N3e,{children:n?.map((r,a)=>d.jsx(Ba,{value:r,children:d.jsx(B3e,{className:t?.(r),children:e})},r.id??`row${a}`))})},"DataTableBody"),B3e=i(({children:e,className:t})=>{const{rowClick:n,handleToggleItem:r}=gM(),a=RY(),{hasBulkActions:o=!1}=EY(),s=Wt();if(!s)throw new Error("DataTableRow can only be used within a RecordContext");const l=Ht();if(!l)throw new Error("DataTableRow can only be used within a ResourceContext");const f=Sa(),c=JG(),p=y.useCallback(g=>{g.stopPropagation(),r&&r(s.id,g)},[r,s.id]),m=y.useCallback(async()=>{const g=typeof n=="function"?n(s.id,l,s):n,b=V3e(g)?await g:g,w=await c({record:s,resource:l,link:b});w===!1||w==null||f(w,{state:{_scrollToTop:!0}})},[s,l,n,f,c]);return d.jsxs(one,{onClick:m,className:Se(n!==!1&&"cursor-pointer",t),children:[o?d.jsx(lne,{className:"flex w-8",onClick:p,children:d.jsx(Up,{checked:a?.includes(s.id),onClick:p})}):null,e]},s.id)},"DataTableRow"),V3e=i(e=>e&&typeof e.then=="function","isPromise"),H3e=i(()=>d.jsx(ai,{children:d.jsx(ki,{children:"No results found."})}),"DataTableEmpty");function gne(e){switch(eye()){case"columnsSelector":return d.jsx(R3e,{...e});case"header":return d.jsx(G3e,{...e});case"data":return d.jsx(Y3e,{...e})}}i(gne,"DataTableColumn");const W3e=i((e,t)=>y.Children.toArray(e).reduce((n,r,a)=>{const o=t.indexOf(a);return o===-1?n[a]=r:n[o]=r,n},[]),"reorderChildren");function G3e(e){const{disableSort:t,source:n,label:r,sortByOrder:a,className:o,headerClassName:s}=e,l=Yge(),{handleSort:f}=gM(),c=Ht(),p=xt(),m=Yw(),{storeKey:g,defaultHiddenColumns:b}=Zw(),[w]=ba(g,b);if(w.includes(n))return null;const _=l&&l.field===n?K3e[l.order]:a??"ASC",j=m({label:typeof r=="string"?r:void 0,resource:c,source:n}),E=p("ra.sort.sort_by",{field:j,field_lower_first:typeof j=="string"?j.charAt(0).toLowerCase()+j.slice(1):void 0,order:p(`ra.sort.${_}`),_:p("ra.action.sort")});return d.jsx(sne,{className:Se(o,s),children:f&&l&&!t&&n?d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsxs(ze,{variant:"ghost",size:"sm",className:"-ml-3 -mr-3 h-8 data-[state=open]:bg-accent cursor-pointer","data-field":n,onClick:f,children:[s?.includes("text-right")?null:d.jsx(ca,{label:r,source:n,resource:c}),l.field===n?l.order==="ASC"?d.jsx(Mxe,{className:"ml-2 h-6 w-6"}):d.jsx(zxe,{className:"ml-2 h-6 w-6"}):null,s?.includes("text-right")?d.jsx(ca,{label:r,source:n,resource:c}):null]})}),d.jsx(oo,{children:d.jsx("p",{children:E})})]})}):d.jsx(ca,{label:r,source:n,resource:c})})}i(G3e,"DataTableHeadCell");const K3e={ASC:"DESC",DESC:"ASC"};function Y3e(e){const{children:t,render:n,field:r,source:a,className:o,cellClassName:s,conditionalClassName:l}=e,{storeKey:f,defaultHiddenColumns:c}=Zw(),[p]=ba(f,c),m=Wt();if(p.includes(a))return null;if(!n&&!r&&!t&&!a)throw new Error("DataTableColumn: Missing at least one of the following props: render, field, children, or source");return d.jsx(lne,{className:Se("py-1",o,s,m&&l?.(m)),children:t??(n?m&&n(m):r?y.createElement(r,{source:a}):Yt(m,a))})}i(Y3e,"DataTableCell");function Q3e(e){const{source:t,options:n,locales:r,className:a,headerClassName:o,cellClassName:s,...l}=e;return d.jsx(gne,{source:t,...l,className:a,headerClassName:Se("text-right",o),cellClassName:Se("text-right",s),children:d.jsx(L3e,{source:t,options:n,locales:r})})}i(Q3e,"DataTableNumberColumn");const yne=i(e=>{const{className:t,inputClassName:n,defaultValue:r,format:a=Z3e,label:o,source:s,helperText:l,onChange:f,onFocus:c,validate:p,disabled:m,readOnly:g,...b}=e,w=Ht(e),{field:S,id:_,isRequired:j}=Cc({defaultValue:r,source:s,validate:p,disabled:m,readOnly:g,format:a,...b}),E=y.useRef(null),O=y.useRef(S.value),[C,T]=y.useState(1),R=y.useRef(!1);y.useEffect(()=>{if(R.current){R.current=!1;return}E.current?.value!==S.value&&!(E.current?.value===""&&S.value==null)&&(O.current=S.value,T($=>$+1),R.current=!1)},[T,S.value]);const{onBlur:A}=S,P=y.useRef(!1),D=Et(U=>{if(f&&f(U),typeof U.target>"u"||typeof U.target.value>"u")return;const $=U.target,V=$.value,z=V===""||$.valueAsDate!=null&&!isNaN(new Date($.valueAsDate).getTime());V!==""&&V!=null&&z&&(S.onChange(V),R.current=!0)}),M=Et(U=>{c&&c(U),P.current=!0}),I=Et(()=>{if(P.current=!1,!E.current)return;const U=E.current.value;(U===""||E.current.valueAsDate!=null&&!isNaN(new Date(E.current.valueAsDate).getTime()))&&S.value!==U&&S.onChange(U??""),A&&A()}),{ref:F,name:L}=S,q=y.useCallback(U=>{typeof F=="function"?F(U):F&&U&&(F.current=U),E.current=U},[F]);return d.jsxs(Wo,{id:_,className:t,name:L,children:[o!==!1&&d.jsx(Xs,{children:d.jsx(ca,{label:o,source:s,resource:w,isRequired:j})}),d.jsx(jy,{children:d.jsx(_r,{ref:q,defaultValue:a(O.current)??"",type:"date",onChange:D,onFocus:M,onBlur:I,className:Se("ra-input",`ra-input-${s}`,"[color-scheme:light] dark:[color-scheme:dark] relative [&::-webkit-calendar-picker-indicator]:cursor-pointer [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:right-3 [&::-webkit-calendar-picker-indicator]:opacity-100",n),disabled:m||g,readOnly:g,...b},C)}),d.jsx(Go,{helperText:l}),d.jsx(il,{})]})},"DateInput"),dV=i(e=>{if(!(e instanceof Date)||isNaN(e.getDate()))return"";const t=new Date(e.getTime()),n="00",r=t.getFullYear().toString(),a=(t.getMonth()+1).toString(),o=t.getDate().toString();return`${r}-${(n+a).slice(-2)}-${(n+o).slice(-2)}`},"convertDateToString$1"),X3e=/^\d{4}-\d{2}-\d{2}$/,Z3e=i(e=>e==null||e===""?null:e instanceof Date?dV(e):typeof e=="string"&&X3e.test(e)?e:dV(new Date(e)),"defaultFormat"),J3e=i(({className:e,defaultValue:t,format:n=n5e,parse:r=r5e,label:a,helperText:o,onBlur:s,onChange:l,onFocus:f,source:c,resource:p,validate:m,disabled:g,readOnly:b,...w})=>{const{field:S,id:_,isRequired:j}=Cc({defaultValue:t,onBlur:s,resource:p,source:c,validate:m,disabled:g,readOnly:b,format:n,parse:r,...w}),E=y.useRef(void 0),O=y.useRef(S.value),[C,T]=y.useState(1),R=y.useRef(!1);y.useEffect(()=>{if(R.current){R.current=!1;return}E.current?.value!==S.value&&!(E.current?.value===""&&S.value==null)&&(O.current=S.value,T($=>$+1),R.current=!1)},[T,S.value]);const{onBlur:A}=S,P=y.useRef(!1),D=i(U=>{if(l&&l(U),typeof U.target>"u"||typeof U.target.value>"u")return;const $=U.target,V=$.value,z=V===""||!isNaN(new Date($.value).getTime());V!==""&&V!=null&&z&&(S.onChange(V),R.current=!0)},"handleChange"),M=i(U=>{f&&f(U),P.current=!0},"handleFocus"),I=i(()=>{if(P.current=!1,!E.current)return;const U=E.current.value;(U===""||!isNaN(new Date(E.current.value).getTime()))&&S.value!==U&&S.onChange(U??""),A&&A()},"handleBlur"),{ref:F,name:L}=S,q=a5e(F,E);return d.jsxs(Wo,{id:_,className:e,name:S.name,children:[a!==!1&&d.jsx(Xs,{children:d.jsx(ca,{label:a,source:c,resource:p,isRequired:j})}),d.jsx(jy,{children:d.jsx(_r,{id:_,ref:q,name:L,defaultValue:n(O.current),type:"datetime-local",onChange:D,onFocus:M,onBlur:I,className:CM("ra-input",`ra-input-${c}`,"[color-scheme:light] dark:[color-scheme:dark] relative [&::-webkit-calendar-picker-indicator]:cursor-pointer [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:right-3 [&::-webkit-calendar-picker-indicator]:opacity-100",e),disabled:g||b,readOnly:b},C)}),d.jsx(Go,{helperText:o}),d.jsx(il,{})]})},"DateTimeInput"),bne=i((e=2)=>t=>("0".repeat(e)+t).slice(-e),"leftPad"),e5e=bne(4),mb=bne(2),fV=i(e=>{if(!(e instanceof Date)||isNaN(e.getDate()))return"";const t=e5e(e.getFullYear()),n=mb(e.getMonth()+1),r=mb(e.getDate()),a=mb(e.getHours()),o=mb(e.getMinutes());return`${t}-${n}-${r}T${a}:${o}`},"convertDateToString"),t5e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/,n5e=i(e=>e==null||e===""?"":e instanceof Date?fV(e):t5e.test(e)?e:fV(new Date(e)),"formatDateTime"),r5e=i(e=>new Date(e).toISOString(),"convertDateStringToISO");function a5e(...e){const t=y.useRef(void 0),n=y.useCallback(r=>{const a=e.map(o=>{if(o==null)return null;if(typeof o=="function"){const s=o,l=s(r);return typeof l=="function"?l:()=>{s(null)}}return o.current=r,()=>{o.current=null}});return()=>{a.forEach(o=>o?.())}},e);return y.useMemo(()=>e.every(r=>r==null)?null:r=>{t.current&&(t.current(),t.current=void 0),r!=null&&(t.current=n(r))},e)}i(a5e,"useForkRef");const xne=i(e=>{const{className:t,empty:n,defaultValue:r,source:a,record:o,...s}=e,l=oi({defaultValue:r,source:a,record:o}),f=xt();return l==null?n?d.jsx("span",{className:t,...s,children:typeof n=="string"?f(n,{_:n}):n}):null:d.jsx("a",{className:Se("underline hover:no-underline",t),href:`mailto:${l}`,onClick:o5e,...s,children:l})},"EmailFieldImpl");xne.displayName="EmailFieldImpl";const i5e=G1(xne),o5e=i(e=>e.stopPropagation(),"stopPropagation"),wne=i(e=>{const{className:t,empty:n,title:r,src:a,target:o,download:s,defaultValue:l,source:f,record:c,...p}=e,m=oi({defaultValue:l,source:f,record:c}),g=oi({...e,source:r})?.toString()??r,b=xt();return m==null||Array.isArray(m)&&m.length===0?n?d.jsx("div",{className:Se("inline-block",t),...p,children:typeof n=="string"?b(n,{_:n}):n}):null:Array.isArray(m)?d.jsx("ul",{className:Se("inline-block",t),...p,children:m.map((w,S)=>{const _=r&&Yt(w,r,r),j=a?Yt(w,a,r):r;return d.jsx("li",{children:d.jsx("a",{href:j,title:_,target:o,download:s,onClick:i(E=>E.stopPropagation(),"onClick"),children:_})},S)})}):d.jsx("div",{className:Se("inline-block",t),...p,children:d.jsx("a",{href:m?.toString(),title:g,target:o,download:s,onClick:i(w=>w.stopPropagation(),"onClick"),children:g})})},"FileField"),_ne=i(e=>{const{alwaysOn:t,defaultValue:n,format:r,label:a,helperText:o,name:s,onBlur:l,onChange:f,parse:c,resource:p,source:m,validate:g,readOnly:b,disabled:w,accept:S,maxSize:_,minSize:j,multiple:E=!1,options:O={},children:C,className:T,inputProps:R,onRemove:A,validateFileRemoval:P,placeholder:D,labelMultiple:M="ra.input.file.upload_several",labelSingle:I="ra.input.file.upload_single",removeIcon:F,...L}=e,{onDrop:q}=O,U=xt(),$=i(ce=>{if(!(ce instanceof File))return ce;const he=URL.createObjectURL(ce);return{rawFile:ce,src:he,title:ce.name}},"transformFile"),V=i(ce=>ce?Array.isArray(ce)?ce.map($):$(ce):E?[]:null,"transformFiles"),{id:z,field:{onChange:W,onBlur:H,value:Q,name:Y},isRequired:K}=Cc({alwaysOn:t,defaultValue:n,format:r||V,label:a,helperText:o,name:s,onBlur:l,onChange:f,parse:c||V,resource:p,source:m,validate:g,readOnly:b,disabled:w}),ee=Q?Array.isArray(Q)?Q:[Q]:[],te=i((ce,he,J)=>{const Me=E?[...ee,...ce]:[...ce];E?(W(Me),H()):(W(Me[0]),H()),q&&q(ce,he,J)},"onDrop"),oe=i(ce=>async()=>{if(P)try{await P(ce)}catch{return}if(E){const he=ee.filter(J=>!XD(J,ce));W(he),H()}else W(null),H();A&&A(ce)},"onRemove"),ne=C&&y.isValidElement(y.Children.only(C))?y.Children.only(C):void 0,{getRootProps:fe,getInputProps:re}=H1({accept:S,maxSize:_,minSize:j,multiple:E,disabled:w||b,...O,onDrop:te});return d.jsxs(Wo,{id:z,name:Y,className:Se("w-full",T),...L,children:[d.jsx(Xs,{htmlFor:z,className:w||b?"cursor-default":"cursor-pointer",children:d.jsx(ca,{label:a,source:m,resource:p,isRequired:K})}),d.jsxs("div",{...fe({className:Se("border-2 border-dashed border-muted rounded-lg p-6 text-center transition-colors","hover:border-sidebar-ring focus:outline-none",w||b?"bg-muted cursor-not-allowed":"bg-muted text-muted-foreground cursor-pointer")}),children:[d.jsx("input",{id:z,name:Y,...re({...R})}),D||(E?d.jsx("p",{className:"text-sm",children:U(M)}):d.jsx("p",{className:"text-sm",children:U(I)}))]}),d.jsx(Go,{helperText:o}),d.jsx(il,{}),C&&d.jsx("div",{className:"previews flex flex-col gap-1",children:ee.map((ce,he)=>d.jsx(s5e,{file:ce,onRemove:oe(ce),removeIcon:F,children:d.jsx(Ba,{value:ce,children:ne})},he))})]})},"FileInput"),s5e=i(e=>{const{className:t,children:n,file:r,onRemove:a,removeIcon:o=al,...s}=e,l=xt();return y.useEffect(()=>()=>{const f=r.rawFile?r.rawFile.preview:r.preview;f&&window.URL.revokeObjectURL(f)},[r]),d.jsxs("div",{className:Se("flex flex-row gap-1",t),...s,children:[d.jsx(ze,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-full shadow-sm cursor-pointer",onClick:a,"aria-label":l("ra.action.delete"),title:l("ra.action.delete"),children:d.jsx(o,{className:"h-4 w-4"})}),n]})},"FileInputPreview");Fs.Col;const l5e=i(e=>{const{children:t,className:n,empty:r,field:a,label:o,render:s,resource:l,source:f,record:c,variant:p,...m}=e,g=Ht(e),b=Wt({recordProp:c}),w=xt();return!f&&!o&&!s?null:d.jsxs("div",{className:Se(n,"flex",p==="inline"?"flex-row":"flex-col"),...m,children:[o!==""&&o!==!1?d.jsx("div",{className:Se(p==="inline"?"block min-w-50":"text-xs","text-muted-foreground"),children:d.jsx(ca,{label:o,source:f,resource:g,isRequired:!1})}):null,t?d.jsx("span",{className:"flex-1",children:t}):s?b&&d.jsx("span",{className:"flex-1",children:s(b)||(typeof r=="string"?w(r,{_:r}):r)}):a?y.createElement(a,{source:f,empty:r,className:"flex-1"}):f?d.jsx(na,{source:f,empty:r,className:"flex-1"}):null]})},"RecordField"),c5e=i(()=>{const e=Wt();return e?d.jsxs("div",{className:"flex flex-row gap-4 items-center justify-start",children:[d.jsx(is,{height:40,width:40,record:e}),d.jsxs("div",{className:"flex flex-col items-start gap-1",children:[d.jsxs("span",{children:[e.first_name," ",e.last_name]}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.title,e.title&&e.company_name&&" at ",e.company_name]})]})]}):null},"ContactOptionRender"),kN=d.jsx(c5e,{}),Sne=i(({selectContact:e,display:t="chip"})=>{const{identity:n}=Zn(),r=_n(),[a]=ud(),o=Vt(),{taskTypes:s}=Va(),l=Wt(),[f,c]=y.useState(!1),p=i(()=>{c(!0)},"handleOpen"),m=i(async g=>{c(!1);const b=await r.getOne("contacts",{id:g.contact_id});b.data&&(await a("contacts",{id:b.data.id,data:{last_seen:new Date().toISOString()},previousData:b.data}),o("Task added"))},"handleSuccess");return n?d.jsxs(d.Fragment,{children:[t==="icon"?d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsx(ze,{size:"sm",variant:"ghost",className:"p-2 cursor-pointer",onClick:p,children:d.jsx(Ji,{className:"w-4 h-4"})})}),d.jsx(oo,{children:"Create task"})]})}):d.jsx("div",{className:"my-2",children:d.jsxs(ze,{variant:"outline",className:"h-6 cursor-pointer",onClick:p,size:"sm",children:[d.jsx(Ji,{className:"w-4 h-4"}),"Add task"]})}),d.jsx(Lw,{resource:"tasks",record:{type:"None",contact_id:l?.id,due_date:new Date().toISOString().slice(0,10),sales_id:n.id},transform:i(g=>{const b=new Date(g.due_date);return b.setHours(0,0,0,0),g.due_date=b.toISOString(),{...g,due_date:new Date(g.due_date).toISOString()}},"transform"),mutationOptions:{onSuccess:m},children:d.jsx(wa,{open:f,onOpenChange:i(()=>c(!1),"onOpenChange"),children:d.jsx(_a,{className:"lg:max-w-xl overflow-y-auto max-h-9/10 top-1/20 translate-y-0",children:d.jsxs(ra,{className:"flex flex-col gap-4",children:[d.jsx(Wr,{children:d.jsxs(Gr,{children:[e?"Create a new task":"Create a new task for ",!e&&d.jsx(CK,{record:l,resource:"contacts"})]})}),d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(ln,{autoFocus:!0,source:"text",label:"Description",validate:nr(),multiline:!0,className:"m-0",helperText:!1}),e&&d.jsx(Ry,{source:"contact_id",reference:"contacts_summary",children:d.jsx(B1,{label:"Contact",optionText:kN,helperText:!1,validate:nr()})}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsx(yne,{source:"due_date",helperText:!1,validate:nr()}),d.jsx(Zs,{source:"type",validate:nr(),choices:s.map(g=>({id:g,name:g})),helperText:!1})]})]}),d.jsx(Yo,{className:"w-full justify-end",children:d.jsx(yd,{})})]})})})})]}):null},"AddTask"),u5e=i(({open:e,close:t,taskId:n})=>{const{taskTypes:r}=Va(),a=Vt();return d.jsx(wa,{open:e,onOpenChange:t,children:n&&d.jsx(aM,{id:n,resource:"tasks",className:"mt-0",mutationOptions:{onSuccess:i(()=>{t(),a("Task updated",{type:"info",undoable:!0})},"onSuccess")},redirect:!1,children:d.jsx(_a,{className:"lg:max-w-xl overflow-y-auto max-h-9/10 top-1/20 translate-y-0",children:d.jsxs(ra,{className:"flex flex-col gap-4",children:[d.jsx(Wr,{children:d.jsx(Gr,{children:"Edit task"})}),d.jsx(ln,{autoFocus:!0,source:"text",label:"Description",validate:nr(),multiline:!0,helperText:!1}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsx(yne,{source:"due_date",helperText:!1,validate:nr()}),d.jsx(Zs,{source:"type",choices:r.map(o=>({id:o,name:o})),helperText:!1,validate:nr()})]}),d.jsxs(Yo,{className:"w-full sm:justify-between gap-4",children:[d.jsx(D4,{mutationOptions:{onSuccess:i(()=>{t(),a("Task deleted",{type:"info",undoable:!0})},"onSuccess")},redirect:!1}),d.jsx(yd,{label:"Save"})]})]})})})})},"TaskEdit"),d5e=i(({task:e,showContact:t})=>{const n=Vt(),r=Pn(),[a,o]=y.useState(!1),s=i(()=>{o(!1)},"handleCloseEdit"),[l,{isPending:f,isSuccess:c,variables:p}]=ud(),{handleDelete:m}=mK({record:e,redirect:!1,mutationOptions:{onSuccess(){n("Task deleted successfully",{undoable:!0})}}}),g=i(()=>{o(!0)},"handleEdit"),b=i(()=>()=>{l("tasks",{id:e.id,data:{done_date:e.done_date?null:new Date().toISOString()},previousData:e})},"handleCheck");y.useEffect(()=>{f||!c||p?.data?.done_date!=null||r.invalidateQueries({queryKey:["tasks","getList"]})},[r,f,c,p]);const w=`checkbox-list-label-${e.id}`;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsxs("div",{className:"flex items-start gap-2 flex-1",children:[d.jsx(Up,{id:w,checked:!!e.done_date,onCheckedChange:b(),disabled:f,className:"mt-1"}),d.jsxs("div",{className:`flex-grow ${e.done_date?"line-through":""}`,children:[d.jsxs("div",{className:"text-sm",children:[e.type&&e.type!=="None"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"font-semibold text-sm",children:e.type})," "]}),e.text]}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:["due ",d.jsx(Bx,{source:"due_date",record:e}),t&&d.jsx(Tr,{source:"contact_id",reference:"contacts",record:e,link:"show",className:"inline text-sm text-muted-foreground",render:i(({referenceRecord:S})=>S?d.jsxs(d.Fragment,{children:[" ","(Re: ",S?.first_name," ",S?.last_name,")"]}):null,"render")})]})]})]}),d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsx(ze,{variant:"ghost",size:"icon",className:"h-5 pr-0! size-8 cursor-pointer","aria-label":"task actions",children:d.jsx(Twe,{className:"h-4 w-4"})})}),d.jsxs(Tc,{align:"end",children:[d.jsx(sr,{className:"cursor-pointer",onClick:i(()=>{l("tasks",{id:e.id,data:{due_date:new Date(Date.now()+1440*60*1e3).toISOString().slice(0,10)},previousData:e})},"onClick"),children:"Postpone to tomorrow"}),d.jsx(sr,{className:"cursor-pointer",onClick:i(()=>{l("tasks",{id:e.id,data:{due_date:new Date(Date.now()+10080*60*1e3).toISOString().slice(0,10)},previousData:e})},"onClick"),children:"Postpone to next week"}),d.jsx(sr,{className:"cursor-pointer",onClick:g,children:"Edit"}),d.jsx(sr,{className:"cursor-pointer",onClick:m,children:"Delete"})]})]})]}),a&&d.jsx(u5e,{taskId:e.id,open:a,close:s})]})},"Task"),jne=i(({showContact:e,className:t})=>{const{data:n,error:r,isPending:a}=Gn();if(a||r||n.length===0)return null;const o=n.filter(s=>!s.done_date||Y0e(new Date(s.done_date),new Date(Date.now()-300*1e3)));return d.jsx("div",{className:`space-y-2 ${t||""}`,children:o.map(s=>d.jsx(d5e,{task:s,showContact:e},s.id))})},"TasksIterator"),vb=["#eddcd2","#fff1e6","#fde2e4","#fad2e1","#c5dedd","#dbe7e4","#f0efeb","#d6e2e9","#bcd4e6","#99c1de"],f5e=i(({color:e,handleClick:t,selected:n})=>d.jsx("button",{type:"button",className:`w-8 h-8 rounded-full inline-block m-1 transition-all ${n?"ring-2 ring-gray-500 ring-offset-1":""}`,style:{backgroundColor:e},onClick:t}),"RoundButton");function Ene({open:e,tag:t,title:n,onClose:r,onSubmit:a}){const[o,s]=y.useState(""),[l,f]=y.useState(vb[0]),[c,p]=y.useState(!1),m=i(w=>{s(w.target.value)},"handleNewTagNameChange"),g=i(()=>{p(!1),r()},"handleClose"),b=i(async w=>{w.preventDefault(),await a({name:o,color:l}),p(!0),s(""),f(vb[0]),g()},"handleSubmit");return y.useEffect(()=>{s(t?.name??""),f(t?.color??vb[0])},[t]),d.jsx(wa,{open:e,onOpenChange:g,children:d.jsx(_a,{className:"sm:max-w-lg",children:d.jsxs("form",{onSubmit:b,children:[d.jsx(Wr,{children:d.jsx(Gr,{children:n})}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"tag-name",children:"Tag name"}),d.jsx(_r,{id:"tag-name",autoFocus:!0,value:o,onChange:m,placeholder:"Enter tag name"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Color"}),d.jsx("div",{className:"flex flex-wrap",children:vb.map(w=>d.jsx(f5e,{color:w,selected:w===l,handleClick:i(()=>{f(w)},"handleClick")},w))})]})]}),d.jsx("div",{className:"flex justify-end pt-4",children:d.jsxs(ze,{variant:"outline",disabled:c,className:Se(kc({variant:"outline"}),"text-primary",c?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[d.jsx(i1,{}),"Save"]})})]})})})}i(Ene,"TagDialog");function h5e({tag:e,open:t,onClose:n,onSuccess:r}){const[a]=ud(),o=i(async s=>{await a("tags",{id:e.id,data:s,previousData:e},{onSuccess:i(async l=>{await r?.(l)},"onSuccess")})},"handleEditTag");return d.jsx(Ene,{open:t,title:"Edit tag",onClose:n,onSubmit:o,tag:e})}i(h5e,"TagEditModal");function p5e({tag:e,onUnlink:t}){const[n,r]=y.useState(!1),a=i(()=>{r(!1)},"handleClose"),o=i(()=>{r(!0)},"handleClick");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"text-black inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md cursor-pointer hover:opacity-80 transition-opacity",style:{backgroundColor:e.color},onClick:o,children:[e.name,d.jsx("button",{onClick:i(s=>{s.stopPropagation(),t()},"onClick"),className:"transition-colors p-0 ml-1 cursor-pointer",children:d.jsx(Tp,{className:"w-3 h-3"})})]}),d.jsx(h5e,{tag:e,open:n,onClose:a})]})}i(p5e,"TagChip");function m5e({open:e,onClose:t,onSuccess:n}){const[r]=vM(),a=i(async o=>{await r("tags",{data:o},{onSuccess:i(async s=>{await n?.(s)},"onSuccess")})},"handleCreateTag");return d.jsx(Ene,{open:e,title:"Create a new tag",onClose:t,onSubmit:a})}i(m5e,"TagCreateModal");const v5e=i(()=>{const e=Wt(),[t,n]=y.useState(!1),{data:r,isPending:a}=za("tags",{pagination:{page:1,perPage:10},sort:{field:"name",order:"ASC"}}),{data:o,isPending:s}=khe("tags",{ids:e?.tags},{enabled:e&&e.tags&&e.tags.length>0}),[l]=ud(),f=r&&e&&r.filter(w=>!e.tags.includes(w.id)),c=i(w=>{if(!e)throw new Error("No contact record found");const S=[...e.tags,w];l("contacts",{id:e.id,data:{tags:S},previousData:e})},"handleTagAdd"),p=i(async w=>{if(!e)throw new Error("No contact record found");const S=e.tags.filter(_=>_!==w);await l("contacts",{id:e.id,data:{tags:S},previousData:e})},"handleTagDelete"),m=i(()=>{n(!0)},"openTagCreateDialog"),g=i(()=>{n(!1)},"handleTagCreateClose"),b=y.useCallback(async w=>{if(!e)throw new Error("No contact record found");await l("contacts",{id:e.id,data:{tags:[...e.tags,w.id]},previousData:e},{onSuccess:i(()=>{n(!1)},"onSuccess")})},[l,e]);return s||a?null:d.jsxs("div",{className:"flex flex-wrap gap-2",children:[o?.map(w=>d.jsx("div",{children:d.jsx(p5e,{tag:w,onUnlink:i(()=>p(w.id),"onUnlink")})},w.id)),d.jsx("div",{children:d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsxs(ze,{variant:"outline",size:"sm",className:"h-6 cursor-pointer",children:[d.jsx(Ji,{className:"h-3 w-3 mr-1"}),"Add tag"]})}),d.jsxs(Tc,{children:[f?.map(w=>d.jsx(sr,{onClick:i(()=>c(w.id),"onClick"),children:d.jsx(Pr,{variant:"secondary",className:"text-xs font-normal text-black",style:{backgroundColor:w.color},children:w.name})},w.id)),d.jsx(sr,{onClick:m,children:d.jsxs(ze,{variant:"ghost",size:"sm",className:"w-full justify-start p-0 cursor-pointer",children:[d.jsx(RQ,{className:"h-3 w-3 mr-2"}),"Create new tag"]})})]})]})}),d.jsx(m5e,{open:t,onClose:g,onSuccess:b})]})},"TagsListEdit"),g5e=i(()=>{const[e,t]=y.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(ze,{variant:"outline",className:"h-6 cursor-pointer",size:"sm",onClick:i(()=>t(!0),"onClick"),children:[d.jsx(CQ,{className:"w-4 h-4"}),"Merge with another contact"]}),d.jsx(y5e,{open:e,onClose:i(()=>t(!1),"onClose")})]})},"ContactMergeButton"),y5e=i(({open:e,onClose:t})=>{const n=Wt(),r=Vt(),a=rs(),o=_n(),[s,l]=y.useState(null),[f,c]=y.useState(null),[p,m]=y.useState(!1),{mutateAsync:g}=Yr({mutationKey:["contacts","merge",{loserId:n?.id,winnerId:s}],mutationFn:i(async()=>o.mergeContacts(n?.id,s),"mutationFn")}),{data:b}=za("contacts",{filter:{first_name:n?.first_name,last_name:n?.last_name,"id@neq":`${n?.id}`},pagination:{page:1,perPage:10}},{enabled:e&&!!n}),w=e&&!!n&&!!s,{total:S}=qT("tasks",{target:"contact_id",id:n?.id,pagination:{page:1,perPage:1}},{enabled:w}),{total:_}=qT("contactNotes",{target:"contact_id",id:n?.id,pagination:{page:1,perPage:1}},{enabled:w}),{total:j}=za("deals",{filter:{"contact_ids@cs":`{${n?.id}}`},pagination:{page:1,perPage:1}},{enabled:w});y.useEffect(()=>{if(b&&b.length>0){const O=b[0].id;c(O),l(O)}},[b]);const E=i(async()=>{if(!s||!n){r("Please select a contact to merge with",{type:"warning"});return}try{m(!0),await g(),m(!1),r("Contacts merged successfully",{type:"success"}),a(`/contacts/${s}/show`),t()}catch(O){m(!1),r("Failed to merge contacts",{type:"error"}),console.error("Merge failed:",O)}},"handleMerge");return n?d.jsx(wa,{open:e,onOpenChange:t,children:d.jsxs(_a,{className:"md:min-w-lg max-w-2xl",children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Merge Contact"}),d.jsx(Oi,{children:"Merge this contact with another one."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[d.jsx("p",{className:"font-medium text-sm",children:"Current Contact (will be deleted)"}),d.jsx("div",{className:"font-medium text-sm mt-4",children:kN}),d.jsx("div",{className:"flex justify-center my-4",children:d.jsx(Fxe,{className:"h-5 w-5 text-muted-foreground"})}),d.jsx("p",{className:"font-medium text-sm mb-2",children:"Target Contact (will be kept)"}),d.jsx(ra,{children:d.jsx(Ry,{source:"winner_id",reference:"contacts",filter:{"id@neq":n.id},children:d.jsx(B1,{label:"",optionText:kN,validate:nr(),onChange:l,defaultValue:f,helperText:!1})})})]}),s&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-medium text-sm",children:"What will be merged:"}),d.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 ml-4",children:[_!=null&&_>0&&d.jsxs("li",{children:["• ",_," note",_!==1?"s":""," will be reassigned"]}),S!=null&&S>0&&d.jsxs("li",{children:["• ",S," task",S!==1?"s":""," will be reassigned"]}),j!=null&&j>0&&d.jsxs("li",{children:["• ",j," deal",j!==1?"s":""," will be updated"]}),n.email_jsonb?.length>0&&d.jsxs("li",{children:["• ",n.email_jsonb.length," email address",n.email_jsonb.length!==1?"es":""," will be added"]}),n.phone_jsonb?.length>0&&d.jsxs("li",{children:["• ",n.phone_jsonb.length," phone number",n.phone_jsonb.length!==1?"s":""," will be added"]}),!_&&!S&&!j&&!n.email_jsonb?.length&&!n.phone_jsonb?.length&&d.jsx("li",{className:"text-muted-foreground/60",children:"No additional data to merge"})]})]}),d.jsxs(ai,{variant:"destructive",children:[d.jsx(J1e,{className:"h-4 w-4"}),d.jsx(_te,{children:"Warning: Destructive Operation"}),d.jsx(ki,{children:"All data will be transferred to the second contact. This action cannot be undone."})]})]})]}),d.jsxs(Yo,{children:[d.jsxs(ze,{variant:"ghost",onClick:t,disabled:p,children:[d.jsx(al,{}),"Cancel"]}),d.jsxs(ze,{onClick:E,disabled:!s||p,children:[d.jsx(CQ,{}),p?"Merging...":"Merge Contacts"]})]})]})}):null},"ContactMergeDialog");function b5e(e){if(e.length<=75)return e;const n=[];let r=e.substring(0,75),a=e.substring(75);for(n.push(r);a.length>0;)r=" "+a.substring(0,74),a=a.substring(74),n.push(r);return n.join(`\r
|
|
105
|
+
`);return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-col space-y-2 w-full",children:[d.jsx("div",{className:"flex flex-row space-x-1 items-center w-full",children:e}),d.jsx("div",{children:d.jsx("div",{className:"text-sm line-clamp-3 overflow-hidden",children:n.map((r,a)=>d.jsxs(y.Fragment,{children:[r,a<n.length-1&&d.jsx("br",{})]},a))})})]})})}i(Rte,"ActivityLogNote");function v4e(){const e=Wt();return d.jsx(is,{width:20,height:20,record:e})}i(v4e,"ContactAvatar");function g4e({activity:e}){const t=Ay(),{contactNote:n}=e;return d.jsx(Rte,{header:d.jsxs("div",{className:"flex items-center gap-2 w-full",children:[d.jsx(Tr,{source:"contact_id",reference:"contacts",record:e.contactNote,children:d.jsx(v4e,{})}),d.jsxs("div",{className:"flex flex-row flex-grow",children:[d.jsx("div",{className:"text-sm text-muted-foreground flex-grow",children:d.jsxs("span",{className:"text-muted-foreground text-sm inline-flex",children:[d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})}),d.jsxs(Tr,{source:"contact_id",reference:"contacts",record:e.contactNote,children:[" added a note about ",d.jsx(na,{source:"first_name"})," ",d.jsx(na,{source:"last_name"})]})]})}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})]}),text:n.text})}i(g4e,"ActivityLogContactNoteCreated");function y4e({activity:e}){const t=Ay(),{deal:n}=e;return d.jsx("div",{className:"p-0",children:d.jsxs("div",{className:"flex flex-row space-x-1 items-center w-full",children:[d.jsx("div",{className:"w-5 h-5 bg-gray-300 rounded-full"}),d.jsxs("div",{className:"text-sm text-muted-foreground flex-grow",children:[d.jsxs("span",{className:"text-muted-foreground text-sm",children:["Sales ID: ",e.sales_id]})," ","added deal ",d.jsx(fn,{to:`/deals/${n.id}/show`,children:n.name})," ",t!=="company"&&d.jsxs(d.Fragment,{children:["to company ",e.company_id," ",d.jsx(vc,{date:e.date})]})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]})})}i(y4e,"ActivityLogDealCreated");function b4e({activity:e}){const t=Ay(),{dealNote:n}=e;return d.jsx(Rte,{header:d.jsxs("div",{className:"flex flex-row items-center gap-2 flex-grow",children:[d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:!1,children:d.jsx(Tr,{source:"company_id",reference:"companies",link:!1,children:d.jsx(qp,{width:20,height:20})})}),d.jsxs("span",{className:"text-sm text-muted-foreground flex-grow inline-flex",children:[d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,link:!1,children:d.jsx(wd,{})})," added a note about deal ",d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:"show"}),t!=="company"&&d.jsxs(d.Fragment,{children:[" at ",d.jsx(Tr,{source:"deal_id",reference:"deals",record:n,link:!1,children:d.jsx(Tr,{source:"company_id",reference:"companies",link:"show"})})," "]})]}),t==="company"&&d.jsx("span",{className:"text-muted-foreground text-sm",children:d.jsx(vc,{date:e.date})})]}),text:n.text})}i(b4e,"ActivityLogDealNoteCreated");function x4e({activities:e,pageSize:t}){const[n,r]=y.useState(t),a=e.slice(0,n);return d.jsxs("div",{className:"space-y-4",children:[a.map((o,s)=>d.jsxs(y.Fragment,{children:[d.jsx(w4e,{activity:o},o.id),d.jsx(pd,{})]},s)),n<e.length&&d.jsx("a",{href:"#",onClick:i(o=>{o.preventDefault(),r(s=>s+t)},"onClick"),className:"flex w-full justify-center text-sm underline hover:no-underline",children:"Load more activity"})]})}i(x4e,"ActivityLogIterator");function w4e({activity:e}){return e.type===jte?d.jsx(p4e,{activity:e}):e.type===Ete?d.jsx(m4e,{activity:e}):e.type===Cte?d.jsx(g4e,{activity:e}):e.type===Ote?d.jsx(y4e,{activity:e}):e.type===kte?d.jsx(b4e,{activity:e}):null}i(w4e,"ActivityItem");function Ate({companyId:e,pageSize:t=20,context:n="all"}){const r=_n(),{data:a,isPending:o,error:s}=Qr({queryKey:["activityLog",e],queryFn:i(()=>r.getActivityLog(e),"queryFn")});return o?d.jsx("div",{className:"mt-1",children:Array.from({length:5}).map((l,f)=>d.jsxs("div",{className:"space-y-2 mt-1",children:[d.jsxs("div",{className:"flex flex-row space-x-2 items-center",children:[d.jsx(sn,{className:"w-5 h-5 rounded-full"}),d.jsx(sn,{className:"w-full h-4"})]}),d.jsx(sn,{className:"w-full h-12"}),d.jsx(pd,{})]},f))}):s?d.jsx(ai,{children:"Failed to load activity log"}):d.jsx(Ste.Provider,{value:n,children:d.jsx(x4e,{activities:a,pageSize:t})})}i(Ate,"ActivityLog");const _4e=Rp("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function Pr({className:e,variant:t,asChild:n=!1,...r}){const a=n?a1:"span";return d.jsx(a,{"data-slot":"badge",className:Se(_4e({variant:t}),e),...r})}i(Pr,"Badge");const Ux=i(({children:e,render:t,className:n})=>{const{data:r}=Gn();return d.jsx("div",{className:`flex gap-2 ${n}`,children:r?.map((a,o)=>d.jsx(Ba,{value:a,children:t?t(a,o):e||d.jsx(S4e,{})},o))})},"SingleFieldList"),S4e=i(()=>d.jsx(Pr,{variant:"outline",children:d.jsx(CK,{})}),"DefaultChildren"),j4e=i(e=>{const{filter:t,page:n=1,perPage:r,reference:a,resource:o,sort:s,source:l,queryOptions:f,render:c,...p}=e;return d.jsx(Eme,{filter:t,page:n,perPage:r,reference:a,resource:o,sort:s,source:l,queryOptions:f,render:c,children:d.jsx(O4e,{...p})})},"ReferenceArrayField"),E4e=i(e=>{const{children:t=C4e,className:n,empty:r,error:a,loading:o,pagination:s}=e,{isPending:l,error:f,total:c,hasPreviousPage:p,hasNextPage:m,data:g,filterValues:b}=Gn();return d.jsx("div",{className:n,children:l&&o!==!1?o:f&&a!==!1?a:(c===0||c==null&&p===!1&&m===!1&&g.length===0&&!Object.keys(b).length)&&r!==!1?r:d.jsxs("span",{children:[t,s&&c!==void 0?s:null]})})},"ReferenceArrayFieldView"),C4e=d.jsx(Ux,{}),O4e=y.memo(E4e),k4e=i(e=>{const t=Wt();return t?d.jsx(Pr,{...e,style:{backgroundColor:t.color,border:0},variant:"outline",className:Se("text-black font-normal",e.className),children:t.name}):null},"ColoredBadge"),Tte=i(()=>d.jsx(j4e,{className:"inline-block",resource:"contacts",source:"tags",reference:"tags",children:d.jsx(Ux,{children:d.jsx(k4e,{source:"name"})})}),"TagsList"),R4e=i((e,t)=>e.find(n=>n.value===t)?.label,"findDealLabel"),Ty=i(({status:e,className:t})=>{const{noteStatuses:n}=Va();if(!e||!n)return null;const r=n.find(a=>a.value===e);return r?d.jsxs("div",{className:Se("group relative inline-block mr-2",t),children:[d.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full",style:{backgroundColor:r.color}}),d.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10",children:r.label})]}):null},"Status"),Pte=i(e=>{const t=Ht(e),n=Wt(e),a=nl()({resource:t,type:"edit",id:n?.id});return d.jsxs(fn,{className:kc({variant:"outline"}),to:a,onClick:A4e,children:[d.jsx(OQ,{}),d.jsx(lr,{i18nKey:e.label??"ra.action.edit",children:e.label??"Edit"})]})},"EditButton"),A4e=i(e=>e.stopPropagation(),"stopPropagation$3"),D4=i(e=>{const{label:t,onClick:n,size:r,mutationOptions:a,redirect:o="list",successMessage:s,variant:l="outline",className:f="cursor-pointer hover:bg-destructive/10! text-destructive! border-destructive! focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40"}=e,c=Wt(e),p=Ht(e),{isPending:m,handleDelete:g}=mK({record:c,resource:p,redirect:o,onClick:n,mutationOptions:a,successMessage:s}),b=xt();let S=Ec(p)(c);const _=b(`resources.${p}.forcedCaseName`,{smart_count:1,_:Gv.humanize(b(`resources.${p}.name`,{smart_count:1,_:p?Gv.singularize(p):void 0}),!0)});y.isValidElement(S)&&(S=`#${c?.id}`);const j=sfe({resourceI18nKey:`resources.${p}.action.delete`,baseI18nKey:"ra.action.delete",options:{name:_,recordRepresentation:S},userText:t});return d.jsxs(ze,{variant:l,type:"button",onClick:g,disabled:m,"aria-label":typeof j=="string"?j:void 0,size:r,className:f,children:[d.jsx(MM,{}),j]})},"DeleteButton"),Nte=i(e=>{const t=Ht(),n=Wt(),a=nl()({resource:t,type:"show",id:n?.id}),{label:o,icon:s,...l}=e;return d.jsxs(fn,{className:kc({variant:"outline"}),to:a,onClick:T4e,...l,children:[s??d.jsx(Mwe,{}),d.jsx(lr,{i18nKey:o??"ra.action.show",children:o??"Show"})]})},"ShowButton"),T4e=i(e=>e.stopPropagation(),"stopPropagation$2");function G1(e){const t=y.memo(e);return t.displayName=e.displayName?.replace("Impl",""),t}i(G1,"genericMemo");const Dte=i(e=>{const{empty:t,locales:n,options:r,showTime:a=!1,showDate:o=!0,transform:s=P4e,source:l,record:f,defaultValue:c,...p}=e,m=xt();if(!a&&!o)throw new Error("<DateField> cannot have showTime and showDate false at the same time");const g=oi({source:l,record:f,defaultValue:c});if(g==null||g==="")return t?d.jsx("span",{...p,children:typeof t=="string"?m(t,{_:t}):t}):null;const b=s(g);let w="";if(b)if(a&&o)w=yA?b.toLocaleString(n,r):b.toLocaleString();else if(o){const S=r??(typeof g=="string"&&g.length<=10?{timeZone:"UTC"}:void 0);w=yA?b.toLocaleDateString(n,S):b.toLocaleDateString()}else a&&(w=yA?b.toLocaleTimeString(n,r):b.toLocaleTimeString());return d.jsx("span",{...p,children:w})},"DateFieldImpl");Dte.displayName="DateFieldImpl";const Bx=G1(Dte),P4e=i(e=>e instanceof Date?e:typeof e=="string"||typeof e=="number"?new Date(e):void 0,"defaultTransform$1"),yA=(()=>{try{new Date().toLocaleString("i")}catch(e){return e instanceof RangeError}return!1})(),Mte=i(e=>{const{empty:t,className:n,defaultValue:r,source:a,record:o,resource:s,...l}=e,f=oi({defaultValue:r,source:a,record:o}),c=xt();return f==null?t?d.jsx("span",{className:n,...l,children:typeof t=="string"?c(t,{_:t}):t}):null:d.jsx("a",{className:Se("underline hover:no-underline",n),href:f,onClick:D4e,...l,children:f})},"UrlFieldImpl");Mte.displayName="UrlFieldImpl";const N4e=G1(Mte),D4e=i(e=>e.stopPropagation(),"stopPropagation$1"),Ite=i(e=>{const{className:t,empty:n,choices:r,defaultValue:a,source:o,record:s,optionValue:l="id",optionText:f="name",translateChoice:c=!0,...p}=e,m=oi({defaultValue:a,source:o,record:s}),{getChoiceText:g,getChoiceValue:b}=Jw({optionText:f,optionValue:l,translateChoice:c}),w=xt(),S=r?r.find(j=>b(j)===m):null;if(!S)return n?d.jsx("span",{className:t,...p,children:typeof n=="string"?w(n,{_:n}):n}):null;const _=g(S);return d.jsx("span",{className:t,...p,children:_})},"SelectFieldImpl");Ite.displayName="SelectFieldImpl";const M4e=G1(Ite);function rc({title:e,children:t,noGap:n}){return d.jsxs("div",{className:"mb-6 text-sm",children:[d.jsx("h3",{className:"font-medium pb-1",children:e}),d.jsx(pd,{}),d.jsx("div",{className:Se("pt-2 flex flex-col",{"gap-1":!n}),children:t})]})}i(rc,"AsideSection");const Fte=i(({link:e="edit"})=>{const t=Wt();return t?d.jsxs("div",{className:"hidden sm:block w-[250px] min-w-[250px] space-y-4",children:[d.jsx("div",{className:"flex flex-row space-x-1",children:e==="edit"?d.jsx(Pte,{label:"Edit Company"}):d.jsx(Nte,{label:"Show Company"})}),d.jsx(I4e,{record:t}),d.jsx(L4e,{record:t}),d.jsx(F4e,{record:t}),d.jsx($4e,{record:t}),e!=="edit"&&d.jsx("div",{className:"mt-6 pt-6 border-t hidden sm:flex flex-col gap-2 items-start",children:d.jsx(D4,{className:"h-6 cursor-pointer hover:bg-destructive/10! text-destructive! border-destructive! focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",size:"sm"})})]}):null},"CompanyAside"),I4e=i(({record:e})=>!e.website&&!e.linkedin_url&&!e.phone_number?null:d.jsxs(rc,{title:"Company Info",children:[e.website&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(Bwe,{className:"w-4 h-4"}),d.jsx(N4e,{source:"website",target:"_blank",rel:"noopener",content:e.website.replace("http://","").replace("https://","")})]}),e.linkedin_url&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(jQ,{className:"w-4 h-4"}),d.jsx("a",{className:"underline hover:no-underline",href:e.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:e.linkedin_url,children:"LinkedIn"})]}),e.phone_number&&d.jsxs("div",{className:"flex flex-row items-center gap-1 min-h-[24px]",children:[d.jsx(NM,{className:"w-4 h-4"}),d.jsx(na,{source:"phone_number"})]})]}),"CompanyInfo"),F4e=i(({record:e})=>!e.revenue&&!e.id?null:d.jsxs(rc,{title:"Context",children:[e.sector&&d.jsxs("span",{children:["Sector: ",d.jsx(na,{source:"sector"})]}),e.size&&d.jsxs("span",{children:["Size: ",d.jsx(M4e,{source:"size",choices:j4})]}),e.revenue&&d.jsxs("span",{children:["Revenue: ",d.jsx(na,{source:"revenue"})]}),e.tax_identifier&&d.jsxs("span",{children:["Tax Identifier: ",d.jsx(na,{source:"tax_identifier"})]})]}),"ContextInfo"),L4e=i(({record:e})=>!e.address&&!e.city&&!e.zipcode&&!e.stateAbbr?null:d.jsxs(rc,{title:"Main Address",noGap:!0,children:[d.jsx(na,{source:"address"}),d.jsx(na,{source:"city"}),d.jsx(na,{source:"zipcode"}),d.jsx(na,{source:"stateAbbr"}),d.jsx(na,{source:"country"})]}),"AddressInfo"),$4e=i(({record:e})=>{if(!e.created_at&&!e.sales_id&&!e.description&&!e.context_links)return null;const t=i(n=>new URL(n.startsWith("http")?n:`https://${n}`).hostname,"getBaseURL");return d.jsxs(rc,{title:"Additional Info",children:[e.description&&d.jsx("p",{className:"text-sm mb-1",children:e.description}),e.context_links&&d.jsx("div",{className:"flex flex-col",children:e.context_links.map((n,r)=>n?d.jsx("a",{className:"text-sm underline hover:no-underline mb-1",href:n.startsWith("http")?n:`https://${n}`,target:"_blank",rel:"noopener noreferrer",title:n,children:t(n)},r):null)}),e.sales_id!==null&&d.jsxs("div",{className:"inline-flex text-sm text-muted-foreground mb-1",children:["Followed by ",d.jsx(Tr,{source:"sales_id",reference:"sales",record:e,children:d.jsx(wd,{})})]}),e.created_at&&d.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:["Added on"," ",d.jsx(Bx,{source:"created_at",record:e,options:{year:"numeric",month:"long",day:"numeric"}})]})]})},"AdditionalInfo"),q4e=i(()=>d.jsx(lY,{children:d.jsx(z4e,{})}),"CompanyShow"),z4e=i(()=>{const{record:e,isPending:t}=cY(),n=Sa(),a=bD("/companies/:id/show/:tab")?.params?.tab||"activity",o=i(s=>{if(s!==a){if(s==="activity"){n(`/companies/${e?.id}/show`);return}n(`/companies/${e?.id}/show/${s}`)}},"handleTabChange");return t||!e?null:d.jsxs("div",{className:"mt-2 flex pb-2 gap-8",children:[d.jsx("div",{className:"flex-1",children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsxs("div",{className:"flex mb-3",children:[d.jsx(qp,{}),d.jsx("h5",{className:"text-xl ml-2 flex-1",children:e.name})]}),d.jsxs(xte,{defaultValue:a,onValueChange:o,children:[d.jsxs(wte,{className:"grid w-full grid-cols-3",children:[d.jsx(Cu,{value:"activity",children:"Activity"}),d.jsx(Cu,{value:"contacts",children:e.nb_contacts?e.nb_contacts===1?"1 Contact":`${e.nb_contacts} Contacts`:"No Contacts"}),e.nb_deals?d.jsx(Cu,{value:"deals",children:e.nb_deals===1?"1 deal":`${e.nb_deals} deals`}):null]}),d.jsx(Ou,{value:"activity",className:"pt-2",children:d.jsx(Ate,{companyId:e.id,context:"company"})}),d.jsx(Ou,{value:"contacts",children:e.nb_contacts?d.jsx(mg,{reference:"contacts_summary",target:"company_id",sort:{field:"last_name",order:"ASC"},children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{className:"flex flex-row justify-end space-x-2 mt-1",children:[!!e.nb_contacts&&d.jsx(x4,{fields:["last_name","first_name","last_seen"]}),d.jsx(iV,{})]}),d.jsx(U4e,{})]})}):d.jsx("div",{className:"flex flex-col gap-4",children:d.jsx("div",{className:"flex flex-row justify-end space-x-2 mt-1",children:d.jsx(iV,{})})})}),d.jsx(Ou,{value:"deals",children:e.nb_deals?d.jsx(mg,{reference:"deals",target:"company_id",sort:{field:"name",order:"ASC"},children:d.jsx(B4e,{})}):null})]})]})})}),d.jsx(Fte,{})]})},"CompanyShowContent"),U4e=i(()=>{const e=Dr(),{data:t,error:n,isPending:r}=Gn();if(r||n)return null;const a=Date.now();return d.jsx("div",{className:"pt-0",children:t.map(o=>d.jsx(Ba,{value:o,children:d.jsx("div",{className:"p-0 text-sm",children:d.jsxs(fn,{to:`/contacts/${o.id}/show`,state:{from:e.pathname},className:"flex items-center justify-between hover:bg-muted py-2 transition-colors",children:[d.jsx("div",{className:"mr-4",children:d.jsx(is,{})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium",children:`${o.first_name} ${o.last_name}`}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.title,o.nb_tasks?` - ${o.nb_tasks} task${o.nb_tasks>1?"s":""}`:""," ",d.jsx(Tte,{})]})]}),o.last_seen&&d.jsx("div",{className:"text-right",children:d.jsxs("div",{className:"text-sm text-muted-foreground",children:["last activity ",wM(o.last_seen,a)," ago"," ",d.jsx(Ty,{status:o.status})]})})]})})},o.id))})},"ContactsIterator"),iV=i(()=>{const e=Wt();return d.jsx(ze,{variant:"outline",asChild:!0,size:"sm",className:"h-9",children:d.jsxs(fn,{to:"/contacts/create",state:e?{record:{company_id:e.id}}:void 0,className:"flex items-center gap-2",children:[d.jsx(a_e,{className:"h-4 w-4"}),"Add contact"]})})},"CreateRelatedContactButton"),B4e=i(()=>{const{data:e,error:t,isPending:n}=Gn(),{dealStages:r}=Va();if(n||t)return null;const a=Date.now();return d.jsx("div",{children:d.jsx("div",{children:e.map(o=>d.jsx("div",{className:"p-0 text-sm",children:d.jsxs(fn,{to:`/deals/${o.id}/show`,className:"flex items-center justify-between hover:bg-muted py-2 px-4 transition-colors",children:[d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"font-medium",children:o.name}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:[R4e(r,o.stage),","," ",o.amount.toLocaleString("en-US",{notation:"compact",style:"currency",currency:"USD",currencyDisplay:"narrowSymbol",minimumSignificantDigits:3}),o.category?`, ${o.category}`:""]})]}),d.jsx("div",{className:"text-right",children:d.jsxs("div",{className:"text-sm text-muted-foreground",children:["last activity ",wM(o.updated_at,a)," ago"," "]})})]})},o.id))})})},"DealsIterator"),Lte=i(()=>d.jsxs("div",{role:"toolbar",className:"sticky flex pt-4 pb-4 md:pb-0 bottom-0 bg-linear-to-b from-transparent to-card to-10% flex-row justify-end gap-2",children:[d.jsx($1,{}),d.jsx(yd,{})]}),"FormToolbar"),V4e=i(()=>d.jsx(aM,{actions:!1,redirect:"show",transform:i(e=>(e.website&&!e.website.startsWith("http")&&(e.website=`https://${e.website}`),e),"transform"),children:d.jsxs("div",{className:"mt-2 flex gap-8",children:[d.jsx(ra,{className:"flex flex-1 flex-col gap-4 pb-2",children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(cte,{}),d.jsx(Lte,{})]})})}),d.jsx(Fte,{link:"show"})]})}),"CompanyEdit"),H4e={list:BPe,create:a4e,edit:V4e,show:q4e};var K1="Switch",[W4e,VUe]=da(K1),[G4e,K4e]=W4e(K1),$te=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:o,required:s,disabled:l,value:f="on",onCheckedChange:c,form:p,...m}=e,[g,b]=y.useState(null),w=Zt(t,O=>b(O)),S=y.useRef(!1),_=g?p||!!g.closest("form"):!0,[j,E]=eo({prop:a,defaultProp:o??!1,onChange:c,caller:K1});return d.jsxs(G4e,{scope:n,checked:j,disabled:l,children:[d.jsx(yt.button,{type:"button",role:"switch","aria-checked":j,"aria-required":s,"data-state":Bte(j),"data-disabled":l?"":void 0,disabled:l,value:f,...m,ref:w,onClick:tt(e.onClick,O=>{E(C=>!C),_&&(S.current=O.isPropagationStopped(),S.current||O.stopPropagation())})}),_&&d.jsx(Ute,{control:g,bubbles:!S.current,name:r,value:f,checked:j,required:s,disabled:l,form:p,style:{transform:"translateX(-100%)"}})]})});$te.displayName=K1;var qte="SwitchThumb",zte=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=K4e(qte,n);return d.jsx(yt.span,{"data-state":Bte(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});zte.displayName=qte;var Y4e="SwitchBubbleInput",Ute=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const s=y.useRef(null),l=Zt(s,o),f=N1(n),c=v1(t);return y.useEffect(()=>{const p=s.current;if(!p)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(f!==n&&b){const w=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(w)}},[f,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Ute.displayName=Y4e;function Bte(e){return e?"checked":"unchecked"}i(Bte,"getState$2");var Q4e=$te,X4e=zte;function Vte({className:e,...t}){return d.jsx(Q4e,{"data-slot":"switch",className:Se("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(X4e,{"data-slot":"switch-thumb",className:Se("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}i(Vte,"Switch");const CN=i(e=>{const{className:t,defaultValue:n=!1,format:r,label:a,helperText:o,onBlur:s,onChange:l,onFocus:f,readOnly:c,disabled:p,parse:m,resource:g,source:b,validate:w,...S}=e,{id:_,field:j,isRequired:E}=Cc({defaultValue:n,format:r,parse:m,resource:g,source:b,onBlur:s,onChange:l,type:"checkbox",validate:w,disabled:p,readOnly:c,...S}),O=y.useCallback(C=>{j.onChange(C),j.onBlur()},[j]);return d.jsxs(Wo,{className:t,id:_,name:j.name,children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Vte,{id:_,checked:!!j.value,onFocus:f,onCheckedChange:O}),d.jsx(Xs,{htmlFor:_,children:d.jsx(ca,{label:a,source:b,resource:g,isRequired:E})})]}),d.jsx(Go,{helperText:o}),d.jsx(il,{})]})},"BooleanInput");var M4="Radio",[Z4e,Hte]=da(M4),[J4e,e3e]=Z4e(M4),Wte=y.forwardRef((e,t)=>{const{__scopeRadio:n,name:r,checked:a=!1,required:o,disabled:s,value:l="on",onCheck:f,form:c,...p}=e,[m,g]=y.useState(null),b=Zt(t,_=>g(_)),w=y.useRef(!1),S=m?c||!!m.closest("form"):!0;return d.jsxs(J4e,{scope:n,checked:a,disabled:s,children:[d.jsx(yt.button,{type:"button",role:"radio","aria-checked":a,"data-state":Qte(a),"data-disabled":s?"":void 0,disabled:s,value:l,...p,ref:b,onClick:tt(e.onClick,_=>{a||f?.(),S&&(w.current=_.isPropagationStopped(),w.current||_.stopPropagation())})}),S&&d.jsx(Yte,{control:m,bubbles:!w.current,name:r,value:l,checked:a,required:o,disabled:s,form:c,style:{transform:"translateX(-100%)"}})]})});Wte.displayName=M4;var Gte="RadioIndicator",Kte=y.forwardRef((e,t)=>{const{__scopeRadio:n,forceMount:r,...a}=e,o=e3e(Gte,n);return d.jsx(Ea,{present:r||o.checked,children:d.jsx(yt.span,{"data-state":Qte(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t})})});Kte.displayName=Gte;var t3e="RadioBubbleInput",Yte=y.forwardRef(({__scopeRadio:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const s=y.useRef(null),l=Zt(s,o),f=N1(n),c=v1(t);return y.useEffect(()=>{const p=s.current;if(!p)return;const m=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(m,"checked").set;if(f!==n&&b){const w=new Event("click",{bubbles:r});b.call(p,n),p.dispatchEvent(w)}},[f,n,r]),d.jsx(yt.input,{type:"radio","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:l,style:{...a.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Yte.displayName=t3e;function Qte(e){return e?"checked":"unchecked"}i(Qte,"getState$1");var n3e=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Y1="RadioGroup",[r3e,HUe]=da(Y1,[Ip,Hte]),Xte=Ip(),Zte=Hte(),[a3e,i3e]=r3e(Y1),Jte=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,name:r,defaultValue:a,value:o,required:s=!1,disabled:l=!1,orientation:f,dir:c,loop:p=!0,onValueChange:m,...g}=e,b=Xte(n),w=xy(c),[S,_]=eo({prop:o,defaultProp:a??null,onChange:m,caller:Y1});return d.jsx(a3e,{scope:n,name:r,required:s,disabled:l,value:S,onValueChange:_,children:d.jsx(JM,{asChild:!0,...b,orientation:f,dir:w,loop:p,children:d.jsx(yt.div,{role:"radiogroup","aria-required":s,"aria-orientation":f,"data-disabled":l?"":void 0,dir:w,...g,ref:t})})})});Jte.displayName=Y1;var ene="RadioGroupItem",tne=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,disabled:r,...a}=e,o=i3e(ene,n),s=o.disabled||r,l=Xte(n),f=Zte(n),c=y.useRef(null),p=Zt(t,c),m=o.value===a.value,g=y.useRef(!1);return y.useEffect(()=>{const b=i(S=>{n3e.includes(S.key)&&(g.current=!0)},"handleKeyDown"),w=i(()=>g.current=!1,"handleKeyUp");return document.addEventListener("keydown",b),document.addEventListener("keyup",w),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",w)}},[]),d.jsx(e4,{asChild:!0,...l,focusable:!s,active:m,children:d.jsx(Wte,{disabled:s,required:o.required,checked:m,...f,...a,name:o.name,ref:p,onCheck:i(()=>o.onValueChange(a.value),"onCheck"),onKeyDown:tt(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:tt(a.onFocus,()=>{g.current&&c.current?.click()})})})});tne.displayName=ene;var o3e="RadioGroupIndicator",nne=y.forwardRef((e,t)=>{const{__scopeRadioGroup:n,...r}=e,a=Zte(n);return d.jsx(Kte,{...a,...r,ref:t})});nne.displayName=o3e;var s3e=Jte,l3e=tne,c3e=nne;function u3e({className:e,...t}){return d.jsx(s3e,{"data-slot":"radio-group",className:Se("grid gap-3",e),...t})}i(u3e,"RadioGroup");function d3e({className:e,...t}){return d.jsx(l3e,{"data-slot":"radio-group-item",className:Se("border-input text-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 aspect-square size-4 shrink-0 rounded-full border shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(c3e,{"data-slot":"radio-group-indicator",className:"relative flex items-center justify-center",children:d.jsx(uP,{className:"fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2"})})})}i(d3e,"RadioGroupItem");const f3e=i(e=>{const{choices:t,isFetching:n,isLoading:r,isPending:a,resource:o,source:s,format:l,onBlur:f,onChange:c,parse:p,validate:m,disabled:g,readOnly:b,optionText:w,optionValue:S="id",translateChoice:_,disableValue:j="disabled",className:E,helperText:O,label:C,row:T,...R}=e,{allChoices:A,isPending:P,error:D,resource:M,source:I}=yM({choices:t,isFetching:n,isLoading:r,isPending:a,resource:o,source:s});if(I===void 0)throw new Error("If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the source prop");if(!P&&!D&&A===void 0)throw new Error("If you're not wrapping the RadioButtonGroupInput inside a ReferenceArrayInput, you must provide the choices prop");const{id:F,field:L,isRequired:q}=Cc({format:l,onBlur:f,onChange:c,parse:p,resource:M,source:I,validate:m,disabled:g,readOnly:b,...R}),{getChoiceText:U,getChoiceValue:$,getDisableValue:V}=Jw({optionText:w,optionValue:S,translateChoice:_,disableValue:j});return P?d.jsx(sn,{className:"w-full h-9"}):d.jsxs(Wo,{id:F,className:E,name:L.name,children:[C&&d.jsx(Xs,{children:d.jsx(ca,{label:C,source:I,resource:M,isRequired:q})}),d.jsx(jy,{children:d.jsx(u3e,{...R,value:L.value||"",onValueChange:L.onChange,className:Se("flex",T?"flex-row gap-4":"flex-col gap-2"),disabled:g||b,children:A?.map(z=>{const W=$(z),H=g||b||V(z);return d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(d3e,{value:W,id:`${F}-${W}`,disabled:H}),d.jsx(Hn,{htmlFor:`${F}-${W}`,className:Se("text-sm font-normal cursor-pointer",H&&"opacity-50 cursor-not-allowed"),children:U(z)})]},W)})})}),d.jsx(Go,{helperText:O}),d.jsx(il,{})]})},"RadioButtonGroupInput"),h3e=i(({validate:e})=>{const[t]=vM(),{identity:n}=Zn(),r=Vt(),a=i(async o=>{if(o)try{return await t("companies",{data:{name:o,sales_id:n?.id,created_at:new Date().toISOString()}},{returnPromise:!0})}catch{r("An error occurred while creating the company",{type:"error"})}},"handleCreateCompany");return d.jsx(B1,{optionText:"name",helperText:!1,onCreate:a,createItemLabel:"Create %{item}",createLabel:"Start typing to create a new company",validate:e})},"AutocompleteCompanyInput"),rne=i(()=>{const e=hd();return d.jsxs("div",{className:"flex flex-col gap-2 p-1",children:[d.jsx(is,{}),d.jsxs("div",{className:`flex gap-6 ${e?"flex-col":"flex-row"}`,children:[d.jsxs("div",{className:"flex flex-col gap-10 flex-1",children:[d.jsx(p3e,{}),d.jsx(m3e,{})]}),d.jsx(pd,{orientation:e?"horizontal":"vertical",className:"flex-shrink-0"}),d.jsxs("div",{className:"flex flex-col gap-10 flex-1",children:[d.jsx(v3e,{}),d.jsx(g3e,{})]})]})]})},"ContactInputs"),p3e=i(()=>{const{contactGender:e}=Va();return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Identity"}),d.jsx(f3e,{label:!1,row:!0,source:"gender",choices:e,helperText:!1,optionText:"label",optionValue:"value",defaultValue:e[0].value}),d.jsx(ln,{source:"first_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:nr(),helperText:!1})]})},"ContactIdentityInputs"),m3e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Position"}),d.jsx(ln,{source:"title",helperText:!1}),d.jsx(Ry,{source:"company_id",reference:"companies",perPage:10,children:d.jsx(h3e,{})})]}),"ContactPositionInputs"),v3e=i(()=>{const{getValues:e,setValue:t}=ua(),n=i(o=>{const{first_name:s,last_name:l}=e();if(s||l||!o)return;const[f,c]=o.split("@")[0].split(".");t("first_name",f.charAt(0).toUpperCase()+f.slice(1)),t("last_name",c?c.charAt(0).toUpperCase()+c.slice(1):"")},"handleEmailChange"),r=i(o=>{const s=o.clipboardData?.getData("text/plain");n(s)},"handleEmailPaste"),a=i(o=>{const s=o.target.value;n(s)},"handleEmailBlur");return d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Personal info"}),d.jsx(cN,{source:"email_jsonb",label:"Email addresses",helperText:!1,children:d.jsxs(uN,{inline:!0,disableReordering:!0,disableClear:!0,className:"[&>ul>li]:border-b-0 [&>ul>li]:pb-0",children:[d.jsx(ln,{source:"email",className:"w-full",helperText:!1,label:!1,placeholder:"Email",validate:JK(),onPaste:r,onBlur:a}),d.jsx(Zs,{source:"type",helperText:!1,label:!1,optionText:"id",choices:oV,defaultValue:"Work",className:"w-24 min-w-24"})]})}),d.jsx(cN,{source:"phone_jsonb",label:"Phone numbers",helperText:!1,children:d.jsxs(uN,{inline:!0,disableReordering:!0,disableClear:!0,className:"[&>ul>li]:border-b-0 [&>ul>li]:pb-0",children:[d.jsx(ln,{source:"number",className:"w-full",helperText:!1,label:!1,placeholder:"Phone number"}),d.jsx(Zs,{source:"type",helperText:!1,label:!1,optionText:"id",choices:oV,defaultValue:"Work",className:"w-24 min-w-24"})]})}),d.jsx(ln,{source:"linkedin_url",label:"Linkedin URL",helperText:!1,validate:ste})]})},"ContactPersonalInformationInputs"),oV=[{id:"Work"},{id:"Home"},{id:"Other"}],g3e=i(()=>d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx("h6",{className:"text-lg font-semibold",children:"Misc"}),d.jsx(ln,{source:"background",label:"Background info (bio, how you met, etc)",multiline:!0,helperText:!1}),d.jsx(CN,{source:"has_newsletter",helperText:!1}),d.jsx(Ry,{reference:"sales",source:"sales_id",sort:{field:"last_name",order:"ASC"},filter:{"disabled@neq":!0},children:d.jsx(Zs,{helperText:!1,label:"Account manager",optionText:y3e,validate:nr()})})]}),"ContactMiscInputs"),y3e=i(e=>`${e.first_name} ${e.last_name}`,"saleOptionRenderer"),b3e=i(()=>{const{identity:e}=Zn();return d.jsx(Lw,{redirect:"show",transform:i(t=>({...t,first_seen:new Date().toISOString(),last_seen:new Date().toISOString(),tags:[]}),"transform"),children:d.jsx("div",{className:"mt-2 flex lg:mr-72",children:d.jsx("div",{className:"flex-1",children:d.jsx(ra,{defaultValues:{sales_id:e?.id},children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(rne,{}),d.jsx(q1,{})]})})})})})})},"ContactCreate"),sV=i(e=>{const{children:t,resource:n,perPage:r,sort:a,filter:o}=e,s=oi(e)||x3e,l=zw({data:s,resource:n,perPage:r,sort:a,filter:o});return d.jsx(ny,{value:l,children:t})},"ArrayField"),x3e=[],w3e=i(({icon:e=_3e,label:t,className:n,...r})=>{const{handleDelete:a,isPending:o}=ape(r);return d.jsxs(ze,{variant:"destructive",type:"button",onClick:a,disabled:o,className:Se("h-9",n),children:[e,d.jsx(lr,{i18nKey:t??"ra.action.delete",children:t??"Delete"})]})},"BulkDeleteButton"),_3e=d.jsx(MM,{}),S3e=i(({icon:e=j3e,label:t="ra.action.export",onClick:n,...r})=>{const a=Kpe(r),o=i(s=>{a(),n?.(s)},"handleClick");return d.jsxs(ze,{onClick:o,role:"button",variant:"outline",size:"sm",className:"flex items-center gap-2 h-9",...E3e(r),children:[e,t&&d.jsx(lr,{i18nKey:t,children:t})]})},"BulkExportButton"),j3e=d.jsx(TM,{className:"h-4 w-4"}),E3e=i(({resource:e,exporter:t,onClick:n,label:r,icon:a,meta:o,...s})=>s,"sanitizeRestProps");function ane(){return d.jsxs(d.Fragment,{children:[d.jsx(S3e,{}),d.jsx(w3e,{})]})}i(ane,"BulkActionsToolbarChildren");const ine=i(({children:e=d.jsx(ane,{})})=>{const{selectedIds:t,onUnselectItems:n}=Gn();if(!t?.length)return null;const r=i(a=>{a.stopPropagation(),n()},"handleUnselectAll");return d.jsxs(pn,{className:"flex flex-col gap-2 md:gap-6 md:flex-row items-stretch sm:items-center p-2 px-4 w-[90%] sm:w-fit mx-auto fixed bottom-2 left-0 right-0 z-10 bg-zinc-100 dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(ze,{variant:"ghost",className:"has-[>svg]:px-0",onClick:r,children:d.jsx(Tp,{})}),d.jsx("span",{className:"text-sm text-muted-foreground",children:d.jsxs(lr,{i18nKey:"ra.action.bulk_actions",options:{smart_count:t.length},children:[t.length," rows selected"]})})]}),e]})},"BulkActionsToolbar");var bA={exports:{}},lV;function C3e(){return lV||(lV=1,(function(e){(function(t,n){e.exports?e.exports=n():this[t]=n()})("Diacritics",function(){for(var t={map:{}},n=[{base:" ",letters:" "},{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"Th",letters:"Þ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"ff",letters:"ff"},{base:"fi",letters:"fi"},{base:"fl",letters:"fl"},{base:"ffi",letters:"ffi"},{base:"ffl",letters:"ffl"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nñnⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ"},{base:"nj",letters:"nj"},{base:"o",letters:"߀oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oe",letters:"Œœ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"ss",letters:"ß"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"th",letters:"þ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],r=0,a=n.length;r<a;r++)for(var o=n[r].letters.split(""),s=0,l=o.length;s<l;s++)t.map[o[s]]=n[r].base;return t.clean=function(f){if(!f||!f.length||f.length<1)return"";for(var c="",p=f.split(""),m=0,g=p.length,b;m<g;m++)b=p[m],c+=b in t.map?t.map[b]:b;return c},t})})(bA)),bA.exports}i(C3e,"requireDiacritics");var cV=C3e();const O3e=i(e=>{const{selected:t,label:n,onToggle:r,onMove:a,source:o,index:s}=e,l=Ht(),f=y.useRef(null),c=y.useRef(null),p=y.useRef(null),m=y.useCallback(_=>{c.current=_.clientX,p.current=_.clientY},[]),g=i(()=>{document.addEventListener("dragover",m)},"handleDragStart"),b=i(_=>{const j=_.target;j.dataset.dragActive="true";const E=j.closest("ul");if(c.current==null||p.current==null)return;const O=document.elementFromPoint(c.current,p.current);let C=O===null?j:O.closest("li");if(!C)return;if(C.classList.contains("dragIcon")){const R=C.parentNode;R instanceof HTMLElement&&(C=R)}if(C===j)return;const T=C.parentNode;if(E&&T instanceof HTMLElement&&E===T.closest("ul")){const R=C.dataset.index;R&&(f.current=parseInt(R,10)),C===j.nextSibling&&(C=C.nextSibling),E.insertBefore(j,C)}},"handleDrag"),w=i(_=>{const j=_.target,E=j.closest("ul"),O=c.current!=null&&p.current!=null?document.elementFromPoint(c.current,p.current):null;let C=c.current==null||p.current==null||O===null?j:O.closest("li");if(p.current!==null&&E&&!C){const T=j.closest("ul");T&&p.current>T.getBoundingClientRect().bottom?C=E.lastChild:C=E.firstChild}C&&E&&C.closest("ul")===E?a&&a(j.dataset.index,f.current):(_.preventDefault(),_.stopPropagation()),j.dataset.dragActive="false",document.removeEventListener("dragover",m)},"handleDragEnd"),S=i(_=>{_.preventDefault(),_.dataTransfer.dropEffect="move"},"handleDragOver");return d.jsxs("li",{role:"option",draggable:a?"true":void 0,onDrag:a?b:void 0,onDragStart:a?g:void 0,onDragEnd:a?w:void 0,onDragOver:a?S:void 0,"data-index":s,className:Se("flex justify-between items-center py-1","data-[drag-active=true]:bg-transparent data-[drag-active=true]:text-transparent data-[drag-active=true]:outline data-[drag-active=true]:outline-1 data-[drag-active=true]:outline-border"),children:[d.jsxs("label",{htmlFor:`switch_${s}`,className:"flex items-center gap-2 cursor-pointer",children:[d.jsx(Vte,{id:`switch_${s}`,checked:t,onCheckedChange:r,name:`${s}`}),d.jsx("span",{className:"text-sm",children:d.jsx(ca,{label:n,source:o,resource:l})})]}),a&&d.jsx(Hwe,{className:"cursor-move dragIcon w-4 h-4 text-muted-foreground"})]},o)},"FieldToggle"),k3e=i(({children:e})=>{const t=xt(),{storeKey:n,defaultHiddenColumns:r}=Zw(),[a,o]=ba(`${n}_columnRanks`),[s,l]=ba(n,r),f=`${n}-columnsSelector`,[c,p]=y.useState(()=>typeof document<"u"?document.getElementById(f):null);y.useEffect(()=>{if(c&&typeof document<"u"&&document.body.contains(c))return;const _=setInterval(()=>{const E=document.getElementById(f);E&&p(E)},100),j=setTimeout(()=>clearInterval(_),500);return()=>{clearInterval(_),clearTimeout(j)}},[f,c]);const[m,g]=y.useState("");if(!c)return null;const b=y.Children.toArray(e),w=ON(a??[],b.length),S=b.length>5;return el.createPortal(d.jsxs("ul",{className:"max-h-[50vh] p-1 overflow-auto",children:[S?d.jsx("li",{className:"pb-2",tabIndex:-1,children:d.jsxs("div",{className:"relative",children:[d.jsx(_r,{value:m,onChange:i(_=>{g(_.target.value)},"onChange"),placeholder:t("ra.action.search_columns",{_:"Search columns"}),className:"pr-8"}),d.jsx(DM,{className:"absolute right-2 top-2 h-4 w-4 text-muted-foreground"}),m&&d.jsx("button",{onClick:i(()=>g(""),"onClick"),className:"absolute right-8 top-2 h-4 w-4 text-muted-foreground","aria-label":"Clear",children:"×"})]})}):null,w.map((_,j)=>d.jsx(PY.Provider,{value:_,children:d.jsx(NY.Provider,{value:m,children:b[_]},j)},j)),d.jsx("li",{className:"text-center mt-2 px-3",children:d.jsx(ze,{variant:"outline",size:"sm",onClick:i(()=>{o(void 0),l(r)},"onClick"),children:"Reset"})})]}),c)},"ColumnsSelector"),R3e=i(({source:e,label:t})=>{const n=Ht(),{storeKey:r,defaultHiddenColumns:a}=Zw(),[o,s]=ba(r,a),l=Zge(),[f,c]=ba(`${r}_columnRanks`),p=Jge(),m=Yw();if(!e&&!t)return null;const g=m({label:typeof t=="string"?t:void 0,resource:n,source:e}),b=o.includes(e),w=A3e(g,p),S=i((_,j)=>{const E=f?Math.max(Number(_),Number(j||0))>f.length-1?ON(f,Math.max(Number(_),Number(j||0))+1):f:ON([],Math.max(Number(_),Number(j||0))+1),O=E.findIndex(R=>R==Number(_)),C=E.findIndex(R=>R==Number(j));if(O===-1||C===-1)return;let T;O>C?T=[...E.slice(0,C),E[O],...E.slice(C,O),...E.slice(O+1)]:T=[...E.slice(0,O),...E.slice(O+1,C+1),E[O],...E.slice(C+1)],c(T)},"handleMove");return w?d.jsx(O3e,{source:e,label:g,index:String(l),selected:!b,onToggle:i(()=>s(b?o.filter(_=>_!==e):[...o,e]),"onToggle"),onMove:S},l):null},"ColumnsSelectorItem"),ON=i((e,t)=>e.concat(Array.from({length:t-e.length},(n,r)=>e.length+r)),"padRanks"),A3e=i((e,t)=>t?cV.clean(e).toLowerCase().includes(cV.clean(t).toLowerCase()):!0,"fieldLabelMatchesFilter");function T3e({className:e,...t}){return d.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:d.jsx("table",{"data-slot":"table",className:Se("w-full caption-bottom text-sm",e),...t})})}i(T3e,"Table");function P3e({className:e,...t}){return d.jsx("thead",{"data-slot":"table-header",className:Se("[&_tr]:border-b",e),...t})}i(P3e,"TableHeader");function N3e({className:e,...t}){return d.jsx("tbody",{"data-slot":"table-body",className:Se("[&_tr:last-child]:border-0",e),...t})}i(N3e,"TableBody");function one({className:e,...t}){return d.jsx("tr",{"data-slot":"table-row",className:Se("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...t})}i(one,"TableRow");function sne({className:e,...t}){return d.jsx("th",{"data-slot":"table-head",className:Se("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}i(sne,"TableHead");function lne({className:e,...t}){return d.jsx("td",{"data-slot":"table-cell",className:Se("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...t})}i(lne,"TableCell");var Q1="Checkbox",[D3e,WUe]=da(Q1),[M3e,I4]=D3e(Q1);function I3e(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:o,form:s,name:l,onCheckedChange:f,required:c,value:p="on",internal_do_not_use_render:m}=e,[g,b]=eo({prop:n,defaultProp:a??!1,onChange:f,caller:Q1}),[w,S]=y.useState(null),[_,j]=y.useState(null),E=y.useRef(!1),O=w?!!s||!!w.closest("form"):!0,C={checked:g,disabled:o,setChecked:b,control:w,setControl:S,name:l,form:s,value:p,hasConsumerStoppedPropagationRef:E,required:c,defaultChecked:dc(a)?!1:a,isFormControl:O,bubbleInput:_,setBubbleInput:j};return d.jsx(M3e,{scope:t,...C,children:F3e(m)?m(C):r})}i(I3e,"CheckboxProvider");var cne="CheckboxTrigger",une=y.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:o,value:s,disabled:l,checked:f,required:c,setControl:p,setChecked:m,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:w}=I4(cne,e),S=Zt(a,p),_=y.useRef(f);return y.useEffect(()=>{const j=o?.form;if(j){const E=i(()=>m(_.current),"reset");return j.addEventListener("reset",E),()=>j.removeEventListener("reset",E)}},[o,m]),d.jsx(yt.button,{type:"button",role:"checkbox","aria-checked":dc(f)?"mixed":f,"aria-required":c,"data-state":vne(f),"data-disabled":l?"":void 0,disabled:l,value:s,...r,ref:S,onKeyDown:tt(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:tt(n,j=>{m(E=>dc(E)?!0:!E),w&&b&&(g.current=j.isPropagationStopped(),g.current||j.stopPropagation())})})});une.displayName=cne;var dne=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:o,required:s,disabled:l,value:f,onCheckedChange:c,form:p,...m}=e;return d.jsx(I3e,{__scopeCheckbox:n,checked:a,defaultChecked:o,disabled:l,required:s,onCheckedChange:c,name:r,form:p,value:f,internal_do_not_use_render:i(({isFormControl:g})=>d.jsxs(d.Fragment,{children:[d.jsx(une,{...m,ref:t,__scopeCheckbox:n}),g&&d.jsx(mne,{__scopeCheckbox:n})]}),"internal_do_not_use_render")})});dne.displayName=Q1;var fne="CheckboxIndicator",hne=y.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,o=I4(fne,n);return d.jsx(Ea,{present:r||dc(o.checked)||o.checked===!0,children:d.jsx(yt.span,{"data-state":vne(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});hne.displayName=fne;var pne="CheckboxBubbleInput",mne=y.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:o,defaultChecked:s,required:l,disabled:f,name:c,value:p,form:m,bubbleInput:g,setBubbleInput:b}=I4(pne,e),w=Zt(n,b),S=N1(o),_=v1(r);y.useEffect(()=>{const E=g;if(!E)return;const O=window.HTMLInputElement.prototype,T=Object.getOwnPropertyDescriptor(O,"checked").set,R=!a.current;if(S!==o&&T){const A=new Event("click",{bubbles:R});E.indeterminate=dc(o),T.call(E,dc(o)?!1:o),E.dispatchEvent(A)}},[g,S,o,a]);const j=y.useRef(dc(o)?!1:o);return d.jsx(yt.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??j.current,required:l,disabled:f,name:c,value:p,form:m,...t,tabIndex:-1,ref:w,style:{...t.style,..._,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});mne.displayName=pne;function F3e(e){return typeof e=="function"}i(F3e,"isFunction");function dc(e){return e==="indeterminate"}i(dc,"isIndeterminate");function vne(e){return dc(e)?"indeterminate":e?"checked":"unchecked"}i(vne,"getState");function Up({className:e,...t}){return d.jsx(dne,{"data-slot":"checkbox",className:Se("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:d.jsx(hne,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:d.jsx(uc,{className:"size-3.5"})})})}i(Up,"Checkbox");const L3e=i(({defaultValue:e,source:t,record:n,empty:r,transform:a=$3e,locales:o,options:s,...l})=>{let f=oi({defaultValue:e,source:t,record:n});const c=xt();return f==null?r?d.jsx("span",{...l,children:typeof r=="string"?c(r,{_:r}):r}):null:(a&&(f=a(f)),d.jsx("span",{...l,children:q3e&&typeof f=="number"?f.toLocaleString(o,s):f}))},"NumberField"),$3e=i(e=>e&&typeof e=="string"&&!isNaN(e)?+e:e,"defaultTransform"),q3e=!!(typeof Intl=="object"&&Intl&&typeof Intl.NumberFormat=="function"),uV=d.jsx(ane,{});function Fs(e){const{children:t,className:n,rowClassName:r,bulkActionButtons:a=uV,bulkActionsToolbar:o,...s}=e,l=!!o||a!==!1,f=Ht(e),c=e.storeKey||`${f}.datatable`,[p]=ba(`${c}_columnRanks`),m=p?W3e(t,p):t;return d.jsxs(Qge,{hasBulkActions:l,loading:null,empty:d.jsx(H3e,{}),...s,children:[d.jsx("div",{className:Se("rounded-md border",n),children:d.jsxs(T3e,{children:[d.jsx(nP.Provider,{value:"header",children:d.jsx(z3e,{children:m})}),d.jsx(U3e,{rowClassName:r,children:m})]})}),o??(a!==!1&&d.jsx(ine,{children:y.isValidElement(a)?a:uV})),d.jsx(nP.Provider,{value:"columnsSelector",children:d.jsx(k3e,{children:t})})]})}i(Fs,"DataTable");Fs.Col=gne;Fs.NumberCol=Q3e;const z3e=i(({children:e})=>{const t=OY(),{hasBulkActions:n=!1}=EY(),{onSelect:r}=gM(),a=RY(),o=i(l=>{!r||!t||!a||r(l?a.concat(t.filter(f=>!a.includes(f.id)).map(f=>f.id)):[])},"handleToggleSelectAll"),s=Array.isArray(t)?t.map(l=>l.id):[];return d.jsx(P3e,{children:d.jsxs(one,{children:[n?d.jsx(sne,{className:"w-8",children:d.jsx(Up,{onCheckedChange:o,checked:a&&a.length>0&&s.length>0&&s.every(l=>a.includes(l)),className:"mb-2"})}):null,e]})})},"DataTableHead"),U3e=i(({children:e,rowClassName:t})=>{const n=OY();return d.jsx(N3e,{children:n?.map((r,a)=>d.jsx(Ba,{value:r,children:d.jsx(B3e,{className:t?.(r),children:e})},r.id??`row${a}`))})},"DataTableBody"),B3e=i(({children:e,className:t})=>{const{rowClick:n,handleToggleItem:r}=gM(),a=RY(),{hasBulkActions:o=!1}=EY(),s=Wt();if(!s)throw new Error("DataTableRow can only be used within a RecordContext");const l=Ht();if(!l)throw new Error("DataTableRow can only be used within a ResourceContext");const f=Sa(),c=JG(),p=y.useCallback(g=>{g.stopPropagation(),r&&r(s.id,g)},[r,s.id]),m=y.useCallback(async()=>{const g=typeof n=="function"?n(s.id,l,s):n,b=V3e(g)?await g:g,w=await c({record:s,resource:l,link:b});w===!1||w==null||f(w,{state:{_scrollToTop:!0}})},[s,l,n,f,c]);return d.jsxs(one,{onClick:m,className:Se(n!==!1&&"cursor-pointer",t),children:[o?d.jsx(lne,{className:"flex w-8",onClick:p,children:d.jsx(Up,{checked:a?.includes(s.id),onClick:p})}):null,e]},s.id)},"DataTableRow"),V3e=i(e=>e&&typeof e.then=="function","isPromise"),H3e=i(()=>d.jsx(ai,{children:d.jsx(ki,{children:"No results found."})}),"DataTableEmpty");function gne(e){switch(eye()){case"columnsSelector":return d.jsx(R3e,{...e});case"header":return d.jsx(G3e,{...e});case"data":return d.jsx(Y3e,{...e})}}i(gne,"DataTableColumn");const W3e=i((e,t)=>y.Children.toArray(e).reduce((n,r,a)=>{const o=t.indexOf(a);return o===-1?n[a]=r:n[o]=r,n},[]),"reorderChildren");function G3e(e){const{disableSort:t,source:n,label:r,sortByOrder:a,className:o,headerClassName:s}=e,l=Yge(),{handleSort:f}=gM(),c=Ht(),p=xt(),m=Yw(),{storeKey:g,defaultHiddenColumns:b}=Zw(),[w]=ba(g,b);if(w.includes(n))return null;const _=l&&l.field===n?K3e[l.order]:a??"ASC",j=m({label:typeof r=="string"?r:void 0,resource:c,source:n}),E=p("ra.sort.sort_by",{field:j,field_lower_first:typeof j=="string"?j.charAt(0).toLowerCase()+j.slice(1):void 0,order:p(`ra.sort.${_}`),_:p("ra.action.sort")});return d.jsx(sne,{className:Se(o,s),children:f&&l&&!t&&n?d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsxs(ze,{variant:"ghost",size:"sm",className:"-ml-3 -mr-3 h-8 data-[state=open]:bg-accent cursor-pointer","data-field":n,onClick:f,children:[s?.includes("text-right")?null:d.jsx(ca,{label:r,source:n,resource:c}),l.field===n?l.order==="ASC"?d.jsx(Mxe,{className:"ml-2 h-6 w-6"}):d.jsx(zxe,{className:"ml-2 h-6 w-6"}):null,s?.includes("text-right")?d.jsx(ca,{label:r,source:n,resource:c}):null]})}),d.jsx(oo,{children:d.jsx("p",{children:E})})]})}):d.jsx(ca,{label:r,source:n,resource:c})})}i(G3e,"DataTableHeadCell");const K3e={ASC:"DESC",DESC:"ASC"};function Y3e(e){const{children:t,render:n,field:r,source:a,className:o,cellClassName:s,conditionalClassName:l}=e,{storeKey:f,defaultHiddenColumns:c}=Zw(),[p]=ba(f,c),m=Wt();if(p.includes(a))return null;if(!n&&!r&&!t&&!a)throw new Error("DataTableColumn: Missing at least one of the following props: render, field, children, or source");return d.jsx(lne,{className:Se("py-1",o,s,m&&l?.(m)),children:t??(n?m&&n(m):r?y.createElement(r,{source:a}):Yt(m,a))})}i(Y3e,"DataTableCell");function Q3e(e){const{source:t,options:n,locales:r,className:a,headerClassName:o,cellClassName:s,...l}=e;return d.jsx(gne,{source:t,...l,className:a,headerClassName:Se("text-right",o),cellClassName:Se("text-right",s),children:d.jsx(L3e,{source:t,options:n,locales:r})})}i(Q3e,"DataTableNumberColumn");const yne=i(e=>{const{className:t,inputClassName:n,defaultValue:r,format:a=Z3e,label:o,source:s,helperText:l,onChange:f,onFocus:c,validate:p,disabled:m,readOnly:g,...b}=e,w=Ht(e),{field:S,id:_,isRequired:j}=Cc({defaultValue:r,source:s,validate:p,disabled:m,readOnly:g,format:a,...b}),E=y.useRef(null),O=y.useRef(S.value),[C,T]=y.useState(1),R=y.useRef(!1);y.useEffect(()=>{if(R.current){R.current=!1;return}E.current?.value!==S.value&&!(E.current?.value===""&&S.value==null)&&(O.current=S.value,T($=>$+1),R.current=!1)},[T,S.value]);const{onBlur:A}=S,P=y.useRef(!1),D=Et(U=>{if(f&&f(U),typeof U.target>"u"||typeof U.target.value>"u")return;const $=U.target,V=$.value,z=V===""||$.valueAsDate!=null&&!isNaN(new Date($.valueAsDate).getTime());V!==""&&V!=null&&z&&(S.onChange(V),R.current=!0)}),M=Et(U=>{c&&c(U),P.current=!0}),I=Et(()=>{if(P.current=!1,!E.current)return;const U=E.current.value;(U===""||E.current.valueAsDate!=null&&!isNaN(new Date(E.current.valueAsDate).getTime()))&&S.value!==U&&S.onChange(U??""),A&&A()}),{ref:F,name:L}=S,q=y.useCallback(U=>{typeof F=="function"?F(U):F&&U&&(F.current=U),E.current=U},[F]);return d.jsxs(Wo,{id:_,className:t,name:L,children:[o!==!1&&d.jsx(Xs,{children:d.jsx(ca,{label:o,source:s,resource:w,isRequired:j})}),d.jsx(jy,{children:d.jsx(_r,{ref:q,defaultValue:a(O.current)??"",type:"date",onChange:D,onFocus:M,onBlur:I,className:Se("ra-input",`ra-input-${s}`,"[color-scheme:light] dark:[color-scheme:dark] relative [&::-webkit-calendar-picker-indicator]:cursor-pointer [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:right-3 [&::-webkit-calendar-picker-indicator]:opacity-100",n),disabled:m||g,readOnly:g,...b},C)}),d.jsx(Go,{helperText:l}),d.jsx(il,{})]})},"DateInput"),dV=i(e=>{if(!(e instanceof Date)||isNaN(e.getDate()))return"";const t=new Date(e.getTime()),n="00",r=t.getFullYear().toString(),a=(t.getMonth()+1).toString(),o=t.getDate().toString();return`${r}-${(n+a).slice(-2)}-${(n+o).slice(-2)}`},"convertDateToString$1"),X3e=/^\d{4}-\d{2}-\d{2}$/,Z3e=i(e=>e==null||e===""?null:e instanceof Date?dV(e):typeof e=="string"&&X3e.test(e)?e:dV(new Date(e)),"defaultFormat"),J3e=i(({className:e,defaultValue:t,format:n=n5e,parse:r=r5e,label:a,helperText:o,onBlur:s,onChange:l,onFocus:f,source:c,resource:p,validate:m,disabled:g,readOnly:b,...w})=>{const{field:S,id:_,isRequired:j}=Cc({defaultValue:t,onBlur:s,resource:p,source:c,validate:m,disabled:g,readOnly:b,format:n,parse:r,...w}),E=y.useRef(void 0),O=y.useRef(S.value),[C,T]=y.useState(1),R=y.useRef(!1);y.useEffect(()=>{if(R.current){R.current=!1;return}E.current?.value!==S.value&&!(E.current?.value===""&&S.value==null)&&(O.current=S.value,T($=>$+1),R.current=!1)},[T,S.value]);const{onBlur:A}=S,P=y.useRef(!1),D=i(U=>{if(l&&l(U),typeof U.target>"u"||typeof U.target.value>"u")return;const $=U.target,V=$.value,z=V===""||!isNaN(new Date($.value).getTime());V!==""&&V!=null&&z&&(S.onChange(V),R.current=!0)},"handleChange"),M=i(U=>{f&&f(U),P.current=!0},"handleFocus"),I=i(()=>{if(P.current=!1,!E.current)return;const U=E.current.value;(U===""||!isNaN(new Date(E.current.value).getTime()))&&S.value!==U&&S.onChange(U??""),A&&A()},"handleBlur"),{ref:F,name:L}=S,q=a5e(F,E);return d.jsxs(Wo,{id:_,className:e,name:S.name,children:[a!==!1&&d.jsx(Xs,{children:d.jsx(ca,{label:a,source:c,resource:p,isRequired:j})}),d.jsx(jy,{children:d.jsx(_r,{id:_,ref:q,name:L,defaultValue:n(O.current),type:"datetime-local",onChange:D,onFocus:M,onBlur:I,className:CM("ra-input",`ra-input-${c}`,"[color-scheme:light] dark:[color-scheme:dark] relative [&::-webkit-calendar-picker-indicator]:cursor-pointer [&::-webkit-calendar-picker-indicator]:absolute [&::-webkit-calendar-picker-indicator]:right-3 [&::-webkit-calendar-picker-indicator]:opacity-100",e),disabled:g||b,readOnly:b},C)}),d.jsx(Go,{helperText:o}),d.jsx(il,{})]})},"DateTimeInput"),bne=i((e=2)=>t=>("0".repeat(e)+t).slice(-e),"leftPad"),e5e=bne(4),mb=bne(2),fV=i(e=>{if(!(e instanceof Date)||isNaN(e.getDate()))return"";const t=e5e(e.getFullYear()),n=mb(e.getMonth()+1),r=mb(e.getDate()),a=mb(e.getHours()),o=mb(e.getMinutes());return`${t}-${n}-${r}T${a}:${o}`},"convertDateToString"),t5e=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/,n5e=i(e=>e==null||e===""?"":e instanceof Date?fV(e):t5e.test(e)?e:fV(new Date(e)),"formatDateTime"),r5e=i(e=>new Date(e).toISOString(),"convertDateStringToISO");function a5e(...e){const t=y.useRef(void 0),n=y.useCallback(r=>{const a=e.map(o=>{if(o==null)return null;if(typeof o=="function"){const s=o,l=s(r);return typeof l=="function"?l:()=>{s(null)}}return o.current=r,()=>{o.current=null}});return()=>{a.forEach(o=>o?.())}},e);return y.useMemo(()=>e.every(r=>r==null)?null:r=>{t.current&&(t.current(),t.current=void 0),r!=null&&(t.current=n(r))},e)}i(a5e,"useForkRef");const xne=i(e=>{const{className:t,empty:n,defaultValue:r,source:a,record:o,...s}=e,l=oi({defaultValue:r,source:a,record:o}),f=xt();return l==null?n?d.jsx("span",{className:t,...s,children:typeof n=="string"?f(n,{_:n}):n}):null:d.jsx("a",{className:Se("underline hover:no-underline",t),href:`mailto:${l}`,onClick:o5e,...s,children:l})},"EmailFieldImpl");xne.displayName="EmailFieldImpl";const i5e=G1(xne),o5e=i(e=>e.stopPropagation(),"stopPropagation"),wne=i(e=>{const{className:t,empty:n,title:r,src:a,target:o,download:s,defaultValue:l,source:f,record:c,...p}=e,m=oi({defaultValue:l,source:f,record:c}),g=oi({...e,source:r})?.toString()??r,b=xt();return m==null||Array.isArray(m)&&m.length===0?n?d.jsx("div",{className:Se("inline-block",t),...p,children:typeof n=="string"?b(n,{_:n}):n}):null:Array.isArray(m)?d.jsx("ul",{className:Se("inline-block",t),...p,children:m.map((w,S)=>{const _=r&&Yt(w,r,r),j=a?Yt(w,a,r):r;return d.jsx("li",{children:d.jsx("a",{href:j,title:_,target:o,download:s,onClick:i(E=>E.stopPropagation(),"onClick"),children:_})},S)})}):d.jsx("div",{className:Se("inline-block",t),...p,children:d.jsx("a",{href:m?.toString(),title:g,target:o,download:s,onClick:i(w=>w.stopPropagation(),"onClick"),children:g})})},"FileField"),_ne=i(e=>{const{alwaysOn:t,defaultValue:n,format:r,label:a,helperText:o,name:s,onBlur:l,onChange:f,parse:c,resource:p,source:m,validate:g,readOnly:b,disabled:w,accept:S,maxSize:_,minSize:j,multiple:E=!1,options:O={},children:C,className:T,inputProps:R,onRemove:A,validateFileRemoval:P,placeholder:D,labelMultiple:M="ra.input.file.upload_several",labelSingle:I="ra.input.file.upload_single",removeIcon:F,...L}=e,{onDrop:q}=O,U=xt(),$=i(ce=>{if(!(ce instanceof File))return ce;const he=URL.createObjectURL(ce);return{rawFile:ce,src:he,title:ce.name}},"transformFile"),V=i(ce=>ce?Array.isArray(ce)?ce.map($):$(ce):E?[]:null,"transformFiles"),{id:z,field:{onChange:W,onBlur:H,value:Q,name:Y},isRequired:K}=Cc({alwaysOn:t,defaultValue:n,format:r||V,label:a,helperText:o,name:s,onBlur:l,onChange:f,parse:c||V,resource:p,source:m,validate:g,readOnly:b,disabled:w}),ee=Q?Array.isArray(Q)?Q:[Q]:[],te=i((ce,he,J)=>{const Me=E?[...ee,...ce]:[...ce];E?(W(Me),H()):(W(Me[0]),H()),q&&q(ce,he,J)},"onDrop"),oe=i(ce=>async()=>{if(P)try{await P(ce)}catch{return}if(E){const he=ee.filter(J=>!XD(J,ce));W(he),H()}else W(null),H();A&&A(ce)},"onRemove"),ne=C&&y.isValidElement(y.Children.only(C))?y.Children.only(C):void 0,{getRootProps:fe,getInputProps:re}=H1({accept:S,maxSize:_,minSize:j,multiple:E,disabled:w||b,...O,onDrop:te});return d.jsxs(Wo,{id:z,name:Y,className:Se("w-full",T),...L,children:[d.jsx(Xs,{htmlFor:z,className:w||b?"cursor-default":"cursor-pointer",children:d.jsx(ca,{label:a,source:m,resource:p,isRequired:K})}),d.jsxs("div",{...fe({className:Se("border-2 border-dashed border-muted rounded-lg p-6 text-center transition-colors","hover:border-sidebar-ring focus:outline-none",w||b?"bg-muted cursor-not-allowed":"bg-muted text-muted-foreground cursor-pointer")}),children:[d.jsx("input",{id:z,name:Y,...re({...R})}),D||(E?d.jsx("p",{className:"text-sm",children:U(M)}):d.jsx("p",{className:"text-sm",children:U(I)}))]}),d.jsx(Go,{helperText:o}),d.jsx(il,{}),C&&d.jsx("div",{className:"previews flex flex-col gap-1",children:ee.map((ce,he)=>d.jsx(s5e,{file:ce,onRemove:oe(ce),removeIcon:F,children:d.jsx(Ba,{value:ce,children:ne})},he))})]})},"FileInput"),s5e=i(e=>{const{className:t,children:n,file:r,onRemove:a,removeIcon:o=al,...s}=e,l=xt();return y.useEffect(()=>()=>{const f=r.rawFile?r.rawFile.preview:r.preview;f&&window.URL.revokeObjectURL(f)},[r]),d.jsxs("div",{className:Se("flex flex-row gap-1",t),...s,children:[d.jsx(ze,{variant:"ghost",size:"icon",className:"h-6 w-6 rounded-full shadow-sm cursor-pointer",onClick:a,"aria-label":l("ra.action.delete"),title:l("ra.action.delete"),children:d.jsx(o,{className:"h-4 w-4"})}),n]})},"FileInputPreview");Fs.Col;const l5e=i(e=>{const{children:t,className:n,empty:r,field:a,label:o,render:s,resource:l,source:f,record:c,variant:p,...m}=e,g=Ht(e),b=Wt({recordProp:c}),w=xt();return!f&&!o&&!s?null:d.jsxs("div",{className:Se(n,"flex",p==="inline"?"flex-row":"flex-col"),...m,children:[o!==""&&o!==!1?d.jsx("div",{className:Se(p==="inline"?"block min-w-50":"text-xs","text-muted-foreground"),children:d.jsx(ca,{label:o,source:f,resource:g,isRequired:!1})}):null,t?d.jsx("span",{className:"flex-1",children:t}):s?b&&d.jsx("span",{className:"flex-1",children:s(b)||(typeof r=="string"?w(r,{_:r}):r)}):a?y.createElement(a,{source:f,empty:r,className:"flex-1"}):f?d.jsx(na,{source:f,empty:r,className:"flex-1"}):null]})},"RecordField"),c5e=i(()=>{const e=Wt();return e?d.jsxs("div",{className:"flex flex-row gap-4 items-center justify-start",children:[d.jsx(is,{height:40,width:40,record:e}),d.jsxs("div",{className:"flex flex-col items-start gap-1",children:[d.jsxs("span",{children:[e.first_name," ",e.last_name]}),d.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.title,e.title&&e.company_name&&" at ",e.company_name]})]})]}):null},"ContactOptionRender"),kN=d.jsx(c5e,{}),Sne=i(({selectContact:e,display:t="chip"})=>{const{identity:n}=Zn(),r=_n(),[a]=ud(),o=Vt(),{taskTypes:s}=Va(),l=Wt(),[f,c]=y.useState(!1),p=i(()=>{c(!0)},"handleOpen"),m=i(async g=>{c(!1);const b=await r.getOne("contacts",{id:g.contact_id});b.data&&(await a("contacts",{id:b.data.id,data:{last_seen:new Date().toISOString()},previousData:b.data}),o("Task added"))},"handleSuccess");return n?d.jsxs(d.Fragment,{children:[t==="icon"?d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsx(ze,{size:"sm",variant:"ghost",className:"p-2 cursor-pointer",onClick:p,children:d.jsx(Ji,{className:"w-4 h-4"})})}),d.jsx(oo,{children:"Create task"})]})}):d.jsx("div",{className:"my-2",children:d.jsxs(ze,{variant:"outline",className:"h-6 cursor-pointer",onClick:p,size:"sm",children:[d.jsx(Ji,{className:"w-4 h-4"}),"Add task"]})}),d.jsx(Lw,{resource:"tasks",record:{type:"None",contact_id:l?.id,due_date:new Date().toISOString().slice(0,10),sales_id:n.id},transform:i(g=>{const b=new Date(g.due_date);return b.setHours(0,0,0,0),g.due_date=b.toISOString(),{...g,due_date:new Date(g.due_date).toISOString()}},"transform"),mutationOptions:{onSuccess:m},children:d.jsx(wa,{open:f,onOpenChange:i(()=>c(!1),"onOpenChange"),children:d.jsx(_a,{className:"lg:max-w-xl overflow-y-auto max-h-9/10 top-1/20 translate-y-0",children:d.jsxs(ra,{className:"flex flex-col gap-4",children:[d.jsx(Wr,{children:d.jsxs(Gr,{children:[e?"Create a new task":"Create a new task for ",!e&&d.jsx(CK,{record:l,resource:"contacts"})]})}),d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(ln,{autoFocus:!0,source:"text",label:"Description",validate:nr(),multiline:!0,className:"m-0",helperText:!1}),e&&d.jsx(Ry,{source:"contact_id",reference:"contacts_summary",children:d.jsx(B1,{label:"Contact",optionText:kN,helperText:!1,validate:nr()})}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsx(yne,{source:"due_date",helperText:!1,validate:nr()}),d.jsx(Zs,{source:"type",validate:nr(),choices:s.map(g=>({id:g,name:g})),helperText:!1})]})]}),d.jsx(Yo,{className:"w-full justify-end",children:d.jsx(yd,{})})]})})})})]}):null},"AddTask"),u5e=i(({open:e,close:t,taskId:n})=>{const{taskTypes:r}=Va(),a=Vt();return d.jsx(wa,{open:e,onOpenChange:t,children:n&&d.jsx(aM,{id:n,resource:"tasks",className:"mt-0",mutationOptions:{onSuccess:i(()=>{t(),a("Task updated",{type:"info",undoable:!0})},"onSuccess")},redirect:!1,children:d.jsx(_a,{className:"lg:max-w-xl overflow-y-auto max-h-9/10 top-1/20 translate-y-0",children:d.jsxs(ra,{className:"flex flex-col gap-4",children:[d.jsx(Wr,{children:d.jsx(Gr,{children:"Edit task"})}),d.jsx(ln,{autoFocus:!0,source:"text",label:"Description",validate:nr(),multiline:!0,helperText:!1}),d.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[d.jsx(yne,{source:"due_date",helperText:!1,validate:nr()}),d.jsx(Zs,{source:"type",choices:r.map(o=>({id:o,name:o})),helperText:!1,validate:nr()})]}),d.jsxs(Yo,{className:"w-full sm:justify-between gap-4",children:[d.jsx(D4,{mutationOptions:{onSuccess:i(()=>{t(),a("Task deleted",{type:"info",undoable:!0})},"onSuccess")},redirect:!1}),d.jsx(yd,{label:"Save"})]})]})})})})},"TaskEdit"),d5e=i(({task:e,showContact:t})=>{const n=Vt(),r=Pn(),[a,o]=y.useState(!1),s=i(()=>{o(!1)},"handleCloseEdit"),[l,{isPending:f,isSuccess:c,variables:p}]=ud(),{handleDelete:m}=mK({record:e,redirect:!1,mutationOptions:{onSuccess(){n("Task deleted successfully",{undoable:!0})}}}),g=i(()=>{o(!0)},"handleEdit"),b=i(()=>()=>{l("tasks",{id:e.id,data:{done_date:e.done_date?null:new Date().toISOString()},previousData:e})},"handleCheck");y.useEffect(()=>{f||!c||p?.data?.done_date!=null||r.invalidateQueries({queryKey:["tasks","getList"]})},[r,f,c,p]);const w=`checkbox-list-label-${e.id}`;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsxs("div",{className:"flex items-start gap-2 flex-1",children:[d.jsx(Up,{id:w,checked:!!e.done_date,onCheckedChange:b(),disabled:f,className:"mt-1"}),d.jsxs("div",{className:`flex-grow ${e.done_date?"line-through":""}`,children:[d.jsxs("div",{className:"text-sm",children:[e.type&&e.type!=="None"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"font-semibold text-sm",children:e.type})," "]}),e.text]}),d.jsxs("div",{className:"text-sm text-muted-foreground",children:["due ",d.jsx(Bx,{source:"due_date",record:e}),t&&d.jsx(Tr,{source:"contact_id",reference:"contacts",record:e,link:"show",className:"inline text-sm text-muted-foreground",render:i(({referenceRecord:S})=>S?d.jsxs(d.Fragment,{children:[" ","(Re: ",S?.first_name," ",S?.last_name,")"]}):null,"render")})]})]})]}),d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsx(ze,{variant:"ghost",size:"icon",className:"h-5 pr-0! size-8 cursor-pointer","aria-label":"task actions",children:d.jsx(Twe,{className:"h-4 w-4"})})}),d.jsxs(Tc,{align:"end",children:[d.jsx(sr,{className:"cursor-pointer",onClick:i(()=>{l("tasks",{id:e.id,data:{due_date:new Date(Date.now()+1440*60*1e3).toISOString().slice(0,10)},previousData:e})},"onClick"),children:"Postpone to tomorrow"}),d.jsx(sr,{className:"cursor-pointer",onClick:i(()=>{l("tasks",{id:e.id,data:{due_date:new Date(Date.now()+10080*60*1e3).toISOString().slice(0,10)},previousData:e})},"onClick"),children:"Postpone to next week"}),d.jsx(sr,{className:"cursor-pointer",onClick:g,children:"Edit"}),d.jsx(sr,{className:"cursor-pointer",onClick:m,children:"Delete"})]})]})]}),a&&d.jsx(u5e,{taskId:e.id,open:a,close:s})]})},"Task"),jne=i(({showContact:e,className:t})=>{const{data:n,error:r,isPending:a}=Gn();if(a||r||n.length===0)return null;const o=n.filter(s=>!s.done_date||Y0e(new Date(s.done_date),new Date(Date.now()-300*1e3)));return d.jsx("div",{className:`space-y-2 ${t||""}`,children:o.map(s=>d.jsx(d5e,{task:s,showContact:e},s.id))})},"TasksIterator"),vb=["#eddcd2","#fff1e6","#fde2e4","#fad2e1","#c5dedd","#dbe7e4","#f0efeb","#d6e2e9","#bcd4e6","#99c1de"],f5e=i(({color:e,handleClick:t,selected:n})=>d.jsx("button",{type:"button",className:`w-8 h-8 rounded-full inline-block m-1 transition-all ${n?"ring-2 ring-gray-500 ring-offset-1":""}`,style:{backgroundColor:e},onClick:t}),"RoundButton");function Ene({open:e,tag:t,title:n,onClose:r,onSubmit:a}){const[o,s]=y.useState(""),[l,f]=y.useState(vb[0]),[c,p]=y.useState(!1),m=i(w=>{s(w.target.value)},"handleNewTagNameChange"),g=i(()=>{p(!1),r()},"handleClose"),b=i(async w=>{w.preventDefault(),await a({name:o,color:l}),p(!0),s(""),f(vb[0]),g()},"handleSubmit");return y.useEffect(()=>{s(t?.name??""),f(t?.color??vb[0])},[t]),d.jsx(wa,{open:e,onOpenChange:g,children:d.jsx(_a,{className:"sm:max-w-lg",children:d.jsxs("form",{onSubmit:b,children:[d.jsx(Wr,{children:d.jsx(Gr,{children:n})}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"tag-name",children:"Tag name"}),d.jsx(_r,{id:"tag-name",autoFocus:!0,value:o,onChange:m,placeholder:"Enter tag name"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Color"}),d.jsx("div",{className:"flex flex-wrap",children:vb.map(w=>d.jsx(f5e,{color:w,selected:w===l,handleClick:i(()=>{f(w)},"handleClick")},w))})]})]}),d.jsx("div",{className:"flex justify-end pt-4",children:d.jsxs(ze,{variant:"outline",disabled:c,className:Se(kc({variant:"outline"}),"text-primary",c?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[d.jsx(i1,{}),"Save"]})})]})})})}i(Ene,"TagDialog");function h5e({tag:e,open:t,onClose:n,onSuccess:r}){const[a]=ud(),o=i(async s=>{await a("tags",{id:e.id,data:s,previousData:e},{onSuccess:i(async l=>{await r?.(l)},"onSuccess")})},"handleEditTag");return d.jsx(Ene,{open:t,title:"Edit tag",onClose:n,onSubmit:o,tag:e})}i(h5e,"TagEditModal");function p5e({tag:e,onUnlink:t}){const[n,r]=y.useState(!1),a=i(()=>{r(!1)},"handleClose"),o=i(()=>{r(!0)},"handleClick");return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"text-black inline-flex items-center gap-1 px-2 py-1 text-xs rounded-md cursor-pointer hover:opacity-80 transition-opacity",style:{backgroundColor:e.color},onClick:o,children:[e.name,d.jsx("button",{onClick:i(s=>{s.stopPropagation(),t()},"onClick"),className:"transition-colors p-0 ml-1 cursor-pointer",children:d.jsx(Tp,{className:"w-3 h-3"})})]}),d.jsx(h5e,{tag:e,open:n,onClose:a})]})}i(p5e,"TagChip");function m5e({open:e,onClose:t,onSuccess:n}){const[r]=vM(),a=i(async o=>{await r("tags",{data:o},{onSuccess:i(async s=>{await n?.(s)},"onSuccess")})},"handleCreateTag");return d.jsx(Ene,{open:e,title:"Create a new tag",onClose:t,onSubmit:a})}i(m5e,"TagCreateModal");const v5e=i(()=>{const e=Wt(),[t,n]=y.useState(!1),{data:r,isPending:a}=za("tags",{pagination:{page:1,perPage:10},sort:{field:"name",order:"ASC"}}),{data:o,isPending:s}=khe("tags",{ids:e?.tags},{enabled:e&&e.tags&&e.tags.length>0}),[l]=ud(),f=r&&e&&r.filter(w=>!(e.tags??[]).includes(w.id)),c=i(w=>{if(!e)throw new Error("No contact record found");const S=[...e.tags??[],w];l("contacts",{id:e.id,data:{tags:S},previousData:e})},"handleTagAdd"),p=i(async w=>{if(!e)throw new Error("No contact record found");const S=(e.tags??[]).filter(_=>_!==w);await l("contacts",{id:e.id,data:{tags:S},previousData:e})},"handleTagDelete"),m=i(()=>{n(!0)},"openTagCreateDialog"),g=i(()=>{n(!1)},"handleTagCreateClose"),b=y.useCallback(async w=>{if(!e)throw new Error("No contact record found");await l("contacts",{id:e.id,data:{tags:[...e.tags??[],w.id]},previousData:e},{onSuccess:i(()=>{n(!1)},"onSuccess")})},[l,e]);return s||a?null:d.jsxs("div",{className:"flex flex-wrap gap-2",children:[o?.map(w=>d.jsx("div",{children:d.jsx(p5e,{tag:w,onUnlink:i(()=>p(w.id),"onUnlink")})},w.id)),d.jsx("div",{children:d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsxs(ze,{variant:"outline",size:"sm",className:"h-6 cursor-pointer",children:[d.jsx(Ji,{className:"h-3 w-3 mr-1"}),"Add tag"]})}),d.jsxs(Tc,{children:[f?.map(w=>d.jsx(sr,{onClick:i(()=>c(w.id),"onClick"),children:d.jsx(Pr,{variant:"secondary",className:"text-xs font-normal text-black",style:{backgroundColor:w.color},children:w.name})},w.id)),d.jsx(sr,{onClick:m,children:d.jsxs(ze,{variant:"ghost",size:"sm",className:"w-full justify-start p-0 cursor-pointer",children:[d.jsx(RQ,{className:"h-3 w-3 mr-2"}),"Create new tag"]})})]})]})}),d.jsx(m5e,{open:t,onClose:g,onSuccess:b})]})},"TagsListEdit"),g5e=i(()=>{const[e,t]=y.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsxs(ze,{variant:"outline",className:"h-6 cursor-pointer",size:"sm",onClick:i(()=>t(!0),"onClick"),children:[d.jsx(CQ,{className:"w-4 h-4"}),"Merge with another contact"]}),d.jsx(y5e,{open:e,onClose:i(()=>t(!1),"onClose")})]})},"ContactMergeButton"),y5e=i(({open:e,onClose:t})=>{const n=Wt(),r=Vt(),a=rs(),o=_n(),[s,l]=y.useState(null),[f,c]=y.useState(null),[p,m]=y.useState(!1),{mutateAsync:g}=Yr({mutationKey:["contacts","merge",{loserId:n?.id,winnerId:s}],mutationFn:i(async()=>o.mergeContacts(n?.id,s),"mutationFn")}),{data:b}=za("contacts",{filter:{first_name:n?.first_name,last_name:n?.last_name,"id@neq":`${n?.id}`},pagination:{page:1,perPage:10}},{enabled:e&&!!n}),w=e&&!!n&&!!s,{total:S}=qT("tasks",{target:"contact_id",id:n?.id,pagination:{page:1,perPage:1}},{enabled:w}),{total:_}=qT("contactNotes",{target:"contact_id",id:n?.id,pagination:{page:1,perPage:1}},{enabled:w}),{total:j}=za("deals",{filter:{"contact_ids@cs":`{${n?.id}}`},pagination:{page:1,perPage:1}},{enabled:w});y.useEffect(()=>{if(b&&b.length>0){const O=b[0].id;c(O),l(O)}},[b]);const E=i(async()=>{if(!s||!n){r("Please select a contact to merge with",{type:"warning"});return}try{m(!0),await g(),m(!1),r("Contacts merged successfully",{type:"success"}),a(`/contacts/${s}/show`),t()}catch(O){m(!1),r("Failed to merge contacts",{type:"error"}),console.error("Merge failed:",O)}},"handleMerge");return n?d.jsx(wa,{open:e,onOpenChange:t,children:d.jsxs(_a,{className:"md:min-w-lg max-w-2xl",children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Merge Contact"}),d.jsx(Oi,{children:"Merge this contact with another one."})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"p-4 bg-primary/5 rounded-lg border border-primary/20",children:[d.jsx("p",{className:"font-medium text-sm",children:"Current Contact (will be deleted)"}),d.jsx("div",{className:"font-medium text-sm mt-4",children:kN}),d.jsx("div",{className:"flex justify-center my-4",children:d.jsx(Fxe,{className:"h-5 w-5 text-muted-foreground"})}),d.jsx("p",{className:"font-medium text-sm mb-2",children:"Target Contact (will be kept)"}),d.jsx(ra,{children:d.jsx(Ry,{source:"winner_id",reference:"contacts",filter:{"id@neq":n.id},children:d.jsx(B1,{label:"",optionText:kN,validate:nr(),onChange:l,defaultValue:f,helperText:!1})})})]}),s&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("p",{className:"font-medium text-sm",children:"What will be merged:"}),d.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 ml-4",children:[_!=null&&_>0&&d.jsxs("li",{children:["• ",_," note",_!==1?"s":""," will be reassigned"]}),S!=null&&S>0&&d.jsxs("li",{children:["• ",S," task",S!==1?"s":""," will be reassigned"]}),j!=null&&j>0&&d.jsxs("li",{children:["• ",j," deal",j!==1?"s":""," will be updated"]}),n.email_jsonb?.length>0&&d.jsxs("li",{children:["• ",n.email_jsonb.length," email address",n.email_jsonb.length!==1?"es":""," will be added"]}),n.phone_jsonb?.length>0&&d.jsxs("li",{children:["• ",n.phone_jsonb.length," phone number",n.phone_jsonb.length!==1?"s":""," will be added"]}),!_&&!S&&!j&&!n.email_jsonb?.length&&!n.phone_jsonb?.length&&d.jsx("li",{className:"text-muted-foreground/60",children:"No additional data to merge"})]})]}),d.jsxs(ai,{variant:"destructive",children:[d.jsx(J1e,{className:"h-4 w-4"}),d.jsx(_te,{children:"Warning: Destructive Operation"}),d.jsx(ki,{children:"All data will be transferred to the second contact. This action cannot be undone."})]})]})]}),d.jsxs(Yo,{children:[d.jsxs(ze,{variant:"ghost",onClick:t,disabled:p,children:[d.jsx(al,{}),"Cancel"]}),d.jsxs(ze,{onClick:E,disabled:!s||p,children:[d.jsx(CQ,{}),p?"Merging...":"Merge Contacts"]})]})]})}):null},"ContactMergeDialog");function b5e(e){if(e.length<=75)return e;const n=[];let r=e.substring(0,75),a=e.substring(75);for(n.push(r);a.length>0;)r=" "+a.substring(0,74),a=a.substring(74),n.push(r);return n.join(`\r
|
|
106
106
|
`)}i(b5e,"foldLine");function x5e(e,t,n){const r=[];if(r.push("BEGIN:VCARD"),r.push("VERSION:3.0"),r.push(`N:${e.last_name};${e.first_name};;;`),r.push(`FN:${e.first_name} ${e.last_name}`),e.title&&r.push(`TITLE:${e.title}`),t?.name&&r.push(`ORG:${t.name}`),e.email_jsonb&&e.email_jsonb.length>0&&e.email_jsonb.forEach(a=>{const o=a.type.toUpperCase();r.push(`EMAIL;TYPE=${o}:${a.email}`)}),e.phone_jsonb&&e.phone_jsonb.length>0&&e.phone_jsonb.forEach(a=>{const o=a.type.toUpperCase();r.push(`TEL;TYPE=${o}:${a.number}`)}),e.linkedin_url&&r.push(`URL:${e.linkedin_url}`),e.background){const a=e.background.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/,/g,"\\,").replace(/;/g,"\\;");r.push(`NOTE:${a}`)}if(n){const o=`PHOTO;ENCODING=b;TYPE=${n.mimeType.split("/")[1]?.toUpperCase()||"PNG"}:${n.base64}`;r.push(b5e(o))}return r.push("END:VCARD"),r.join(`\r
|
|
107
107
|
`)}i(x5e,"exportToVCard");const w5e=i(()=>{const e=Wt(),{data:t}=Dw("companies",{id:e?.company_id},{enabled:!!e?.company_id}),n=i(async()=>{if(!e)return;let r;if(e.avatar?.src)try{const c=await(await fetch(e.avatar.src)).blob(),p=c.type||"image/png";r={base64:await new Promise((g,b)=>{const w=new FileReader;w.onloadend=()=>{const _=w.result.split(",")[1];g(_)},w.onerror=b,w.readAsDataURL(c)}),mimeType:p}}catch(f){console.error("Failed to fetch avatar image:",f)}const a=x5e(e,t,r),o=new Blob([a],{type:"text/vcard;charset=utf-8"}),s=URL.createObjectURL(o),l=document.createElement("a");l.href=s,l.download=`${e.first_name}_${e.last_name}.vcf`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)},"handleExport");return e?d.jsxs(ze,{variant:"outline",size:"sm",onClick:n,className:"h-6 cursor-pointer",children:[d.jsx(TM,{className:"w-4 h-4"}),"Export to vCard"]}):null},"ExportVCardButton"),Cne=i(({link:e="edit"})=>{const{contactGender:t}=Va(),n=Wt();return n?d.jsxs("div",{className:"hidden sm:block w-64 min-w-64 text-sm",children:[d.jsx("div",{className:"mb-4 -ml-1",children:e==="edit"?d.jsx(Pte,{label:"Edit Contact"}):d.jsx(Nte,{label:"Show Contact"})}),d.jsxs(rc,{title:"Personal info",children:[d.jsx(sV,{source:"email_jsonb",children:d.jsx(Ux,{className:"flex-col",children:d.jsx(gb,{icon:d.jsx(EQ,{className:"w-4 h-4 text-muted-foreground"}),primary:d.jsx(i5e,{source:"email"})})})}),n.has_newsletter&&d.jsx("p",{className:"pl-6 text-sm text-muted-foreground",children:"Subscribed to newsletter"}),n.linkedin_url&&d.jsx(gb,{icon:d.jsx(jQ,{className:"w-4 h-4 text-muted-foreground"}),primary:d.jsx("a",{className:"underline hover:no-underline text-sm text-muted-foreground",href:n.linkedin_url,target:"_blank",rel:"noopener noreferrer",title:n.linkedin_url,children:"LinkedIn"})}),d.jsx(sV,{source:"phone_jsonb",children:d.jsx(Ux,{className:"flex-col",children:d.jsx(gb,{icon:d.jsx(NM,{className:"w-4 h-4 text-muted-foreground"}),primary:d.jsx(na,{source:"number"}),showType:!0})})}),t.map(r=>n.gender===r.value?d.jsx(gb,{icon:d.jsx(r.icon,{className:"w-4 h-4 text-muted-foreground"}),primary:d.jsx("span",{children:r.label})},r.value):null).filter(Boolean)]}),d.jsxs(rc,{title:"Background info",children:[d.jsx(nM,{render:i(r=>r?.background?d.jsx(na,{source:"background",record:r,className:"pb-2"}):null,"render")}),d.jsxs("div",{className:"text-muted-foreground",children:[d.jsx("span",{className:"text-sm",children:"Added on"})," ",d.jsx(Bx,{source:"first_seen",options:{year:"numeric",month:"long",day:"numeric"}})]}),d.jsxs("div",{className:"text-muted-foreground",children:[d.jsx("span",{className:"text-sm",children:"Last activity on"})," ",d.jsx(Bx,{source:"last_seen",options:{year:"numeric",month:"long",day:"numeric"}})]}),d.jsxs("div",{className:"inline-flex text-muted-foreground",children:["Followed by ",d.jsx(Tr,{source:"sales_id",reference:"sales",children:d.jsx(wd,{})})]})]}),d.jsx(rc,{title:"Tags",children:d.jsx(v5e,{})}),d.jsxs(rc,{title:"Tasks",children:[d.jsx(mg,{target:"contact_id",reference:"tasks",sort:{field:"due_date",order:"ASC"},children:d.jsx(jne,{})}),d.jsx(Sne,{})]}),e!=="edit"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"mt-6 pt-6 border-t hidden sm:flex flex-col gap-2 items-start",children:[d.jsx(w5e,{}),d.jsx(g5e,{})]}),d.jsx("div",{className:"mt-6 pt-6 border-t hidden sm:flex flex-col gap-2 items-start",children:d.jsx(D4,{className:"h-6 cursor-pointer hover:bg-destructive/10! text-destructive! border-destructive! focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",size:"sm"})})]})]}):null},"ContactAside"),gb=i(({icon:e,primary:t,showType:n})=>d.jsxs("div",{className:"flex flex-row items-center gap-2 min-h-6",children:[e,d.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-0",children:[t,n?d.jsx(nM,{render:i(r=>r.type!=="Other"&&d.jsx(na,{source:"type",className:"text-muted-foreground"}),"render")}):null]})]}),"PersonalInfoRow"),_5e=i(()=>d.jsx(aM,{redirect:"show",children:d.jsx(S5e,{})}),"ContactEdit"),S5e=i(()=>{const{isPending:e,record:t}=wpe();return e||!t?null:d.jsxs("div",{className:"mt-2 flex gap-8",children:[d.jsx(ra,{className:"flex flex-1 flex-col gap-4",children:d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx(rne,{}),d.jsx(Lte,{})]})})}),d.jsx(Cne,{link:"show"})]})},"ContactEditContent");var Ib={exports:{}};var j5e=Ib.exports,hV;function E5e(){return hV||(hV=1,(function(e,t){((n,r)=>{e.exports=r()})(j5e,i(function n(){var r=typeof self<"u"?self:typeof window<"u"?window:r!==void 0?r:{},a,o=!r.document&&!!r.postMessage,s=r.IS_PAPA_WORKER||!1,l={},f=0,c={};function p(P){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(D){var M=T(D);M.chunkSize=parseInt(M.chunkSize),D.step||D.chunk||(M.chunkSize=null),this._handle=new S(M),(this._handle.streamer=this)._config=M}).call(this,P),this.parseChunk=function(D,M){var I=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<I){let L=this._config.newline;L||(F=this._config.quoteChar||'"',L=this._handle.guessLineEndings(D,F)),D=[...D.split(L).slice(I)].join(L)}this.isFirstChunk&&A(this._config.beforeFirstChunk)&&(F=this._config.beforeFirstChunk(D))!==void 0&&(D=F),this.isFirstChunk=!1,this._halted=!1;var I=this._partialLine+D,F=(this._partialLine="",this._handle.parse(I,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(D=F.meta.cursor,I=(this._finished||(this._partialLine=I.substring(D-this._baseIndex),this._baseIndex=D),F&&F.data&&(this._rowCount+=F.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),s)r.postMessage({results:F,workerId:c.WORKER_ID,finished:I});else if(A(this._config.chunk)&&!M){if(this._config.chunk(F,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=F=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(F.data),this._completeResults.errors=this._completeResults.errors.concat(F.errors),this._completeResults.meta=F.meta),this._completed||!I||!A(this._config.complete)||F&&F.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),I||F&&F.meta.paused||this._nextChunk(),F}this._halted=!0},this._sendError=function(D){A(this._config.error)?this._config.error(D):s&&this._config.error&&r.postMessage({workerId:c.WORKER_ID,error:D,finished:!1})}}i(p,"u");function m(P){var D;(P=P||{}).chunkSize||(P.chunkSize=c.RemoteChunkSize),p.call(this,P),this._nextChunk=o?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(M){this._input=M,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(D=new XMLHttpRequest,this._config.withCredentials&&(D.withCredentials=this._config.withCredentials),o||(D.onload=R(this._chunkLoaded,this),D.onerror=R(this._chunkError,this)),D.open(this._config.downloadRequestBody?"POST":"GET",this._input,!o),this._config.downloadRequestHeaders){var M,I=this._config.downloadRequestHeaders;for(M in I)D.setRequestHeader(M,I[M])}var F;this._config.chunkSize&&(F=this._start+this._config.chunkSize-1,D.setRequestHeader("Range","bytes="+this._start+"-"+F));try{D.send(this._config.downloadRequestBody)}catch(L){this._chunkError(L.message)}o&&D.status===0&&this._chunkError()}},this._chunkLoaded=function(){D.readyState===4&&(D.status<200||400<=D.status?this._chunkError():(this._start+=this._config.chunkSize||D.responseText.length,this._finished=!this._config.chunkSize||this._start>=(M=>(M=M.getResponseHeader("Content-Range"))!==null?parseInt(M.substring(M.lastIndexOf("/")+1)):-1)(D),this.parseChunk(D.responseText)))},this._chunkError=function(M){M=D.statusText||M,this._sendError(new Error(M))}}i(m,"f");function g(P){(P=P||{}).chunkSize||(P.chunkSize=c.LocalChunkSize),p.call(this,P);var D,M,I=typeof FileReader<"u";this.stream=function(F){this._input=F,M=F.slice||F.webkitSlice||F.mozSlice,I?((D=new FileReader).onload=R(this._chunkLoaded,this),D.onerror=R(this._chunkError,this)):D=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var F=this._input,L=(this._config.chunkSize&&(L=Math.min(this._start+this._config.chunkSize,this._input.size),F=M.call(F,this._start,L)),D.readAsText(F,this._config.encoding));I||this._chunkLoaded({target:{result:L}})},this._chunkLoaded=function(F){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(F.target.result)},this._chunkError=function(){this._sendError(D.error)}}i(g,"l");function b(P){var D;p.call(this,P=P||{}),this.stream=function(M){return D=M,this._nextChunk()},this._nextChunk=function(){var M,I;if(!this._finished)return M=this._config.chunkSize,D=M?(I=D.substring(0,M),D.substring(M)):(I=D,""),this._finished=!D,this.parseChunk(I)}}i(b,"c");function w(P){p.call(this,P=P||{});var D=[],M=!0,I=!1;this.pause=function(){p.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){p.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(F){this._input=F,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){I&&D.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),D.length?this.parseChunk(D.shift()):M=!0},this._streamData=R(function(F){try{D.push(typeof F=="string"?F:F.toString(this._config.encoding)),M&&(M=!1,this._checkIsFinished(),this.parseChunk(D.shift()))}catch(L){this._streamError(L)}},this),this._streamError=R(function(F){this._streamCleanUp(),this._sendError(F)},this),this._streamEnd=R(function(){this._streamCleanUp(),I=!0,this._streamData("")},this),this._streamCleanUp=R(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}i(w,"p");function S(P){var D,M,I,F,L=Math.pow(2,53),q=-L,U=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,$=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,V=this,z=0,W=0,H=!1,Q=!1,Y=[],K={data:[],errors:[],meta:{}};function ee(fe){return P.skipEmptyLines==="greedy"?fe.join("").trim()==="":fe.length===1&&fe[0].length===0}i(ee,"y");function te(){if(K&&I&&(ne("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+c.DefaultDelimiter+"'"),I=!1),P.skipEmptyLines&&(K.data=K.data.filter(function(he){return!ee(he)})),oe()){let he=function(J,Me){A(P.transformHeader)&&(J=P.transformHeader(J,Me)),Y.push(J)};if(i(he,"t"),K)if(Array.isArray(K.data[0])){for(var fe=0;oe()&&fe<K.data.length;fe++)K.data[fe].forEach(he);K.data.splice(0,1)}else K.data.forEach(he)}function re(he,J){for(var Me=P.header?{}:[],we=0;we<he.length;we++){var Ee=we,Re=he[we],Re=((ke,Pe)=>(Ue=>(P.dynamicTypingFunction&&P.dynamicTyping[Ue]===void 0&&(P.dynamicTyping[Ue]=P.dynamicTypingFunction(Ue)),(P.dynamicTyping[Ue]||P.dynamicTyping)===!0))(ke)?Pe==="true"||Pe==="TRUE"||Pe!=="false"&&Pe!=="FALSE"&&((Ue=>{if(U.test(Ue)&&(Ue=parseFloat(Ue),q<Ue&&Ue<L))return 1})(Pe)?parseFloat(Pe):$.test(Pe)?new Date(Pe):Pe===""?null:Pe):Pe)(Ee=P.header?we>=Y.length?"__parsed_extra":Y[we]:Ee,Re=P.transform?P.transform(Re,Ee):Re);Ee==="__parsed_extra"?(Me[Ee]=Me[Ee]||[],Me[Ee].push(Re)):Me[Ee]=Re}return P.header&&(we>Y.length?ne("FieldMismatch","TooManyFields","Too many fields: expected "+Y.length+" fields but parsed "+we,W+J):we<Y.length&&ne("FieldMismatch","TooFewFields","Too few fields: expected "+Y.length+" fields but parsed "+we,W+J)),Me}i(re,"i");var ce;K&&(P.header||P.dynamicTyping||P.transform)&&(ce=1,!K.data.length||Array.isArray(K.data[0])?(K.data=K.data.map(re),ce=K.data.length):K.data=re(K.data,0),P.header&&K.meta&&(K.meta.fields=Y),W+=ce)}i(te,"g");function oe(){return P.header&&Y.length===0}i(oe,"_");function ne(fe,re,ce,he){fe={type:fe,code:re,message:ce},he!==void 0&&(fe.row=he),K.errors.push(fe)}i(ne,"k"),A(P.step)&&(F=P.step,P.step=function(fe){K=fe,oe()?te():(te(),K.data.length!==0&&(z+=fe.data.length,P.preview&&z>P.preview?M.abort():(K.data=K.data[0],F(K,V))))}),this.parse=function(fe,re,ce){var he=P.quoteChar||'"',he=(P.newline||(P.newline=this.guessLineEndings(fe,he)),I=!1,P.delimiter?A(P.delimiter)&&(P.delimiter=P.delimiter(fe),K.meta.delimiter=P.delimiter):((he=((J,Me,we,Ee,Re)=>{var ke,Pe,Ue,X;Re=Re||[","," ","|",";",c.RECORD_SEP,c.UNIT_SEP];for(var se=0;se<Re.length;se++){for(var me,Te=Re[se],de=0,ue=0,Ae=0,Ne=(Ue=void 0,new j({comments:Ee,delimiter:Te,newline:Me,preview:10}).parse(J)),Fe=0;Fe<Ne.data.length;Fe++)we&&ee(Ne.data[Fe])?Ae++:(me=Ne.data[Fe].length,ue+=me,Ue===void 0?Ue=me:0<me&&(de+=Math.abs(me-Ue),Ue=me));0<Ne.data.length&&(ue/=Ne.data.length-Ae),(Pe===void 0||de<=Pe)&&(X===void 0||X<ue)&&1.99<ue&&(Pe=de,ke=Te,X=ue)}return{successful:!!(P.delimiter=ke),bestDelimiter:ke}})(fe,P.newline,P.skipEmptyLines,P.comments,P.delimitersToGuess)).successful?P.delimiter=he.bestDelimiter:(I=!0,P.delimiter=c.DefaultDelimiter),K.meta.delimiter=P.delimiter),T(P));return P.preview&&P.header&&he.preview++,D=fe,M=new j(he),K=M.parse(D,re,ce),te(),H?{meta:{paused:!0}}:K||{meta:{paused:!1}}},this.paused=function(){return H},this.pause=function(){H=!0,M.abort(),D=A(P.chunk)?"":D.substring(M.getCharIndex())},this.resume=function(){V.streamer._halted?(H=!1,V.streamer.parseChunk(D,!0)):setTimeout(V.resume,3)},this.aborted=function(){return Q},this.abort=function(){Q=!0,M.abort(),K.meta.aborted=!0,A(P.complete)&&P.complete(K),D=""},this.guessLineEndings=function(J,he){J=J.substring(0,1048576);var he=new RegExp(_(he)+"([^]*?)"+_(he),"gm"),ce=(J=J.replace(he,"")).split("\r"),he=J.split(`
|
|
108
108
|
`),J=1<he.length&&he[0].length<ce[0].length;if(ce.length===1||J)return`
|
|
@@ -151,7 +151,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
151
151
|
L`+r+" "+r+`
|
|
152
152
|
L0 `+r+`
|
|
153
153
|
L`+r/2+` 0
|
|
154
|
-
`,fill:a,opacity:s,strokeWidth:f,stroke:c===void 0?"transparent":c,style:{pointerEvents:"none"}})})},"y");function oc(){return oc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oc.apply(null,arguments)}i(oc,"b");var Ci={translateX:0,translateY:0,padding:0,itemsSpacing:0,itemDirection:"left-to-right",justify:!1,symbolShape:"square",symbolSize:16,symbolSpacing:8},tqe={top:0,right:0,bottom:0,left:0},T3=i(function(e){var t,n=e.direction,r=e.itemsSpacing,a=e.padding,o=e.itemCount,s=e.itemWidth,l=e.itemHeight;if(typeof a!="number"&&(typeof(t=a)!="object"||Array.isArray(t)||t===null))throw new Error("Invalid property padding, must be one of: number, object");var f=typeof a=="number"?{top:a,right:a,bottom:a,left:a}:oc({},tqe,a),c=f.left+f.right,p=f.top+f.bottom,m=s+c,g=l+p,b=(o-1)*r;return n==="row"?m=s*o+b+c:n==="column"&&(g=l*o+b+p),{width:m,height:g,padding:f}},"A"),Wae=i(function(e){var t=e.anchor,n=e.translateX,r=e.translateY,a=e.containerWidth,o=e.containerHeight,s=e.width,l=e.height,f=n,c=r;switch(t){case"top":f+=(a-s)/2;break;case"top-right":f+=a-s;break;case"right":f+=a-s,c+=(o-l)/2;break;case"bottom-right":f+=a-s,c+=o-l;break;case"bottom":f+=(a-s)/2,c+=o-l;break;case"bottom-left":c+=o-l;break;case"left":c+=(o-l)/2;break;case"center":f+=(a-s)/2,c+=(o-l)/2}return{x:f,y:c}},"C"),Gae=i(function(e){var t,n,r,a,o,s,l=e.direction,f=e.justify,c=e.symbolSize,p=e.symbolSpacing,m=e.width,g=e.height;switch(l){case"left-to-right":t=0,n=(g-c)/2,a=g/2,s="central",f?(r=m,o="end"):(r=c+p,o="start");break;case"right-to-left":t=m-c,n=(g-c)/2,a=g/2,s="central",f?(r=0,o="start"):(r=m-c-p,o="end");break;case"top-to-bottom":t=(m-c)/2,n=0,r=m/2,o="middle",f?(a=g,s="alphabetic"):(a=c+p,s="text-before-edge");break;case"bottom-to-top":t=(m-c)/2,n=g-c,r=m/2,o="middle",f?(a=0,s="text-before-edge"):(a=g-c-p,s="alphabetic")}return{symbolX:t,symbolY:n,labelX:r,labelY:a,labelAnchor:o,labelAlignment:s}},"z"),nqe={circle:X9e,diamond:Z9e,square:J9e,triangle:eqe},rqe=i(function(e){var t,n,r,a,o,s,l,f,c,p,m,g=e.x,b=e.y,w=e.width,S=e.height,_=e.data,j=e.direction,E=j===void 0?Ci.itemDirection:j,O=e.justify,C=O===void 0?Ci.justify:O,T=e.textColor,R=e.background,A=R===void 0?"transparent":R,P=e.opacity,D=P===void 0?1:P,M=e.symbolShape,I=M===void 0?Ci.symbolShape:M,F=e.symbolSize,L=F===void 0?Ci.symbolSize:F,q=e.symbolSpacing,U=q===void 0?Ci.symbolSpacing:q,$=e.symbolBorderWidth,V=$===void 0?0:$,z=e.symbolBorderColor,W=z===void 0?"transparent":z,H=e.onClick,Q=e.onMouseEnter,Y=e.onMouseLeave,K=e.toggleSerie,ee=e.effects,te=y.useState({}),oe=te[0],ne=te[1],fe=Mr(),re=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on==="hover"})).reduce((function(me,Te){return oc({},me,Te.style)}),{});ne(se)}Q?.(_,X)}),[Q,_,ee]),ce=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on!=="hover"})).reduce((function(me,Te){return oc({},me,Te.style)}),{});ne(se)}Y?.(_,X)}),[Y,_,ee]),he=Gae({direction:E,justify:C,symbolSize:(t=oe.symbolSize)!=null?t:L,symbolSpacing:U,width:w,height:S}),J=he.symbolX,Me=he.symbolY,we=he.labelX,Ee=he.labelY,Re=he.labelAnchor,ke=he.labelAlignment,Pe=[H,Q,Y,K].some((function(X){return X!==void 0})),Ue=typeof I=="function"?I:nqe[I];return d.jsxs("g",{transform:"translate("+g+","+b+")",style:{opacity:(n=oe.itemOpacity)!=null?n:D},children:[d.jsx("rect",{width:w,height:S,fill:(r=oe.itemBackground)!=null?r:A,style:{cursor:Pe?"pointer":"auto"},onClick:i(function(X){H?.(_,X),K?.(_.id)},"onClick"),onMouseEnter:re,onMouseLeave:ce}),y.createElement(Ue,oc({id:_.id,x:J,y:Me,size:(a=oe.symbolSize)!=null?a:L,fill:(o=(s=_.fill)!=null?s:_.color)!=null?o:"black",borderWidth:(l=oe.symbolBorderWidth)!=null?l:V,borderColor:(f=oe.symbolBorderColor)!=null?f:W},_.hidden?fe.legends.hidden.symbol:void 0)),d.jsx(V_,{textAnchor:Re,style:oc({},fe.legends.text,{fill:(c=(p=(m=oe.itemTextColor)!=null?m:T)!=null?p:fe.legends.text.fill)!=null?c:"black",dominantBaseline:ke,pointerEvents:"none",userSelect:"none"},_.hidden?fe.legends.hidden.text:void 0),x:we,y:Ee,children:_.label})]})},"B"),aqe=i(function(e){var t=e.data,n=e.x,r=e.y,a=e.direction,o=e.padding,s=o===void 0?Ci.padding:o,l=e.justify,f=e.effects,c=e.itemWidth,p=e.itemHeight,m=e.itemDirection,g=m===void 0?Ci.itemDirection:m,b=e.itemsSpacing,w=b===void 0?Ci.itemsSpacing:b,S=e.itemTextColor,_=e.itemBackground,j=_===void 0?"transparent":_,E=e.itemOpacity,O=E===void 0?1:E,C=e.symbolShape,T=e.symbolSize,R=e.symbolSpacing,A=e.symbolBorderWidth,P=e.symbolBorderColor,D=e.onClick,M=e.onMouseEnter,I=e.onMouseLeave,F=e.toggleSerie,L=T3({itemCount:t.length,itemWidth:c,itemHeight:p,itemsSpacing:w,direction:a,padding:s}).padding,q=a==="row"?c+w:0,U=a==="column"?p+w:0;return d.jsx("g",{transform:"translate("+n+","+r+")",children:t.map((function($,V){return d.jsx(rqe,{data:$,x:V*q+L.left,y:V*U+L.top,width:c,height:p,direction:g,justify:l,effects:f,textColor:S,background:j,opacity:O,symbolShape:C,symbolSize:T,symbolSpacing:R,symbolBorderWidth:A,symbolBorderColor:P,onClick:D,onMouseEnter:M,onMouseLeave:I,toggleSerie:F},V)}))})},"H"),iqe=i(function(e){var t=e.data,n=e.containerWidth,r=e.containerHeight,a=e.translateX,o=a===void 0?Ci.translateX:a,s=e.translateY,l=s===void 0?Ci.translateY:s,f=e.anchor,c=e.direction,p=e.padding,m=p===void 0?Ci.padding:p,g=e.justify,b=e.itemsSpacing,w=b===void 0?Ci.itemsSpacing:b,S=e.itemWidth,_=e.itemHeight,j=e.itemDirection,E=e.itemTextColor,O=e.itemBackground,C=e.itemOpacity,T=e.symbolShape,R=e.symbolSize,A=e.symbolSpacing,P=e.symbolBorderWidth,D=e.symbolBorderColor,M=e.onClick,I=e.onMouseEnter,F=e.onMouseLeave,L=e.toggleSerie,q=e.effects,U=T3({itemCount:t.length,itemsSpacing:w,itemWidth:S,itemHeight:_,direction:c,padding:m}),$=U.width,V=U.height,z=Wae({anchor:f,translateX:o,translateY:l,containerWidth:n,containerHeight:r,width:$,height:V}),W=z.x,H=z.y;return d.jsx(aqe,{data:t,x:W,y:H,direction:c,padding:m,justify:g,effects:q,itemsSpacing:w,itemWidth:S,itemHeight:_,itemDirection:j,itemTextColor:E,itemBackground:O,itemOpacity:C,symbolShape:T,symbolSize:R,symbolSpacing:A,symbolBorderWidth:P,symbolBorderColor:D,onClick:M,onMouseEnter:I,onMouseLeave:F,toggleSerie:typeof L=="boolean"?void 0:L})},"E"),oqe={start:"left",middle:"center",end:"right"},sqe=i(function(e,t){var n=t.data,r=t.containerWidth,a=t.containerHeight,o=t.translateX,s=o===void 0?0:o,l=t.translateY,f=l===void 0?0:l,c=t.anchor,p=t.direction,m=t.padding,g=m===void 0?0:m,b=t.justify,w=b!==void 0&&b,S=t.itemsSpacing,_=S===void 0?0:S,j=t.itemWidth,E=t.itemHeight,O=t.itemDirection,C=O===void 0?"left-to-right":O,T=t.itemTextColor,R=t.symbolSize,A=R===void 0?16:R,P=t.symbolSpacing,D=P===void 0?8:P,M=t.theme,I=T3({itemCount:n.length,itemWidth:j,itemHeight:E,itemsSpacing:_,direction:p,padding:g}),F=I.width,L=I.height,q=I.padding,U=Wae({anchor:c,translateX:s,translateY:f,containerWidth:r,containerHeight:a,width:F,height:L}),$=U.x,V=U.y,z=p==="row"?j+_:0,W=p==="column"?E+_:0;e.save(),e.translate($,V),Ig(e,M.legends.text),n.forEach((function(H,Q){var Y,K=Q*z+q.left,ee=Q*W+q.top,te=Gae({direction:C,justify:w,symbolSize:A,symbolSpacing:D,width:j,height:E}),oe=te.symbolX,ne=te.symbolY,fe=te.labelX,re=te.labelY,ce=te.labelAnchor,he=te.labelAlignment;e.fillStyle=(Y=H.color)!=null?Y:"black",e.fillRect(K+oe,ee+ne,A,A),e.textAlign=oqe[ce],he==="central"&&(e.textBaseline="middle"),Fg(e,oc({},M.legends.text,{fill:T??M.legends.text.fill}),String(H.label),K+fe,ee+re)})),e.restore()},"L"),lqe=i(function(e,t,n,r,a,o){o>0?(e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()):e.rect(t,n,r,a)},"o");function vn(){return vn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vn.apply(null,arguments)}i(vn,"Q");function Fc(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}i(Fc,"U");var hW,cqe=i(function(e){var t=e.bars,n=e.annotations,r=Uae({data:t,annotations:n,getPosition:i(function(a){return{x:a.x+a.width/2,y:a.y+a.height/2}},"getPosition"),getDimensions:i(function(a){var o=a.height,s=a.width;return{width:s,height:o,size:Math.max(s,o)}},"getDimensions")});return d.jsx(d.Fragment,{children:r.map((function(a,o){return d.jsx(D9e,vn({},a),o)}))})},"$"),uqe=i(function(e){var t=e.width,n=e.height,r=e.legends,a=e.toggleSerie;return d.jsx(d.Fragment,{children:r.map((function(o,s){var l,f=o[0],c=o[1];return d.jsx(iqe,vn({},f,{containerWidth:t,containerHeight:n,data:(l=f.data)!=null?l:c,toggleSerie:f.toggleSerie&&f.dataFrom==="keys"?a:void 0}),s)}))})},"ee"),dqe=["data"],fqe=i(function(e){var t,n=e.bar,r=n.data,a=Fc(n,dqe),o=e.style,s=o.borderColor,l=o.color,f=o.height,c=o.labelColor,p=o.labelOpacity,m=o.labelX,g=o.labelY,b=o.transform,w=o.width,S=o.textAnchor,_=e.borderRadius,j=e.borderWidth,E=e.label,O=e.shouldRenderLabel,C=e.isInteractive,T=e.onClick,R=e.onMouseEnter,A=e.onMouseLeave,P=e.tooltip,D=e.isFocusable,M=e.ariaLabel,I=e.ariaLabelledBy,F=e.ariaDescribedBy,L=e.ariaDisabled,q=e.ariaHidden,U=Mr(),$=wre(),V=$.showTooltipFromEvent,z=$.showTooltipAt,W=$.hideTooltip,H=y.useMemo((function(){return function(){return y.createElement(P,vn({},a,r))}}),[P,a,r]),Q=y.useCallback((function(ne){T?.(vn({color:a.color},r),ne)}),[a,r,T]),Y=y.useCallback((function(ne){return V(H(),ne)}),[V,H]),K=y.useCallback((function(ne){R?.(r,ne),V(H(),ne)}),[r,R,V,H]),ee=y.useCallback((function(ne){A?.(r,ne),W()}),[r,W,A]),te=y.useCallback((function(){z(H(),[a.absX+a.width/2,a.absY])}),[z,H,a]),oe=y.useCallback((function(){W()}),[W]);return d.jsxs(pr.g,{transform:b,children:[d.jsx(pr.rect,{width:UN(w,(function(ne){return Math.max(ne,0)})),height:UN(f,(function(ne){return Math.max(ne,0)})),rx:_,ry:_,fill:(t=r.fill)!=null?t:l,strokeWidth:j,stroke:s,focusable:D,tabIndex:D?0:void 0,"aria-label":M?M(r):void 0,"aria-labelledby":I?I(r):void 0,"aria-describedby":F?F(r):void 0,"aria-disabled":L?L(r):void 0,"aria-hidden":q?q(r):void 0,onMouseEnter:C?K:void 0,onMouseMove:C?Y:void 0,onMouseLeave:C?ee:void 0,onClick:C?Q:void 0,onFocus:C&&D?te:void 0,onBlur:C&&D?oe:void 0,"data-testid":"bar.item."+r.id+"."+r.index}),O&&d.jsx(V_,{x:m,y:g,textAnchor:S,dominantBaseline:"central",fillOpacity:p,style:vn({},U.labels.text,{pointerEvents:"none",fill:c}),children:E})]})},"ae"),hqe=["color","label"],pqe=i(function(e){var t=e.color,n=e.label,r=Fc(e,hqe);return d.jsx(D8e,{id:n,value:r.formattedValue,enableChip:!0,color:t})},"ne"),Fn={indexBy:"id",keys:["value"],groupMode:"stacked",layout:"vertical",valueScale:{type:"linear",nice:!0,round:!1},indexScale:{type:"band",round:!1},padding:.1,innerPadding:0,enableGridX:!1,enableGridY:!0,enableLabel:!0,label:"formattedValue",labelPosition:"middle",labelOffset:0,labelSkipWidth:0,labelSkipHeight:0,labelTextColor:{theme:"labels.text.fill"},colorBy:"id",colors:{scheme:"nivo"},borderRadius:0,borderWidth:0,borderColor:{from:"color"},isInteractive:!0,tooltip:pqe,tooltipLabel:i(function(e){return e.id+" - "+e.indexValue},"tooltipLabel"),legends:[],initialHiddenIds:[],annotations:[],enableTotals:!1,totalsOffset:10},In=vn({},Fn,{layers:["grid","axes","bars","totals","markers","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},barComponent:fqe,defs:[],fill:[],markers:[],animate:!0,animateOnMount:!1,motionConfig:"default",role:"img",isFocusable:!1}),gr=vn({},Fn,{layers:["grid","axes","bars","totals","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},renderBar:i(function(e,t){var n=t.bar,r=n.color,a=n.height,o=n.width,s=n.x,l=n.y,f=t.borderColor,c=t.borderRadius,p=t.borderWidth,m=t.label,g=t.shouldRenderLabel,b=t.labelStyle,w=t.labelX,S=t.labelY,_=t.textAnchor;e.fillStyle=r,p>0&&(e.strokeStyle=f,e.lineWidth=p),e.beginPath(),lqe(e,s,l,o,a,Math.min(c,a)),e.fill(),p>0&&e.stroke(),g&&(e.textBaseline="middle",e.textAlign=_==="middle"?"center":_,Fg(e,b,m,s+w,l+S))},"renderBar"),pixelRatio:typeof window<"u"&&(hW=window.devicePixelRatio)!=null?hW:1}),Kae=i(function(e,t,n,r,a,o){return A3(r,{all:e.map(t),min:0,max:0},a,o).padding(n)},"de"),Yae=i(function(e,t){return e.map((function(n){return vn({},t.reduce((function(r,a){return r[a]=null,r}),{}),n)}))},"ue"),H_=i(function(e){return Object.keys(e).reduce((function(t,n){return e[n]&&(t[n]=e[n]),t}),{})},"se"),W_=i(function(e){return[e,Number(e)]},"ce");function Qae(e,t,n,r){return e===void 0&&(e=Fn.layout),n===void 0&&(n=Fn.labelPosition),r===void 0&&(r=Fn.labelOffset),function(a,o){var s=r*(t?-1:1);if(e==="horizontal"){var l=a/2;return n==="start"?l=t?a:0:n==="end"&&(l=t?0:a),{labelX:l+s,labelY:o/2,textAnchor:n==="middle"?"middle":t?"end":"start"}}var f=o/2;return n==="start"?f=t?0:o:n==="end"&&(f=t?o:0),{labelX:a/2,labelY:f-s,textAnchor:"middle"}}}i(Qae,"he");var mqe=["layout","width","height","padding","innerPadding","valueScale","indexScale","hiddenIds"],P3=i(function(e,t){return e>t},"be"),Xae=i(function(e,t){return e<t},"ge"),Zae=i(function(e,t){return Array.from(" ".repeat(t-e),(function(n,r){return e+r}))},"ve"),vqe=i(function(e){return P3(e,0)?0:e},"me"),gqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getColor,l=e.getIndex,f=e.getTooltipLabel,c=e.innerPadding,p=c===void 0?0:c,m=e.keys,g=e.xScale,b=e.yScale,w=e.margin,S=n?Xae:P3,_=a.map(H_),j=[];return m.forEach((function(E,O){return Zae(0,g.domain().length).forEach((function(C){var T,R,A,P=W_(a[C][E]),D=P[0],M=P[1],I=l(a[C]),F=((T=g(I))!=null?T:0)+t*O+p*O,L=S(R=M,0)?(A=b(R))!=null?A:0:r,q=(function($,V){var z;return S($,0)?r-V:((z=b($))!=null?z:0)-r})(M,L),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:t,height:q,color:s(U),label:f(U)})}))})),j},"pe"),yqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getIndex,l=e.getColor,f=e.getTooltipLabel,c=e.keys,p=e.innerPadding,m=p===void 0?0:p,g=e.xScale,b=e.yScale,w=e.margin,S=n?Xae:P3,_=a.map(H_),j=[];return c.forEach((function(E,O){return Zae(0,b.domain().length).forEach((function(C){var T,R,A,P=W_(a[C][E]),D=P[0],M=P[1],I=s(a[C]),F=S(R=M,0)?r:(A=g(R))!=null?A:0,L=((T=b(I))!=null?T:0)+t*O+m*O,q=(function($,V){var z;return S($,0)?((z=g($))!=null?z:0)-r:r-V})(M,F),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:q,height:t,color:l(U),label:f(U)})}))})),j},"ye"),bqe=i(function(e){var t,n,r,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.innerPadding,p=c===void 0?0:c,m=e.valueScale,g=e.indexScale,b=e.hiddenIds,w=b===void 0?[]:b,S=Fc(e,mqe),_=S.keys.filter((function(V){return!w.includes(V)})),j=Yae(S.data,_),E=a==="vertical"?["y","x",o]:["x","y",s],O=E[0],C=E[1],T=E[2],R=Kae(j,S.getIndex,f,g,T,C),A=m.min==="auto"?vqe:function(V){return V},P=j.reduce((function(V,z){return[].concat(V,_.map((function(W){return z[W]})))}),[]).filter(Boolean),D=A(Math.min.apply(Math,P)),M=(r=Math.max.apply(Math,P),isFinite(r)?r:0),I=A3(m,{all:P,min:D,max:M},O==="x"?o:s,O),F=a==="vertical"?[R,I]:[I,R],L=F[0],q=F[1],U=(R.bandwidth()-p*(_.length-1))/_.length,$=[vn({},S,{data:j,keys:_,innerPadding:p,xScale:L,yScale:q}),U,(t=m.reverse)!=null&&t,(n=I(0))!=null?n:0];return{xScale:L,yScale:q,bars:U>0?a==="vertical"?gqe.apply(void 0,$):yqe.apply(void 0,$):[]}},"xe"),xqe=["data","layout","width","height","padding","valueScale","indexScale","hiddenIds"],Jae=i(function(e){var t;return e.some(Array.isArray)?Jae((t=[]).concat.apply(t,e)):e},"ke"),wqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,g=[];return f.forEach((function(b){return c.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=c(o(E.data)))!=null?_:0,C=((j=(function(M){return p(M[n?0:1])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=p(M[n?1:0]))!=null?F:0)-I})(E,C)-l,R=W_(E.data[b.key]),A=R[0],P=R[1],D={id:b.key,value:A===null?A:P,formattedValue:r(P),hidden:!1,index:S,indexValue:w,data:H_(E.data)};g.push({key:b.key+"."+w,index:g.length,data:D,x:O,y:C,absX:m.left+O,absY:m.top+C,width:t,height:T,color:a(D),label:s(D)})}))})),g},"we"),_qe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,g=[];return f.forEach((function(b){return p.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=p(o(E.data)))!=null?_:0,C=((j=(function(M){return c(M[n?1:0])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=c(M[n?0:1]))!=null?F:0)-I})(E,C)-l,R=W_(E.data[b.key]),A=R[0],P=R[1],D={id:b.key,value:A===null?A:P,formattedValue:r(P),hidden:!1,index:S,indexValue:w,data:H_(E.data)};g.push({key:b.key+"."+w,index:g.length,data:D,x:C,y:O,absX:m.left+C,absY:m.top+O,width:T,height:t,color:a(D),label:s(D)})}))})),g},"Le"),Sqe=i(function(e){var t,n,r=e.data,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.valueScale,p=e.indexScale,m=e.hiddenIds,g=m===void 0?[]:m,b=Fc(e,xqe),w=b.keys.filter((function(U){return!g.includes(U)})),S=GIe().keys(w).offset(KIe)(Yae(r,w)),_=a==="vertical"?["y","x",o]:["x","y",s],j=_[0],E=_[1],O=_[2],C=Kae(r,b.getIndex,f,p,O,E),T=(n=Jae(S),c.type==="log"?n.filter((function(U){return U!==0})):n),R=Math.min.apply(Math,T),A=Math.max.apply(Math,T),P=A3(c,{all:T,min:R,max:A},j==="x"?o:s,j),D=a==="vertical"?[C,P]:[P,C],M=D[0],I=D[1],F=b.innerPadding>0?b.innerPadding:0,L=C.bandwidth(),q=[vn({},b,{innerPadding:F,stackedData:S,xScale:M,yScale:I}),L,(t=c.reverse)!=null&&t];return{xScale:M,yScale:I,bars:L>0?a==="vertical"?wqe.apply(void 0,q):_qe.apply(void 0,q):[]}},"Ce"),jqe=i(function(e){var t=e.bars,n=e.direction,r=e.from,a=e.groupMode,o=e.layout,s=e.legendLabel,l=e.reverse,f=Pae(s??(r==="indexes"?"indexValue":"id"));return r==="indexes"?(function(c,p,m){var g=qH(c.map((function(b){var w,S;return{id:(w=b.data.indexValue)!=null?w:"",label:m(b.data),hidden:b.data.hidden,color:(S=b.color)!=null?S:"#000"}})),(function(b){return b.id}));return p==="horizontal"&&g.reverse(),g})(t,o,f):(function(c,p,m,g,b,w){var S=qH(c.map((function(_){var j;return{id:_.data.id,label:w(_.data),hidden:_.data.hidden,color:(j=_.color)!=null?j:"#000"}})),(function(_){return _.id}));return(p==="vertical"&&g==="stacked"&&m==="column"&&b!==!0||p==="horizontal"&&g==="stacked"&&b===!0)&&S.reverse(),S})(t,o,n,a,l,f)},"We"),pW=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+n)},"Me"),Eqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+(n>0?n:0))},"Be"),Cqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,Math.max(r,Number(n)))},"Re"),Oqe=i(function(e,t){var n=e.get(t)||0;e.set(t,n+1)},"Oe"),eie=i(function(e){var t,n=e.indexBy,r=n===void 0?Fn.indexBy:n,a=e.keys,o=a===void 0?Fn.keys:a,s=e.label,l=s===void 0?Fn.label:s,f=e.tooltipLabel,c=f===void 0?Fn.tooltipLabel:f,p=e.valueFormat,m=e.colors,g=m===void 0?Fn.colors:m,b=e.colorBy,w=b===void 0?Fn.colorBy:b,S=e.borderColor,_=S===void 0?Fn.borderColor:S,j=e.labelTextColor,E=j===void 0?Fn.labelTextColor:j,O=e.groupMode,C=O===void 0?Fn.groupMode:O,T=e.layout,R=T===void 0?Fn.layout:T,A=e.data,P=e.margin,D=e.width,M=e.height,I=e.padding,F=I===void 0?Fn.padding:I,L=e.innerPadding,q=L===void 0?Fn.innerPadding:L,U=e.valueScale,$=U===void 0?Fn.valueScale:U,V=e.indexScale,z=V===void 0?Fn.indexScale:V,W=e.initialHiddenIds,H=W===void 0?Fn.initialHiddenIds:W,Q=e.enableLabel,Y=Q===void 0?Fn.enableLabel:Q,K=e.labelSkipWidth,ee=K===void 0?Fn.labelSkipWidth:K,te=e.labelSkipHeight,oe=te===void 0?Fn.labelSkipHeight:te,ne=e.legends,fe=ne===void 0?Fn.legends:ne,re=e.legendLabel,ce=e.totalsOffset,he=ce===void 0?Fn.totalsOffset:ce,J=y.useState(H??[]),Me=J[0],we=J[1],Ee=y.useCallback((function(Ke){we((function(pt){return pt.indexOf(Ke)>-1?pt.filter((function(ge){return ge!==Ke})):[].concat(pt,[Ke])}))}),[]),Re=zA(r),ke=zA(l),Pe=zA(c),Ue=R3(p),X=Mr(),se=Q9e(g,w),me=fW(_,X),Te=fW(E,X),de=(C==="grouped"?bqe:Sqe)({layout:R,data:A,getIndex:Re,keys:o,width:D,height:M,getColor:se,padding:F,innerPadding:q,valueScale:$,indexScale:z,hiddenIds:Me,formatValue:Ue,getTooltipLabel:Pe,margin:P}),ue=de.bars,Ae=de.xScale,Ne=de.yScale,Fe=y.useMemo((function(){return ue.filter((function(Ke){return Ke.data.value!==null})).map((function(Ke,pt){return vn({},Ke,{index:pt})}))}),[ue]),Je=y.useCallback((function(Ke){var pt=Ke.width,ge=Ke.height;return!!Y&&!(ee>0&&pt<ee)&&!(oe>0&&ge<oe)}),[Y,ee,oe]),Pt=y.useMemo((function(){return o.map((function(Ke){var pt=ue.find((function(ge){return ge.data.id===Ke}));return vn({},pt,{data:vn({id:Ke},pt?.data,{hidden:Me.includes(Ke)})})}))}),[Me,o,ue]),$t=(t=$.reverse)!=null&&t,Rt=y.useMemo((function(){return fe.map((function(Ke){return[Ke,jqe({bars:Ke.dataFrom==="keys"?Pt:ue,direction:Ke.direction,from:Ke.dataFrom,groupMode:C,layout:R,legendLabel:re,reverse:$t})]}))}),[fe,Pt,ue,C,R,re,$t]),qt=y.useMemo((function(){return(function(Ke,pt,ge,ye,ct,Le,Xe){ye===void 0&&(ye=Fn.layout),ct===void 0&&(ct=Fn.groupMode);var We=[];if(Ke.length===0)return We;var et=new Map,jt=Ke[0].width,Ye=Ke[0].height;if(ct==="stacked"){var mt=new Map;Ke.forEach((function(At){var _t=At.data,vt=_t.indexValue,Ct=_t.value;pW(et,vt,Number(Ct)),Eqe(mt,vt,Number(Ct))})),mt.forEach((function(At,_t){var vt,Ct,Z,pe=et.get(_t)||0;ye==="vertical"?(vt=pt(_t),Ct=ge(At),Z=ge(At/2)):(vt=pt(At),Ct=ge(_t),Z=pt(At/2)),vt+=ye==="vertical"?jt/2:Le,Ct+=ye==="vertical"?-Le:Ye/2,We.push({key:"total_"+_t,x:vt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}else if(ct==="grouped"){var Ft=new Map,Nt=new Map;Ke.forEach((function(At){var _t=At.data,vt=_t.indexValue,Ct=_t.value;pW(et,vt,Number(Ct)),Cqe(Ft,vt,Number(Ct)),Oqe(Nt,vt)})),Ft.forEach((function(At,_t){var vt,Ct,Z,pe=et.get(_t)||0,_e=Nt.get(_t);ye==="vertical"?(vt=pt(_t),Ct=ge(At),Z=ge(At/2)):(vt=pt(At),Ct=ge(_t),Z=pt(At/2)),vt+=ye==="vertical"?_e*jt/2:Le,Ct+=ye==="vertical"?-Le:_e*Ye/2,We.push({key:"total_"+_t,x:vt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}return We})(ue,Ae,Ne,R,C,he,Ue)}),[ue,Ae,Ne,R,C,he,Ue]);return{bars:ue,barsWithValue:Fe,xScale:Ae,yScale:Ne,getIndex:Re,getLabel:ke,getTooltipLabel:Pe,formatValue:Ue,getColor:se,getBorderColor:me,getLabelColor:Te,shouldRenderBarLabel:Je,hiddenIds:Me,toggleSerie:Ee,legendsWithData:Rt,barTotals:qt}},"Ie"),kqe=i(function(e){var t=e.data,n=e.springConfig,r=e.animate,a=e.layout,o=a===void 0?In.layout:a,s=Mr();return o_(t,{keys:i(function(l){return l.key},"keys"),from:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"from"),enter:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"enter"),update:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"update"),leave:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"leave"),config:n,immediate:!r,initial:r?void 0:null})((function(l,f){return d.jsx(pr.text,{x:l.x,y:l.y,fillOpacity:l.labelOpacity,style:vn({},s.labels.text,{pointerEvents:"none"}),fontWeight:"bold",fontSize:s.labels.text.fontSize,fontFamily:s.labels.text.fontFamily,textAnchor:o==="vertical"?"middle":"start",alignmentBaseline:o==="vertical"?"alphabetic":"middle",children:f.formattedValue},f.key)}))},"Ve"),Rqe=["isInteractive","animate","motionConfig","theme","renderWrapper"],Aqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,g=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?In.axisBottom:_,E=e.axisLeft,O=E===void 0?In.axisLeft:E,C=e.enableGridX,T=C===void 0?In.enableGridX:C,R=e.enableGridY,A=R===void 0?In.enableGridY:R,P=e.gridXValues,D=e.gridYValues,M=e.layers,I=M===void 0?In.layers:M,F=e.barComponent,L=F===void 0?In.barComponent:F,q=e.enableLabel,U=q===void 0?In.enableLabel:q,$=e.label,V=e.labelSkipWidth,z=V===void 0?In.labelSkipWidth:V,W=e.labelSkipHeight,H=W===void 0?In.labelSkipHeight:W,Q=e.labelTextColor,Y=e.labelPosition,K=Y===void 0?In.labelPosition:Y,ee=e.labelOffset,te=ee===void 0?In.labelOffset:ee,oe=e.markers,ne=oe===void 0?In.markers:oe,fe=e.colorBy,re=e.colors,ce=e.defs,he=ce===void 0?In.defs:ce,J=e.fill,Me=J===void 0?In.fill:J,we=e.borderRadius,Ee=we===void 0?In.borderRadius:we,Re=e.borderWidth,ke=Re===void 0?In.borderWidth:Re,Pe=e.borderColor,Ue=e.annotations,X=Ue===void 0?In.annotations:Ue,se=e.legendLabel,me=e.tooltipLabel,Te=e.valueFormat,de=e.isInteractive,ue=de===void 0?In.isInteractive:de,Ae=e.tooltip,Ne=Ae===void 0?In.tooltip:Ae,Fe=e.onClick,Je=e.onMouseEnter,Pt=e.onMouseLeave,$t=e.legends,Rt=e.role,qt=Rt===void 0?In.role:Rt,Ke=e.ariaLabel,pt=e.ariaLabelledBy,ge=e.ariaDescribedBy,ye=e.isFocusable,ct=ye===void 0?In.isFocusable:ye,Le=e.barAriaLabel,Xe=e.barAriaLabelledBy,We=e.barAriaDescribedBy,et=e.barAriaHidden,jt=e.barAriaDisabled,Ye=e.initialHiddenIds,mt=e.enableTotals,Ft=mt===void 0?In.enableTotals:mt,Nt=e.totalsOffset,At=Nt===void 0?In.totalsOffset:Nt,_t=e.forwardedRef,vt=ho(),Ct=vt.animate,Z=vt.config,pe=Tae(s,l,o),_e=pe.outerWidth,$e=pe.outerHeight,Ve=pe.margin,rt=pe.innerWidth,nt=pe.innerHeight,Qe=eie({indexBy:r,label:$,tooltipLabel:me,valueFormat:Te,colors:re,colorBy:fe,borderColor:Pe,labelTextColor:Q,groupMode:f,layout:c,data:n,keys:a,margin:Ve,width:rt,height:nt,padding:g,innerPadding:b,valueScale:p,indexScale:m,enableLabel:U,labelSkipWidth:z,labelSkipHeight:H,legends:$t,legendLabel:se,initialHiddenIds:Ye,totalsOffset:At}),ot=Qe.bars,ut=Qe.barsWithValue,st=Qe.xScale,lt=Qe.yScale,gt=Qe.getLabel,at=Qe.getTooltipLabel,kt=Qe.getBorderColor,bt=Qe.getLabelColor,Lt=Qe.shouldRenderBarLabel,Mt=Qe.toggleSerie,Fr=Qe.legendsWithData,Oa=Qe.barTotals,li=Qe.getColor,cr=Qae(c,(t=p?.reverse)!=null&&t,K,te),po=o_(ut,{keys:i(function(He){return He.key},"keys"),from:i(function(He){return vn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},cr(He.width,He.height),{transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:{height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0})},"from"),enter:i(function(He){return vn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},cr(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"enter"),update:i(function(He){return vn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},cr(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"update"),leave:i(function(He){return vn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},cr(He.width,He.height),{labelY:0,transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:vn({},cr(He.width,He.height),{labelX:0,height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0}))},"leave"),config:Z,immediate:!Ct,initial:Ct?void 0:null}),Lr=y.useMemo((function(){return{borderRadius:Ee,borderWidth:ke,enableLabel:U,isInteractive:ue,labelSkipWidth:z,labelSkipHeight:H,onClick:Fe,onMouseEnter:Je,onMouseLeave:Pt,getTooltipLabel:at,tooltip:Ne,isFocusable:ct,ariaLabel:Le,ariaLabelledBy:Xe,ariaDescribedBy:We,ariaHidden:et,ariaDisabled:jt}}),[Ee,ke,U,at,ue,H,z,Fe,Je,Pt,Ne,ct,Le,Xe,We,et,jt]),Ha=O7e(he,ot,Me,{dataKey:"data",targetKey:"data.fill"}),Zr={annotations:null,axes:null,bars:null,grid:null,legends:null,markers:null,totals:null};I.includes("annotations")&&(Zr.annotations=d.jsx(cqe,{bars:ot,annotations:X},"annotations")),I.includes("axes")&&(Zr.axes=d.jsx(s9e,{xScale:st,yScale:lt,width:rt,height:nt,top:w,right:S,bottom:j,left:O},"axes")),I.includes("bars")&&(Zr.bars=d.jsx(y.Fragment,{children:po((function(He,$n){return y.createElement(L,vn({},Lr,{bar:$n,style:He,shouldRenderLabel:Lt($n),label:gt($n.data)}))}))},"bars")),I.includes("grid")&&(Zr.grid=d.jsx(c9e,{width:rt,height:nt,xScale:T?st:null,yScale:A?lt:null,xValues:P,yValues:D},"grid")),I.includes("legends")&&(Zr.legends=d.jsx(uqe,{width:rt,height:nt,legends:Fr,toggleSerie:Mt},"legends")),I.includes("markers")&&(Zr.markers=d.jsx(g7e,{markers:ne,width:rt,height:nt,xScale:st,yScale:lt},"markers")),I.includes("totals")&&Ft&&(Zr.totals=d.jsx(kqe,{data:Oa,springConfig:Z,animate:Ct,layout:c},"totals"));var Wa=vn({},Lr,{margin:Ve,width:s,height:l,innerWidth:rt,innerHeight:nt,bars:ot,legendData:Fr,enableLabel:U,xScale:st,yScale:lt,tooltip:Ne,getTooltipLabel:at,onClick:Fe,onMouseEnter:Je,onMouseLeave:Pt,getColor:li});return d.jsx(p7e,{width:_e,height:$e,margin:Ve,defs:Ha,role:qt,ariaLabel:Ke,ariaLabelledBy:pt,ariaDescribedBy:ge,isFocusable:ct,ref:_t,children:I.map((function(He,$n){var Ii;return typeof He=="function"?d.jsx(y.Fragment,{children:y.createElement(He,Wa)},$n):(Ii=Zr?.[He])!=null?Ii:null}))})},"He"),Tqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=n===void 0?In.isInteractive:n,a=e.animate,o=a===void 0?In.animate:a,s=e.motionConfig,l=s===void 0?In.motionConfig:s,f=e.theme,c=e.renderWrapper,p=Fc(e,Rqe);return d.jsx(Cae,{animate:o,isInteractive:r,motionConfig:l,renderWrapper:c,theme:f,children:d.jsx(Aqe,vn({},p,{isInteractive:r,forwardedRef:t}))})})),Pqe=["isInteractive","renderWrapper","theme"],dT=i(function(e,t,n,r){return e.find((function(a){return S7e(a.x+t.left,a.y+t.top,a.width,a.height,n,r)}))},"Fe"),Nqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,g=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?gr.axisBottom:_,E=e.axisLeft,O=E===void 0?gr.axisLeft:E,C=e.enableGridX,T=C===void 0?gr.enableGridX:C,R=e.enableGridY,A=R===void 0?gr.enableGridY:R,P=e.gridXValues,D=e.gridYValues,M=e.labelPosition,I=M===void 0?gr.labelPosition:M,F=e.labelOffset,L=F===void 0?gr.labelOffset:F,q=e.layers,U=q===void 0?gr.layers:q,$=e.renderBar,V=$===void 0?gr.renderBar:$,z=e.enableLabel,W=z===void 0?gr.enableLabel:z,H=e.label,Q=e.labelSkipWidth,Y=Q===void 0?gr.labelSkipWidth:Q,K=e.labelSkipHeight,ee=K===void 0?gr.labelSkipHeight:K,te=e.labelTextColor,oe=e.colorBy,ne=e.colors,fe=e.borderRadius,re=fe===void 0?gr.borderRadius:fe,ce=e.borderWidth,he=ce===void 0?gr.borderWidth:ce,J=e.borderColor,Me=e.annotations,we=Me===void 0?gr.annotations:Me,Ee=e.legendLabel,Re=e.tooltipLabel,ke=e.valueFormat,Pe=e.isInteractive,Ue=Pe===void 0?gr.isInteractive:Pe,X=e.tooltip,se=X===void 0?gr.tooltip:X,me=e.onClick,Te=e.onMouseEnter,de=e.onMouseLeave,ue=e.legends,Ae=e.pixelRatio,Ne=Ae===void 0?gr.pixelRatio:Ae,Fe=e.role,Je=e.forwardedRef,Pt=e.enableTotals,$t=Pt===void 0?gr.enableTotals:Pt,Rt=e.totalsOffset,qt=Rt===void 0?gr.totalsOffset:Rt,Ke=y.useRef(null),pt=Mr(),ge=Tae(s,l,o),ye=ge.margin,ct=ge.innerWidth,Le=ge.innerHeight,Xe=ge.outerWidth,We=ge.outerHeight,et=eie({indexBy:r,label:H,tooltipLabel:Re,valueFormat:ke,colors:ne,colorBy:oe,borderColor:J,labelTextColor:te,groupMode:f,layout:c,data:n,keys:a,margin:ye,width:ct,height:Le,padding:g,innerPadding:b,valueScale:p,indexScale:m,enableLabel:W,labelSkipWidth:Y,labelSkipHeight:ee,legends:ue,legendLabel:Ee,totalsOffset:qt}),jt=et.bars,Ye=et.barsWithValue,mt=et.xScale,Ft=et.yScale,Nt=et.getLabel,At=et.getTooltipLabel,_t=et.getBorderColor,vt=et.getLabelColor,Ct=et.shouldRenderBarLabel,Z=et.legendsWithData,pe=et.barTotals,_e=et.getColor,$e=wre(),Ve=$e.showTooltipFromEvent,rt=$e.hideTooltip,nt=k9e({annotations:Uae({data:jt,annotations:we,getPosition:i(function(at){return{x:at.x,y:at.y}},"getPosition"),getDimensions:i(function(at){var kt=at.width,bt=at.height;return{width:kt,height:bt,size:Math.max(kt,bt)}},"getDimensions")})}),Qe=y.useMemo((function(){return{borderRadius:re,borderWidth:he,isInteractive:Ue,isFocusable:!1,labelSkipWidth:Y,labelSkipHeight:ee,margin:ye,width:s,height:l,innerWidth:ct,innerHeight:Le,bars:jt,legendData:Z,enableLabel:W,xScale:mt,yScale:Ft,tooltip:se,getTooltipLabel:At,onClick:me,onMouseEnter:Te,onMouseLeave:de,getColor:_e}}),[re,he,Ue,Y,ee,ye,s,l,ct,Le,jt,Z,W,mt,Ft,se,At,me,Te,de,_e]),ot=R3(ke),ut=Qae(c,(t=p?.reverse)!=null&&t,I,L);y.useEffect((function(){if(Ke.current){Ke.current.width=Xe*Ne,Ke.current.height=We*Ne;var at=Ke.current.getContext("2d");at.scale(Ne,Ne),at.fillStyle=pt.background,at.fillRect(0,0,Xe,We),at.translate(ye.left,ye.top),U.forEach((function(kt){kt==="grid"?typeof pt.grid.line.strokeWidth=="number"&&pt.grid.line.strokeWidth>0&&(at.lineWidth=pt.grid.line.strokeWidth,at.strokeStyle=pt.grid.line.stroke,T&&JH(at,{width:ct,height:Le,scale:mt,axis:"x",values:P}),A&&JH(at,{width:ct,height:Le,scale:Ft,axis:"y",values:D})):kt==="axes"?d9e(at,{xScale:mt,yScale:Ft,width:ct,height:Le,top:w,right:S,bottom:j,left:O,theme:pt}):kt==="bars"?(Ig(at,pt.text),Ye.forEach((function(bt){V(at,vn({bar:bt,borderColor:_t(bt),borderRadius:re,borderWidth:he,label:Nt(bt.data),shouldRenderLabel:Ct(bt),labelStyle:vn({},pt.labels.text,{fill:vt(bt)})},ut(bt.width,bt.height)))}))):kt==="legends"?Z.forEach((function(bt){var Lt=bt[0],Mt=bt[1];sqe(at,vn({},Lt,{data:Mt,containerWidth:ct,containerHeight:Le,theme:pt}))})):kt==="annotations"?M9e(at,{annotations:nt,theme:pt}):kt==="totals"&&$t?(function(bt,Lt,Mt,Fr){Fr===void 0&&(Fr=gr.layout),Ig(bt,Mt.labels.text),bt.textBaseline=Fr==="vertical"?"alphabetic":"middle",bt.textAlign=Fr==="vertical"?"center":"start",Lt.forEach((function(Oa){Fg(bt,Mt.labels.text,Oa.formattedValue,Oa.x,Oa.y)}))})(at,pe,pt,c):typeof kt=="function"&&kt(at,Qe)})),at.save()}}),[j,O,S,w,Ye,re,he,nt,T,A,_t,Nt,vt,P,D,f,l,Le,ct,Qe,U,c,Z,ye.left,ye.top,We,Xe,Ne,V,mt,Ft,Ct,pt,s,pe,$t,ot,ut]);var st=y.useCallback((function(at){if(jt&&Ke.current){var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt!==void 0?(Ve(y.createElement(se,vn({},Mt.data,{color:Mt.color,label:Mt.label,value:Number(Mt.data.value)})),at),at.type==="mouseenter"&&Te?.(Mt.data,at)):rt()}}),[rt,ye,Te,jt,Ve,se]),lt=y.useCallback((function(at){if(jt&&Ke.current){rt();var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt&&de?.(Mt.data,at)}}),[rt,ye,de,jt]),gt=y.useCallback((function(at){if(jt&&Ke.current){var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt!==void 0&&me?.(vn({},Mt.data,{color:Mt.color}),at)}}),[ye,me,jt]);return d.jsx("canvas",{ref:k7e(Ke,Je),width:Xe*Ne,height:We*Ne,style:{width:Xe,height:We,cursor:Ue?"auto":"normal"},onMouseEnter:Ue?st:void 0,onMouseMove:Ue?st:void 0,onMouseLeave:Ue?lt:void 0,onClick:Ue?gt:void 0,role:Fe})},"ze"),Dqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=e.renderWrapper,a=e.theme,o=Fc(e,Pqe);return d.jsx(Cae,{isInteractive:n,renderWrapper:r,theme:a,animate:!1,children:d.jsx(Nqe,vn({},o,{isInteractive:n,forwardedRef:t}))})})),Mqe=["defaultWidth","defaultHeight","onResize","debounceResize"],Iqe=y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=Fc(e,Mqe);return d.jsx(Oae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Tqe,vn({},s,{width:f,height:c,ref:t}))},"children")})})),Fqe=["defaultWidth","defaultHeight","onResize","debounceResize"];y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=Fc(e,Fqe);return d.jsx(Oae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Dqe,vn({},s,{width:f,height:c,ref:t}))},"children")})}));const Lqe={opportunity:.2,"proposal-sent":.5,"in-negociation":.8,delayed:.3},$qe=new Date(new Date().setMonth(new Date().getMonth()-6)).toISOString(),mW="en-US",qqe="USD",zqe=y.memo(()=>{const e=navigator?navigator.languages||[navigator.language]:[mW],{data:t,isPending:n}=za("deals",{pagination:{perPage:100,page:1},sort:{field:"created_at",order:"ASC"},filter:{"created_at@gte":$qe}}),r=y.useMemo(()=>{if(!t)return[];const o=t.reduce((l,f)=>{const c=lP(f.created_at??new Date).toISOString();return l[c]||(l[c]=[]),l[c].push(f),l},{});return Object.keys(o).map(l=>({date:cc(l,"MMM"),won:o[l].filter(f=>f.stage==="won").reduce((f,c)=>(f+=c.amount,f),0),pending:o[l].filter(f=>!["won","lost"].includes(f.stage)).reduce((f,c)=>(f+=c.amount*Lqe[c.stage],f),0),lost:o[l].filter(f=>f.stage==="lost").reduce((f,c)=>(f-=c.amount,f),0)}))},[t]);if(n)return null;const a=r.reduce((o,s)=>(o.min=Math.min(o.min,s.lost),o.max=Math.max(o.max,s.won+s.pending),o),{min:0,max:0});return d.jsxs("div",{className:"flex flex-col",children:[d.jsxs("div",{className:"flex items-center mb-4",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(SQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Upcoming Deal Revenue"})]}),d.jsx("div",{className:"h-[400px]",children:d.jsx(Iqe,{data:r,indexBy:"date",keys:["won","pending","lost"],colors:["#61cdbb","#97e3d5","#e25c3b"],margin:{top:30,right:50,bottom:30,left:0},padding:.3,valueScale:{type:"linear",min:a.min*1.2,max:a.max*1.2},indexScale:{type:"band",round:!0},enableGridX:!0,enableGridY:!1,enableLabel:!1,tooltip:i(({value:o,indexValue:s})=>d.jsxs("div",{className:"p-2 bg-secondary rounded shadow inline-flex items-center gap-1 text-secondary-foreground",children:[d.jsxs("strong",{children:[s,": "]})," ",o>0?"+":"",o.toLocaleString(e.at(0)??mW,{style:"currency",currency:qqe})]}),"tooltip"),axisTop:{tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisBottom:{legendPosition:"middle",legendOffset:50,tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisLeft:null,axisRight:{format:i(o=>`${Math.abs(o/1e3)}k`,"format"),tickValues:8,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},markers:[{axis:"y",value:0,lineStyle:{strokeOpacity:0},textStyle:{fill:"#2ebca6"},legend:"Won",legendPosition:"top-left",legendOrientation:"vertical"},{axis:"y",value:0,lineStyle:{stroke:"#f47560",strokeWidth:1},textStyle:{fill:"#e25c3b"},legend:"Lost",legendPosition:"bottom-left",legendOrientation:"vertical"}]})})]})}),Uqe=i(e=>{const t=xt(),n=Ht(e),{filterValues:r,setFilters:a}=qw(e),o=fd();if(!n)throw new Error("<ListNoResults> must be used inside a <List> component");return d.jsx("div",{className:"p-6",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:r&&a&&Object.keys(r).length>0?d.jsxs(d.Fragment,{children:[t("ra.navigation.no_filtered_results",{resource:n,name:o(n,0),_:"No results found with the current filters."})," ",d.jsx(ze,{variant:"outline",size:"sm",onClick:i(()=>a({},[]),"onClick"),children:t("ra.navigation.clear_filters",{_:"Clear filters"})})]}):t("ra.navigation.no_results",{resource:n,name:o(n,0),_:"No results found."})})})},"ListNoResults"),Bqe=i(e=>{const{children:t,linkType:n,rowClick:r,style:a}=e,o=Ht(e),s=Wt(e),l=Sa(),f=typeof n=="function"||typeof r=="function",c=QG({link:f?!1:n??r,resource:o}),p=JG(),m=Et(async()=>{if(!f||!s)return;const g=typeof n=="function"?n(s,s.id):typeof r=="function"?(w,S)=>r(w.id,S,w):!1,b=await p({record:s,resource:o,link:g});b===!1||b==null||l(b)});return s?f?d.jsx("li",{className:"w-full",children:d.jsx("button",{onClick:m,style:a,className:"w-full text-left hover:bg-muted focus: bg-muted focus:outline-none",children:t})}):c?d.jsx("li",{className:"w-full",children:d.jsx(fn,{to:c,style:a,className:"block w-full hover:bg-muted focus:bg-muted focus:outline-none",children:t})}):d.jsx("li",{className:"w-full",children:t}):null},"SimpleListItem"),fT=i(({className:e})=>d.jsx("span",{className:Se("bg-gray-300 flex",e),children:" "}),"ListPlaceholder"),Vqe=i(e=>{const{className:t,hasLeftAvatarOrIcon:n,hasRightAvatarOrIcon:r,hasSecondaryText:a,hasTertiaryText:o,nbFakeLines:s=5,...l}=e;return RK(1e3)?d.jsx("ul",{className:t,...l,children:Hqe(s,c=>d.jsxs("li",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"mb-1",children:[d.jsx(fT,{className:"w-1/3 inline-block mb-1"}),o&&d.jsx("span",{className:"float-right opacity-55 min-w-[10vw]",children:d.jsx(fT,{})})]}),a&&d.jsx(fT,{className:"w-1/4"})]}),r&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "})]},c))}):null},"SimpleListLoading"),Hqe=i((e,t)=>Array.from({length:e},(n,r)=>t(r)),"times"),Wqe=i(e=>{const{className:t,empty:n=Kqe,leftAvatar:r,leftIcon:a,linkType:o,rowClick:s,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,resource:g,...b}=e,{data:w,isPending:S,total:_}=qw(e);return S===!0?d.jsx(Vqe,{className:t,hasLeftAvatarOrIcon:!!a||!!r,hasRightAvatarOrIcon:!!c||!!f,hasSecondaryText:!!p,hasTertiaryText:!!m}):w==null||w.length===0||_===0?n||null:d.jsx("ul",{className:t,...cme(b),children:d.jsx(vme,{data:w,total:_,render:i((j,E)=>d.jsx(Bqe,{rowIndex:E,linkType:o,rowClick:s,resource:g,children:d.jsx(Gqe,{leftAvatar:r,leftIcon:a,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,rowIndex:E})},j.id),"render")})})},"SimpleList"),Gqe=i(e=>{const{leftAvatar:t,leftIcon:n,primaryText:r,rightAvatar:a,rightIcon:o,secondaryText:s,tertiaryText:l}=e,f=Ht(e),c=Wt(e),p=Ec(f),m=xt(),g=i((b,w)=>{const S=w(b,b.id);return typeof S=="string"&&(S.startsWith("http")||S.startsWith("data:"))?d.jsx("img",{src:S,alt:"",className:"w-10 h-10 rounded-full object-cover"}):d.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center text-sm",children:S})},"renderAvatar");return c?d.jsxs("div",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"flex-shrink-0",children:n(c,c.id)}),t&&d.jsx("div",{className:"flex-shrink-0",children:g(c,t)}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"text-sm font-medium truncate",children:r?typeof r=="string"?m(r,{...c,_:r}):y.isValidElement(r)?r:r(c,c.id):p(c)}),!!l&&d.jsx("div",{className:"text-xs text-muted-foreground ml-2",children:typeof l=="string"?m(l,{...c,_:l}):y.isValidElement(l)?l:l(c,c.id)})]}),!!s&&d.jsx("div",{className:"text-sm text-muted-foreground truncate",children:typeof s=="string"?m(s,{...c,_:s}):y.isValidElement(s)?s:s(c,c.id)})]}),(a||o)&&d.jsxs("div",{className:"flex-shrink-0 flex items-center space-x-2",children:[a&&g(c,a),o&&o(c,c.id)]})]}):null},"SimpleListItemContent"),Kqe=d.jsx(Uqe,{}),Yqe=i(()=>{const{identity:e}=Zn(),{data:t,total:n,isPending:r}=za("contacts",{pagination:{page:1,perPage:10},sort:{field:"last_seen",order:"DESC"},filter:{status:"hot",sales_id:e?.id}},{enabled:Number.isInteger(e?.id)});return d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(IM,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Hot Contacts"}),d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsx(ze,{variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",asChild:!0,children:d.jsx(fn,{to:"/contacts/create",children:d.jsx(Ji,{className:"w-4 h-4 text-primary"})})})}),d.jsx(oo,{children:"Create contact"})]})})]}),d.jsx(pn,{className:"py-0",children:d.jsx(Wqe,{linkType:"show",data:t,total:n,isPending:r,resource:"contacts",className:"[&>li:first-child>a]:rounded-t-xl [&>li:last-child>a]:rounded-b-xl",primaryText:i(a=>`${a.first_name} ${a.last_name}`,"primaryText"),secondaryText:i(a=>d.jsxs(d.Fragment,{children:[a.title," at ",a.company_name]}),"secondaryText"),leftAvatar:i(a=>d.jsx(is,{record:a}),"leftAvatar"),empty:d.jsxs("div",{className:"p-4",children:[d.jsx("p",{className:"text-sm mb-4",children:'Contacts with a "hot" status will appear here.'}),d.jsx("p",{className:"text-sm",children:'Change the status of a contact by adding a note to that contact and clicking on "show options".'})]})})})]})},"HotContacts"),Qqe=i(()=>{const{identity:e}=Zn(),{total:t}=za("tasks",{pagination:{page:1,perPage:1},filter:{sales_id:e?.id}},{enabled:!!e});return t?null:d.jsx("p",{className:"text-sm",children:"Tasks added to your contacts will appear here."})},"TasksListEmpty"),uv=i(({title:e,filter:t})=>{const{identity:n}=Zn(),{data:r,total:a,isPending:o}=za("tasks",{pagination:{page:1,perPage:100},sort:{field:"due_date",order:"ASC"},filter:{...t,sales_id:n?.id}},{enabled:!!n}),s=zw({data:r,isPending:o,resource:"tasks",perPage:5});return o||!r||!a?null:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium mb-2",children:e}),d.jsx(dd,{value:"tasks",children:d.jsx(ny,{value:s,children:d.jsx(jne,{showContact:!0})})}),a>s.perPage&&d.jsx("div",{className:"flex justify-center",children:d.jsx("a",{href:"#",onClick:i(l=>{s.setPerPage(s.perPage+10),l.preventDefault()},"onClick"),className:"text-sm underline hover:no-underline",children:"Load more"})})]})},"TasksListFilter"),tie=new Date,Xqe=K0e(tie),Zqe=Xqe<5,vW=Q0e().toISOString(),gW=Gye().toISOString(),yW=Kye().toISOString(),bW=Wye(tie,{weekStartsOn:0}).toISOString(),dv={overdue:{"done_date@is":null,"due_date@lt":vW},today:{"done_date@is":null,"due_date@gte":vW,"due_date@lte":gW},tomorrow:{"done_date@is":null,"due_date@gt":gW,"due_date@lt":yW},thisWeek:{"done_date@is":null,"due_date@gte":yW,"due_date@lte":bW},later:{"done_date@is":null,"due_date@gt":bW}},Jqe=i(()=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(kQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground flex-1",children:"Upcoming Tasks"}),d.jsx(Sne,{display:"icon",selectContact:!0})]}),d.jsx(pn,{className:"p-4 mb-2",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(Qqe,{}),d.jsx(uv,{title:"Overdue",filter:dv.overdue}),d.jsx(uv,{title:"Today",filter:dv.today}),d.jsx(uv,{title:"Tomorrow",filter:dv.tomorrow}),Zqe&&d.jsx(uv,{title:"This week",filter:dv.thisWeek}),d.jsx(uv,{title:"Later",filter:dv.later})]})})]}),"TasksList"),eze=i(()=>{const{data:e,total:t,isPending:n}=za("contacts",{pagination:{page:1,perPage:1}}),{total:r,isPending:a}=za("contactNotes",{pagination:{page:1,perPage:1}}),{total:o,isPending:s}=za("deals",{pagination:{page:1,perPage:1}});return n||a||s?null:t?r?d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 mt-1",children:[d.jsx("div",{className:"md:col-span-3",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[null,d.jsx(Yqe,{})]})}),d.jsx("div",{className:"md:col-span-6",children:d.jsxs("div",{className:"flex flex-col gap-6",children:[o?d.jsx(zqe,{}):null,d.jsx(Z5e,{})]})}),d.jsx("div",{className:"md:col-span-3",children:d.jsx(Jqe,{})})]}):d.jsx(bV,{step:2,contactId:e?.[0]?.id}):d.jsx(bV,{step:1})},"Dashboard"),tze=y.lazy(()=>Fp(()=>import("./DealList-Dxd6Tt9n.js"),[],import.meta.url)),nze={list:tze},rze=y.createContext(void 0),G_=i(()=>y.useContext(rze),"useUserMenu"),aze=i(()=>{const{darkModeLogo:e,lightModeLogo:t,title:n}=Va(),r=Dr(),o=[{path:"/",pattern:"/"},{path:"/contacts",pattern:"/contacts/*"},{path:"/companies",pattern:"/companies/*"},{path:"/deals",pattern:"/deals/*"}].find(s=>tp(s.pattern,r.pathname))?.path||!1;return d.jsx("header",{className:"bg-secondary fixed top-0 left-0 right-0 z-50 border-b border-border",children:d.jsx("div",{className:"px-4",children:d.jsxs("div",{className:"flex justify-between items-center flex-1",children:[d.jsx(ize,{darkLogo:e,lightLogo:t,title:n}),d.jsxs("nav",{className:"flex","aria-label":"Main navigation",children:[d.jsx(Eb,{label:"Dashboard",to:"/",isActive:o==="/"}),d.jsx(Eb,{label:"Contacts",to:"/contacts",isActive:o==="/contacts"}),d.jsx(Eb,{label:"Companies",to:"/companies",isActive:o==="/companies"}),d.jsx(Eb,{label:"Deals",to:"/deals",isActive:o==="/deals"})]}),d.jsxs("div",{className:"flex items-center",children:[d.jsx(MZ,{}),d.jsx(IZ,{}),d.jsxs(PZ,{children:[d.jsx(sze,{}),d.jsx(lze,{}),d.jsx(cze,{}),d.jsx(Pge,{resource:"sales",action:"list",children:d.jsx(oze,{})}),d.jsx(ng,{}),d.jsx(l4,{className:"font-normal",children:d.jsxs("div",{className:"text-xs text-muted-foreground",children:["Version ","0.9.8"]})})]})]})]})})})},"Header"),ize=i(({darkLogo:e,lightLogo:t,title:n})=>d.jsxs(fn,{to:"/",className:"flex items-center gap-2 text-secondary-foreground no-underline hover:opacity-80 transition-opacity",children:[d.jsx("img",{className:"[.light_&]:hidden h-6",src:e,alt:`${n} logo`}),d.jsx("img",{className:"[.dark_&]:hidden h-6",src:t,alt:`${n} logo`}),d.jsx("h1",{className:"text-xl font-semibold",children:n})]}),"Logo"),Eb=i(({label:e,to:t,isActive:n})=>d.jsx(fn,{to:t,className:`px-6 py-3 text-sm font-medium transition-colors border-b-2 ${n?"text-secondary-foreground border-secondary-foreground":"text-secondary-foreground/70 border-transparent hover:text-secondary-foreground/80"}`,children:e}),"NavigationTab"),oze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/sales",className:"flex items-center gap-2",children:[d.jsx(TQ,{className:"h-4 w-4"}),"Users"]})})},"UsersMenu"),sze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/settings",className:"flex items-center gap-2",children:[d.jsx(dP,{className:"h-4 w-4"}),"My info"]})})},"ConfigurationMenu"),lze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/database",className:"flex items-center gap-2",children:[d.jsx(Qv,{className:"h-4 w-4"}),"Database"]})})},"DatabaseMenu"),cze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/integrations",className:"flex items-center gap-2",children:[d.jsx(u_e,{className:"h-4 w-4"}),"Integrations"]})})},"IntegrationsMenu"),uze=i(({children:e})=>d.jsxs(d.Fragment,{children:[d.jsx(aze,{}),d.jsx("main",{className:"max-w-screen-xl mx-auto pt-20 px-4",id:"main-content",children:d.jsx(hx,{FallbackComponent:FZ,children:d.jsx(y.Suspense,{fallback:d.jsx(sn,{className:"h-12 w-12 rounded-full"}),children:e})})}),d.jsx(R1,{})]}),"Layout"),nie=i(()=>d.jsx("div",{className:"max-w-screen-xl mx-auto h-screen pt-8",children:d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-8",children:[d.jsx(sn,{className:"w-full h-[100px]"}),d.jsx(sn,{className:"w-4/5 h-[50px]"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-2/5 h-9"})]})})}),"LoginSkeleton"),aD=i(()=>{const e=Pn(),t=_n(),{darkModeLogo:n,title:r}=Va(),{data:a,isPending:o}=Qr({queryKey:["init"],queryFn:i(async()=>t.isInitialized(),"queryFn")}),{isPending:s,mutate:l}=Yr({mutationKey:["signup"],mutationFn:i(async w=>t.signUp(w),"mutationFn"),onSuccess:i(w=>{f({email:w.email,password:w.password,redirectTo:"/contacts"}).then(()=>{c("Initial user successfully created"),e.invalidateQueries({queryKey:["auth","canAccess"]})})},"onSuccess"),onError:i(()=>{c("An error occurred. Please try again.")},"onError")}),f=xY(),c=Vt(),{register:p,handleSubmit:m,formState:{isValid:g}}=iy({mode:"onChange"});if(o)return d.jsx(nie,{});if(a)return d.jsx(gw,{to:"/login"});const b=i(async w=>{l(w)},"onSubmit");return d.jsxs("div",{className:"h-screen p-8",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("img",{src:n,alt:r,width:24,className:"filter brightness-0 invert"}),d.jsx("h1",{className:"text-xl font-semibold",children:r})]}),d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-4",children:[d.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Welcome to CRM"}),d.jsx("p",{className:"text-base mb-4",children:"Create the first user account to complete the setup."}),d.jsxs("form",{onSubmit:m(b),className:"space-y-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"first_name",children:"First name"}),d.jsx(_r,{...p("first_name",{required:!0}),id:"first_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"last_name",children:"Last name"}),d.jsx(_r,{...p("last_name",{required:!0}),id:"last_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"email",children:"Email"}),d.jsx(_r,{...p("email",{required:!0}),id:"email",type:"email",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"password",children:"Password"}),d.jsx(_r,{...p("password",{required:!0}),id:"password",type:"password",required:!0})]}),d.jsx("div",{className:"flex justify-between items-center mt-8",children:d.jsx(ze,{type:"submit",disabled:!g||s,className:"w-full",children:s?d.jsxs(d.Fragment,{children:[d.jsx(Oc,{className:"w-4 h-4 animate-spin mr-2"}),"Creating..."]}):"Create account"})})]})]})})]})},"SignupPage");aD.path="/sign-up";const dze=i((e,t)=>e==="admin"?!0:t.resource!=="sales","canAccess"),hT=tAe(Bn,{getIdentity:i(async()=>{const e=await rie();if(e==null)throw new Error;return{id:e.id,fullName:`${e.first_name} ${e.last_name}`,avatar:e.avatar?.src}},"getIdentity")});async function Ws(){if(Ws._is_initialized_cache==null){const{data:e}=await Bn.from("init_state").select("is_initialized");Ws._is_initialized_cache=e?.at(0)?.is_initialized>0}return Ws._is_initialized_cache}i(Ws,"getIsInitialized");(e=>{e._is_initialized_cache=null})(Ws||(Ws={}));const fze={...hT,login:i(async e=>{const t=await hT.login(e);return qb=void 0,t},"login"),checkAuth:i(async e=>{if(window.location.pathname==="/set-password"||window.location.hash.includes("#/set-password")||window.location.pathname==="/forgot-password"||window.location.hash.includes("#/forgot-password")||window.location.pathname==="/change-password"||window.location.hash.includes("#/change-password")||window.location.pathname==="/otp-login"||window.location.hash.includes("#/otp-login")||window.location.pathname==="/sign-up"||window.location.hash.includes("#/sign-up"))return;if(!await Ws())throw await Bn.auth.signOut(),{redirectTo:"/sign-up",message:!1};return hT.checkAuth(e)},"checkAuth"),canAccess:i(async e=>{if(!await Ws())return!1;const n=await rie();if(n==null)return!1;const r=n.administrator?"admin":"user";return dze(r,e)},"canAccess")};let qb;const rie=i(async()=>{if(qb!=null)return qb;const{data:e,error:t}=await Bn.auth.getSession();if(e?.session?.user==null||t)return;const{data:n,error:r}=await Bn.from("sales").select("id, first_name, last_name, avatar, administrator").match({user_id:e?.session?.user.id}).single();if(!(n==null||r))return qb=n,n},"getSaleFromCache");async function hze(e,t,n){const r={};t&&(r.id=t);const a={};t&&(a.company_id=t);const[o,s,l]=await Promise.all([pze(e,r),mze(e,a),vze(e,a)]);return[...o,...s,...l].sort((f,c)=>f.date&&c.date?f.date.localeCompare(c.date)*-1:0).slice(0,250)}i(hze,"getActivityLog");const pze=i(async(e,t)=>{const{data:n}=await e.getList("companies",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}});return n.map(r=>({id:`company.${r.id}.created`,type:jte,company_id:r.id,company:r,sales_id:r.sales_id,date:r.created_at}))},"getNewCompanies");async function mze(e,t){const{data:n}=await e.getList("contacts",{filter:t,pagination:{page:1,perPage:250},sort:{field:"first_seen",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["contact_id@in"]=`(${l})`}const{data:a}=await e.getList("contactNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`contact.${l.id}.created`,type:Ete,company_id:l.company_id,sales_id:l.sales_id,contact:l,date:l.first_seen})),s=a.map(l=>({id:`contactNote.${l.id}.created`,type:Cte,sales_id:l.sales_id,contactNote:l,date:l.date}));return[...o,...s]}i(mze,"getNewContactsAndNotes");async function vze(e,t){const{data:n}=await e.getList("deals",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["deal_id@in"]=`(${l})`}const{data:a}=await e.getList("dealNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`deal.${l.id}.created`,type:Ote,company_id:l.company_id,sales_id:l.sales_id,deal:l,date:l.created_at})),s=a.map(l=>({id:`dealNote.${l.id}.created`,type:kte,sales_id:l.sales_id,dealNote:l,date:l.date}));return[...o,...s]}i(vze,"getNewDealsAndNotes");async function gze(e){return e.website?{src:`https://favicon.show/${e.website.replace(/^https?:\/\//,"").replace(/\/$/,"")}`,title:"Company favicon"}:null}i(gze,"getCompanyAvatar");async function yze(e,t={}){const{timeout:n=2e3}=t,r=new AbortController,a=setTimeout(()=>r.abort(),n),o=await fetch(e,{...t,signal:r.signal});return clearTimeout(a),o}i(yze,"fetchWithTimeout");const bze=["gmail.com","yahoo.com","hotmail.com","aol.com","hotmail.co.uk","hotmail.fr","msn.com","yahoo.fr","wanadoo.fr","orange.fr","comcast.net","yahoo.co.uk","yahoo.com.br","yahoo.co.in","live.com","rediffmail.com","free.fr","gmx.de","web.de","yandex.ru","ymail.com","libero.it","outlook.com","uol.com.br","bol.com.br","mail.ru","cox.net","hotmail.it","sbcglobal.net","sfr.fr","live.fr","verizon.net","live.co.uk","googlemail.com","yahoo.es","ig.com.br","live.nl","bigpond.com","terra.com.br","yahoo.it","neuf.fr","yahoo.de","alice.it","rocketmail.com","att.net","laposte.net","facebook.com","bellsouth.net","yahoo.in","hotmail.es","charter.net","yahoo.ca","yahoo.com.au","rambler.ru","hotmail.de","tiscali.it","shaw.ca","yahoo.co.jp","sky.com","earthlink.net","optonline.net","freenet.de","t-online.de","aliceadsl.fr","virgilio.it","home.nl","qq.com","telenet.be","me.com","yahoo.com.ar","tiscali.co.uk","yahoo.com.mx","voila.fr","gmx.net","mail.com","planet.nl","tin.it","live.it","ntlworld.com","arcor.de","yahoo.co.id","frontiernet.net","hetnet.nl","live.com.au","yahoo.com.sg","zonnet.nl","club-internet.fr","juno.com","optusnet.com.au","blueyonder.co.uk","bluewin.ch","skynet.be","sympatico.ca","windstream.net","mac.com","centurytel.net","chello.nl","live.ca","aim.com","bigpond.net.au","online.de","apple.com"];async function xze(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(xze,"hash");async function wze(e){return`https://www.gravatar.com/avatar/${await xze(e)}?d=404`}i(wze,"getGravatarUrl");async function _ze(e){if(bze.includes(e))return null;try{const t=`https://${e}/favicon.ico`;if((await yze(t)).ok)return t}catch{return null}return null}i(_ze,"getFaviconUrl");async function Sze(e){if(!e.email_jsonb||!e.email_jsonb.length)return null;for(const{email:t}of e.email_jsonb){const n=await wze(t);try{if((await fetch(n)).ok)return n}catch{}const r=t.split("@")[1],a=await _ze(r);if(a)return a}return null}i(Sze,"getContactAvatar");const xW=xd()||{url:"https://placeholder.supabase.co",anonKey:"placeholder-key"},So=bAe({instanceUrl:xW.url,apiKey:xW.anonKey,supabaseClient:Bn,sortOrder:"asc,desc.nullslast"}),wW=i(async e=>{let t=e.data.logo;return typeof t!="object"||t===null||!t.src?t=await gze(e.data):t.rawFile instanceof File&&await zb(t),{...e,data:{...e.data,logo:t}}},"processCompanyLogo");async function _W(e){const{data:t}=e;if(t.avatar?.src||!t.email_jsonb||!t.email_jsonb.length)return e;const n=await Sze(t),r={...t,avatar:{src:n||void 0}};return{...e,data:r}}i(_W,"processContactAvatar");const jze={...So,async getList(e,t){return e==="companies"?So.getList("companies_summary",t):e==="contacts"?So.getList("contacts_summary",t):So.getList(e,t)},async getOne(e,t){return e==="companies"?So.getOne("companies_summary",t):e==="contacts"?So.getOne("contacts_summary",t):So.getOne(e,t)},async signUp({email:e,password:t,first_name:n,last_name:r}){const{data:a,error:o}=await Bn.functions.invoke("setup",{method:"POST",body:{email:e,password:t,first_name:n,last_name:r}});if(!a||o)throw console.error("signUp.error",o),new Error("Failed to create account");return Ws._is_initialized_cache=!0,{id:a.data.id,email:e,password:t}},async salesCreate(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"POST",body:e});if(!t||n)throw console.error("salesCreate.error",n),new Error("Failed to create account manager");return t},async salesUpdate(e,t){const{email:n,first_name:r,last_name:a,administrator:o,avatar:s,disabled:l}=t,{data:f,error:c}=await Bn.functions.invoke("users",{method:"PATCH",body:{sales_id:e,email:n,first_name:r,last_name:a,administrator:o,disabled:l,avatar:s}});if(!f||c)throw console.error("salesCreate.error",c),new Error("Failed to update account manager");return t},async resendInvite(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"invite"}});if(!t||n)throw console.error("resendInvite.error",n),new Error("Failed to resend invitation");return t},async resetPassword(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"reset"}});if(!t||n)throw console.error("resetPassword.error",n),new Error("Failed to send password reset");return t},async updatePassword(e){const{data:t,error:n}=await Bn.functions.invoke("updatePassword",{method:"PATCH",body:{sales_id:e}});if(!t||n)throw console.error("passwordUpdate.error",n),new Error("Failed to update password");return t},async unarchiveDeal(e){const{data:t}=await So.getList("deals",{filter:{stage:e.stage},pagination:{page:1,perPage:1e3},sort:{field:"index",order:"ASC"}}),n=t.map((r,a)=>({...r,index:r.id===e.id?0:a+1,archived_at:r.id===e.id?null:r.archived_at}));return await Promise.all(n.map(r=>So.update("deals",{id:r.id,data:r,previousData:t.find(a=>a.id===r.id)})))},async getActivityLog(e){return hze(So,e)},async isInitialized(){return Ws()},async mergeContacts(e,t){const{data:n,error:r}=await Bn.functions.invoke("mergeContacts",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeContacts.error",r),new Error("Failed to merge contacts");return n}},Eze=bhe(jze,[{resource:"contactNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await zb(r);return e},"beforeSave")},{resource:"dealNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await zb(r);return e},"beforeSave")},{resource:"sales",beforeSave:i(async(e,t,n)=>(e.avatar&&await zb(e.avatar),e),"beforeSave")},{resource:"contacts",beforeCreate:i(async e=>_W(e),"beforeCreate"),beforeUpdate:i(async e=>_W(e),"beforeUpdate"),beforeGetList:i(async e=>Cb(["first_name","last_name","company_name","title","email","phone","background"])(e),"beforeGetList")},{resource:"companies",beforeGetList:i(async e=>Cb(["name","phone_number","website","zipcode","city","stateAbbr"])(e),"beforeGetList"),beforeCreate:i(async e=>{const t=await wW(e);return{...t,data:{...t.data,created_at:new Date().toISOString()}}},"beforeCreate"),beforeUpdate:i(async e=>await wW(e),"beforeUpdate")},{resource:"contacts_summary",beforeGetList:i(async e=>Cb(["first_name","last_name"])(e),"beforeGetList")},{resource:"deals",beforeGetList:i(async e=>Cb(["name","type","description"])(e),"beforeGetList")}]),Cb=i(e=>t=>{if(!t.filter?.q)return t;const{q:n,...r}=t.filter;return{...t,filter:{...r,"@or":e.reduce((a,o)=>o==="email"?{...a,"email_fts@ilike":n}:o==="phone"?{...a,"phone_fts@ilike":n}:{...a,[`${o}@ilike`]:n},{})}}},"applyFullTextSearch"),zb=i(async e=>{if(!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&e.path){const{error:c}=await Bn.storage.from("attachments").createSignedUrl(e.path,60);if(!c)return}const t=e.src?await fetch(e.src).then(c=>c.blob()):e.rawFile,n=e.rawFile,r=n.name.split(".").pop(),o=`${`${Math.random()}.${r}`}`,{error:s}=await Bn.storage.from("attachments").upload(o,t);if(s)throw console.error("uploadError",s),new Error("Failed to upload attachment");const{data:l}=Bn.storage.from("attachments").getPublicUrl(o);e.path=o,e.src=l.publicUrl;const f=n.type;return e.type=f,e},"uploadToBucket");function aie(){const{identity:e}=Zn(),t=Wt();return d.jsxs("div",{className:"space-y-4 w-full",children:[d.jsx(ln,{source:"first_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"email",validate:[nr(),JK()],helperText:!1}),d.jsx(CN,{source:"administrator",readOnly:t?.id===e?.id,helperText:!1}),d.jsx(CN,{source:"disabled",readOnly:t?.id===e?.id,helperText:!1})]})}i(aie,"SalesInputs");function Cze(){const e=_n(),t=Vt(),n=rs(),{mutate:r}=Yr({mutationKey:["signup"],mutationFn:i(async o=>e.salesCreate(o),"mutationFn"),onSuccess:i(()=>{t("User created. They will soon receive an email to set their password."),n("/sales")},"onSuccess"),onError:i(()=>{t("An error occurred while creating the user.",{type:"error"})},"onError")}),a=i(async o=>{r(o)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsxs(pn,{children:[d.jsx(Qo,{children:d.jsx(Xo,{children:"Create a new user"})}),d.jsx(Wn,{children:d.jsx(pee,{onSubmit:a,children:d.jsx(aie,{})})})]})})}i(Cze,"SalesCreate");function Oze(){return d.jsxs("div",{className:"flex justify-end gap-4",children:[d.jsx($1,{}),d.jsx(yd,{})]})}i(Oze,"EditToolbar");function kze(){const{record:e}=EK(),t=_n(),n=Vt(),r=rs(),{mutate:a}=Yr({mutationKey:["signup"],mutationFn:i(async s=>{if(!e)throw new Error("Record not found");return t.salesUpdate(e.id,s)},"mutationFn"),onSuccess:i(()=>{r("/sales"),n("User updated successfully")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")}),o=i(async s=>{a(s)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsx(pn,{children:d.jsx(Wn,{children:d.jsxs(pee,{toolbar:d.jsx(Oze,{}),onSubmit:o,record:e,children:[d.jsx(Rze,{}),d.jsx(aie,{})]})})})})}i(kze,"SalesEdit");const Rze=i(()=>{const e=Wt();return e?d.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Edit ",e?.first_name," ",e?.last_name]}):null},"SaleEditTitle"),Aze=i(()=>d.jsxs(_4,{children:[d.jsx(P1,{}),d.jsx(Pc,{label:"New user"})]}),"SalesListActions"),Tze=[d.jsx(S4,{source:"q",alwaysOn:!0})],Pze=i(e=>{const t=Wt();return t?d.jsxs("div",{className:"flex flex-row gap-1",children:[t.administrator&&d.jsx(Pr,{variant:"outline",className:"border-blue-300 dark:border-blue-700",children:"Admin"}),t.disabled&&d.jsx(Pr,{variant:"outline",className:"border-orange-300 dark:border-orange-700",children:"Disabled"})]}):null},"OptionsField"),Nze=i(()=>{const e=Wt(),t=_n(),n=Vt(),r=Nw(),[a,o]=y.useState(!1),[s,l]=y.useState(!1),{mutate:f,isPending:c}=Yr({mutationFn:i(async()=>t.resendInvite(e.id),"mutationFn"),onSuccess:i(()=>{n("Invitation email resent successfully"),o(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to resend invitation email",{type:"error"}),o(!1)},"onError")}),{mutate:p,isPending:m}=Yr({mutationFn:i(async()=>t.resetPassword(e.id),"mutationFn"),onSuccess:i(()=>{n("Password reset email sent successfully"),l(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to send password reset email",{type:"error"}),l(!1)},"onError")});if(!e)return null;const g=e.email_confirmed_at!==null,b=e.disabled===!0;return console.log("[RowActions] Record:",{email:e.email,email_confirmed_at:e.email_confirmed_at,isConfirmed:g,isDisabled:b,inviteDialogOpen:a,resetDialogOpen:s}),d.jsxs(d.Fragment,{children:[d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsxs(ze,{variant:"ghost",className:"h-8 w-8 p-0",children:[d.jsx("span",{className:"sr-only",children:"Open menu"}),d.jsx(PM,{className:"h-4 w-4"})]})}),d.jsxs(Tc,{align:"end",children:[d.jsx(l4,{children:"Email Actions"}),d.jsx(ng,{}),!g&&d.jsxs(sr,{onClick:i(w=>{w.preventDefault(),w.stopPropagation(),console.log("[Menu] Clicked Resend Invite"),o(!0)},"onClick"),children:[d.jsx(A1e,{className:"mr-2 h-4 w-4"}),"Resend Invite"]}),g&&!b&&d.jsxs(sr,{onClick:i(()=>l(!0),"onClick"),children:[d.jsx(Xwe,{className:"mr-2 h-4 w-4"}),"Send Password Reset"]})]})]}),d.jsx(wa,{open:a,onOpenChange:o,children:d.jsxs(_a,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Resend Invitation"}),d.jsxs(Oi,{children:["Send a new invitation email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a fresh invitation link to set up their account."]})]}),d.jsxs(Yo,{children:[d.jsx(ze,{variant:"outline",onClick:i(w=>{w.stopPropagation(),o(!1)},"onClick"),disabled:c,children:"Cancel"}),d.jsx(ze,{onClick:i(w=>{w.stopPropagation(),f()},"onClick"),disabled:c,children:c?"Sending...":"Send Invitation"})]})]})}),d.jsx(wa,{open:s,onOpenChange:l,children:d.jsxs(_a,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Send Password Reset"}),d.jsxs(Oi,{children:["Send a password reset email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a link to reset their password."]})]}),d.jsxs(Yo,{children:[d.jsx(ze,{variant:"outline",onClick:i(w=>{w.stopPropagation(),l(!1)},"onClick"),disabled:m,children:"Cancel"}),d.jsx(ze,{onClick:i(w=>{w.stopPropagation(),p()},"onClick"),disabled:m,children:m?"Sending...":"Send Reset Link"})]})]})})]})},"RowActions");function Dze(){return d.jsx(b4,{filters:Tze,actions:d.jsx(Aze,{}),sort:{field:"first_name",order:"ASC"},children:d.jsx(Mze,{})})}i(Dze,"SalesList");const Mze=i(()=>{const{data:e,isPending:t,filterValues:n}=Gn(),{identity:r}=Zn(),a=n&&Object.keys(n).length>0;return!r||t?d.jsx(pn,{className:"p-4",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"})]})}):!e?.length&&!a?d.jsx(Ize,{}):d.jsxs(Fs,{children:[d.jsx(Fs.Col,{source:"first_name"}),d.jsx(Fs.Col,{source:"last_name"}),d.jsx(Fs.Col,{source:"email"}),d.jsx(Fs.Col,{label:!1,children:d.jsx(Pze,{})}),d.jsx(Fs.Col,{label:!1,children:d.jsx(Nze,{})})]})},"SalesListLayout"),Ize=i(()=>{const e=F1();return d.jsxs("div",{className:"flex flex-col justify-center items-center gap-3",style:{height:`calc(100dvh - ${e}px)`},children:[d.jsx("img",{src:"./img/empty.svg",alt:"No users found"}),d.jsxs("div",{className:"flex flex-col gap-0 items-center",children:[d.jsx("h6",{className:"text-lg font-bold",children:"No users found"}),d.jsx("p",{className:"text-sm text-muted-foreground text-center mb-4",children:"It seems your user list is empty."})]}),d.jsx("div",{className:"flex flex-row gap-2",children:d.jsx(Pc,{label:"New user"})})]})},"SalesEmpty"),Fze={list:Dze,create:Cze,edit:kze,recordRepresentation:i(e=>`${e.first_name} ${e.last_name}`,"recordRepresentation")};function iie({open:e,onComplete:t,canClose:n=!1}){const[r,a]=y.useState("welcome"),[o,s]=y.useState(""),[l,f]=y.useState(""),[c,p]=y.useState(null),m=i(async()=>{p(null),a("validating");const b=await XRe(o,l);b.valid?(KRe({url:o,anonKey:l}),a("success"),setTimeout(()=>{window.location.href=window.location.origin},1500)):(p(b.error||"Connection failed"),a("credentials"))},"handleValidateAndSave"),g=i(()=>{n&&t()},"handleClose");return d.jsx(wa,{open:e,onOpenChange:n?g:void 0,children:d.jsxs(_a,{className:"sm:max-w-md",onPointerDownOutside:i(b=>!n&&b.preventDefault(),"onPointerDownOutside"),onEscapeKeyDown:i(b=>!n&&b.preventDefault(),"onEscapeKeyDown"),children:[r==="welcome"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(Qv,{className:"h-6 w-6 text-primary"}),d.jsx(Gr,{children:"Welcome to CRM"})]}),d.jsx(Oi,{children:"To get started, you'll need to connect to a Supabase database."})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsx(ai,{children:d.jsxs(ki,{children:[d.jsx("strong",{children:"Don't have a Supabase project?"}),d.jsx("br",{}),"Create one for free at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"supabase.com"})]})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-medium text-sm",children:"What you'll need:"}),d.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[d.jsx("li",{children:"Your Supabase project URL"}),d.jsx("li",{children:"Your anonymous (anon) API key"})]})]}),d.jsx(ze,{onClick:i(()=>a("credentials"),"onClick"),className:"w-full",children:"Continue"})]})]}),r==="credentials"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Connect to Supabase"}),d.jsx(Oi,{children:"Enter your Supabase project credentials"})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[c&&d.jsxs(ai,{variant:"destructive",children:[d.jsx(Ap,{className:"h-4 w-4"}),d.jsx(ki,{children:c})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"supabase-url",children:"Supabase URL"}),d.jsx(_r,{id:"supabase-url",placeholder:"https://xxxxx.supabase.co",value:o,onChange:i(b=>s(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"anon-key",children:"Anonymous Key"}),d.jsx(_r,{id:"anon-key",type:"password",placeholder:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",value:l,onChange:i(b=>f(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API → Project API keys"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ze,{variant:"outline",onClick:i(()=>a("welcome"),"onClick"),className:"flex-1",children:"Back"}),d.jsx(ze,{onClick:m,disabled:!o||!l,className:"flex-1",children:"Connect"})]})]})]}),r==="validating"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Validating Connection"}),d.jsx(Oi,{children:"Testing your Supabase credentials..."})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Oc,{className:"h-12 w-12 animate-spin text-primary mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait..."})]})]}),r==="success"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Connection Successful!"}),d.jsx(Oi,{children:"Your Supabase database is now connected"})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Fo,{className:"h-12 w-12 text-green-500 mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Reloading application..."})]})]})]})})}i(iie,"SupabaseSetupWizard");function Lze(){const[e,t]=y.useState(!1),n=xd(),r=ZRe(),a=i(()=>{confirm("Are you sure you want to clear the database configuration? The app will need to be reconfigured on next launch.")&&(YRe(),window.location.reload())},"handleClearConfig");return d.jsxs(d.Fragment,{children:[d.jsxs(pn,{children:[d.jsxs(Qo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Qv,{className:"h-5 w-5"}),d.jsx(Xo,{children:"Database Connection"})]}),d.jsx(w4,{children:"Manage your Supabase database connection settings"})]}),d.jsx(Wn,{className:"space-y-4",children:n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border rounded-lg",children:[d.jsx(Fo,{className:"h-5 w-5 text-green-500 mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:n.url}),n.configuredAt&&d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Configured on"," ",new Date(n.configuredAt).toLocaleDateString()]})]})]}),r==="env"&&d.jsxs(ai,{children:[d.jsx(dP,{className:"h-4 w-4"}),d.jsx(ki,{children:"Using configuration from environment variables. You can override this by setting up a new connection via the UI."})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(ze,{variant:"outline",onClick:i(()=>t(!0),"onClick"),className:"flex-1",children:[d.jsx(dP,{className:"h-4 w-4 mr-2"}),"Change Connection"]}),r==="ui"&&d.jsxs(ze,{variant:"destructive",onClick:a,className:"flex-1",children:[d.jsx(cy,{className:"h-4 w-4 mr-2"}),"Clear Configuration"]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx($ze,{className:"text-sm font-medium",children:"Anonymous Key"}),d.jsxs("div",{className:"font-mono text-sm p-2 bg-muted rounded",children:[n.anonKey.substring(0,20),"...",n.anonKey.substring(n.anonKey.length-10)]})]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border border-dashed rounded-lg",children:[d.jsx(al,{className:"h-5 w-5 text-destructive mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Not Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"No Supabase database is configured"})]})]}),d.jsx(ai,{children:d.jsxs(ki,{children:["Connect to a Supabase database to start using Atomic CRM. You can create a free project at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"supabase.com"})]})}),d.jsxs(ze,{onClick:i(()=>t(!0),"onClick"),className:"w-full",children:[d.jsx(Qv,{className:"h-4 w-4 mr-2"}),"Connect to Supabase"]})]})})]}),d.jsx(iie,{open:e,onComplete:i(()=>t(!1),"onComplete"),canClose:!0})]})}i(Lze,"DatabaseSettings");function $ze({children:e,className:t}){return d.jsx("label",{className:t,children:e})}i($ze,"Label");const iD=i(()=>d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Lze,{})}),"DatabasePage");iD.path="/database";const oD=i(()=>{const[e,t]=y.useState(!1),{identity:n,refetch:r}=Zn(),{data:a,refetch:o}=Dw("sales",{id:n?.id}),s=Vt(),l=_n(),{mutate:f}=Yr({mutationKey:["signup"],mutationFn:i(async p=>{if(!n)throw new Error("Record not found");return l.salesUpdate(n.id,p)},"mutationFn"),onSuccess:i(()=>{r(),o(),t(!1),s("Your profile has been updated")},"onSuccess"),onError:i(p=>{s("An error occurred. Please try again",{type:"error"})},"onError")});if(!n)return null;const c=i(async p=>{f(p)},"handleOnSubmit");return d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(ra,{onSubmit:c,record:a,children:d.jsx(qze,{isEditMode:e,setEditMode:t})})})},"SettingsPage"),qze=i(({isEditMode:e,setEditMode:t})=>{const n=Vt(),r=Sa(),a=Wt(),{identity:o,refetch:s}=Zn(),{isDirty:l}=ay(),f=_n(),{mutate:c}=Yr({mutationKey:["signup"],mutationFn:i(async g=>{if(!a)throw new Error("Record not found");return f.salesUpdate(a.id,g)},"mutationFn"),onSuccess:i(()=>{s(),n("Your profile has been updated")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")});if(!o)return null;const p=i(()=>{r("/change-password")},"handleClickOpenPasswordChange"),m=i(async g=>{c(g)},"handleAvatarUpdate");return d.jsxs("div",{className:"space-y-4",children:[d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx("div",{className:"mb-4 flex flex-row justify-between",children:d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"My info"})}),d.jsxs("div",{className:"space-y-4 mb-4",children:[d.jsx(ote,{source:"avatar",type:"avatar",onSave:m,linkPosition:"right"}),d.jsx(pT,{source:"first_name",isEditMode:e}),d.jsx(pT,{source:"last_name",isEditMode:e}),d.jsx(pT,{source:"email",isEditMode:e})]}),d.jsxs("div",{className:"flex flex-row justify-end gap-2",children:[!e&&d.jsx(d.Fragment,{children:d.jsx(ze,{variant:"outline",type:"button",onClick:p,children:"Change password"})}),d.jsxs(ze,{type:"button",variant:e?"ghost":"outline",onClick:i(()=>t(!e),"onClick"),className:"flex items-center",children:[e?d.jsx(al,{}):d.jsx(OQ,{}),e?"Cancel":"Edit"]}),e&&d.jsxs(ze,{type:"submit",disabled:!l,variant:"outline",children:[d.jsx(i1,{}),"Save"]})]})]})}),void 0]})},"SettingsForm"),pT=i(({source:e,isEditMode:t})=>t?d.jsx(ln,{source:e,helperText:!1}):d.jsx("div",{className:"m-2",children:d.jsx(l5e,{source:e})}),"TextRender");oD.path="/settings";function oie(){const e=new Uint8Array(16);return crypto.getRandomValues(e),`ak_live_${Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("")}`}i(oie,"generateApiKey");async function zze(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(zze,"hashApiKey");const Uze=[{value:"contacts:read",label:"Contacts: Read"},{value:"contacts:write",label:"Contacts: Write"},{value:"companies:read",label:"Companies: Read"},{value:"companies:write",label:"Companies: Write"},{value:"deals:read",label:"Deals: Read"},{value:"deals:write",label:"Deals: Write"},{value:"activities:write",label:"Activities: Write"}],Bze=i(({open:e,onClose:t})=>{const[n,r]=y.useState(null),[a,o]=y.useState(!1),s=_n(),l=Vt(),f=Pn(),{identity:c}=Zn(),{register:p,handleSubmit:m,watch:g,setValue:b,reset:w}=iy({defaultValues:{name:"",scopes:[],expires_at:""}}),S=Yr({mutationFn:i(async O=>{const C=oie(),T=await zze(C),R=C.substring(0,12),{data:A}=await s.create("api_keys",{data:{name:O.name,key_hash:T,key_prefix:R,scopes:O.scopes,is_active:!0,expires_at:O.expires_at||null,sales_id:c?.id,created_by_sales_id:c?.id}});return{data:A,apiKey:C}},"mutationFn"),onSuccess:i(({apiKey:O})=>{r(O),f.invalidateQueries({queryKey:["api_keys"]}),l("API key created successfully")},"onSuccess"),onError:i(()=>{l("Failed to create API key",{type:"error"})},"onError")}),_=i(()=>{r(null),o(!1),w(),t()},"handleClose"),j=i(()=>{n&&(navigator.clipboard.writeText(n),o(!0),setTimeout(()=>o(!1),2e3))},"copyApiKey"),E=i(O=>{const C=g("scopes");C.includes(O)?b("scopes",C.filter(T=>T!==O)):b("scopes",[...C,O])},"toggleScope");return d.jsx(wa,{open:e,onOpenChange:_,children:d.jsxs(_a,{className:"sm:max-w-[500px]",children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:n?"API Key Created":"Create API Key"}),d.jsx(Oi,{children:n?"Copy this key now - it won't be shown again!":"Create a new API key to access the CRM API"})]}),n?d.jsxs("div",{className:"space-y-4",children:[d.jsx(ai,{children:d.jsx(ki,{children:"Make sure to copy your API key now. You won't be able to see it again!"})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Your API Key"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(_r,{value:n,readOnly:!0,className:"font-mono text-sm"}),d.jsx(ze,{type:"button",variant:"outline",size:"icon",onClick:j,children:a?d.jsx(Fo,{className:"h-4 w-4 text-green-500"}):d.jsx(AM,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(ze,{onClick:_,children:"Done"})})]}):d.jsx("form",{onSubmit:m(O=>S.mutate(O)),children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"name",children:"Name"}),d.jsx(_r,{id:"name",placeholder:"e.g., Production API Key",...p("name",{required:!0})})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Scopes"}),d.jsx("div",{className:"space-y-2",children:Uze.map(O=>d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Up,{id:O.value,checked:g("scopes").includes(O.value),onCheckedChange:i(()=>E(O.value),"onCheckedChange")}),d.jsx("label",{htmlFor:O.value,className:"text-sm cursor-pointer",children:O.label})]},O.value))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"expires_at",children:"Expiration (optional)"}),d.jsx(_r,{id:"expires_at",type:"date",...p("expires_at")})]}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(ze,{type:"button",variant:"outline",onClick:_,children:"Cancel"}),d.jsx(ze,{type:"submit",disabled:S.isPending,children:"Create"})]})]})})]})})},"CreateApiKeyDialog");var Vze=Symbol("radix.slottable");function Hze(e){const t=i(({children:n})=>d.jsx(d.Fragment,{children:n}),"Slottable2");return t.displayName=`${e}.Slottable`,t.__radixId=Vze,t}i(Hze,"createSlottable");var sie="AlertDialog",[Wze,KUe]=da(sie,[WQ]),sl=WQ(),lie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=sl(t);return d.jsx(fy,{...r,...n,modal:!0})},"AlertDialog$1");lie.displayName=sie;var Gze="AlertDialogTrigger",Kze=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(lX,{...a,...r,ref:t})});Kze.displayName=Gze;var Yze="AlertDialogPortal",cie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=sl(t);return d.jsx(hy,{...r,...n})},"AlertDialogPortal$1");cie.displayName=Yze;var Qze="AlertDialogOverlay",uie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(py,{...a,...r,ref:t})});uie.displayName=Qze;var uh="AlertDialogContent",[Xze,Zze]=Wze(uh),Jze=Hze("AlertDialogContent"),die=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...a}=e,o=sl(n),s=y.useRef(null),l=Zt(t,s),f=y.useRef(null);return d.jsx(KSe,{contentName:uh,titleName:fie,docsSlug:"alert-dialog",children:d.jsx(Xze,{scope:n,cancelRef:f,children:d.jsxs(my,{role:"alertdialog",...o,...a,ref:l,onOpenAutoFocus:tt(a.onOpenAutoFocus,c=>{c.preventDefault(),f.current?.focus({preventScroll:!0})}),onPointerDownOutside:i(c=>c.preventDefault(),"onPointerDownOutside"),onInteractOutside:i(c=>c.preventDefault(),"onInteractOutside"),children:[d.jsx(Jze,{children:r}),d.jsx(tUe,{contentRef:s})]})})})});die.displayName=uh;var fie="AlertDialogTitle",hie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(u1,{...a,...r,ref:t})});hie.displayName=fie;var pie="AlertDialogDescription",mie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(d1,{...a,...r,ref:t})});mie.displayName=pie;var eUe="AlertDialogAction",vie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(vy,{...a,...r,ref:t})});vie.displayName=eUe;var gie="AlertDialogCancel",yie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=Zze(gie,n),o=sl(n),s=Zt(t,a);return d.jsx(vy,{...o,...r,ref:s})});yie.displayName=gie;var tUe=i(({contentRef:e})=>{const t=`\`${uh}\` requires a description for the component to be accessible for screen reader users.
|
|
154
|
+
`,fill:a,opacity:s,strokeWidth:f,stroke:c===void 0?"transparent":c,style:{pointerEvents:"none"}})})},"y");function oc(){return oc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oc.apply(null,arguments)}i(oc,"b");var Ci={translateX:0,translateY:0,padding:0,itemsSpacing:0,itemDirection:"left-to-right",justify:!1,symbolShape:"square",symbolSize:16,symbolSpacing:8},tqe={top:0,right:0,bottom:0,left:0},T3=i(function(e){var t,n=e.direction,r=e.itemsSpacing,a=e.padding,o=e.itemCount,s=e.itemWidth,l=e.itemHeight;if(typeof a!="number"&&(typeof(t=a)!="object"||Array.isArray(t)||t===null))throw new Error("Invalid property padding, must be one of: number, object");var f=typeof a=="number"?{top:a,right:a,bottom:a,left:a}:oc({},tqe,a),c=f.left+f.right,p=f.top+f.bottom,m=s+c,g=l+p,b=(o-1)*r;return n==="row"?m=s*o+b+c:n==="column"&&(g=l*o+b+p),{width:m,height:g,padding:f}},"A"),Wae=i(function(e){var t=e.anchor,n=e.translateX,r=e.translateY,a=e.containerWidth,o=e.containerHeight,s=e.width,l=e.height,f=n,c=r;switch(t){case"top":f+=(a-s)/2;break;case"top-right":f+=a-s;break;case"right":f+=a-s,c+=(o-l)/2;break;case"bottom-right":f+=a-s,c+=o-l;break;case"bottom":f+=(a-s)/2,c+=o-l;break;case"bottom-left":c+=o-l;break;case"left":c+=(o-l)/2;break;case"center":f+=(a-s)/2,c+=(o-l)/2}return{x:f,y:c}},"C"),Gae=i(function(e){var t,n,r,a,o,s,l=e.direction,f=e.justify,c=e.symbolSize,p=e.symbolSpacing,m=e.width,g=e.height;switch(l){case"left-to-right":t=0,n=(g-c)/2,a=g/2,s="central",f?(r=m,o="end"):(r=c+p,o="start");break;case"right-to-left":t=m-c,n=(g-c)/2,a=g/2,s="central",f?(r=0,o="start"):(r=m-c-p,o="end");break;case"top-to-bottom":t=(m-c)/2,n=0,r=m/2,o="middle",f?(a=g,s="alphabetic"):(a=c+p,s="text-before-edge");break;case"bottom-to-top":t=(m-c)/2,n=g-c,r=m/2,o="middle",f?(a=0,s="text-before-edge"):(a=g-c-p,s="alphabetic")}return{symbolX:t,symbolY:n,labelX:r,labelY:a,labelAnchor:o,labelAlignment:s}},"z"),nqe={circle:X9e,diamond:Z9e,square:J9e,triangle:eqe},rqe=i(function(e){var t,n,r,a,o,s,l,f,c,p,m,g=e.x,b=e.y,w=e.width,S=e.height,_=e.data,j=e.direction,E=j===void 0?Ci.itemDirection:j,O=e.justify,C=O===void 0?Ci.justify:O,T=e.textColor,R=e.background,A=R===void 0?"transparent":R,P=e.opacity,D=P===void 0?1:P,M=e.symbolShape,I=M===void 0?Ci.symbolShape:M,F=e.symbolSize,L=F===void 0?Ci.symbolSize:F,q=e.symbolSpacing,U=q===void 0?Ci.symbolSpacing:q,$=e.symbolBorderWidth,V=$===void 0?0:$,z=e.symbolBorderColor,W=z===void 0?"transparent":z,H=e.onClick,Q=e.onMouseEnter,Y=e.onMouseLeave,K=e.toggleSerie,ee=e.effects,te=y.useState({}),oe=te[0],ne=te[1],fe=Mr(),re=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on==="hover"})).reduce((function(me,Te){return oc({},me,Te.style)}),{});ne(se)}Q?.(_,X)}),[Q,_,ee]),ce=y.useCallback((function(X){if(ee){var se=ee.filter((function(me){return me.on!=="hover"})).reduce((function(me,Te){return oc({},me,Te.style)}),{});ne(se)}Y?.(_,X)}),[Y,_,ee]),he=Gae({direction:E,justify:C,symbolSize:(t=oe.symbolSize)!=null?t:L,symbolSpacing:U,width:w,height:S}),J=he.symbolX,Me=he.symbolY,we=he.labelX,Ee=he.labelY,Re=he.labelAnchor,ke=he.labelAlignment,Pe=[H,Q,Y,K].some((function(X){return X!==void 0})),Ue=typeof I=="function"?I:nqe[I];return d.jsxs("g",{transform:"translate("+g+","+b+")",style:{opacity:(n=oe.itemOpacity)!=null?n:D},children:[d.jsx("rect",{width:w,height:S,fill:(r=oe.itemBackground)!=null?r:A,style:{cursor:Pe?"pointer":"auto"},onClick:i(function(X){H?.(_,X),K?.(_.id)},"onClick"),onMouseEnter:re,onMouseLeave:ce}),y.createElement(Ue,oc({id:_.id,x:J,y:Me,size:(a=oe.symbolSize)!=null?a:L,fill:(o=(s=_.fill)!=null?s:_.color)!=null?o:"black",borderWidth:(l=oe.symbolBorderWidth)!=null?l:V,borderColor:(f=oe.symbolBorderColor)!=null?f:W},_.hidden?fe.legends.hidden.symbol:void 0)),d.jsx(V_,{textAnchor:Re,style:oc({},fe.legends.text,{fill:(c=(p=(m=oe.itemTextColor)!=null?m:T)!=null?p:fe.legends.text.fill)!=null?c:"black",dominantBaseline:ke,pointerEvents:"none",userSelect:"none"},_.hidden?fe.legends.hidden.text:void 0),x:we,y:Ee,children:_.label})]})},"B"),aqe=i(function(e){var t=e.data,n=e.x,r=e.y,a=e.direction,o=e.padding,s=o===void 0?Ci.padding:o,l=e.justify,f=e.effects,c=e.itemWidth,p=e.itemHeight,m=e.itemDirection,g=m===void 0?Ci.itemDirection:m,b=e.itemsSpacing,w=b===void 0?Ci.itemsSpacing:b,S=e.itemTextColor,_=e.itemBackground,j=_===void 0?"transparent":_,E=e.itemOpacity,O=E===void 0?1:E,C=e.symbolShape,T=e.symbolSize,R=e.symbolSpacing,A=e.symbolBorderWidth,P=e.symbolBorderColor,D=e.onClick,M=e.onMouseEnter,I=e.onMouseLeave,F=e.toggleSerie,L=T3({itemCount:t.length,itemWidth:c,itemHeight:p,itemsSpacing:w,direction:a,padding:s}).padding,q=a==="row"?c+w:0,U=a==="column"?p+w:0;return d.jsx("g",{transform:"translate("+n+","+r+")",children:t.map((function($,V){return d.jsx(rqe,{data:$,x:V*q+L.left,y:V*U+L.top,width:c,height:p,direction:g,justify:l,effects:f,textColor:S,background:j,opacity:O,symbolShape:C,symbolSize:T,symbolSpacing:R,symbolBorderWidth:A,symbolBorderColor:P,onClick:D,onMouseEnter:M,onMouseLeave:I,toggleSerie:F},V)}))})},"H"),iqe=i(function(e){var t=e.data,n=e.containerWidth,r=e.containerHeight,a=e.translateX,o=a===void 0?Ci.translateX:a,s=e.translateY,l=s===void 0?Ci.translateY:s,f=e.anchor,c=e.direction,p=e.padding,m=p===void 0?Ci.padding:p,g=e.justify,b=e.itemsSpacing,w=b===void 0?Ci.itemsSpacing:b,S=e.itemWidth,_=e.itemHeight,j=e.itemDirection,E=e.itemTextColor,O=e.itemBackground,C=e.itemOpacity,T=e.symbolShape,R=e.symbolSize,A=e.symbolSpacing,P=e.symbolBorderWidth,D=e.symbolBorderColor,M=e.onClick,I=e.onMouseEnter,F=e.onMouseLeave,L=e.toggleSerie,q=e.effects,U=T3({itemCount:t.length,itemsSpacing:w,itemWidth:S,itemHeight:_,direction:c,padding:m}),$=U.width,V=U.height,z=Wae({anchor:f,translateX:o,translateY:l,containerWidth:n,containerHeight:r,width:$,height:V}),W=z.x,H=z.y;return d.jsx(aqe,{data:t,x:W,y:H,direction:c,padding:m,justify:g,effects:q,itemsSpacing:w,itemWidth:S,itemHeight:_,itemDirection:j,itemTextColor:E,itemBackground:O,itemOpacity:C,symbolShape:T,symbolSize:R,symbolSpacing:A,symbolBorderWidth:P,symbolBorderColor:D,onClick:M,onMouseEnter:I,onMouseLeave:F,toggleSerie:typeof L=="boolean"?void 0:L})},"E"),oqe={start:"left",middle:"center",end:"right"},sqe=i(function(e,t){var n=t.data,r=t.containerWidth,a=t.containerHeight,o=t.translateX,s=o===void 0?0:o,l=t.translateY,f=l===void 0?0:l,c=t.anchor,p=t.direction,m=t.padding,g=m===void 0?0:m,b=t.justify,w=b!==void 0&&b,S=t.itemsSpacing,_=S===void 0?0:S,j=t.itemWidth,E=t.itemHeight,O=t.itemDirection,C=O===void 0?"left-to-right":O,T=t.itemTextColor,R=t.symbolSize,A=R===void 0?16:R,P=t.symbolSpacing,D=P===void 0?8:P,M=t.theme,I=T3({itemCount:n.length,itemWidth:j,itemHeight:E,itemsSpacing:_,direction:p,padding:g}),F=I.width,L=I.height,q=I.padding,U=Wae({anchor:c,translateX:s,translateY:f,containerWidth:r,containerHeight:a,width:F,height:L}),$=U.x,V=U.y,z=p==="row"?j+_:0,W=p==="column"?E+_:0;e.save(),e.translate($,V),Ig(e,M.legends.text),n.forEach((function(H,Q){var Y,K=Q*z+q.left,ee=Q*W+q.top,te=Gae({direction:C,justify:w,symbolSize:A,symbolSpacing:D,width:j,height:E}),oe=te.symbolX,ne=te.symbolY,fe=te.labelX,re=te.labelY,ce=te.labelAnchor,he=te.labelAlignment;e.fillStyle=(Y=H.color)!=null?Y:"black",e.fillRect(K+oe,ee+ne,A,A),e.textAlign=oqe[ce],he==="central"&&(e.textBaseline="middle"),Fg(e,oc({},M.legends.text,{fill:T??M.legends.text.fill}),String(H.label),K+fe,ee+re)})),e.restore()},"L"),lqe=i(function(e,t,n,r,a,o){o>0?(e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+a-o),e.quadraticCurveTo(t+r,n+a,t+r-o,n+a),e.lineTo(t+o,n+a),e.quadraticCurveTo(t,n+a,t,n+a-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()):e.rect(t,n,r,a)},"o");function vn(){return vn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vn.apply(null,arguments)}i(vn,"Q");function Fc(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}i(Fc,"U");var hW,cqe=i(function(e){var t=e.bars,n=e.annotations,r=Uae({data:t,annotations:n,getPosition:i(function(a){return{x:a.x+a.width/2,y:a.y+a.height/2}},"getPosition"),getDimensions:i(function(a){var o=a.height,s=a.width;return{width:s,height:o,size:Math.max(s,o)}},"getDimensions")});return d.jsx(d.Fragment,{children:r.map((function(a,o){return d.jsx(D9e,vn({},a),o)}))})},"$"),uqe=i(function(e){var t=e.width,n=e.height,r=e.legends,a=e.toggleSerie;return d.jsx(d.Fragment,{children:r.map((function(o,s){var l,f=o[0],c=o[1];return d.jsx(iqe,vn({},f,{containerWidth:t,containerHeight:n,data:(l=f.data)!=null?l:c,toggleSerie:f.toggleSerie&&f.dataFrom==="keys"?a:void 0}),s)}))})},"ee"),dqe=["data"],fqe=i(function(e){var t,n=e.bar,r=n.data,a=Fc(n,dqe),o=e.style,s=o.borderColor,l=o.color,f=o.height,c=o.labelColor,p=o.labelOpacity,m=o.labelX,g=o.labelY,b=o.transform,w=o.width,S=o.textAnchor,_=e.borderRadius,j=e.borderWidth,E=e.label,O=e.shouldRenderLabel,C=e.isInteractive,T=e.onClick,R=e.onMouseEnter,A=e.onMouseLeave,P=e.tooltip,D=e.isFocusable,M=e.ariaLabel,I=e.ariaLabelledBy,F=e.ariaDescribedBy,L=e.ariaDisabled,q=e.ariaHidden,U=Mr(),$=wre(),V=$.showTooltipFromEvent,z=$.showTooltipAt,W=$.hideTooltip,H=y.useMemo((function(){return function(){return y.createElement(P,vn({},a,r))}}),[P,a,r]),Q=y.useCallback((function(ne){T?.(vn({color:a.color},r),ne)}),[a,r,T]),Y=y.useCallback((function(ne){return V(H(),ne)}),[V,H]),K=y.useCallback((function(ne){R?.(r,ne),V(H(),ne)}),[r,R,V,H]),ee=y.useCallback((function(ne){A?.(r,ne),W()}),[r,W,A]),te=y.useCallback((function(){z(H(),[a.absX+a.width/2,a.absY])}),[z,H,a]),oe=y.useCallback((function(){W()}),[W]);return d.jsxs(pr.g,{transform:b,children:[d.jsx(pr.rect,{width:UN(w,(function(ne){return Math.max(ne,0)})),height:UN(f,(function(ne){return Math.max(ne,0)})),rx:_,ry:_,fill:(t=r.fill)!=null?t:l,strokeWidth:j,stroke:s,focusable:D,tabIndex:D?0:void 0,"aria-label":M?M(r):void 0,"aria-labelledby":I?I(r):void 0,"aria-describedby":F?F(r):void 0,"aria-disabled":L?L(r):void 0,"aria-hidden":q?q(r):void 0,onMouseEnter:C?K:void 0,onMouseMove:C?Y:void 0,onMouseLeave:C?ee:void 0,onClick:C?Q:void 0,onFocus:C&&D?te:void 0,onBlur:C&&D?oe:void 0,"data-testid":"bar.item."+r.id+"."+r.index}),O&&d.jsx(V_,{x:m,y:g,textAnchor:S,dominantBaseline:"central",fillOpacity:p,style:vn({},U.labels.text,{pointerEvents:"none",fill:c}),children:E})]})},"ae"),hqe=["color","label"],pqe=i(function(e){var t=e.color,n=e.label,r=Fc(e,hqe);return d.jsx(D8e,{id:n,value:r.formattedValue,enableChip:!0,color:t})},"ne"),Fn={indexBy:"id",keys:["value"],groupMode:"stacked",layout:"vertical",valueScale:{type:"linear",nice:!0,round:!1},indexScale:{type:"band",round:!1},padding:.1,innerPadding:0,enableGridX:!1,enableGridY:!0,enableLabel:!0,label:"formattedValue",labelPosition:"middle",labelOffset:0,labelSkipWidth:0,labelSkipHeight:0,labelTextColor:{theme:"labels.text.fill"},colorBy:"id",colors:{scheme:"nivo"},borderRadius:0,borderWidth:0,borderColor:{from:"color"},isInteractive:!0,tooltip:pqe,tooltipLabel:i(function(e){return e.id+" - "+e.indexValue},"tooltipLabel"),legends:[],initialHiddenIds:[],annotations:[],enableTotals:!1,totalsOffset:10},In=vn({},Fn,{layers:["grid","axes","bars","totals","markers","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},barComponent:fqe,defs:[],fill:[],markers:[],animate:!0,animateOnMount:!1,motionConfig:"default",role:"img",isFocusable:!1}),gr=vn({},Fn,{layers:["grid","axes","bars","totals","legends","annotations"],axisTop:null,axisRight:null,axisBottom:{},axisLeft:{},renderBar:i(function(e,t){var n=t.bar,r=n.color,a=n.height,o=n.width,s=n.x,l=n.y,f=t.borderColor,c=t.borderRadius,p=t.borderWidth,m=t.label,g=t.shouldRenderLabel,b=t.labelStyle,w=t.labelX,S=t.labelY,_=t.textAnchor;e.fillStyle=r,p>0&&(e.strokeStyle=f,e.lineWidth=p),e.beginPath(),lqe(e,s,l,o,a,Math.min(c,a)),e.fill(),p>0&&e.stroke(),g&&(e.textBaseline="middle",e.textAlign=_==="middle"?"center":_,Fg(e,b,m,s+w,l+S))},"renderBar"),pixelRatio:typeof window<"u"&&(hW=window.devicePixelRatio)!=null?hW:1}),Kae=i(function(e,t,n,r,a,o){return A3(r,{all:e.map(t),min:0,max:0},a,o).padding(n)},"de"),Yae=i(function(e,t){return e.map((function(n){return vn({},t.reduce((function(r,a){return r[a]=null,r}),{}),n)}))},"ue"),H_=i(function(e){return Object.keys(e).reduce((function(t,n){return e[n]&&(t[n]=e[n]),t}),{})},"se"),W_=i(function(e){return[e,Number(e)]},"ce");function Qae(e,t,n,r){return e===void 0&&(e=Fn.layout),n===void 0&&(n=Fn.labelPosition),r===void 0&&(r=Fn.labelOffset),function(a,o){var s=r*(t?-1:1);if(e==="horizontal"){var l=a/2;return n==="start"?l=t?a:0:n==="end"&&(l=t?0:a),{labelX:l+s,labelY:o/2,textAnchor:n==="middle"?"middle":t?"end":"start"}}var f=o/2;return n==="start"?f=t?0:o:n==="end"&&(f=t?o:0),{labelX:a/2,labelY:f-s,textAnchor:"middle"}}}i(Qae,"he");var mqe=["layout","width","height","padding","innerPadding","valueScale","indexScale","hiddenIds"],P3=i(function(e,t){return e>t},"be"),Xae=i(function(e,t){return e<t},"ge"),Zae=i(function(e,t){return Array.from(" ".repeat(t-e),(function(n,r){return e+r}))},"ve"),vqe=i(function(e){return P3(e,0)?0:e},"me"),gqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getColor,l=e.getIndex,f=e.getTooltipLabel,c=e.innerPadding,p=c===void 0?0:c,m=e.keys,g=e.xScale,b=e.yScale,w=e.margin,S=n?Xae:P3,_=a.map(H_),j=[];return m.forEach((function(E,O){return Zae(0,g.domain().length).forEach((function(C){var T,R,A,P=W_(a[C][E]),D=P[0],M=P[1],I=l(a[C]),F=((T=g(I))!=null?T:0)+t*O+p*O,L=S(R=M,0)?(A=b(R))!=null?A:0:r,q=(function($,V){var z;return S($,0)?r-V:((z=b($))!=null?z:0)-r})(M,L),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:t,height:q,color:s(U),label:f(U)})}))})),j},"pe"),yqe=i(function(e,t,n,r){var a=e.data,o=e.formatValue,s=e.getIndex,l=e.getColor,f=e.getTooltipLabel,c=e.keys,p=e.innerPadding,m=p===void 0?0:p,g=e.xScale,b=e.yScale,w=e.margin,S=n?Xae:P3,_=a.map(H_),j=[];return c.forEach((function(E,O){return Zae(0,b.domain().length).forEach((function(C){var T,R,A,P=W_(a[C][E]),D=P[0],M=P[1],I=s(a[C]),F=S(R=M,0)?r:(A=g(R))!=null?A:0,L=((T=b(I))!=null?T:0)+t*O+m*O,q=(function($,V){var z;return S($,0)?((z=g($))!=null?z:0)-r:r-V})(M,F),U={id:E,value:D===null?D:M,formattedValue:o(M),hidden:!1,index:C,indexValue:I,data:_[C]};j.push({key:E+"."+U.indexValue,index:j.length,data:U,x:F,y:L,absX:w.left+F,absY:w.top+L,width:q,height:t,color:l(U),label:f(U)})}))})),j},"ye"),bqe=i(function(e){var t,n,r,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.innerPadding,p=c===void 0?0:c,m=e.valueScale,g=e.indexScale,b=e.hiddenIds,w=b===void 0?[]:b,S=Fc(e,mqe),_=S.keys.filter((function(V){return!w.includes(V)})),j=Yae(S.data,_),E=a==="vertical"?["y","x",o]:["x","y",s],O=E[0],C=E[1],T=E[2],R=Kae(j,S.getIndex,f,g,T,C),A=m.min==="auto"?vqe:function(V){return V},P=j.reduce((function(V,z){return[].concat(V,_.map((function(W){return z[W]})))}),[]).filter(Boolean),D=A(Math.min.apply(Math,P)),M=(r=Math.max.apply(Math,P),isFinite(r)?r:0),I=A3(m,{all:P,min:D,max:M},O==="x"?o:s,O),F=a==="vertical"?[R,I]:[I,R],L=F[0],q=F[1],U=(R.bandwidth()-p*(_.length-1))/_.length,$=[vn({},S,{data:j,keys:_,innerPadding:p,xScale:L,yScale:q}),U,(t=m.reverse)!=null&&t,(n=I(0))!=null?n:0];return{xScale:L,yScale:q,bars:U>0?a==="vertical"?gqe.apply(void 0,$):yqe.apply(void 0,$):[]}},"xe"),xqe=["data","layout","width","height","padding","valueScale","indexScale","hiddenIds"],Jae=i(function(e){var t;return e.some(Array.isArray)?Jae((t=[]).concat.apply(t,e)):e},"ke"),wqe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,g=[];return f.forEach((function(b){return c.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=c(o(E.data)))!=null?_:0,C=((j=(function(M){return p(M[n?0:1])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=p(M[n?1:0]))!=null?F:0)-I})(E,C)-l,R=W_(E.data[b.key]),A=R[0],P=R[1],D={id:b.key,value:A===null?A:P,formattedValue:r(P),hidden:!1,index:S,indexValue:w,data:H_(E.data)};g.push({key:b.key+"."+w,index:g.length,data:D,x:O,y:C,absX:m.left+O,absY:m.top+C,width:t,height:T,color:a(D),label:s(D)})}))})),g},"we"),_qe=i(function(e,t,n){var r=e.formatValue,a=e.getColor,o=e.getIndex,s=e.getTooltipLabel,l=e.innerPadding,f=e.stackedData,c=e.xScale,p=e.yScale,m=e.margin,g=[];return f.forEach((function(b){return p.domain().forEach((function(w,S){var _,j,E=b[S],O=(_=p(o(E.data)))!=null?_:0,C=((j=(function(M){return c(M[n?1:0])})(E))!=null?j:0)+.5*l,T=(function(M,I){var F;return((F=c(M[n?0:1]))!=null?F:0)-I})(E,C)-l,R=W_(E.data[b.key]),A=R[0],P=R[1],D={id:b.key,value:A===null?A:P,formattedValue:r(P),hidden:!1,index:S,indexValue:w,data:H_(E.data)};g.push({key:b.key+"."+w,index:g.length,data:D,x:C,y:O,absX:m.left+C,absY:m.top+O,width:T,height:t,color:a(D),label:s(D)})}))})),g},"Le"),Sqe=i(function(e){var t,n,r=e.data,a=e.layout,o=e.width,s=e.height,l=e.padding,f=l===void 0?0:l,c=e.valueScale,p=e.indexScale,m=e.hiddenIds,g=m===void 0?[]:m,b=Fc(e,xqe),w=b.keys.filter((function(U){return!g.includes(U)})),S=GIe().keys(w).offset(KIe)(Yae(r,w)),_=a==="vertical"?["y","x",o]:["x","y",s],j=_[0],E=_[1],O=_[2],C=Kae(r,b.getIndex,f,p,O,E),T=(n=Jae(S),c.type==="log"?n.filter((function(U){return U!==0})):n),R=Math.min.apply(Math,T),A=Math.max.apply(Math,T),P=A3(c,{all:T,min:R,max:A},j==="x"?o:s,j),D=a==="vertical"?[C,P]:[P,C],M=D[0],I=D[1],F=b.innerPadding>0?b.innerPadding:0,L=C.bandwidth(),q=[vn({},b,{innerPadding:F,stackedData:S,xScale:M,yScale:I}),L,(t=c.reverse)!=null&&t];return{xScale:M,yScale:I,bars:L>0?a==="vertical"?wqe.apply(void 0,q):_qe.apply(void 0,q):[]}},"Ce"),jqe=i(function(e){var t=e.bars,n=e.direction,r=e.from,a=e.groupMode,o=e.layout,s=e.legendLabel,l=e.reverse,f=Pae(s??(r==="indexes"?"indexValue":"id"));return r==="indexes"?(function(c,p,m){var g=qH(c.map((function(b){var w,S;return{id:(w=b.data.indexValue)!=null?w:"",label:m(b.data),hidden:b.data.hidden,color:(S=b.color)!=null?S:"#000"}})),(function(b){return b.id}));return p==="horizontal"&&g.reverse(),g})(t,o,f):(function(c,p,m,g,b,w){var S=qH(c.map((function(_){var j;return{id:_.data.id,label:w(_.data),hidden:_.data.hidden,color:(j=_.color)!=null?j:"#000"}})),(function(_){return _.id}));return(p==="vertical"&&g==="stacked"&&m==="column"&&b!==!0||p==="horizontal"&&g==="stacked"&&b===!0)&&S.reverse(),S})(t,o,n,a,l,f)},"We"),pW=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+n)},"Me"),Eqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,r+(n>0?n:0))},"Be"),Cqe=i(function(e,t,n){var r=e.get(t)||0;e.set(t,Math.max(r,Number(n)))},"Re"),Oqe=i(function(e,t){var n=e.get(t)||0;e.set(t,n+1)},"Oe"),eie=i(function(e){var t,n=e.indexBy,r=n===void 0?Fn.indexBy:n,a=e.keys,o=a===void 0?Fn.keys:a,s=e.label,l=s===void 0?Fn.label:s,f=e.tooltipLabel,c=f===void 0?Fn.tooltipLabel:f,p=e.valueFormat,m=e.colors,g=m===void 0?Fn.colors:m,b=e.colorBy,w=b===void 0?Fn.colorBy:b,S=e.borderColor,_=S===void 0?Fn.borderColor:S,j=e.labelTextColor,E=j===void 0?Fn.labelTextColor:j,O=e.groupMode,C=O===void 0?Fn.groupMode:O,T=e.layout,R=T===void 0?Fn.layout:T,A=e.data,P=e.margin,D=e.width,M=e.height,I=e.padding,F=I===void 0?Fn.padding:I,L=e.innerPadding,q=L===void 0?Fn.innerPadding:L,U=e.valueScale,$=U===void 0?Fn.valueScale:U,V=e.indexScale,z=V===void 0?Fn.indexScale:V,W=e.initialHiddenIds,H=W===void 0?Fn.initialHiddenIds:W,Q=e.enableLabel,Y=Q===void 0?Fn.enableLabel:Q,K=e.labelSkipWidth,ee=K===void 0?Fn.labelSkipWidth:K,te=e.labelSkipHeight,oe=te===void 0?Fn.labelSkipHeight:te,ne=e.legends,fe=ne===void 0?Fn.legends:ne,re=e.legendLabel,ce=e.totalsOffset,he=ce===void 0?Fn.totalsOffset:ce,J=y.useState(H??[]),Me=J[0],we=J[1],Ee=y.useCallback((function(Ke){we((function(pt){return pt.indexOf(Ke)>-1?pt.filter((function(ge){return ge!==Ke})):[].concat(pt,[Ke])}))}),[]),Re=zA(r),ke=zA(l),Pe=zA(c),Ue=R3(p),X=Mr(),se=Q9e(g,w),me=fW(_,X),Te=fW(E,X),de=(C==="grouped"?bqe:Sqe)({layout:R,data:A,getIndex:Re,keys:o,width:D,height:M,getColor:se,padding:F,innerPadding:q,valueScale:$,indexScale:z,hiddenIds:Me,formatValue:Ue,getTooltipLabel:Pe,margin:P}),ue=de.bars,Ae=de.xScale,Ne=de.yScale,Fe=y.useMemo((function(){return ue.filter((function(Ke){return Ke.data.value!==null})).map((function(Ke,pt){return vn({},Ke,{index:pt})}))}),[ue]),Je=y.useCallback((function(Ke){var pt=Ke.width,ge=Ke.height;return!!Y&&!(ee>0&&pt<ee)&&!(oe>0&&ge<oe)}),[Y,ee,oe]),Pt=y.useMemo((function(){return o.map((function(Ke){var pt=ue.find((function(ge){return ge.data.id===Ke}));return vn({},pt,{data:vn({id:Ke},pt?.data,{hidden:Me.includes(Ke)})})}))}),[Me,o,ue]),$t=(t=$.reverse)!=null&&t,Rt=y.useMemo((function(){return fe.map((function(Ke){return[Ke,jqe({bars:Ke.dataFrom==="keys"?Pt:ue,direction:Ke.direction,from:Ke.dataFrom,groupMode:C,layout:R,legendLabel:re,reverse:$t})]}))}),[fe,Pt,ue,C,R,re,$t]),qt=y.useMemo((function(){return(function(Ke,pt,ge,ye,ct,Le,Xe){ye===void 0&&(ye=Fn.layout),ct===void 0&&(ct=Fn.groupMode);var We=[];if(Ke.length===0)return We;var et=new Map,jt=Ke[0].width,Ye=Ke[0].height;if(ct==="stacked"){var mt=new Map;Ke.forEach((function(At){var _t=At.data,vt=_t.indexValue,Ct=_t.value;pW(et,vt,Number(Ct)),Eqe(mt,vt,Number(Ct))})),mt.forEach((function(At,_t){var vt,Ct,Z,pe=et.get(_t)||0;ye==="vertical"?(vt=pt(_t),Ct=ge(At),Z=ge(At/2)):(vt=pt(At),Ct=ge(_t),Z=pt(At/2)),vt+=ye==="vertical"?jt/2:Le,Ct+=ye==="vertical"?-Le:Ye/2,We.push({key:"total_"+_t,x:vt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}else if(ct==="grouped"){var Ft=new Map,Nt=new Map;Ke.forEach((function(At){var _t=At.data,vt=_t.indexValue,Ct=_t.value;pW(et,vt,Number(Ct)),Cqe(Ft,vt,Number(Ct)),Oqe(Nt,vt)})),Ft.forEach((function(At,_t){var vt,Ct,Z,pe=et.get(_t)||0,_e=Nt.get(_t);ye==="vertical"?(vt=pt(_t),Ct=ge(At),Z=ge(At/2)):(vt=pt(At),Ct=ge(_t),Z=pt(At/2)),vt+=ye==="vertical"?_e*jt/2:Le,Ct+=ye==="vertical"?-Le:_e*Ye/2,We.push({key:"total_"+_t,x:vt,y:Ct,value:pe,formattedValue:Xe(pe),animationOffset:Z})}))}return We})(ue,Ae,Ne,R,C,he,Ue)}),[ue,Ae,Ne,R,C,he,Ue]);return{bars:ue,barsWithValue:Fe,xScale:Ae,yScale:Ne,getIndex:Re,getLabel:ke,getTooltipLabel:Pe,formatValue:Ue,getColor:se,getBorderColor:me,getLabelColor:Te,shouldRenderBarLabel:Je,hiddenIds:Me,toggleSerie:Ee,legendsWithData:Rt,barTotals:qt}},"Ie"),kqe=i(function(e){var t=e.data,n=e.springConfig,r=e.animate,a=e.layout,o=a===void 0?In.layout:a,s=Mr();return o_(t,{keys:i(function(l){return l.key},"keys"),from:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"from"),enter:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"enter"),update:i(function(l){return{x:l.x,y:l.y,labelOpacity:1}},"update"),leave:i(function(l){return{x:o==="vertical"?l.x:l.animationOffset,y:o==="vertical"?l.animationOffset:l.y,labelOpacity:0}},"leave"),config:n,immediate:!r,initial:r?void 0:null})((function(l,f){return d.jsx(pr.text,{x:l.x,y:l.y,fillOpacity:l.labelOpacity,style:vn({},s.labels.text,{pointerEvents:"none"}),fontWeight:"bold",fontSize:s.labels.text.fontSize,fontFamily:s.labels.text.fontFamily,textAnchor:o==="vertical"?"middle":"start",alignmentBaseline:o==="vertical"?"alphabetic":"middle",children:f.formattedValue},f.key)}))},"Ve"),Rqe=["isInteractive","animate","motionConfig","theme","renderWrapper"],Aqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,g=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?In.axisBottom:_,E=e.axisLeft,O=E===void 0?In.axisLeft:E,C=e.enableGridX,T=C===void 0?In.enableGridX:C,R=e.enableGridY,A=R===void 0?In.enableGridY:R,P=e.gridXValues,D=e.gridYValues,M=e.layers,I=M===void 0?In.layers:M,F=e.barComponent,L=F===void 0?In.barComponent:F,q=e.enableLabel,U=q===void 0?In.enableLabel:q,$=e.label,V=e.labelSkipWidth,z=V===void 0?In.labelSkipWidth:V,W=e.labelSkipHeight,H=W===void 0?In.labelSkipHeight:W,Q=e.labelTextColor,Y=e.labelPosition,K=Y===void 0?In.labelPosition:Y,ee=e.labelOffset,te=ee===void 0?In.labelOffset:ee,oe=e.markers,ne=oe===void 0?In.markers:oe,fe=e.colorBy,re=e.colors,ce=e.defs,he=ce===void 0?In.defs:ce,J=e.fill,Me=J===void 0?In.fill:J,we=e.borderRadius,Ee=we===void 0?In.borderRadius:we,Re=e.borderWidth,ke=Re===void 0?In.borderWidth:Re,Pe=e.borderColor,Ue=e.annotations,X=Ue===void 0?In.annotations:Ue,se=e.legendLabel,me=e.tooltipLabel,Te=e.valueFormat,de=e.isInteractive,ue=de===void 0?In.isInteractive:de,Ae=e.tooltip,Ne=Ae===void 0?In.tooltip:Ae,Fe=e.onClick,Je=e.onMouseEnter,Pt=e.onMouseLeave,$t=e.legends,Rt=e.role,qt=Rt===void 0?In.role:Rt,Ke=e.ariaLabel,pt=e.ariaLabelledBy,ge=e.ariaDescribedBy,ye=e.isFocusable,ct=ye===void 0?In.isFocusable:ye,Le=e.barAriaLabel,Xe=e.barAriaLabelledBy,We=e.barAriaDescribedBy,et=e.barAriaHidden,jt=e.barAriaDisabled,Ye=e.initialHiddenIds,mt=e.enableTotals,Ft=mt===void 0?In.enableTotals:mt,Nt=e.totalsOffset,At=Nt===void 0?In.totalsOffset:Nt,_t=e.forwardedRef,vt=ho(),Ct=vt.animate,Z=vt.config,pe=Tae(s,l,o),_e=pe.outerWidth,$e=pe.outerHeight,Ve=pe.margin,rt=pe.innerWidth,nt=pe.innerHeight,Qe=eie({indexBy:r,label:$,tooltipLabel:me,valueFormat:Te,colors:re,colorBy:fe,borderColor:Pe,labelTextColor:Q,groupMode:f,layout:c,data:n,keys:a,margin:Ve,width:rt,height:nt,padding:g,innerPadding:b,valueScale:p,indexScale:m,enableLabel:U,labelSkipWidth:z,labelSkipHeight:H,legends:$t,legendLabel:se,initialHiddenIds:Ye,totalsOffset:At}),ot=Qe.bars,ut=Qe.barsWithValue,st=Qe.xScale,lt=Qe.yScale,gt=Qe.getLabel,at=Qe.getTooltipLabel,kt=Qe.getBorderColor,bt=Qe.getLabelColor,Lt=Qe.shouldRenderBarLabel,Mt=Qe.toggleSerie,Fr=Qe.legendsWithData,Oa=Qe.barTotals,li=Qe.getColor,cr=Qae(c,(t=p?.reverse)!=null&&t,K,te),po=o_(ut,{keys:i(function(He){return He.key},"keys"),from:i(function(He){return vn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},cr(He.width,He.height),{transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:{height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0})},"from"),enter:i(function(He){return vn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},cr(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"enter"),update:i(function(He){return vn({borderColor:kt(He),color:He.color,height:He.height,labelColor:bt(He),labelOpacity:1},cr(He.width,He.height),{transform:"translate("+He.x+", "+He.y+")",width:He.width})},"update"),leave:i(function(He){return vn({borderColor:kt(He),color:He.color,height:0,labelColor:bt(He),labelOpacity:0},cr(He.width,He.height),{labelY:0,transform:"translate("+He.x+", "+(He.y+He.height)+")",width:He.width},c==="vertical"?{}:vn({},cr(He.width,He.height),{labelX:0,height:He.height,transform:"translate("+He.x+", "+He.y+")",width:0}))},"leave"),config:Z,immediate:!Ct,initial:Ct?void 0:null}),Lr=y.useMemo((function(){return{borderRadius:Ee,borderWidth:ke,enableLabel:U,isInteractive:ue,labelSkipWidth:z,labelSkipHeight:H,onClick:Fe,onMouseEnter:Je,onMouseLeave:Pt,getTooltipLabel:at,tooltip:Ne,isFocusable:ct,ariaLabel:Le,ariaLabelledBy:Xe,ariaDescribedBy:We,ariaHidden:et,ariaDisabled:jt}}),[Ee,ke,U,at,ue,H,z,Fe,Je,Pt,Ne,ct,Le,Xe,We,et,jt]),Ha=O7e(he,ot,Me,{dataKey:"data",targetKey:"data.fill"}),Zr={annotations:null,axes:null,bars:null,grid:null,legends:null,markers:null,totals:null};I.includes("annotations")&&(Zr.annotations=d.jsx(cqe,{bars:ot,annotations:X},"annotations")),I.includes("axes")&&(Zr.axes=d.jsx(s9e,{xScale:st,yScale:lt,width:rt,height:nt,top:w,right:S,bottom:j,left:O},"axes")),I.includes("bars")&&(Zr.bars=d.jsx(y.Fragment,{children:po((function(He,$n){return y.createElement(L,vn({},Lr,{bar:$n,style:He,shouldRenderLabel:Lt($n),label:gt($n.data)}))}))},"bars")),I.includes("grid")&&(Zr.grid=d.jsx(c9e,{width:rt,height:nt,xScale:T?st:null,yScale:A?lt:null,xValues:P,yValues:D},"grid")),I.includes("legends")&&(Zr.legends=d.jsx(uqe,{width:rt,height:nt,legends:Fr,toggleSerie:Mt},"legends")),I.includes("markers")&&(Zr.markers=d.jsx(g7e,{markers:ne,width:rt,height:nt,xScale:st,yScale:lt},"markers")),I.includes("totals")&&Ft&&(Zr.totals=d.jsx(kqe,{data:Oa,springConfig:Z,animate:Ct,layout:c},"totals"));var Wa=vn({},Lr,{margin:Ve,width:s,height:l,innerWidth:rt,innerHeight:nt,bars:ot,legendData:Fr,enableLabel:U,xScale:st,yScale:lt,tooltip:Ne,getTooltipLabel:at,onClick:Fe,onMouseEnter:Je,onMouseLeave:Pt,getColor:li});return d.jsx(p7e,{width:_e,height:$e,margin:Ve,defs:Ha,role:qt,ariaLabel:Ke,ariaLabelledBy:pt,ariaDescribedBy:ge,isFocusable:ct,ref:_t,children:I.map((function(He,$n){var Ii;return typeof He=="function"?d.jsx(y.Fragment,{children:y.createElement(He,Wa)},$n):(Ii=Zr?.[He])!=null?Ii:null}))})},"He"),Tqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=n===void 0?In.isInteractive:n,a=e.animate,o=a===void 0?In.animate:a,s=e.motionConfig,l=s===void 0?In.motionConfig:s,f=e.theme,c=e.renderWrapper,p=Fc(e,Rqe);return d.jsx(Cae,{animate:o,isInteractive:r,motionConfig:l,renderWrapper:c,theme:f,children:d.jsx(Aqe,vn({},p,{isInteractive:r,forwardedRef:t}))})})),Pqe=["isInteractive","renderWrapper","theme"],dT=i(function(e,t,n,r){return e.find((function(a){return S7e(a.x+t.left,a.y+t.top,a.width,a.height,n,r)}))},"Fe"),Nqe=i(function(e){var t,n=e.data,r=e.indexBy,a=e.keys,o=e.margin,s=e.width,l=e.height,f=e.groupMode,c=e.layout,p=e.valueScale,m=e.indexScale,g=e.padding,b=e.innerPadding,w=e.axisTop,S=e.axisRight,_=e.axisBottom,j=_===void 0?gr.axisBottom:_,E=e.axisLeft,O=E===void 0?gr.axisLeft:E,C=e.enableGridX,T=C===void 0?gr.enableGridX:C,R=e.enableGridY,A=R===void 0?gr.enableGridY:R,P=e.gridXValues,D=e.gridYValues,M=e.labelPosition,I=M===void 0?gr.labelPosition:M,F=e.labelOffset,L=F===void 0?gr.labelOffset:F,q=e.layers,U=q===void 0?gr.layers:q,$=e.renderBar,V=$===void 0?gr.renderBar:$,z=e.enableLabel,W=z===void 0?gr.enableLabel:z,H=e.label,Q=e.labelSkipWidth,Y=Q===void 0?gr.labelSkipWidth:Q,K=e.labelSkipHeight,ee=K===void 0?gr.labelSkipHeight:K,te=e.labelTextColor,oe=e.colorBy,ne=e.colors,fe=e.borderRadius,re=fe===void 0?gr.borderRadius:fe,ce=e.borderWidth,he=ce===void 0?gr.borderWidth:ce,J=e.borderColor,Me=e.annotations,we=Me===void 0?gr.annotations:Me,Ee=e.legendLabel,Re=e.tooltipLabel,ke=e.valueFormat,Pe=e.isInteractive,Ue=Pe===void 0?gr.isInteractive:Pe,X=e.tooltip,se=X===void 0?gr.tooltip:X,me=e.onClick,Te=e.onMouseEnter,de=e.onMouseLeave,ue=e.legends,Ae=e.pixelRatio,Ne=Ae===void 0?gr.pixelRatio:Ae,Fe=e.role,Je=e.forwardedRef,Pt=e.enableTotals,$t=Pt===void 0?gr.enableTotals:Pt,Rt=e.totalsOffset,qt=Rt===void 0?gr.totalsOffset:Rt,Ke=y.useRef(null),pt=Mr(),ge=Tae(s,l,o),ye=ge.margin,ct=ge.innerWidth,Le=ge.innerHeight,Xe=ge.outerWidth,We=ge.outerHeight,et=eie({indexBy:r,label:H,tooltipLabel:Re,valueFormat:ke,colors:ne,colorBy:oe,borderColor:J,labelTextColor:te,groupMode:f,layout:c,data:n,keys:a,margin:ye,width:ct,height:Le,padding:g,innerPadding:b,valueScale:p,indexScale:m,enableLabel:W,labelSkipWidth:Y,labelSkipHeight:ee,legends:ue,legendLabel:Ee,totalsOffset:qt}),jt=et.bars,Ye=et.barsWithValue,mt=et.xScale,Ft=et.yScale,Nt=et.getLabel,At=et.getTooltipLabel,_t=et.getBorderColor,vt=et.getLabelColor,Ct=et.shouldRenderBarLabel,Z=et.legendsWithData,pe=et.barTotals,_e=et.getColor,$e=wre(),Ve=$e.showTooltipFromEvent,rt=$e.hideTooltip,nt=k9e({annotations:Uae({data:jt,annotations:we,getPosition:i(function(at){return{x:at.x,y:at.y}},"getPosition"),getDimensions:i(function(at){var kt=at.width,bt=at.height;return{width:kt,height:bt,size:Math.max(kt,bt)}},"getDimensions")})}),Qe=y.useMemo((function(){return{borderRadius:re,borderWidth:he,isInteractive:Ue,isFocusable:!1,labelSkipWidth:Y,labelSkipHeight:ee,margin:ye,width:s,height:l,innerWidth:ct,innerHeight:Le,bars:jt,legendData:Z,enableLabel:W,xScale:mt,yScale:Ft,tooltip:se,getTooltipLabel:At,onClick:me,onMouseEnter:Te,onMouseLeave:de,getColor:_e}}),[re,he,Ue,Y,ee,ye,s,l,ct,Le,jt,Z,W,mt,Ft,se,At,me,Te,de,_e]),ot=R3(ke),ut=Qae(c,(t=p?.reverse)!=null&&t,I,L);y.useEffect((function(){if(Ke.current){Ke.current.width=Xe*Ne,Ke.current.height=We*Ne;var at=Ke.current.getContext("2d");at.scale(Ne,Ne),at.fillStyle=pt.background,at.fillRect(0,0,Xe,We),at.translate(ye.left,ye.top),U.forEach((function(kt){kt==="grid"?typeof pt.grid.line.strokeWidth=="number"&&pt.grid.line.strokeWidth>0&&(at.lineWidth=pt.grid.line.strokeWidth,at.strokeStyle=pt.grid.line.stroke,T&&JH(at,{width:ct,height:Le,scale:mt,axis:"x",values:P}),A&&JH(at,{width:ct,height:Le,scale:Ft,axis:"y",values:D})):kt==="axes"?d9e(at,{xScale:mt,yScale:Ft,width:ct,height:Le,top:w,right:S,bottom:j,left:O,theme:pt}):kt==="bars"?(Ig(at,pt.text),Ye.forEach((function(bt){V(at,vn({bar:bt,borderColor:_t(bt),borderRadius:re,borderWidth:he,label:Nt(bt.data),shouldRenderLabel:Ct(bt),labelStyle:vn({},pt.labels.text,{fill:vt(bt)})},ut(bt.width,bt.height)))}))):kt==="legends"?Z.forEach((function(bt){var Lt=bt[0],Mt=bt[1];sqe(at,vn({},Lt,{data:Mt,containerWidth:ct,containerHeight:Le,theme:pt}))})):kt==="annotations"?M9e(at,{annotations:nt,theme:pt}):kt==="totals"&&$t?(function(bt,Lt,Mt,Fr){Fr===void 0&&(Fr=gr.layout),Ig(bt,Mt.labels.text),bt.textBaseline=Fr==="vertical"?"alphabetic":"middle",bt.textAlign=Fr==="vertical"?"center":"start",Lt.forEach((function(Oa){Fg(bt,Mt.labels.text,Oa.formattedValue,Oa.x,Oa.y)}))})(at,pe,pt,c):typeof kt=="function"&&kt(at,Qe)})),at.save()}}),[j,O,S,w,Ye,re,he,nt,T,A,_t,Nt,vt,P,D,f,l,Le,ct,Qe,U,c,Z,ye.left,ye.top,We,Xe,Ne,V,mt,Ft,Ct,pt,s,pe,$t,ot,ut]);var st=y.useCallback((function(at){if(jt&&Ke.current){var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt!==void 0?(Ve(y.createElement(se,vn({},Mt.data,{color:Mt.color,label:Mt.label,value:Number(Mt.data.value)})),at),at.type==="mouseenter"&&Te?.(Mt.data,at)):rt()}}),[rt,ye,Te,jt,Ve,se]),lt=y.useCallback((function(at){if(jt&&Ke.current){rt();var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt&&de?.(Mt.data,at)}}),[rt,ye,de,jt]),gt=y.useCallback((function(at){if(jt&&Ke.current){var kt=UA(Ke.current,at),bt=kt[0],Lt=kt[1],Mt=dT(jt,ye,bt,Lt);Mt!==void 0&&me?.(vn({},Mt.data,{color:Mt.color}),at)}}),[ye,me,jt]);return d.jsx("canvas",{ref:k7e(Ke,Je),width:Xe*Ne,height:We*Ne,style:{width:Xe,height:We,cursor:Ue?"auto":"normal"},onMouseEnter:Ue?st:void 0,onMouseMove:Ue?st:void 0,onMouseLeave:Ue?lt:void 0,onClick:Ue?gt:void 0,role:Fe})},"ze"),Dqe=y.forwardRef((function(e,t){var n=e.isInteractive,r=e.renderWrapper,a=e.theme,o=Fc(e,Pqe);return d.jsx(Cae,{isInteractive:n,renderWrapper:r,theme:a,animate:!1,children:d.jsx(Nqe,vn({},o,{isInteractive:n,forwardedRef:t}))})})),Mqe=["defaultWidth","defaultHeight","onResize","debounceResize"],Iqe=y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=Fc(e,Mqe);return d.jsx(Oae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Tqe,vn({},s,{width:f,height:c,ref:t}))},"children")})})),Fqe=["defaultWidth","defaultHeight","onResize","debounceResize"];y.forwardRef((function(e,t){var n=e.defaultWidth,r=e.defaultHeight,a=e.onResize,o=e.debounceResize,s=Fc(e,Fqe);return d.jsx(Oae,{defaultWidth:n,defaultHeight:r,onResize:a,debounceResize:o,children:i(function(l){var f=l.width,c=l.height;return d.jsx(Dqe,vn({},s,{width:f,height:c,ref:t}))},"children")})}));const Lqe={opportunity:.2,"proposal-sent":.5,"in-negociation":.8,delayed:.3},$qe=new Date(new Date().setMonth(new Date().getMonth()-6)).toISOString(),mW="en-US",qqe="USD",zqe=y.memo(()=>{const e=navigator?navigator.languages||[navigator.language]:[mW],{data:t,isPending:n}=za("deals",{pagination:{perPage:100,page:1},sort:{field:"created_at",order:"ASC"},filter:{"created_at@gte":$qe}}),r=y.useMemo(()=>{if(!t)return[];const o=t.reduce((l,f)=>{const c=lP(f.created_at??new Date).toISOString();return l[c]||(l[c]=[]),l[c].push(f),l},{});return Object.keys(o).map(l=>({date:cc(l,"MMM"),won:o[l].filter(f=>f.stage==="won").reduce((f,c)=>(f+=c.amount,f),0),pending:o[l].filter(f=>!["won","lost"].includes(f.stage)).reduce((f,c)=>(f+=c.amount*Lqe[c.stage],f),0),lost:o[l].filter(f=>f.stage==="lost").reduce((f,c)=>(f-=c.amount,f),0)}))},[t]);if(n)return null;const a=r.reduce((o,s)=>(o.min=Math.min(o.min,s.lost),o.max=Math.max(o.max,s.won+s.pending),o),{min:0,max:0});return d.jsxs("div",{className:"flex flex-col",children:[d.jsxs("div",{className:"flex items-center mb-4",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(SQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Upcoming Deal Revenue"})]}),d.jsx("div",{className:"h-[400px]",children:d.jsx(Iqe,{data:r,indexBy:"date",keys:["won","pending","lost"],colors:["#61cdbb","#97e3d5","#e25c3b"],margin:{top:30,right:50,bottom:30,left:0},padding:.3,valueScale:{type:"linear",min:a.min*1.2,max:a.max*1.2},indexScale:{type:"band",round:!0},enableGridX:!0,enableGridY:!1,enableLabel:!1,tooltip:i(({value:o,indexValue:s})=>d.jsxs("div",{className:"p-2 bg-secondary rounded shadow inline-flex items-center gap-1 text-secondary-foreground",children:[d.jsxs("strong",{children:[s,": "]})," ",o>0?"+":"",o.toLocaleString(e.at(0)??mW,{style:"currency",currency:qqe})]}),"tooltip"),axisTop:{tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisBottom:{legendPosition:"middle",legendOffset:50,tickSize:0,tickPadding:12,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},axisLeft:null,axisRight:{format:i(o=>`${Math.abs(o/1e3)}k`,"format"),tickValues:8,style:{ticks:{text:{fill:"var(--color-muted-foreground)"}},legend:{text:{fill:"var(--color-muted-foreground)"}}}},markers:[{axis:"y",value:0,lineStyle:{strokeOpacity:0},textStyle:{fill:"#2ebca6"},legend:"Won",legendPosition:"top-left",legendOrientation:"vertical"},{axis:"y",value:0,lineStyle:{stroke:"#f47560",strokeWidth:1},textStyle:{fill:"#e25c3b"},legend:"Lost",legendPosition:"bottom-left",legendOrientation:"vertical"}]})})]})}),Uqe=i(e=>{const t=xt(),n=Ht(e),{filterValues:r,setFilters:a}=qw(e),o=fd();if(!n)throw new Error("<ListNoResults> must be used inside a <List> component");return d.jsx("div",{className:"p-6",children:d.jsx("p",{className:"text-sm text-muted-foreground",children:r&&a&&Object.keys(r).length>0?d.jsxs(d.Fragment,{children:[t("ra.navigation.no_filtered_results",{resource:n,name:o(n,0),_:"No results found with the current filters."})," ",d.jsx(ze,{variant:"outline",size:"sm",onClick:i(()=>a({},[]),"onClick"),children:t("ra.navigation.clear_filters",{_:"Clear filters"})})]}):t("ra.navigation.no_results",{resource:n,name:o(n,0),_:"No results found."})})})},"ListNoResults"),Bqe=i(e=>{const{children:t,linkType:n,rowClick:r,style:a}=e,o=Ht(e),s=Wt(e),l=Sa(),f=typeof n=="function"||typeof r=="function",c=QG({link:f?!1:n??r,resource:o}),p=JG(),m=Et(async()=>{if(!f||!s)return;const g=typeof n=="function"?n(s,s.id):typeof r=="function"?(w,S)=>r(w.id,S,w):!1,b=await p({record:s,resource:o,link:g});b===!1||b==null||l(b)});return s?f?d.jsx("li",{className:"w-full",children:d.jsx("button",{onClick:m,style:a,className:"w-full text-left hover:bg-muted focus: bg-muted focus:outline-none",children:t})}):c?d.jsx("li",{className:"w-full",children:d.jsx(fn,{to:c,style:a,className:"block w-full hover:bg-muted focus:bg-muted focus:outline-none",children:t})}):d.jsx("li",{className:"w-full",children:t}):null},"SimpleListItem"),fT=i(({className:e})=>d.jsx("span",{className:Se("bg-gray-300 flex",e),children:" "}),"ListPlaceholder"),Vqe=i(e=>{const{className:t,hasLeftAvatarOrIcon:n,hasRightAvatarOrIcon:r,hasSecondaryText:a,hasTertiaryText:o,nbFakeLines:s=5,...l}=e;return RK(1e3)?d.jsx("ul",{className:t,...l,children:Hqe(s,c=>d.jsxs("li",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"mb-1",children:[d.jsx(fT,{className:"w-1/3 inline-block mb-1"}),o&&d.jsx("span",{className:"float-right opacity-55 min-w-[10vw]",children:d.jsx(fT,{})})]}),a&&d.jsx(fT,{className:"w-1/4"})]}),r&&d.jsx("div",{className:"w-10 h-10 bg-gray-300 rounded-full flex-shrink-0",children:" "})]},c))}):null},"SimpleListLoading"),Hqe=i((e,t)=>Array.from({length:e},(n,r)=>t(r)),"times"),Wqe=i(e=>{const{className:t,empty:n=Kqe,leftAvatar:r,leftIcon:a,linkType:o,rowClick:s,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,resource:g,...b}=e,{data:w,isPending:S,total:_}=qw(e);return S===!0?d.jsx(Vqe,{className:t,hasLeftAvatarOrIcon:!!a||!!r,hasRightAvatarOrIcon:!!c||!!f,hasSecondaryText:!!p,hasTertiaryText:!!m}):w==null||w.length===0||_===0?n||null:d.jsx("ul",{className:t,...cme(b),children:d.jsx(vme,{data:w,total:_,render:i((j,E)=>d.jsx(Bqe,{rowIndex:E,linkType:o,rowClick:s,resource:g,children:d.jsx(Gqe,{leftAvatar:r,leftIcon:a,primaryText:l,rightAvatar:f,rightIcon:c,secondaryText:p,tertiaryText:m,rowIndex:E})},j.id),"render")})})},"SimpleList"),Gqe=i(e=>{const{leftAvatar:t,leftIcon:n,primaryText:r,rightAvatar:a,rightIcon:o,secondaryText:s,tertiaryText:l}=e,f=Ht(e),c=Wt(e),p=Ec(f),m=xt(),g=i((b,w)=>{const S=w(b,b.id);return typeof S=="string"&&(S.startsWith("http")||S.startsWith("data:"))?d.jsx("img",{src:S,alt:"",className:"w-10 h-10 rounded-full object-cover"}):d.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center text-sm",children:S})},"renderAvatar");return c?d.jsxs("div",{className:"flex items-center space-x-3 p-3",children:[n&&d.jsx("div",{className:"flex-shrink-0",children:n(c,c.id)}),t&&d.jsx("div",{className:"flex-shrink-0",children:g(c,t)}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"text-sm font-medium truncate",children:r?typeof r=="string"?m(r,{...c,_:r}):y.isValidElement(r)?r:r(c,c.id):p(c)}),!!l&&d.jsx("div",{className:"text-xs text-muted-foreground ml-2",children:typeof l=="string"?m(l,{...c,_:l}):y.isValidElement(l)?l:l(c,c.id)})]}),!!s&&d.jsx("div",{className:"text-sm text-muted-foreground truncate",children:typeof s=="string"?m(s,{...c,_:s}):y.isValidElement(s)?s:s(c,c.id)})]}),(a||o)&&d.jsxs("div",{className:"flex-shrink-0 flex items-center space-x-2",children:[a&&g(c,a),o&&o(c,c.id)]})]}):null},"SimpleListItemContent"),Kqe=d.jsx(Uqe,{}),Yqe=i(()=>{const{identity:e}=Zn(),{data:t,total:n,isPending:r}=za("contacts",{pagination:{page:1,perPage:10},sort:{field:"last_seen",order:"DESC"},filter:{status:"hot",sales_id:e?.id}},{enabled:Number.isInteger(e?.id)});return d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(IM,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"Hot Contacts"}),d.jsx(Pi,{children:d.jsxs(ao,{children:[d.jsx(io,{asChild:!0,children:d.jsx(ze,{variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground",asChild:!0,children:d.jsx(fn,{to:"/contacts/create",children:d.jsx(Ji,{className:"w-4 h-4 text-primary"})})})}),d.jsx(oo,{children:"Create contact"})]})})]}),d.jsx(pn,{className:"py-0",children:d.jsx(Wqe,{linkType:"show",data:t,total:n,isPending:r,resource:"contacts",className:"[&>li:first-child>a]:rounded-t-xl [&>li:last-child>a]:rounded-b-xl",primaryText:i(a=>`${a.first_name} ${a.last_name}`,"primaryText"),secondaryText:i(a=>d.jsxs(d.Fragment,{children:[a.title," at ",a.company_name]}),"secondaryText"),leftAvatar:i(a=>d.jsx(is,{record:a}),"leftAvatar"),empty:d.jsxs("div",{className:"p-4",children:[d.jsx("p",{className:"text-sm mb-4",children:'Contacts with a "hot" status will appear here.'}),d.jsx("p",{className:"text-sm",children:'Change the status of a contact by adding a note to that contact and clicking on "show options".'})]})})})]})},"HotContacts"),Qqe=i(()=>{const{identity:e}=Zn(),{total:t}=za("tasks",{pagination:{page:1,perPage:1},filter:{sales_id:e?.id}},{enabled:!!e});return t?null:d.jsx("p",{className:"text-sm",children:"Tasks added to your contacts will appear here."})},"TasksListEmpty"),uv=i(({title:e,filter:t})=>{const{identity:n}=Zn(),{data:r,total:a,isPending:o}=za("tasks",{pagination:{page:1,perPage:100},sort:{field:"due_date",order:"ASC"},filter:{...t,sales_id:n?.id}},{enabled:!!n}),s=zw({data:r,isPending:o,resource:"tasks",perPage:5});return o||!r||!a?null:d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground font-medium mb-2",children:e}),d.jsx(dd,{value:"tasks",children:d.jsx(ny,{value:s,children:d.jsx(jne,{showContact:!0})})}),a>s.perPage&&d.jsx("div",{className:"flex justify-center",children:d.jsx("a",{href:"#",onClick:i(l=>{s.setPerPage(s.perPage+10),l.preventDefault()},"onClick"),className:"text-sm underline hover:no-underline",children:"Load more"})})]})},"TasksListFilter"),tie=new Date,Xqe=K0e(tie),Zqe=Xqe<5,vW=Q0e().toISOString(),gW=Gye().toISOString(),yW=Kye().toISOString(),bW=Wye(tie,{weekStartsOn:0}).toISOString(),dv={overdue:{"done_date@is":null,"due_date@lt":vW},today:{"done_date@is":null,"due_date@gte":vW,"due_date@lte":gW},tomorrow:{"done_date@is":null,"due_date@gt":gW,"due_date@lt":yW},thisWeek:{"done_date@is":null,"due_date@gte":yW,"due_date@lte":bW},later:{"done_date@is":null,"due_date@gt":bW}},Jqe=i(()=>d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center",children:[d.jsx("div",{className:"mr-3 flex",children:d.jsx(kQ,{className:"text-muted-foreground w-6 h-6"})}),d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground flex-1",children:"Upcoming Tasks"}),d.jsx(Sne,{display:"icon",selectContact:!0})]}),d.jsx(pn,{className:"p-4 mb-2",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsx(Qqe,{}),d.jsx(uv,{title:"Overdue",filter:dv.overdue}),d.jsx(uv,{title:"Today",filter:dv.today}),d.jsx(uv,{title:"Tomorrow",filter:dv.tomorrow}),Zqe&&d.jsx(uv,{title:"This week",filter:dv.thisWeek}),d.jsx(uv,{title:"Later",filter:dv.later})]})})]}),"TasksList"),eze=i(()=>{const{data:e,total:t,isPending:n}=za("contacts",{pagination:{page:1,perPage:1}}),{total:r,isPending:a}=za("contactNotes",{pagination:{page:1,perPage:1}}),{total:o,isPending:s}=za("deals",{pagination:{page:1,perPage:1}});return n||a||s?null:t?r?d.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6 mt-1",children:[d.jsx("div",{className:"md:col-span-3",children:d.jsxs("div",{className:"flex flex-col gap-4",children:[null,d.jsx(Yqe,{})]})}),d.jsx("div",{className:"md:col-span-6",children:d.jsxs("div",{className:"flex flex-col gap-6",children:[o?d.jsx(zqe,{}):null,d.jsx(Z5e,{})]})}),d.jsx("div",{className:"md:col-span-3",children:d.jsx(Jqe,{})})]}):d.jsx(bV,{step:2,contactId:e?.[0]?.id}):d.jsx(bV,{step:1})},"Dashboard"),tze=y.lazy(()=>Fp(()=>import("./DealList-Bfe4r2OW.js"),[],import.meta.url)),nze={list:tze},rze=y.createContext(void 0),G_=i(()=>y.useContext(rze),"useUserMenu"),aze=i(()=>{const{darkModeLogo:e,lightModeLogo:t,title:n}=Va(),r=Dr(),o=[{path:"/",pattern:"/"},{path:"/contacts",pattern:"/contacts/*"},{path:"/companies",pattern:"/companies/*"},{path:"/deals",pattern:"/deals/*"}].find(s=>tp(s.pattern,r.pathname))?.path||!1;return d.jsx("header",{className:"bg-secondary fixed top-0 left-0 right-0 z-50 border-b border-border",children:d.jsx("div",{className:"px-4",children:d.jsxs("div",{className:"flex justify-between items-center flex-1",children:[d.jsx(ize,{darkLogo:e,lightLogo:t,title:n}),d.jsxs("nav",{className:"flex","aria-label":"Main navigation",children:[d.jsx(Eb,{label:"Dashboard",to:"/",isActive:o==="/"}),d.jsx(Eb,{label:"Contacts",to:"/contacts",isActive:o==="/contacts"}),d.jsx(Eb,{label:"Companies",to:"/companies",isActive:o==="/companies"}),d.jsx(Eb,{label:"Deals",to:"/deals",isActive:o==="/deals"})]}),d.jsxs("div",{className:"flex items-center",children:[d.jsx(MZ,{}),d.jsx(IZ,{}),d.jsxs(PZ,{children:[d.jsx(sze,{}),d.jsx(lze,{}),d.jsx(cze,{}),d.jsx(Pge,{resource:"sales",action:"list",children:d.jsx(oze,{})}),d.jsx(ng,{}),d.jsx(l4,{className:"font-normal",children:d.jsxs("div",{className:"text-xs text-muted-foreground",children:["Version ","0.9.10"]})})]})]})]})})})},"Header"),ize=i(({darkLogo:e,lightLogo:t,title:n})=>d.jsxs(fn,{to:"/",className:"flex items-center gap-2 text-secondary-foreground no-underline hover:opacity-80 transition-opacity",children:[d.jsx("img",{className:"[.light_&]:hidden h-6",src:e,alt:`${n} logo`}),d.jsx("img",{className:"[.dark_&]:hidden h-6",src:t,alt:`${n} logo`}),d.jsx("h1",{className:"text-xl font-semibold",children:n})]}),"Logo"),Eb=i(({label:e,to:t,isActive:n})=>d.jsx(fn,{to:t,className:`px-6 py-3 text-sm font-medium transition-colors border-b-2 ${n?"text-secondary-foreground border-secondary-foreground":"text-secondary-foreground/70 border-transparent hover:text-secondary-foreground/80"}`,children:e}),"NavigationTab"),oze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/sales",className:"flex items-center gap-2",children:[d.jsx(TQ,{className:"h-4 w-4"}),"Users"]})})},"UsersMenu"),sze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/settings",className:"flex items-center gap-2",children:[d.jsx(dP,{className:"h-4 w-4"}),"My info"]})})},"ConfigurationMenu"),lze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/database",className:"flex items-center gap-2",children:[d.jsx(Qv,{className:"h-4 w-4"}),"Database"]})})},"DatabaseMenu"),cze=i(()=>{const{onClose:e}=G_()??{};return d.jsx(sr,{asChild:!0,onClick:e,children:d.jsxs(fn,{to:"/integrations",className:"flex items-center gap-2",children:[d.jsx(u_e,{className:"h-4 w-4"}),"Integrations"]})})},"IntegrationsMenu"),uze=i(({children:e})=>d.jsxs(d.Fragment,{children:[d.jsx(aze,{}),d.jsx("main",{className:"max-w-screen-xl mx-auto pt-20 px-4",id:"main-content",children:d.jsx(hx,{FallbackComponent:FZ,children:d.jsx(y.Suspense,{fallback:d.jsx(sn,{className:"h-12 w-12 rounded-full"}),children:e})})}),d.jsx(R1,{})]}),"Layout"),nie=i(()=>d.jsx("div",{className:"max-w-screen-xl mx-auto h-screen pt-8",children:d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-8",children:[d.jsx(sn,{className:"w-full h-[100px]"}),d.jsx(sn,{className:"w-4/5 h-[50px]"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-full h-9"}),d.jsx(sn,{className:"w-2/5 h-9"})]})})}),"LoginSkeleton"),aD=i(()=>{const e=Pn(),t=_n(),{darkModeLogo:n,title:r}=Va(),{data:a,isPending:o}=Qr({queryKey:["init"],queryFn:i(async()=>t.isInitialized(),"queryFn")}),{isPending:s,mutate:l}=Yr({mutationKey:["signup"],mutationFn:i(async w=>t.signUp(w),"mutationFn"),onSuccess:i(w=>{f({email:w.email,password:w.password,redirectTo:"/contacts"}).then(()=>{c("Initial user successfully created"),e.invalidateQueries({queryKey:["auth","canAccess"]})})},"onSuccess"),onError:i(()=>{c("An error occurred. Please try again.")},"onError")}),f=xY(),c=Vt(),{register:p,handleSubmit:m,formState:{isValid:g}}=iy({mode:"onChange"});if(o)return d.jsx(nie,{});if(a)return d.jsx(gw,{to:"/login"});const b=i(async w=>{l(w)},"onSubmit");return d.jsxs("div",{className:"h-screen p-8",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("img",{src:n,alt:r,width:24,className:"filter brightness-0 invert"}),d.jsx("h1",{className:"text-xl font-semibold",children:r})]}),d.jsx("div",{className:"h-full",children:d.jsxs("div",{className:"max-w-sm mx-auto h-full flex flex-col justify-center gap-4",children:[d.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Welcome to CRM"}),d.jsx("p",{className:"text-base mb-4",children:"Create the first user account to complete the setup."}),d.jsxs("form",{onSubmit:m(b),className:"space-y-4",children:[d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"first_name",children:"First name"}),d.jsx(_r,{...p("first_name",{required:!0}),id:"first_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"last_name",children:"Last name"}),d.jsx(_r,{...p("last_name",{required:!0}),id:"last_name",type:"text",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"email",children:"Email"}),d.jsx(_r,{...p("email",{required:!0}),id:"email",type:"email",required:!0})]}),d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsx(Hn,{htmlFor:"password",children:"Password"}),d.jsx(_r,{...p("password",{required:!0}),id:"password",type:"password",required:!0})]}),d.jsx("div",{className:"flex justify-between items-center mt-8",children:d.jsx(ze,{type:"submit",disabled:!g||s,className:"w-full",children:s?d.jsxs(d.Fragment,{children:[d.jsx(Oc,{className:"w-4 h-4 animate-spin mr-2"}),"Creating..."]}):"Create account"})})]})]})})]})},"SignupPage");aD.path="/sign-up";const dze=i((e,t)=>e==="admin"?!0:t.resource!=="sales","canAccess"),hT=tAe(Bn,{getIdentity:i(async()=>{const e=await rie();if(e==null)throw new Error;return{id:e.id,fullName:`${e.first_name} ${e.last_name}`,avatar:e.avatar?.src}},"getIdentity")});async function Ws(){if(Ws._is_initialized_cache==null){const{data:e}=await Bn.from("init_state").select("is_initialized");Ws._is_initialized_cache=e?.at(0)?.is_initialized>0}return Ws._is_initialized_cache}i(Ws,"getIsInitialized");(e=>{e._is_initialized_cache=null})(Ws||(Ws={}));const fze={...hT,login:i(async e=>{const t=await hT.login(e);return qb=void 0,t},"login"),checkAuth:i(async e=>{if(window.location.pathname==="/set-password"||window.location.hash.includes("#/set-password")||window.location.pathname==="/forgot-password"||window.location.hash.includes("#/forgot-password")||window.location.pathname==="/change-password"||window.location.hash.includes("#/change-password")||window.location.pathname==="/otp-login"||window.location.hash.includes("#/otp-login")||window.location.pathname==="/sign-up"||window.location.hash.includes("#/sign-up"))return;if(!await Ws())throw await Bn.auth.signOut(),{redirectTo:"/sign-up",message:!1};return hT.checkAuth(e)},"checkAuth"),canAccess:i(async e=>{if(!await Ws())return!1;const n=await rie();if(n==null)return!1;const r=n.administrator?"admin":"user";return dze(r,e)},"canAccess")};let qb;const rie=i(async()=>{if(qb!=null)return qb;const{data:e,error:t}=await Bn.auth.getSession();if(e?.session?.user==null||t)return;const{data:n,error:r}=await Bn.from("sales").select("id, first_name, last_name, avatar, administrator").match({user_id:e?.session?.user.id}).single();if(!(n==null||r))return qb=n,n},"getSaleFromCache");async function hze(e,t,n){const r={};t&&(r.id=t);const a={};t&&(a.company_id=t);const[o,s,l]=await Promise.all([pze(e,r),mze(e,a),vze(e,a)]);return[...o,...s,...l].sort((f,c)=>f.date&&c.date?f.date.localeCompare(c.date)*-1:0).slice(0,250)}i(hze,"getActivityLog");const pze=i(async(e,t)=>{const{data:n}=await e.getList("companies",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}});return n.map(r=>({id:`company.${r.id}.created`,type:jte,company_id:r.id,company:r,sales_id:r.sales_id,date:r.created_at}))},"getNewCompanies");async function mze(e,t){const{data:n}=await e.getList("contacts",{filter:t,pagination:{page:1,perPage:250},sort:{field:"first_seen",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["contact_id@in"]=`(${l})`}const{data:a}=await e.getList("contactNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`contact.${l.id}.created`,type:Ete,company_id:l.company_id,sales_id:l.sales_id,contact:l,date:l.first_seen})),s=a.map(l=>({id:`contactNote.${l.id}.created`,type:Cte,sales_id:l.sales_id,contactNote:l,date:l.date}));return[...o,...s]}i(mze,"getNewContactsAndNotes");async function vze(e,t){const{data:n}=await e.getList("deals",{filter:t,pagination:{page:1,perPage:250},sort:{field:"created_at",order:"DESC"}}),r={};if(t.sales_id&&(r.sales_id=t.sales_id),t.company_id){const l=n.map(f=>f.id).join(",");r["deal_id@in"]=`(${l})`}const{data:a}=await e.getList("dealNotes",{filter:r,pagination:{page:1,perPage:250},sort:{field:"date",order:"DESC"}}),o=n.map(l=>({id:`deal.${l.id}.created`,type:Ote,company_id:l.company_id,sales_id:l.sales_id,deal:l,date:l.created_at})),s=a.map(l=>({id:`dealNote.${l.id}.created`,type:kte,sales_id:l.sales_id,dealNote:l,date:l.date}));return[...o,...s]}i(vze,"getNewDealsAndNotes");async function gze(e){return e.website?{src:`https://favicon.show/${e.website.replace(/^https?:\/\//,"").replace(/\/$/,"")}`,title:"Company favicon"}:null}i(gze,"getCompanyAvatar");async function yze(e,t={}){const{timeout:n=2e3}=t,r=new AbortController,a=setTimeout(()=>r.abort(),n),o=await fetch(e,{...t,signal:r.signal});return clearTimeout(a),o}i(yze,"fetchWithTimeout");const bze=["gmail.com","yahoo.com","hotmail.com","aol.com","hotmail.co.uk","hotmail.fr","msn.com","yahoo.fr","wanadoo.fr","orange.fr","comcast.net","yahoo.co.uk","yahoo.com.br","yahoo.co.in","live.com","rediffmail.com","free.fr","gmx.de","web.de","yandex.ru","ymail.com","libero.it","outlook.com","uol.com.br","bol.com.br","mail.ru","cox.net","hotmail.it","sbcglobal.net","sfr.fr","live.fr","verizon.net","live.co.uk","googlemail.com","yahoo.es","ig.com.br","live.nl","bigpond.com","terra.com.br","yahoo.it","neuf.fr","yahoo.de","alice.it","rocketmail.com","att.net","laposte.net","facebook.com","bellsouth.net","yahoo.in","hotmail.es","charter.net","yahoo.ca","yahoo.com.au","rambler.ru","hotmail.de","tiscali.it","shaw.ca","yahoo.co.jp","sky.com","earthlink.net","optonline.net","freenet.de","t-online.de","aliceadsl.fr","virgilio.it","home.nl","qq.com","telenet.be","me.com","yahoo.com.ar","tiscali.co.uk","yahoo.com.mx","voila.fr","gmx.net","mail.com","planet.nl","tin.it","live.it","ntlworld.com","arcor.de","yahoo.co.id","frontiernet.net","hetnet.nl","live.com.au","yahoo.com.sg","zonnet.nl","club-internet.fr","juno.com","optusnet.com.au","blueyonder.co.uk","bluewin.ch","skynet.be","sympatico.ca","windstream.net","mac.com","centurytel.net","chello.nl","live.ca","aim.com","bigpond.net.au","online.de","apple.com"];async function xze(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(xze,"hash");async function wze(e){return`https://www.gravatar.com/avatar/${await xze(e)}?d=404`}i(wze,"getGravatarUrl");async function _ze(e){if(bze.includes(e))return null;try{const t=`https://${e}/favicon.ico`;if((await yze(t)).ok)return t}catch{return null}return null}i(_ze,"getFaviconUrl");async function Sze(e){if(!e.email_jsonb||!e.email_jsonb.length)return null;for(const{email:t}of e.email_jsonb){const n=await wze(t);try{if((await fetch(n)).ok)return n}catch{}const r=t.split("@")[1],a=await _ze(r);if(a)return a}return null}i(Sze,"getContactAvatar");const xW=xd()||{url:"https://placeholder.supabase.co",anonKey:"placeholder-key"},So=bAe({instanceUrl:xW.url,apiKey:xW.anonKey,supabaseClient:Bn,sortOrder:"asc,desc.nullslast"}),wW=i(async e=>{let t=e.data.logo;return typeof t!="object"||t===null||!t.src?t=await gze(e.data):t.rawFile instanceof File&&await zb(t),{...e,data:{...e.data,logo:t}}},"processCompanyLogo");async function _W(e){const{data:t}=e;if(t.avatar?.src||!t.email_jsonb||!t.email_jsonb.length)return e;const n=await Sze(t),r={...t,avatar:{src:n||void 0}};return{...e,data:r}}i(_W,"processContactAvatar");const jze={...So,async getList(e,t){return e==="companies"?So.getList("companies_summary",t):e==="contacts"?So.getList("contacts_summary",t):So.getList(e,t)},async getOne(e,t){return e==="companies"?So.getOne("companies_summary",t):e==="contacts"?So.getOne("contacts_summary",t):So.getOne(e,t)},async signUp({email:e,password:t,first_name:n,last_name:r}){const{data:a,error:o}=await Bn.functions.invoke("setup",{method:"POST",body:{email:e,password:t,first_name:n,last_name:r}});if(!a||o)throw console.error("signUp.error",o),new Error("Failed to create account");return Ws._is_initialized_cache=!0,{id:a.data.id,email:e,password:t}},async salesCreate(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"POST",body:e});if(!t||n)throw console.error("salesCreate.error",n),new Error("Failed to create account manager");return t},async salesUpdate(e,t){const{email:n,first_name:r,last_name:a,administrator:o,avatar:s,disabled:l}=t,{data:f,error:c}=await Bn.functions.invoke("users",{method:"PATCH",body:{sales_id:e,email:n,first_name:r,last_name:a,administrator:o,disabled:l,avatar:s}});if(!f||c)throw console.error("salesCreate.error",c),new Error("Failed to update account manager");return t},async resendInvite(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"invite"}});if(!t||n)throw console.error("resendInvite.error",n),new Error("Failed to resend invitation");return t},async resetPassword(e){const{data:t,error:n}=await Bn.functions.invoke("users",{method:"PUT",body:{sales_id:e,action:"reset"}});if(!t||n)throw console.error("resetPassword.error",n),new Error("Failed to send password reset");return t},async updatePassword(e){const{data:t,error:n}=await Bn.functions.invoke("updatePassword",{method:"PATCH",body:{sales_id:e}});if(!t||n)throw console.error("passwordUpdate.error",n),new Error("Failed to update password");return t},async unarchiveDeal(e){const{data:t}=await So.getList("deals",{filter:{stage:e.stage},pagination:{page:1,perPage:1e3},sort:{field:"index",order:"ASC"}}),n=t.map((r,a)=>({...r,index:r.id===e.id?0:a+1,archived_at:r.id===e.id?null:r.archived_at}));return await Promise.all(n.map(r=>So.update("deals",{id:r.id,data:r,previousData:t.find(a=>a.id===r.id)})))},async getActivityLog(e){return hze(So,e)},async isInitialized(){return Ws()},async mergeContacts(e,t){const{data:n,error:r}=await Bn.functions.invoke("mergeContacts",{method:"POST",body:{loserId:e,winnerId:t}});if(r)throw console.error("mergeContacts.error",r),new Error("Failed to merge contacts");return n}},Eze=bhe(jze,[{resource:"contactNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await zb(r);return e},"beforeSave")},{resource:"dealNotes",beforeSave:i(async(e,t,n)=>{if(e.attachments)for(const r of e.attachments)await zb(r);return e},"beforeSave")},{resource:"sales",beforeSave:i(async(e,t,n)=>(e.avatar&&await zb(e.avatar),e),"beforeSave")},{resource:"contacts",beforeCreate:i(async e=>_W(e),"beforeCreate"),beforeUpdate:i(async e=>_W(e),"beforeUpdate"),beforeGetList:i(async e=>Cb(["first_name","last_name","company_name","title","email","phone","background"])(e),"beforeGetList")},{resource:"companies",beforeGetList:i(async e=>Cb(["name","phone_number","website","zipcode","city","stateAbbr"])(e),"beforeGetList"),beforeCreate:i(async e=>{const t=await wW(e);return{...t,data:{...t.data,created_at:new Date().toISOString()}}},"beforeCreate"),beforeUpdate:i(async e=>await wW(e),"beforeUpdate")},{resource:"contacts_summary",beforeGetList:i(async e=>Cb(["first_name","last_name"])(e),"beforeGetList")},{resource:"deals",beforeGetList:i(async e=>Cb(["name","type","description"])(e),"beforeGetList")}]),Cb=i(e=>t=>{if(!t.filter?.q)return t;const{q:n,...r}=t.filter;return{...t,filter:{...r,"@or":e.reduce((a,o)=>o==="email"?{...a,"email_fts@ilike":n}:o==="phone"?{...a,"phone_fts@ilike":n}:{...a,[`${o}@ilike`]:n},{})}}},"applyFullTextSearch"),zb=i(async e=>{if(!e.src.startsWith("blob:")&&!e.src.startsWith("data:")&&e.path){const{error:c}=await Bn.storage.from("attachments").createSignedUrl(e.path,60);if(!c)return}const t=e.src?await fetch(e.src).then(c=>c.blob()):e.rawFile,n=e.rawFile,r=n.name.split(".").pop(),o=`${`${Math.random()}.${r}`}`,{error:s}=await Bn.storage.from("attachments").upload(o,t);if(s)throw console.error("uploadError",s),new Error("Failed to upload attachment");const{data:l}=Bn.storage.from("attachments").getPublicUrl(o);e.path=o,e.src=l.publicUrl;const f=n.type;return e.type=f,e},"uploadToBucket");function aie(){const{identity:e}=Zn(),t=Wt();return d.jsxs("div",{className:"space-y-4 w-full",children:[d.jsx(ln,{source:"first_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"last_name",validate:nr(),helperText:!1}),d.jsx(ln,{source:"email",validate:[nr(),JK()],helperText:!1}),d.jsx(CN,{source:"administrator",readOnly:t?.id===e?.id,helperText:!1}),d.jsx(CN,{source:"disabled",readOnly:t?.id===e?.id,helperText:!1})]})}i(aie,"SalesInputs");function Cze(){const e=_n(),t=Vt(),n=rs(),{mutate:r}=Yr({mutationKey:["signup"],mutationFn:i(async o=>e.salesCreate(o),"mutationFn"),onSuccess:i(()=>{t("User created. They will soon receive an email to set their password."),n("/sales")},"onSuccess"),onError:i(()=>{t("An error occurred while creating the user.",{type:"error"})},"onError")}),a=i(async o=>{r(o)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsxs(pn,{children:[d.jsx(Qo,{children:d.jsx(Xo,{children:"Create a new user"})}),d.jsx(Wn,{children:d.jsx(pee,{onSubmit:a,children:d.jsx(aie,{})})})]})})}i(Cze,"SalesCreate");function Oze(){return d.jsxs("div",{className:"flex justify-end gap-4",children:[d.jsx($1,{}),d.jsx(yd,{})]})}i(Oze,"EditToolbar");function kze(){const{record:e}=EK(),t=_n(),n=Vt(),r=rs(),{mutate:a}=Yr({mutationKey:["signup"],mutationFn:i(async s=>{if(!e)throw new Error("Record not found");return t.salesUpdate(e.id,s)},"mutationFn"),onSuccess:i(()=>{r("/sales"),n("User updated successfully")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")}),o=i(async s=>{a(s)},"onSubmit");return d.jsx("div",{className:"max-w-lg w-full mx-auto mt-8",children:d.jsx(pn,{children:d.jsx(Wn,{children:d.jsxs(pee,{toolbar:d.jsx(Oze,{}),onSubmit:o,record:e,children:[d.jsx(Rze,{}),d.jsx(aie,{})]})})})})}i(kze,"SalesEdit");const Rze=i(()=>{const e=Wt();return e?d.jsxs("h2",{className:"text-lg font-semibold mb-4",children:["Edit ",e?.first_name," ",e?.last_name]}):null},"SaleEditTitle"),Aze=i(()=>d.jsxs(_4,{children:[d.jsx(P1,{}),d.jsx(Pc,{label:"New user"})]}),"SalesListActions"),Tze=[d.jsx(S4,{source:"q",alwaysOn:!0})],Pze=i(e=>{const t=Wt();return t?d.jsxs("div",{className:"flex flex-row gap-1",children:[t.administrator&&d.jsx(Pr,{variant:"outline",className:"border-blue-300 dark:border-blue-700",children:"Admin"}),t.disabled&&d.jsx(Pr,{variant:"outline",className:"border-orange-300 dark:border-orange-700",children:"Disabled"})]}):null},"OptionsField"),Nze=i(()=>{const e=Wt(),t=_n(),n=Vt(),r=Nw(),[a,o]=y.useState(!1),[s,l]=y.useState(!1),{mutate:f,isPending:c}=Yr({mutationFn:i(async()=>t.resendInvite(e.id),"mutationFn"),onSuccess:i(()=>{n("Invitation email resent successfully"),o(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to resend invitation email",{type:"error"}),o(!1)},"onError")}),{mutate:p,isPending:m}=Yr({mutationFn:i(async()=>t.resetPassword(e.id),"mutationFn"),onSuccess:i(()=>{n("Password reset email sent successfully"),l(!1),r()},"onSuccess"),onError:i(()=>{n("Failed to send password reset email",{type:"error"}),l(!1)},"onError")});if(!e)return null;const g=e.email_confirmed_at!==null,b=e.disabled===!0;return console.log("[RowActions] Record:",{email:e.email,email_confirmed_at:e.email_confirmed_at,isConfirmed:g,isDisabled:b,inviteDialogOpen:a,resetDialogOpen:s}),d.jsxs(d.Fragment,{children:[d.jsxs(Ac,{children:[d.jsx(Qs,{asChild:!0,children:d.jsxs(ze,{variant:"ghost",className:"h-8 w-8 p-0",children:[d.jsx("span",{className:"sr-only",children:"Open menu"}),d.jsx(PM,{className:"h-4 w-4"})]})}),d.jsxs(Tc,{align:"end",children:[d.jsx(l4,{children:"Email Actions"}),d.jsx(ng,{}),!g&&d.jsxs(sr,{onClick:i(w=>{w.preventDefault(),w.stopPropagation(),console.log("[Menu] Clicked Resend Invite"),o(!0)},"onClick"),children:[d.jsx(A1e,{className:"mr-2 h-4 w-4"}),"Resend Invite"]}),g&&!b&&d.jsxs(sr,{onClick:i(()=>l(!0),"onClick"),children:[d.jsx(Xwe,{className:"mr-2 h-4 w-4"}),"Send Password Reset"]})]})]}),d.jsx(wa,{open:a,onOpenChange:o,children:d.jsxs(_a,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Resend Invitation"}),d.jsxs(Oi,{children:["Send a new invitation email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a fresh invitation link to set up their account."]})]}),d.jsxs(Yo,{children:[d.jsx(ze,{variant:"outline",onClick:i(w=>{w.stopPropagation(),o(!1)},"onClick"),disabled:c,children:"Cancel"}),d.jsx(ze,{onClick:i(w=>{w.stopPropagation(),f()},"onClick"),disabled:c,children:c?"Sending...":"Send Invitation"})]})]})}),d.jsx(wa,{open:s,onOpenChange:l,children:d.jsxs(_a,{onClick:i(w=>w.stopPropagation(),"onClick"),onPointerDown:i(w=>w.stopPropagation(),"onPointerDown"),children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Send Password Reset"}),d.jsxs(Oi,{children:["Send a password reset email to ",d.jsx("strong",{children:e.email}),"?",d.jsx("br",{}),d.jsx("br",{}),"This will send them a link to reset their password."]})]}),d.jsxs(Yo,{children:[d.jsx(ze,{variant:"outline",onClick:i(w=>{w.stopPropagation(),l(!1)},"onClick"),disabled:m,children:"Cancel"}),d.jsx(ze,{onClick:i(w=>{w.stopPropagation(),p()},"onClick"),disabled:m,children:m?"Sending...":"Send Reset Link"})]})]})})]})},"RowActions");function Dze(){return d.jsx(b4,{filters:Tze,actions:d.jsx(Aze,{}),sort:{field:"first_name",order:"ASC"},children:d.jsx(Mze,{})})}i(Dze,"SalesList");const Mze=i(()=>{const{data:e,isPending:t,filterValues:n}=Gn(),{identity:r}=Zn(),a=n&&Object.keys(n).length>0;return!r||t?d.jsx(pn,{className:"p-4",children:d.jsxs("div",{className:"space-y-3",children:[d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"}),d.jsx(sn,{className:"h-12 w-full"})]})}):!e?.length&&!a?d.jsx(Ize,{}):d.jsxs(Fs,{children:[d.jsx(Fs.Col,{source:"first_name"}),d.jsx(Fs.Col,{source:"last_name"}),d.jsx(Fs.Col,{source:"email"}),d.jsx(Fs.Col,{label:!1,children:d.jsx(Pze,{})}),d.jsx(Fs.Col,{label:!1,children:d.jsx(Nze,{})})]})},"SalesListLayout"),Ize=i(()=>{const e=F1();return d.jsxs("div",{className:"flex flex-col justify-center items-center gap-3",style:{height:`calc(100dvh - ${e}px)`},children:[d.jsx("img",{src:"./img/empty.svg",alt:"No users found"}),d.jsxs("div",{className:"flex flex-col gap-0 items-center",children:[d.jsx("h6",{className:"text-lg font-bold",children:"No users found"}),d.jsx("p",{className:"text-sm text-muted-foreground text-center mb-4",children:"It seems your user list is empty."})]}),d.jsx("div",{className:"flex flex-row gap-2",children:d.jsx(Pc,{label:"New user"})})]})},"SalesEmpty"),Fze={list:Dze,create:Cze,edit:kze,recordRepresentation:i(e=>`${e.first_name} ${e.last_name}`,"recordRepresentation")};function iie({open:e,onComplete:t,canClose:n=!1}){const[r,a]=y.useState("welcome"),[o,s]=y.useState(""),[l,f]=y.useState(""),[c,p]=y.useState(null),m=i(async()=>{p(null),a("validating");const b=await XRe(o,l);b.valid?(KRe({url:o,anonKey:l}),a("success"),setTimeout(()=>{window.location.href=window.location.origin},1500)):(p(b.error||"Connection failed"),a("credentials"))},"handleValidateAndSave"),g=i(()=>{n&&t()},"handleClose");return d.jsx(wa,{open:e,onOpenChange:n?g:void 0,children:d.jsxs(_a,{className:"sm:max-w-md",onPointerDownOutside:i(b=>!n&&b.preventDefault(),"onPointerDownOutside"),onEscapeKeyDown:i(b=>!n&&b.preventDefault(),"onEscapeKeyDown"),children:[r==="welcome"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[d.jsx(Qv,{className:"h-6 w-6 text-primary"}),d.jsx(Gr,{children:"Welcome to CRM"})]}),d.jsx(Oi,{children:"To get started, you'll need to connect to a Supabase database."})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[d.jsx(ai,{children:d.jsxs(ki,{children:[d.jsx("strong",{children:"Don't have a Supabase project?"}),d.jsx("br",{}),"Create one for free at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline text-primary",children:"supabase.com"})]})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"font-medium text-sm",children:"What you'll need:"}),d.jsxs("ul",{className:"list-disc list-inside text-sm text-muted-foreground space-y-1",children:[d.jsx("li",{children:"Your Supabase project URL"}),d.jsx("li",{children:"Your anonymous (anon) API key"})]})]}),d.jsx(ze,{onClick:i(()=>a("credentials"),"onClick"),className:"w-full",children:"Continue"})]})]}),r==="credentials"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Connect to Supabase"}),d.jsx(Oi,{children:"Enter your Supabase project credentials"})]}),d.jsxs("div",{className:"space-y-4 py-4",children:[c&&d.jsxs(ai,{variant:"destructive",children:[d.jsx(Ap,{className:"h-4 w-4"}),d.jsx(ki,{children:c})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"supabase-url",children:"Supabase URL"}),d.jsx(_r,{id:"supabase-url",placeholder:"https://xxxxx.supabase.co",value:o,onChange:i(b=>s(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"anon-key",children:"Anonymous Key"}),d.jsx(_r,{id:"anon-key",type:"password",placeholder:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",value:l,onChange:i(b=>f(b.target.value),"onChange")}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Found in Project Settings → API → Project API keys"})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ze,{variant:"outline",onClick:i(()=>a("welcome"),"onClick"),className:"flex-1",children:"Back"}),d.jsx(ze,{onClick:m,disabled:!o||!l,className:"flex-1",children:"Connect"})]})]})]}),r==="validating"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Validating Connection"}),d.jsx(Oi,{children:"Testing your Supabase credentials..."})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Oc,{className:"h-12 w-12 animate-spin text-primary mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait..."})]})]}),r==="success"&&d.jsxs(d.Fragment,{children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:"Connection Successful!"}),d.jsx(Oi,{children:"Your Supabase database is now connected"})]}),d.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[d.jsx(Fo,{className:"h-12 w-12 text-green-500 mb-4"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Reloading application..."})]})]})]})})}i(iie,"SupabaseSetupWizard");function Lze(){const[e,t]=y.useState(!1),n=xd(),r=ZRe(),a=i(()=>{confirm("Are you sure you want to clear the database configuration? The app will need to be reconfigured on next launch.")&&(YRe(),window.location.reload())},"handleClearConfig");return d.jsxs(d.Fragment,{children:[d.jsxs(pn,{children:[d.jsxs(Qo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Qv,{className:"h-5 w-5"}),d.jsx(Xo,{children:"Database Connection"})]}),d.jsx(w4,{children:"Manage your Supabase database connection settings"})]}),d.jsx(Wn,{className:"space-y-4",children:n?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border rounded-lg",children:[d.jsx(Fo,{className:"h-5 w-5 text-green-500 mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:n.url}),n.configuredAt&&d.jsxs("p",{className:"text-xs text-muted-foreground",children:["Configured on"," ",new Date(n.configuredAt).toLocaleDateString()]})]})]}),r==="env"&&d.jsxs(ai,{children:[d.jsx(dP,{className:"h-4 w-4"}),d.jsx(ki,{children:"Using configuration from environment variables. You can override this by setting up a new connection via the UI."})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs(ze,{variant:"outline",onClick:i(()=>t(!0),"onClick"),className:"flex-1",children:[d.jsx(dP,{className:"h-4 w-4 mr-2"}),"Change Connection"]}),r==="ui"&&d.jsxs(ze,{variant:"destructive",onClick:a,className:"flex-1",children:[d.jsx(cy,{className:"h-4 w-4 mr-2"}),"Clear Configuration"]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx($ze,{className:"text-sm font-medium",children:"Anonymous Key"}),d.jsxs("div",{className:"font-mono text-sm p-2 bg-muted rounded",children:[n.anonKey.substring(0,20),"...",n.anonKey.substring(n.anonKey.length-10)]})]})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"flex items-start gap-3 p-4 border border-dashed rounded-lg",children:[d.jsx(al,{className:"h-5 w-5 text-destructive mt-0.5"}),d.jsxs("div",{className:"flex-1 space-y-1",children:[d.jsx("p",{className:"font-medium",children:"Not Connected"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"No Supabase database is configured"})]})]}),d.jsx(ai,{children:d.jsxs(ki,{children:["Connect to a Supabase database to start using Atomic CRM. You can create a free project at"," ",d.jsx("a",{href:"https://supabase.com",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"supabase.com"})]})}),d.jsxs(ze,{onClick:i(()=>t(!0),"onClick"),className:"w-full",children:[d.jsx(Qv,{className:"h-4 w-4 mr-2"}),"Connect to Supabase"]})]})})]}),d.jsx(iie,{open:e,onComplete:i(()=>t(!1),"onComplete"),canClose:!0})]})}i(Lze,"DatabaseSettings");function $ze({children:e,className:t}){return d.jsx("label",{className:t,children:e})}i($ze,"Label");const iD=i(()=>d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(Lze,{})}),"DatabasePage");iD.path="/database";const oD=i(()=>{const[e,t]=y.useState(!1),{identity:n,refetch:r}=Zn(),{data:a,refetch:o}=Dw("sales",{id:n?.id}),s=Vt(),l=_n(),{mutate:f}=Yr({mutationKey:["signup"],mutationFn:i(async p=>{if(!n)throw new Error("Record not found");return l.salesUpdate(n.id,p)},"mutationFn"),onSuccess:i(()=>{r(),o(),t(!1),s("Your profile has been updated")},"onSuccess"),onError:i(p=>{s("An error occurred. Please try again",{type:"error"})},"onError")});if(!n)return null;const c=i(async p=>{f(p)},"handleOnSubmit");return d.jsx("div",{className:"max-w-lg mx-auto mt-8",children:d.jsx(ra,{onSubmit:c,record:a,children:d.jsx(qze,{isEditMode:e,setEditMode:t})})})},"SettingsPage"),qze=i(({isEditMode:e,setEditMode:t})=>{const n=Vt(),r=Sa(),a=Wt(),{identity:o,refetch:s}=Zn(),{isDirty:l}=ay(),f=_n(),{mutate:c}=Yr({mutationKey:["signup"],mutationFn:i(async g=>{if(!a)throw new Error("Record not found");return f.salesUpdate(a.id,g)},"mutationFn"),onSuccess:i(()=>{s(),n("Your profile has been updated")},"onSuccess"),onError:i(()=>{n("An error occurred. Please try again.")},"onError")});if(!o)return null;const p=i(()=>{r("/change-password")},"handleClickOpenPasswordChange"),m=i(async g=>{c(g)},"handleAvatarUpdate");return d.jsxs("div",{className:"space-y-4",children:[d.jsx(pn,{children:d.jsxs(Wn,{children:[d.jsx("div",{className:"mb-4 flex flex-row justify-between",children:d.jsx("h2",{className:"text-xl font-semibold text-muted-foreground",children:"My info"})}),d.jsxs("div",{className:"space-y-4 mb-4",children:[d.jsx(ote,{source:"avatar",type:"avatar",onSave:m,linkPosition:"right"}),d.jsx(pT,{source:"first_name",isEditMode:e}),d.jsx(pT,{source:"last_name",isEditMode:e}),d.jsx(pT,{source:"email",isEditMode:e})]}),d.jsxs("div",{className:"flex flex-row justify-end gap-2",children:[!e&&d.jsx(d.Fragment,{children:d.jsx(ze,{variant:"outline",type:"button",onClick:p,children:"Change password"})}),d.jsxs(ze,{type:"button",variant:e?"ghost":"outline",onClick:i(()=>t(!e),"onClick"),className:"flex items-center",children:[e?d.jsx(al,{}):d.jsx(OQ,{}),e?"Cancel":"Edit"]}),e&&d.jsxs(ze,{type:"submit",disabled:!l,variant:"outline",children:[d.jsx(i1,{}),"Save"]})]})]})}),void 0]})},"SettingsForm"),pT=i(({source:e,isEditMode:t})=>t?d.jsx(ln,{source:e,helperText:!1}):d.jsx("div",{className:"m-2",children:d.jsx(l5e,{source:e})}),"TextRender");oD.path="/settings";function oie(){const e=new Uint8Array(16);return crypto.getRandomValues(e),`ak_live_${Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("")}`}i(oie,"generateApiKey");async function zze(e){const n=new TextEncoder().encode(e),r=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(r)).map(o=>o.toString(16).padStart(2,"0")).join("")}i(zze,"hashApiKey");const Uze=[{value:"contacts:read",label:"Contacts: Read"},{value:"contacts:write",label:"Contacts: Write"},{value:"companies:read",label:"Companies: Read"},{value:"companies:write",label:"Companies: Write"},{value:"deals:read",label:"Deals: Read"},{value:"deals:write",label:"Deals: Write"},{value:"activities:write",label:"Activities: Write"}],Bze=i(({open:e,onClose:t})=>{const[n,r]=y.useState(null),[a,o]=y.useState(!1),s=_n(),l=Vt(),f=Pn(),{identity:c}=Zn(),{register:p,handleSubmit:m,watch:g,setValue:b,reset:w}=iy({defaultValues:{name:"",scopes:[],expires_at:""}}),S=Yr({mutationFn:i(async O=>{const C=oie(),T=await zze(C),R=C.substring(0,12),{data:A}=await s.create("api_keys",{data:{name:O.name,key_hash:T,key_prefix:R,scopes:O.scopes,is_active:!0,expires_at:O.expires_at||null,sales_id:c?.id,created_by_sales_id:c?.id}});return{data:A,apiKey:C}},"mutationFn"),onSuccess:i(({apiKey:O})=>{r(O),f.invalidateQueries({queryKey:["api_keys"]}),l("API key created successfully")},"onSuccess"),onError:i(()=>{l("Failed to create API key",{type:"error"})},"onError")}),_=i(()=>{r(null),o(!1),w(),t()},"handleClose"),j=i(()=>{n&&(navigator.clipboard.writeText(n),o(!0),setTimeout(()=>o(!1),2e3))},"copyApiKey"),E=i(O=>{const C=g("scopes");C.includes(O)?b("scopes",C.filter(T=>T!==O)):b("scopes",[...C,O])},"toggleScope");return d.jsx(wa,{open:e,onOpenChange:_,children:d.jsxs(_a,{className:"sm:max-w-[500px]",children:[d.jsxs(Wr,{children:[d.jsx(Gr,{children:n?"API Key Created":"Create API Key"}),d.jsx(Oi,{children:n?"Copy this key now - it won't be shown again!":"Create a new API key to access the CRM API"})]}),n?d.jsxs("div",{className:"space-y-4",children:[d.jsx(ai,{children:d.jsx(ki,{children:"Make sure to copy your API key now. You won't be able to see it again!"})}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Your API Key"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(_r,{value:n,readOnly:!0,className:"font-mono text-sm"}),d.jsx(ze,{type:"button",variant:"outline",size:"icon",onClick:j,children:a?d.jsx(Fo,{className:"h-4 w-4 text-green-500"}):d.jsx(AM,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex justify-end",children:d.jsx(ze,{onClick:_,children:"Done"})})]}):d.jsx("form",{onSubmit:m(O=>S.mutate(O)),children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"name",children:"Name"}),d.jsx(_r,{id:"name",placeholder:"e.g., Production API Key",...p("name",{required:!0})})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{children:"Scopes"}),d.jsx("div",{className:"space-y-2",children:Uze.map(O=>d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(Up,{id:O.value,checked:g("scopes").includes(O.value),onCheckedChange:i(()=>E(O.value),"onCheckedChange")}),d.jsx("label",{htmlFor:O.value,className:"text-sm cursor-pointer",children:O.label})]},O.value))})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(Hn,{htmlFor:"expires_at",children:"Expiration (optional)"}),d.jsx(_r,{id:"expires_at",type:"date",...p("expires_at")})]}),d.jsxs("div",{className:"flex justify-end gap-2",children:[d.jsx(ze,{type:"button",variant:"outline",onClick:_,children:"Cancel"}),d.jsx(ze,{type:"submit",disabled:S.isPending,children:"Create"})]})]})})]})})},"CreateApiKeyDialog");var Vze=Symbol("radix.slottable");function Hze(e){const t=i(({children:n})=>d.jsx(d.Fragment,{children:n}),"Slottable2");return t.displayName=`${e}.Slottable`,t.__radixId=Vze,t}i(Hze,"createSlottable");var sie="AlertDialog",[Wze,KUe]=da(sie,[WQ]),sl=WQ(),lie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=sl(t);return d.jsx(fy,{...r,...n,modal:!0})},"AlertDialog$1");lie.displayName=sie;var Gze="AlertDialogTrigger",Kze=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(lX,{...a,...r,ref:t})});Kze.displayName=Gze;var Yze="AlertDialogPortal",cie=i(e=>{const{__scopeAlertDialog:t,...n}=e,r=sl(t);return d.jsx(hy,{...r,...n})},"AlertDialogPortal$1");cie.displayName=Yze;var Qze="AlertDialogOverlay",uie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(py,{...a,...r,ref:t})});uie.displayName=Qze;var uh="AlertDialogContent",[Xze,Zze]=Wze(uh),Jze=Hze("AlertDialogContent"),die=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,children:r,...a}=e,o=sl(n),s=y.useRef(null),l=Zt(t,s),f=y.useRef(null);return d.jsx(KSe,{contentName:uh,titleName:fie,docsSlug:"alert-dialog",children:d.jsx(Xze,{scope:n,cancelRef:f,children:d.jsxs(my,{role:"alertdialog",...o,...a,ref:l,onOpenAutoFocus:tt(a.onOpenAutoFocus,c=>{c.preventDefault(),f.current?.focus({preventScroll:!0})}),onPointerDownOutside:i(c=>c.preventDefault(),"onPointerDownOutside"),onInteractOutside:i(c=>c.preventDefault(),"onInteractOutside"),children:[d.jsx(Jze,{children:r}),d.jsx(tUe,{contentRef:s})]})})})});die.displayName=uh;var fie="AlertDialogTitle",hie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(u1,{...a,...r,ref:t})});hie.displayName=fie;var pie="AlertDialogDescription",mie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(d1,{...a,...r,ref:t})});mie.displayName=pie;var eUe="AlertDialogAction",vie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,a=sl(n);return d.jsx(vy,{...a,...r,ref:t})});vie.displayName=eUe;var gie="AlertDialogCancel",yie=y.forwardRef((e,t)=>{const{__scopeAlertDialog:n,...r}=e,{cancelRef:a}=Zze(gie,n),o=sl(n),s=Zt(t,a);return d.jsx(vy,{...o,...r,ref:s})});yie.displayName=gie;var tUe=i(({contentRef:e})=>{const t=`\`${uh}\` requires a description for the component to be accessible for screen reader users.
|
|
155
155
|
|
|
156
156
|
You can add a description to the \`${uh}\` by passing a \`${pie}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
|
|
157
157
|
|
|
@@ -163,4 +163,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
|
|
|
163
163
|
${g?"border-green-500 bg-green-50 scale-[1.02] shadow-lg":"border-gray-300 hover:border-primary/50 hover:bg-gray-50"}
|
|
164
164
|
`,children:[d.jsx("input",{...m()}),d.jsx(AQ,{className:"w-12 h-12 mx-auto mb-4 text-gray-400"}),g?d.jsx("p",{className:"text-lg font-medium",children:"Drop files here..."}):d.jsxs(d.Fragment,{children:[d.jsx("p",{className:"text-lg font-medium mb-2",children:"Drag & drop files here, or click to select"}),d.jsx("p",{className:"text-sm text-gray-500",children:"Supports all file types (executables blocked for security)"})]})]}),e.length>0&&d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("h3",{className:"font-medium",children:["Files (",e.length,")"]}),d.jsxs("div",{className:"space-x-2",children:[d.jsx(ze,{size:"sm",onClick:w,disabled:!e.some(j=>j.status==="pending"),children:"Upload All"}),d.jsx(ze,{size:"sm",variant:"outline",onClick:S,disabled:!e.some(j=>j.status==="success"),children:"Clear Completed"})]})]}),d.jsx("div",{className:"space-y-2",children:e.map((j,E)=>d.jsxs("div",{className:"border rounded-lg p-4 space-y-2",children:[d.jsxs("div",{className:"flex items-start justify-between gap-4",children:[d.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[d.jsx(Fwe,{className:"w-5 h-5 mt-0.5 flex-shrink-0 text-gray-400"}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("p",{className:"font-medium truncate",children:j.file.name}),d.jsxs("p",{className:"text-sm text-gray-500",children:[_(j.file.size),j.activityId&&d.jsxs("span",{className:"ml-2 text-xs",children:["ID: ",j.activityId.substring(0,8),"..."]})]})]})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[j.status==="pending"&&d.jsx(ze,{size:"sm",onClick:i(()=>b(E),"onClick"),children:"Upload"}),j.status==="uploading"&&d.jsx(Oc,{className:"w-5 h-5 animate-spin text-primary"}),j.status==="success"&&d.jsx(Fo,{className:"w-5 h-5 text-green-500"}),j.status==="error"&&d.jsx(al,{className:"w-5 h-5 text-red-500"})]})]}),j.status==="uploading"&&d.jsx(Dne,{value:j.progress,className:"h-1"}),j.status==="error"&&j.error&&d.jsxs("p",{className:"text-sm text-red-500",children:["Error: ",j.error]})]},E))})]})]})]}),d.jsxs(pn,{children:[d.jsx(Qo,{children:d.jsx(Xo,{className:"text-base",children:"How it works"})}),d.jsxs(Wn,{className:"text-sm text-gray-600 space-y-2",children:[d.jsx("p",{children:"• Files are uploaded directly to secure storage (no database bloat)"}),d.jsx("p",{children:"• Each file creates an activity record for tracking and search"}),d.jsx("p",{children:"• Large files are handled automatically (no size limits)"}),d.jsx("p",{children:"• Files are linked to your selected ingestion channel"}),d.jsx("p",{children:"• Activities appear in the Activity Feed immediately"})]})]})]})},"FileUpload"),sD=i(()=>d.jsxs("div",{className:"max-w-6xl mx-auto mt-8 px-4",children:[d.jsxs("div",{className:"mb-6",children:[d.jsx("h1",{className:"text-3xl font-bold",children:"Integrations"}),d.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage API keys, webhooks, and ingestion channels to integrate Atomic CRM with external systems."})]}),d.jsxs(xte,{defaultValue:"ingestion",children:[d.jsxs(wte,{className:"mb-4",children:[d.jsx(Cu,{value:"ingestion",children:"Ingestion Channels"}),d.jsx(Cu,{value:"file-upload",children:"File Upload"}),d.jsx(Cu,{value:"api-keys",children:"API Keys"}),d.jsx(Cu,{value:"webhooks",children:"Webhooks (Outbound)"})]}),d.jsx(Ou,{value:"ingestion",children:d.jsx(bUe,{})}),d.jsx(Ou,{value:"file-upload",children:d.jsx(wUe,{})}),d.jsx(Ou,{value:"api-keys",children:d.jsx(fUe,{})}),d.jsx(Ou,{value:"webhooks",children:d.jsx(mUe,{})})]})]}),"IntegrationsPage");sD.path="/integrations";var _Ue={"ra-supabase":{auth:{email:"Email",confirm_password:"Confirm password",sign_in_with:"Sign in with %{provider}",forgot_password:"Forgot password?",reset_password:"Reset password",password_reset:"Your password has been reset. You will receive an email containing a link to log in.",missing_tokens:"Access and refresh tokens are missing",back_to_login:"Back to login"},reset_password:{forgot_password:"Forgot password?",forgot_password_details:"Enter your email for instructions."},set_password:{new_password:"Choose your password"},validation:{password_mismatch:"Passwords do not match"}}};const SUe={"ra-supabase":{auth:{password_reset:"Check your emails for a Reset Password message."}}},jUe=oQ(()=>afe(GY,_Ue,SUe),"en",[{locale:"en",name:"English"}],{allowMissing:!0}),EUe=i(()=>{const e=_n(),{data:t,error:n,isPending:r}=Qr({queryKey:["init"],queryFn:i(async()=>e.isInitialized(),"queryFn")});return r?d.jsx(nie,{}):n?d.jsx(_x,{}):t?d.jsx(_x,{}):d.jsx(gw,{to:"/sign-up"})},"StartPage");async function CUe(e){const t=["contacts","companies","deals","contactNotes","dealNotes","tasks","sales","tags"],n=[];try{for(const r of t)try{await e.getList(r,{pagination:{page:1,perPage:1},sort:{field:"id",order:"ASC"},filter:{}})}catch(a){(a?.message?.includes("Could not find the table")||a?.message?.includes("relation")||a?.message?.includes("does not exist"))&&n.push(r)}return{isHealthy:n.length===0,missingTables:n}}catch(r){return{isHealthy:!1,missingTables:t,error:r?.message||"Unknown error"}}}i(CUe,"checkDatabaseHealth");function OUe({missingTables:e,supabaseUrl:t}){const n=t.match(/https:\/\/([^.]+)\.supabase\.co/)?.[1];return d.jsxs("div",{className:"max-w-2xl mx-auto mt-8 space-y-4",children:[d.jsxs(ai,{variant:"destructive",children:[d.jsx(Ap,{className:"h-4 w-4"}),d.jsx(_te,{children:"Database Schema Not Configured"}),d.jsx(ki,{children:"Your Supabase database is connected, but the CRM schema hasn't been set up yet."})]}),d.jsxs(pn,{children:[d.jsxs(Qo,{children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Qv,{className:"h-5 w-5"}),d.jsx(Xo,{children:"Setup Instructions"})]}),d.jsx(w4,{children:"Follow these steps to set up your database schema"})]}),d.jsxs(Wn,{className:"space-y-6",children:[d.jsxs("div",{children:[d.jsx("h3",{className:"font-semibold mb-2",children:"Missing Tables:"}),d.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(r=>d.jsx("span",{className:"px-2 py-1 bg-destructive/10 text-destructive text-sm rounded",children:r},r))})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold",children:"1"}),d.jsx("h3",{className:"font-semibold",children:"Using Supabase CLI (Recommended)"})]}),d.jsxs("div",{className:"ml-8 space-y-3",children:[d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Install Supabase CLI:"}),d.jsx("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:"npm install -g supabase"})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Clone the RealTimeX CRM repository to get migrations:"}),d.jsxs("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:["git clone https://github.com/therealtimex/realtimex-crm.git",`
|
|
165
165
|
`,"cd realtimex-crm"]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Link to your Supabase project:"}),d.jsxs("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:["supabase link --project-ref ",n||"YOUR_PROJECT_REF"]})]}),d.jsxs("div",{children:[d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Push the migrations:"}),d.jsx("pre",{className:"bg-muted p-3 rounded text-sm overflow-x-auto",children:"supabase db push"})]}),d.jsx("div",{children:d.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Reload this page after migrations are complete."})})]})]}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold",children:"2"}),d.jsx("h3",{className:"font-semibold",children:"Using Supabase SQL Editor"})]}),d.jsxs("div",{className:"ml-8 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"Manually run the SQL migrations in your Supabase SQL Editor:"}),d.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-muted-foreground",children:[d.jsxs("li",{children:["Download migrations from"," ",d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm/tree/main/supabase/migrations",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["GitHub",d.jsx(df,{className:"h-3 w-3"})]})]}),d.jsxs("li",{children:["Open your"," ",d.jsxs("a",{href:`https://supabase.com/dashboard/project/${n}/sql/new`,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Supabase SQL Editor",d.jsx(df,{className:"h-3 w-3"})]})]}),d.jsx("li",{children:"Run each migration file in order (by date in filename)"}),d.jsx("li",{children:"Reload this page after all migrations are complete"})]}),n&&d.jsx(ze,{asChild:!0,variant:"outline",className:"w-full",children:d.jsxs("a",{href:`https://supabase.com/dashboard/project/${n}/sql/new`,target:"_blank",rel:"noopener noreferrer",children:[d.jsx(df,{className:"h-4 w-4 mr-2"}),"Open SQL Editor"]})})]})]}),d.jsxs("div",{className:"space-y-3 pt-4 border-t",children:[d.jsx("h3",{className:"font-semibold",children:"After Setup"}),d.jsxs("div",{className:"space-y-2 text-sm text-muted-foreground",children:[d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx(Fo,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"All tables will be created with proper schemas and relationships"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx(Fo,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"Row Level Security (RLS) policies will be configured"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx(Fo,{className:"h-4 w-4 mt-0.5 text-green-500"}),d.jsx("span",{children:"Database triggers and functions will be set up"})]})]}),d.jsx(ze,{onClick:i(()=>window.location.reload(),"onClick"),className:"w-full mt-4",children:"Reload Page"})]})]})]}),d.jsxs(pn,{children:[d.jsx(Qo,{children:d.jsx(Xo,{className:"text-base",children:"Need Help?"})}),d.jsxs(Wn,{className:"space-y-2 text-sm",children:[d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm#installation",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(df,{className:"h-4 w-4"}),"View Full Setup Guide"]}),d.jsxs("a",{href:"https://github.com/therealtimex/realtimex-crm/issues",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(df,{className:"h-4 w-4"}),"Report an Issue"]}),d.jsxs("a",{href:"https://supabase.com/docs/guides/cli",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[d.jsx(df,{className:"h-4 w-4"}),"Supabase CLI Documentation"]})]})]})]})}i(OUe,"DatabaseSetupGuide");function kUe({children:e,dataProvider:t}){const[n,r]=y.useState(null),[a,o]=y.useState(!0);if(y.useEffect(()=>{let s=!1;async function l(){try{const f=await CUe(t);s||(r(f),o(!1))}catch(f){console.error("[DatabaseHealthCheck] Failed to check database health:",f),s||o(!1)}}return i(l,"checkHealth"),l(),()=>{s=!0}},[t]),a)return d.jsx("div",{className:"flex items-center justify-center min-h-screen",children:d.jsxs("div",{className:"text-center space-y-4",children:[d.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"}),d.jsx("p",{className:"text-muted-foreground",children:"Checking database connection..."})]})});if(n&&!n.isHealthy){const s=xd();if(s)return d.jsx(OUe,{missingTables:n.missingTables,supabaseUrl:s.url})}return d.jsx(d.Fragment,{children:e})}i(kUe,"DatabaseHealthCheck");const RUe=i(({contactGender:e=XZ,companySectors:t=HZ,dealCategories:n=KZ,dealPipelineStatuses:r=GZ,dealStages:a=WZ,darkModeLogo:o=UZ,lightModeLogo:s=BZ,noteStatuses:l=YZ,taskTypes:f=QZ,title:c=VZ,dataProvider:p=Eze,authProvider:m=fze,disableTelemetry:g,...b})=>(y.useEffect(()=>{if(g||typeof window>"u"||typeof window.location>"u"||typeof Image>"u")return;const w=new Image;w.src=`https://atomic-crm-telemetry.marmelab.com/atomic-crm-telemetry?domain=${window.location.hostname}`},[g]),d.jsx(tke,{contactGender:e,companySectors:t,dealCategories:n,dealPipelineStatuses:r,dealStages:a,darkModeLogo:o,lightModeLogo:s,noteStatuses:l,taskTypes:f,title:c,children:d.jsx(kUe,{dataProvider:p,children:d.jsxs(oke,{dataProvider:p,authProvider:m,store:pG(void 0,"CRM"),layout:uze,loginPage:EUe,i18nProvider:jUe,dashboard:eze,requireAuth:!0,disableTelemetry:!0,...b,children:[d.jsxs(eP,{noLayout:!0,children:[d.jsx(Qn,{path:aD.path,element:d.jsx(aD,{})}),d.jsx(Qn,{path:XP.path,element:d.jsx(XP,{})}),d.jsx(Qn,{path:KP.path,element:d.jsx(KP,{})}),d.jsx(Qn,{path:ZP.path,element:d.jsx(ZP,{})}),d.jsx(Qn,{path:JP.path,element:d.jsx(JP,{})})]}),d.jsxs(eP,{children:[d.jsx(Qn,{path:oD.path,element:d.jsx(oD,{})}),d.jsx(Qn,{path:iD.path,element:d.jsx(iD,{})}),d.jsx(Qn,{path:sD.path,element:d.jsx(sD,{})})]}),d.jsx(Co,{name:"deals",...nze}),d.jsx(Co,{name:"contacts",...X5e}),d.jsx(Co,{name:"companies",...H4e}),d.jsx(Co,{name:"contactNotes"}),d.jsx(Co,{name:"dealNotes"}),d.jsx(Co,{name:"tasks"}),d.jsx(Co,{name:"sales",...Fze}),d.jsx(Co,{name:"tags"})]})})})),"CRM"),AUe=i(()=>{const[e,t]=y.useState(()=>!QRe());return e?d.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:d.jsx(iie,{open:!0,onComplete:i(()=>{t(!1)},"onComplete"),canClose:!1})}):d.jsx(RUe,{})},"App");Nse.createRoot(document.getElementById("root")).render(d.jsx(y.StrictMode,{children:d.jsx(AUe,{})}));export{Zn as $,nl as A,Pr as B,jK as C,mY as D,m4 as E,Wo as F,h4 as G,fn as H,Go as I,SJ as J,Se as K,AK as L,Jme as M,_r as N,dw as O,ie as P,hG as Q,dd as R,el as S,lr as T,rs as U,pn as V,Wn as W,Tp as X,Tr as Y,qp as Z,zp as _,oy as a,ze as a0,wa as a1,_a as a2,Gr as a3,hd as a4,pd as a5,ln as a6,nr as a7,Ry as a8,h3e as a9,Fye as aA,j4e as aB,mg as aC,V5e as aD,Rne as aE,Nw as aF,Yr as aG,ud as aH,Vte as aI,Hn as aJ,S4 as aK,B1 as aL,b4 as aM,sn as aN,_4 as aO,hPe as aP,P1 as aQ,kN as aa,Va as ab,Zs as ac,yne as ad,_n as ae,Gn as af,Pn as ag,ra as ah,q1 as ai,yd as aj,Vt as ak,aM as al,Lte as am,Wt as an,D4 as ao,Dr as ap,tp as aq,F1 as ar,Dne as as,Pc as at,R4e as au,Zi as av,is as aw,lY as ax,Pte as ay,cc as az,uM as b,cK as c,Hme as d,za as e,Ge as f,yM as g,Cc as h,xt as i,Ec as j,Jw as k,Et as l,d as m,Xs as n,ca as o,jy as p,gNe as q,y as r,bNe as s,wNe as t,ua as u,_Ne as v,il as w,Lw as x,Ht as y,fd as z};
|
|
166
|
-
//# sourceMappingURL=index-
|
|
166
|
+
//# sourceMappingURL=index-Dat6OHMH.js.map
|