1import{r as g,j as t,q as $e,L as xe,S as lr,m as Be,l as Xe,n as cr,T as tn,o as dr}from"./vendor-react-C7ASs9Oj.js";import{c as be,Z as ur,_ as mr,$ as Rn,a0 as Ln,a1 as zn,a2 as Fn,a3 as xr,a4 as $n,a5 as Ze,a6 as pr,a7 as gr,a8 as fr,m as xs,a as N,a9 as ps,aa as gs,ab as De,ac as re,ad as hr,ae as jr,af as br,ag as vr,ah as _e,ai as yr,aj as Nr,ak as fs,al as wr,am as Sr,an as Cr,ao as kr,ap as Mr,aq as Ir,ar as Tr,as as Dr,at as Ar,au as Or,av as Er,aw as Pr,ax as _r,ay as Rr,az as ot,aA as Lr,F as W,aB as zr,aC as Fr,aD as $r,r as hs,K as We,J as js,q as bs,Q as pe,aE as vs,D as Ae,n as Oe,p as Ee,u as le,aF as Br,aG as ys,aH as it,aI as Ns,aJ as Kr,aK as Gr,aL as Ur,aM as Hr,aN as lt,aO as ws,e as nn,f as sn,g as an,aP as qr,N as P,aQ as Wr,aR as Yr,L as rn,aS as Qr,C as F,aT as U,aU as Ye,aV as Ss,aW as Cs,aX as Vr,aY as Jr,t as G,aZ as Xr,a_ as ks,a$ as Ms,b0 as Zr,b1 as eo,b2 as Is,b3 as to,b4 as no,b5 as so,b6 as ao,b7 as ro,b8 as oo,b9 as io,ba as on,P as te,bb as Ts,d as ne,bc as et,bd as lo,X as Ds,be as co,bf as ie,bg as As,b as ve,x as uo,bh as mo,z as xo,H as po,A as go,E as fo,bi as ho,bj as ln,bk as cn,bl as $t,bm as Os,bn as Es,bo as tt,bp as jo,bq as Ps,S as q,U as dn,br as _s,bs as bo,bt as vo,bu as yo,bv as Bn,o as R,bw as Rs,bx as Z,by as No,bz as wo,bA as Ls,bB as nt,bC as So,bD as Co,bE as ko,bF as Qe,bG as ge,bH as Mo,bI as ct,bJ as dt,bK as ut,bL as mt,bM as xt,bN as Io,Y as pt,bO as zs,bP as Fs,bQ as $s,bR as Bs,bS as Ks,bT as un,bU as To,bV as Do,bW as Ao,V as Oo,bX as Eo,bY as Po,bZ as _o,b_ as Ro,b$ as Lo,c0 as zo,h as Ke,l as mn,c1 as Gs,c2 as Us,c3 as xn,c4 as Bt,c5 as Hs,c6 as qs,c7 as pn,c8 as Ws,c9 as Kn,ca as Fo,cb as $o,cc as Bo,cd as Kt,R as Ko,ce as Go,cf as Uo,cg as Ho,ch as qo,ci as Wo,cj as Yo,ck as Qo,cl as gt,cm as Vo,cn as Jo,co as Xo,cp as Ys,O as Gn,cq as Zo,cr as ei,cs as ti,ct as ni,cu as si,cv as ai,cw as ri,cx as oi,cy as ii,cz as li,cA as ci,cB as di}from"./index-u3J_xIHd.js";import{f as ft,t as ye}from"./upcomingMeetings-DCivANBm.js";import{T as Ge,a as Qs,n as Vs,b as ui,t as mi,u as gn,c as xi}from"./tagQueries-BbbNvGQY.js";import{l as Me,S as X,a as pi,b as gi,c as fi,u as hi}from"./libraryQueries-DY0mJRrj.js";import{B as je}from"./bookmark-nDfdB_Yf.js";import{u as fn,g as ji,a as bi,M as Js}from"./MeetingVisibilityMenu-BGvNk5G8.js";import{R as Xs}from"./repeat-3iy2wTLF.js";import{C as hn,B as vi,s as yi,a as Ni,i as wi}from"./calendar-BH63X9xq.js";import{C as Zs,e as Si}from"./endOfWeek-BbSGErec.js";import{c as Ci,g as ki,e as Nt}from"./endOfDay-CXznyf2o.js";import{C as ht}from"./clock-Bxc4mTTd.js";import{C as Mi}from"./meetingTranscriptsClipboard-CwG2E_5l.js";import{U as Ii}from"./user-check-tNiAPW6w.js";import{L as Ti,a as Di}from"./list-filter-k6l9ovh5.js";import{C as jn}from"./checkbox-B-HilsCT.js";import{M as Ai,L as Oi}from"./minimize-2-CvY7o4sO.js";import{S as Ei}from"./sparkles-BKMaqHrK.js";import{T as Pi}from"./text-align-start-BmTRefoK.js";import{f as _i}from"./time-9-KLj7BP.js";import{A as Ri}from"./arrow-right-DuMHa0Na.js";import{u as Li}from"./useUnbookmark-CdJ6ZOhN.js";import{u as zi}from"./useMeetingBulkActions-b57DS9JD.js";import{S as Fi}from"./SharePersonMenu-CMRnJiFP.js";import{M as $i}from"./MultiContactComboBoxV2-DJ3C4KtY.js";import{e as Bi}from"./endOfMonth-DWPrX32M.js";import{S as Ki}from"./save-CeaX_Hxl.js";import{C as Gi}from"./circle-dashed-CD76TEDX.js";import{E as Ui}from"./ellipsis-CGXeEO7U.js";import{c as Hi}from"./commandCenterWorkspaceRows-DSyRvYAL.js";import{u as qi,o as Wi}from"./onlyMineQuery-CIpMCme-.js";import{C as Yi}from"./circle-check-big-BA0GzUtI.js";import{u as Qi}from"./useMediaQuery-Evc9PeUO.js";import{u as Vi}from"./usePageTitle-T4dL9DRD.js";import{a as Ji,A as Xi,m as Un}from"./vendor-motion-D0i_FyGX.js";import"./vendor-charts-BBg_9aJv.js";import"./lock-DJRRP3f6.js";import"./isSameYear-DT6VUyul.js";import"./useTranscriptCopyPausedAt-Bq9I2TQL.js";import"./textarea-CZr9QLXe.js";const Zi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],el=be("columns-3",Zi);const tl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],nl=be("panel-right-close",tl);const sl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],al=be("panel-right-open",sl);const rl=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7
1a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],Hn=be("pin",rl);const ol=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],il=be("rows-3",ol);const ll=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 7v7",key:"1x2jlm"}],["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M16 7v9",key:"1hp2iy"}]],cl=be("square-kanban",ll);const dl=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],ul=be("wand-sparkles",dl);function ml(e,n,s){const a=xr(),r=s?.locale??a.locale??ur,o=Ci(e,n);if(isNaN(o))throw new RangeError("Invalid time value");const d=Object.assign({},s,{addSuffix:s?.addSuffix,comparison:o}),[l,i]=mr(s?.in,...o>0?[n,e]:[e,n]),c=ki(s?.roundingMethod??"round"),u=i.getTime()-l.getTime(),x=u/$n,m=Rn(i)-Rn(l),p=(u-m)/$n,f=s?.unit;let h;if(f?h=f:x<1?h="second":x<60?h="minute":x<Ln?h="hour":p<zn?h="day":p<Fn?h="month":h="year",h==="second"){const b=c(u/1e3);return r.formatDistance("xSeconds",b,d)}else if(h==="minute"){const b=c(x);return r.formatDistance("xMinutes",b,d)}else if(h==="hour"){const b=c(x/60);return r.formatDistance("xHours",b,d)}else if(h==="day"){const b=c(p/Ln);return r.formatDistance("xDays",b,d)}else if(h==="month"){const b=c(p/zn);return b===12&&f!=="month"?r.formatDistance("xYears",1,d):r.formatDistance("xMonths",b,d)}else{const b=c(p/Fn);return r.formatDistance("xYears",b,d)}}const ea=e=>e.kind==="recorded"?{entityType:"meeting",entityId:e.transcriptId}:e.kind==="upcoming"&&e.stableOccurrenceId?{entityType:"future_meeting",entityId:e.stableOccurrenceId}:null,ta=e=>{if(e.kind!=="recorded"&&e.kind!=="upcoming")return null;const n=e.source.seriesId;return n?{entityType:"meeting_series",entityId:n}:null},Gt=(e,n)=>e.length>0&&e.every(s=>n.has(Me(s.entityType,s.entityId))),fe=e=>e.kind==="action"?[Me("actionItem",e.actionItemId)]:[ea(e),ta(e)].flatMap(n=>n?[Me(n.entityType,n.entityId)]:[]),xl=(e,n,s)=>n.length===0?[...e]:e.filter(a=>a.kind==="live"?!0:fe(a).some(r=>{const o=s.get(r);return o!==void 0&&n.some(d=>o.tags.includes(d))})),pl=e=>e?.kind==="recorded"||e?.kind==="live",na=e=>pl(e)||e?.kind==="upcoming"&&e.stableOccurrenceId?e:null,gl=e=>e.kind==="recorded"?{kind:"meeting",id:e.transcriptId}:e.kind==="upcoming"&&e.stableOccurrenceId?{kind:"occurrence",id:e.stableOccurrenceId}:null,fl=e=>{const n=e.map(a=>a.kind==="recorded"||a.kind==="upcoming"?xs(a.source.grants,a.source.restrictToGrants):null),s=n[0]??null;return s&&n.every(a=>a?.key===s.key)?s:null};function sa(e){const n=e.filter(h=>h.kind==="recorded"),s=e.filter(h=>h.kind==="upcoming"),a=e.length>0&&n.length===e.length,r=e.length>0&&s.length===e.length,o=e.length>0&&e.every(h=>h.kind===e[0].kind),d=e.some(Ze),l=e.map(ea).filter(h=>h!==null),i=e.map(ta),c=i.every(h=>h!==null)?[...new Map(i.map(h=>[h.entityId,h])).values()]:[],u=e.map(gl).filter(h=>h!==null),x=e.length>0&&u.length===e.length,m=e.length===1?e[0]:null,p=m?.kind==="upcoming"?m.providerEventId:null,f=e.map(pr);return{header:m?m.title:`${e.length} ${o&&e[0]?gr[e[0].kind]:d?"items":"meetings"} selected`,subheader:m?`${ft(m.start)} · ${ye(m.start,m.end,m.isAllDay)}`:null,canOpen:m!==null&&fr(m),canShare:na(m)!==null,canCopyTranscripts:a,recordedIds:n.map(h=>h.transcriptId),bookmarkRefs:l,seriesRefs:c,canBookmark:e.length>0&&l.length===e.length,audienceRefs:u,canMarkAudience:x,audiencePreset:x?fl(e):null,canPrep:p!=null,mindMapOccurrenceId:m?.kind==="upcoming"?m.stableOccurrenceId:null,prepEventId:p,canSendNotetaker:r,upcomingEvents:r?s.map(h=>h.source):[],copyLinkPaths:f.every(h=>h!==null)?f:null}}const bn=[],hl=[],aa=g.createContext(null),ra=g.createContext(null),Pe=()=>{const e=g.useContext(ra);if(!e)throw new Error("Calendar lookups need a CalendarActionsProvider");return e},Y=()=>{const e=g.useContext(aa);if(!e)throw new Error("Calendar actions need a CalendarActionsProvider");return e},vn={joining:{dot:"bg-emerald-500 text-white",glyph:"â",label:"Note-taker joining"}
1,joiningViaOther:{dot:"bg-amber-500 text-black",glyph:"â",label:"Note-taker joining, booked by someone else"},notJoining:{dot:"bg-rose-500 text-white",glyph:"Ã",label:"Note-taker not joining"},removed:{dot:"bg-muted-foreground text-background",glyph:"â",label:"Note-taker removed from this meeting"}},Ut=e=>`${vn[e.state].label} â ${e.reason}`;function Ht({className:e,children:n}){return t.jsx("span",{className:N("inline-flex h-[15px] items-center rounded-full px-1.5 text-[10px] font-semibold",e),children:n})}function jl({notetaker:e}){const n=e.state==="joining"||e.state==="joiningViaOther";return t.jsx("span",{title:Ut(e),className:N("inline-block h-[7px] w-[7px] flex-none rounded-full",n?"bg-foreground/85":"border-[1.5px] border-[oklch(0.55_0_0)]")})}function he({keys:e,dotClassName:n="size-1.5"}){const{tagsByKey:s,flaggedKeys:a}=Pe(),r=[...new Map(e.flatMap(o=>s.get(o)??[]).map(o=>[o.id,o])).values()];return r.length>0?t.jsx("span",{title:r.map(o=>o.name).join(", "),className:"flex flex-none items-center gap-0.5 self-center",children:r.map(o=>t.jsx("span",{"aria-hidden":"true",className:N("rounded-full",n,Ge[o.color])},o.id))}):e.some(o=>a.has(o))?t.jsx("span",{title:"Bookmarked",className:"flex-none text-teal",children:t.jsx(je,{className:"size-3 fill-current","aria-hidden":"true"})}):null}function wt({block:e}){const{automations:n}=Pe(),s=ps(n,e);if(!s.on&&!s.overrides)return null;const a=gs(s);return t.jsxs("span",{title:a.charAt(0).toUpperCase()+a.slice(1),className:"flex flex-none items-center gap-0.5 self-center text-teal",children:[s.on?t.jsx(De,{className:"size-3 fill-current","aria-hidden":"true"}):null,s.overrides?t.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-amber-500"}):null]})}function bl({block:e,width:n}){const s=n>=.6;return t.jsxs("div",{className:"flex items-center gap-1 overflow-hidden whitespace-nowrap text-muted-foreground",children:[e.kind==="upcoming"?t.jsx(jl,{notetaker:e.notetaker}):null,t.jsx("span",{children:ye(e.start,e.end,e.isAllDay)}),s&&e.kind==="live"?t.jsx(Ht,{className:"bg-danger-subtle text-danger-foreground",children:"Live"}):null,s&&re(e)?t.jsx(Ht,{className:"bg-background/70 text-muted-foreground",children:"Done"}):null]})}function oa({block:e,variant:n,width:s=1}){switch(n){case"compact":return t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold",children:e.title}),t.jsx(he,{keys:fe(e)}),t.jsx(wt,{block:e})]});case"full":return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsx("span",{className:"min-w-0 flex-1 break-words font-semibold",children:e.title}),t.jsx(he,{keys:fe(e)}),t.jsx(wt,{block:e})]}),t.jsx(bl,{block:e,width:s})]});case"pill":return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"flex-none text-muted-foreground",children:ye(e.start,null,e.isAllDay)}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-medium",children:e.title}),t.jsx(he,{keys:fe(e)}),t.jsx(wt,{block:e})]})}}var yn="ContextMenu",[vl]=Er(yn,[fs]),$=fs(),[yl,ia]=vl(yn),la=e=>{const{__scopeContextMenu:n,children:s,onOpenChange:a,dir:r,modal:o=!0}=e,[d,l]=g.useState(!1),i=$(n),c=hr(a),u=g.useCallback(x=>{l(x),c(x)},[c]);return t.jsx(yl,{scope:n,open:d,onOpenChange:u,modal:o,children:t.jsx(jr,{...i,dir:r,open:d,onOpenChange:u,modal:o,children:s})})};la.displayName=yn;var ca="ContextMenuTrigger",da=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,disabled:a=!1,...r}=e,o=ia(ca,s),d=$(s),l=g.useRef({x:0,y:0}),i=g.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),c=g.useRef(0),u=g.useCallback(()=>window.clearTimeout(c.current),[]),x=m=>{l.current={x:m.clientX,y:m.clientY},o.onOpenChange(!0)};return g.useEffect(()=>u,[u]),g.useEffect(()=>{a&&u()},[a,u]),t.jsxs(t.Fragment,{children:[t.jsx(br,{...d,virtualRef:i}),t.jsx(vr.span,{"data-state":o.open?"open":"closed","data-disabled":a?"":void 0,...r,ref:n,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:a?e.onContextMenu:_e(e.onContextMenu,m=>{u(),x(m),m.preventDefault()}),onPointerDown:a?e.onPointerDown:_e(e.onPointerDown,He(m=>{u(),c.current=window.setTimeout(()=>x(m),700)})),onPointerMove:a?e.onPointerMove:_e(e.onPointerMove,He(u)),onPointerCancel:a?e.onPointerCancel:_e(e.onPointerCancel,He(u)),onPointerUp:a?e.onPointerUp:_e(e.onPointerUp,He(u))})]})});da.displayName=ca;var Nl="ContextMenuPortal",ua=e=>{const{__scopeContextMenu:n,...s}=e,a=$(n);return t.jsx(yr,{...a,...s})};ua.displayName=Nl;
1var ma="ContextMenuContent",xa=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=ia(ma,s),o=$(s),d=g.useRef(!1);return t.jsx(Nr,{...o,...a,ref:n,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{e.onCloseAutoFocus?.(l),!l.defaultPrevented&&d.current&&l.preventDefault(),d.current=!1},onInteractOutside:l=>{e.onInteractOutside?.(l),!l.defaultPrevented&&!r.modal&&(d.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xa.displayName=ma;var wl="ContextMenuGroup",Sl=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(_r,{...r,...a,ref:n})});Sl.displayName=wl;var Cl="ContextMenuLabel",pa=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(wr,{...r,...a,ref:n})});pa.displayName=Cl;var kl="ContextMenuItem",ga=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Cr,{...r,...a,ref:n})});ga.displayName=kl;var Ml="ContextMenuCheckboxItem",fa=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Pr,{...r,...a,ref:n})});fa.displayName=Ml;var Il="ContextMenuRadioGroup",ha=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Or,{...r,...a,ref:n})});ha.displayName=Il;var Tl="ContextMenuRadioItem",ja=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Dr,{...r,...a,ref:n})});ja.displayName=Tl;var Dl="ContextMenuItemIndicator",ba=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Ar,{...r,...a,ref:n})});ba.displayName=Dl;var Al="ContextMenuSeparator",va=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Sr,{...r,...a,ref:n})});va.displayName=Al;var Ol="ContextMenuArrow",El=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Rr,{...r,...a,ref:n})});El.displayName=Ol;var ya="ContextMenuSub",Na=e=>{const{__scopeContextMenu:n,children:s,onOpenChange:a,open:r,defaultOpen:o}=e,d=$(n),[l,i]=Ir({prop:r,defaultProp:o??!1,onChange:a,caller:ya});return t.jsx(Tr,{...d,open:l,onOpenChange:i,children:s})};Na.displayName=ya;var Pl="ContextMenuSubTrigger",wa=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(kr,{...r,...a,ref:n})});wa.displayName=Pl;var _l="ContextMenuSubContent",Sa=g.forwardRef((e,n)=>{const{__scopeContextMenu:s,...a}=e,r=$(s);return t.jsx(Mr,{...r,...a,ref:n,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Sa.displayName=_l;function He(e){return n=>n.pointerType!=="mouse"?e(n):void 0}var Rl=la,Ll=da,zl=ua,Fl=xa,$l=pa,Bl=ga,Kl=fa,Gl=ha,Ul=ja,Ca=ba,Hl=va,ql=Na,Wl=wa,Yl=Sa;function Ql({...e}){return t.jsx(Rl,{"data-slot":"context-menu",...e})}function Vl({...e}){return t.jsx(Ll,{"data-slot":"context-menu-trigger",...e})}function jt({...e}){return t.jsx(ql,{"data-slot":"context-menu-sub",...e})}function Jl({...e}){return t.jsx(Gl,{"data-slot":"context-menu-radio-group",...e})}function bt({className:e,inset:n,children:s,...a}){return t.jsxs(Wl,{"data-slot":"context-menu-sub-trigger","data-inset":n,className:N("flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...a,children:[s,t.jsx(ot,{className:"ml-auto"})]})}function vt({className:e,...n}){return t.jsx(Yl,{"data-slot":"context-menu-sub-content",className:N("z-50 min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
1de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...n})}function Xl({className:e,...n}){return t.jsx(zl,{children:t.jsx(Fl,{"data-slot":"context-menu-content",className:N("z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...n})})}function oe({className:e,inset:n,variant:s="default",...a}){return t.jsx(Bl,{"data-slot":"context-menu-item","data-inset":n,"data-variant":s,className:N("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",e),...a})}function qn({className:e,children:n,checked:s,...a}){return t.jsxs(Kl,{"data-slot":"context-menu-checkbox-item",className:N("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:s,...a,children:[t.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:t.jsx(Ca,{children:t.jsx(W,{className:"size-4"})})}),n]})}function Zl({className:e,children:n,...s}){return t.jsxs(Ul,{"data-slot":"context-menu-radio-item",className:N("relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[t.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:t.jsx(Ca,{children:t.jsx(Lr,{className:"size-2 fill-current"})})}),n]})}function st({className:e,inset:n,...s}){return t.jsx($l,{"data-slot":"context-menu-label","data-inset":n,className:N("px-2 py-1.5 text-sm font-medium text-foreground data-[inset]:pl-8",e),...s})}function ke({className:e,...n}){return t.jsx(Hl,{"data-slot":"context-menu-separator",className:N("-mx-1 my-1 h-px bg-border",e),...n})}const qt=()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0})),Nn={Item:oe,Label:st,RadioGroup:Jl,RadioItem:Zl,Separator:ke,Sub:jt,SubContent:vt,SubTrigger:bt},ka={Item:pe,Label:bs,RadioGroup:js,RadioItem:We,Separator:hs,Sub:$r,SubContent:Fr,SubTrigger:zr},Wn="flex-1 justify-center gap-1.5 py-1 pl-2 text-xs text-muted-foreground [&>span:first-child]:hidden data-[state=checked]:bg-background data-[state=checked]:font-medium data-[state=checked]:text-foreground data-[state=checked]:shadow-sm",Yn=e=>e.preventDefault();function Ma({parts:e}){const{seriesScope:n,setSeriesScope:s}=Y();return t.jsxs(e.RadioGroup,{value:n,onValueChange:a=>s(a==="meeting"?"meeting":"series"),"aria-label":"Apply to",className:"m-1 flex gap-0.5 rounded-md bg-muted p-0.5",children:[t.jsx(e.RadioItem,{value:"meeting",onSelect:Yn,className:Wn,children:"This meeting"}),t.jsxs(e.RadioItem,{value:"series",onSelect:Yn,className:Wn,children:[t.jsx(Xs,{className:"size-3.5"}),"All in series"]})]})}const ec="size-4 text-muted-foreground",St=e=>e.preventDefault(),Ia=e=>{const n=le("automations.use"),{automations:s}=Y();return!n||e.kind!=="upcoming"||!e.stableOccurrenceId?null:{block:e,states:Br(s,e)}},Wt=e=>e>0?`Reminders, ${String(e)} on`:"Reminders";function tc(){return t.jsx("span",{title:"Overrides series",className:"inline-block size-1.5 flex-none rounded-full bg-amber-500",children:t.jsx("span",{className:"sr-only",children:"Overrides series"})})}const nc=e=>e.kind==="at"?`at:${String(e.offsetMinutes)}`:e.kind,sc=e=>e==="inherit"?{kind:"inherit"}:e.startsWith("at:")?{kind:"at",offsetMinutes:Number(e.slice(3))}:{kind:"off"},ac=(e,n)=>n&&e.series?{value:e.series,inherited:!1,overrides:!1}:e.occurrence.kind==="inherit"?{value:e.effective,inherited:!0,overrides:!1}:{value:e.occurrence,inherited:!1,overrides:e.overridesSeries};function rc({parts:e,block:n,state:s,onSeries:a}){const{label:r}=it[s.action],{value:o,inherited:d,overrides:l}=ac(s,a),i=Ns(o,s.action),c=`${r}: ${i}${d?", from the series":""}${l?", overrides series":""}`;return t.jsxs(e.Sub,{children:[t.jsxs(e.SubTrigger,{"aria-label":c,children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:r}),t.jsxs("span",{className:N("flex flex-none items-center gap-1 text-xs",d||o.kind==="off"?"text-muted-foreground":"text-foreground"),children:[d?t.jsx(Xs,{className:"size-3","aria-hidden":"true"}):null,i,l?t.jsx(tc,{}):null]})]}),t.jsx(e.SubContent,{className:"w-64",children:t.jsx(oc,{parts:e,block:n,state:s,onSeries:a})})]})}function oc({parts:e,block:n,state:s,onSeries:a}){const{automations:r,automate:o,removeAutomations:d,pickTiming:l}=Y(),i=ys(n),c=a?"series":"occurrence",u=a&&s.series?s.series:s.occurrence,x=it[s.action],m=p=>{if(Ur(p,u))return;const f=Hr(r,n,s,c,p);f.removeIds.length>0&&d(f.removeIds),f.create&&o(f.create)};return t.jsxs(t.Fragment,{children:[i?t.jsx(e.Label,{className:"text-xs font-normal text-muted-foreground",children:a?"All in series":"This meeting only"}):null,t.jsxs(e.RadioGroup,{value:nc(u),onValueChange:p=>m(sc(p)),children:[i&&!a&&s.series?t.jsxs(t.Fragment,{children:[t.jsxs(e.RadioItem,{value:"inherit",onSelect:St,children:[t.jsx("span",{className:"flex-1",children:"Use series setting"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ns(s.series,s.action)})]}),t.jsx(e.Separator,{})]}):null,t.jsx(e.RadioItem,{value:"off",onSelect:St,children:"Off"}),Kr(s).map(p=>t.jsx(e.RadioItem,{value:`at:${String(p)}`,onSelect:St,children:Gr(p,s.action)},p))]}),x.customMax?t.jsxs(t.Fragment,{children:[t.jsx(e.Separator,{}),t.jsx(e.Item,{onSelect:()=>l({block:n,scope:c,action:s.action}),children:"Customâ¦"})]}):null]})}function Ta({parts:e,reminders:n}){const{seriesScope:s}=Y(),a=ys(n.block),r=a&&s==="series";return t.jsxs(t.Fragment,{children:[a?t.jsx(Ma,{parts:e}):null,n.states.map(o=>t.jsx(rc,{parts:e,block:n.block,state:o,onSeries:r},o.action))]})}function ic({block:e}){const n=Ia(e);if(!n)return null;const s=vs(n.states);return t.jsxs(jt,{children:[t.jsxs(bt,{"aria-label":Wt(s),children:[t.jsx(De,{className:ec}),t.jsx("span",{className:"flex-1",children:"Reminders"}),s>0?t.jsxs("span",{className:"text-xs text-muted-foreground",children:[s," on"]}):null]}),t.jsx(vt,{className:"w-[22rem]",children:t.jsx(Ta,{parts:Nn,reminders:n})})]})}function lc({block:e}){const n=Ia(e);if(!n)return null;const s=vs(n.states);return t.jsxs(Ae,{children:[t.jsx(Oe,{asChild:!0,children:t.jsx("button",{type:"button",className:"inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",title:Wt(s),"aria-label":Wt(s),children:t.jsx(De,{className:N("size-4",s>0&&"fill-current text-teal")})})}),t.jsx(Ee,{align:"start",className:"w-[22rem]",children:t.jsx(Ta,{parts:ka,reminders:n})})]})}const cc="size-4 text-muted-foreground",dc=(e,n)=>`${String(e)} ${n}${e===1?"":"s"}`;function uc({refs:e,seriesRefs:n=[],onManageTags:s}){const{flaggedKeys:a,tags:r,tagsByKey:o,setMark:d,unbookmark:l,seriesScope:i}=Y(),c=Qs(),u=n.length>0?i:"meeting",x=u==="series"?n:e,[m,p]=g.useState(""),[f,h]=g.useState(0),b=M=>M.preventDefault(),w=Gt(x,a),S=M=>
1o.get(Me(M.entityType,M.entityId))??bn,j=M=>x.every(B=>S(B).some(J=>J.id===M));let v=0;for(const M of x)v+=S(M).length;const y=(M,B)=>{B&&!w&&h(J=>J+1),d(x,M,B)},k=m.trim(),T=k.toLowerCase(),A=T?r.filter(M=>M.name.toLowerCase().includes(T)):r,H=r.find(M=>M.name.toLowerCase()===T),C=async()=>{const M=await c.mutateAsync({name:k,color:Vs(r.length)});y(M.id,!0),p("")},E=()=>{const M=H??(A.length===1?A[0]:void 0);M?(j(M.id)||y(M.id,!0),p("")):k&&C()},Q=M=>{M.key==="Escape"||M.key==="Tab"||(M.stopPropagation(),M.key==="Enter"?(M.preventDefault(),E()):M.key==="ArrowDown"&&(M.preventDefault(),M.currentTarget.closest('[role="menu"]')?.querySelector("[data-tag-row]")?.focus()))};return t.jsxs(t.Fragment,{children:[n.length>0?t.jsx(Ma,{parts:Nn}):null,t.jsxs(qn,{checked:w,onSelect:b,onCheckedChange:M=>{M?d(x,X,!0):u==="series"?l(x,"the series"):l(x)},children:[f>0?t.jsx("span",{"aria-hidden":"true",className:"animate-bookmark-row-flash pointer-events-none absolute inset-0 rounded-sm"},f):null,t.jsx("span",{className:N("flex",f>0&&"animate-bookmark-pop"),children:t.jsx(je,{className:N("size-3.5 text-teal",w&&"fill-current")})},`icon-${String(f)}`),t.jsxs("span",{className:"flex flex-col",children:["Bookmarked",w&&v>0?t.jsxs("span",{className:"text-xs text-muted-foreground",children:["Unchecking also removes ",dc(v,"tag"),u==="series"?" from the series":""]}):null]})]}),t.jsx(ke,{}),t.jsx("div",{className:"px-1 py-1",children:t.jsx("input",{value:m,onChange:M=>p(M.target.value),onKeyDown:Q,"aria-label":"Find or create a tag",placeholder:r.length===0?"Name your first tagâ¦":"Find or create a tagâ¦",className:"h-7 w-full rounded-sm border bg-transparent px-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring"})}),t.jsx(st,{className:"text-[10.5px] font-semibold tracking-wide text-muted-foreground uppercase",children:"Tags"}),r.length===0&&!k?t.jsx(oe,{disabled:!0,children:"No tags yet"}):null,A.map(M=>t.jsxs(qn,{"data-tag-row":"",checked:j(M.id),onSelect:b,onCheckedChange:B=>y(M.id,B),children:[t.jsx("span",{"aria-hidden":"true",className:N("size-2.5 shrink-0 rounded-full",Ge[M.color])}),t.jsx("span",{className:"truncate",children:M.name})]},M.id)),k&&!H?t.jsxs(oe,{disabled:c.isPending,onSelect:M=>{M.preventDefault(),C()},children:[t.jsx(lt,{className:cc}),t.jsxs("span",{className:"truncate",children:["Create â",k,"â"]}
1)]}):null,t.jsx(ke,{}),t.jsx(oe,{onSelect:s,children:"Manage tagsâ¦"})]})}function mc({bookmarked:e,tags:n,openOnMount:s,onToggle:a,children:r}){const[o,d]=g.useState(!1);g.useEffect(()=>{if(!s)return;const i=requestAnimationFrame(()=>d(!0));return()=>cancelAnimationFrame(i)},[s]);const l=()=>{a(),qt()};return t.jsxs(jt,{open:o,onOpenChange:d,children:[t.jsxs(bt,{className:"gap-0 py-0 pr-2 pl-0",onClick:i=>{!(i.target instanceof Element)||!i.target.closest("[data-bookmark-toggle]")||(i.preventDefault(),l())},onKeyDown:i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),l())},children:[t.jsxs("span",{"data-bookmark-toggle":"",className:"flex min-w-0 flex-1 items-center gap-2 py-1.5 pl-2",children:[t.jsx(je,{className:N("size-4",e?"fill-current text-teal":"text-muted-foreground")}),e?"Bookmarked":"Bookmark",e&&n.length>0?t.jsx("span",{"aria-hidden":"true",className:"ml-auto flex items-center gap-0.5 pr-2",children:n.map(i=>t.jsx("span",{className:N("size-1.5 rounded-full",Ge[i.color])},i.id))}):null]}),t.jsx("span",{"aria-hidden":"true",className:"mr-2 h-4 w-px self-center bg-border"})]}),t.jsx(vt,{className:"w-64",children:r})]})}const Da=e=>P(e,"EEE h:mm a"),wn=e=>{const n=le("automations.use"),{automations:s}=Y(),a=n?qr(s,e.subject):null;return{shown:n,pending:a}},Qn="pl-8";function Aa({parts:e,request:n}){const{automate:s,removeAutomations:a}=Y(),{pending:r}=wn(n),[o,d]=g.useState(!1);if(o)return t.jsx(xc,{request:n,onBack:()=>d(!1)});const l=Wr(new Date).map(u=>({key:u.label,...u}));let i="";if(r){const u=l.find(x=>x.at.getTime()===r.at.getTime());i=u?u.key:"pending"}const c=u=>{u.key!==i&&s(Ss(n,u.at))};return t.jsxs(t.Fragment,{children:[t.jsx(e.Label,{className:"text-xs font-normal text-muted-foreground",children:"Snooze until"}),t.jsxs(e.RadioGroup,{value:i,children:[l.map(u=>t.jsx(e.RadioItem,{value:u.key,onSelect:()=>c(u),children:u.label},u.key)),r&&i==="pending"?t.jsx(e.RadioItem,{value:"pending",children:ws(r.at)}):null]}),t.jsx(e.Separator,{}),t.jsx(e.Item,{className:Qn,onSelect:u=>{u.preventDefault(),d(!0)},children:"Pick a date and timeâ¦"}),r?t.jsxs(t.Fragment,{children:[t.jsx(e.Separator,{}),t.jsx(e.Item,{className:Qn,onSelect:()=>a([r.automationId]),children:"Remove snooze"})]}):null]})}const Ct=Array.from({length:48},(e,n)=>P(Cs(new Date(2e3,0,1),n*30),"HH:mm"));function xc({request:e,onBack:n}){const{automate:s}=Y(),[a,r]=g.useState(""),[o,d]=g.useState(!0),[l,i]=g.useState(null),c=g.useRef(null);g.useEffect(()=>{c.current?.focus()},[]);const u=new Date,x=Yr(a,u),m=x!==null&&x>u;let p="Try âfri 3pmâ or âoct 12 9amâ";a.trim()&&!x?p="Couldn't read that":x&&!m&&(p="That time has passed");const f=y=>{r(y),i(null),c.current?.focus()},h=y=>P(Ye(y,"HH:mm",u),"h:mmaaa"),b=y=>f(`${P(y,"EEE MMM d")} ${x?P(x,"h:mmaaa"):"9am"}`),w=y=>f(`${P(x??u,"EEE MMM d")} ${h(y)}`),S=()=>{m&&(s(Ss(e,x)),qt())},j=x?P(x,"HH:mm"):"",v=j&&!Ct.includes(j)?[...Ct,j].sort():Ct;return t.jsxs("div",{className:"w-[17rem]",onKeyDown:y=>y.key!=="Escape"&&y.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-1 px-1.5 pt-1.5",children:[t.jsx("button",{type:"button",onClick:n,"aria-label":"Back to presets",className:"inline-flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground",children:t.jsx(Zs,{className:"size-3.5"})}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Snooze until"})]}),t.jsxs("div",{className:"px-2.5 pt-1.5",children:[t.jsxs("div",{className:"flex h-8 items-center gap-1.5 rounded-md border bg-background px-2 focus-within:border-teal focus-within:ring-1 focus-within:ring-teal",children:[t.jsx(rn,{className:"size-3.5 flex-none text-muted-foreground"}),t.jsx("input",{ref:c,value:a,onChange:y=>{r(y.target.value),i(null)},onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),S())},placeholder:"fri 3pm","aria-label":"Snooze until",className:"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button",onClick:()=>d(y=>!y),"aria-label":o?"Hide calendar":"Show calendar",className:"inline-flex size-5 flex-none items-center justify-center rounded-sm bg-muted text-muted-foreground hover:text-foreground",children:o?t.jsx(Qr,{className:"size-3.5"}):t.jsx(F,{className:"size-3.5"})})]}),t.jsx("div",{className:"flex h-7 items-center justify-between text-xs","aria-live":"polite",children:m?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium text-teal",children:P(x,"EEE, MMM d · h:mm a")}),t.jsx("span",{className:"text-muted-foreground",children:ml(x,u,{addSuffix:!0})})]}):t.jsx("span",{className:"text-muted-foreground",children:p})})]}),o?t.jsx(hn,{mode:"single",selected:m?x:void 0,month:l??(m?x:u),onMonthChange:i,onSelect:y=>y&&b(y),disabled:{before:U(u)},className:"w-full border-t bg-transparent p-2.5 [--cell-size:30px]",classNames:{root:"w-full",month:"flex w-full flex-col gap-1.5",month_caption:"flex h-[26px] items-center justify-start pl-1",caption_label:"text-[12.5px] font-semibold",nav:"absolute top-0 right-0 flex items-center gap-1",button_previous:"inline-flex size-[26px] items-center justify-center rounded-sm text-foreground
1/75 hover:bg-muted",button_next:"inline-flex size-[26px] items-center justify-center rounded-sm text-foreground/75 hover:bg-muted",weekday:"flex h-6 flex-1 items-center justify-center text-[10.5px] font-normal text-muted-foreground",week:"mt-0.5 flex w-full gap-0.5",day:"flex-1 p-0 text-center",day_button:"h-[30px] w-full rounded-sm text-xs font-normal hover:bg-muted data-[selected-single=true]:bg-teal data-[selected-single=true]:font-semibold data-[selected-single=true]:text-inverse",today:"[&_button]:text-foreground [&_button]:ring-1 [&_button]:ring-teal [&_button]:ring-inset",outside:"text-muted-foreground/50",disabled:"text-muted-foreground/40"}}):null,t.jsxs("div",{className:"flex items-center gap-2 border-t px-2.5 py-2",children:[t.jsxs("label",{className:"relative inline-flex h-7 items-center gap-1 rounded-md border px-2 text-xs",children:[t.jsx(ht,{className:"size-3.5 text-muted-foreground"}),t.jsx("span",{children:j?P(Ye(j,"HH:mm",u),"h:mm a"):"Time"}),t.jsxs("select",{value:j,onChange:y=>w(y.target.value),"aria-label":"Time",className:"absolute inset-0 cursor-pointer opacity-0",children:[j?null:t.jsx("option",{value:"",children:"Time"}),v.map(y=>t.jsx("option",{value:y,children:P(Ye(y,"HH:mm",u),"h:mm a")},y))]})]}),t.jsx("span",{className:"flex-1"}),t.jsx("button",{type:"button",onClick:qt,className:"h-7 rounded-md px-2.5 text-xs font-medium text-foreground/75 hover:bg-muted",children:"Cancel"}),t.jsx("button",{type:"button",disabled:!m,onClick:S,className:"h-7 rounded-md bg-teal px-3 text-xs font-semibold text-inverse hover:bg-teal-hover active:bg-teal-active disabled:pointer-events-none disabled:opacity-50",children:"Snooze"})]})]})}function pc({parts:e,request:n}){const{shown:s,pending:a}=wn(n);return s?t.jsxs(e.Sub,{children:[t.jsxs(e.SubTrigger,{children:[t.jsx(De,{className:N("size-4 text-muted-foreground",a&&"fill-current text-teal")}),t.jsx("span",{className:"flex-1",children:"Snooze"}),a?t.jsx("span",{className:"text-xs text-muted-foreground",children:Da(a.at)}):null]}),t.jsx(e.SubContent,{className:"min-w-56",children:t.jsx(Aa,{parts:e,request:n})})]}):null}function Oa({request:e,compact:n=!1,className:s}){const{shown:a,pending:r}=wn(e),[o,d]=g.useState(!1),[l,i]=g.useState(!1),c=g.useRef(!1);if(!a)return null;const u=r?`Snoozed until ${ws(r.at)}`:"Snooze";return t.jsxs(Ae,{open:o,onOpenChange:x=>{d(x),i(!1),x||(c.current=!0)},children:[t.jsxs(nn,{open:l&&!o,onOpenChange:x=>{if(x&&c.current){c.current=!1;return}i(x)},children:[t.jsx(sn,{asChild:!0,children:t.jsx(Oe,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":u,className:N("inline-flex h-7 flex-none items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground",n&&!r&&"opacity-0 group-hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100",s),children:[t.jsx(De,{className:N("size-3.5",r&&"fill-current text-teal")}),r&&!n?t.jsx("span",{children:Da(r.at)}):null]})})}),t.jsx(an,{children:u})]}),t.jsx(Ee,{align:"start",className:"min-w-56",children:t.jsx(Aa,{parts:ka,request:e})})]})}function gc(e,n){const s=$e(),a=Vr(),r=Jr(),o=e.mindMapOccurrenceId?a.data?.items.find(i=>i.upcomingMeeting?.stableOccurrenceId===e.mindMapOccurrenceId):void 0,d=i=>{s({to:"/scratch-pad/map/$mapId",params:{mapId:i}})};return{run:()=>{if(o){d(o.id);return}e.mindMapOccurrenceId&&r.mutateAsync({title:n?.title?`${n.title} â mind map`:"Meeting mind map",upcomingMeeting:{stableOccurrenceId:e.mindMapOccurrenceId,title:n?.title?.trim()||"Untitled meeting",startsAt:n?.start??null}}).then(i=>d(i.id)).catch(()=>G.error("Could not create a mind map for this meeting"))},pending:r.isPending,label:o?"Open mind map":"Prepare a mind map"}}const fc=async e=>{try{await navigator.clipboard.writeText(e.map(n=>`${window.location.origin}${n}`).join(` 2`)),G.success(e.length===1?"Link copied to clipboard":`${e.length} links copied`)}catch{G.error("Failed to copy link")}};function Ea(e){const{actions:n,openShare:s,allow:a,flaggedKeys:r,setMark:o,unbookmark:d,openTags:l}=Y(),i=le("tags.use"),c=g.useMemo(()=>sa(e),[e]),u=e.length===1?e[0]:null,x=gc(c,u),m=c.upcomingEvents.filter(j=>a.allowKind(j)===null&&j.dedupKey!==null),p=Gt(c.bookmarkRefs,r),f=u!==null&&c.seriesRefs.length>0&&Gt(c.seriesRefs,r),h=p||f,b=()=>{const j=c.bookmarkRefs;if(f){p?d([...j,...c.seriesRefs],"this meeting and the series"):d(c.seriesRefs,"the series");return}if(p){n.refuseOversizedFanOut(j.length)||d(j);return}if(!u||!i){n.applyBookmark(!0,"Bookmarked");return}o(j,X,!0).then(v=>{v.failed>0?G.error("Failed to bookmark"):G.success("Bookmarked",{action:{label:"Add tags",onClick:()=>l(u.key)}})})},w=[];c.canCopyTranscripts&&n.canCopyTranscripts&&w.push({key:"copyTranscript",label:c.recordedIds.length===1?"Copy transcript":"Copy transcripts",icon:Mi,run:n.copyTranscripts}),c.mindMapOccurrenceId&&w.push({key:"mindMap",label:x.label,icon:Xr,run:x.run,disabled:x.pending}),c.canBookmark&&w.push({key:"bookmark",label:h?"Bookmarked":"Bookmark",icon:je,run:b,active:h,peekLabel:h?"Remove bookmark":"Bookmark",peekIcon:h?vi:je}),c.canSendNotetaker&&w.push({key:"sendNotetaker",label:"Send the note-taker",icon:Ms,run:ks}),a.active&&m.length>0&&w.push({key:"allowNotetaker",label:"Allow note-taker",icon:Ii,run:()=>{a.allowMany(m)}}),c.canShare&&w.push({key:"share",label:"Shareâ¦",icon:Zr,run:s,peekLabel:"Share"});const S=c.copyLinkPaths;return S&&w.push({key:"copyLink",label:S.length===1?"Copy link":"Copy links",icon:Ti,run:()=>{fc(S)}}),w}const Ve="size-4 text-muted-foreground";function me({action:e}){return e?t.jsxs(oe,{onSelect:e.run,disabled:e.disabled,children:[t.jsx(e.icon,{className:N(Ve,e.active&&"fill-current text-teal")}),e.label]}):null}function hc({targets:e}){const n=$e(),{state:s,applyGrants:a,tagsByKey:r,tagsOpenFor:o}=Y(),d=Ea(e),l=v=>d.find(y=>y.key===v),i=l("bookmark"),c=()=>{n({to:"/library"})}
2,u=e.length===1?e[0]:null,x=eo(u),m=fn(),p=le("tags.use"),f=u?.kind==="recorded"?u.source.detectedRisks:[],h=u?.kind==="recorded"?u.source.grantsMarkedBy:null,b=()=>{if(u)switch(u.kind){case"recorded":n({to:"/meetings/$meetingId",params:{meetingId:u.transcriptId}});return;case"live":n({to:"/meetings/live/$meetingId",params:{meetingId:u.meetingId}});return;case"action":n({to:"/action-logs",search:{focus:u.actionItemId}});return;case"upcoming":return}},w=()=>{s.prepEventId&&n({to:"/meetings/prep/$eventId",params:{eventId:s.prepEventId}})},S=u?[...s.bookmarkRefs,...s.seriesRefs]:[],j=[...new Map(S.flatMap(v=>r.get(Me(v.entityType,v.entityId))??bn).map(v=>[v.id,v])).values()];return t.jsxs(t.Fragment,{children:[t.jsxs(st,{className:"truncate",children:[s.header,s.subheader?t.jsx("div",{className:"truncate text-xs font-normal text-muted-foreground",children:s.subheader}):null]}),t.jsx(ke,{}),s.canOpen&&u?t.jsxs(oe,{onSelect:b,children:[t.jsx(Is,{className:Ve}),to(u)]}):null,x?t.jsx(pc,{parts:Nn,request:x}):null,t.jsx(me,{action:l("copyTranscript")}),s.canPrep?t.jsxs(oe,{onSelect:w,children:[t.jsx(ul,{className:Ve}),"Prep"]}):null,t.jsx(me,{action:l("mindMap")}),u?t.jsx(ic,{block:u}):null,i&&p?t.jsx(mc,{bookmarked:i.active??!1,tags:j,openOnMount:u!==null&&o===u.key,onToggle:i.run,children:t.jsx(uc,{refs:s.bookmarkRefs,seriesRefs:s.seriesRefs,onManageTags:c})}):null,i&&!p?t.jsx(me,{action:i}):null,m&&s.canMarkAudience?t.jsxs(jt,{children:[t.jsxs(bt,{children:[t.jsx(no,{className:Ve}),"Who can see this"]}),t.jsxs(vt,{className:"w-72",children:[h?t.jsx("p",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:ji(h)}):null,f.length>0?t.jsxs(t.Fragment,{children:[t.jsxs(st,{className:"flex items-center gap-1.5 text-amber-500",children:[t.jsx(so,{className:"size-3.5"}),"AI-detected risks"]}),t.jsx("div",{className:"max-h-48 overflow-y-auto px-2 pb-1.5",children:f.map((v,y)=>t.jsxs("div",{className:"pb-1.5",children:[t.jsx("p",{className:"text-xs font-semibold",children:ao[v.category]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:v.note})]},y))}),t.jsx(ke,{})]}):null,ro.map(v=>{const y=bi[v.key];return t.jsxs(oe,{className:"gap-2",onSelect:()=>a(s.audienceRefs,{grants:[...v.grants],restrictToGrants:v.restrictToGrants}),children:[t.jsx(y.icon,{className:N("size-4",y.className)}),t.jsxs("div",{className:"flex flex-1 flex-col",children:[t.jsx("span",{children:v.label}),t.jsx("span",{className:"text-xs text-muted-foreground",children:v.description})]}),s.audiencePreset?.key===v.key?t.jsx(W,{className:"size-4"}):null]},v.key)})]})]}):null,t.jsx(me,{action:l("sendNotetaker")}),t.jsx(me,{action:l("allowNotetaker")}),l("share")||l("copyLink")?t.jsx(ke,{}):null,t.jsx(me,{action:l("share")}),t.jsx(me,{action:l("copyLink")})]})}function jc({block:e,selection:n,children:s}){const[a,r]=g.useState(!1),{setTargets:o,clearTagsOpen:d}=Pe(),l=n.selectedKeySet.has(e.key),i=l?n.selectedBlocks:[e];return t.jsxs(Ql,{onOpenChange:c=>{c?(l||n.selectOnly(e.key),o(i)):d(),r(c)},children:[t.jsx(Vl,{asChild:!0,children:s}),t.jsx(Xl,{className:"w-64",children:a?t.jsx(hc,{targets:i}):null})]})}const kt={taskName:"",additionalNote:"",dueDate:null,dueTime:null,destination:null,tags:[],pbiTags:[],personalTagIds:[]},Pa=e=>e.taskName.trim().length>0&&e.destination!==null&&e.dueDate!==null,bc=(e,n)=>({taskName:e.taskName??"",additionalNote:e.additionalNote??"",dueDate:e.dueDate,dueTime:e.dueDate?e.dueTime??null:null,destination:e.destination,tags:e.tags,pbiTags:e.pbiTags,personalTagIds:n}),Mt=(e,n)=>e.length===n.length&&e.every(s=>n.includes(s)),Vn=(e,n)=>e.taskName.trim()!==n.taskName.trim()||e.additionalNote.trim()!==n.additionalNote.trim()||e.dueDate!==n.dueDate||e.dueTime!==n.dueTime||e.destination!==n.destination||!Mt(e.tags,n.tags)||!Mt(e.pbiTags,n.pbiTags)||!Mt(e.personalTagIds,n.personalTagIds),vc=(e,n)=>({...e,taskName:n.taskName.trim(),additionalNote:n.additionalNote.trim()?n.additionalNote:null,dueDate:n.dueDate,dueTime:n.dueDate?n.dueTime:null,destination:n.destination??e.destination,tags:n.tags,pbiTags:n.pbiTags});function yc({dirty:e,left:n,extra:s,adding:a=!1,saving:r,canSave:o,onCancel:d,onSave:l}){return t.jsxs("div",{className:"flex h-10 items-center gap-2 border-t pr-1.5 pl-2.5 text-[10.5px] text-muted-foreground",children:[e?t.jsxs("span",{className:"inline-flex items-center gap-[5px] font-medium text-amber-800 dark:text-amber-300",children:[t.jsx("span",{className:"size-1.5 rounded-full bg-amber-500"}),"Unsaved changes"]}):n,s,t.jsx("span",{className:"flex-1"}),t.jsx("button",{type:"button",onClick:d,className:"h-7 rounded-md px-2.5 text-xs font-medium text-foreground
2/75 hover:bg-muted",children:"Cancel"}),t.jsx("button",{type:"button",disabled:!o,onClick:l,className:"h-7 rounded-md bg-teal px-3 text-xs font-semibold text-inverse hover:bg-teal-hover active:bg-teal-active disabled:pointer-events-none disabled:opacity-50",children:a?r?"Addingâ¦":"Add":r?"Savingâ¦":"Save"})]})}const Nc=(e,n)=>{const s=n.trim().toLowerCase();if(!s)return[...e];const a=r=>{const o=r.toLowerCase();return o.startsWith(s)?0:o.split(/\s+/).some(d=>d.startsWith(s))?1:o.includes(s)?2:-1};return e.map(r=>({option:r,rank:a(r.label)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank).map(r=>r.option)};function wc({value:e,onChange:n,open:s,onOpenChange:a}){const r=oo(),o=io.filter(j=>j.value===e||r.has(j.value)),d=g.useId(),l=g.useRef(null),i=g.useRef(null),c=e?on(e):"",[u,x]=g.useState(null),[m,p]=g.useState(0),f=Nc(o,u??""),h=u?f[Math.min(m,f.length-1)]:void 0,b=u&&h&&h.label.toLowerCase().startsWith(u.toLowerCase())?h.label.slice(u.length):"",w=j=>{n(j),x(null),a(!1)},S=()=>{x(null),a(!1)};return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{htmlFor:d,className:"w-[74px] flex-none text-[11px] text-muted-foreground",children:"Destination"}),t.jsxs(te,{open:s,onOpenChange:a,children:[t.jsx(Ts,{asChild:!0,children:t.jsxs("div",{ref:l,className:N("flex h-[30px] min-w-0 flex-1 items-center gap-1.5 rounded-md border bg-card pr-1.5 pl-2 hover:border-ring",s&&"border-ring ring-[3px] ring-ring/25"),children:[t.jsxs("div",{className:"relative h-5 min-w-0 flex-1",children:[b?t.jsxs("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex items-center overflow-hidden text-xs leading-5 whitespace-pre",children:[t.jsx("span",{className:"invisible",children:u}),t.jsx("span",{className:"text-muted-foreground",children:b})]}):null,t.jsx("input",{ref:i,id:d,role:"combobox","aria-expanded":s,"aria-autocomplete":"both",autoComplete:"off",value:u??c,placeholder:"Select destination",onFocus:j=>{j.target.select(),a(!0)},onChange:j=>{x(j.target.value),p(0),a(!0)},onBlur:()=>{const j=o.find(v=>v.label.toLowerCase()===u?.trim().toLowerCase());j?w(j.value):S()},onKeyDown:j=>{if(j.key==="ArrowDown"||j.key==="ArrowUp"){j.preventDefault(),a(!0);const v=u?f:o;x(y=>y??""),p(y=>Math.max(0,Math.min(v.length-1,y+(j.key==="ArrowDown"?1:-1))))}else j.key==="Tab"&&!j.shiftKey&&h?w(h.value):j.key==="Enter"&&!(j.metaKey||j.ctrlKey)?(j.preventDefault(),j.stopPropagation(),h&&w(h.value)):j.key==="Escape"&&(j.stopPropagation(),S(),i.current?.blur())},className:"relative block h-5 w-full bg-transparent p-0 text-xs leading-5 outline-none placeholder:text-muted-foreground"})]}),t.jsx("button",{type:"button",tabIndex:-1,"aria-label":"Show destinations",onMouseDown:j=>j.preventDefault(),onClick:()=>{i.current?.focus(),a(!s)},className:"inline-flex size-5 flex-none items-center justify-center rounded-sm text-muted-foreground hover:bg-muted",children:t.jsx(F,{className:"size-3.5"})})]})}),t.jsx(ne,{align:"start",onOpenAutoFocus:j=>j.preventDefault(),onEscapeKeyDown:j=>j.preventDefault(),onInteractOutside:j=>{l.current?.contains(j.target)&&j.preventDefault()},className:"w-[max(220px,var(--radix-popover-trigger-width))] overflow-hidden p-1 shadow-lg",children:t.jsx("div",{role:"listbox",className:"max-h-60 overflow-y-auto",children:(u?f:o).length===0?t.jsx("p",{className:"px-2 py-2.5 text-xs text-muted-foreground",children:"No matches"}):(u?f:o).map((j,v)=>t.jsxs("button",{type:"button",role:"option","aria-selected":j.value===e,onMouseDown:y=>y.preventDefault(),onClick:()=>w(j.value),onMouseEnter:()=>u!==null&&p(v),className:N("flex h-[30px] w-full items-center gap-2 rounded-md px-2 text-left text-[12.5px] hover:bg-muted",u!==null&&v===Math.min(m,f.length-1)&&"bg-muted"),children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label}),j.value===e?t.jsx(W,{className:"size-3.5"}):null]},j.value))})})]})]})}const It=Array.from({length:29},(e,n)=>P(Cs(new Date(2e3,0,1,7,0),n*30),"HH:mm"));function Sc({value:e,today:n,open:s,onOpenChange:a,onChange:r,onSaveCard:o,children:d}){const l=g.useId(),i=g.useRef(null),c=g.useRef(!1),u=et(e.dueDate,e.dueTime,n)??"",[x,m]=g.useState(null),[p,f]=g.useState(!1),h=x!==null&&x.trim()!==u,b=h&&x.trim()?lo(x,n):null,w=h&&x.trim()!==""&&b===null,S=()=>{h&&(x.trim()?b&&r({dueDate:b.date,dueTime:b.time}):r({dueDate:null,dueTime:null})),m(null)};return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{htmlFor:l,className:"w-[74px] flex-none text-[11px] text-muted-foreground",children:"Due"}),t.jsxs(te,{open:s,onOpenChange:a,children:[t.jsx(Ts,{asChild:!0,children:t.jsxs("div",{className:N("flex h-[30px] min-w-0 flex-1 items-center gap-1.5 rounded-md border bg-card pr-1 pl-2",(p||s)&&"border-ring ring-[3px] ring-ring/25",w&&"border-destructive/55"),children:[t.jsx(rn,{className:N("size-[13px] flex-none",b?"text-teal":"text-muted-foreground")}),t.jsx("input",{ref:i,id:l,autoComplete:"off",value:x??u,placeholder:"No date · type e.g. next fri 3pm",onFocus:j=>{f(!0),j.target.select()},onChange:j=>m(j.target.value),onBlur:()=>{f(!1),c.current?c.current=!1:S()},onKeyDown:j=>{if(j.key==="Enter"){j.preventDefault(),j.stopPropagation(),S(),(j.metaKey||j.ctrlKey)&&o();const v=j.currentTarget;requestAnimationFrame(()=>v.select())}else j.key==="Escape"&&(j.stopPropagation(),c.current=!0,m(null),i.current?.blur())},className:"block h-5 min-w-0 flex-1 bg-transparent p-0 text-xs leading-5 outline-none placeholder:text-muted-foreground"}),t.jsx("button",{type:"button","aria-label":"Pick a due date",onMouseDown:j=>j.preventDefault(),onClick:()=>a(!s),className:"inline-flex size-6 flex-none items-center justify-center rounded-sm text-muted-foreground hover:bg-muted",children:t.jsx(F,{className:"size-3.5"})})]})}),t.jsx(ne,{align:"start",onEscapeKeyDown:j=>j.preventDefault(),className:"w-[260px] overflow-hidden p-0 shadow-lg",children:d})]})]}),h&&x.trim()?t.jsxs("p",{role:"status",className:N("flex min-w-0 items-center gap-1.5 pt-1 pl-[82px] text-[11px]",b?"text-muted-foreground":"text-destructive"),children:[b?t.jsx(W,{className:"size-3 flex-none text-teal-active",strokeWidth:2.5}):t.jsx(Ds,{className:"size-3 flex-none",strokeWidth:2.5}),t.jsx("span",{className:N("flex-none font-semibold",b&&"text-teal-active"),children:b?et(b.date,b.time,n):"Not a date"}),b?t.jsx("span",{className:"flex-none",children:"· âµ to set"}):null]}):null]})}function Cc({value:e,today:n,onChange:s,onClear:a}){const r=e.dueDate?co(e.dueDate):void 0,[o,d]=g.useState(r??n),l=e.dueTime&&!It.includes(e.dueTime)?[e.dueTime,...It].sort():It;return t.jsxs(t.Fragment,{children:[t.jsx(hn,{mode:"single",required:!0,selected:r,onSelect:i=>s({dueDate:P(i,ie)}),month:o,onMonthChange:d,today:n,modifiers:{past:{before:U(n)}},modifiersClassNames:{past:"text-muted-foreground"},className:"w-full p-2.5 [--cell-size:30px]",classNames:{root:"w-full",month:"flex w-full flex-col gap-1.5",month_caption:"flex h-[26px] items-center justify-start pl-1",caption_label:"text-[12.5px] font-semibold",nav:"absolute top-2.5 right-2.5 flex items-center gap-1",button_previous:"inline-flex size-[26px] items-center justify-center rounded-sm text-foreground
2/75 hover:bg-muted",button_next:"inline-flex size-[26px] items-center justify-center rounded-sm text-foreground/75 hover:bg-muted",weekday:"flex h-6 flex-1 items-center justify-center text-[10.5px] font-normal text-muted-foreground",week:"mt-0.5 flex w-full gap-0.5",day:"flex-1 p-0 text-center",day_button:"h-[30px] w-full rounded-sm text-xs font-normal hover:bg-muted data-[selected-single=true]:bg-teal data-[selected-single=true]:font-semibold data-[selected-single=true]:text-white",today:"[&_button]:font-semibold [&_button]:ring-1 [&_button]:ring-teal [&_button]:ring-inset",outside:"text-muted-foreground/50"}}),t.jsxs("div",{className:"flex items-center gap-2 border-t px-2.5 py-2",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Time"}),t.jsxs("select",{value:e.dueTime??"",onChange:i=>{const c=i.target.value||null;s(e.dueDate||!c?{dueTime:c}:{dueTime:c,dueDate:P(n,ie)})},"aria-label":"Due time",className:"h-7 flex-1 rounded-sm border bg-card px-1.5 text-xs",children:[t.jsx("option",{value:"",children:"No time"}),l.map(i=>t.jsx("option",{value:i,children:As(i)},i))]}),t.jsx("button",{type:"button",onClick:a,className:"px-0.5 text-[11px] font-medium text-muted-foreground hover:text-foreground",children:"Clear"})]})]})}function Yt({label:e,open:n,onOpenChange:s,width:a="w-[max(220px,var(--radix-popover-trigger-width))]",trigger:r,children:o}){return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-[74px] flex-none text-[11px] text-muted-foreground",children:e}),t.jsxs(te,{open:n,onOpenChange:s,children:[t.jsx(ve,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":e,className:N("flex h-[30px] min-w-0 flex-1 items-center gap-1.5 rounded-md border bg-card pr-1.5 pl-2 text-left hover:border-ring",n&&"border-ring ring-[3px] ring-ring/25"),children:[t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:r}),t.jsx(F,{className:"size-3.5 flex-none text-muted-foreground"})]})}),t.jsx(ne,{align:"start",onEscapeKeyDown:d=>d.preventDefault(),onOpenAutoFocus:d=>{d.currentTarget.querySelector("input")||d.preventDefault()},className:N("overflow-hidden p-0 shadow-lg",a),children:o})]})]})}const _a=e=>e instanceof Element&&e.closest('[data-slot="dropdown-menu-content"]')!==null,Ra=e=>_a(e)||e instanceof Element&&e.closest('[data-slot="popover-content"]')!==null;function kc(){const[e,n]=g.useState(null);return g.useEffect(()=>{if(!e)return;const s=a=>{Ra(a.target)||n(null)};return document.addEventListener("scroll",s,!0),()=>document.removeEventListener("scroll",s,!0)},[e]),{open:e,close:()=>n(null),props:s=>({open:e===s,onOpenChange:a=>n(a?s:null)})}}function Mc({title:e,onTitleChange:n,titlePlaceholder:s,note:a,onNoteChange:r,done:o=!1,onToggleDone:d,peek:l=!1,menus:i,className:c,subtitle:u,onSave:x,onMinimize:m,children:p,footer:f}){const h=g.useRef(null);return g.useEffect(()=>{if(l)return;const b=w=>{Ra(w.target)||h.current&&!h.current.contains(w.target)&&m()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[m,l]),t.jsxs("div",{ref:h,onKeyDown:b=>{if(b.key==="Escape"){if(b.stopPropagation(),_a(b.target))return;i.open?i.close():m()}else b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),x())},className:N("rounded-md border border-ring bg-card shadow-[0_4px_12px_rgba(0,0,0,0.06)] ring-[3px] ring-ring/25",c),children:[t.jsxs("div",{className:"flex gap-2.5 px-2.5 pt-[9px] pb-2",children:[d?t.jsx(jn,{checked:o,onCheckedChange:b=>d(!!b),"aria-label":"Mark as done",className:"mt-0.5 size-[15px] flex-none"}):null,t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-[3px]",children:[t.jsx("input",{autoFocus:!l,value:e,onChange:b=>n(b.target.value),onFocus:b=>b.target.setSelectionRange(b.target.value.length,b.target.value.length),onKeyDown:b=>{b.key==="Enter"&&!b.nativeEvent.isComposing&&(b.preventDefault(),x())},placeholder:s,"aria-label":"Title",className:N("w-full bg-transparent text-[13px] leading-[1.35] font-medium outline-none",o&&"text-muted-foreground line-through")}),u,t.jsx("textarea",{value:a,onChange:b=>r(b.target.value),placeholder:"Add a note","aria-label":"Note",rows:1,className:"mt-[3px] min-h-[18px] w-full resize-none bg-transparent text-xs leading-[1.45] text-foreground
2/75 outline-none [field-sizing:content]"})]}),t.jsx("button",{type:"button",onClick:m,title:l?"Close · keeps your changes (Esc)":"Minimize · keeps your changes (Esc)","aria-label":l?"Close":"Minimize",className:"-mt-[3px] -mr-1 inline-flex size-6 flex-none items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",children:l?t.jsx(Ds,{className:"size-3.5"}):t.jsx(Ai,{className:"size-3.5"})})]}),t.jsx("div",{className:"flex flex-col gap-1.5 border-t px-2.5 pt-2 pb-2.5",children:p}),f]})}const Re="h-[30px] flex-none whitespace-nowrap rounded-md border bg-card px-2.5 text-xs font-medium dark:bg-input/30",Sn="flex h-[30px] min-w-0 flex-1 items-center gap-1.5 rounded-md border bg-card pr-1.5 pl-2 text-left text-xs hover:border-ring disabled:pointer-events-none disabled:opacity-50",Tt=2,Ic=(e,n)=>e.includes(n)?e.filter(s=>s!==n):[...e,n];function Tc({children:e}){return t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:e})}function Ie({empty:e,chips:n}){return n.length===0?t.jsx(Tc,{children:e}):t.jsxs(t.Fragment,{children:[n.slice(0,Tt).map(s=>t.jsx("span",{className:N("inline-flex h-[19px] max-w-[110px] flex-none items-center truncate rounded-sm px-[7px] text-[10.5px] font-semibold",s.className),children:t.jsx("span",{className:"truncate",children:s.label})},s.key)),n.length>Tt?t.jsxs("span",{className:"flex-none whitespace-nowrap text-[10.5px] font-medium text-muted-foreground",children:["+",String(n.length-Tt)," more"]}):null]})}function Dc({on:e}){return t.jsx("span",{className:N("inline-flex size-[15px] flex-none items-center justify-center rounded-[4px] border",e&&"border-foreground bg-foreground text-background"),children:e?t.jsx(W,{className:"size-2.5 text-background",strokeWidth:3.5}):null})}function at({options:e,selected:n,placeholder:s,onChange:a,onCreate:r}){const[o,d]=g.useState(""),l=o.trim().toLowerCase(),i=e.filter(p=>p.label.toLowerCase().includes(l)),c=r!==void 0&&l.length>0&&!e.some(p=>p.label.toLowerCase()===l),u=()=>{r?.(o.trim()),d("")},x=[...new Set(e.map(p=>p.group))],m=p=>t.jsxs(fo,{value:p.group?`${p.group} ${p.label}`:p.label,onSelect:()=>a(Ic(n,p.value)),className:"h-[30px] gap-2 rounded-md px-2 text-[12.5px] data-[selected=true]:bg-muted",children:[t.jsx(Dc,{on:n.includes(p.value)}),p.dot?t.jsx("span",{className:N("size-[9px] flex-none rounded-full",p.dot)}):null,t.jsx("span",{className:"min-w-0 flex-1 truncate",children:p.label})]},p.value);return t.jsxs(uo,{children:[t.jsx("div",{className:"border-b p-1.5",children:t.jsx(mo.Input,{autoFocus:!0,value:o,onValueChange:d,onKeyDown:p=>{p.key==="Enter"&&i.length===0&&c&&(p.preventDefault(),u())},placeholder:s,className:"h-[30px] w-full rounded-sm border bg-card px-2 text-xs outline-none placeholder:text-muted-foreground"})}),t.jsxs(xo,{className:"max-h-60 p-1",children:[t.jsx(po,{className:"px-2 py-2.5 text-xs text-muted-foreground",children:"No matches"}),x.map(p=>p?t.jsx(go,{heading:p,className:"p-0",children:e.filter(f=>f.group===p).map(m)},p):e.filter(f=>!f.group).map(m))]}),c?t.jsxs("button",{type:"button",onClick:u,className:"flex h-[34px] w-full items-center gap-2 border-t bg-muted/50 px-3 text-left text-xs hover:bg-muted",children:[t.jsx(lt,{className:"size-[13px]"})," Create â",o.trim(),"â"]}):null,t.jsxs("div",{className:"flex h-8 items-center border-t px-3 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"flex-1",children:[String(n.length)," selected"]}),t.jsx("button",{type:"button",onClick:()=>a([]),disabled:n.length===0,className:"font-medium hover:text-foreground disabled:opacity-50",children:"Clear"})]})]})}function Ce({label:e,options:n,value:s,empty:a,placeholder:r,disabled:o=!1,onChange:d}){const[l,i]=g.useState(!1),c=new Map(n.map(u=>[u.value,u.label]));return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-[84px] flex-none text-[11px] text-muted-foreground",children:e}),t.jsxs(te,{open:l,onOpenChange:i,children:[t.jsx(ve,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":e,disabled:o,className:N(Sn,l&&"border-ring ring-[3px] ring-ring/25"),children:[t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:t.jsx(Ie,{empty:a,chips:s.map(u=>({key:u,label:c.get(u)??u,className:"border bg-muted text-foreground"}))})}),t.jsx(F,{className:"size-3.5 flex-none text-muted-foreground"})]})}),t.jsx(ne,{align:"start",className:"w-[max(240px,var(--radix-popover-trigger-width))] overflow-hidden p-0 shadow-lg",children:t.jsx(at,{options:n,selected:s,placeholder:r,onChange:d})})]})]})}function Ac({tags:e,selected:n,onChange:s,onCreated:a,open:r,onOpenChange:o}){const d=Qs(),l=new Map(e.map(c=>[c.id,c])),i=n.map(c=>l.get(c)).filter(c=>c!==void 0);return t.jsx(Yt,{label:"Personal",open:r,onOpenChange:o,trigger:t.jsx(Ie,{empty:"Select personal tags",chips:i.map(c=>
2({key:c.id,label:c.name,className:ui[c.color]}))}),children:t.jsx(at,{options:e.map(c=>({value:c.id,label:c.name,dot:Ge[c.color]})),selected:n,placeholder:"Search or create a tag",onChange:s,onCreate:c=>{d.mutateAsync({name:c,color:Vs(e.length)}).then(u=>a(u.id))}})})}const Jn="border bg-muted text-foreground",Oc=new Map(ln.map(e=>[e.value,e.label])),Ec=new Map(cn.map(e=>[e.value,e.label])),Pc=e=>{const n=[e.taskName.trim()?null:"a title",e.destination?null:"a destination",e.dueDate?null:"a due date"].filter(s=>s!==null);return n.length===0?null:`Needs ${n.length>1?`${n.slice(0,-1).join(", ")} and ${n.at(-1)??""}`:n[0]}`};function Cn({item:e,draft:n,dirty:s,saving:a,done:r=!1,today:o,personalTags:d,onChange:l,onToggleDone:i,onSave:c,onCancel:u,onMinimize:x,className:m="-mx-1.5 my-1",peek:p=!1,footerAction:f=null}){const h=kc(),b=e===null,w=!a&&(b?Pa(n):s&&n.taskName.trim().length>0),S=()=>{w&&c()},j=g.useRef(S);g.useEffect(()=>{j.current=S});const v=T=>l(A=>({...A,...T})),y=e?.transcriptRef?t.jsxs(xe,{to:"/meetings/$meetingId",params:{meetingId:e.transcriptRef.id},className:"min-w-0 truncate text-[10.5px] text-muted-foreground hover:underline",children:["From · ",e.sourceProvenance?.meetingName??"a meeting"]}):null;let k=null;return e===null?k=t.jsx("span",{className:"truncate",children:Pc(n)}):p?k=t.jsxs(nn,{children:[t.jsx(sn,{asChild:!0,children:t.jsx(xe,{to:"/action-logs",search:{focus:e.id},"aria-label":"Open in Action Logs",className:"inline-flex size-7 items-center justify-center rounded-md hover:bg-accent hover:text-foreground",children:t.jsx(ho,{className:"size-3.5"})})}),t.jsx(an,{children:"Open in Action Logs"})]}):k=t.jsx(xe,{to:"/action-logs",search:{focus:e.id},className:"font-medium whitespace-nowrap hover:text-foreground hover:underline",children:"Open in Action Logs"}),t.jsxs(Mc,{title:n.taskName,onTitleChange:T=>v({taskName:T}),titlePlaceholder:b?"What needs doing?":"Action item title",note:n.additionalNote,onNoteChange:T=>v({additionalNote:T}),done:r,onToggleDone:i,peek:p,menus:h,className:m,subtitle:y,onSave:S,onMinimize:x,footer:t.jsx(yc,{dirty:!b&&s,left:k,extra:f,adding:b,saving:a,canSave:w,onCancel:u,onSave:S}),children:[t.jsx(Sc,{...h.props("due"),value:n,today:o,onChange:v,onSaveCard:()=>setTimeout(()=>j.current(),0),children:t.jsx(Cc,{value:n,today:o,onChange:v,onClear:()=>{v({dueDate:null,dueTime:null}),h.close()}})}),t.jsx(wc,{...h.props("destination"),value:n.destination,onChange:T=>v({destination:T})}),b?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-[74px] flex-none text-[11px] text-muted-foreground",children:"Responsible"}),t.jsx("span",{className:"flex h-[30px] min-w-0 flex-1 items-center rounded-md bg-muted/60 px-2 text-xs",children:"You"})]}):null,t.jsx(Yt,{label:"Tags",...h.props("tags"),trigger:t.jsx(Ie,{empty:"Select tags",chips:n.tags.map(T=>({key:T,label:Oc.get(T)??T,className:Jn}))}),children:t.jsx(at,{options:ln,selected:n.tags,placeholder:"Search tags",onChange:T=>v({tags:T})})}),t.jsx(Yt,{label:"PBI tags",...h.props("pbiTags"),trigger:t.jsx(Ie,{empty:"Select PBI tags",chips:n.pbiTags.map(T=>({key:T,label:Ec.get(T)??T,className:Jn}))}),children:t.jsx(at,{options:cn,selected:n.pbiTags,placeholder:"Search PBI tags",onChange:T=>v({pbiTags:T})})}),d?t.jsx(Ac,{...h.props("personal"),tags:d,selected:n.personalTagIds,onChange:T=>v({personalTagIds:T}),onCreated:T=>l(A=>({...A,personalTagIds:[...A.personalTagIds,T]}))}):null]})}const La=g.createContext(null);function _c({children:e}){const[n,s]=g.useState({action:{}}),[a,r]=g.useState(null),o=Object.keys(n.action).length>0;lr({shouldBlockFn:({current:l,next:i})=>l.pathname!==i.pathname&&!window.confirm("You have unsaved changes that will be lost. Leave anyway?"),enableBeforeUnload:o,disabled:!o});const d=g.useMemo(()=>({drafts:n,setDrafts:s,openItem:a,setOpenItem:r}),[n,a]);return t.jsx(La.Provider,{value:d,children:e})}const za=()=>{const e=g.useContext(La);if(!e)throw new Error("Item drafts need an ItemDraftsProvider");return e};function Rc(){const{openItem:e,setOpenItem:n}=za();return{openItem:e,setOpenItem:n}}const Xn=(e,n)=>{const s={...e};return delete s[n],s};function Lc(e,n){const{drafts:s,setDrafts:a}=za(),r=s[e],o=l=>a(i=>({...i,[e]:l(i[e])}));return{draftOf:(l,i)=>r[l]??i,isDirty:(l,i)=>{const c=r[l];return c?n(c,i):!1},change:(l,i,c)=>o(u=>({...u,[l]:c(u[l]??i)})),drop:l=>o(i=>Xn(i,l)),dropIfUnedited:(l,i)=>o(c=>c[l]===i?Xn(c,l):c)}}const zc=(e,n)=>({add:e.personalTagIds.filter(s=>!n.personalTagIds.includes(s)),remove:n.personalTagIds.filter(s=>!e.personalTagIds.includes(s))});function Fc(){const e=pi();return(n,s,a,r)=>{const{add:o,remove:d}=zc(a,r);return o.length===0&&d.length===0?Promise.resolve(!0):e.mutateAsync({entityType:n,entity
2Id:s,add:o,remove:d}).then(()=>!0,()=>!1)}}const kn=e=>typeof e=="object"&&e!==null&&Array.isArray(e.items),Mn=e=>typeof e=="object"&&e!==null&&Array.isArray(e.pages)&&e.pages.every(kn),Fa=e=>Array.isArray(e)?e:Mn(e)?e.pages.flatMap(n=>n.items):kn(e)?e.items:[],Dt=(e,n)=>Array.isArray(e)?n(e):Mn(e)?{...e,pages:e.pages.map(s=>({...s,items:n(s.items)}))}:kn(e)?{...e,items:n(e.items)}:e,$c=(e,n,s)=>e.getQueriesData({queryKey:n}).flatMap(([,a])=>Fa(a)).find(a=>a.id===s),Bc=(e,n,s,a)=>{for(const[r,o]of e.getQueriesData({queryKey:n})){if(o===void 0)continue;const d=Fa(o).some(i=>i.id===s.id),l=a?a(s,r):null;d&&l===!1?e.setQueryData(r,Dt(o,i=>i.filter(c=>c.id!==s.id))):d?e.setQueryData(r,Dt(o,i=>i.map(c=>c.id===s.id?s:c))):l===!0&&!Mn(o)&&e.setQueryData(r,Dt(o,i=>[...i,s]))}},Kc=(e,n)=>$c(e,$t.all,n),Gc=(e,n)=>{if(n[1]!=="calendar")return null;const s=n[n.length-1];return e.dueDate!==null&&(!s.dueDateFrom||e.dueDate>=s.dueDateFrom)&&(!s.dueDateTo||e.dueDate<=s.dueDateTo)},Zn=(e,n)=>{e.cancelQueries({queryKey:$t.all}),Bc(e,$t.all,n,Gc)};function $a(){const e=Be(),n=Os();return g.useCallback((s,a)=>{const r=Kc(e,s);if(!r)return null;const o=a(r);return o===r?null:(Zn(e,o),n.mutateAsync(Es({items:[o]})).catch(d=>{throw Zn(e,r),d}))},[e,n])}function In(){const e=Lc("action",Vn),n=le("tags.use"),{tags:s,tagsByKey:a}=Pe(),r=$a(),o=Fc(),d=n?s:null,l=c=>d?a.get(mi("actionItem",c.id))??[]:[],i=c=>bc(c,l(c).map(u=>u.id));return{personalTags:d,draftOf:c=>e.draftOf(c.id,i(c)),isDirty:c=>e.isDirty(c.id,i(c)),change:(c,u)=>e.change(c.id,i(c),u),close:c=>{c&&!e.isDirty(c.id,i(c))&&e.drop(c.id)},cancel:c=>e.drop(c.id),toggleDone:(c,u)=>{r(c.id,x=>({...x,done:u}))?.catch(x=>G.error(`Could not update: ${x.message}`))},save:c=>{const u=i(c),x=e.draftOf(c.id,u),m=x.taskName.trim(),p=o("actionItem",c.id,x,u),f=Vn({...x,personalTagIds:[]},{...u,personalTagIds:[]})?r(c.id,h=>vc(h,x))?.then(()=>!0,h=>(G.error(`Save failed: ${h.message}. Your changes are kept.`),!1))??!1:!0;Promise.all([p,f]).then(([h,b])=>{!h||!b||(e.dropIfUnedited(c.id,x),G.success(`Saved â${m}â`))})}}}function Uc({block:e,now:n,onClose:s}){const a=In(),r=e.source,o=g.useRef(()=>a.close(r));return g.useEffect(()=>{o.current=()=>a.close(r)}),g.useEffect(()=>()=>o.current(),[]),t.jsx(Cn,{peek:!0,className:"rounded-none border-0 shadow-none ring-0",item:r,draft:a.draftOf(r),dirty:a.isDirty(r),saving:!1,done:tt(r),today:U(n),personalTags:a.personalTags,onChange:d=>a.change(r,d),onToggleDone:d=>a.toggleDone(r,d),onSave:()=>{s(),a.save(r)},onCancel:()=>{a.cancel(r),s()},onMinimize:s,footerAction:t.jsx(Oa,{request:{subject:{type:"action_item",id:r.id},title:e.title}})})}function ee({icon:e,children:n}){return t.jsxs("div",{className:"flex gap-2.5 px-3 py-2",children:[t.jsx(e,{className:"mt-0.5 size-3.5 flex-none text-muted-foreground"}),t.jsx("div",{className:"min-w-0 text-xs",children:n})]})}const Hc=(e,n)=>{const s=Math.max(0,Math.round((n.getTime()-e.getTime())/6e4)),a=Math.floor(s/60),r=s%60;return a>0?`${String(a)}h ${String(r)}m`:`${String(s)}m`};function qc({block:e,now:n}){const{source:s,start:a,meetingId:r}=e;return t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-3 pb-2",children:[t.jsx("div",{className:"min-w-0 flex-1 font-semibold leading-snug break-words",children:e.title}),t.jsx("span",{className:"inline-flex h-[15px] items-center rounded-full bg-danger-subtle px-1.5 text-[10px] font-semibold text-danger-foreground",children:"Live"})]}),t.jsxs("div",{className:"flex gap-1.5 px-3 pb-2",children:[t.jsxs(xe,{to:"/meetings/live/$meetingId",params:{meetingId:r},className:"inline-flex h-7 items-center gap-1 rounded-md bg-teal px-2.5 text-xs font-medium text-inverse",children:[t.jsx(jo,{className:"size-3.5"}),"Watch live"]}),s.meetingLink?t.jsxs("a",{href:s.meetingLink,target:"_blank",rel:"noreferrer noopener",className:"inline-flex h-7 items-center gap-1 rounded-md border px-2.5 text-xs font-medium hover:bg-muted",children:[t.jsx(Ps,{className:"size-3.5"}),"Join"]}):null]}),t.jsx(q,{}),t.jsxs(ee,{icon:ht,children:["Started ",ye(a,null,!1)," · ",Hc(a,n)]}),s.participantEmails.length>0?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsxs(ee,{icon:dn,children:[s.participantEmails.length," in the meeting"]})]}):null]})}function Wc({block:e,now:n}){const{automations:s}=Y(),a=_s(),r=bo(s,e);return r.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 text-xs font-semibold",children:[t.jsx(De,{className:"size-3.5 text-muted-foreground"}),"Reminders"]}),t.jsx("ul",{className:"flex flex-col gap-1.5 px-3 py-2",children:r.map(o=>t.jsxs("li",{className:"flex items-start gap-2 text-xs",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"leading-snug",children:[it[o.action.kind].label,t.jsxs("span",{className:"text-muted-foreground",children:[" · ",vo(o)]})]}),e.kind==="recorded"&&yo(o,e)?.status==="awaiting_you"?t.jsx(xe,{to:"/meetings/$meetingId/send-summary",params:{meetingId:e.transcriptId},className:"text-teal-700 hover:underline dark:text-teal-300",children:Bn(o,e,n)}):t.jsx("span",{className:"text-teal-700 dark:text-teal-300",children:Bn(o,e,n)})]}),o.status!=="ended"?t.jsx("button",{type:"button",onClick:()=>a.mutate(o.id),className:"flex-none text-[11px] text-muted-foreground hover:text-foreground hover:underline",children:"Remove"}):null]},o.id))})]})}function Yc({event:e,allow:n}){if(!n.active)return e.covered?t.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(W,{className:"size-3"})," Note-taker booked"]}):null;const s=n.allowKind(e);return s!==null?t.jsxs(R,{variant:"default",size:"sm",className:"h-7",disabled:n.saving,title:s==="series"?"Joining this and every meeting in the series â press to stop":"Joining this meeting â press to stop",onClick:()=>{n.disallow(e)},children:[t.jsx(W,{className:"size-3"}),s==="series"?"Joining · series":"Joining"]}):t.jsxs("span",{className:"inline-flex flex-none",children:[t.jsx("span",{className:"mr-2 self-center text-xs text-muted-foreground",children:"Not joining"}),t.jsx(R,{variant:"outline",size:"sm",className:"h-7 rounded-r-none border-r-0",disabled:n.saving||e.dedupKey===null,onClick:()=>{n.allowOnce(e)},children:"Allow"}),t.jsxs(Ae,{children:[t.jsx(Oe,{asChild:!0,children:t.jsx(R,{variant:"outline",size:"sm",className:"h-7 rounded-l-none px-1.5",disabled:n.saving,"aria-label":"Allow options",children:t.jsx(F,{className:"size-3"})})}),t.jsxs(Ee,{align:"end",className:"w-56",children:[t.jsx(pe,{disabled:e.dedupKey===null,onSelect:()=>{n.allowOnce(e)},children:t.jsxs("span",{className:"flex flex-col",children:[t.jsx("span",{children:"Just this meeting"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"The one occurrence"})]})}),t.jsx(pe,{disabled:e.icalUid===null,onSelect:()=>{n.allowSeries(e)},children:t.jsxs("span",{className:"flex flex-col",children:[t.jsx("span",{children:"This and future meetings"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"Every occurrence in the series"})]})})]})]})]})}function Qc({status:e,className:n}){const{dot:s,glyph:a}=vn[e.state];return t.jsx("span",{title:Ut(e),"aria-label":Ut(e),className:N("inline-flex size-3 flex-none items-center justify-center rounded-full text-[8px] font-bold leading-none",s,n),children:a})}function Ba(){const e=Rs(),n=Be(),s=Xe({queryKey:Z.recordingSettings,queryFn:()=>e.getRecordingSettings(),staleTime:6e4,retry:!1}),a=cr({mutationFn:o=>e.setRecordingSettings(o),onSuccess:async o=>
2{n.setQueryData(Z.recordingSettings,o),await n.invalidateQueries({queryKey:Z.upcoming})},onError:()=>{G.error("Couldn't update the note-taker for that meeting.")}}),r=s.data;return g.useMemo(()=>{const o=r?.allows??[],d=l=>{r&&a.mutate({...r,allows:l})};return{active:r?.mode==="allowlist",saving:a.isPending,allowKind:l=>o.find(i=>i.scope==="once"?i.dedupKey===l.dedupKey:l.icalUid!==null&&i.icalUid===l.icalUid)?.scope??null,allowOnce:l=>{l.dedupKey!==null&&d([...o,{scope:"once",dedupKey:l.dedupKey}])},allowSeries:l=>{l.icalUid!==null&&d([...o,{scope:"series",icalUid:l.icalUid}])},allowMany:l=>{const i=[],c=new Set;for(const m of l)if(m.icalUid!==null){if(c.has(`s:${m.icalUid}`))continue;c.add(`s:${m.icalUid}`),i.push({scope:"series",icalUid:m.icalUid})}else if(m.dedupKey!==null){if(c.has(`o:${m.dedupKey}`))continue;c.add(`o:${m.dedupKey}`),i.push({scope:"once",dedupKey:m.dedupKey})}const u=new Set(o.map(m=>m.scope==="once"?`o:${m.dedupKey}`:`s:${m.icalUid}`)),x=i.filter(m=>!u.has(m.scope==="once"?`o:${m.dedupKey}`:`s:${m.icalUid}`));x.length!==0&&d([...o,...x])},disallow:l=>{d(o.filter(i=>i.scope==="once"?i.dedupKey!==l.dedupKey:i.icalUid!==l.icalUid))}}},[r,a])}const Vc={accepted:"Accepted",declined:"Declined",tentative:"Tentative",none:"No reply"};function Jc({invitees:e}){const[n,s]=g.useState(!1),a=e.filter(r=>r.response==="accepted").length;return t.jsxs("div",{children:[t.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>{s(r=>!r)},className:"inline-flex items-center gap-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:[a," of ",e.length," accepted",t.jsx(F,{className:N("size-3 transition-transform",n&&"rotate-180")})]}),n?t.jsx("ul",{className:"mt-1.5 max-h-40 space-y-1 overflow-y-auto pr-1",children:e.map(r=>t.jsxs("li",{className:"flex items-baseline gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[r.name??r.email,r.role==="organizer"?t.jsx("span",{className:"text-muted-foreground",children:" · organizer"}):null]}),t.jsx("span",{className:"flex-none text-muted-foreground",children:Vc[r.response]})]},r.email))}):null]})}function Xc({text:e}){const n=g.useRef(null),[s,a]=g.useState(!1),[r,o]=g.useState(!1);return g.useLayoutEffect(()=>{const d=n.current;d&&!r&&a(d.scrollHeight>d.clientHeight)},[e,r]),t.jsxs("div",{children:[t.jsx("div",{ref:n,className:N("whitespace-pre-line break-words text-muted-foreground",r?"max-h-72 overflow-y-auto pr-1":"line-clamp-6"),children:e}),s?t.jsxs("button",{type:"button","aria-expanded":r,onClick:()=>o(!r),className:"mt-1 inline-flex items-center gap-1 rounded-sm font-medium text-teal-700 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring dark:text-teal-300",children:[r?"Show less":"Show more",t.jsx(F,{className:N("size-3 transition-transform",r&&"rotate-180")})]}):null]})}function Zc({block:e}){const{source:n,start:s,end:a,stableOccurrenceId:r}=e,o=n.title?.trim()||"(No title)",{label:d}=vn[n.notetaker.state],l=n.description?.trim(),i=Ba(),c=fn(),{applyGrants:u,grantsPending:x}=Y();return t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"px-3 pt-3",children:[t.jsx("div",{className:"font-semibold leading-snug break-words",children:n.isCancelled?t.jsx("s",{children:o}):o}),n.isCancelled?t.jsx("div",{className:"mt-1 text-xs font-medium text-destructive",children:"Cancelled"}):null]}),n.joinUrl||n.providerEventId?t.jsxs("div",{className:"flex flex-wrap gap-2 px-3 pt-2.5",children:[n.joinUrl?t.jsxs("a",{href:n.joinUrl,target:"_blank",rel:"noreferrer noopener",className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium hover:bg-muted",children:[t.jsx(Ps,{className:"size-3.5"})," Join"]}):null,n.providerEventId?t.jsxs(xe,{to:"/meetings/prep/$eventId",params:{eventId:n.providerEventId},className:"inline-flex h-7 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium text-primary hover:bg-muted",children:[t.jsx(Ei,{className:"size-3.5"})," Prep"]}):null]}):null,t.jsx(q,{className:"mt-3"}),t.jsxs(ee,{icon:ht,children:[ft(s)," · ",ye(s,a,n.isAllDay)]}),t.jsx(q,{}),t.jsx(ee,{icon:No,children:n.location??t.jsx("span",{className:"text-muted-foreground",children:"No location added"})}),n.organizer||n.invitees.length>0?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsxs(ee,{icon:dn,children:[n.organizer?t.jsxs("div",{children:["Organized by ",n.organizer]}):null,n.invitees.length>
20?t.jsx(Jc,{invitees:n.invitees}):null]})]}):null,t.jsx(q,{}),t.jsxs("div",{className:"flex gap-2.5 px-3 py-2",children:[t.jsx(Qc,{status:n.notetaker,className:"mt-1"}),t.jsxs("div",{className:"min-w-0 text-xs",children:[t.jsx("div",{children:d}),t.jsx("div",{className:"text-muted-foreground",children:n.notetaker.reason}),t.jsx("div",{className:"mt-1.5",children:t.jsx(Yc,{event:n,allow:i})})]})]}),l?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsx(ee,{icon:Pi,children:t.jsx(Xc,{text:l})})]}):null,c&&r?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsx("div",{className:"px-0.5 py-1",children:t.jsx(Js,{grants:n.grants,restrictToGrants:n.restrictToGrants,risks:[],disabled:x,onSelect:m=>u([{kind:"occurrence",id:r}],m)})})]}):null]})}const ed="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground";function es({action:e}){const n=e.peekLabel??e.label,s=e.peekIcon??e.icon;return t.jsx("button",{type:"button",className:ed,title:n,"aria-label":n,disabled:e.disabled,onClick:e.run,children:t.jsx(s,{className:"size-4"})})}function td({block:e}){const n=Ea([e]),s=n.find(r=>r.key==="mindMap"),a=n.filter(r=>r.key!=="mindMap");return t.jsxs("div",{className:"flex items-center gap-1 border-t px-2 py-1.5",children:[s?t.jsx(es,{action:s}):null,t.jsx(lc,{block:e}),a.map(r=>t.jsx(es,{action:r},r.key))]})}function nd({block:e}){const n=fn(),{applyGrants:s,grantsPending:a}=Y(),{source:r,start:o,end:d,transcriptId:l,record:i}=e,c=r.normalizedParticipants.length-3,u=wo(r.meetingItemStats,i);return t.jsxs("div",{className:"text-sm",children:[t.jsx("div",{className:"px-3 pt-3 pb-2",children:t.jsx("div",{className:"font-semibold leading-snug break-words",children:e.title})}),t.jsx("div",{className:"flex gap-1.5 px-3 pb-2",children:t.jsxs(xe,{to:"/meetings/$meetingId",params:{meetingId:l},className:"inline-flex h-7 items-center gap-1 rounded-md bg-teal px-2.5 text-xs font-medium text-inverse",children:[t.jsx(Ri,{className:"size-3.5"}),"Open meeting"]})}),t.jsx(q,{}),t.jsxs(ee,{icon:ht,children:[ft(o)," · ",ye(o,d,!1),r.duration!=null?` · ${_i(r.duration)}`:null]}),r.normalizedParticipants.length>0?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsxs(ee,{icon:dn,children:[r.normalizedParticipants.slice(0,3).map(x=>x.fullName).join(", "),c>0?t.jsxs("span",{className:"text-muted-foreground",children:[" +",c," more"]}):null]})]}):null,u?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsx(ee,{icon:Is,children:u})]}):null,n?t.jsxs(t.Fragment,{children:[t.jsx(q,{}),t.jsx("div",{className:"px-0.5 py-1",children:t.jsx(Js,{grants:r.grants,restrictToGrants:r.restrictToGrants,markedBy:r.grantsMarkedBy,risks:r.detectedRisks,disabled:a,onSelect:x=>s([{kind:"meeting",id:l}],x)})})]}):null]})}function sd({block:e,now:n,onClose:s}){switch(e.kind){case"recorded":return t.jsx(nd,{block:e});case"live":return t.jsx(qc,{block:e,now:n});case"upcoming":return t.jsx(Zc,{block:e});case"action":return t.jsx(Uc,{block:e,now:n,onClose:s});default:return e}}function ad({block:e,now:n,onClose:s}){return t.jsxs(t.Fragment,{children:[t.jsx(sd,{block:e,now:n,onClose:s}),t.jsx(Wc,{block:e,now:n}),Ze(e)?null:t.jsx(td,{block:e})]})}const V=1440,rd=(e,n)=>{if(e==="day")return[n];const s=Ls(n,{weekStartsOn:1});return Array.from({length:e==="workWeek"?5:7},(r,o)=>nt(s,o))},ts=30,od=e=>{const n=[...e].sort((i,c)=>i.startMinutes-c.startMinutes||c.endMinutes-i.endMinutes||i.key.localeCompare(c.key)),s=new Map,a=[],r=new Map;let o=-1,d=-1/0;for(const i of n){const c=Math.max(i.endMinutes,i.startMinutes+ts);i.startMinutes>=d?(o+=1,d=c,a.length=0):d=Math.max(d,c),r.set(i.key,o);let u=a.findIndex(x=>x<=i.startMinutes);u===-1&&(u=a.length),a[u]=c,s.set(i.key,u)}const l=new Map;for(const i of n){const c=r.get(i.key)??0,u=s.get(i.key)??0;l.set(c,Math.max(l.get(c)??1,u+1))}return n.map(i=>{const c=Math.max(0,Math.min(i.startMinutes,V)),u=Math.max(c+ts,Math.min(i.endMinutes,V)),x=l.get(r.get(i.key)??0)??1,m=s.get(i.key)??0;return{item:i,top:c/V,height:Math.min(u-c,V-c)/V,left:m/x,width:1/x}})},Tn="application/x-luniko-action-item",At=15,Ka="application/x-luniko-planner-grab",Ga=(e,n,s=0)=>{e.dataTransfer.setData(Tn,n.id),e.dataTransfer.setData(Ka,String(s)),e.dataTransfer.effectAllowed="move"},id=e=>{const n=Number(e.dataTransfer.getData(Ka));return Number.isFinite(n)?n:0},Ua=e=>!(e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)),Ha=e=>Array.from(e.dataTransfer.types).includes(Tn),qa=e=>{const n=e.dataTransfer.getData(Tn);return n.length>0?{kind:"action",id:n}:null},ld=(e,n)=>{if(n<=0)return 0;const s=e/n*V,a=Math.round(s/At)*At;return Math.min(Math.max(a,0),V-At)},cd=e=>`${String(Math.floor(e/60)).padStart(2,"0")}
2:${String(e%60).padStart(2,"0")}`,dd=(e,n)=>`${e.title}, ${ft(e.start)} ${ye(e.start,e.end,e.isAllDay)}, ${ko(e)}${n?`, ${n}`:""}`;function Te({block:e,now:n,side:s,selection:a,draggable:r=!1,className:o,children:d}){const[l,i]=g.useState(!1),{setTargets:c,automations:u}=Pe(),x=gs(ps(u,e)),m=a.selectedKeySet.has(e.key),p=r?So(e):null;return t.jsxs(te,{open:l,onOpenChange:f=>{i(f),f&&c([e])},children:[t.jsx(jc,{block:e,selection:a,children:t.jsx(ve,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":dd(e,x),"aria-selected":m,"data-block-key":e.key,draggable:p!==null||void 0,onDragStart:p?f=>{i(!1),Ga(f,p,f.clientY-f.currentTarget.getBoundingClientRect().top)}:void 0,onContextMenu:()=>{i(!1)},onClick:f=>{if(f.metaKey||f.ctrlKey||f.shiftKey){f.preventDefault(),a.toggleKey(e.key);return}a.clearSelection()},className:N("cursor-pointer overflow-hidden text-left hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",m||l&&Ze(e)?"bg-teal/12 shadow-[0_0_0_2px_var(--teal)]":Co(e),e.isCancelled&&"opacity-50 line-through",re(e)&&"opacity-60 line-through",p&&"cursor-grab active:cursor-grabbing",o),children:d})})}),t.jsx(ne,{align:"start",side:s,className:"w-80 p-0",onOpenAutoFocus:Ze(e)?f=>f.preventDefault():void 0,children:t.jsx(ad,{block:e,now:n,onClose:()=>i(!1)})})]})}function Dn(e,n,s){const a=g.useMemo(()=>new Set(n),[n]),r=g.useMemo(()=>e.filter(i=>a.has(i.key)),[e,a]),o=g.useCallback(i=>{s(a.has(i)?n.filter(c=>c!==i):[...n,i])},[n,a,s]),d=g.useCallback(()=>{s([])},[s]),l=g.useCallback(i=>{s([i])},[s]);return{selectedKeySet:a,selectedBlocks:r,toggleKey:o,clearSelection:d,selectOnly:l}}const Qt=64,Ot=(e,n)=>(e.getTime()-U(n).getTime())/6e4,ud=e=>{if(e===0||e===24)return"";const n=e<12?"AM":"PM",s=e%12===0?12:e%12;return`${String(s)} ${n}`};function Wa({block:e,now:n,side:s,width:a,compact:r,selection:o}){return t.jsx(Te,{block:e,now:n,side:s,selection:o,draggable:!0,className:N("w-full rounded-md border px-1.5 py-1 text-[11px] leading-tight",!r&&"h-full"),children:t.jsx(oa,{block:e,variant:r?"compact":"full",width:a})})}const md=[{top:540/V,height:60/V},{top:780/V,height:30/V}];function xd({day:e,dayIndex:n,daysCount:s,blocks:a,now:r,isToday:o,showPlaceholders:d,selection:l,onDropItem:i}){const[c,u]=g.useState(!1),x=g.useMemo(()=>od(a.map(p=>({key:p.key,startMinutes:Ot(p.start,e),endMinutes:Ot(p.end,e),block:p}))),[a,e]),m=n>=s-2?"left":"right";return t.jsxs("div",{className:N("relative min-w-0 flex-1 border-l",o&&"bg-primary/[0.05]",c&&"bg-violet-500/10"),onDragOver:p=>{!i||!Ha(p)||(p.preventDefault(),p.dataTransfer.dropEffect="move",u(!0))},onDragLeave:p=>{Ua(p)&&u(!1)},onDrop:p=>{u(!1);const f=i?qa(p):null;if(!f||!i)return;p.preventDefault();const h=p.currentTarget.getBoundingClientRect(),b=p.clientY-id(p)-h.top;i(f,e,ld(b,h.height))},children:[Array.from({length:24},(p,f)=>t.jsx("div",{className:"border-b border-border/60",style:{height:Qt}},f)),t.jsx("div",{className:"absolute inset-x-0 top-1.5 bottom-1.5",children:d?md.map((p,f)=>t.jsx("div",{className:"absolute inset-x-0 animate-pulse rounded-md bg-muted/70",style:{to
2p:`${String(p.top*100)}%`,height:`${String(p.height*100)}%`}},f)):x.map(p=>t.jsx("div",{className:"absolute px-px",style:{top:`${String(p.top*100)}%`,height:`${String(p.height*100)}%`,left:`${String(p.left*100)}%`,width:`${String(p.width*100)}%`},children:t.jsx(Wa,{block:p.item.block,now:r,side:m,width:p.width,selection:l})},p.item.key))}),o?t.jsx("div",{className:"pointer-events-none absolute inset-x-0 z-[12] border-t-2 border-destructive",style:{top:`${String(Ot(r,e)/V*100)}%`},children:t.jsx("span",{className:"absolute -left-1 -top-1 size-2 rounded-full bg-destructive"})}):null]})}function pd({days:e,blocks:n,now:s,loading:a,mode:r,allDay:o,onAllDayChange:d,selectedKeys:l,onSelectionChange:i,onDropItem:c}){const u=g.useRef(null);g.useEffect(()=>{u.current&&(u.current.scrollTop=8*Qt)},[]);const x=g.useMemo(()=>e.some(w=>Qe(n,w).some(S=>S.isAllDay)),[e,n]),m=Dn(n,l,i),p=a&&n.length===0,f=!a&&n.length===0,h=r==="day"?"No meetings on this day.":"No meetings this week.",b=U(s);return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border bg-card",children:[t.jsxs("div",{className:"flex flex-none border-b",children:[t.jsx("div",{className:"w-14"}),e.map(w=>{const S=ge(w,s),j=w.getTime()<b.getTime();return t.jsxs("div",{className:N("flex-1 border-l py-2 text-center",S&&"bg-primary/10"),children:[t.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:w.toLocaleDateString(void 0,{weekday:"short"})}),t.jsx("div",{className:"mt-0.5 inline-flex items-center gap-1.5",children:t.jsx("span",{className:N("text-sm font-semibold",S&&"inline-flex h-6 min-w-6 items-center justify-center rounded-full bg-primary px-1.5 font-bold text-primary-foreground",!S&&j&&"text-muted-foreground",!S&&!j&&"text-foreground"),children:w.getDate()})})]},w.toISOString())})]}),x?t.jsxs("div",{className:N("flex flex-none border-b bg-muted/30",o==="full"&&"max-h-48 overflow-y-auto"),children:[t.jsx("div",{className:"flex w-14 flex-none items-start justify-end py-1 pr-1",children:t.jsxs(Ae,{children:[t.jsxs(Oe,{"aria-label":"All-day items",className:"flex items-center gap-0.5 rounded px-0.5 text-[10px] text-muted-foreground hover:text-foreground",children:["All day",t.jsx(F,{className:"size-3","aria-hidden":"true"})]}),t.jsx(Ee,{align:"start",children:t.jsxs(js,{value:o,onValueChange:w=>{d(w)},children:[t.jsx(We,{value:"count",children:"Count only"}),t.jsx(We,{value:"condensed",children:"Condensed"}),t.jsx(We,{value:"full",children:"Full"})]})})]})}),e.map((w,S)=>{const{shown:j,hidden:v}=Mo(Qe(n,w).filter(y=>y.isAllDay),o);return t.jsxs("div",{className:N("min-h-7 min-w-0 flex-1 space-y-1 border-l p-1 first:border-l-0",ge(w,s)&&"bg-primary/[0.05]"),children:[j.map(y=>t.jsx(Wa,{block:y,now:s,side:S>=e.length-2?"left":"right",width:1,compact:!0,selection:m},y.key)),v>0?t.jsx("button",{type:"button",className:"w-full px-1.5 text-left text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{d("full")},children:j.length===0?`${String(v)} all day`:`+${String(v)} more`}):null]},w.toISOString())})]}):null,t.jsxs("div",{className:"relative min-h-0 flex-1",children:[t.jsx("div",{ref:u,className:"h-full overflow-y-auto",children:t.jsxs("div",{className:"flex",children:[t.jsx("div",{className:"w-14 pt-1.5",children:Array.from({length:24},(w,S)=>t.jsx("div",{className:"relative",style:{height:Qt},children:t.jsx("span",{className:"absolute -top-1.5 right-2 text-[10px] text-muted-foreground",children:ud(S)})},S))}),e.map((w,S)=>t.jsx(xd,{day:w,dayIndex:S,daysCount:e.length,blocks:Qe(n,w).filter(j=>!j.isAllDay),now:s,isToday:ge(w,s),showPlaceholders:p,selection:m,onDropItem:c},w.toISOString()))]})}),f?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"text-sm text-muted-foreground",children:h})}):null]})]})}const ns=[{value:"minutes",label:"minutes",minutes:1},{value:"hours",label:"hours",minutes:60},{value:"days",label:"days",minutes:1440}];function gd({request:e,onClose:n,onPick:s}){const[a,r]=g.useState("2"),[o,d]=g.useState("hours"),l=e?it[e.action]:null,i=l?.customMax??0,c=ns.find(p=>p.value===o)?.minutes??1,u=Number(a),x=Number.isInteger(u)?u*c:NaN,m=x>=1&&x<=i;return t.jsx(ct,{open:e!==null,onOpenChange:p=>!p&&n(),children:t.jsxs(dt,{className:"sm:max-w-sm",children:[t.jsxs(ut,{children:[t.jsx(mt,{children:l?.label??""}),t.jsx(xt,{children:m&&l?Io(x,l.triggerKind):"Up to 7 days after it ends."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(pt,{"aria-label":"Amount",type:"number",min:1,step:1,value:a,onChange:p=>r(p.target.value),className:"h-9 w-24 text-sm"}),t.jsxs(zs,{value:o,onValueChange:p=>d(p),children:[t.jsx(Fs,{"aria-label":"Unit",className:"h-9 w-32 text-sm",children:t.jsx($s,{})}),t.jsx(Bs,{children:ns.map(p=>t.jsx(Ks,{value:p.value,children:p.label},p.value))})]}),t.jsx("span",{className:"text-sm text-muted-foreground",children:"after it ends"})]}),t.jsxs(un,{children:[t.jsx(R,{type:"button",variant:"ghost",onClick:n,children:"Cancel"}),t.jsx(R,{type:"button",className:"bg-teal text-inverse hover:bg-teal-hover",disabled:!m,onClick:()=>{!e||!m||(s(e,x),n())},children:"Set"})]})]})})}const Ya="luniko.calendar.seriesScope",fd=()=>{try{return window.localStorage.getItem(Ya)==="meeting"?"meeting":"series"}catch{return"series"}},hd=()=>{const[e,n]=g.useState(fd),s=g.useCallback(a=>{n(a);try{window.localStorage.setItem(Ya,a)}catch{return}},[]);return[e,s]},jd={recorded:"meeting",live:"liveMeeting",upcoming:"future_meeting"};function bd({block:e}){const n=Be(),s=To(),a=Do(),r=Ao(),o=e.kind==="upcoming"?e.stableOccurrenceId??"":e.kind==="live"?e.meetingId:e.transcriptId,d=e.kind==="upcoming"?void 0:e.kind==="live"?a.data?.sharedWithPersonIds:s.data?.transcript.sharedWithPersonIds,l=(i,c,u)=>{if(e.kind==="upcoming"){if(!e.stableOccurrenceId)return;r.mutate({stableOccurrenceId:e.stableOccurrenceId,input:{personIds:i,shared:c,message:u}});return}if(e.kind==="live"){a.mutate({meetingId:e.meetingId,input:{personIds:i,shared:c,message:u}});return}s.mutate({meetingId:e.transcriptId,input:{personIds:i,shared:c,message:u}},{onSettled:()=>{n.invalidateQueries({queryKey:Z.recordedRange})}})};return t.jsx(Fi,{entityType:jd[e.kind],entityId:o,sharedWithPersonIds:d??e.source.sharedWithPersonIds??[],alreadyHasAccessPersonIds:e.kind==="upcoming"?[]:e.source.participantPersonIds??[],alreadyHasAccessLabel:e.kind==="live"?"in the room":"in the meeting",pending:s.isPending||a.isPending||r.isPending,onShare:(i,c)=>{l(i,!0,c)},onUnshare:i=>{l([i],!1)}})}function vd({block:e,open:n,onOpenChange:s}){return t.jsx(ct,{open:n&&e!==null,onOpenChange:s,children:t.jsxs(dt,{className:"p-0 sm:max-w-sm",children:[t.jsxs(ut,{className:"min-w-0 gap-1 px-4 pt-4",children:[t.jsx(mt,{children:e?.kind==="live"?"Share live room":"Share meeting"}),t.jsx(xt,{className:"truncate",children:e?.title}),e?.kind==="upcoming"?t.jsx("p",{className:"text-xs text-muted-foreground",children:"They get it once the meeting is recorded."}):null]}),e?t.jsx(bd,{block:e}):null]})})}function yd({children:e}){const[n,s]=g.useState([]),[a,r]=g.useState(!1),[o,d]=g.useState(null),l=g.useMemo(()=>sa(n),[n]),i=zi(l.recordedIds,l.bookmarkRefs),c=Ba(),u=n.length===1?n[0]:null,x=Be(),{mutateAsync:m,isPending:p}=Oo(),{mutateAsync:f,isPending:h}=Eo(),b=gi(),w=le("tags.use"),S=gn(w).data?.items??bn,j=xi(),v=g.useMemo(()=>{const z=new Map(S.map(K=>[K.id,K])),L=new Map;for(const[K,ue]of j){const Se=ue.flatMap(yt=>z.get(yt)??[]);Se.length>0&&L.set(K,Se)}return L},[S,j]),{mutateAsync:y}=fi(),k=Li(),[T,A]=g.useState(null),H=Po(),{mutateAsync:C}=_o(),{mutate:E}=_s(),[Q,M]=hd(),B=g.useCallback(z=>{C(z).then(()=>G.success(Ro(z))).catch(()=>{})},[C]),J=g.useCallback(z=>{const L=document.querySelector(`[data-block-key="${CSS.escape(z)}"]`);if(!L)return;const K=L.getBoundingClientRect();A(z),L.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:K.left+12,clientY:K.top+12}))},[]),Ne=g.useCallback((z,L)=>{const K=xs(L.grants,L.restrictToGrants)?.label??"a custom audience";Promise.allSettled(z.map(ue=>
2ue.kind==="meeting"?m({meetingId:ue.id,input:L}):f({stableOccurrenceId:ue.id,input:L}))).then(ue=>{x.invalidateQueries({queryKey:Z.recordedRange}),x.invalidateQueries({queryKey:Z.upcoming});const Se=ue.filter(yt=>yt.status==="fulfilled").length;Se===1?G.success(`Marked ${K}`):Se>1&&G.success(`Marked ${Se} meetings ${K}`)})},[x,m,f]),ce=g.useCallback((z,L,K)=>y({refs:z,change:K?{add:[L]}:{remove:[L]}}),[y]),de=g.useCallback(z=>{for(const L of z)E(L)},[E]),I=H.data?.items??hl,D=g.useCallback(()=>A(null),[]),O=p||h,_=g.useMemo(()=>({flaggedKeys:b,tags:S,tagsByKey:v,automations:I,setTargets:s,clearTagsOpen:D}),[b,S,v,I,D]),we=g.useMemo(()=>({setTargets:s,state:l,actions:i,openShare:()=>r(!0),applyGrants:Ne,grantsPending:O,allow:c,flaggedKeys:b,tags:S,tagsByKey:v,setMark:ce,unbookmark:k,openTags:J,tagsOpenFor:T,clearTagsOpen:D,automations:I,automate:B,pickTiming:d,removeAutomations:de,seriesScope:Q,setSeriesScope:M}),[l,i,Ne,O,c,b,S,v,ce,k,J,T,D,I,B,de,Q,M]);return t.jsx(ra.Provider,{value:_,children:t.jsxs(aa.Provider,{value:we,children:[e,t.jsx(gd,{request:o,onClose:()=>d(null),onPick:(z,L)=>{const K=Lo(z.block,z.scope,z.action,L);K&&B(K)}}),t.jsx(vd,{block:na(u),open:a,onOpenChange:r})]})})}function An({icon:e,name:n,switchLabel:s,shown:a=!0,onShownChange:r,activeCount:o=0,children:d}){return t.jsxs("section",{"aria-label":n,className:"border-b px-3 py-2.5",children:[t.jsxs("div",{className:"flex min-h-7 items-center gap-2",children:[t.jsx(e,{"aria-hidden":!0,className:"size-4 flex-none text-muted-foreground"}),t.jsx("span",{className:"flex-1 text-sm font-semibold",children:n}),a&&o>0?t.jsx("span",{className:"text-xs text-teal",children:o===1?"1 filter":`${String(o)} filters`}):null,r?t.jsx(zo,{"aria-label":s,checked:a,onCheckedChange:r,className:"data-[state=checked]:bg-teal"}):null]}),d?t.jsx("div",{className:N("mt-2 flex flex-col gap-1.5 pl-6",!a&&"opacity-50"),children:d}):null]})}const Nd=xn.map(e=>({value:e,label:Bt[e],group:e==="attended"||e==="missed"?"Past":"Upcoming"}));function wd({shown:e,onShownChange:n,value:s,onChange:a}){const r=Ke().data,o=r?.personId??null,d=r?.email??null,l=r?.orgId??null,{contactsMap:i,isLoading:c}=mn(),u=Gs().data,x=g.useMemo(()=>{const f=new Map(i);for(const[h,b]of i)(h===o||d!==null&&b.email===d)&&f.delete(h);return f},[i,o,d]),m=g.useMemo(()=>(u??[]).filter(f=>f.orgId!==l),[u,l]),p=[s.personIds,s.me,s.customers].filter(f=>f.length>0).length;return t.jsxs(An,{icon:Us,name:"Meetings",switchLabel:"Show meetings",shown:e,onShownChange:n,activeCount:p,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-[84px] flex-none text-[11px] text-muted-foreground",children:"With"}),t.jsx($i,{contacts:x,value:s.personIds,onCommit:f=>a({personIds:f}),isLoading:c,disabled:!e,className:"flex min-w-0 flex-1",renderDisplay:f=>t.jsxs("span",{"aria-label":"With",title:f.length>1?f.map(h=>h.name).join(", "):void 0,className:N(Sn,"cursor-pointer"),children:[t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:t.jsx(Ie,{empty:"Anyone",chips:f.map(h=>({key:h.id,label:h.name,className:"border bg-muted text-foreground"}))})}),t.jsx(F,{className:"size-3.5 flex-none text-muted-foreground"})]})})]}),t.jsx(Ce,{label:"My attendance",options:Nd,value:s.me,empty:"Any",placeholder:"Search",disabled:!e,onChange:f=>a({me:xn.filter(h=>f.includes(h))})}),t.jsx(Ce,{label:"Customer",options:m.map(f=>({value:f.orgId,label:f.name})),value:s.customers,empty:"Any customer",placeholder:"Search customers",disabled:!e,onChange:f=>a({customers:f})})]})}function Sd({count:e,onClearAll:n,onSaveAsProfile:s,children:a}){return t.jsxs(te,{children:[t.jsx(ve,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":e>0?`Filters: ${String(e)} on`:"Filters",className:N(Re,"inline-flex items-center gap-1.5",e>0&&"border-teal"),children:[t.jsx(Di,{className:"size-3.5 flex-none text-muted-foreground"}),"Filters",e>0?t.jsx("span",{className:"inline-flex size-4 items-center justify-center rounded-full bg-teal text-[10px] font-semibold text-inverse",children:e}):null,t.jsx(F,{className:"size-3 flex-none text-muted-foreground"})]})}),t.jsxs(ne,{align:"start",className:"w-[480px] p-0",children:[t.jsx("div",{className:"max-h-[70vh] overflow-y-auto",children:a}),t.jsxs("div",{className:"flex items-center justify-between px-1.5 py-1.5",children:[t.jsx(R,{variant:"ghost",className:"h-8 px-2 text-xs",disabled:e===0,onClick:n,children:"Clear all"}),s?t.jsx(R,{variant:"ghost",className:"h-8 px-2 text-xs text-teal hover:text-teal",onClick:s,children:"Save as profileâ¦"}):null]})]})]})}const ss="flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12.5px] hover:bg-accent";function Cd({value:e,tags:n,onChange:s}){const[a,r]=g.useState(""),[o,d]=g.useState(!1),l=e.length>0,i=a.trim().toLowerCase(),c=n.filter(m=>m.name.toLowerCase().includes(i)).sort((m,p)=>m.name.localeCompare(p.name)),u=m=>{s(e.includes(m)?e.filter(p=>p!==m):[...e,m])},x=e.map(m=>({key:m,label:m===X?"Bookmarked":n.find(p=>p.id===m)?.name??"Tag",className:"border bg-muted text-foreground"}));return t.jsx(An,{icon:je,name:"Saved",activeCount:l?1:0,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"w-[84px] flex-none text-[11px] text-muted-foreground",children:"Marked"}),t.jsxs(te,{open:o,onOpenChange:m=>{d(m),r("")},children:[t.jsx(ve,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":"Filter by bookmark or tag",className:N(Sn,o&&"border-ring ring-[3px] ring-ring/25"),children:[t.jsx("span",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:t.jsx(Ie,{empty:"Any",chips:x})}),t.jsx(F,{className:"size-3.5 flex-none text-muted-foreground"})]})}),t.jsxs(ne,{align:"start",className:"w-72 p-0 text-sm",children:[n.length>0?t.jsx("div",{className:"border-b p-2",children:t.jsx(pt,{value:a,onChange:m=>r(m.target.value),placeholder:"Find a tag","aria-label":"Find a tag",maxLength:40,className:"h-8 text-xs"})}):null,t.jsxs("ul",{className:"max-h-72 overflow-y-auto p-1",children:[i===""?t.jsx("li",{children:t.jsxs("button",{type:"button","aria-pressed":e.includes(X),onClick:()=>u(X),className:N(ss,e.includes(X)&&"font-medium"),children:[t.jsx(je,{className:"size-3.5 flex-none text-teal"}),t.jsx("span",{className:"flex-1",children:"Bookmarked"}),e.includes(X)?t.jsx(W,{className:"size-3.5"}):null]})}):null,i===""&&c.length>0?t.jsx("li",{className:"px-2 pt-2 pb-1 text-[10.5px] font-semibold tracking-wide text-muted-foreground uppercase",children:"Tags"}):null,c.map(m=>t.jsx("li",{children:t.jsxs("button",{type:"button","aria-pressed":e.includes(m.id),onClick:()=>u(m.id),className:N(ss,e.includes(m.id)&&"font-medium"),children:[t.jsx("span",{"aria-hidden":"true",className:N("size-2.5 shrink-0 rounded-full",Ge[m.color])}),t.jsx("span",{className:"flex-1 truncate",children:m.name}),e.includes(m.id)?t.jsx(W,{className:"size-3.5"}):null]})},m.id)),i!==""&&c.length===0?t.jsx("li",{className:"px-2 py-4 text-center text-xs text-muted-foreground",children:"No tag by that name."}):null]}),t.jsx("div",{className:"border-t",children:t.jsx(R,{variant:"ghost",className:"h-8 w-full rounded-none text-xs",disabled:!l,onClick:()=>s([]),children:"Clear filters"})})]})]})]})})}const kd=Object.values(pn).map(e=>({value:e,label:Ws(e)})),Md=e=>[e.destination,e.status,e.tags,e.pbiTags].filter(n=>n.length>0).length;
2function Id({value:e,onChange:n}){const s=Hs(),{filters:a,shown:r}=e,o=d=>n({shown:r,filters:{...a,...d}});return t.jsxs(An,{icon:qs,name:"Action items",switchLabel:"Show my action items",shown:r,onShownChange:d=>n({shown:d,filters:a}),activeCount:Md(a),children:[t.jsx(Ce,{label:"Destination",options:s,value:a.destination,empty:"Any log",placeholder:"Search logs",disabled:!r,onChange:d=>o({destination:d})}),t.jsx(Ce,{label:"Status",options:kd,value:a.status,empty:"Any status",placeholder:"Search statuses",disabled:!r,onChange:d=>o({status:d})}),t.jsx(Ce,{label:"Tags",options:ln,value:a.tags,empty:"Any tag",placeholder:"Search tags",disabled:!r,onChange:d=>o({tags:d})}),t.jsx(Ce,{label:"PBI tags",options:cn,value:a.pbiTags,empty:"Any PBI tag",placeholder:"Search PBI tags",disabled:!r,onChange:d=>o({pbiTags:d})})]})}const Qa={day:"Day",workWeek:"Work week",week:"Week",month:"Month"},Et=(e,n)=>{if(e!=="month")return rd(e,n);const s=Ls(yi(n),{weekStartsOn:1}),a=Si(Bi(n),{weekStartsOn:1}),r=[];for(let o=s;o<=a;o=nt(o,1))r.push(o);return r},rt=(e,n,s)=>e==="day"?nt(n,s):e==="month"?Ni(n,s):nt(n,s*7),Td=(e,n,s)=>{if(e==="day")return n.toLocaleDateString(void 0,{weekday:"long",day:"numeric",month:"long"});if(e==="month")return n.toLocaleDateString(void 0,{month:"long",year:"numeric"});const a=s[0],r=s[s.length-1],o=`${a.toLocaleDateString(void 0,{month:"short",day:"numeric"})} â ${r.toLocaleDateString(void 0,{month:"short",day:"numeric"})}`,d=new Date().getFullYear();return a.getFullYear()===d&&r.getFullYear()===d?o:`${o}, ${String(r.getFullYear())}`},Je="none",Vt={mode:"week",allDay:"condensed",view:"grid",agendaGroup:"day",agendaLayout:"board",saved:[],meetings:{shown:!0,personIds:[],me:[],customers:[]},actions:{shown:!0,destination:[],status:[],tags:[],pbiTags:[]}},Dd={profiles:[],startupId:null},On=["mode","allDay","view","group","layout"],Va=["saved","person","me","customer","meetings","actions","actionDestination","actionTag","actionPbiTag","actionStatus"],Ad=Object.values(Fo),Od=Object.values(pn),Ed=Object.values($o),Pd=Object.values(Bo),se=(e,n)=>(n?e.filter(a=>n.includes(a)):[...e]).sort(),Jt=e=>({mode:e.mode,allDay:e.allDay,view:e.view,agendaGroup:e.view==="agenda"?e.agendaGroup:"day",agendaLayout:e.view==="agenda"?e.agendaLayout:"board",saved:se(e.saved),meetings:{shown:e.meetings.shown,personIds:se(e.meetings.personIds),me:se(e.meetings.me,xn),customers:se(e.meetings.customers)},actions:{shown:e.actions.shown,destination:se(e.actions.destination,Ad),status:se(e.actions.status,Od),tags:se(e.actions.tags,Ed),pbiTags:se(e.actions.pbiTags,Pd)}}),Le=e=>({mode:e.mode??"week",allDay:e.allDay??"condensed",view:e.view??"grid",agendaGroup:e.group??"day",agendaLayout:e.layout??"board",saved:e.saved??[],meetings:{shown:e.meetings!=="hide",personIds:e.person??[],me:e.me??[],customers:e.customer??[]},actions:{shown:e.actions!=="hide",destination:e.actionDestination??[],status:e.actionStatus??[],tags:e.actionTag??[],pbiTags:e.actionPbiTag??[]}}),ae=e=>e.length>0?e:void 0,Ja=e=>({mode:e.mode==="week"?void 0:e.mode,allDay:e.allDay==="condensed"?void 0:e.allDay,view:e.view==="grid"?void 0:e.view,group:e.agendaGroup==="day"?void 0:e.agendaGroup,layout:e.agendaLayout==="board"?void 0:e.agendaLayout,saved:ae(e.saved),person:ae(e.meetings.personIds),me:ae(e.meetings.me),customer:ae(e.meetings.customers),meetings:e.meetings.shown?void 0:"hide",actions:e.actions.shown?void 0:"hide",actionDestination:ae(e.actions.destination),actionTag:ae(e.actions.tags),actionPbiTag:ae(e.actions.pbiTags),actionStatus:ae(e.actions.status)}),Pt=(e,n)=>n?e.filter(s=>s===X||n.has(s)):e,ze=(e,n)=>{const s=Jt(e);return{...s,saved:Pt(s.saved,n.tags),meetings:{...s.meetings,personIds:Pt(s.meetings.personIds,n.people),customers:Pt(s.meetings.customers,n.customers)}}},En=(e,n)=>JSON.stringify(Jt(e))===JSON.stringify(Jt(n)),Xt=(e,n)=>e.profiles.find(s=>s.id===n),Xa=(e,n,s)=>!En(ze(Le(n),s),ze(e.snapshot,s)),_d=(e,n,s)=>{if(n.profile===Je)return null;const a=[...On,...Va].some(d=>n[d]!==void 0);if(n.profile===void 0&&!a)return{profile:Xt(e,e.startupId??void 0)??null,keepFilters:!1};const r=Xt(e,n.profile);return r?!Xa(r,n,s)&&!En(Le(n),ze(r.snapshot,s))?{profile:r,keepFilters:!1}:null:{profile:null,keepFilters:!0}},Rd={count:"All day: count only",full:"All day: full"}
2,qe=(e,n)=>{const s=[];for(const a of e){const r=n(a);r&&s.push(r)}return s},_t=e=>e.length<=2?e.join(", "):`${e.slice(0,2).join(", ")} +${String(e.length-2)}`,Za=(e,n)=>{const{meetings:s,actions:a}=e;let r=null;if(!s.shown)r="Meetings hidden";else{const i=[],c=qe(s.personIds,n.personName).map(m=>m.split(" ")[0]);c.length>0&&i.push(`With ${_t(c)}`);const u=s.me.filter(m=>m in Bt);u.length>0&&i.push(_t(u.map(m=>Bt[m])));const x=qe(s.customers,n.customerName);x.length>0&&i.push(_t(x)),i.length>0&&(r=i.join(" · "))}const o=qe(e.saved,i=>i===X?"Bookmarked":n.tagName(i));let d=null;if(n.showActions)if(!a.shown)d="No action items";else{const i=[],c=qe(a.destination,n.destinationLabel);if(c.length===1&&i.push(c[0]),c.length>1&&i.push(`${String(c.length)} logs`),a.status.length>0){const x=a.status.map(m=>Ws(m));i.push(`${x.join(", ")} actions`)}const u=a.tags.length+a.pbiTags.length;u>0&&i.push(u===1?"1 tag":`${String(u)} tags`),i.length>0&&(d=i.join(" · "))}const l=[Qa[e.mode]];if(e.allDay!=="condensed"&&l.push(Rd[e.allDay]),e.view==="agenda"){const i=e.agendaGroup==="type"?"By type":"By day",c=e.agendaLayout==="list"?"List":"Board";l.push(`Agenda · ${i} · ${c}`)}return{view:l.join(" · "),meetings:r,saved:o.length>0?o.join(" or "):null,actions:d}},Ld=(e,n)=>{const s=Za(e,n),a=[s.meetings,s.saved,s.actions].filter(r=>r!==null);return a.length===0?`${s.view} · Everything shown`:[s.view,...a].join(" · ")},Zt=(e,n)=>{const s=Za(e,n),a=[{label:"View",value:s.view},{label:"Meetings",value:s.meetings??"All"},{label:"Saved",value:s.saved??"Any"}];return n.showActions&&a.push({label:"Action items",value:s.actions??"All"}),a},zd=(e,n,s)=>{const a=Zt(e,s),r=Zt(n,s),o=[];for(let d=0;d<a.length;d+=1)a[d].value!==r[d].value&&o.push({label:a[d].label,before:a[d].value,after:r[d].value});return o},er=(e,n,s)=>{const a=e.trim();if(a.length===0)return"Give it a name.";if(a.length>Kn)return`Keep it to ${String(Kn)} characters.`;const r=a.toLowerCase();return n.some(d=>d.id!==s&&d.name.toLowerCase()===r)?"You already have a profile with that name.":null};function tr({rows:e}){return t.jsx("div",{className:"rounded-md border",children:e.map((n,s)=>t.jsxs("div",{className:s===0?"flex px-3 py-[7px] text-xs":"flex border-t px-3 py-[7px] text-xs",children:[t.jsx("span",{className:"w-24 flex-none text-muted-foreground",children:n.label}),t.jsx("span",{className:"min-w-0 flex-1",children:n.value})]},n.label))})}function Fd({rows:e,profiles:n,onSave:s,onClose:a}){const[r,o]=g.useState(""),[d,l]=g.useState(!1),[i,c]=g.useState(!1),u=er(r,n),x=()=>{if(u){c(!0);return}s(r,d)};return t.jsx(ct,{open:!0,onOpenChange:m=>{m||a()},children:t.jsxs(dt,{className:"gap-4 p-5 sm:max-w-[440px]",children:[t.jsxs(ut,{children:[t.jsx(mt,{className:"text-base tracking-[-0.01em]",children:"Save as profile"}),t.jsx(xt,{className:"text-[12.5px]",children:"Saves the view you have now. The date isnât saved."})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:m=>{m.preventDefault(),x()},children:[t.jsxs("label",{className:"flex flex-col gap-1.5 text-xs font-medium",children:["Name",t.jsx(pt,{autoFocus:!0,value:r,placeholder:"e.g. Delivery lead","aria-invalid":i&&u!==null,className:"h-8 text-sm",onChange:m=>{o(m.target.value)}}),i&&u?t.jsx("span",{className:"font-normal text-destructive",children:u}):null]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("span",{className:"text-xs font-medium",children:"What it keeps"}),t.jsx(tr,{rows:e})]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx(jn,{checked:d,className:"data-[state=checked]:border-teal data-[state=checked]:bg-teal",onCheckedChange:m=>{l(m===!0)}}),"Open Calendar on this profile"]}),t.jsxs(un,{children:[t.jsx(R,{type:"button",variant:"outline",onClick:a,children:"Cancel"}),t.jsx(R,{type:"submit",className:"bg-teal font-semibold text-inverse hover:bg-teal-hover",children:"Save profile"})]})]})]})})}function $d({activeName:e,targetName:n,changes:s,onDiscard:a,onSaveAsNew:r,onUpdate:o,onCancel:d}){return t.jsx(ct,{open:!0,onOpenChange:l=>{l||d()},children:t.jsxs(dt,{className:"gap-4 p-5 sm:max-w-[440px]",children:[t.jsxs(ut,{children:[t.jsxs(mt,{className:"text-base tracking-[-0.01em]",children:["Keep your changes to ",e,"?"]}),t.jsxs(xt,{className:"text-[12.5px]",children:["Youâre switching to ",t.jsx("strong",{className:"font-semibold text-foreground",children:n}),". You changed these:"]})]}),t.jsx(tr,{rows:s.map(l=>({label:l.label,value:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground line-through",children:l.before})," â ",t.jsx("span",{className:"font-semibold",children:l.after})]})}))}),t.jsxs(un,{className:"sm:justify-between",children:[t.jsx(R,{type:"button",variant:"ghost",className:"text-muted-foreground",onClick:a,children:"Discard"}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[t.jsx(R,{type:"button",variant:"outline",onClick:r,children:"Save as newâ¦"}),t.jsx(R,{type:"button",autoFocus:!0,className:"bg-teal font-semibold text-inverse hover:bg-teal-hover",onClick:o,children:"Update profile"})]})]})]})})}const as="text-[10.5px] font-semibold uppercase tracking-wide text-muted-foreground",Rt="flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12.5px] hover:bg-accent disabled:pointer-events-none disabled:opacity-50",Lt="h-[30px] text-[12.5px]";function Bd({profile:e,profiles:n,onSave:s}){const[a,r]=g.useState(e.name),[o,d]=g.useState(!1),l=er(a,n,e.id);return t.jsxs("div",{className:"flex flex-col gap-1 rounded-md bg-accent px-2 py-2",children:[t.jsx(pt,{autoFocus:!0,value:a,"aria-label":"Profile name","aria-invalid":o&&l!==null,className:"h-7 text-[12.5px] font-medium",onFocus:i=>{i.target.select()},onChange:i=>{r(i.target.value)},onKeyDown:i=>{if(i.key==="Enter"){if(i.preventDefault(),l){d(!0);return}s(a)}}}),t.jsx("span",{className:N("text-[10.5px]",o&&l?"text-destructive":"text-muted-foreground"),children:o&&l?l:"Enter to save · Esc to cancel"})]})}function Kd({name:e,onCancel:n,onDelete:s}){return t.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-danger-subtle p-2",children:[t.jsxs("p",{className:"min-w-0 flex-1 text-xs text-danger-foreground",children:["Delete ",t.jsx("strong",{className:"font-semibold",children:e}),"? This canât be undone."]}),t.jsx(R,{type:"button",size:"sm",variant:"outline",className:"h-[26px] px-2 text-xs",onClick:n,children:"Cancel"}),t.jsx(R,{type:"button",size:"sm",autoFocus:!0,className:"h-[26px] bg-destructive px-2 text-xs text-destructive-foreground hover:bg-destructive/90",onClick:s,children:"Delete"})]})}function rs({name:e,summary:n,icon:s,active:a,startup:r,onSelect:o,onSetStartup:d,onRename:l,onDelete:i}){return t.jsxs("div",{role:"button",tabIndex:0,"aria-current":a?"true":void 0,className:N("group flex cursor-pointer items-start gap-2 rounded-md py-2 pr-2 pl-2 text-left outline-hidden hover:bg-accent focus-visible:bg-accent",a&&"bg-accent"),onClick:o,onKeyDown:c=>{c.target===c.currentTarget&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},children:[s,t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:N("flex items-center gap-1 text-[12.5px]",a?"font-semibold":"font-medium"),children:[t.jsx("span",{className:"truncate",children:e}),r?t.jsx(Hn,{"aria-label":"Calendar opens on this",className:"size-3 flex-none text-teal"}):null]}),t.jsx("p",{className:"text-[11px] leading-[1.35] text-pretty text-muted-foreground",children:n})]}),t.jsxs("div",{className:"flex items-center gap-1.5",children:[a?t.jsx(W,{"aria-hidden":!0,
2className:"size-3.5"}):null,t.jsxs(Ae,{children:[t.jsx(Oe,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":`More for ${e}`,className:"inline-flex h-5 w-[22px] items-center justify-center rounded-sm text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-border focus-visible:opacity-100 data-[state=open]:bg-border data-[state=open]:opacity-100",onClick:c=>{c.stopPropagation()},children:t.jsx(Ui,{className:"size-3.5"})})}),t.jsxs(Ee,{side:"right",align:"start",sideOffset:8,className:"w-[190px] p-1",onClick:c=>{c.stopPropagation()},onCloseAutoFocus:c=>{c.preventDefault()},children:[l?t.jsxs(pe,{className:Lt,onSelect:l,children:[t.jsx(Go,{}),"Rename"]}):null,t.jsxs(pe,{className:Lt,disabled:r,onSelect:d,children:[t.jsx(Hn,{}),r?"Calendar opens on this":"Open Calendar on this"]}),i?t.jsxs(t.Fragment,{children:[t.jsx(hs,{}),t.jsxs(pe,{className:Lt,variant:"destructive",onSelect:i,children:[t.jsx(Uo,{}),"Delete"]})]}):null]})]})]})]})}function Gd({state:e}){const[n,s]=g.useState(!1),[a,r]=g.useState(null),{active:o,edited:d,profiles:l,lookups:i}=e,c=l.length>=Kt,u=()=>{s(!1),e.openSaveDialog()},x=p=>{s(!1),e.requestSwitch(p)},m=(p,f)=>{const h=t.jsxs("button",{type:"button",className:N(Rt,f),disabled:c,onClick:u,children:[t.jsx(lt,{className:"size-3.5"}),p]});return c?t.jsxs(nn,{children:[t.jsx(sn,{asChild:!0,children:t.jsx("span",{className:"block",children:h})}),t.jsxs(an,{children:["You can have up to ",Kt," profiles"]})]}):h};return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 text-lg text-border",children:"/"}),t.jsxs(te,{open:n,onOpenChange:p=>{s(p),p||r(null)},children:[t.jsx(ve,{asChild:!0,children:t.jsxs("button",{type:"button",title:o?.name,className:N("inline-flex h-[30px] flex-none items-center gap-[7px] whitespace-nowrap rounded-md px-2 text-sm hover:bg-accent",n&&"bg-accent"),children:[o?t.jsx("span",{className:"max-w-[140px] truncate font-semibold",children:o.name}):t.jsx("span",{className:"font-medium text-muted-foreground",children:"Profiles"}),d?t.jsx("span",{className:"inline-flex h-[18px] items-center rounded-sm border bg-muted px-1.5 text-[10.5px] font-semibold text-muted-foreground",children:"Edited"}):null,t.jsx(F,{className:"size-3.5 text-muted-foreground"})]})}),t.jsxs(ne,{align:"start",sideOffset:6,className:"w-[340px] overflow-visible p-0 shadow-lg",onEscapeKeyDown:p=>{a&&(p.preventDefault(),r(null))},children:[d&&o?t.jsxs("div",{className:"border-b p-1",children:[t.jsx("div",{className:N(as,"px-2 pt-2 pb-1"),children:"Edited view"}),t.jsxs("button",{type:"button",className:Rt,onClick:()=>{e.updateActive(),s(!1)},children:[t.jsx(Ki,{className:"size-3.5"}),"Update â",o.name,"â"]}),m("Save as new profileâ¦"),t.jsxs("button",{type:"button",className:N(Rt,"text-teal"),onClick:()=>{e.apply(o),s(!1)},children:[t.jsx(Ko,{className:"size-3.5"}),"Reset changes"]})]}):null,t.jsx("div",{className:"border-b p-1",children:t.jsx(rs,{name:"No profile",summary:"Shows everything",icon:t.jsx(Gi,{"aria-hidden":!0,className:"mt-0.5 size-3.5 flex-none text-muted-foreground"}),active:o===null,startup:e.startupId===null,onSelect:()=>x(null),onSetStartup:()=>e.setStartup(null)})}),l.length===0?t.jsxs("div",{className:"px-3 py-3",children:[t.jsx("p",{className:"text-[12.5px] font-semibold",children:"No saved profiles yet"}),t.jsx("p",{className:"mt-0.5 text-[11.5px] text-muted-foreground",children:"Set up the filters you use often, then save them here to switch back in one click."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:N(as,"px-3 pt-2.5 pb-1"),children:"Profiles"}),t.jsx("div",{className:"flex max-h-[60vh] flex-col gap-px overflow-y-auto p-1",children:l.map(p=>{if(a?.id===p.id&&a.kind==="rename")return t.jsx(Bd,{profile:p,profiles:l,onSave:b=>{e.rename(p.id,b),r(null)}},p.id);if(a?.id===p.id&&a.kind==="delete")return t.jsx(Kd,{name:p.name,onCancel:()=>r(null),onDelete:()=>{e.remove(p.id),r(null)}},p.id);const f=p.id===o?.id,h=f&&d?e.currentSnapshot:p.snapshot;return t.jsx(rs,{name:p.name,summary:Ld(h,i),active:f,startup:p.id===e.startupId,onSelect:()=>x(p),onSetStartup:()=>e.setStartup(p.id),onRename:()=>r({id:p.id,kind:"rename"}),onDelete:()=>r({id:p.id,kind:"delete"})}
2,p.id)})})]}),d?null:t.jsx("div",{className:"border-t p-1",children:m("Save this view as a profileâ¦",e.unsavedFilters?"bg-teal-secondary font-semibold text-teal":"text-muted-foreground")})]})]}),e.saveDialog?t.jsx(Fd,{rows:Zt(e.currentSnapshot,i),profiles:l,onSave:e.saveAsNew,onClose:e.closeSaveDialog}):null,e.pendingSwitch&&o?t.jsx($d,{activeName:o.name,targetName:e.pendingSwitch.profile?.name??"No profile",changes:zd(o.snapshot,e.currentSnapshot,i),onDiscard:()=>e.confirmSwitch("discard"),onSaveAsNew:()=>e.openSaveDialog(e.pendingSwitch),onUpdate:()=>e.confirmSwitch("update"),onCancel:e.closePendingSwitch}):null]})}function Ue(){const e=Ke().data;return e===void 0?!1:Ho(e.usableModules??[],e.entitledModules??[],"/action-logs")&&qo(e.capabilities??[],"/action-logs")}function nr(){const e=tn({from:"/calendar"}),n=$e(),s=Ue(),a=JSON.stringify(Le(e)),r=g.useMemo(()=>JSON.parse(a),[a]),o=g.useMemo(()=>({saved:r.saved,meetings:{shown:r.meetings.shown,personIds:r.meetings.personIds,me:r.meetings.me,customers:r.meetings.customers},actions:{shown:r.actions.shown,filters:{destination:r.actions.destination,tags:r.actions.tags,pbiTags:r.actions.pbiTags,status:r.actions.status}}}),[r]),d=x=>{n({to:"/calendar",search:m=>{const p=Object.fromEntries(On.map(f=>[f,m[f]]));return{...m,...Ja(x(Le(m))),...p}},replace:!0})};let l=o.saved.length>0?1:0;const{meetings:i,actions:c}=o,u=[i.personIds,i.me,i.customers].filter(x=>x.length>0).length;if(l+=i.shown?u:1,s){const x=Object.values(c.filters).filter(m=>m.length>0).length;l+=c.shown?x:1}return{filters:o,activeCount:l,setSaved:x=>d(m=>({...m,saved:x})),setMeetings:x=>d(m=>({...m,meetings:{...m.meetings,...x}})),setMeetingsShown:x=>d(m=>({...m,meetings:{...m.meetings,shown:x}})),setActions:x=>d(m=>({...m,actions:{shown:x.shown,...x.filters}})),clear:()=>d(()=>Vt)}}const en="yyyy-MM-dd",Ud=e=>{if(!e)return U(new Date);const n=Ye(e,en,new Date);return Number.isNaN(n.getTime())?U(new Date):U(n)};function sr(){const e=tn({from:"/calendar"}),n=$e(),s=Wo(Yo)===!0,a=e.mode??"week",r=e.allDay??"condensed",o=s&&a!=="month"&&e.view==="agenda"?"agenda":"grid",d=e.group??"day",l=e.layout??"board",i=g.useMemo(()=>Ud(e.date),[e.date]),c=v=>{n({to:"/calendar",search:y=>({...y,mode:v}),replace:!0})},u=v=>{n({to:"/calendar",search:y=>({...y,view:v==="grid"?void 0:v}),replace:!0})},x=v=>{n({to:"/calendar",search:y=>({...y,group:v==="day"?void 0:v}),replace:!0})},m=v=>{n({to:"/calendar",search:y=>({...y,layout:v==="board"?void 0:v}),replace:!0})},p=v=>{n({to:"/calendar",search:y=>({...y,allDay:v==="condensed"?void 0:v}),replace:!0})},f=g.useCallback(v=>{n({to:"/calendar",search:y=>({...y,date:P(U(v),en)}),replace:!0})},[n]),h=g.useCallback(v=>{n({to:"/calendar",search:y=>({...y,mode:"day",date:P(U(v),en)}),replace:!0})},[n]),b=g.useMemo(()=>Et(a,i),[a,i]),w=g.useMemo(()=>U(b[0]),[b]),S=g.useMemo(()=>Nt(b[b.length-1]),[b]),j=g.useMemo(()=>{const v=Et(a,rt(a,i,-1)),y=Et(a,rt(a,i,1));return[{since:U(v[0]),until:Nt(v[v.length-1])},{since:U(y[0]),until:Nt(y[y.length-1])}]},[a,i]);return{mode:a,allDay:r,view:o,agendaEnabled:s,agendaGroup:d,agendaLayout:l,anchor:i,days:b,since:w,until:S,adjacent:j,setMode:c,setAllDay:p,setView:u,setAgendaGroup:x,setAgendaLayout:m,setAnchor:f,openDay:h}}const Hd=N(Re,"gap-1.5 shadow-none data-[size=sm]:h-[30px]"),qd=[],Wd=[{value:"grid",label:"Grid",icon:rn},{value:"agenda",label:"Agenda",icon:cl}],Yd=[{value:"day",label:"Day",hint:"Days across, a lane per type"},{value:"type",label:"Type",hint:"Meetings · Action items"}],Qd=[{value:"board",label:"Board",icon:el},{value:"list",label:"List",icon:il}];function Vd({planner:e,profiles:n}){const{mode:s,anchor:a,days:r,view:o,agendaEnabled:d,agendaGroup:l,agendaLayout:i,setMode:c,setAnchor:u,setView:x,setAgendaGroup:m,setAgendaLayout:p}=sr(),f=nr(),{filters:h}=f,b=Ue(),w=gn(le("tags.use")),[S,j]=g.useState(!1),v=Td(s,a,r),y=n!==void 0&&n.profiles.length<Kt;return t.jsxs("div",{className:"flex min-h-12 flex-wrap items-center gap-x-2 gap-y-1.5 bg-background px-5 py-[9px]",children:[t.jsx("h1",{className:"flex-none text-xl font-semibold tracking-[-0.01em]",children:"Calendar"}),n?t.jsx(Gd,{state:n}):null,t.jsx("div",{className:"mx-0.5 h-5 w-px bg-border"}),t.jsx("button",{type:"button",className:N(Re,"px-3"),onClick:()=>{u(new Date)},children:"Today"}),t.jsxs("div",{className:"inline-flex items-center gap-0.5",children:[t.jsx(R,{variant:"ghost",size:"sm",className:"size-7 p-0",onClick:()=>{u(rt(s,a,-1))},"aria-label":"Previous",children:t.jsx(Zs,{className:"size-4"})}),t.jsxs(te,{open:S,onOpenChange:j,children:[t.jsx(ve,{asChild:!0,children:t.jsxs(R,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-sm font-semibold",children:[v,t.jsx(F,{className:"size-3.5 text-muted-foreground"})]})}),t.jsx(ne,{align:"start",className:"w-auto p-0",children:t.jsx(hn,{mode:"single",selected:a,onSelect:k=>{k&&(u(k),j(!1))},autoFocus:!0})})]}),t.jsx(R,{variant:"ghost",size:"sm",className:"size-7 p-0",onClick:()=>{u(rt(s,a,1))},"aria-label":"Next",children:t.jsx(ot,{className:"size-4"})})]}),t.jsxs(zs,{value:s,onValueChange:k=>{c(k)},children:[t.jsx(Fs,{size:"sm","aria-label":"Calendar view",className:Hd,children:t.jsx($s,{})}),t.jsx(Bs,{children:["day","workWeek","week","month"].map(k=>t.jsx(Ks,{value:k,className:"text-xs",children:Qa[k]},k))})]}),d&&s!=="month"?t.jsx("div",{role:"tablist","aria-label":"Calendar layout",className:"inline-flex flex-none gap-0.5 rounded-lg bg-border/60 p-0.5",children:Wd.map(k=>t.jsxs("button",{type:"button",role:"tab","aria-selected":o===k.value,className:N("inline-flex h-[26px] flex-none items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 text-xs font-medium",o===k.value?"bg-card text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),onClick:()=>{x(k.value)},children:[t.jsx(k.icon,{className:"size-3.5"}),k.label]},k.value))}):null,o==="agenda"?t.jsxs(t.Fragment,{children:[t.jsxs(Ae,{children:[t.jsx(Oe,{asChild:!0,children:t.jsxs("button",{type:"button",className:N(Re,"inline-flex items-center gap-1.5"),children:[t.jsx(Oi,{className:"size-3.5 text-muted-foreground","aria-label":"Group by"}),l==="day"?"Day":"Type",t.jsx(F,{className:"size-3 text-muted-foreground"})]})}),t.jsxs(Ee,{align:"start",className:"w-[260px] p-1",children:[t.jsx(bs,{className:"px-2 py-1 text-[10.5px] font-semibold tracking-[0.05em] text-muted-foreground uppercase",children:"Group by"}),Yd.map(k=>t.jsxs(pe,{onSelect:()=>{m(k.value)},className:"items-start gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:N("text-[12.5px]",l===k.value?"font-semibold":"font-medium"),children:k.label}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:k.hint})]}),l===k.value?t.jsx(W,{className:"mt-0.5 size-3.5 text-teal"}):null]},k.value))]})]}),t.jsx("div",{className:"inline-flex flex-none gap-0.5 rounded-md border bg-card p-0.5 dark:bg-input/30",children:Qd.map(k=>t.jsx("button",{type:"button","aria-label":k.label,title:k.label,"aria-pressed":i===k.value,className:N("inline-flex h-6 w-7 flex-none items-center justify-center rounded-sm",i===k.value?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>{p(k.value)},children:t.jsx(k.icon,{className:"size-3.5"})},k.value))})]}):null,t.jsxs(Sd,{count:f.activeCount,onClearAll:f.clear,onSaveAsProfile:y?()=>n.openSaveDialog():void 0,children:[t.jsx(Cd,{value:h.saved,tags:w.data?.items??qd,onChange:f.setSaved}),t.jsx(wd,{shown:h.meetings.shown,onShownChange:f.setMeetingsShown,value:h.meetings,onChange:f.setMeetings}),b?t.jsx(Id,{value:h.actions,onChange:f.setActions}):null]}),t.jsx("div",{className:"flex-1"}),t.jsx("button",{type:"button","aria-label":"Send note-taker",title:"Send note-taker",className:"inline-flex size-[30px] flex-none items-center justify-center rounded-full bg-teal text-inverse",onClick:ks,children:t.jsx(Ms,{className:"size-3.5"})}),e?t.jsx("button",{type:"button","aria-pressed":e.open,"aria-label":e.open?"Hide planner":"Show planner",title:e.open?"Hide planner":"Show planner",className:N(Re,"inline-flex w-[30px] items-center justify-center px-0",e.open?"text-foreground":"text-muted-foreground hover:text-foreground"),onClick:e.onToggle,children:e.open?t.jsx(nl,{className:"size-3.5"}):t.jsx(al,{className:"size-3.5"})}):null]})}function Jd(){return t.jsxs("div",{className:"rounded-lg border border-dashed px-4 py-3 flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-medium",children:"Connect your calendar"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Your upcoming meetings appear here once it's connected, and
2you can allow or block the note-taker per meeting."})]}),t.jsx(R,{size:"sm",variant:"secondary",onClick:()=>{Qo("meetings")},children:"Connect"})]})}function Xd({checked:e,onToggle:n,className:s}){return t.jsx("button",{type:"button",role:"checkbox","aria-checked":e,"aria-label":e?"Mark as not done":"Mark as done",onClick:()=>{n(!e)},className:N("absolute z-10 flex size-3.5 items-center justify-center rounded-[4px] border-[1.5px] outline-none focus-visible:ring-2 focus-visible:ring-ring",e?"border-muted-foreground bg-muted-foreground text-background":"border-sky-400",s),children:e?t.jsx(W,{className:"size-2.5",strokeWidth:3}):null})}const os="flex-none text-[10.5px] font-medium text-amber-800 dark:text-amber-300";function Pn({block:e,now:n,side:s,selection:a,list:r=!1,fullDue:o=!1}){const d=In();if(e.kind!=="action")return null;const l=re(e),i=e.source.dueDate,c=e.source.dueTime??null,u=o?et(i,c,n):c?As(c):null,x=on(e.source.destination),m=d.isDirty(e.source),p=j=>d.toggleDone(e.source,j),f=t.jsx("span",{className:"block size-3.5 flex-none"}),h=j=>t.jsx(Xd,{checked:l,onToggle:p,className:j}),b=t.jsx(he,{keys:fe(e)}),w=N(l&&"text-muted-foreground");if(r)return t.jsxs("div",{className:"relative",children:[h("top-1/2 left-1 -translate-y-1/2"),t.jsxs(Te,{block:e,now:n,side:s,selection:a,className:"grid min-h-[34px] w-full grid-cols-[22px_1fr_auto] items-center gap-0 rounded-none border-b border-border/50 bg-transparent px-1 text-[13px] ring-0 hover:bg-muted/50 data-[state=open]:bg-teal/8",children:[f,t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:N("min-w-0 truncate font-medium",w),children:e.title}),b]}),t.jsxs("span",{className:"flex items-center gap-3 pl-3 text-[11px] text-muted-foreground",children:[m?t.jsx("span",{className:os,children:"⢠Unsaved"}):null,x?t.jsx("span",{className:"max-w-[200px] truncate",children:x}):null,t.jsx("span",{className:"min-w-16 text-right",children:u})]})]})]});const S=[u,x].filter(Boolean).join(" · ");return t.jsxs("div",{className:"relative",children:[h("top-[9px] left-[9px]"),t.jsxs(Te,{block:e,now:n,side:s,selection:a,className:"flex w-full flex-col gap-1 rounded-lg border bg-card px-[9px] py-2 text-[12.5px] ring-0 hover:border-ring hover:bg-card data-[state=open]:border-teal data-[state=open]:bg-teal/8 data-[state=open]:ring-1 data-[state=open]:ring-teal",children:[t.jsxs("span",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"pt-px",children:f}),t.jsx("span",{className:N("min-w-0 flex-1 text-pretty font-medium leading-[1.35]",w),children:e.title}),b]}),S||m?t.jsxs("span",{className:"flex items-center gap-1 pl-[22px] text-[11px] whitespace-nowrap text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",children:S}),m?t.jsx("span",{className:os,children:"⢠Unsaved"}):null]}):null]})]})}function _n({block:e,now:n,side:s,selection:a,list:r=!1}){const o=e.kind!=="live"&&e.end<n,d=e.isAllDay?"All day":P(e.start,r?"h:mm a":"h:mm"),l=e.kind==="live"?t.jsx(Ht,{className:"bg-danger-subtle text-danger-foreground",children:"Live"}):null,i=t.jsx("span",{className:N("min-w-0 truncate",o&&"text-muted-foreground"),children:e.title});return r?t.jsxs(Te,{block:e,now:n,side:s,selection:a,className:"grid min-h-[30px] w-full grid-cols-[64px_1fr] items-center gap-0 rounded-none border-b border-border/50 bg-transparent px-1 text-[12px] ring-0 hover:bg-muted/50 data-[state=open]:shadow-[0_0_0_2px_var(--teal)]",children:[t.jsx("span",{className:"tabular-nums text-muted-foreground",children:d}),t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[i,t.jsx(he,{keys:fe(e)}),l]})]}):t.jsxs(Te,{block:e,now:n,side:s,selection:a,className:"flex min-h-[26px] w-full items-center gap-1.5 rounded-md px-2 py-1 text-[11.5px] data-[state=open]:shadow-[0_0_0_2px_var(--teal)]",children:[t.jsx("span",{className:"min-w-8 flex-none tabular-nums text-muted-foreground",children:d}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[i,t.jsx(he,{keys:fe(e)})]}),l]})}const Fe=[{key:"meetings",label:"Meetings",icon:Us,textClass:"text-muted-foreground"},{key:"actions",label:"Action items",icon:qs,textClass:"text-sky-700 dark:text-sky-300"}],Zd=e=>e.meetings.length+e.actions.length===0;function ar({type:e,items:n,now:s,selection:a}){return t.jsx("div",{className:"min-w-0",children:n.map(r=>e==="meetings"?t.jsx(_n,{block:r,now:s,side:"right",selection:a,list:!0},r.key):t.jsx(Pn,{block:r,now:s,side:"right",selection:a,list:!0},r.key))})}const is=(e,n)=>`${String(e)} ${n}${e===1?"":"s"}`,eu=e=>{const n=[e.meetings.length>0?is(e.meetings.length,"meeting"):"",e.actions.length>
20?is(e.actions.length,"action item"):""].filter(Boolean);return n.length>0?n.join(" · "):"Nothing scheduled"};function tu({groups:e,now:n,selection:s}){return t.jsx("div",{className:"h-full overflow-auto rounded-[10px] border bg-card",children:t.jsx("div",{className:"mx-auto max-w-[960px] px-6 pt-1 pb-6",children:e.map(a=>t.jsxs("section",{className:"pt-[18px]",children:[t.jsxs("header",{className:"flex items-center gap-2 border-b pb-2",children:[t.jsx("h3",{className:"text-[14px] font-semibold",children:P(a.day,"EEEE, MMMM d")}),ge(a.day,n)?t.jsx("span",{className:"inline-flex h-[18px] items-center rounded-full bg-teal px-[7px] text-[10.5px] font-semibold text-white",children:"Today"}):null,t.jsx("span",{className:"flex-1"}),t.jsx("span",{className:"text-[11.5px] text-muted-foreground",children:eu(a)})]}),Fe.map(r=>{const o=a[r.key];if(o.length===0)return null;const d=r.icon;return t.jsxs("div",{className:"grid grid-cols-[120px_1fr] pt-1.5",children:[t.jsxs("div",{className:N("flex items-start gap-1.5 pt-2 text-[11.5px] font-semibold",r.textClass),children:[t.jsx(d,{className:"mt-px size-3.5 flex-none"}),r.label]}),t.jsx(ar,{type:r.key,items:o,now:n,selection:s})]},r.key)})]},a.day.toISOString()))})})}function nu({groups:e,now:n,selection:s}){return t.jsx("div",{className:"h-full overflow-auto rounded-[10px] border bg-card",children:t.jsx("div",{className:"mx-auto max-w-[960px] px-6 pt-1 pb-6",children:Fe.map(a=>{const r=e[a.key],o=a.icon;return t.jsxs("section",{className:"pt-[18px]",children:[t.jsxs("header",{className:N("flex items-center gap-2 border-b pb-2",a.textClass),children:[t.jsx(o,{className:"size-4"}),t.jsx("h3",{className:"text-[14px] font-semibold",children:a.label})]}),r.length===0?t.jsx("p",{className:"pt-2 text-[11px] text-muted-foreground/50",children:"â"}):null,r.map(d=>t.jsxs("div",{className:"grid grid-cols-[120px_1fr] pt-1.5",children:[t.jsx("div",{className:"pt-2 text-[11.5px] font-semibold text-muted-foreground",children:gt(P(d.day,ie),n)}),t.jsx(ar,{type:a.key,items:d.items,now:n,selection:s})]},d.day.toISOString()))]},a.key)})})})}const zt=e=>e.filter(n=>!re(n)).length;function su(){return t.jsx("span",{className:"inline-flex h-[18px] items-center rounded-full bg-teal px-[7px] text-[10.5px] font-semibold text-white",children:"Today"})}function au({groups:e,now:n,rangeWord:s,selection:a}){const[r,o]=g.useState([]),d=l=>o(i=>i.includes(l)?i.filter(c=>c!==l):[...i,l]);return t.jsx("div",{className:"h-full overflow-auto rounded-[10px] border bg-card",children:t.jsxs("div",{className:"grid min-w-min",style:{gridTemplateColumns:`104px repeat(${String(e.length)}, minmax(212px, 1fr))`},children:[t.jsx("div",{className:"sticky top-0 left-0 z-20 border-b bg-card"}),e.map(l=>{const i=ge(l.day,n),c=zt(l.actions);return t.jsxs("div",{className:N("sticky top-0 z-10 flex items-center gap-2 border-b border-l px-2.5 pt-2.5 pb-2",i?"bg-[color-mix(in_oklab,var(--teal)_8%,var(--card))]":"bg-card"),children:[t.jsx("span",{className:"text-[13px] font-semibold whitespace-nowrap",children:P(l.day,"EEE d")}),i?t.jsx(su,{}):null,t.jsx("span",{className:"flex-1"}),c>0?t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:c}):null]},l.day.toISOString())}),Fe.map(l=>{const i=r.includes(l.key),c=e.flatMap(m=>m[l.key]),u=l.key==="meetings"?`${String(c.length)} ${s}`:`${String(zt(c))} open`,x=i?ot:F;return t.jsxs(g.Fragment,{children:[t.jsx("div",{className:"sticky left-0 z-10 border-b bg-card",children:t.jsxs("div",{className:"h-full bg-muted/30 py-2.5 pr-1 pl-2.5",children:[t.jsxs("button",{type:"button","aria-expanded":!i,onClick:()=>d(l.key),className:N("flex items-center gap-1 text-left text-[12px] font-semibold whitespace-nowrap",l.textClass),children:[t.jsx(x,{className:"size-3 flex-none"}),l.label]}),t.jsx("div",{className:"pl-4 text-[11px] text-muted-foreground",children:u})]})}),e.map((m,p)=>{const f=m[l.key],h=zt(f),b=p<e.length/2?"right":"left";return t.jsxs("div",{className:N("flex min-w-0 flex-col border-b border-l p-2",l.key==="meetings"?"gap-0.5":"gap-1.5",ge(m.day,n)&&"bg-teal/4"),children:[f.length===0?t.jsx("span",{className:"text-[11px] text-muted-foreground
2/50",children:"â"}):null,f.length>0&&i?t.jsx("span",{className:"text-[11px] text-muted-foreground",children:l.key==="meetings"?`${String(f.length)} meeting${f.length===1?"":"s"}`:`${String(h)} open`}):null,i?null:f.map(w=>l.key==="meetings"?t.jsx(_n,{block:w,now:n,side:b,selection:a},w.key):t.jsx(Pn,{block:w,now:n,side:b,selection:a},w.key))]},m.day.toISOString())})]},l.key)})]})})}function ru({groups:e,now:n,selection:s}){return t.jsx("div",{className:"flex h-full gap-3 overflow-x-auto",children:Fe.map((a,r)=>{const o=e[a.key],d=o.flatMap(u=>u.items),l=a.key==="meetings"?d.length:d.filter(u=>!re(u)).length,i=r===Fe.length-1?"left":"right",c=a.icon;return t.jsxs("section",{className:"flex min-w-[260px] flex-1 basis-0 flex-col overflow-hidden rounded-[10px] border bg-card/50",children:[t.jsxs("header",{className:"flex flex-none items-center gap-2 border-b px-3 py-2.5",children:[t.jsx(c,{className:N("size-4",a.textClass)}),t.jsx("h3",{className:N("text-[13px] font-semibold",a.textClass),children:a.label}),t.jsx("span",{className:"flex-1"}),l>0?t.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:l}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[o.length===0?t.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:"â"}):null,o.map(u=>t.jsxs("div",{className:"mb-3 last:mb-0",children:[t.jsx("h4",{className:"px-1 pb-1.5 text-[10.5px] font-bold tracking-[0.12em] text-muted-foreground uppercase",children:gt(P(u.day,ie),n)}),t.jsx("div",{className:N("flex flex-col",a.key==="meetings"?"gap-0.5":"gap-1.5"),children:u.items.map(x=>a.key==="meetings"?t.jsx(_n,{block:x,now:n,side:i,selection:s},x.key):t.jsx(Pn,{block:x,now:n,side:i,selection:s,fullDue:!0},x.key))})]},u.day.toISOString()))]})]},a.key)})})}function ou({columns:e}){return t.jsx("div",{className:"flex h-full gap-3 overflow-x-auto rounded-[10px] border bg-card p-2",children:Array.from({length:e},(n,s)=>t.jsxs("div",{className:"flex min-w-[212px] flex-1 basis-0 animate-pulse flex-col gap-2",children:[t.jsx("div",{className:"h-[26px] rounded-md bg-muted"}),t.jsx("div",{className:"h-[26px] rounded-md bg-muted"}),t.jsx("div",{className:"h-[52px] rounded-lg bg-muted/60"}),t.jsx("div",{className:"h-[52px] rounded-lg bg-muted/60"}),t.jsx("div",{className:"h-[52px] rounded-lg bg-muted/60"})]},s))})}function iu({days:e,blocks:n,now:s,mode:a,group:r,layout:o,loading:d,selectedKeys:l,onSelectionChange:i}){const c=Dn(n,l,i),u=g.useMemo(()=>Vo(n,e),[n,e]),x=g.useMemo(()=>Jo(n,e),[n,e]);if(d)return t.jsx(ou,{columns:r==="day"?e.length:3});const m=a==="day"?"this day":"this week";return u.every(Zd)?t.jsx("div",{className:"flex h-full items-center justify-center rounded-[10px] border bg-card",children:t.jsxs("span",{className:"text-sm text-muted-foreground",children:["Nothing scheduled ",m,"."]})}):r==="day"&&o==="board"?t.jsx(au,{groups:u,now:s,rangeWord:m,selection:c}):r==="day"?t.jsx(tu,{groups:u,now:s,selection:c}):o==="board"?t.jsx(ru,{groups:x,now:s,selection:c}):t.jsx(nu,{groups:x,now:s,selection:c})}const lu=2,cu=20,du=e=>{const[n,s]=g.useState(2);return g.useEffect(()=>{const a=e.current;if(!a)return;const r=()=>{const d=a.firstElementChild,l=d instanceof HTMLElement?d.offsetHeight:cu;s(Math.max(1,Math.floor(a.clientHeight/(l+lu))))};r();const o=new ResizeObserver(r);return o.observe(a),()=>{o.disconnect()}},[e]),n},uu=e=>[...e].sort((n,s)=>n.isAllDay!==s.isAllDay?n.isAllDay?-1:1:re(n)!==re(s)?re(n)?1:-1:n.start.getTime()-s.start.getTime());function mu({day:e,index:n,anchor:s,blocks:a,now:r,loading:o,selection:d,onOpenDay:l,onDropItem:i}){const[c,u]=g.useState(!1),x=wi(e,s),m=ge(e,r),p=e.getDay()===0||e.getDay()===6,f=g.useRef(null),h=du(f),b=uu(a),w=b.length-h,S=n%7>=5?"left":"right";return t.jsxs("div",{className:N("relative flex flex-col border-l border-b px-[7px] py-1.5 first:border-l-0",n%7===0&&"border-l-0",x?p&&"bg-muted/40":"bg-muted/30",c&&"bg-violet-500/10"),onDragOver:j=>{!i||!Ha(j)||(j.preventDefault(),j.dataTransfer.dropEffect="move",u(!0))},onDragLeave:j=>{Ua(j)&&u(!1)},onDrop:j=>{u(!1);const v=i?qa(j):null;!v||!i||(j.preventDefault(),i(v,e,"keep"))},children:[t.jsxs("div",{className:"flex flex-none items-start justify-between",children:[t.jsx("span",{className:N("text-[11px] font-semibold",m&&"inline-flex size-5 items-center justify-center rounded-full bg-primary text-primary-foreground",!m&&!x&&"text-muted-foreground
2/70"),children:e.getDate()}),w>0?t.jsxs("button",{type:"button",className:"text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{l(e)},children:["+",w," more"]}):null]}),t.jsx("div",{ref:f,className:"min-h-0 flex-1 overflow-hidden",children:o&&b.length===0?[0,1].map(j=>t.jsx("div",{className:"mt-0.5 h-4 animate-pulse rounded bg-muted/70"},j)):b.slice(0,h).map(j=>t.jsx(Te,{block:j,now:r,side:S,selection:d,draggable:!0,className:"mt-0.5 flex w-full items-center gap-1 rounded px-1 py-0.5 text-[10px]",children:t.jsx(oa,{block:j,variant:"pill"})},j.key))})]})}function xu({days:e,blocks:n,now:s,anchor:a,loading:r,selectedKeys:o,onSelectionChange:d,onOpenDay:l,onDropItem:i}){const c=Dn(n,o,d),u=!r&&n.length===0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border bg-card",children:[t.jsx("div",{className:"flex flex-none border-b",children:e.slice(0,7).map(x=>t.jsx("div",{className:"flex-1 border-l py-1.5 text-center text-[11px] uppercase tracking-wide text-muted-foreground first:border-l-0",children:x.toLocaleDateString(void 0,{weekday:"short"})},x.toISOString()))}),t.jsxs("div",{className:"relative min-h-0 flex-1 overflow-y-auto",children:[t.jsx("div",{className:"grid h-full grid-cols-7",style:{gridTemplateRows:`repeat(${String(e.length/7)}, minmax(92px, 1fr))`},children:e.map((x,m)=>t.jsx(mu,{day:x,index:m,anchor:a,blocks:Qe(n,x),now:s,loading:r,selection:c,onOpenDay:l,onDropItem:i},x.toISOString()))}),u?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("span",{className:"text-sm text-muted-foreground",children:"No meetings this month."})}):null]})]})}function pu(){const e=$a();return g.useCallback((n,s,a)=>{e(n,r=>{const o=P(s,ie),d=a==="keep"?r.dueTime??null:a===null?null:cd(a);return o===r.dueDate&&d===(r.dueTime??null)?r:{...r,dueDate:o,dueTime:d}})?.catch(r=>G.error(`Could not move it: ${r.message}`))},[e])}const rr="luniko.planner.collapsed",or=e=>e.replace(/^actions:/,""),gu=e=>/^\d{4}-\d{2}-\d{2}$/.test(or(e)),fu=e=>{try{const n=window.localStorage.getItem(rr),s=n?JSON.parse(n):[];return Array.isArray(s)?new Set(s.filter(a=>typeof a=="string"&&(!gu(a)||or(a)>=e))):new Set}catch{return new Set}},hu=e=>{try{window.localStorage.setItem(rr,JSON.stringify([...e]))}catch{}},ju=e=>{const[n,s]=g.useState(()=>fu(e)),a=g.useCallback(r=>{s(o=>{const d=new Set(o);return d.has(r)?d.delete(r):d.add(r),hu(d),d})},[]);return{collapsed:n,toggle:a}},bu=2500;function vu({today:e,personalTags:n,onCreated:s}){const a=Ke().data?.personId??null,r=Os(),[o,d]=g.useState(!1),[l,i]=g.useState(kt),[c,u]=g.useState(null);if(g.useEffect(()=>{if(!c)return;const p=setTimeout(()=>u(null),bu);return()=>clearTimeout(p)},[c]),!a)return null;const x=()=>{i(kt),d(!1)},m=()=>{const{destination:p,dueDate:f}=l;if(!Pa(l)||!p||!f)return;const h=l.taskName.trim(),b={...Hi(),taskName:h,additionalNote:l.additionalNote.trim()?l.additionalNote:null,dueDate:f,dueTime:l.dueTime,destination:p,tags:l.tags,pbiTags:l.pbiTags,responsibleDoer:a,status:pn.NEW,source:Xo.WEB},w=Es({items:[b],getPendingMarks:()=>({pendingTagIds:l.personalTagIds})});r.mutate(w,{onSuccess:()=>{i(kt),u(`Added to ${gt(f,e)}`),s({title:h,dueDate:f})},onError:S=>G.error(`Could not add: ${S.message}`)})};return t.jsxs("div",{className:"flex-none border-b p-2",children:[o?t.jsx(Cn,{className:"",item:null,draft:l,dirty:!1,saving:r.isPending,today:e,personalTags:n,onChange:i,onSave:m,onCancel:x,onMinimize:x}):t.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex min-h-9 w-full items-center gap-2 rounded-md border bg-background px-2.5 text-left text-[13px] text-muted-foreground hover:border-ring",children:[t.jsx(lt,{className:"size-3.5 flex-none"}),"Add an action item"]}),c?t.jsxs("p",{role:"status",className:"mt-1.5 flex items-center gap-1.5 px-1 text-[11px] text-muted-foreground",children:[t.jsx(W,{className:"size-3 text-green-600"}),c]}):null]})}const yu=500,ls=[],Nu=async(e,n)=>{const s=[];let a=1;for(;;){const r=await e.find({...n,page:a,pageSize:yu});if(s.push(...r.items),!r.hasNextPage)return s;a+=1}},ir=(e,n)=>{const s=qi(),a=Wi(s);return{ready:(a.responsibleDoer.length>0||a.responsibleDoerPersonIds.length>0)&&!s.isLoading,params:{...a,...e,...n.destination.length>0?{destination:n.destination}:{},...n.tags.length>0?{tags:n.tags}:{},...n.pbiTags.length>0?{pbiTags:n.pbiTags}:{},...n.status.length>0?{status:n.status}:{}}}};function wu({since:e,until:n},s,a){const r=Ys(),{params:o,ready:d}=ir({dueDateFrom:P(e,"yyyy-MM-dd"),dueDateTo:P(n,"yyyy-MM-dd")},s),l=a&&d,i=Xe({queryKey:Z.actionItemsCalendar(o),queryFn:()=>Nu(r,o),staleTime:3e4,enabled:l});return{items:l?i.data??ls:ls,isLoading:i.isLoading}}const Su=50;function Cu({filters:e,marks:n,pollMs:s,pollUntil:a}){const r=Ys(),{params:o,ready:d}=ir({done:!1,sortBy:"due_date",...n?{marks:n}:{}},e);return dr({queryKey:Z.actionItemsPlanner(o),queryFn:({pageParam:l})=>r.find({...o,page:l,pageSize:Su}),initialPageParam:1,getNextPageParam:l=>l.hasNextPage?l.page+1:void 0,staleTime:3e4,refetchInterval:l=>a&&!a(l.state.data?.pages.flatMap(i=>i.items)??[])?s:!1,enabled:d})}const ku=2e3,Mu=3e4;function Iu(e){const[n,s]=g.useState(null),a=Cu({...e,pollMs:ku,pollUntil:n?r=>r.some(o=>o.taskName===n.title&&o.dueDate===n.dueDate):void 0});return g.useEffect(()=>{if(!n)return;const r=setTimeout(()=>s(null),Mu);return()=>clearTimeout(r)},[n]),{query:a,awaitCreated:s}}
2const Tu=(e,n)=>{const s=P(n,ie),a=[],r=[],o=new Map,d=new Set;for(const l of e)if(!(tt(l)||d.has(l.id)))if(d.add(l.id),!l.dueDate)a.push(l);else if(l.dueDate<s)r.push(l);else{const i=o.get(l.dueDate);i?i.items.push(l):o.set(l.dueDate,{key:l.dueDate,label:gt(l.dueDate,n),items:[l]})}return{undated:a,overdue:r,days:[...o.values()]}},Du="border-sky-400/50 bg-sky-500/[0.07]";function Au({id:e,title:n,done:s,highlight:a,unsaved:r,subtitle:o,trailing:d,reminder:l,draggable:i=!0,onOpen:c,onToggleDone:u}){return t.jsxs("li",{draggable:i,onDragStart:x=>Ga(x,{id:e}),title:i?"Drag onto the calendar to set its day":void 0,className:N("flex min-h-[33px] items-center gap-2.5 border-t py-1 text-[12.5px] first:border-t-0",i&&"cursor-grab active:cursor-grabbing",a&&N("-mx-1.5 rounded-md border px-2 first:border-t",Du)),children:[t.jsx(jn,{checked:s,onCheckedChange:x=>u(!!x),"aria-label":"Mark as done",className:"size-[15px] flex-none"}),t.jsxs("button",{type:"button",onClick:c,"aria-label":`Action item: ${n}`,className:"flex min-w-0 flex-1 flex-col text-left",children:[t.jsx("span",{className:N("min-w-0 truncate",s&&"text-muted-foreground line-through"),children:n}),o?t.jsx("span",{className:"truncate text-[10.5px] leading-tight text-muted-foreground",children:o}):null]}),r?t.jsx("span",{className:"flex-none text-[10.5px] font-medium text-amber-800 dark:text-amber-300",children:"⢠Unsaved"}):null,t.jsx(he,{keys:[Me("actionItem",e)],dotClassName:"size-2"}),d?t.jsx("span",{className:"flex-none text-[11px] text-muted-foreground",children:d}):null,l]})}const cs=(e,n)=>n?`${String(e)}+`:e;function Ou({hasNextPage:e,isFetchingNextPage:n,fetchNextPage:s}){const[a,r]=g.useState(null);return g.useEffect(()=>{if(!a||!e||n)return;const o=new IntersectionObserver(d=>{d.some(l=>l.isIntersecting)&&s()},{rootMargin:"400px 0px",threshold:.01});return o.observe(a),()=>o.disconnect()},[a,e,n,s]),r}function Eu(){return g.useCallback(e=>{if(!e||typeof e.scrollIntoView!="function")return;const n=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;e.scrollIntoView({block:"nearest",behavior:n?"auto":"smooth"})},[])}function Pu({children:e}){return t.jsx("li",{ref:Eu(),children:e})}function Ft({id:e,label:n,count:s,urgent:a=!1,collapsed:r,onToggle:o,action:d,children:l}){const i=r?ot:F;return t.jsxs("section",{className:"border-b last:border-b-0",children:[t.jsxs("div",{className:"flex items-center pr-3.5",children:[t.jsxs("button",{type:"button","aria-expanded":!r,"aria-controls":e,onClick:o,className:N("flex h-8 min-w-0 flex-1 items-center gap-1.5 px-3.5 text-left text-[10.5px] font-bold uppercase tracking-[0.14em] hover:bg-muted/40",a?"text-destructive":"text-muted-foreground"),children:[t.jsx(i,{className:"size-[13px] flex-none"}),t.jsx("span",{className:"truncate",children:n}),t.jsx("span",{className:"font-medium normal-case tracking-normal opacity-70",children:s})]}),d]}),r?null:t.jsx("ul",{id:e,className:"px-3.5 pb-1.5",children:l})]})}function _u({today:e,filters:n,marks:s,collapsed:a,onToggle:r,draggable:o}){const{query:d,awaitCreated:l}=Iu({filters:n,marks:s}),i=g.useMemo(()=>d.data?.pages.flatMap(C=>C.items)??[],[d.data]),c=g.useMemo(()=>Tu(i,e),[i,e]),u=Ou(d),[x,m]=g.useState(!1),p=In(),{openItem:f,setOpenItem:h}=Rc(),b=f?.kind==="action"?f.id:null,w=C=>h(C?{kind:"action",id:C}:null),{personalTags:S}=p,j=d.hasNextPage&&c.overdue.length===0&&c.days.length===0,v=d.hasNextPage&&c.days.length===0,y=C=>{p.close(C),w(null)},k=C=>{p.close(i.find(E=>E.id===b)),w(C)},T=C=>C.id===b?t.jsx(Pu,{children:t.jsx(Cn,{item:C,draft:p.draftOf(C),dirty:p.isDirty(C),saving:!1,done:tt(C),today:e,personalTags:S,onChange:E=>p.change(C,E),onToggleDone:E=>p.toggleDone(C,E),onSave:()=>{w(null),p.save(C)},onCancel:()=>{p.cancel(C),w(null)},onMinimize:()=>y(C),footerAction:t.jsx(Oa,{request:{subject:{type:"action_item",id:C.id},title:C.taskName?.trim()??""}})})},C.id):t.jsx(Au,{id:C.id,title:C.taskName?.trim()||"Untitled action item",done:tt(C),highlight:C.dueDate===P(e,ie)&&!!C.dueTime,unsaved:p.isDirty(C),draggable:o,subtitle:`${et(C.dueDate,C.dueTime??null,e)??"No date"} · ${on(C.destination)}`,onOpen:()=>k(C.id),onToggleDone:E=>p.toggleDone(C,E)},C.id),A=t.jsx(vu,{today:e,personalTags:S,onCreated:l});if(d.isPending)return t.jsxs(t.Fragment,{children:[A,t.jsxs("p",{className:"flex items-center justify-center gap-2 px-3.5 py-6 text-xs text-muted-foreground",children:[t.jsx(Gn,{className:"size-3.5 animate-spin"})," Loading your action items"]})]});if(d.isError)return t.jsxs(t.Fragment,{children:[A,t.jsx("p",{className:"px-3.5 py-6 text-center text-xs text-muted-foreground",children:"Could not load your action items."})]});
2const H=c.undated.length===0&&c.overdue.length===0&&c.days.length===0;return t.jsxs(t.Fragment,{children:[A,t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[H?t.jsx("p",{className:"px-3.5 py-6 text-center text-xs text-muted-foreground",children:"No open action items. Add one above."}):null,c.undated.length>0?t.jsx(Ft,{id:"planner-actions-undated",label:"No date",count:cs(c.undated.length,j),collapsed:!x,onToggle:()=>m(C=>!C),children:c.undated.map(T)}):null,c.overdue.length>0?t.jsx(Ft,{id:"planner-actions-overdue",label:"Overdue",count:cs(c.overdue.length,v),urgent:!0,collapsed:a.has("actions:overdue"),onToggle:()=>r("actions:overdue"),children:c.overdue.map(T)}):null,c.days.map(C=>t.jsx(Ft,{id:`planner-actions-${C.key}`,label:C.label,count:C.items.length,collapsed:a.has(`actions:${C.key}`),onToggle:()=>r(`actions:${C.key}`),children:C.items.map(T)},C.key)),t.jsx("div",{ref:u,"aria-hidden":"true",className:"h-px"}),d.isFetchingNextPage?t.jsxs("p",{className:"flex items-center justify-center gap-2 px-3.5 py-3 text-[11px] text-muted-foreground",children:[t.jsx(Gn,{className:"size-3 animate-spin"})," Loading more"]}):null]})]})}function Ru({today:e,actionItems:n,saved:s,onClearSaved:a,draggable:r=!0}){const{tags:o}=Pe(),{collapsed:d,toggle:l}=ju(P(e,ie)),i=s.length>0?[...s]:void 0,c=s.map(u=>u===X?"Bookmarked":o.find(x=>x.id===u)?.name??"a tag");return t.jsxs("aside",{"aria-label":"Planner",className:"flex h-full w-[380px] flex-none flex-col overflow-hidden rounded-lg border bg-card",children:[t.jsxs("header",{className:"flex h-10 flex-none items-center gap-2 border-b pr-2 pl-3.5",children:[t.jsx(Yi,{className:"size-4 text-violet-600"}),t.jsx("h2",{className:"text-[13px] font-semibold",children:"Planner"})]}),i?t.jsxs("div",{className:"flex flex-none items-center gap-2 border-b bg-muted/50 px-3.5 py-1.5 text-[11.5px]",children:[t.jsxs("span",{className:"min-w-0 flex-1 truncate text-muted-foreground",children:["Showing: ",t.jsx("span",{className:"font-medium text-foreground",children:c.join(" or ")})]}),t.jsx("button",{type:"button",className:"flex-none font-medium text-teal hover:underline",onClick:a,children:"Clear"})]}):null,t.jsx(_u,{today:e,filters:n,marks:i,collapsed:d,onToggle:l,draggable:r})]})}const Lu=(e,n,s,a,r)=>{if(s.personId===null)return[];const o=e.filter(u=>u.kind==="action"||n.meetings.shown),d=[{id:s.personId,email:s.email},...r],l=Zo(o,d,s.personId),i=ei(l,n.meetings.me,{email:s.email,name:s.name}),c=ti(i,n.meetings.customers,s.orgId);return xl(c,n.saved,a)},zu=500,Fu=1440*60*1e3,$u=60,Bu=[],Ku=[],Gu=[],ds=(e,n)=>[...Z.recordedRange,e.toISOString(),n.toISOString()],us=async(e,n,s)=>{const a=[];let r=1;for(;;){const o=await e.find({since:n,until:s,view:"calendar",pageSize:zu,page:r});if(a.push(...o.items.map(d=>d.transcript)),!o.hasNextPage)return a;r+=1}},Uu=(e,n)=>Math.min(Math.max(Math.ceil((e.getTime()-n.getTime())/Fu),1),$u);function Hu({since:e,until:n},s,a=[]){const r=ni(),o=Rs(),d=Be(),l=Xe({queryKey:ds(e,n),queryFn:()=>us(r,e,n),staleTime:3e4,enabled:e<=s}),i=Uu(n,s),c=Xe({queryKey:[...Z.upcoming,i],queryFn:()=>o.getUpcomingEvents(i),staleTime:6e4,retry:!1,enabled:n>s}),u=si();g.useEffect(()=>{for(const b of a)b.since>new Date||d.prefetchQuery({queryKey:ds(b.since,b.until),queryFn:()=>us(r,b.since,b.until),staleTime:3e4})},[a,d,r]);const x=l.data,m=u.data,p=c.data,f=g.useMemo(()=>({recorded:x??Bu,live:m?.items??Ku,upcoming:p?.events??Gu}),[x,m,p]),h=c.error instanceof ai&&c.error.status===404;return{meetings:f,recorded:{isLoading:l.isLoading,error:l.error},upcoming:{isLoading:c.isLoading,error:c.error,noCalendar:h},live:{isLoading:u.isLoading,error:u.error}}}const qu=[];function Wu({range:e,adjacent:n,now:s,filters:a,ready:r}){const o=Ke().data,d=Ue(),l=hi(),{contactsMap:i}=mn(),c=wu(e,a.actions.filters,d&&a.actions.shown),{meetings:u,recorded:x,upcoming:m,live:p}=Hu(e,s,n),f=g.useMemo(()=>ri(u,c.items,s),[u,c.items,s]),h=a.meetings.personIds.join(","),b=g.useMemo(()=>h===""||i.size===0?qu:h.split(",").map(E=>i.get(E)).filter(E=>E!==void 0),[h,i]),w=o?.personId??null,S=o?.email??null,j=o?.name??null,v=o?.orgId??null,{saved:y}=a,{shown:k,me:T,customers:A}=a.meetings,H=g.useMemo(()=>r?Lu(f,{saved:y,meetings:{shown:k,me:T,customers:A}},{personId:w,email:S,name:j,orgId:v},l,b):[],[r,f,y,k,T,A,w,S,j,v,l,b]),C=x.isLoading||m.isLoading||p.isLoading;return{blocks:H,loading:C,recorded:x,upcoming:m}}let ms=null;function Yu(){const e=tn({from:"/calendar"}),n=$e(),s=Ke().data,a=oi(),{contactsMap:r,isLoading:o}=mn(),d=gn(le("tags.use")),l=Gs(),i=Hs(),c=Ue(),u=d.data?.items,x=l.data,m=g.useMemo(()=>({people:o||r.size===0?null:new Set(r.keys()),tags:d.isSuccess?new Set((u??[]).map(I=>I.id)):null,customers:l.isSuccess?new Set((x??[]).map(I=>I.orgId)):null}),[o,r,d.isSuccess,u,l.isSuccess,x]),p=g.useMemo(()=>({personName:I=>r.get(I)?.name,tagName:I=>u?.find(D=>D.id===I)?.name,customerName:I=>x?.find(D=>D.orgId===I)?.name,destinationLabel:I=>i.find(D=>D.value===I)?.label,showActions:c}),[r,u,x,i,c]),[f,h]=g.useState(null),[b,w]=g.useState(null),[S,j]=g.useState(null),v=f??(s?s.calendarProfiles??Dd:null),y=g.useCallback(I=>{const D=I?ze(I.snapshot,m):Vt;n({to:"/calendar",search:O=>({...O,...Ja(D),profile:I?.id??Je}),replace:!0})},[n,m]),k=g.useCallback(I=>{n({to:"/calendar",search:D=>({...D,profile:I}),replace:!0})},[n]);if(g.useEffect(()=>{e.profile!==void 0&&(ms=e)},[e]),g.useEffect(()=>{const I=e.profile===void 0&&[...On,...Va].every(_=>e[_]===void 0),D=ms;if(I&&D){n({to:"/calendar",search:_=>({...D,date:_.date??D.date,focus:_.focus}),replace:!0});return}if(!v)return;const O=_d(v,e,m);O&&(O.keepFilters?k(O.profile?.id??Je):y(O.profile))},[v,e,m,n,y,k]),!v)return null;const T=v.profiles,A=e.profile===Je?null:Xt(v,e.profile)??null,H=A!==null&&Xa(A,e,m),C=ze(Le(e),m),E=I=>{h(I),a.mutate(I,{onSettled:()=>{h(D=>D===I?null:D)}})},Q=I=>{(I?.id??null)!==(A?.id??null)&&(H?w({profile:I}
2):y(I))},M=()=>{A&&E({...v,profiles:T.map(I=>I.id===A.id?{...I,snapshot:C}:I)})},B=I=>{b&&(I==="update"&&M(),y(b.profile),w(null))},J=(I,D)=>{const O={id:crypto.randomUUID(),name:I.trim(),snapshot:C};E({profiles:[...T,O],startupId:D?O.id:v.startupId});const _=S?.thenSwitchTo??null;j(null),_?y(_.profile):k(O.id);const we=T.length+1;G.success(we<=9?`Saved â${O.name}â · press ${String(we)} to switch here`:`Saved â${O.name}â`)},Ne=(I,D)=>{E({...v,profiles:T.map(O=>O.id===I?{...O,name:D.trim()}:O)})},ce=I=>{E({...v,startupId:I})},de=I=>{E({profiles:T.filter(D=>D.id!==I),startupId:v.startupId===I?null:v.startupId}),A?.id===I&&y(null)};return{profiles:T,startupId:v.startupId,active:A,edited:H,ready:e.profile!==void 0,unsavedFilters:A===null&&!En(C,Vt),currentSnapshot:C,lookups:p,apply:y,requestSwitch:Q,confirmSwitch:B,updateActive:M,saveAsNew:J,rename:Ne,setStartup:ce,remove:de,pendingSwitch:b,closePendingSwitch:()=>w(null),saveDialog:S,openSaveDialog:(I=null)=>{w(null),j({thenSwitchTo:I})},closeSaveDialog:()=>j(null)}}const Qu=()=>{const[e,n]=g.useState(()=>new Date);return g.useEffect(()=>{const s=setInterval(()=>{n(new Date)},6e4);return()=>{clearInterval(s)}},[]),e};function Lm(){return t.jsx(_c,{children:t.jsx(Vu,{})})}function Vu(){Vi("Calendar");const e=Qu(),{mode:n,allDay:s,view:a,agendaGroup:r,agendaLayout:o,anchor:d,days:l,since:i,until:c,adjacent:u,setAllDay:x,openDay:m}=sr(),[p,f]=g.useState(!1),h=Ue(),b=nr(),{filters:w}=b,S=w.actions,j=h&&S.shown?S.filters:void 0,v=w.saved,y=Yu(),k=y!==null&&y.ready,{blocks:T,loading:A,recorded:H,upcoming:C}=Wu({range:{since:i,until:c},adjacent:u,now:e,filters:w,ready:k}),[E,Q]=g.useState([]),M=g.useMemo(()=>{const O=new Set(E);return T.map(_=>_.key).filter(_=>O.has(_))},[E,T]),B=M.length>0;g.useEffect(()=>{if(!B)return;const O=_=>{_.key!=="Escape"||_.defaultPrevented||di(_.target)||document.querySelector('[role="dialog"][data-state="open"]')||Q([])};return window.addEventListener("keydown",O),()=>{window.removeEventListener("keydown",O)}},[B]);const J=pu(),Ne=g.useCallback((O,_,we)=>J(O.id,_,we),[J]),ce=h?Ne:void 0,de=Qi("(min-width: 1180px)"),I=Ji()?{duration:0}:{duration:.28,ease:[.32,.72,0,1]},D=j?t.jsx(Ru,{today:U(e),actionItems:j,saved:v,onClearSaved:()=>b.setSaved([]),draggable:a!=="agenda"}):null;return t.jsxs("div",{className:"flex h-[calc(100vh-3rem-1px)] min-h-0 flex-col",children:[t.jsx(Vd,{planner:D?{open:p,onToggle:()=>f(O=>!O)}:void 0,profiles:y??void 0}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-2 px-5 pb-5",children:[C.noCalendar?t.jsx(Jd,{}):null,H.error?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Couldn't load recorded meetings."}):null,C.error&&!C.noCalendar?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Couldn't load upcoming meetings."}):null,M.length>0?t.jsxs("div",{"aria-live":"polite",className:"sr-only",children:[M.length," meeting",M.length===1?"":"s"," selected"]}):null,t.jsx("div",{className:"min-h-0 flex-1",onClick:O=>{M.length===0||O.target.closest("button, a, [role='dialog'], [role='menu']")||Q([])},children:t.jsxs(yd,{children:[t.jsxs("div",{className:"flex h-full min-h-0",children:[t.jsx("div",{className:"min-h-0 min-w-0 flex-1",children:a==="agenda"?t.jsx(iu,{days:l,blocks:T,now:e,mode:n,group:r,layout:o,loading:A,selectedKeys:M,onSelectionChange:Q}):n==="month"?t.jsx(xu,{days:l,blocks:T,now:e,anchor:d,loading:A,selectedKeys:M,onSelectionChange:Q,onOpenDay:m,onDropItem:ce}):t.jsx(pd,{days:l,blocks:T,now:e,loading:A,mode:n,allDay:s,onAllDayChange:x,selectedKeys:M,onSelectionChange:Q,onDropItem:ce})}),t.jsx(Xi,{initial:!1,children:D&&p&&de?t.jsx(Un.div,{className:"h-full flex-none overflow-hidden",initial:{width:0},animate:{width:388},exit:{width:0},transition:I,children:t.jsx(Un.div,{className:"h-full w-[388px] pl-2",initial:{x:40,opacity:0},animate:{x:0,opacity:1},exit:{x:40,opacity:0},transition:I,children:D})},"planner"):null})]}),D&&!de?t.jsx(ii,{open:p,onOpenChange:f,children:t.jsxs(li,{side:"right",className:"w-[380px] p-2 sm:max-w-[380px]",children:[t.jsx(ci,{className:"sr-only",children:"Planner"}),D]})}):null]})})]})]})}export{Lm as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.