@college-africa/chat-ui 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,8 @@ export interface MessageInputProps {
8
8
  placeholder?: string;
9
9
  /** Disabled state */
10
10
  disabled?: boolean;
11
+ /** Reason why input is disabled (displayed to user) */
12
+ disableReason?: string;
11
13
  }
12
14
  /**
13
15
  * MessageInput component
package/dist/index.js CHANGED
@@ -28,4 +28,4 @@ export default theme;`}function fr(e){return typeof e==`number`?`${(e*100).toFix
28
28
  `))}t[r]={}}}};Object.keys(m.components).forEach(e=>{let n=m.components[e].styleOverrides;n&&e.startsWith(`Mui`)&&t(n,e)})}return m.unstable_sxConfig={...Qe,...u?.unstable_sxConfig},m.unstable_sx=function(e){return nt({sx:e,theme:this})},m.toRuntimeSource=dr,mr(m),m}function gr(e){let t;return t=e<1?5.11916*e**2:4.5*Math.log(e+1)+2,Math.round(t*10)/1e3}var _r=[...Array(25)].map((e,t)=>{if(t===0)return`none`;let n=gr(t);return`linear-gradient(rgba(255 255 255 / ${n}), rgba(255 255 255 / ${n}))`});function vr(e){return{inputPlaceholder:e===`dark`?.5:.42,inputUnderline:e===`dark`?.7:.42,switchTrackDisabled:e===`dark`?.2:.12,switchTrack:e===`dark`?.3:.38}}function yr(e){return e===`dark`?_r:[]}function br(e){let{palette:t={mode:`light`},opacity:n,overlays:r,colorSpace:i,...a}=e,o=qn({...t,colorSpace:i});return{palette:o,opacity:{...vr(o.mode),...n},overlays:r||yr(o.mode),...a}}function xr(e){return!!e[0].match(/(cssVarPrefix|colorSchemeSelector|modularCssLayers|rootSelector|typography|mixins|breakpoints|direction|transitions)/)||!!e[0].match(/sxConfig$/)||e[0]===`palette`&&!!e[1]?.match(/(mode|contrastThreshold|tonalOffset)/)}var Sr=e=>[...[...Array(25)].map((t,n)=>`--${e?`${e}-`:``}overlays-${n}`),`--${e?`${e}-`:``}palette-AppBar-darkBg`,`--${e?`${e}-`:``}palette-AppBar-darkColor`],Cr=e=>(t,n)=>{let r=e.rootSelector||`:root`,i=e.colorSchemeSelector,a=i;if(i===`class`&&(a=`.%s`),i===`data`&&(a=`[data-%s]`),i?.startsWith(`data-`)&&!i.includes(`%s`)&&(a=`[${i}="%s"]`),e.defaultColorScheme===t){if(t===`dark`){let i={};return Sr(e.cssVarPrefix).forEach(e=>{i[e]=n[e],delete n[e]}),a===`media`?{[r]:n,"@media (prefers-color-scheme: dark)":{[r]:i}}:a?{[a.replace(`%s`,t)]:i,[`${r}, ${a.replace(`%s`,t)}`]:n}:{[r]:{...n,...i}}}if(a&&a!==`media`)return`${r}, ${a.replace(`%s`,String(t))}`}else if(t){if(a===`media`)return{[`@media (prefers-color-scheme: ${String(t)})`]:{[r]:n}};if(a)return a.replace(`%s`,String(t))}return r};function wr(e,t){t.forEach(t=>{e[t]||(e[t]={})})}function G(e,t,n){!e[t]&&n&&(e[t]=n)}function Tr(e){return typeof e!=`string`||!e.startsWith(`hsl`)?e:rn(e)}function Er(e,t){`${t}Channel`in e||(e[`${t}Channel`]=tn(Tr(e[t]),`MUI: Can't create \`palette.${t}Channel\` because \`palette.${t}\` is not one of these formats: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().
29
29
  To suppress this warning, you need to explicitly provide the \`palette.${t}Channel\` as a string (in rgb format, for example "12 12 12") or undefined if you want to remove the channel token.`))}function Dr(e){return typeof e==`number`?`${e}px`:typeof e==`string`||typeof e==`function`||Array.isArray(e)?e:`8px`}var K=e=>{try{return e()}catch{}},Or=(e=`mui`)=>yn(e);function kr(e,t,n,r,i){if(!n)return;n=n===!0?{}:n;let a=i===`dark`?`dark`:`light`;if(!r){t[i]=br({...n,palette:{mode:a,...n?.palette},colorSpace:e});return}let{palette:o,...s}=hr({...r,palette:{mode:a,...n?.palette},colorSpace:e});return t[i]={...n,palette:o,opacity:{...vr(a),...n?.opacity},overlays:n?.overlays||yr(a)},s}function Ar(e={},...t){let{colorSchemes:n={light:!0},defaultColorScheme:r,disableCssColorScheme:i=!1,cssVarPrefix:a=`mui`,nativeColor:o=!1,shouldSkipGeneratingVar:s=xr,colorSchemeSelector:c=n.light&&n.dark?`media`:void 0,rootSelector:l=`:root`,...u}=e,d=Object.keys(n)[0],p=r||(n.light&&d!==`light`?`light`:d),m=Or(a),{[p]:h,light:g,dark:_,...v}=n,y={...v},b=h;if((p===`dark`&&!(`dark`in n)||p===`light`&&!(`light`in n))&&(b=!0),!b)throw Error(process.env.NODE_ENV===`production`?f(21,p):`MUI: The \`colorSchemes.${p}\` option is either missing or invalid.`);let x;o&&(x=`oklch`);let S=kr(x,y,b,u,p);g&&!y.light&&kr(x,y,g,void 0,`light`),_&&!y.dark&&kr(x,y,_,void 0,`dark`);let C={defaultColorScheme:p,...S,cssVarPrefix:a,colorSchemeSelector:c,rootSelector:l,getCssVar:m,colorSchemes:y,font:{...Jn(S.typography),...S.font},spacing:Dr(u.spacing)};Object.keys(C.colorSchemes).forEach(e=>{let t=C.colorSchemes[e].palette,n=e=>{let n=e.split(`-`),r=n[1],i=n[2];return m(e,t[r][i])};t.mode===`light`&&(G(t.common,`background`,`#fff`),G(t.common,`onBackground`,`#000`)),t.mode===`dark`&&(G(t.common,`background`,`#000`),G(t.common,`onBackground`,`#fff`));function r(e,t,n){if(x){let r;return e===cn&&(r=`transparent ${((1-n)*100).toFixed(0)}%`),e===H&&(r=`#000 ${(n*100).toFixed(0)}%`),e===U&&(r=`#fff ${(n*100).toFixed(0)}%`),`color-mix(in ${x}, ${t}, ${r})`}return e(t,n)}if(wr(t,[`Alert`,`AppBar`,`Avatar`,`Button`,`Chip`,`FilledInput`,`LinearProgress`,`Skeleton`,`Slider`,`SnackbarContent`,`SpeedDialAction`,`StepConnector`,`StepContent`,`Switch`,`TableCell`,`Tooltip`]),t.mode===`light`){G(t.Alert,`errorColor`,r(H,o?m(`palette-error-light`):t.error.light,.6)),G(t.Alert,`infoColor`,r(H,o?m(`palette-info-light`):t.info.light,.6)),G(t.Alert,`successColor`,r(H,o?m(`palette-success-light`):t.success.light,.6)),G(t.Alert,`warningColor`,r(H,o?m(`palette-warning-light`):t.warning.light,.6)),G(t.Alert,`errorFilledBg`,n(`palette-error-main`)),G(t.Alert,`infoFilledBg`,n(`palette-info-main`)),G(t.Alert,`successFilledBg`,n(`palette-success-main`)),G(t.Alert,`warningFilledBg`,n(`palette-warning-main`)),G(t.Alert,`errorFilledColor`,K(()=>t.getContrastText(t.error.main))),G(t.Alert,`infoFilledColor`,K(()=>t.getContrastText(t.info.main))),G(t.Alert,`successFilledColor`,K(()=>t.getContrastText(t.success.main))),G(t.Alert,`warningFilledColor`,K(()=>t.getContrastText(t.warning.main))),G(t.Alert,`errorStandardBg`,r(U,o?m(`palette-error-light`):t.error.light,.9)),G(t.Alert,`infoStandardBg`,r(U,o?m(`palette-info-light`):t.info.light,.9)),G(t.Alert,`successStandardBg`,r(U,o?m(`palette-success-light`):t.success.light,.9)),G(t.Alert,`warningStandardBg`,r(U,o?m(`palette-warning-light`):t.warning.light,.9)),G(t.Alert,`errorIconColor`,n(`palette-error-main`)),G(t.Alert,`infoIconColor`,n(`palette-info-main`)),G(t.Alert,`successIconColor`,n(`palette-success-main`)),G(t.Alert,`warningIconColor`,n(`palette-warning-main`)),G(t.AppBar,`defaultBg`,n(`palette-grey-100`)),G(t.Avatar,`defaultBg`,n(`palette-grey-400`)),G(t.Button,`inheritContainedBg`,n(`palette-grey-300`)),G(t.Button,`inheritContainedHoverBg`,n(`palette-grey-A100`)),G(t.Chip,`defaultBorder`,n(`palette-grey-400`)),G(t.Chip,`defaultAvatarColor`,n(`palette-grey-700`)),G(t.Chip,`defaultIconColor`,n(`palette-grey-700`)),G(t.FilledInput,`bg`,`rgba(0, 0, 0, 0.06)`),G(t.FilledInput,`hoverBg`,`rgba(0, 0, 0, 0.09)`),G(t.FilledInput,`disabledBg`,`rgba(0, 0, 0, 0.12)`),G(t.LinearProgress,`primaryBg`,r(U,o?m(`palette-primary-main`):t.primary.main,.62)),G(t.LinearProgress,`secondaryBg`,r(U,o?m(`palette-secondary-main`):t.secondary.main,.62)),G(t.LinearProgress,`errorBg`,r(U,o?m(`palette-error-main`):t.error.main,.62)),G(t.LinearProgress,`infoBg`,r(U,o?m(`palette-info-main`):t.info.main,.62)),G(t.LinearProgress,`successBg`,r(U,o?m(`palette-success-main`):t.success.main,.62)),G(t.LinearProgress,`warningBg`,r(U,o?m(`palette-warning-light`):t.warning.main,.62)),G(t.Skeleton,`bg`,x?r(cn,o?m(`palette-text-primary`):t.text.primary,.11):`rgba(${n(`palette-text-primaryChannel`)} / 0.11)`),G(t.Slider,`primaryTrack`,r(U,o?m(`palette-primary-main`):t.primary.main,.62)),G(t.Slider,`secondaryTrack`,r(U,o?m(`palette-secondary-main`):t.secondary.main,.62)),G(t.Slider,`errorTrack`,r(U,o?m(`palette-error-main`):t.error.main,.62)),G(t.Slider,`infoTrack`,r(U,o?m(`palette-info-main`):t.info.main,.62)),G(t.Slider,`successTrack`,r(U,o?m(`palette-success-main`):t.success.main,.62)),G(t.Slider,`warningTrack`,r(U,o?m(`palette-warning-main`):t.warning.main,.62));let e=x?r(H,o?m(`palette-background-default`):t.background.default,.6825):fn(t.background.default,.8);G(t.SnackbarContent,`bg`,e),G(t.SnackbarContent,`color`,K(()=>x?Ln.text.primary:t.getContrastText(e))),G(t.SpeedDialAction,`fabHoverBg`,fn(t.background.paper,.15)),G(t.StepConnector,`border`,n(`palette-grey-400`)),G(t.StepContent,`border`,n(`palette-grey-400`)),G(t.Switch,`defaultColor`,n(`palette-common-white`)),G(t.Switch,`defaultDisabledColor`,n(`palette-grey-100`)),G(t.Switch,`primaryDisabledColor`,r(U,o?m(`palette-primary-main`):t.primary.main,.62)),G(t.Switch,`secondaryDisabledColor`,r(U,o?m(`palette-secondary-main`):t.secondary.main,.62)),G(t.Switch,`errorDisabledColor`,r(U,o?m(`palette-error-main`):t.error.main,.62)),G(t.Switch,`infoDisabledColor`,r(U,o?m(`palette-info-main`):t.info.main,.62)),G(t.Switch,`successDisabledColor`,r(U,o?m(`palette-success-main`):t.success.main,.62)),G(t.Switch,`warningDisabledColor`,r(U,o?m(`palette-warning-main`):t.warning.main,.62)),G(t.TableCell,`border`,r(U,cn(o?m(`palette-divider`):t.divider,1),.88)),G(t.Tooltip,`bg`,r(cn,o?m(`palette-grey-700`):t.grey[700],.92))}if(t.mode===`dark`){G(t.Alert,`errorColor`,r(U,o?m(`palette-error-light`):t.error.light,.6)),G(t.Alert,`infoColor`,r(U,o?m(`palette-info-light`):t.info.light,.6)),G(t.Alert,`successColor`,r(U,o?m(`palette-success-light`):t.success.light,.6)),G(t.Alert,`warningColor`,r(U,o?m(`palette-warning-light`):t.warning.light,.6)),G(t.Alert,`errorFilledBg`,n(`palette-error-dark`)),G(t.Alert,`infoFilledBg`,n(`palette-info-dark`)),G(t.Alert,`successFilledBg`,n(`palette-success-dark`)),G(t.Alert,`warningFilledBg`,n(`palette-warning-dark`)),G(t.Alert,`errorFilledColor`,K(()=>t.getContrastText(t.error.dark))),G(t.Alert,`infoFilledColor`,K(()=>t.getContrastText(t.info.dark))),G(t.Alert,`successFilledColor`,K(()=>t.getContrastText(t.success.dark))),G(t.Alert,`warningFilledColor`,K(()=>t.getContrastText(t.warning.dark))),G(t.Alert,`errorStandardBg`,r(H,o?m(`palette-error-light`):t.error.light,.9)),G(t.Alert,`infoStandardBg`,r(H,o?m(`palette-info-light`):t.info.light,.9)),G(t.Alert,`successStandardBg`,r(H,o?m(`palette-success-light`):t.success.light,.9)),G(t.Alert,`warningStandardBg`,r(H,o?m(`palette-warning-light`):t.warning.light,.9)),G(t.Alert,`errorIconColor`,n(`palette-error-main`)),G(t.Alert,`infoIconColor`,n(`palette-info-main`)),G(t.Alert,`successIconColor`,n(`palette-success-main`)),G(t.Alert,`warningIconColor`,n(`palette-warning-main`)),G(t.AppBar,`defaultBg`,n(`palette-grey-900`)),G(t.AppBar,`darkBg`,n(`palette-background-paper`)),G(t.AppBar,`darkColor`,n(`palette-text-primary`)),G(t.Avatar,`defaultBg`,n(`palette-grey-600`)),G(t.Button,`inheritContainedBg`,n(`palette-grey-800`)),G(t.Button,`inheritContainedHoverBg`,n(`palette-grey-700`)),G(t.Chip,`defaultBorder`,n(`palette-grey-700`)),G(t.Chip,`defaultAvatarColor`,n(`palette-grey-300`)),G(t.Chip,`defaultIconColor`,n(`palette-grey-300`)),G(t.FilledInput,`bg`,`rgba(255, 255, 255, 0.09)`),G(t.FilledInput,`hoverBg`,`rgba(255, 255, 255, 0.13)`),G(t.FilledInput,`disabledBg`,`rgba(255, 255, 255, 0.12)`),G(t.LinearProgress,`primaryBg`,r(H,o?m(`palette-primary-main`):t.primary.main,.5)),G(t.LinearProgress,`secondaryBg`,r(H,o?m(`palette-secondary-main`):t.secondary.main,.5)),G(t.LinearProgress,`errorBg`,r(H,o?m(`palette-error-main`):t.error.main,.5)),G(t.LinearProgress,`infoBg`,r(H,o?m(`palette-info-main`):t.info.main,.5)),G(t.LinearProgress,`successBg`,r(H,o?m(`palette-success-main`):t.success.main,.5)),G(t.LinearProgress,`warningBg`,r(H,o?m(`palette-warning-main`):t.warning.main,.5)),G(t.Skeleton,`bg`,x?r(cn,o?m(`palette-text-primary`):t.text.primary,.13):`rgba(${n(`palette-text-primaryChannel`)} / 0.13)`),G(t.Slider,`primaryTrack`,r(H,o?m(`palette-primary-main`):t.primary.main,.5)),G(t.Slider,`secondaryTrack`,r(H,o?m(`palette-secondary-main`):t.secondary.main,.5)),G(t.Slider,`errorTrack`,r(H,o?m(`palette-error-main`):t.error.main,.5)),G(t.Slider,`infoTrack`,r(H,o?m(`palette-info-main`):t.info.main,.5)),G(t.Slider,`successTrack`,r(H,o?m(`palette-success-main`):t.success.main,.5)),G(t.Slider,`warningTrack`,r(H,o?m(`palette-warning-light`):t.warning.main,.5));let e=x?r(U,o?m(`palette-background-default`):t.background.default,.985):fn(t.background.default,.98);G(t.SnackbarContent,`bg`,e),G(t.SnackbarContent,`color`,K(()=>x?Fn.text.primary:t.getContrastText(e))),G(t.SpeedDialAction,`fabHoverBg`,fn(t.background.paper,.15)),G(t.StepConnector,`border`,n(`palette-grey-600`)),G(t.StepContent,`border`,n(`palette-grey-600`)),G(t.Switch,`defaultColor`,n(`palette-grey-300`)),G(t.Switch,`defaultDisabledColor`,n(`palette-grey-600`)),G(t.Switch,`primaryDisabledColor`,r(H,o?m(`palette-primary-main`):t.primary.main,.55)),G(t.Switch,`secondaryDisabledColor`,r(H,o?m(`palette-secondary-main`):t.secondary.main,.55)),G(t.Switch,`errorDisabledColor`,r(H,o?m(`palette-error-main`):t.error.main,.55)),G(t.Switch,`infoDisabledColor`,r(H,o?m(`palette-info-main`):t.info.main,.55)),G(t.Switch,`successDisabledColor`,r(H,o?m(`palette-success-main`):t.success.main,.55)),G(t.Switch,`warningDisabledColor`,r(H,o?m(`palette-warning-light`):t.warning.main,.55)),G(t.TableCell,`border`,r(H,cn(o?m(`palette-divider`):t.divider,1),.68)),G(t.Tooltip,`bg`,r(cn,o?m(`palette-grey-700`):t.grey[700],.92))}o||(Er(t.background,`default`),Er(t.background,`paper`),Er(t.common,`background`),Er(t.common,`onBackground`),Er(t,`divider`)),Object.keys(t).forEach(e=>{let n=t[e];e!==`tonalOffset`&&!o&&n&&typeof n==`object`&&(n.main&&G(t[e],`mainChannel`,tn(Tr(n.main))),n.light&&G(t[e],`lightChannel`,tn(Tr(n.light))),n.dark&&G(t[e],`darkChannel`,tn(Tr(n.dark))),n.contrastText&&G(t[e],`contrastTextChannel`,tn(Tr(n.contrastText))),e===`text`&&(Er(t[e],`primary`),Er(t[e],`secondary`)),e===`action`&&(n.active&&Er(t[e],`active`),n.selected&&Er(t[e],`selected`)))})}),C=t.reduce((e,t)=>j(e,t),C);let w={prefix:a,disableCssColorScheme:i,shouldSkipGeneratingVar:s,getSelector:Cr(C),enableContrastVars:o},{vars:T,generateThemeVars:E,generateStyleSheets:ee}=wn(C,w);return C.vars=T,Object.entries(C.colorSchemes[C.defaultColorScheme]).forEach(([e,t])=>{C[e]=t}),C.generateThemeVars=E,C.generateStyleSheets=ee,C.generateSpacing=function(){return Et(u.spacing,Se(this))},C.getColorSchemeSelector=Tn(c),C.spacing=C.generateSpacing(),C.shouldSkipGeneratingVar=s,C.unstable_sxConfig={...Qe,...u?.unstable_sxConfig},C.unstable_sx=function(e){return nt({sx:e,theme:this})},C.toRuntimeSource=dr,C}function jr(e,t,n){e.colorSchemes&&n&&(e.colorSchemes[t]={...n!==!0&&n,palette:qn({...n===!0?{}:n.palette,mode:t})})}function Mr(e={},...t){let{palette:n,cssVariables:r=!1,colorSchemes:i=n?void 0:{light:!0},defaultColorScheme:a=n?.mode,...o}=e,s=a||`light`,c=i?.[s],l={...i,...n?{[s]:{...typeof c!=`boolean`&&c,palette:n}}:void 0};if(r===!1){if(!(`colorSchemes`in e))return hr(e,...t);let r=n;`palette`in e||l[s]&&(l[s]===!0?s===`dark`&&(r={mode:`dark`}):r=l[s].palette);let i=hr({...e,palette:r},...t);return i.defaultColorScheme=s,i.colorSchemes=l,i.palette.mode===`light`&&(i.colorSchemes.light={...l.light!==!0&&l.light,palette:i.palette},jr(i,`dark`,l.dark)),i.palette.mode===`dark`&&(i.colorSchemes.dark={...l.dark!==!0&&l.dark,palette:i.palette},jr(i,`light`,l.light)),i}return!n&&!(`light`in l)&&s===`light`&&(l.light=!0),Ar({...o,colorSchemes:l,defaultColorScheme:s,...typeof r!=`boolean`&&r},...t)}var Nr=Mr(),Pr=`$$material`;function Fr(e){return e!==`ownerState`&&e!==`theme`&&e!==`sx`&&e!==`as`}var Ir=Ut({themeId:Pr,defaultTheme:Nr,rootShouldForwardProp:e=>Fr(e)&&e!==`classes`}),Lr=vn;function Rr(e){return(0,i.jsx)(mn,{...e})}process.env.NODE_ENV!==`production`&&(Rr.propTypes={children:M.default.node,value:M.default.object.isRequired});function zr(e){return gn(e)}function Br(e){return At(`MuiSvgIcon`,e)}jt(`MuiSvgIcon`,[`root`,`colorPrimary`,`colorSecondary`,`colorAction`,`colorError`,`colorDisabled`,`fontSizeInherit`,`fontSizeSmall`,`fontSizeMedium`,`fontSizeLarge`]);var Vr=e=>{let{color:t,fontSize:n,classes:r}=e;return ee({root:[`root`,t!==`inherit`&&`color${m(t)}`,`fontSize${m(n)}`]},Br,r)},Hr=Ir(`svg`,{name:`MuiSvgIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color!==`inherit`&&t[`color${m(n.color)}`],t[`fontSize${m(n.fontSize)}`]]}})(Lr(({theme:e})=>({userSelect:`none`,width:`1em`,height:`1em`,display:`inline-block`,flexShrink:0,transition:e.transitions?.create?.(`fill`,{duration:(e.vars??e).transitions?.duration?.shorter}),variants:[{props:e=>!e.hasSvgAsChild,style:{fill:`currentColor`}},{props:{fontSize:`inherit`},style:{fontSize:`inherit`}},{props:{fontSize:`small`},style:{fontSize:e.typography?.pxToRem?.(20)||`1.25rem`}},{props:{fontSize:`medium`},style:{fontSize:e.typography?.pxToRem?.(24)||`1.5rem`}},{props:{fontSize:`large`},style:{fontSize:e.typography?.pxToRem?.(35)||`2.1875rem`}},...Object.entries((e.vars??e).palette).filter(([,e])=>e&&e.main).map(([t])=>({props:{color:t},style:{color:(e.vars??e).palette?.[t]?.main}})),{props:{color:`action`},style:{color:(e.vars??e).palette?.action?.active}},{props:{color:`disabled`},style:{color:(e.vars??e).palette?.action?.disabled}},{props:{color:`inherit`},style:{color:void 0}}]}))),Ur=t.forwardRef(function(e,n){let r=zr({props:e,name:`MuiSvgIcon`}),{children:a,className:o,color:s=`inherit`,component:c=`svg`,fontSize:l=`medium`,htmlColor:u,inheritViewBox:d=!1,titleAccess:f,viewBox:p=`0 0 24 24`,...m}=r,h=t.isValidElement(a)&&a.type===`svg`,g={...r,color:s,component:c,fontSize:l,instanceFontSize:e.fontSize,inheritViewBox:d,viewBox:p,hasSvgAsChild:h},_={};return d||(_.viewBox=p),(0,i.jsxs)(Hr,{as:c,className:E(Vr(g).root,o),focusable:`false`,color:u,"aria-hidden":f?void 0:!0,role:f?`img`:void 0,ref:n,..._,...m,...h&&a.props,ownerState:g,children:[h?a.props.children:a,f?(0,i.jsx)(`title`,{children:f}):null]})});process.env.NODE_ENV!==`production`&&(Ur.propTypes={children:M.default.node,classes:M.default.object,className:M.default.string,color:M.default.oneOfType([M.default.oneOf([`inherit`,`action`,`disabled`,`primary`,`secondary`,`error`,`info`,`success`,`warning`]),M.default.string]),component:M.default.elementType,fontSize:M.default.oneOfType([M.default.oneOf([`inherit`,`large`,`medium`,`small`]),M.default.string]),htmlColor:M.default.string,inheritViewBox:M.default.bool,shapeRendering:M.default.string,sx:M.default.oneOfType([M.default.arrayOf(M.default.oneOfType([M.default.func,M.default.object,M.default.bool])),M.default.func,M.default.object]),titleAccess:M.default.string,viewBox:M.default.string}),Ur.muiName=`SvgIcon`;function q(e,n){function r(t,r){return(0,i.jsx)(Ur,{"data-testid":process.env.NODE_ENV===`production`?void 0:`${n}Icon`,ref:r,...t,children:e})}return process.env.NODE_ENV!==`production`&&(r.displayName=`${n}Icon`),r.muiName=Ur.muiName,t.memo(t.forwardRef(r))}var Wr=q((0,i.jsx)(`path`,{d:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6z`}),`Add`),Gr=q((0,i.jsx)(`path`,{d:`M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20z`}),`ArrowBack`),Kr=q((0,i.jsx)(`path`,{d:`m7 10 5 5 5-5z`}),`ArrowDropDown`),qr=q((0,i.jsx)(`path`,{d:`M7.5 5.6 10 7 8.6 4.5 10 2 7.5 3.4 5 2l1.4 2.5L5 7zm12 9.8L17 14l1.4 2.5L17 19l2.5-1.4L22 19l-1.4-2.5L22 14zM22 2l-2.5 1.4L17 2l1.4 2.5L17 7l2.5-1.4L22 7l-1.4-2.5zm-7.63 5.29a.996.996 0 0 0-1.41 0L1.29 18.96c-.39.39-.39 1.02 0 1.41l2.34 2.34c.39.39 1.02.39 1.41 0L16.7 11.05c.39-.39.39-1.02 0-1.41zm-1.03 5.49-2.12-2.12 2.44-2.44 2.12 2.12z`}),`AutoFixHigh`),Jr=q((0,i.jsx)(`path`,{d:`M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`}),`Close`),Yr=q((0,i.jsx)(`path`,{d:`M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z`}),`Done`),Xr=q((0,i.jsx)(`path`,{d:`M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8`}),`ErrorOutline`),Zr=q((0,i.jsx)(`path`,{d:`M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5s-3 1.34-3 3 1.34 3 3 3m-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5 5 6.34 5 8s1.34 3 3 3m0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5m8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5`}),`Group`),Qr=q((0,i.jsx)(`path`,{d:`M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4`}),`Person`),$r=q((0,i.jsx)(`path`,{d:`M15 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m-9-2V7H4v3H1v2h3v3h2v-3h3v-2zm9 4c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4`}),`PersonAdd`),ei=q((0,i.jsx)(`path`,{d:`M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z`}),`Refresh`),ti=q([(0,i.jsx)(`path`,{d:`M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8`},`0`),(0,i.jsx)(`path`,{d:`M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z`},`1`)],`Schedule`),ni=q((0,i.jsx)(`path`,{d:`M2.01 21 23 12 2.01 3 2 10l15 2-15 2z`}),`Send`),ri=q((0,i.jsx)(`path`,{d:`M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5M12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5m0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3`}),`Visibility`),ii=q((0,i.jsx)(`path`,{d:`M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7M2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2m4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3z`}),`VisibilityOff`),ai=q((0,i.jsx)(`path`,{d:`M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7zm-4 4c-1.29-1.29-2.84-2.13-4.49-2.56l3.53 3.53zM2 3.05 5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24C7.81 10.89 6.27 11.73 5 13v.01L6.99 15c1.36-1.36 3.14-2.04 4.92-2.06L18.98 20l1.27-1.26L3.29 1.79zM9 17l3 3 3-3c-1.65-1.66-4.34-1.66-6 0`}),`WifiOff`);function oi(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4),i=Math.floor(n/36e5),a=Math.floor(n/864e5);return r<1?`now`:r<60?`${r}m`:i<24?`${i}h`:a<7?`${a}d`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}var si=n.default.memo(({conversation:e,displayName:t,selected:n,onClick:a,currentUser:o})=>{let s=!!e.group,c=e.unread_count,l=o?.role===`admin`;return(0,i.jsx)(r.ListItem,{disablePadding:!0,children:(0,i.jsxs)(r.ListItemButton,{selected:n,onClick:a,sx:{"&.Mui-selected":{backgroundColor:`action.selected`,"&:hover":{backgroundColor:`action.selected`}}},children:[(0,i.jsx)(r.ListItemAvatar,{children:(0,i.jsx)(r.Badge,{badgeContent:c,color:`primary`,overlap:`circular`,invisible:c===0,children:(0,i.jsx)(r.Avatar,{sx:{bgcolor:s?`primary.main`:`secondary.main`},children:s?(0,i.jsx)(Zr,{}):(0,i.jsx)(Qr,{})})})}),(0,i.jsx)(r.ListItemText,{primary:(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:`space-between`,alignItems:`center`,children:[(0,i.jsx)(r.Typography,{variant:`subtitle2`,noWrap:!0,sx:{fontWeight:c>0?600:400,flex:1},children:t}),(0,i.jsx)(r.Typography,{variant:`caption`,color:`text.secondary`,sx:{ml:1,flexShrink:0},children:oi(e.last_message_at)})]}),secondary:(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,noWrap:!0,sx:{fontWeight:c>0?500:400},children:e.message_count===0?l&&s?`View group`:`No messages yet`:`${e.message_count} message${e.message_count===1?``:`s`}`})})]})})}),ci=()=>(0,i.jsxs)(r.ListItem,{children:[(0,i.jsx)(r.ListItemAvatar,{children:(0,i.jsx)(r.Skeleton,{variant:`circular`,width:40,height:40})}),(0,i.jsx)(r.ListItemText,{primary:(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:`space-between`,children:[(0,i.jsx)(r.Skeleton,{variant:`text`,width:`60%`}),(0,i.jsx)(r.Skeleton,{variant:`text`,width:`15%`})]}),secondary:(0,i.jsx)(r.Skeleton,{variant:`text`,width:`80%`})})]}),li=function(e){return ui(e)&&!di(e)};function ui(e){return!!e&&typeof e==`object`}function di(e){var t=Object.prototype.toString.call(e);return t===`[object RegExp]`||t===`[object Date]`||pi(e)}var fi=typeof Symbol==`function`&&Symbol.for?Symbol.for(`react.element`):60103;function pi(e){return e.$$typeof===fi}function mi(e){return Array.isArray(e)?[]:{}}function hi(e,t){return t.clone!==!1&&t.isMergeableObject(e)?vi(mi(e),e,t):e}function gi(e,t,n){return e.concat(t).map(function(e){return hi(e,n)})}function _i(e,t,n){var r={};return n.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=hi(e[t],n)}),Object.keys(t).forEach(function(i){!n.isMergeableObject(t[i])||!e[i]?r[i]=hi(t[i],n):r[i]=vi(e[i],t[i],n)}),r}function vi(e,t,n){n||={},n.arrayMerge=n.arrayMerge||gi,n.isMergeableObject=n.isMergeableObject||li;var r=Array.isArray(t);return r===Array.isArray(e)?r?n.arrayMerge(e,t,n):_i(e,t,n):hi(t,n)}vi.all=function(e,t){if(!Array.isArray(e))throw Error(`first argument should be an array`);return e.reduce(function(e,n){return vi(e,n,t)},{})};var yi=vi,bi=typeof global==`object`&&global&&global.Object===Object&&global,xi=typeof self==`object`&&self&&self.Object===Object&&self,Si=bi||xi||Function(`return this`)(),Ci=Si.Symbol,wi=Object.prototype,Ti=wi.hasOwnProperty,Ei=wi.toString,Di=Ci?Ci.toStringTag:void 0;function Oi(e){var t=Ti.call(e,Di),n=e[Di];try{e[Di]=void 0;var r=!0}catch{}var i=Ei.call(e);return r&&(t?e[Di]=n:delete e[Di]),i}var ki=Object.prototype.toString;function Ai(e){return ki.call(e)}var ji=`[object Null]`,Mi=`[object Undefined]`,Ni=Ci?Ci.toStringTag:void 0;function Pi(e){return e==null?e===void 0?Mi:ji:Ni&&Ni in Object(e)?Oi(e):Ai(e)}function Fi(e,t){return function(n){return e(t(n))}}var Ii=Fi(Object.getPrototypeOf,Object);function Li(e){return typeof e==`object`&&!!e}var Ri=`[object Object]`,zi=Function.prototype,Bi=Object.prototype,Vi=zi.toString,Hi=Bi.hasOwnProperty,Ui=Vi.call(Object);function Wi(e){if(!Li(e)||Pi(e)!=Ri)return!1;var t=Ii(e);if(t===null)return!0;var n=Hi.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&Vi.call(n)==Ui}function Gi(){this.__data__=[],this.size=0}function Ki(e,t){return e===t||e!==e&&t!==t}function qi(e,t){for(var n=e.length;n--;)if(Ki(e[n][0],t))return n;return-1}var Ji=Array.prototype.splice;function Yi(e){var t=this.__data__,n=qi(t,e);return n<0?!1:(n==t.length-1?t.pop():Ji.call(t,n,1),--this.size,!0)}function Xi(e){var t=this.__data__,n=qi(t,e);return n<0?void 0:t[n][1]}function Zi(e){return qi(this.__data__,e)>-1}function Qi(e,t){var n=this.__data__,r=qi(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function $i(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}$i.prototype.clear=Gi,$i.prototype.delete=Yi,$i.prototype.get=Xi,$i.prototype.has=Zi,$i.prototype.set=Qi;function ea(){this.__data__=new $i,this.size=0}function ta(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function na(e){return this.__data__.get(e)}function ra(e){return this.__data__.has(e)}function ia(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}var aa=`[object AsyncFunction]`,oa=`[object Function]`,sa=`[object GeneratorFunction]`,ca=`[object Proxy]`;function la(e){if(!ia(e))return!1;var t=Pi(e);return t==oa||t==sa||t==aa||t==ca}var ua=Si[`__core-js_shared__`],da=function(){var e=/[^.]+$/.exec(ua&&ua.keys&&ua.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function fa(e){return!!da&&da in e}var pa=Function.prototype.toString;function ma(e){if(e!=null){try{return pa.call(e)}catch{}try{return e+``}catch{}}return``}var ha=/[\\^$.*+?()[\]{}|]/g,ga=/^\[object .+?Constructor\]$/,_a=Function.prototype,va=Object.prototype,ya=_a.toString,ba=va.hasOwnProperty,xa=RegExp(`^`+ya.call(ba).replace(ha,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function Sa(e){return!ia(e)||fa(e)?!1:(la(e)?xa:ga).test(ma(e))}function Ca(e,t){return e?.[t]}function wa(e,t){var n=Ca(e,t);return Sa(n)?n:void 0}var Ta=wa(Si,`Map`),Ea=wa(Object,`create`);function Da(){this.__data__=Ea?Ea(null):{},this.size=0}function Oa(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var ka=`__lodash_hash_undefined__`,Aa=Object.prototype.hasOwnProperty;function ja(e){var t=this.__data__;if(Ea){var n=t[e];return n===ka?void 0:n}return Aa.call(t,e)?t[e]:void 0}var Ma=Object.prototype.hasOwnProperty;function Na(e){var t=this.__data__;return Ea?t[e]!==void 0:Ma.call(t,e)}var Pa=`__lodash_hash_undefined__`;function Fa(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=Ea&&t===void 0?Pa:t,this}function Ia(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Ia.prototype.clear=Da,Ia.prototype.delete=Oa,Ia.prototype.get=ja,Ia.prototype.has=Na,Ia.prototype.set=Fa;function La(){this.size=0,this.__data__={hash:new Ia,map:new(Ta||$i),string:new Ia}}function Ra(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function za(e,t){var n=e.__data__;return Ra(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Ba(e){var t=za(this,e).delete(e);return this.size-=+!!t,t}function Va(e){return za(this,e).get(e)}function Ha(e){return za(this,e).has(e)}function Ua(e,t){var n=za(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function Wa(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Wa.prototype.clear=La,Wa.prototype.delete=Ba,Wa.prototype.get=Va,Wa.prototype.has=Ha,Wa.prototype.set=Ua;var Ga=200;function Ka(e,t){var n=this.__data__;if(n instanceof $i){var r=n.__data__;if(!Ta||r.length<Ga-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Wa(r)}return n.set(e,t),this.size=n.size,this}function qa(e){this.size=(this.__data__=new $i(e)).size}qa.prototype.clear=ea,qa.prototype.delete=ta,qa.prototype.get=na,qa.prototype.has=ra,qa.prototype.set=Ka;function Ja(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var Ya=function(){try{var e=wa(Object,`defineProperty`);return e({},``,{}),e}catch{}}();function Xa(e,t,n){t==`__proto__`&&Ya?Ya(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}var Za=Object.prototype.hasOwnProperty;function Qa(e,t,n){var r=e[t];(!(Za.call(e,t)&&Ki(r,n))||n===void 0&&!(t in e))&&Xa(e,t,n)}function $a(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?Xa(n,s,c):Qa(n,s,c)}return n}function eo(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var to=`[object Arguments]`;function no(e){return Li(e)&&Pi(e)==to}var ro=Object.prototype,io=ro.hasOwnProperty,ao=ro.propertyIsEnumerable,oo=no(function(){return arguments}())?no:function(e){return Li(e)&&io.call(e,`callee`)&&!ao.call(e,`callee`)},so=Array.isArray;function co(){return!1}var lo=typeof exports==`object`&&exports&&!exports.nodeType&&exports,uo=lo&&typeof module==`object`&&module&&!module.nodeType&&module,fo=uo&&uo.exports===lo?Si.Buffer:void 0,po=(fo?fo.isBuffer:void 0)||co,mo=9007199254740991,ho=/^(?:0|[1-9]\d*)$/;function go(e,t){var n=typeof e;return t??=mo,!!t&&(n==`number`||n!=`symbol`&&ho.test(e))&&e>-1&&e%1==0&&e<t}var _o=9007199254740991;function vo(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=_o}var yo=`[object Arguments]`,bo=`[object Array]`,xo=`[object Boolean]`,So=`[object Date]`,Co=`[object Error]`,wo=`[object Function]`,To=`[object Map]`,Eo=`[object Number]`,Do=`[object Object]`,Oo=`[object RegExp]`,ko=`[object Set]`,Ao=`[object String]`,jo=`[object WeakMap]`,Mo=`[object ArrayBuffer]`,No=`[object DataView]`,Po=`[object Float32Array]`,Fo=`[object Float64Array]`,Io=`[object Int8Array]`,Lo=`[object Int16Array]`,Ro=`[object Int32Array]`,zo=`[object Uint8Array]`,Bo=`[object Uint8ClampedArray]`,Vo=`[object Uint16Array]`,Ho=`[object Uint32Array]`,J={};J[Po]=J[Fo]=J[Io]=J[Lo]=J[Ro]=J[zo]=J[Bo]=J[Vo]=J[Ho]=!0,J[yo]=J[bo]=J[Mo]=J[xo]=J[No]=J[So]=J[Co]=J[wo]=J[To]=J[Eo]=J[Do]=J[Oo]=J[ko]=J[Ao]=J[jo]=!1;function Uo(e){return Li(e)&&vo(e.length)&&!!J[Pi(e)]}function Wo(e){return function(t){return e(t)}}var Go=typeof exports==`object`&&exports&&!exports.nodeType&&exports,Ko=Go&&typeof module==`object`&&module&&!module.nodeType&&module,qo=Ko&&Ko.exports===Go&&bi.process,Jo=function(){try{return Ko&&Ko.require&&Ko.require(`util`).types||qo&&qo.binding&&qo.binding(`util`)}catch{}}(),Yo=Jo&&Jo.isTypedArray,Xo=Yo?Wo(Yo):Uo,Zo=Object.prototype.hasOwnProperty;function Qo(e,t){var n=so(e),r=!n&&oo(e),i=!n&&!r&&po(e),a=!n&&!r&&!i&&Xo(e),o=n||r||i||a,s=o?eo(e.length,String):[],c=s.length;for(var l in e)(t||Zo.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||go(l,c)))&&s.push(l);return s}var $o=Object.prototype;function es(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||$o)}var ts=Fi(Object.keys,Object),ns=Object.prototype.hasOwnProperty;function rs(e){if(!es(e))return ts(e);var t=[];for(var n in Object(e))ns.call(e,n)&&n!=`constructor`&&t.push(n);return t}function is(e){return e!=null&&vo(e.length)&&!la(e)}function as(e){return is(e)?Qo(e):rs(e)}function os(e,t){return e&&$a(t,as(t),e)}function ss(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var cs=Object.prototype.hasOwnProperty;function ls(e){if(!ia(e))return ss(e);var t=es(e),n=[];for(var r in e)r==`constructor`&&(t||!cs.call(e,r))||n.push(r);return n}function us(e){return is(e)?Qo(e,!0):ls(e)}function ds(e,t){return e&&$a(t,us(t),e)}var fs=typeof exports==`object`&&exports&&!exports.nodeType&&exports,ps=fs&&typeof module==`object`&&module&&!module.nodeType&&module,ms=ps&&ps.exports===fs?Si.Buffer:void 0,hs=ms?ms.allocUnsafe:void 0;function gs(e,t){if(t)return e.slice();var n=e.length,r=hs?hs(n):new e.constructor(n);return e.copy(r),r}function _s(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function vs(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function ys(){return[]}var bs=Object.prototype.propertyIsEnumerable,xs=Object.getOwnPropertySymbols,Ss=xs?function(e){return e==null?[]:(e=Object(e),vs(xs(e),function(t){return bs.call(e,t)}))}:ys;function Cs(e,t){return $a(e,Ss(e),t)}function ws(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var Ts=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)ws(t,Ss(e)),e=Ii(e);return t}:ys;function Es(e,t){return $a(e,Ts(e),t)}function Ds(e,t,n){var r=t(e);return so(e)?r:ws(r,n(e))}function Os(e){return Ds(e,as,Ss)}function ks(e){return Ds(e,us,Ts)}var As=wa(Si,`DataView`),js=wa(Si,`Promise`),Ms=wa(Si,`Set`),Ns=wa(Si,`WeakMap`),Ps=`[object Map]`,Fs=`[object Object]`,Is=`[object Promise]`,Ls=`[object Set]`,Rs=`[object WeakMap]`,zs=`[object DataView]`,Bs=ma(As),Vs=ma(Ta),Hs=ma(js),Us=ma(Ms),Ws=ma(Ns),Gs=Pi;(As&&Gs(new As(new ArrayBuffer(1)))!=zs||Ta&&Gs(new Ta)!=Ps||js&&Gs(js.resolve())!=Is||Ms&&Gs(new Ms)!=Ls||Ns&&Gs(new Ns)!=Rs)&&(Gs=function(e){var t=Pi(e),n=t==Fs?e.constructor:void 0,r=n?ma(n):``;if(r)switch(r){case Bs:return zs;case Vs:return Ps;case Hs:return Is;case Us:return Ls;case Ws:return Rs}return t});var Ks=Gs,qs=Object.prototype.hasOwnProperty;function Js(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&qs.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var Ys=Si.Uint8Array;function Xs(e){var t=new e.constructor(e.byteLength);return new Ys(t).set(new Ys(e)),t}function Zs(e,t){var n=t?Xs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var Qs=/\w*$/;function $s(e){var t=new e.constructor(e.source,Qs.exec(e));return t.lastIndex=e.lastIndex,t}var ec=Ci?Ci.prototype:void 0,tc=ec?ec.valueOf:void 0;function nc(e){return tc?Object(tc.call(e)):{}}function rc(e,t){var n=t?Xs(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var ic=`[object Boolean]`,ac=`[object Date]`,oc=`[object Map]`,sc=`[object Number]`,cc=`[object RegExp]`,lc=`[object Set]`,uc=`[object String]`,dc=`[object Symbol]`,fc=`[object ArrayBuffer]`,pc=`[object DataView]`,mc=`[object Float32Array]`,hc=`[object Float64Array]`,gc=`[object Int8Array]`,_c=`[object Int16Array]`,vc=`[object Int32Array]`,yc=`[object Uint8Array]`,bc=`[object Uint8ClampedArray]`,xc=`[object Uint16Array]`,Sc=`[object Uint32Array]`;function Cc(e,t,n){var r=e.constructor;switch(t){case fc:return Xs(e);case ic:case ac:return new r(+e);case pc:return Zs(e,n);case mc:case hc:case gc:case _c:case vc:case yc:case bc:case xc:case Sc:return rc(e,n);case oc:return new r;case sc:case uc:return new r(e);case cc:return $s(e);case lc:return new r;case dc:return nc(e)}}var wc=Object.create,Tc=function(){function e(){}return function(t){if(!ia(t))return{};if(wc)return wc(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Ec(e){return typeof e.constructor==`function`&&!es(e)?Tc(Ii(e)):{}}var Dc=`[object Map]`;function Oc(e){return Li(e)&&Ks(e)==Dc}var kc=Jo&&Jo.isMap,Ac=kc?Wo(kc):Oc,jc=`[object Set]`;function Mc(e){return Li(e)&&Ks(e)==jc}var Nc=Jo&&Jo.isSet,Pc=Nc?Wo(Nc):Mc,Fc=1,Ic=2,Lc=4,Rc=`[object Arguments]`,zc=`[object Array]`,Bc=`[object Boolean]`,Vc=`[object Date]`,Hc=`[object Error]`,Uc=`[object Function]`,Wc=`[object GeneratorFunction]`,Gc=`[object Map]`,Kc=`[object Number]`,qc=`[object Object]`,Jc=`[object RegExp]`,Yc=`[object Set]`,Xc=`[object String]`,Zc=`[object Symbol]`,Qc=`[object WeakMap]`,$c=`[object ArrayBuffer]`,el=`[object DataView]`,tl=`[object Float32Array]`,nl=`[object Float64Array]`,rl=`[object Int8Array]`,il=`[object Int16Array]`,al=`[object Int32Array]`,ol=`[object Uint8Array]`,sl=`[object Uint8ClampedArray]`,cl=`[object Uint16Array]`,ll=`[object Uint32Array]`,Y={};Y[Rc]=Y[zc]=Y[$c]=Y[el]=Y[Bc]=Y[Vc]=Y[tl]=Y[nl]=Y[rl]=Y[il]=Y[al]=Y[Gc]=Y[Kc]=Y[qc]=Y[Jc]=Y[Yc]=Y[Xc]=Y[Zc]=Y[ol]=Y[sl]=Y[cl]=Y[ll]=!0,Y[Hc]=Y[Uc]=Y[Qc]=!1;function ul(e,t,n,r,i,a){var o,s=t&Fc,c=t&Ic,l=t&Lc;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!ia(e))return e;var u=so(e);if(u){if(o=Js(e),!s)return _s(e,o)}else{var d=Ks(e),f=d==Uc||d==Wc;if(po(e))return gs(e,s);if(d==qc||d==Rc||f&&!i){if(o=c||f?{}:Ec(e),!s)return c?Es(e,ds(o,e)):Cs(e,os(o,e))}else{if(!Y[d])return i?e:{};o=Cc(e,d,s)}}a||=new qa;var p=a.get(e);if(p)return p;a.set(e,o),Pc(e)?e.forEach(function(r){o.add(ul(r,t,n,r,e,a))}):Ac(e)&&e.forEach(function(r,i){o.set(i,ul(r,t,n,i,e,a))});var m=u?void 0:(l?c?ks:Os:c?us:as)(e);return Ja(m||e,function(r,i){m&&(i=r,r=e[i]),Qa(o,i,ul(r,t,n,i,e,a))}),o}var dl=1,fl=4;function pl(e){return ul(e,dl|fl)}var ml=e.g(((e,t)=>{var n=Array.isArray,r=Object.keys,i=Object.prototype.hasOwnProperty,a=typeof Element<`u`;function o(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var s=n(e),c=n(t),l,u,d;if(s&&c){if(u=e.length,u!=t.length)return!1;for(l=u;l--!==0;)if(!o(e[l],t[l]))return!1;return!0}if(s!=c)return!1;var f=e instanceof Date,p=t instanceof Date;if(f!=p)return!1;if(f&&p)return e.getTime()==t.getTime();var m=e instanceof RegExp,h=t instanceof RegExp;if(m!=h)return!1;if(m&&h)return e.toString()==t.toString();var g=r(e);if(u=g.length,u!==r(t).length)return!1;for(l=u;l--!==0;)if(!i.call(t,g[l]))return!1;if(a&&e instanceof Element&&t instanceof Element)return e===t;for(l=u;l--!==0;)if(d=g[l],!(d===`_owner`&&e.$$typeof)&&!o(e[d],t[d]))return!1;return!0}return e!==e&&t!==t}t.exports=function(e,t){try{return o(e,t)}catch(e){if(e.message&&e.message.match(/stack|recursion/i)||e.number===-2146828260)return console.warn(`Warning: react-fast-compare does not handle circular references.`,e.name,e.message),!1;throw e}}})),hl=e._(ml()),gl=process.env.NODE_ENV===`production`;function _l(e,t){if(!gl){if(e)return;var n=`Warning: `+t;typeof console<`u`&&console.warn(n);try{throw Error(n)}catch{}}}var vl=4;function yl(e){return ul(e,vl)}function bl(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var xl=`[object Symbol]`;function Sl(e){return typeof e==`symbol`||Li(e)&&Pi(e)==xl}var Cl=`Expected a function`;function wl(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(Cl);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(wl.Cache||Wa),n}wl.Cache=Wa;var Tl=500;function El(e){var t=wl(e,function(e){return n.size===Tl&&n.clear(),e}),n=t.cache;return t}var Dl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ol=/\\(\\)?/g,kl=El(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Dl,function(e,n,r,i){t.push(r?i.replace(Ol,`$1`):n||e)}),t}),Al=1/0;function jl(e){if(typeof e==`string`||Sl(e))return e;var t=e+``;return t==`0`&&1/e==-Al?`-0`:t}var Ml=1/0,Nl=Ci?Ci.prototype:void 0,Pl=Nl?Nl.toString:void 0;function Fl(e){if(typeof e==`string`)return e;if(so(e))return bl(e,Fl)+``;if(Sl(e))return Pl?Pl.call(e):``;var t=e+``;return t==`0`&&1/e==-Ml?`-0`:t}function Il(e){return e==null?``:Fl(e)}function Ll(e){return so(e)?bl(e,jl):Sl(e)?[e]:_s(kl(Il(e)))}var Rl=e.g((e=>{var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:switch(e=e.type,e){case l:case u:case i:case o:case a:case f:return e;default:switch(e&&=e.$$typeof,e){case c:case d:case h:case m:case s:return e;default:return t}}case r:return t}}}function x(e){return b(e)===u}e.AsyncMode=l,e.ConcurrentMode=u,e.ContextConsumer=c,e.ContextProvider=s,e.Element=n,e.ForwardRef=d,e.Fragment=i,e.Lazy=h,e.Memo=m,e.Portal=r,e.Profiler=o,e.StrictMode=a,e.Suspense=f,e.isAsyncMode=function(e){return x(e)||b(e)===l},e.isConcurrentMode=x,e.isContextConsumer=function(e){return b(e)===c},e.isContextProvider=function(e){return b(e)===s},e.isElement=function(e){return typeof e==`object`&&!!e&&e.$$typeof===n},e.isForwardRef=function(e){return b(e)===d},e.isFragment=function(e){return b(e)===i},e.isLazy=function(e){return b(e)===h},e.isMemo=function(e){return b(e)===m},e.isPortal=function(e){return b(e)===r},e.isProfiler=function(e){return b(e)===o},e.isStrictMode=function(e){return b(e)===a},e.isSuspense=function(e){return b(e)===f},e.isValidElementType=function(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)},e.typeOf=b})),zl=e.g((e=>{process.env.NODE_ENV!==`production`&&(function(){"use strict";var t=typeof Symbol==`function`&&Symbol.for,n=t?Symbol.for(`react.element`):60103,r=t?Symbol.for(`react.portal`):60106,i=t?Symbol.for(`react.fragment`):60107,a=t?Symbol.for(`react.strict_mode`):60108,o=t?Symbol.for(`react.profiler`):60114,s=t?Symbol.for(`react.provider`):60109,c=t?Symbol.for(`react.context`):60110,l=t?Symbol.for(`react.async_mode`):60111,u=t?Symbol.for(`react.concurrent_mode`):60111,d=t?Symbol.for(`react.forward_ref`):60112,f=t?Symbol.for(`react.suspense`):60113,p=t?Symbol.for(`react.suspense_list`):60120,m=t?Symbol.for(`react.memo`):60115,h=t?Symbol.for(`react.lazy`):60116,g=t?Symbol.for(`react.block`):60121,_=t?Symbol.for(`react.fundamental`):60117,v=t?Symbol.for(`react.responder`):60118,y=t?Symbol.for(`react.scope`):60119;function b(e){return typeof e==`string`||typeof e==`function`||e===i||e===u||e===o||e===a||e===f||e===p||typeof e==`object`&&!!e&&(e.$$typeof===h||e.$$typeof===m||e.$$typeof===s||e.$$typeof===c||e.$$typeof===d||e.$$typeof===_||e.$$typeof===v||e.$$typeof===y||e.$$typeof===g)}function x(e){if(typeof e==`object`&&e){var t=e.$$typeof;switch(t){case n:var p=e.type;switch(p){case l:case u:case i:case o:case a:case f:return p;default:var g=p&&p.$$typeof;switch(g){case c:case d:case h:case m:case s:return g;default:return t}}case r:return t}}}var S=l,C=u,w=c,T=s,E=n,ee=d,te=i,D=h,O=m,k=r,A=o,j=a,ne=f,M=!1;function N(e){return M||(M=!0,console.warn(`The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.`)),re(e)||x(e)===l}function re(e){return x(e)===u}function ie(e){return x(e)===c}function ae(e){return x(e)===s}function oe(e){return typeof e==`object`&&!!e&&e.$$typeof===n}function P(e){return x(e)===d}function se(e){return x(e)===i}function ce(e){return x(e)===h}function F(e){return x(e)===m}function le(e){return x(e)===r}function ue(e){return x(e)===o}function de(e){return x(e)===a}function fe(e){return x(e)===f}e.AsyncMode=S,e.ConcurrentMode=C,e.ContextConsumer=w,e.ContextProvider=T,e.Element=E,e.ForwardRef=ee,e.Fragment=te,e.Lazy=D,e.Memo=O,e.Portal=k,e.Profiler=A,e.StrictMode=j,e.Suspense=ne,e.isAsyncMode=N,e.isConcurrentMode=re,e.isContextConsumer=ie,e.isContextProvider=ae,e.isElement=oe,e.isForwardRef=P,e.isFragment=se,e.isLazy=ce,e.isMemo=F,e.isPortal=le,e.isProfiler=ue,e.isStrictMode=de,e.isSuspense=fe,e.isValidElementType=b,e.typeOf=x})()})),Bl=e.g(((e,t)=>{process.env.NODE_ENV===`production`?t.exports=Rl():t.exports=zl()}));e.g(((e,t)=>{var n=Bl(),r={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};s[n.ForwardRef]=a,s[n.Memo]=o;function c(e){return n.isMemo(e)?o:s[e.$$typeof]||r}var l=Object.defineProperty,u=Object.getOwnPropertyNames,d=Object.getOwnPropertySymbols,f=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,m=Object.prototype;function h(e,t,n){if(typeof t!=`string`){if(m){var r=p(t);r&&r!==m&&h(e,r,n)}var a=u(t);d&&(a=a.concat(d(t)));for(var o=c(e),s=c(t),g=0;g<a.length;++g){var _=a[g];if(!i[_]&&!(n&&n[_])&&!(s&&s[_])&&!(o&&o[_])){var v=f(t,_);try{l(e,_,v)}catch{}}}}return e}t.exports=h}))();function X(){return X=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(this,arguments)}function Vl(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function Hl(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Ul(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}var Wl=(0,t.createContext)(void 0);Wl.displayName=`FormikContext`,Wl.Provider,Wl.Consumer;function Gl(){var e=(0,t.useContext)(Wl);return!e&&(process.env.NODE_ENV===`production`?_l(!1):_l(!1,`Formik context is undefined, please verify you are calling useFormikContext() as child of a <Formik> component.`)),e}var Kl=function(e){return Array.isArray(e)&&e.length===0},Z=function(e){return typeof e==`function`},ql=function(e){return typeof e==`object`&&!!e},Jl=function(e){return String(Math.floor(Number(e)))===e},Yl=function(e){return Object.prototype.toString.call(e)===`[object String]`},Xl=function(e){return t.Children.count(e)===0},Zl=function(e){return ql(e)&&Z(e.then)};function Ql(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Q(e,t,n,r){r===void 0&&(r=0);for(var i=Ll(t);e&&r<i.length;)e=e[i[r++]];return r!==i.length&&!e||e===void 0?n:e}function $l(e,t,n){for(var r=yl(e),i=r,a=0,o=Ll(t);a<o.length-1;a++){var s=o[a],c=Q(e,o.slice(0,a+1));if(c&&(ql(c)||Array.isArray(c)))i=i[s]=yl(c);else{var l=o[a+1];i=i[s]=Jl(l)&&Number(l)>=0?[]:{}}}return(a===0?e:i)[o[a]]===n?e:(n===void 0?delete i[o[a]]:i[o[a]]=n,a===0&&n===void 0&&delete r[o[a]],r)}function eu(e,t,n,r){n===void 0&&(n=new WeakMap),r===void 0&&(r={});for(var i=0,a=Object.keys(e);i<a.length;i++){var o=a[i],s=e[o];ql(s)?n.get(s)||(n.set(s,!0),r[o]=Array.isArray(s)?[]:{},eu(s,t,n,r[o])):r[o]=t}return r}function tu(e,t){switch(t.type){case`SET_VALUES`:return X({},e,{values:t.payload});case`SET_TOUCHED`:return X({},e,{touched:t.payload});case`SET_ERRORS`:return(0,hl.default)(e.errors,t.payload)?e:X({},e,{errors:t.payload});case`SET_STATUS`:return X({},e,{status:t.payload});case`SET_ISSUBMITTING`:return X({},e,{isSubmitting:t.payload});case`SET_ISVALIDATING`:return X({},e,{isValidating:t.payload});case`SET_FIELD_VALUE`:return X({},e,{values:$l(e.values,t.payload.field,t.payload.value)});case`SET_FIELD_TOUCHED`:return X({},e,{touched:$l(e.touched,t.payload.field,t.payload.value)});case`SET_FIELD_ERROR`:return X({},e,{errors:$l(e.errors,t.payload.field,t.payload.value)});case`RESET_FORM`:return X({},e,t.payload);case`SET_FORMIK_STATE`:return t.payload(e);case`SUBMIT_ATTEMPT`:return X({},e,{touched:eu(e.values,!0),isSubmitting:!0,submitCount:e.submitCount+1});case`SUBMIT_FAILURE`:return X({},e,{isSubmitting:!1});case`SUBMIT_SUCCESS`:return X({},e,{isSubmitting:!1});default:return e}}var nu={},ru={};function iu(e){var n=e.validateOnChange,r=n===void 0?!0:n,i=e.validateOnBlur,a=i===void 0?!0:i,o=e.validateOnMount,s=o===void 0?!1:o,c=e.isInitialValid,l=e.enableReinitialize,u=l===void 0?!1:l,d=e.onSubmit,f=Hl(e,[`validateOnChange`,`validateOnBlur`,`validateOnMount`,`isInitialValid`,`enableReinitialize`,`onSubmit`]),p=X({validateOnChange:r,validateOnBlur:a,validateOnMount:s,onSubmit:d},f),m=(0,t.useRef)(p.initialValues),h=(0,t.useRef)(p.initialErrors||nu),g=(0,t.useRef)(p.initialTouched||ru),_=(0,t.useRef)(p.initialStatus),v=(0,t.useRef)(!1),y=(0,t.useRef)({});process.env.NODE_ENV!==`production`&&(0,t.useEffect)(function(){c!==void 0&&(process.env.NODE_ENV===`production`?_l(!1):_l(!1,`isInitialValid has been deprecated and will be removed in future versions of Formik. Please use initialErrors or validateOnMount instead.`))},[]),(0,t.useEffect)(function(){return v.current=!0,function(){v.current=!1}},[]);var b=(0,t.useState)(0)[1],x=(0,t.useRef)({values:pl(p.initialValues),errors:pl(p.initialErrors)||nu,touched:pl(p.initialTouched)||ru,status:pl(p.initialStatus),isSubmitting:!1,isValidating:!1,submitCount:0}),S=x.current,C=(0,t.useCallback)(function(e){var t=x.current;x.current=tu(t,e),t!==x.current&&b(function(e){return e+1})},[]),w=(0,t.useCallback)(function(e,t){return new Promise(function(n,r){var i=p.validate(e,t);i==null?n(nu):Zl(i)?i.then(function(e){n(e||nu)},function(e){process.env.NODE_ENV!==`production`&&console.warn(`Warning: An unhandled error was caught during validation in <Formik validate />`,e),r(e)}):n(i)})},[p.validate]),T=(0,t.useCallback)(function(e,t){var n=p.validationSchema,r=Z(n)?n(t):n,i=t&&r.validateAt?r.validateAt(t,e):su(e,r);return new Promise(function(e,t){i.then(function(){e(nu)},function(n){n.name===`ValidationError`?e(ou(n)):(process.env.NODE_ENV!==`production`&&console.warn(`Warning: An unhandled error was caught during validation in <Formik validationSchema />`,n),t(n))})})},[p.validationSchema]),E=(0,t.useCallback)(function(e,t){return new Promise(function(n){return n(y.current[e].validate(t))})},[]),ee=(0,t.useCallback)(function(e){var t=Object.keys(y.current).filter(function(e){return Z(y.current[e].validate)}),n=t.length>0?t.map(function(t){return E(t,Q(e,t))}):[Promise.resolve(`DO_NOT_DELETE_YOU_WILL_BE_FIRED`)];return Promise.all(n).then(function(e){return e.reduce(function(e,n,r){return n===`DO_NOT_DELETE_YOU_WILL_BE_FIRED`||n&&(e=$l(e,t[r],n)),e},{})})},[E]),te=(0,t.useCallback)(function(e){return Promise.all([ee(e),p.validationSchema?T(e):{},p.validate?w(e):{}]).then(function(e){var t=e[0],n=e[1],r=e[2];return yi.all([t,n,r],{arrayMerge:lu})})},[p.validate,p.validationSchema,ee,w,T]),D=$(function(e){return e===void 0&&(e=S.values),C({type:`SET_ISVALIDATING`,payload:!0}),te(e).then(function(e){return v.current&&(C({type:`SET_ISVALIDATING`,payload:!1}),C({type:`SET_ERRORS`,payload:e})),e})});(0,t.useEffect)(function(){s&&v.current===!0&&(0,hl.default)(m.current,p.initialValues)&&D(m.current)},[s,D]);var O=(0,t.useCallback)(function(e){var t=e&&e.values?e.values:m.current,n=e&&e.errors?e.errors:h.current?h.current:p.initialErrors||{},r=e&&e.touched?e.touched:g.current?g.current:p.initialTouched||{},i=e&&e.status?e.status:_.current?_.current:p.initialStatus;m.current=t,h.current=n,g.current=r,_.current=i;var a=function(){C({type:`RESET_FORM`,payload:{isSubmitting:!!e&&!!e.isSubmitting,errors:n,touched:r,status:i,values:t,isValidating:!!e&&!!e.isValidating,submitCount:e&&e.submitCount&&typeof e.submitCount==`number`?e.submitCount:0}})};if(p.onReset){var o=p.onReset(S.values,I);Zl(o)?o.then(a):a()}else a()},[p.initialErrors,p.initialStatus,p.initialTouched,p.onReset]);(0,t.useEffect)(function(){v.current===!0&&!(0,hl.default)(m.current,p.initialValues)&&u&&(m.current=p.initialValues,O(),s&&D(m.current))},[u,p.initialValues,O,s,D]),(0,t.useEffect)(function(){u&&v.current===!0&&!(0,hl.default)(h.current,p.initialErrors)&&(h.current=p.initialErrors||nu,C({type:`SET_ERRORS`,payload:p.initialErrors||nu}))},[u,p.initialErrors]),(0,t.useEffect)(function(){u&&v.current===!0&&!(0,hl.default)(g.current,p.initialTouched)&&(g.current=p.initialTouched||ru,C({type:`SET_TOUCHED`,payload:p.initialTouched||ru}))},[u,p.initialTouched]),(0,t.useEffect)(function(){u&&v.current===!0&&!(0,hl.default)(_.current,p.initialStatus)&&(_.current=p.initialStatus,C({type:`SET_STATUS`,payload:p.initialStatus}))},[u,p.initialStatus,p.initialTouched]);var k=$(function(e){if(y.current[e]&&Z(y.current[e].validate)){var t=Q(S.values,e),n=y.current[e].validate(t);return Zl(n)?(C({type:`SET_ISVALIDATING`,payload:!0}),n.then(function(e){return e}).then(function(t){C({type:`SET_FIELD_ERROR`,payload:{field:e,value:t}}),C({type:`SET_ISVALIDATING`,payload:!1})})):(C({type:`SET_FIELD_ERROR`,payload:{field:e,value:n}}),Promise.resolve(n))}else if(p.validationSchema)return C({type:`SET_ISVALIDATING`,payload:!0}),T(S.values,e).then(function(e){return e}).then(function(t){C({type:`SET_FIELD_ERROR`,payload:{field:e,value:Q(t,e)}}),C({type:`SET_ISVALIDATING`,payload:!1})});return Promise.resolve()}),A=(0,t.useCallback)(function(e,t){var n=t.validate;y.current[e]={validate:n}},[]),j=(0,t.useCallback)(function(e){delete y.current[e]},[]),ne=$(function(e,t){return C({type:`SET_TOUCHED`,payload:e}),(t===void 0?a:t)?D(S.values):Promise.resolve()}),M=(0,t.useCallback)(function(e){C({type:`SET_ERRORS`,payload:e})},[]),N=$(function(e,t){var n=Z(e)?e(S.values):e;return C({type:`SET_VALUES`,payload:n}),(t===void 0?r:t)?D(n):Promise.resolve()}),re=(0,t.useCallback)(function(e,t){C({type:`SET_FIELD_ERROR`,payload:{field:e,value:t}})},[]),ie=$(function(e,t,n){var i=Z(t)?t(Q(S.values,e)):t;return C({type:`SET_FIELD_VALUE`,payload:{field:e,value:i}}),(n===void 0?r:n)?D($l(S.values,e,i)):Promise.resolve()}),ae=(0,t.useCallback)(function(e,t){var n=t,r=e,i;if(!Yl(e)){e.persist&&e.persist();var a=e.target?e.target:e.currentTarget,o=a.type,s=a.name,c=a.id,l=a.value,u=a.checked,d=a.outerHTML,f=a.options,p=a.multiple;n=t||s||c,!n&&process.env.NODE_ENV!==`production`&&au({htmlContent:d,documentationAnchorLink:`handlechange-e-reactchangeeventany--void`,handlerName:`handleChange`}),r=/number|range/.test(o)?(i=parseFloat(l),isNaN(i)?``:i):/checkbox/.test(o)?du(Q(S.values,n),u,l):f&&p?uu(f):l}n&&ie(n,r)},[ie,S.values]),oe=$(function(e){if(Yl(e))return function(t){return ae(t,e)};ae(e)}),P=$(function(e,t,n){return t===void 0&&(t=!0),C({type:`SET_FIELD_TOUCHED`,payload:{field:e,value:t}}),(n===void 0?a:n)?D(S.values):Promise.resolve()}),se=(0,t.useCallback)(function(e,t){e.persist&&e.persist();var n=e.target,r=n.name,i=n.id,a=n.outerHTML,o=t||r||i;!o&&process.env.NODE_ENV!==`production`&&au({htmlContent:a,documentationAnchorLink:`handleblur-e-any--void`,handlerName:`handleBlur`}),P(o,!0)},[P]),ce=$(function(e){if(Yl(e))return function(t){return se(t,e)};se(e)}),F=(0,t.useCallback)(function(e){Z(e)?C({type:`SET_FORMIK_STATE`,payload:e}):C({type:`SET_FORMIK_STATE`,payload:function(){return e}})},[]),le=(0,t.useCallback)(function(e){C({type:`SET_STATUS`,payload:e})},[]),ue=(0,t.useCallback)(function(e){C({type:`SET_ISSUBMITTING`,payload:e})},[]),de=$(function(){return C({type:`SUBMIT_ATTEMPT`}),D().then(function(e){var t=e instanceof Error;if(!t&&Object.keys(e).length===0){var n;try{if(n=pe(),n===void 0)return}catch(e){throw e}return Promise.resolve(n).then(function(e){return v.current&&C({type:`SUBMIT_SUCCESS`}),e}).catch(function(e){if(v.current)throw C({type:`SUBMIT_FAILURE`}),e})}else if(v.current&&(C({type:`SUBMIT_FAILURE`}),t))throw e})}),fe=$(function(e){if(e&&e.preventDefault&&Z(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&Z(e.stopPropagation)&&e.stopPropagation(),process.env.NODE_ENV!==`production`&&typeof document<`u`){var t=Ql();t!==null&&t instanceof HTMLButtonElement&&!(t.attributes&&t.attributes.getNamedItem(`type`))&&(process.env.NODE_ENV===`production`?_l(!1):_l(!1,'You submitted a Formik form using a button with an unspecified `type` attribute. Most browsers default button elements to `type="submit"`. If this is not a submit button, please add `type="button"`.'))}de().catch(function(e){console.warn(`Warning: An unhandled error was caught from submitForm()`,e)})}),I={resetForm:O,validateForm:D,validateField:k,setErrors:M,setFieldError:re,setFieldTouched:P,setFieldValue:ie,setStatus:le,setSubmitting:ue,setTouched:ne,setValues:N,setFormikState:F,submitForm:de},pe=$(function(){return d(S.values,I)}),me=$(function(e){e&&e.preventDefault&&Z(e.preventDefault)&&e.preventDefault(),e&&e.stopPropagation&&Z(e.stopPropagation)&&e.stopPropagation(),O()}),he=(0,t.useCallback)(function(e){return{value:Q(S.values,e),error:Q(S.errors,e),touched:!!Q(S.touched,e),initialValue:Q(m.current,e),initialTouched:!!Q(g.current,e),initialError:Q(h.current,e)}},[S.errors,S.touched,S.values]),ge=(0,t.useCallback)(function(e){return{setValue:function(t,n){return ie(e,t,n)},setTouched:function(t,n){return P(e,t,n)},setError:function(t){return re(e,t)}}},[ie,P,re]),_e=(0,t.useCallback)(function(e){var t=ql(e),n=t?e.name:e,r=Q(S.values,n),i={name:n,value:r,onChange:oe,onBlur:ce};if(t){var a=e.type,o=e.value,s=e.as,c=e.multiple;a===`checkbox`?o===void 0?i.checked=!!r:(i.checked=!!(Array.isArray(r)&&~r.indexOf(o)),i.value=o):a===`radio`?(i.checked=r===o,i.value=o):s===`select`&&c&&(i.value=i.value||[],i.multiple=!0)}return i},[ce,oe,S.values]),ve=(0,t.useMemo)(function(){return!(0,hl.default)(m.current,S.values)},[m.current,S.values]),ye=(0,t.useMemo)(function(){return c===void 0||ve?S.errors&&Object.keys(S.errors).length===0:c!==!1&&Z(c)?c(p):c},[c,ve,S.errors,p]);return X({},S,{initialValues:m.current,initialErrors:h.current,initialTouched:g.current,initialStatus:_.current,handleBlur:ce,handleChange:oe,handleReset:me,handleSubmit:fe,resetForm:O,setErrors:M,setFormikState:F,setFieldTouched:P,setFieldValue:ie,setFieldError:re,setStatus:le,setSubmitting:ue,setTouched:ne,setValues:N,submitForm:de,validateForm:D,validateField:k,isValid:ye,dirty:ve,unregisterField:j,registerField:A,getFieldProps:_e,getFieldMeta:he,getFieldHelpers:ge,validateOnBlur:a,validateOnChange:r,validateOnMount:s})}function au(e){var t=e.htmlContent,n=e.documentationAnchorLink,r=e.handlerName;console.warn("Warning: Formik called `"+r+"`, but you forgot to pass an `id` or `name` attribute to your input:\n "+t+`
30
30
  Formik cannot determine which value to update. For more info see https://formik.org/docs/api/formik#`+n+`
31
- `)}function ou(e){var t={};if(e.inner){if(e.inner.length===0)return $l(t,e.path,e.message);for(var n=e.inner,r=Array.isArray(n),i=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(i>=n.length)break;a=n[i++]}else{if(i=n.next(),i.done)break;a=i.value}var o=a;Q(t,o.path)||(t=$l(t,o.path,o.message))}}return t}function su(e,t,n,r){n===void 0&&(n=!1);var i=cu(e);return t[n?`validateSync`:`validate`](i,{abortEarly:!1,context:r||i})}function cu(e){var t=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=String(n);Array.isArray(e[r])===!0?t[r]=e[r].map(function(e){return Array.isArray(e)===!0||Wi(e)?cu(e):e===``?void 0:e}):Wi(e[r])?t[r]=cu(e[r]):t[r]=e[r]===``?void 0:e[r]}return t}function lu(e,t,n){var r=e.slice();return t.forEach(function(t,i){r[i]===void 0?r[i]=n.clone!==!1&&n.isMergeableObject(t)?yi(Array.isArray(t)?[]:{},t,n):t:n.isMergeableObject(t)?r[i]=yi(e[i],t,n):e.indexOf(t)===-1&&r.push(t)}),r}function uu(e){return Array.from(e).filter(function(e){return e.selected}).map(function(e){return e.value})}function du(e,t,n){if(typeof e==`boolean`)return!!t;var r=[],i=!1,a=-1;if(Array.isArray(e))r=e,a=e.indexOf(n),i=a>=0;else if(!n||n==`true`||n==`false`)return!!t;return t&&n&&!i?r.concat(n):i?r.slice(0,a).concat(r.slice(a+1)):r}var fu=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?t.useLayoutEffect:t.useEffect;function $(e){var n=(0,t.useRef)(e);return fu(function(){n.current=e}),(0,t.useCallback)(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.current.apply(void 0,t)},[])}var pu=(0,t.forwardRef)(function(e,n){var r=e.action,i=Hl(e,[`action`]),a=r??`#`,o=Gl(),s=o.handleReset,c=o.handleSubmit;return(0,t.createElement)(`form`,X({onSubmit:c,ref:n,onReset:s,action:a},i))});pu.displayName=`Form`;var mu=function(e,t,n){var r=vu(e),i=r[t];return r.splice(t,1),r.splice(n,0,i),r},hu=function(e,t,n){var r=vu(e),i=r[t];return r[t]=r[n],r[n]=i,r},gu=function(e,t,n){var r=vu(e);return r.splice(t,0,n),r},_u=function(e,t,n){var r=vu(e);return r[t]=n,r},vu=function(e){if(!e)return[];if(Array.isArray(e))return[].concat(e);var t=Object.keys(e).map(function(e){return parseInt(e)}).reduce(function(e,t){return t>e?t:e},0);return Array.from(X({},e,{length:t+1}))},yu=function(e,t){var n=typeof e==`function`?e:t;return function(e){return Array.isArray(e)||ql(e)?n(vu(e)):e}},bu=function(e){Vl(n,e);function n(t){var n=e.call(this,t)||this;return n.updateArrayField=function(e,t,r){var i=n.props,a=i.name,o=i.formik.setFormikState;o(function(n){var i=yu(r,e),o=yu(t,e),s=$l(n.values,a,e(Q(n.values,a))),c=r?i(Q(n.errors,a)):void 0,l=t?o(Q(n.touched,a)):void 0;return Kl(c)&&(c=void 0),Kl(l)&&(l=void 0),X({},n,{values:s,errors:r?$l(n.errors,a,c):n.errors,touched:t?$l(n.touched,a,l):n.touched})})},n.push=function(e){return n.updateArrayField(function(t){return[].concat(vu(t),[pl(e)])},!1,!1)},n.handlePush=function(e){return function(){return n.push(e)}},n.swap=function(e,t){return n.updateArrayField(function(n){return hu(n,e,t)},!0,!0)},n.handleSwap=function(e,t){return function(){return n.swap(e,t)}},n.move=function(e,t){return n.updateArrayField(function(n){return mu(n,e,t)},!0,!0)},n.handleMove=function(e,t){return function(){return n.move(e,t)}},n.insert=function(e,t){return n.updateArrayField(function(n){return gu(n,e,t)},function(t){return gu(t,e,null)},function(t){return gu(t,e,null)})},n.handleInsert=function(e,t){return function(){return n.insert(e,t)}},n.replace=function(e,t){return n.updateArrayField(function(n){return _u(n,e,t)},!1,!1)},n.handleReplace=function(e,t){return function(){return n.replace(e,t)}},n.unshift=function(e){var t=-1;return n.updateArrayField(function(n){var r=n?[e].concat(n):[e];return t=r.length,r},function(e){return e?[null].concat(e):[null]},function(e){return e?[null].concat(e):[null]}),t},n.handleUnshift=function(e){return function(){return n.unshift(e)}},n.handleRemove=function(e){return function(){return n.remove(e)}},n.handlePop=function(){return function(){return n.pop()}},n.remove=n.remove.bind(Ul(n)),n.pop=n.pop.bind(Ul(n)),n}var r=n.prototype;return r.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!(0,hl.default)(Q(e.formik.values,e.name),Q(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},r.remove=function(e){var t;return this.updateArrayField(function(n){var r=n?vu(n):[];return t||=r[e],Z(r.splice)&&r.splice(e,1),Z(r.every)&&r.every(function(e){return e===void 0})?[]:r},!0,!0),t},r.pop=function(){var e;return this.updateArrayField(function(t){var n=t.slice();return e||=n&&n.pop&&n.pop(),n},!0,!0),e},r.render=function(){var e={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},n=this.props,r=n.component,i=n.render,a=n.children,o=n.name,s=n.formik,c=Hl(s,[`validate`,`validationSchema`]),l=X({},e,{form:c,name:o});return r?(0,t.createElement)(r,l):i?i(l):a?typeof a==`function`?a(l):Xl(a)?null:t.Children.only(a):null},n}(t.Component);bu.defaultProps={validateOnChange:!0};var xu=e.g(((e,t)=>{t.exports=Array.isArray})),Su=e.g(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),Cu=e.g(((e,t)=>{var n=Su(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),wu=e.g(((e,t)=>{t.exports=Cu().Symbol})),Tu=e.g(((e,t)=>{var n=wu(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),Eu=e.g(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),Du=e.g(((e,t)=>{var n=wu(),r=Tu(),i=Eu(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),Ou=e.g(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),ku=e.g(((e,t)=>{var n=Du(),r=Ou(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Au=e.g(((e,t)=>{var n=xu(),r=ku(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),ju=e.g(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Mu=e.g(((e,t)=>{var n=Du(),r=ju(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),Nu=e.g(((e,t)=>{t.exports=Cu()[`__core-js_shared__`]})),Pu=e.g(((e,t)=>{var n=Nu(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),Fu=e.g(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),Iu=e.g(((e,t)=>{var n=Mu(),r=Pu(),i=ju(),a=Fu(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),Lu=e.g(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),Ru=e.g(((e,t)=>{var n=Iu(),r=Lu();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),zu=e.g(((e,t)=>{t.exports=Ru()(Object,`create`)})),Bu=e.g(((e,t)=>{var n=zu();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),Vu=e.g(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),Hu=e.g(((e,t)=>{var n=zu(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),Uu=e.g(((e,t)=>{var n=zu(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),Wu=e.g(((e,t)=>{var n=zu(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),Gu=e.g(((e,t)=>{var n=Bu(),r=Vu(),i=Hu(),a=Uu(),o=Wu();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Ku=e.g(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),qu=e.g(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Ju=e.g(((e,t)=>{var n=qu();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),Yu=e.g(((e,t)=>{var n=Ju(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Xu=e.g(((e,t)=>{var n=Ju();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Zu=e.g(((e,t)=>{var n=Ju();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Qu=e.g(((e,t)=>{var n=Ju();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),$u=e.g(((e,t)=>{var n=Ku(),r=Yu(),i=Xu(),a=Zu(),o=Qu();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ed=e.g(((e,t)=>{t.exports=Ru()(Cu(),`Map`)})),td=e.g(((e,t)=>{var n=Gu(),r=$u(),i=ed();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),nd=e.g(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),rd=e.g(((e,t)=>{var n=nd();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),id=e.g(((e,t)=>{var n=rd();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),ad=e.g(((e,t)=>{var n=rd();function r(e){return n(this,e).get(e)}t.exports=r})),od=e.g(((e,t)=>{var n=rd();function r(e){return n(this,e).has(e)}t.exports=r})),sd=e.g(((e,t)=>{var n=rd();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),cd=e.g(((e,t)=>{var n=td(),r=id(),i=ad(),a=od(),o=sd();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ld=e.g(((e,t)=>{var n=cd(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),ud=e.g(((e,t)=>{var n=ld(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),dd=e.g(((e,t)=>{var n=ud(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),fd=e.g(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),pd=e.g(((e,t)=>{var n=wu(),r=fd(),i=xu(),a=ku(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),md=e.g(((e,t)=>{var n=pd();function r(e){return e==null?``:n(e)}t.exports=r})),hd=e.g(((e,t)=>{var n=xu(),r=Au(),i=dd(),a=md();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),gd=e.g(((e,t)=>{var n=ku(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),_d=e.g(((e,t)=>{var n=hd(),r=gd();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),vd=e.g(((e,t)=>{var n=_d();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),yd=e._(vd(),1),bd=(e=16)=>{let t={upper:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`,lower:`abcdefghijklmnopqrstuvwxyz`,numbers:`0123456789`,symbols:`!@%^&*()_+[]{}|;:,.<>?`},n=t.upper+t.lower+t.numbers+t.symbols,r=e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length],i=[r(t.upper),r(t.lower),r(t.numbers),r(t.symbols)];for(let t=4;t<e;t++)i.push(r(n));for(let e=i.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1),n=i[e];i[e]=i[t],i[t]=n}return i.join(``)},xd=({showPassword:e,onToggleVisibility:t,onGenerate:n})=>(0,i.jsxs)(r.InputAdornment,{position:`end`,children:[n&&(0,i.jsx)(r.Tooltip,{title:`Generate Password`,children:(0,i.jsx)(r.IconButton,{onClick:n,edge:`end`,size:`small`,sx:{opacity:.7},"aria-label":`generate password`,children:(0,i.jsx)(qr,{})})}),(0,i.jsx)(r.Tooltip,{title:e?`Hide password`:`Show password`,children:(0,i.jsx)(r.IconButton,{onClick:t,edge:`end`,size:`small`,sx:{opacity:.7},"aria-label":e?`hide password`:`show password`,children:e?(0,i.jsx)(ii,{}):(0,i.jsx)(ri,{})})})]}),Sd=({type:e,autoGenerate:t=!1,formik:r,name:i})=>{let[a,o]=(0,n.useState)(!1),s={},c=a?`text`:`password`;return e===`password`?(s.endAdornment=xd({showPassword:a,onToggleVisibility:()=>{o(!a)},onGenerate:t?()=>{if(!r||!i)return;let e=bd();r.setFieldValue(i,e),a||o(!0)}:void 0}),{inputType:c,inputProps:s}):{inputType:e,inputProps:s}},Cd=({helperText:e,errorText:t,formik:a,name:o,defaultValue:s,onChange:c,type:l,fullWidth:u=!0,autoGenerate:d=!1,...f})=>{let p=Sd({type:l,autoGenerate:d,formik:a,name:o}),m={},h=f.value??s;if((0,n.useEffect)(()=>{!a||!o||h===void 0||a.setFieldValue(o,h)},[h]),o&&a){a.touched[o]&&(t??=a.errors[o]);let e=(0,yd.default)(a.values,o,``);l===`date`&&(e=wd(e)),m={value:e??``,onBlur:()=>a.setFieldTouched(o),onChange:e=>{let t=e.target.value;l===`date`&&t&&(t=new Date(t)),a.setFieldValue(o,t||null),c?.(e)},slotProps:{...f.slotProps,input:{...f.InputProps,...f.slotProps?.input,...p.inputProps},inputLabel:l===`date`?{shrink:!0}:void 0}}}return(0,i.jsx)(r.TextField,{variant:`standard`,onChange:c,...f,...m,name:o,type:p.inputType,fullWidth:u,helperText:t||e,error:!!t})},wd=e=>{if(!e)return``;let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`},Td=({multiple:t=!1,formik:a,name:o,label:s=`Search users`,disabled:c=!1,error:l,helperText:u,value:d,onChange:f})=>{let[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)([]),[_,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(``),x=(0,n.useCallback)(async t=>{if(t.length<2){g([]);return}v(!0);try{g(await e.a().searchUsers({name:t}))}catch(e){console.error(`Failed to search users:`,e),g([])}finally{v(!1)}},[]),S=(0,n.useCallback)((e,t)=>{b(t),x(t)},[x]),C=()=>d===void 0?a&&o?a.values[o]:t?[]:null:d,w=(e,t)=>{f?f(t):a&&o&&a.setFieldValue(o,t)},T=()=>{a&&o&&a.setFieldTouched(o)},E=()=>{if(l)return` `;if(a&&o&&a.touched[o]&&a.errors[o])return a.errors[o]};return(0,i.jsx)(r.Autocomplete,{open:p,onOpen:()=>m(!0),onClose:()=>m(!1),multiple:t,options:h,value:C(),onChange:w,onBlur:T,onInputChange:S,getOptionLabel:e=>e.name,isOptionEqualToValue:(e,t)=>e.id===t.id,loading:_,noOptionsText:y.length<3?`Type at least 3 characters to search`:`No users found`,renderOption:(e,t)=>(0,n.createElement)(r.Box,{component:`li`,...e,key:t.id},(0,i.jsxs)(r.Box,{children:[(0,i.jsx)(r.Typography,{variant:`body1`,children:t.name}),(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:t.email})]})),renderInput:e=>(0,i.jsx)(r.TextField,{...e,label:s,disabled:c,error:!!E(),helperText:E()||u,InputProps:{...e.InputProps,endAdornment:(0,i.jsxs)(i.Fragment,{children:[_?(0,i.jsx)(r.CircularProgress,{size:20}):null,e.InputProps.endAdornment]})}})})},Ed=e.m({name:e.h().trim().required(`Group name is required`).min(2,`Group name must be at least 2 characters`).max(100,`Group name must be at most 100 characters`)}),Dd=({open:t,onClose:a,onSuccess:s,orgId:c})=>{let[l,u]=(0,n.useState)(null),d=iu({initialValues:{name:``,read_only:!1,members:[]},validationSchema:Ed,onSubmit:async(t,{setSubmitting:n,resetForm:r})=>{u(null);try{let n=e.a(),i=await n.createGroup(c,{name:t.name.trim(),read_only:t.read_only});t.members&&t.members.length>0&&await n.addGroupMembers(c,i.id,t.members.map(e=>({user:e.userId,role:e.role}))),r(),s?.(),a()}catch(e){u(o(e,`Failed to create group`))}n(!1)}}),f=e=>{let t=Array.isArray(e)?e:[];d.setFieldValue(`members`,t.map(e=>({userId:e.id,role:`member`,user:e})))},p=(e,t)=>{let n=d.values.members.map(n=>n.userId===e?{...n,role:t}:n);d.setFieldValue(`members`,n)},m=e=>{let t=d.values.members.filter(t=>t.userId!==e);d.setFieldValue(`members`,t)},h=()=>{d.resetForm(),a()};return(0,i.jsxs)(r.Dialog,{open:t,onClose:h,maxWidth:`sm`,fullWidth:!0,PaperProps:{component:`form`,onSubmit:d.handleSubmit},children:[(0,i.jsx)(r.DialogTitle,{children:`Create New Group`}),(0,i.jsx)(r.DialogContent,{children:(0,i.jsxs)(r.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:1},children:[l&&(0,i.jsx)(r.Alert,{severity:`error`,onClose:()=>u(null),children:l.message}),(0,i.jsx)(Cd,{label:`Group Name`,name:`name`,formik:d,required:!0,disabled:d.isSubmitting,placeholder:`e.g., Computer Science 101`}),(0,i.jsx)(r.FormControlLabel,{control:(0,i.jsx)(r.Switch,{name:`read_only`,checked:d.values.read_only,onChange:d.handleChange,disabled:d.isSubmitting}),label:`Read-only group (only moderators can post)`}),(0,i.jsx)(r.Divider,{sx:{my:2}}),(0,i.jsx)(r.Typography,{color:`warning.main`,fontWeight:500,children:`You cannot add members later. Only admins can join a group after it is created`}),(0,i.jsxs)(r.Box,{children:[(0,i.jsx)(r.Typography,{variant:`subtitle2`,gutterBottom:!0,children:`Add Members`}),(0,i.jsx)(Td,{multiple:!0,label:`Search users to add`,value:d.values.members.map(e=>e.user),onChange:f,disabled:d.isSubmitting})]}),d.values.members.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.Typography,{variant:`subtitle2`,gutterBottom:!0,children:`Selected Members`}),d.values.members.map(e=>(0,i.jsxs)(r.Box,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:1},children:[(0,i.jsx)(r.Box,{sx:{flex:1},children:e.user.name}),(0,i.jsxs)(r.Select,{value:e.role,onChange:t=>p(e.userId,t.target.value),size:`small`,disabled:d.isSubmitting,sx:{mr:2},children:[(0,i.jsx)(r.MenuItem,{value:`member`,children:`Member`}),(0,i.jsx)(r.MenuItem,{value:`moderator`,children:`Moderator`})]}),(0,i.jsx)(r.IconButton,{size:`small`,onClick:()=>m(e.userId),disabled:d.isSubmitting,color:`error`,children:(0,i.jsx)(Jr,{})})]},e.userId))]})]})}),(0,i.jsxs)(r.DialogActions,{sx:{p:3},children:[(0,i.jsx)(r.Button,{onClick:h,disabled:d.isSubmitting,children:`Cancel`}),(0,i.jsx)(r.Button,{type:`submit`,variant:`contained`,disabled:d.isSubmitting||!d.isValid,startIcon:d.isSubmitting&&(0,i.jsx)(r.CircularProgress,{size:16}),children:`Create Group`})]})]})},Od=async t=>{let n=await e.a().getGroups(t);return await e.d.groups.clear(),await e.d.groups.bulkPut(n),n};function kd(e,t,r){let i,a;typeof e==`function`?(i=t||[],a=r):(i=[],a=t);let o=n.default.useRef({hasResult:!1,result:a,error:null}),[s,c]=n.default.useReducer(e=>e+1,0),l=n.default.useMemo(()=>{let t=typeof e==`function`?e():e;if(!t||typeof t.subscribe!=`function`)throw TypeError(e===t?`Given argument to useObservable() was neither a valid observable nor a function.`:`Observable factory given to useObservable() did not return a valid observable.`);if(!o.current.hasResult&&typeof window<`u`&&(typeof t.hasValue!=`function`||t.hasValue()))if(typeof t.getValue==`function`)o.current.result=t.getValue(),o.current.hasResult=!0;else{let e=t.subscribe(e=>{o.current.result=e,o.current.hasResult=!0});typeof e==`function`?e():e.unsubscribe()}return t},i);if(n.default.useDebugValue(o.current.result),n.default.useEffect(()=>{let e=l.subscribe(e=>{let{current:t}=o;(t.error!==null||t.result!==e)&&(t.error=null,t.result=e,t.hasResult=!0,c())},e=>{let{current:t}=o;t.error!==e&&(t.error=e,c())});return typeof e==`function`?e:e.unsubscribe.bind(e)},i),o.current.error)throw o.current.error;return o.current.result}function Ad(t,n,r){return kd(()=>e.f.liveQuery(t),n||[],r)}typeof FinalizationRegistry<`u`&&new FinalizationRegistry(t=>{let n=e.f.DexieYProvider;n&&n.release(t)}),Reflect.get(n,`use`);var jd=({selectedConversation:t,currentUser:a,onConversationSelect:o})=>{let[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(),[d,f]=(0,n.useState)(!1),p=Ad(()=>e.d.summaries.toArray(),[t])||[],m=Ad(()=>e.d.groups.toArray(),[])||[],h=a?.role===`admin`||a?.role===`system`,g=(0,n.useCallback)(async()=>{c(!0),a?.org&&(await Promise.all([e.t({}),Od(a?.org)]).catch(e=>{u(e instanceof Error?e:Error(String(e)))}),c(!1))},[a?.org]);(0,n.useEffect)(()=>{g();let e=setInterval(g,3*6e4);return()=>clearInterval(e)},[g]);let[_,v]=(0,n.useState)({});(0,n.useEffect)(()=>{p.length>0&&a?.org&&(async()=>{if(!a?.org)return;let t=e.a(),n={};for(let e of p)try{if(e.user!==void 0&&!_[e.user]){let r=await t.getUser(e.user);n[e.user]=r.name}}catch(e){console.error(`Failed to load conversation name:`,e)}Object.keys(n).length>0&&v(e=>({...e,...n}))})()},[p,a?.org]);let y=e=>e.user===void 0?e.group===void 0?`Unknown`:m.find(t=>t.id===e.group)?.name||`Group ${e.group}`:_[e.user]||`User ${e.user}`,b=e=>t?e.group===void 0?e.user===void 0?!1:t.type===`dm`&&t.id===e.user:t.type===`group`&&t.id===e.group:!1,x=e=>{e.group===void 0?e.user!==void 0&&o({type:`dm`,id:e.user,name:y(e)}):o({type:`group`,id:e.group,name:y(e)})};return(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,height:`100%`,children:[(0,i.jsx)(r.AppBar,{position:`static`,elevation:0,sx:{backgroundColor:`background.default`,color:`text.primary`},children:(0,i.jsxs)(r.Toolbar,{children:[(0,i.jsx)(r.Typography,{variant:`h6`,component:`div`,sx:{flexGrow:1},children:`Messages`}),h&&(0,i.jsx)(r.Tooltip,{title:`Create Group`,children:(0,i.jsx)(r.IconButton,{color:`primary`,onClick:()=>f(!0),size:`small`,sx:{mr:-2},children:(0,i.jsx)(Wr,{})})})]})}),h&&a?.org&&(0,i.jsx)(Dd,{open:d,onClose:()=>f(!1),onSuccess:async()=>{await g()},orgId:a.org}),(0,i.jsx)(r.Box,{flex:1,overflow:`auto`,children:s&&!p.length?(0,i.jsx)(r.List,{disablePadding:!0,children:[1,2,3,4,5].map(e=>(0,i.jsx)(ci,{},e))}):l?(0,i.jsx)(r.Box,{p:2,children:(0,i.jsxs)(r.Alert,{severity:`error`,children:[`Failed to load conversations: `,l.message]})}):p.length===0&&m.length===0?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,p:2,children:(0,i.jsx)(r.Typography,{color:`text.secondary`,align:`center`,children:`No conversations yet`})}):(0,i.jsx)(r.List,{disablePadding:!0,children:(()=>{let e=new Set(p.filter(e=>e.group!==void 0).map(e=>e.group)),t=m.filter(t=>!e.has(t.id)).map(e=>({group:e.id,last_message_at:e.created_at,message_count:0,unread_count:0}));return[...[...p].sort((e,t)=>new Date(t.last_message_at).getTime()-new Date(e.last_message_at).getTime()),...t].map(e=>(0,i.jsx)(si,{conversation:e,displayName:y(e),selected:b(e),onClick:()=>x(e),currentUser:a},e.group===void 0?`user-${e.user}`:`group-${e.group}`))})()})})]})},Md=({displayName:e,type:t,subtitle:a,isConnected:o=!0,onBack:s,showJoinButton:c=!1,onJoin:l,joining:u=!1})=>{let d=t===`group`,[f,p]=(0,n.useState)(null),m=e=>{p(e.currentTarget)},h=()=>{p(null)},g=e=>{l(e),h()};return(0,i.jsx)(r.AppBar,{position:`static`,elevation:0,sx:{backgroundColor:`background.default`,color:`text.primary`},children:(0,i.jsxs)(r.Toolbar,{children:[s&&(0,i.jsx)(r.IconButton,{edge:`start`,color:`inherit`,onClick:s,sx:{mr:2,display:{xs:`flex`,sm:`flex`,md:`none`}},children:(0,i.jsx)(Gr,{})}),(0,i.jsx)(r.Avatar,{sx:{bgcolor:d?`primary.main`:`secondary.main`,mr:2},children:d?(0,i.jsx)(Zr,{}):(0,i.jsx)(Qr,{})}),(0,i.jsxs)(r.Box,{flex:1,children:[(0,i.jsx)(r.Typography,{variant:`h6`,component:`div`,noWrap:!0,children:e}),a&&(0,i.jsx)(r.Typography,{variant:`caption`,color:`inherit`,sx:{opacity:.7},children:a})]}),c&&d&&(0,i.jsxs)(r.Box,{sx:{display:`flex`,alignItems:`center`,mr:1},children:[(0,i.jsx)(r.Button,{variant:`contained`,color:`primary`,startIcon:(0,i.jsx)($r,{}),endIcon:(0,i.jsx)(Kr,{}),onClick:m,disabled:u,children:u?`Joining...`:`Join`}),(0,i.jsxs)(r.Menu,{anchorEl:f,open:!!f,onClose:h,children:[(0,i.jsx)(r.MenuItem,{onClick:()=>g(`member`),children:`Member`}),(0,i.jsx)(r.MenuItem,{onClick:()=>g(`moderator`),children:`Moderator`})]})]}),!o&&(0,i.jsx)(r.Chip,{icon:(0,i.jsx)(ai,{}),label:`Disconnected`,size:`small`,color:`warning`,sx:{ml:1}})]})})};function Nd(e){return(typeof e==`string`?new Date(e):e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0})}var Pd=n.default.memo(({message:t,isOwnMessage:n,senderName:a,showSenderName:o=!0,isFirstInGroup:s=!0,isLastInGroup:c=!0,status:l=`sent`})=>{let u=t.id.startsWith(`temp-`),d=()=>{if(!n||!c)return null;let e={fontSize:14,ml:.5,opacity:.7,verticalAlign:`middle`};return l===`failed`?(0,i.jsx)(Xr,{sx:{...e,color:`error.main`}}):l===`sending`||u?(0,i.jsx)(ti,{sx:e}):(0,i.jsx)(Yr,{sx:e})},f=(0,i.jsx)(r.Avatar,{sx:{width:32,height:32,fontSize:`0.875rem`,color:n?`primary.contrastText`:`secondary.contrastText`,bgcolor:n?`primary.main`:`secondary.main`,visibility:c?`visible`:`hidden`},children:e.l(a)});return(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-end`,mb:c?1:.25,gap:1,children:[!n&&f,(0,i.jsxs)(r.Paper,{elevation:1,sx:{maxWidth:`80%`,p:1.5,backgroundColor:n?`primary.main`:`background.paper`,color:n?`primary.contrastText`:`text.primary`,borderTopLeftRadius:n||!s?void 0:4,borderTopRightRadius:!n||!s?void 0:4,borderBottomLeftRadius:n||!c?void 0:4,borderBottomRightRadius:!n||!c?void 0:4},children:[!n&&o&&s&&(0,i.jsx)(r.Typography,{variant:`caption`,fontWeight:`bold`,display:`block`,mb:.5,children:a||`User ${t.sender}`}),(0,i.jsx)(r.Typography,{variant:`body1`,sx:{whiteSpace:`pre-wrap`},children:t.content}),c&&(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:`flex-end`,alignItems:`center`,mt:.5,children:[(0,i.jsx)(r.Typography,{variant:`caption`,color:n?`inherit`:`text.secondary`,sx:{opacity:.7},children:Nd(new Date(t.created_at))}),(0,i.jsx)(d,{})]})]}),n&&f]})}),Fd=({isOwnMessage:e=!1})=>(0,i.jsx)(r.Box,{display:`flex`,justifyContent:e?`flex-end`:`flex-start`,mb:1,children:(0,i.jsxs)(r.Box,{maxWidth:`70%`,children:[!e&&(0,i.jsx)(r.Skeleton,{variant:`text`,width:80,sx:{mb:.5}}),(0,i.jsx)(r.Skeleton,{variant:`rounded`,width:Math.random()*200+150,height:60,sx:{borderRadius:2,bgcolor:e?`primary.light`:`background.main`}})]})}),Id=({hasMore:e,loading:t,onLoadMore:a,threshold:o=1,rootMargin:s=`100px`})=>{let c=(0,n.useRef)(null),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!e||t)return;let n=c.current;if(n)return l.current=new IntersectionObserver(n=>{let[r]=n;r&&r.isIntersecting&&e&&!t&&a()},{threshold:o,rootMargin:s}),l.current.observe(n),()=>{l.current&&n&&(l.current.unobserve(n),l.current.disconnect())}},[e,t,a,o,s]),e?(0,i.jsx)(r.Box,{ref:c,display:`flex`,justifyContent:`center`,alignItems:`center`,py:2,children:t?(0,i.jsx)(r.CircularProgress,{size:24}):(0,i.jsx)(r.Typography,{variant:`caption`,color:`text.secondary`,children:`Scroll to load more`})}):null},Ld=(e,t,r)=>{(0,n.useEffect)(()=>((async()=>{await e()})(),r),t)};function Rd(e){let t=e.map(e=>Number(e.sender));return new Set(t)}function zd(t){let r=e.a(),[i,a]=(0,n.useState)(()=>new Map),o=(0,n.useCallback)(async()=>{if(!t.length)return i;try{let n=Rd(t),a=Array.from(n);if(console.log(`[names] size:`,n.size),!n.size)return i;let o=(await e.d.users.bulkGet(a)).filter(e=>!!e),s=new Map;if(o.forEach(e=>{s.set(e.id,e.name)}),n.size===o.length)return s;let c=a.filter(e=>!s.has(e)),l=await r.getUsers(c,{fields:[`id`,`name`]});await e.d.users.bulkPut(l);let u=s;return l.forEach(e=>u.set(e.id,e.name)),u}catch(e){console.error(`[useSenderNames] Failed to fetch users:`,e)}return i},[t,i]);return Ld(async()=>{a(await o())},[t]),i}var Bd=({messages:t,currentUserId:a,loading:o=!1,error:s=null,autoScroll:c=!0,hasMore:l=!1,loadingMore:u=!1,onLoadMore:d})=>{let f=(0,n.useRef)(null),p=(0,n.useRef)(null),m=(0,n.useRef)(0),h=(0,n.useRef)(!0),[g,_]=(0,n.useState)(c),v=zd(t),y=()=>{if(!p.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:n}=p.current;return t-e-n<100};return(0,n.useEffect)(()=>{t.length>0&&f.current&&(f.current.scrollIntoView({behavior:`auto`}),h.current=!0)},[]),(0,n.useEffect)(()=>{!u||!t.length||(p.current&&(m.current=p.current.scrollHeight),_(!1))},[u]),(0,n.useLayoutEffect)(()=>{if(t.length){if(g&&f.current&&h.current)f.current.scrollIntoView({behavior:`smooth`});else if(!g&&p.current&&m.current>0){let e=p.current.scrollHeight-m.current;p.current.scrollTop=p.current.scrollTop+e,m.current=0,_(!0)}}},[t.length,c]),o&&!t.length?(0,i.jsx)(r.Box,{flex:1,overflow:`auto`,p:2,children:[1,2,3,4,5].map(e=>(0,i.jsx)(Fd,{isOwnMessage:e%3==0},e))}):s&&!t.length?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,flex:1,p:2,children:(0,i.jsxs)(r.Alert,{severity:`error`,children:[(0,i.jsx)(`strong`,{children:`Failed to load messages`}),(0,i.jsx)(`br`,{}),s.message]})}):t.length===0?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,flex:1,children:(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:`No messages yet. Start the conversation!`})}):(0,i.jsxs)(r.Box,{ref:p,flex:1,overflow:`auto`,p:2,display:`flex`,flexDirection:`column`,onScroll:()=>{h.current=y()},children:[l&&d&&(0,i.jsx)(Id,{hasMore:l,loading:u,onLoadMore:d}),t.map((n,r)=>{let o=n.sender,s=n.sender===a,c=v.get(o),l=r>0?t[r-1]:null,u=r<t.length-1?t[r+1]:null,d=!l||!e.u(l,n);return(0,i.jsx)(Pd,{message:n,isOwnMessage:s,senderName:c,showSenderName:d,isFirstInGroup:d,isLastInGroup:!u||!e.u(n,u)},n.id)}),(0,i.jsx)(`div`,{ref:f})]})},Vd=({onSend:e,sending:t=!1,placeholder:a=`Type a message...`,disabled:o=!1})=>{let[s,c]=(0,n.useState)(``),l=(0,n.useRef)(null),u=()=>{let n=s.trim();n&&!t&&!o&&(e(n),c(``),setTimeout(()=>{l.current?.querySelector(`textarea`)?.focus()},300))};return(0,i.jsxs)(r.Box,{display:`flex`,gap:1,p:2,borderTop:1,borderColor:`divider`,children:[(0,i.jsx)(r.TextField,{ref:l,fullWidth:!0,multiline:!0,maxRows:4,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u())},placeholder:a,disabled:o||t,variant:`outlined`,size:`small`}),(0,i.jsx)(r.IconButton,{color:`primary`,onClick:u,disabled:!s.trim()||t||o,size:`large`,children:t?(0,i.jsx)(r.CircularProgress,{size:24}):(0,i.jsx)(ni,{})})]})};function Hd({conversation:t,limit:r=50}){let i=e.p(t),[a,o]=(0,n.useState)(!1),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)(),d=Ad(()=>e.d.messages.where(`conversationId`).equals(i).sortBy(`created_at`),[i])||[],f=Ad(()=>e.d.msgCursor.where(`id`).equals(i).first(),[i]);return Ld(async()=>{let n={limit:r};d.length&&(n.cursorType=`after`,n.cursorDatetime=d[d.length-1]?.created_at),o(!0),await e.c(t,n).catch(u),o(!1),await e.d.summaries.update(i,{unread_count:0})},[t,r]),console.log(`mw`,d.length),{messages:d,cursor:f,loading:a,error:l,loadMore:(0,n.useCallback)(async()=>{if(!(!f||s||a)){c(!0);try{let n={limit:r};if(!f?.datetime)return;n.cursorType=`before`,n.cursorDatetime=f.datetime,await e.c(t,n)}catch(e){console.error(`[useMessages] Failed to load more:`,e)}c(!1)}},[f,r,t,s,a]),loadingMore:s}}var Ud=({conversation:t,user:a,isConnected:s,onBack:c})=>{let l=e.a(),{messages:u,cursor:d,loading:f,error:p,loadMore:m,loadingMore:h}=Hd({conversation:t}),g=Ad(async()=>t.type===`group`?await e.d.groups.get(t.id):null,[t.id,t.type]),_=a?.role===`admin`,v=g?.is_member??!0,y=_&&t.type===`group`&&!v,b=t.type===`group`&&!v,[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=async n=>{if(t.type===`group`){S(!0);try{await l.joinGroup(a.org,t.id,n),w(!0),await Od(a.org),await e.t({}),setTimeout(()=>w(!1),3e3)}catch(e){D(o(e,`Failed to join group`))}S(!1)}},[E,ee]=(0,n.useState)(!1),[te,D]=(0,n.useState)(null),[O,k]=(0,n.useState)(!1);return(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,height:`100%`,children:[(0,i.jsx)(Md,{displayName:t.name||`Chat`,type:t.type,isConnected:s,onBack:c,showJoinButton:y,onJoin:T,joining:x}),(0,i.jsx)(r.Snackbar,{open:C,autoHideDuration:3e3,onClose:()=>w(!1),message:`Successfully joined group`}),te&&(0,i.jsx)(r.Alert,{severity:`error`,onClose:()=>D(null),children:te.message}),(0,i.jsx)(Bd,{messages:u,currentUserId:a?.id||0,loading:f,error:p,autoScroll:!0,hasMore:!!d?.datetime,loadingMore:h,onLoadMore:m,forceScrollToBottom:O}),b?(0,i.jsx)(r.Alert,{severity:`warning`,sx:{m:2},children:`You must be a group member to send messages`}):(0,i.jsx)(Vd,{onSend:async n=>{if(!n.trim())return;ee(!0),D(null),k(!0);let r=`temp-${Date.now()}-${Math.random()}`,i={id:r,sender:a?.id,receiver:t.type===`dm`?t.id:null,group:t.type===`group`?t.id:null,content:n,created_at:new Date().toISOString(),conversationId:e.p(t)};try{await e.d.messages.put(i),await(t.type===`group`?l.sendGroupMessage:l.sendDM).bind(l)(t.id,n),await e.d.messages.delete(r)}catch(e){D(o(e,`Failed to send message`))}ee(!1),setTimeout(()=>k(!1),100)},sending:E})]})},Wd=class extends n.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error:`,e,t),this.props.onError?.(e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:`100%`,p:3,children:[(0,i.jsxs)(r.Alert,{severity:`error`,sx:{mb:2,maxWidth:500},children:[(0,i.jsx)(r.Typography,{variant:`h6`,gutterBottom:!0,children:`Something went wrong`}),(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:this.state.error?.message||`An unexpected error occurred`})]}),(0,i.jsx)(r.Button,{variant:`contained`,startIcon:(0,i.jsx)(ei,{}),onClick:this.handleReset,children:`Try Again`})]}):this.props.children}};function Gd({onMessage:t,onConnect:r,onDisconnect:i,onError:a}={}){let[o,s]=(0,n.useState)(!1),c=(0,n.useCallback)(e=>{t?.(e)},[t]),l=(0,n.useCallback)(()=>{s(!0),r?.()},[r]),u=(0,n.useCallback)(()=>{s(!1),i?.()},[i]),d=(0,n.useCallback)(e=>{a?.(e)},[a]);return(0,n.useEffect)(()=>{if(e.s())try{let t=e.a();return s(t.isConnected()),t.on(`message`,c),t.on(`open`,l),t.on(`close`,u),t.on(`error`,d),()=>{t.off(`message`,c),t.off(`open`,l),t.off(`close`,u),t.off(`error`,d)}}catch(e){console.error(`Failed to setup WebSocket listeners:`,e)}},[c,l,u,d]),{isConnected:o}}var Kd=({initialConversation:t})=>{let[a,o]=(0,n.useState)(t??null),[s,c]=(0,n.useState)(),[l,u]=(0,n.useState)(!0),d=(0,n.useCallback)(e=>()=>u(e),[]),f=e.a();return Ld(async()=>{let t=await f.getMe();c(t),e.d.users.put(t)},[]),Gd({onError:d(!1),onConnect:d(!0),onDisconnect:d(!1)}),(0,i.jsxs)(r.Box,{display:`flex`,height:`100%`,overflow:`hidden`,children:[(0,i.jsx)(r.Box,{sx:{width:{xs:`100%`,sm:`100%`,md:`320px`},flexShrink:0,border:`0px solid`,borderRightWidth:{xs:0,md:1},borderColor:`divider`,overflow:`hidden`,display:{xs:a?`none`:`flex`,sm:a?`none`:`flex`,md:`flex`},flexDirection:`column`},children:(0,i.jsx)(Wd,{children:(0,i.jsx)(jd,{currentUser:s,selectedConversation:a,onConversationSelect:t=>{o(t),e.n(e.p(t))}})})}),(0,i.jsx)(r.Box,{sx:{flex:1,overflow:`hidden`,display:{xs:a?`flex`:`none`,sm:a?`flex`:`none`,md:`flex`},flexDirection:`column`},children:a?(0,i.jsx)(Wd,{children:(0,i.jsx)(Ud,{conversation:a,user:s,isConnected:l,onBack:()=>{o(null),e.n(null)}})}):(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,color:`text.secondary`,children:`Select a conversation to start chatting`})})]})},qd=({count:e,children:t,max:n=99})=>(0,i.jsx)(r.Badge,{badgeContent:e,color:`error`,max:n,overlap:`rectangular`,sx:{"& .MuiBadge-badge":{right:8,top:`50%`,transform:`translateY(-50%)`}},children:t});function Jd(){return Ad(()=>e.d.summaries.toArray().then(e=>e.reduce((e,t)=>e+t.unread_count,0)),[],void 0)}var Yd={SUMMARIES:300*1e3,USER:3600*1e3,MESSAGES:1/0},Xd=()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches,Zd={mode:`dark`,background:{paper:`#3d3d43`,default:`#333338`},text:{primary:`#eee`,secondary:`#aaa`}},Qd={mode:`light`,background:{default:`#f5f5f5`,paper:`#ffff`}},$d=e=>{let t=Xd(),n=(e||(t?`dark`:`light`))===`dark`;return Mr({palette:{...n?Zd:Qd,primary:{main:`#E91E63`,light:`#F48FB1`,dark:`#AD1457`,contrastText:`#fff`},secondary:{main:`#e4e6eb`,light:`#f0f2f5`,dark:`#b0b3b8`,contrastText:`rgba(0, 0, 0, 0.87)`},error:{main:`#d32f2f`,light:`#ef5350`,dark:`#c62828`,contrastText:`#fff`},warning:{main:`#ed6c02`,light:`#ff9800`,dark:`#e65100`,contrastText:`#fff`},info:{main:`#0288d1`,light:`#03a9f4`,dark:`#01579b`,contrastText:`#fff`},success:{main:`#2e7d32`,light:`#4caf50`,dark:`#1b5e20`,contrastText:`#fff`}},typography:{fontFamily:[`-apple-system`,`BlinkMacSystemFont`,`"Segoe UI"`,`Roboto`,`"Helvetica Neue"`,`Arial`,`sans-serif`,`"Apple Color Emoji"`,`"Segoe UI Emoji"`,`"Segoe UI Symbol"`].join(`,`),fontSize:14,h1:{fontSize:`2.5rem`,fontWeight:500},h2:{fontSize:`2rem`,fontWeight:500},h3:{fontSize:`1.75rem`,fontWeight:500},h4:{fontSize:`1.5rem`,fontWeight:500},h5:{fontSize:`1.25rem`,fontWeight:500},h6:{fontSize:`1rem`,fontWeight:500},body1:{fontSize:`0.9375rem`,lineHeight:1.4},body2:{fontSize:`0.8125rem`,lineHeight:1.4}},shape:{borderRadius:12},components:{MuiButton:{styleOverrides:{root:{textTransform:`none`,fontWeight:500,borderRadius:20}}},MuiIconButton:{styleOverrides:{root:{borderRadius:`50%`}}},MuiPaper:{styleOverrides:{root:{backgroundImage:`none`},rounded:{borderRadius:12}}},MuiBadge:{styleOverrides:{badge:{fontSize:`0.6875rem`,height:18,minWidth:18,borderRadius:9,fontWeight:600}}},MuiCssBaseline:{styleOverrides:{body:{"*::-webkit-scrollbar":{width:`8px`,height:`8px`},"*::-webkit-scrollbar-track":{background:`undo`,borderRadius:`4px`},"*::-webkit-scrollbar-thumb":{background:`undo`,borderRadius:`4px`,"&:hover":{background:`undo`}},scrollbarWidth:`thin`,scrollbarColor:n?`#6a6a6e #333338`:`#c1c1c1 #f5f5f5`}}}}})},ef=$d();exports.CACHE_TTL=Yd,exports.ChatApp=l,exports.ChatContainer=Kd,exports.ChatHeader=Md,exports.ChatWindow=Ud,exports.ConversationItem=si,exports.ConversationItemSkeleton=ci,exports.ConversationList=jd,exports.CreateGroupDialog=Dd,exports.ErrorBoundary=Wd,exports.LoadMoreTrigger=Id,exports.MessageBubble=Pd,exports.MessageInput=Vd,exports.MessageList=Bd,exports.MessageSkeleton=Fd,exports.UnreadBadge=qd,exports.db=e.d,exports.disconnectSDK=e.i,exports.fetchSummaries=e.t,exports.getSDK=e.a,exports.getTheme=$d,exports.initSDK=e.o,exports.isSDKInitialized=e.s,exports.theme=ef,exports.useMessages=Hd,exports.useSenderNames=zd,exports.useUnreadCount=Jd,exports.useWebSocket=Gd;
31
+ `)}function ou(e){var t={};if(e.inner){if(e.inner.length===0)return $l(t,e.path,e.message);for(var n=e.inner,r=Array.isArray(n),i=0,n=r?n:n[Symbol.iterator]();;){var a;if(r){if(i>=n.length)break;a=n[i++]}else{if(i=n.next(),i.done)break;a=i.value}var o=a;Q(t,o.path)||(t=$l(t,o.path,o.message))}}return t}function su(e,t,n,r){n===void 0&&(n=!1);var i=cu(e);return t[n?`validateSync`:`validate`](i,{abortEarly:!1,context:r||i})}function cu(e){var t=Array.isArray(e)?[]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=String(n);Array.isArray(e[r])===!0?t[r]=e[r].map(function(e){return Array.isArray(e)===!0||Wi(e)?cu(e):e===``?void 0:e}):Wi(e[r])?t[r]=cu(e[r]):t[r]=e[r]===``?void 0:e[r]}return t}function lu(e,t,n){var r=e.slice();return t.forEach(function(t,i){r[i]===void 0?r[i]=n.clone!==!1&&n.isMergeableObject(t)?yi(Array.isArray(t)?[]:{},t,n):t:n.isMergeableObject(t)?r[i]=yi(e[i],t,n):e.indexOf(t)===-1&&r.push(t)}),r}function uu(e){return Array.from(e).filter(function(e){return e.selected}).map(function(e){return e.value})}function du(e,t,n){if(typeof e==`boolean`)return!!t;var r=[],i=!1,a=-1;if(Array.isArray(e))r=e,a=e.indexOf(n),i=a>=0;else if(!n||n==`true`||n==`false`)return!!t;return t&&n&&!i?r.concat(n):i?r.slice(0,a).concat(r.slice(a+1)):r}var fu=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0?t.useLayoutEffect:t.useEffect;function $(e){var n=(0,t.useRef)(e);return fu(function(){n.current=e}),(0,t.useCallback)(function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.current.apply(void 0,t)},[])}var pu=(0,t.forwardRef)(function(e,n){var r=e.action,i=Hl(e,[`action`]),a=r??`#`,o=Gl(),s=o.handleReset,c=o.handleSubmit;return(0,t.createElement)(`form`,X({onSubmit:c,ref:n,onReset:s,action:a},i))});pu.displayName=`Form`;var mu=function(e,t,n){var r=vu(e),i=r[t];return r.splice(t,1),r.splice(n,0,i),r},hu=function(e,t,n){var r=vu(e),i=r[t];return r[t]=r[n],r[n]=i,r},gu=function(e,t,n){var r=vu(e);return r.splice(t,0,n),r},_u=function(e,t,n){var r=vu(e);return r[t]=n,r},vu=function(e){if(!e)return[];if(Array.isArray(e))return[].concat(e);var t=Object.keys(e).map(function(e){return parseInt(e)}).reduce(function(e,t){return t>e?t:e},0);return Array.from(X({},e,{length:t+1}))},yu=function(e,t){var n=typeof e==`function`?e:t;return function(e){return Array.isArray(e)||ql(e)?n(vu(e)):e}},bu=function(e){Vl(n,e);function n(t){var n=e.call(this,t)||this;return n.updateArrayField=function(e,t,r){var i=n.props,a=i.name,o=i.formik.setFormikState;o(function(n){var i=yu(r,e),o=yu(t,e),s=$l(n.values,a,e(Q(n.values,a))),c=r?i(Q(n.errors,a)):void 0,l=t?o(Q(n.touched,a)):void 0;return Kl(c)&&(c=void 0),Kl(l)&&(l=void 0),X({},n,{values:s,errors:r?$l(n.errors,a,c):n.errors,touched:t?$l(n.touched,a,l):n.touched})})},n.push=function(e){return n.updateArrayField(function(t){return[].concat(vu(t),[pl(e)])},!1,!1)},n.handlePush=function(e){return function(){return n.push(e)}},n.swap=function(e,t){return n.updateArrayField(function(n){return hu(n,e,t)},!0,!0)},n.handleSwap=function(e,t){return function(){return n.swap(e,t)}},n.move=function(e,t){return n.updateArrayField(function(n){return mu(n,e,t)},!0,!0)},n.handleMove=function(e,t){return function(){return n.move(e,t)}},n.insert=function(e,t){return n.updateArrayField(function(n){return gu(n,e,t)},function(t){return gu(t,e,null)},function(t){return gu(t,e,null)})},n.handleInsert=function(e,t){return function(){return n.insert(e,t)}},n.replace=function(e,t){return n.updateArrayField(function(n){return _u(n,e,t)},!1,!1)},n.handleReplace=function(e,t){return function(){return n.replace(e,t)}},n.unshift=function(e){var t=-1;return n.updateArrayField(function(n){var r=n?[e].concat(n):[e];return t=r.length,r},function(e){return e?[null].concat(e):[null]},function(e){return e?[null].concat(e):[null]}),t},n.handleUnshift=function(e){return function(){return n.unshift(e)}},n.handleRemove=function(e){return function(){return n.remove(e)}},n.handlePop=function(){return function(){return n.pop()}},n.remove=n.remove.bind(Ul(n)),n.pop=n.pop.bind(Ul(n)),n}var r=n.prototype;return r.componentDidUpdate=function(e){this.props.validateOnChange&&this.props.formik.validateOnChange&&!(0,hl.default)(Q(e.formik.values,e.name),Q(this.props.formik.values,this.props.name))&&this.props.formik.validateForm(this.props.formik.values)},r.remove=function(e){var t;return this.updateArrayField(function(n){var r=n?vu(n):[];return t||=r[e],Z(r.splice)&&r.splice(e,1),Z(r.every)&&r.every(function(e){return e===void 0})?[]:r},!0,!0),t},r.pop=function(){var e;return this.updateArrayField(function(t){var n=t.slice();return e||=n&&n.pop&&n.pop(),n},!0,!0),e},r.render=function(){var e={push:this.push,pop:this.pop,swap:this.swap,move:this.move,insert:this.insert,replace:this.replace,unshift:this.unshift,remove:this.remove,handlePush:this.handlePush,handlePop:this.handlePop,handleSwap:this.handleSwap,handleMove:this.handleMove,handleInsert:this.handleInsert,handleReplace:this.handleReplace,handleUnshift:this.handleUnshift,handleRemove:this.handleRemove},n=this.props,r=n.component,i=n.render,a=n.children,o=n.name,s=n.formik,c=Hl(s,[`validate`,`validationSchema`]),l=X({},e,{form:c,name:o});return r?(0,t.createElement)(r,l):i?i(l):a?typeof a==`function`?a(l):Xl(a)?null:t.Children.only(a):null},n}(t.Component);bu.defaultProps={validateOnChange:!0};var xu=e.g(((e,t)=>{t.exports=Array.isArray})),Su=e.g(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),Cu=e.g(((e,t)=>{var n=Su(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),wu=e.g(((e,t)=>{t.exports=Cu().Symbol})),Tu=e.g(((e,t)=>{var n=wu(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),Eu=e.g(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),Du=e.g(((e,t)=>{var n=wu(),r=Tu(),i=Eu(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),Ou=e.g(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),ku=e.g(((e,t)=>{var n=Du(),r=Ou(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Au=e.g(((e,t)=>{var n=xu(),r=ku(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),ju=e.g(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),Mu=e.g(((e,t)=>{var n=Du(),r=ju(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),Nu=e.g(((e,t)=>{t.exports=Cu()[`__core-js_shared__`]})),Pu=e.g(((e,t)=>{var n=Nu(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),Fu=e.g(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),Iu=e.g(((e,t)=>{var n=Mu(),r=Pu(),i=ju(),a=Fu(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),Lu=e.g(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),Ru=e.g(((e,t)=>{var n=Iu(),r=Lu();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),zu=e.g(((e,t)=>{t.exports=Ru()(Object,`create`)})),Bu=e.g(((e,t)=>{var n=zu();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),Vu=e.g(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),Hu=e.g(((e,t)=>{var n=zu(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),Uu=e.g(((e,t)=>{var n=zu(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),Wu=e.g(((e,t)=>{var n=zu(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),Gu=e.g(((e,t)=>{var n=Bu(),r=Vu(),i=Hu(),a=Uu(),o=Wu();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),Ku=e.g(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),qu=e.g(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Ju=e.g(((e,t)=>{var n=qu();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),Yu=e.g(((e,t)=>{var n=Ju(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Xu=e.g(((e,t)=>{var n=Ju();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Zu=e.g(((e,t)=>{var n=Ju();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Qu=e.g(((e,t)=>{var n=Ju();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),$u=e.g(((e,t)=>{var n=Ku(),r=Yu(),i=Xu(),a=Zu(),o=Qu();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ed=e.g(((e,t)=>{t.exports=Ru()(Cu(),`Map`)})),td=e.g(((e,t)=>{var n=Gu(),r=$u(),i=ed();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),nd=e.g(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),rd=e.g(((e,t)=>{var n=nd();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),id=e.g(((e,t)=>{var n=rd();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),ad=e.g(((e,t)=>{var n=rd();function r(e){return n(this,e).get(e)}t.exports=r})),od=e.g(((e,t)=>{var n=rd();function r(e){return n(this,e).has(e)}t.exports=r})),sd=e.g(((e,t)=>{var n=rd();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),cd=e.g(((e,t)=>{var n=td(),r=id(),i=ad(),a=od(),o=sd();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ld=e.g(((e,t)=>{var n=cd(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),ud=e.g(((e,t)=>{var n=ld(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),dd=e.g(((e,t)=>{var n=ud(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),fd=e.g(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),pd=e.g(((e,t)=>{var n=wu(),r=fd(),i=xu(),a=ku(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),md=e.g(((e,t)=>{var n=pd();function r(e){return e==null?``:n(e)}t.exports=r})),hd=e.g(((e,t)=>{var n=xu(),r=Au(),i=dd(),a=md();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),gd=e.g(((e,t)=>{var n=ku(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),_d=e.g(((e,t)=>{var n=hd(),r=gd();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),vd=e.g(((e,t)=>{var n=_d();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),yd=e._(vd(),1),bd=(e=16)=>{let t={upper:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`,lower:`abcdefghijklmnopqrstuvwxyz`,numbers:`0123456789`,symbols:`!@%^&*()_+[]{}|;:,.<>?`},n=t.upper+t.lower+t.numbers+t.symbols,r=e=>e[crypto.getRandomValues(new Uint32Array(1))[0]%e.length],i=[r(t.upper),r(t.lower),r(t.numbers),r(t.symbols)];for(let t=4;t<e;t++)i.push(r(n));for(let e=i.length-1;e>0;e--){let t=crypto.getRandomValues(new Uint32Array(1))[0]%(e+1),n=i[e];i[e]=i[t],i[t]=n}return i.join(``)},xd=({showPassword:e,onToggleVisibility:t,onGenerate:n})=>(0,i.jsxs)(r.InputAdornment,{position:`end`,children:[n&&(0,i.jsx)(r.Tooltip,{title:`Generate Password`,children:(0,i.jsx)(r.IconButton,{onClick:n,edge:`end`,size:`small`,sx:{opacity:.7},"aria-label":`generate password`,children:(0,i.jsx)(qr,{})})}),(0,i.jsx)(r.Tooltip,{title:e?`Hide password`:`Show password`,children:(0,i.jsx)(r.IconButton,{onClick:t,edge:`end`,size:`small`,sx:{opacity:.7},"aria-label":e?`hide password`:`show password`,children:e?(0,i.jsx)(ii,{}):(0,i.jsx)(ri,{})})})]}),Sd=({type:e,autoGenerate:t=!1,formik:r,name:i})=>{let[a,o]=(0,n.useState)(!1),s={},c=a?`text`:`password`;return e===`password`?(s.endAdornment=xd({showPassword:a,onToggleVisibility:()=>{o(!a)},onGenerate:t?()=>{if(!r||!i)return;let e=bd();r.setFieldValue(i,e),a||o(!0)}:void 0}),{inputType:c,inputProps:s}):{inputType:e,inputProps:s}},Cd=({helperText:e,errorText:t,formik:a,name:o,defaultValue:s,onChange:c,type:l,fullWidth:u=!0,autoGenerate:d=!1,...f})=>{let p=Sd({type:l,autoGenerate:d,formik:a,name:o}),m={},h=f.value??s;if((0,n.useEffect)(()=>{!a||!o||h===void 0||a.setFieldValue(o,h)},[h]),o&&a){a.touched[o]&&(t??=a.errors[o]);let e=(0,yd.default)(a.values,o,``);l===`date`&&(e=wd(e)),m={value:e??``,onBlur:()=>a.setFieldTouched(o),onChange:e=>{let t=e.target.value;l===`date`&&t&&(t=new Date(t)),a.setFieldValue(o,t||null),c?.(e)},slotProps:{...f.slotProps,input:{...f.InputProps,...f.slotProps?.input,...p.inputProps},inputLabel:l===`date`?{shrink:!0}:void 0}}}return(0,i.jsx)(r.TextField,{variant:`standard`,onChange:c,...f,...m,name:o,type:p.inputType,fullWidth:u,helperText:t||e,error:!!t})},wd=e=>{if(!e)return``;let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`},Td=({multiple:t=!1,formik:a,name:o,label:s=`Search users`,disabled:c=!1,error:l,helperText:u,value:d,onChange:f})=>{let[p,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)([]),[_,v]=(0,n.useState)(!1),[y,b]=(0,n.useState)(``),x=(0,n.useCallback)(async t=>{if(t.length<2){g([]);return}v(!0);try{g(await e.a().searchUsers({name:t}))}catch(e){console.error(`Failed to search users:`,e),g([])}finally{v(!1)}},[]),S=(0,n.useCallback)((e,t)=>{b(t),x(t)},[x]),C=()=>d===void 0?a&&o?a.values[o]:t?[]:null:d,w=(e,t)=>{f?f(t):a&&o&&a.setFieldValue(o,t)},T=()=>{a&&o&&a.setFieldTouched(o)},E=()=>{if(l)return` `;if(a&&o&&a.touched[o]&&a.errors[o])return a.errors[o]};return(0,i.jsx)(r.Autocomplete,{open:p,onOpen:()=>m(!0),onClose:()=>m(!1),multiple:t,options:h,value:C(),onChange:w,onBlur:T,onInputChange:S,getOptionLabel:e=>e.name,isOptionEqualToValue:(e,t)=>e.id===t.id,loading:_,noOptionsText:y.length<3?`Type at least 3 characters to search`:`No users found`,renderOption:(e,t)=>(0,n.createElement)(r.Box,{component:`li`,...e,key:t.id},(0,i.jsxs)(r.Box,{children:[(0,i.jsx)(r.Typography,{variant:`body1`,children:t.name}),(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:t.email})]})),renderInput:e=>(0,i.jsx)(r.TextField,{...e,label:s,disabled:c,error:!!E(),helperText:E()||u,InputProps:{...e.InputProps,endAdornment:(0,i.jsxs)(i.Fragment,{children:[_?(0,i.jsx)(r.CircularProgress,{size:20}):null,e.InputProps.endAdornment]})}})})},Ed=e.m({name:e.h().trim().required(`Group name is required`).min(2,`Group name must be at least 2 characters`).max(100,`Group name must be at most 100 characters`)}),Dd=({open:t,onClose:a,onSuccess:s,orgId:c})=>{let[l,u]=(0,n.useState)(null),d=iu({initialValues:{name:``,read_only:!1,members:[]},validationSchema:Ed,onSubmit:async(t,{setSubmitting:n,resetForm:r})=>{u(null);try{let n=e.a(),i=await n.createGroup(c,{name:t.name.trim(),read_only:t.read_only});t.members&&t.members.length>0&&await n.addGroupMembers(c,i.id,t.members.map(e=>({user:e.userId,role:e.role}))),r(),s?.(),a()}catch(e){u(o(e,`Failed to create group`))}n(!1)}}),f=e=>{let t=Array.isArray(e)?e:[];d.setFieldValue(`members`,t.map(e=>({userId:e.id,role:`member`,user:e})))},p=(e,t)=>{let n=d.values.members.map(n=>n.userId===e?{...n,role:t}:n);d.setFieldValue(`members`,n)},m=e=>{let t=d.values.members.filter(t=>t.userId!==e);d.setFieldValue(`members`,t)},h=()=>{d.resetForm(),a()};return(0,i.jsxs)(r.Dialog,{open:t,onClose:h,maxWidth:`sm`,fullWidth:!0,PaperProps:{component:`form`,onSubmit:d.handleSubmit},children:[(0,i.jsx)(r.DialogTitle,{children:`Create New Group`}),(0,i.jsx)(r.DialogContent,{children:(0,i.jsxs)(r.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2,pt:1},children:[l&&(0,i.jsx)(r.Alert,{severity:`error`,onClose:()=>u(null),children:l.message}),(0,i.jsx)(Cd,{label:`Group Name`,name:`name`,formik:d,required:!0,disabled:d.isSubmitting,placeholder:`e.g., Computer Science 101`}),(0,i.jsx)(r.FormControlLabel,{control:(0,i.jsx)(r.Switch,{name:`read_only`,checked:d.values.read_only,onChange:d.handleChange,disabled:d.isSubmitting}),label:`Read-only group (only moderators can post)`}),(0,i.jsx)(r.Divider,{sx:{my:2}}),(0,i.jsx)(r.Typography,{color:`warning.main`,fontWeight:500,children:`You cannot add members later. Only admins can join a group after it is created`}),(0,i.jsxs)(r.Box,{children:[(0,i.jsx)(r.Typography,{variant:`subtitle2`,gutterBottom:!0,children:`Add Members`}),(0,i.jsx)(Td,{multiple:!0,label:`Search users to add`,value:d.values.members.map(e=>e.user),onChange:f,disabled:d.isSubmitting})]}),d.values.members.length>0&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(r.Typography,{variant:`subtitle2`,gutterBottom:!0,children:`Selected Members`}),d.values.members.map(e=>(0,i.jsxs)(r.Box,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,borderRadius:1},children:[(0,i.jsx)(r.Box,{sx:{flex:1},children:e.user.name}),(0,i.jsxs)(r.Select,{value:e.role,onChange:t=>p(e.userId,t.target.value),size:`small`,disabled:d.isSubmitting,sx:{mr:2},children:[(0,i.jsx)(r.MenuItem,{value:`member`,children:`Member`}),(0,i.jsx)(r.MenuItem,{value:`moderator`,children:`Moderator`})]}),(0,i.jsx)(r.IconButton,{size:`small`,onClick:()=>m(e.userId),disabled:d.isSubmitting,color:`error`,children:(0,i.jsx)(Jr,{})})]},e.userId))]})]})}),(0,i.jsxs)(r.DialogActions,{sx:{p:3},children:[(0,i.jsx)(r.Button,{onClick:h,disabled:d.isSubmitting,children:`Cancel`}),(0,i.jsx)(r.Button,{type:`submit`,variant:`contained`,disabled:d.isSubmitting||!d.isValid,startIcon:d.isSubmitting&&(0,i.jsx)(r.CircularProgress,{size:16}),children:`Create Group`})]})]})},Od=async t=>{let n=await e.a().getGroups(t);return await e.d.groups.clear(),await e.d.groups.bulkPut(n),n};function kd(e,t,r){let i,a;typeof e==`function`?(i=t||[],a=r):(i=[],a=t);let o=n.default.useRef({hasResult:!1,result:a,error:null}),[s,c]=n.default.useReducer(e=>e+1,0),l=n.default.useMemo(()=>{let t=typeof e==`function`?e():e;if(!t||typeof t.subscribe!=`function`)throw TypeError(e===t?`Given argument to useObservable() was neither a valid observable nor a function.`:`Observable factory given to useObservable() did not return a valid observable.`);if(!o.current.hasResult&&typeof window<`u`&&(typeof t.hasValue!=`function`||t.hasValue()))if(typeof t.getValue==`function`)o.current.result=t.getValue(),o.current.hasResult=!0;else{let e=t.subscribe(e=>{o.current.result=e,o.current.hasResult=!0});typeof e==`function`?e():e.unsubscribe()}return t},i);if(n.default.useDebugValue(o.current.result),n.default.useEffect(()=>{let e=l.subscribe(e=>{let{current:t}=o;(t.error!==null||t.result!==e)&&(t.error=null,t.result=e,t.hasResult=!0,c())},e=>{let{current:t}=o;t.error!==e&&(t.error=e,c())});return typeof e==`function`?e:e.unsubscribe.bind(e)},i),o.current.error)throw o.current.error;return o.current.result}function Ad(t,n,r){return kd(()=>e.f.liveQuery(t),n||[],r)}typeof FinalizationRegistry<`u`&&new FinalizationRegistry(t=>{let n=e.f.DexieYProvider;n&&n.release(t)}),Reflect.get(n,`use`);var jd=({selectedConversation:t,currentUser:a,onConversationSelect:o})=>{let[s,c]=(0,n.useState)(!0),[l,u]=(0,n.useState)(),[d,f]=(0,n.useState)(!1),p=Ad(()=>e.d.summaries.toArray(),[t])||[],m=Ad(()=>e.d.groups.toArray(),[])||[],h=a?.role===`admin`||a?.role===`system`,g=(0,n.useCallback)(async()=>{c(!0),a?.org&&(await Promise.all([e.t({}),Od(a?.org)]).catch(e=>{u(e instanceof Error?e:Error(String(e)))}),c(!1))},[a?.org]);(0,n.useEffect)(()=>{g();let e=setInterval(g,3*6e4);return()=>clearInterval(e)},[g]);let[_,v]=(0,n.useState)({});(0,n.useEffect)(()=>{p.length>0&&a?.org&&(async()=>{if(!a?.org)return;let t=e.a(),n={};for(let e of p)try{if(e.user!==void 0&&!_[e.user]){let r=await t.getUser(e.user);n[e.user]=r.name}}catch(e){console.error(`Failed to load conversation name:`,e)}Object.keys(n).length>0&&v(e=>({...e,...n}))})()},[p,a?.org]);let y=e=>e.user===void 0?e.group===void 0?`Unknown`:m.find(t=>t.id===e.group)?.name||`Group ${e.group}`:_[e.user]||`User ${e.user}`,b=e=>t?e.group===void 0?e.user===void 0?!1:t.type===`dm`&&t.id===e.user:t.type===`group`&&t.id===e.group:!1,x=e=>{e.group===void 0?e.user!==void 0&&o({type:`dm`,id:e.user,name:y(e)}):o({type:`group`,id:e.group,name:y(e)})};return(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,height:`100%`,children:[(0,i.jsx)(r.AppBar,{position:`static`,elevation:0,sx:{backgroundColor:`background.default`,color:`text.primary`},children:(0,i.jsxs)(r.Toolbar,{children:[(0,i.jsx)(r.Typography,{variant:`h6`,component:`div`,sx:{flexGrow:1},children:`Messages`}),h&&(0,i.jsx)(r.Tooltip,{title:`Create Group`,children:(0,i.jsx)(r.IconButton,{color:`primary`,onClick:()=>f(!0),size:`small`,sx:{mr:-2},children:(0,i.jsx)(Wr,{})})})]})}),h&&a?.org&&(0,i.jsx)(Dd,{open:d,onClose:()=>f(!1),onSuccess:async()=>{await g()},orgId:a.org}),(0,i.jsx)(r.Box,{flex:1,overflow:`auto`,children:s&&!p.length?(0,i.jsx)(r.List,{disablePadding:!0,children:[1,2,3,4,5].map(e=>(0,i.jsx)(ci,{},e))}):l?(0,i.jsx)(r.Box,{p:2,children:(0,i.jsxs)(r.Alert,{severity:`error`,children:[`Failed to load conversations: `,l.message]})}):p.length===0&&m.length===0?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,p:2,children:(0,i.jsx)(r.Typography,{color:`text.secondary`,align:`center`,children:`No conversations yet`})}):(0,i.jsx)(r.List,{disablePadding:!0,children:(()=>{let e=new Set(p.filter(e=>e.group!==void 0).map(e=>e.group)),t=m.filter(t=>!e.has(t.id)).map(e=>({group:e.id,last_message_at:e.created_at,message_count:0,unread_count:0}));return[...[...p].sort((e,t)=>new Date(t.last_message_at).getTime()-new Date(e.last_message_at).getTime()),...t].map(e=>(0,i.jsx)(si,{conversation:e,displayName:y(e),selected:b(e),onClick:()=>x(e),currentUser:a},e.group===void 0?`user-${e.user}`:`group-${e.group}`))})()})})]})},Md=({displayName:e,type:t,subtitle:a,isConnected:o=!0,onBack:s,showJoinButton:c=!1,onJoin:l,joining:u=!1})=>{let d=t===`group`,[f,p]=(0,n.useState)(null),m=e=>{p(e.currentTarget)},h=()=>{p(null)},g=e=>{l(e),h()};return(0,i.jsx)(r.AppBar,{position:`static`,elevation:0,sx:{backgroundColor:`background.default`,color:`text.primary`},children:(0,i.jsxs)(r.Toolbar,{children:[s&&(0,i.jsx)(r.IconButton,{edge:`start`,color:`inherit`,onClick:s,sx:{mr:2,display:{xs:`flex`,sm:`flex`,md:`none`}},children:(0,i.jsx)(Gr,{})}),(0,i.jsx)(r.Avatar,{sx:{bgcolor:d?`primary.main`:`secondary.main`,mr:2},children:d?(0,i.jsx)(Zr,{}):(0,i.jsx)(Qr,{})}),(0,i.jsxs)(r.Box,{flex:1,children:[(0,i.jsx)(r.Typography,{variant:`h6`,component:`div`,noWrap:!0,children:e}),a&&(0,i.jsx)(r.Typography,{variant:`caption`,color:`inherit`,sx:{opacity:.7},children:a})]}),c&&d&&(0,i.jsxs)(r.Box,{sx:{display:`flex`,alignItems:`center`,mr:1},children:[(0,i.jsx)(r.Button,{variant:`contained`,color:`primary`,startIcon:(0,i.jsx)($r,{}),endIcon:(0,i.jsx)(Kr,{}),onClick:m,disabled:u,children:u?`Joining...`:`Join`}),(0,i.jsxs)(r.Menu,{anchorEl:f,open:!!f,onClose:h,children:[(0,i.jsx)(r.MenuItem,{onClick:()=>g(`member`),children:`Member`}),(0,i.jsx)(r.MenuItem,{onClick:()=>g(`moderator`),children:`Moderator`})]})]}),!o&&(0,i.jsx)(r.Chip,{icon:(0,i.jsx)(ai,{}),label:`Disconnected`,size:`small`,color:`warning`,sx:{ml:1}})]})})};function Nd(e){return(typeof e==`string`?new Date(e):e).toLocaleTimeString(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0})}var Pd=n.default.memo(({message:t,isOwnMessage:n,senderName:a,showSenderName:o=!0,isFirstInGroup:s=!0,isLastInGroup:c=!0,status:l=`sent`})=>{let u=t.id.startsWith(`temp-`),d=()=>{if(!n||!c)return null;let e={fontSize:14,ml:.5,opacity:.7,verticalAlign:`middle`};return l===`failed`?(0,i.jsx)(Xr,{sx:{...e,color:`error.main`}}):l===`sending`||u?(0,i.jsx)(ti,{sx:e}):(0,i.jsx)(Yr,{sx:e})},f=(0,i.jsx)(r.Avatar,{sx:{width:32,height:32,fontSize:`0.875rem`,color:n?`primary.contrastText`:`secondary.contrastText`,bgcolor:n?`primary.main`:`secondary.main`,visibility:c?`visible`:`hidden`},children:e.l(a)});return(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-end`,mb:c?1:.25,gap:1,children:[!n&&f,(0,i.jsxs)(r.Paper,{elevation:1,sx:{maxWidth:`80%`,p:1.5,backgroundColor:n?`primary.main`:`background.paper`,color:n?`primary.contrastText`:`text.primary`,borderTopLeftRadius:n||!s?void 0:4,borderTopRightRadius:!n||!s?void 0:4,borderBottomLeftRadius:n||!c?void 0:4,borderBottomRightRadius:!n||!c?void 0:4},children:[!n&&o&&s&&(0,i.jsx)(r.Typography,{variant:`caption`,fontWeight:`bold`,display:`block`,mb:.5,children:a||`User ${t.sender}`}),(0,i.jsx)(r.Typography,{variant:`body1`,sx:{whiteSpace:`pre-wrap`},children:t.content}),c&&(0,i.jsxs)(r.Box,{display:`flex`,justifyContent:`flex-end`,alignItems:`center`,mt:.5,children:[(0,i.jsx)(r.Typography,{variant:`caption`,color:n?`inherit`:`text.secondary`,sx:{opacity:.7},children:Nd(new Date(t.created_at))}),(0,i.jsx)(d,{})]})]}),n&&f]})}),Fd=({isOwnMessage:e=!1})=>(0,i.jsx)(r.Box,{display:`flex`,justifyContent:e?`flex-end`:`flex-start`,mb:1,children:(0,i.jsxs)(r.Box,{maxWidth:`70%`,children:[!e&&(0,i.jsx)(r.Skeleton,{variant:`text`,width:80,sx:{mb:.5}}),(0,i.jsx)(r.Skeleton,{variant:`rounded`,width:Math.random()*200+150,height:60,sx:{borderRadius:2,bgcolor:e?`primary.light`:`background.main`}})]})}),Id=({hasMore:e,loading:t,onLoadMore:a,threshold:o=1,rootMargin:s=`100px`})=>{let c=(0,n.useRef)(null),l=(0,n.useRef)(null);return(0,n.useEffect)(()=>{if(!e||t)return;let n=c.current;if(n)return l.current=new IntersectionObserver(n=>{let[r]=n;r&&r.isIntersecting&&e&&!t&&a()},{threshold:o,rootMargin:s}),l.current.observe(n),()=>{l.current&&n&&(l.current.unobserve(n),l.current.disconnect())}},[e,t,a,o,s]),e?(0,i.jsx)(r.Box,{ref:c,display:`flex`,justifyContent:`center`,alignItems:`center`,py:2,children:t?(0,i.jsx)(r.CircularProgress,{size:24}):(0,i.jsx)(r.Typography,{variant:`caption`,color:`text.secondary`,children:`Scroll to load more`})}):null},Ld=(e,t,r)=>{(0,n.useEffect)(()=>((async()=>{await e()})(),r),t)};function Rd(e){let t=e.map(e=>Number(e.sender));return new Set(t)}function zd(t){let r=e.a(),[i,a]=(0,n.useState)(()=>new Map),o=(0,n.useCallback)(async()=>{if(!t.length)return i;try{let n=Rd(t),a=Array.from(n);if(console.log(`[names] size:`,n.size),!n.size)return i;let o=(await e.d.users.bulkGet(a)).filter(e=>!!e),s=new Map;if(o.forEach(e=>{s.set(e.id,e.name)}),n.size===o.length)return s;let c=a.filter(e=>!s.has(e)),l=await r.getUsers(c,{fields:[`id`,`name`]});await e.d.users.bulkPut(l);let u=s;return l.forEach(e=>u.set(e.id,e.name)),u}catch(e){console.error(`[useSenderNames] Failed to fetch users:`,e)}return i},[t,i]);return Ld(async()=>{a(await o())},[t]),i}var Bd=({messages:t,currentUserId:a,loading:o=!1,error:s=null,autoScroll:c=!0,hasMore:l=!1,loadingMore:u=!1,onLoadMore:d})=>{let f=(0,n.useRef)(null),p=(0,n.useRef)(null),m=(0,n.useRef)(0),h=(0,n.useRef)(!0),[g,_]=(0,n.useState)(c),v=zd(t),y=()=>{if(!p.current)return!1;let{scrollTop:e,scrollHeight:t,clientHeight:n}=p.current;return t-e-n<100};return(0,n.useEffect)(()=>{t.length>0&&f.current&&(f.current.scrollIntoView({behavior:`auto`}),h.current=!0)},[]),(0,n.useEffect)(()=>{!u||!t.length||(p.current&&(m.current=p.current.scrollHeight),_(!1))},[u]),(0,n.useLayoutEffect)(()=>{if(t.length){if(g&&f.current&&h.current)f.current.scrollIntoView({behavior:`smooth`});else if(!g&&p.current&&m.current>0){let e=p.current.scrollHeight-m.current;p.current.scrollTop=p.current.scrollTop+e,m.current=0,_(!0)}}},[t.length,c]),o&&!t.length?(0,i.jsx)(r.Box,{flex:1,overflow:`auto`,p:2,children:[1,2,3,4,5].map(e=>(0,i.jsx)(Fd,{isOwnMessage:e%3==0},e))}):s&&!t.length?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,flex:1,p:2,children:(0,i.jsxs)(r.Alert,{severity:`error`,children:[(0,i.jsx)(`strong`,{children:`Failed to load messages`}),(0,i.jsx)(`br`,{}),s.message]})}):t.length===0?(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,flex:1,children:(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:`No messages yet. Start the conversation!`})}):(0,i.jsxs)(r.Box,{ref:p,flex:1,overflow:`auto`,p:2,display:`flex`,flexDirection:`column`,onScroll:()=>{h.current=y()},children:[l&&d&&(0,i.jsx)(Id,{hasMore:l,loading:u,onLoadMore:d}),t.map((n,r)=>{let o=n.sender,s=n.sender===a,c=v.get(o),l=r>0?t[r-1]:null,u=r<t.length-1?t[r+1]:null,d=!l||!e.u(l,n);return(0,i.jsx)(Pd,{message:n,isOwnMessage:s,senderName:c,showSenderName:d,isFirstInGroup:d,isLastInGroup:!u||!e.u(n,u)},n.id)}),(0,i.jsx)(`div`,{ref:f})]})},Vd=({onSend:e,sending:t=!1,placeholder:a=`Type a message...`,disabled:o=!1,disableReason:s})=>{let[c,l]=(0,n.useState)(``),u=(0,n.useRef)(null),d=()=>{let n=c.trim();n&&!t&&!o&&(e(n),l(``),setTimeout(()=>{u.current?.querySelector(`textarea`)?.focus()},300))};return(0,i.jsxs)(r.Box,{display:`flex`,gap:1,p:2,borderTop:1,borderColor:`divider`,children:[(0,i.jsx)(r.TextField,{ref:u,fullWidth:!0,multiline:!0,maxRows:4,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),d())},placeholder:o&&s?s:a,disabled:o||t,variant:`outlined`,size:`small`}),(0,i.jsx)(r.IconButton,{color:`primary`,onClick:d,disabled:!c.trim()||t||o,size:`large`,children:t?(0,i.jsx)(r.CircularProgress,{size:24}):(0,i.jsx)(ni,{})})]})};function Hd({conversation:t,limit:r=50}){let i=e.p(t),[a,o]=(0,n.useState)(!1),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)(),d=Ad(()=>e.d.messages.where(`conversationId`).equals(i).sortBy(`created_at`),[i])||[],f=Ad(()=>e.d.msgCursor.where(`id`).equals(i).first(),[i]);return Ld(async()=>{let n={limit:r};d.length&&(n.cursorType=`after`,n.cursorDatetime=d[d.length-1]?.created_at),o(!0),await e.c(t,n).catch(u),o(!1),await e.d.summaries.update(i,{unread_count:0})},[t,r]),console.log(`mw`,d.length),{messages:d,cursor:f,loading:a,error:l,loadMore:(0,n.useCallback)(async()=>{if(!(!f||s||a)){c(!0);try{let n={limit:r};if(!f?.datetime)return;n.cursorType=`before`,n.cursorDatetime=f.datetime,await e.c(t,n)}catch(e){console.error(`[useMessages] Failed to load more:`,e)}c(!1)}},[f,r,t,s,a]),loadingMore:s}}var Ud=({conversation:t,user:a,isConnected:s,onBack:c})=>{let l=e.a(),{messages:u,cursor:d,loading:f,error:p,loadMore:m,loadingMore:h}=Hd({conversation:t}),g=Ad(async()=>t.type===`group`?await e.d.groups.get(t.id):null,[t.id,t.type]),_=a?.role===`admin`,v=g?.is_member??!0,y=_&&t.type===`group`&&!v,b=t.type===`group`&&!v,[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(!1),T=async n=>{if(t.type===`group`){S(!0);try{await l.joinGroup(a.org,t.id,n),w(!0),await Od(a.org),await e.t({}),setTimeout(()=>w(!1),3e3)}catch(e){D(o(e,`Failed to join group`))}S(!1)}},[E,ee]=(0,n.useState)(!1),[te,D]=(0,n.useState)(null),[O,k]=(0,n.useState)(!1);return(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,height:`100%`,children:[(0,i.jsx)(Md,{displayName:t.name||`Chat`,type:t.type,isConnected:s,onBack:c,showJoinButton:y,onJoin:T,joining:x}),(0,i.jsx)(r.Snackbar,{open:C,autoHideDuration:3e3,onClose:()=>w(!1),message:`Successfully joined group`}),te&&(0,i.jsx)(r.Alert,{severity:`error`,onClose:()=>D(null),children:te.message}),(0,i.jsx)(Bd,{messages:u,currentUserId:a?.id||0,loading:f,error:p,autoScroll:!0,hasMore:!!d?.datetime,loadingMore:h,onLoadMore:m,forceScrollToBottom:O}),b?(0,i.jsx)(r.Alert,{severity:`warning`,sx:{m:2},children:`You must be a group member to send messages`}):(0,i.jsx)(Vd,{onSend:async n=>{if(!n.trim())return;ee(!0),D(null),k(!0);let r=`temp-${Date.now()}-${Math.random()}`,i={id:r,sender:a?.id,receiver:t.type===`dm`?t.id:null,group:t.type===`group`?t.id:null,content:n,created_at:new Date().toISOString(),conversationId:e.p(t)};try{await e.d.messages.put(i),await(t.type===`group`?l.sendGroupMessage:l.sendDM).bind(l)(t.id,n),await e.d.messages.delete(r)}catch(e){D(o(e,`Failed to send message`))}ee(!1),setTimeout(()=>k(!1),100)},sending:E,disabled:!s,disableReason:s?void 0:`You're offline. You need to be online to send messages`})]})},Wd=class extends n.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error:`,e,t),this.props.onError?.(e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,i.jsxs)(r.Box,{display:`flex`,flexDirection:`column`,justifyContent:`center`,alignItems:`center`,height:`100%`,p:3,children:[(0,i.jsxs)(r.Alert,{severity:`error`,sx:{mb:2,maxWidth:500},children:[(0,i.jsx)(r.Typography,{variant:`h6`,gutterBottom:!0,children:`Something went wrong`}),(0,i.jsx)(r.Typography,{variant:`body2`,color:`text.secondary`,children:this.state.error?.message||`An unexpected error occurred`})]}),(0,i.jsx)(r.Button,{variant:`contained`,startIcon:(0,i.jsx)(ei,{}),onClick:this.handleReset,children:`Try Again`})]}):this.props.children}};function Gd({onMessage:t,onConnect:r,onDisconnect:i,onError:a}={}){let[o,s]=(0,n.useState)(!1),c=(0,n.useCallback)(e=>{t?.(e)},[t]),l=(0,n.useCallback)(()=>{s(!0),r?.()},[r]),u=(0,n.useCallback)(()=>{s(!1),i?.()},[i]),d=(0,n.useCallback)(e=>{a?.(e)},[a]);return(0,n.useEffect)(()=>{if(e.s())try{let t=e.a();return s(t.isConnected()),t.on(`message`,c),t.on(`open`,l),t.on(`close`,u),t.on(`error`,d),()=>{t.off(`message`,c),t.off(`open`,l),t.off(`close`,u),t.off(`error`,d)}}catch(e){console.error(`Failed to setup WebSocket listeners:`,e)}},[c,l,u,d]),{isConnected:o}}var Kd=({initialConversation:t})=>{let[a,o]=(0,n.useState)(t??null),[s,c]=(0,n.useState)(),[l,u]=(0,n.useState)(!0),d=(0,n.useCallback)(e=>()=>u(e),[]),f=e.a();return Ld(async()=>{let t=await f.getMe();c(t),e.d.users.put(t)},[]),Gd({onError:d(!1),onConnect:d(!0),onDisconnect:d(!1)}),(0,i.jsxs)(r.Box,{display:`flex`,height:`100%`,overflow:`hidden`,children:[(0,i.jsx)(r.Box,{sx:{width:{xs:`100%`,sm:`100%`,md:`320px`},flexShrink:0,border:`0px solid`,borderRightWidth:{xs:0,md:1},borderColor:`divider`,overflow:`hidden`,display:{xs:a?`none`:`flex`,sm:a?`none`:`flex`,md:`flex`},flexDirection:`column`},children:(0,i.jsx)(Wd,{children:(0,i.jsx)(jd,{currentUser:s,selectedConversation:a,onConversationSelect:t=>{o(t),e.n(e.p(t))}})})}),(0,i.jsx)(r.Box,{sx:{flex:1,overflow:`hidden`,display:{xs:a?`flex`:`none`,sm:a?`flex`:`none`,md:`flex`},flexDirection:`column`},children:a?(0,i.jsx)(Wd,{children:(0,i.jsx)(Ud,{conversation:a,user:s,isConnected:l,onBack:()=>{o(null),e.n(null)}})}):(0,i.jsx)(r.Box,{display:`flex`,justifyContent:`center`,alignItems:`center`,height:`100%`,color:`text.secondary`,children:`Select a conversation to start chatting`})})]})},qd=({count:e,children:t,max:n=99})=>(0,i.jsx)(r.Badge,{badgeContent:e,color:`error`,max:n,overlap:`rectangular`,sx:{"& .MuiBadge-badge":{right:8,top:`50%`,transform:`translateY(-50%)`}},children:t});function Jd(){return Ad(()=>e.d.summaries.toArray().then(e=>e.reduce((e,t)=>e+t.unread_count,0)),[],void 0)}var Yd={SUMMARIES:300*1e3,USER:3600*1e3,MESSAGES:1/0},Xd=()=>typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches,Zd={mode:`dark`,background:{paper:`#3d3d43`,default:`#333338`},text:{primary:`#eee`,secondary:`#aaa`}},Qd={mode:`light`,background:{default:`#f5f5f5`,paper:`#ffff`}},$d=e=>{let t=Xd(),n=(e||(t?`dark`:`light`))===`dark`;return Mr({palette:{...n?Zd:Qd,primary:{main:`#E91E63`,light:`#F48FB1`,dark:`#AD1457`,contrastText:`#fff`},secondary:{main:`#e4e6eb`,light:`#f0f2f5`,dark:`#b0b3b8`,contrastText:`rgba(0, 0, 0, 0.87)`},error:{main:`#d32f2f`,light:`#ef5350`,dark:`#c62828`,contrastText:`#fff`},warning:{main:`#ed6c02`,light:`#ff9800`,dark:`#e65100`,contrastText:`#fff`},info:{main:`#0288d1`,light:`#03a9f4`,dark:`#01579b`,contrastText:`#fff`},success:{main:`#2e7d32`,light:`#4caf50`,dark:`#1b5e20`,contrastText:`#fff`}},typography:{fontFamily:[`-apple-system`,`BlinkMacSystemFont`,`"Segoe UI"`,`Roboto`,`"Helvetica Neue"`,`Arial`,`sans-serif`,`"Apple Color Emoji"`,`"Segoe UI Emoji"`,`"Segoe UI Symbol"`].join(`,`),fontSize:14,h1:{fontSize:`2.5rem`,fontWeight:500},h2:{fontSize:`2rem`,fontWeight:500},h3:{fontSize:`1.75rem`,fontWeight:500},h4:{fontSize:`1.5rem`,fontWeight:500},h5:{fontSize:`1.25rem`,fontWeight:500},h6:{fontSize:`1rem`,fontWeight:500},body1:{fontSize:`0.9375rem`,lineHeight:1.4},body2:{fontSize:`0.8125rem`,lineHeight:1.4}},shape:{borderRadius:12},components:{MuiButton:{styleOverrides:{root:{textTransform:`none`,fontWeight:500,borderRadius:20}}},MuiIconButton:{styleOverrides:{root:{borderRadius:`50%`}}},MuiPaper:{styleOverrides:{root:{backgroundImage:`none`},rounded:{borderRadius:12}}},MuiBadge:{styleOverrides:{badge:{fontSize:`0.6875rem`,height:18,minWidth:18,borderRadius:9,fontWeight:600}}},MuiCssBaseline:{styleOverrides:{body:{"*::-webkit-scrollbar":{width:`8px`,height:`8px`},"*::-webkit-scrollbar-track":{background:`undo`,borderRadius:`4px`},"*::-webkit-scrollbar-thumb":{background:`undo`,borderRadius:`4px`,"&:hover":{background:`undo`}},scrollbarWidth:`thin`,scrollbarColor:n?`#6a6a6e #333338`:`#c1c1c1 #f5f5f5`}}}}})},ef=$d();exports.CACHE_TTL=Yd,exports.ChatApp=l,exports.ChatContainer=Kd,exports.ChatHeader=Md,exports.ChatWindow=Ud,exports.ConversationItem=si,exports.ConversationItemSkeleton=ci,exports.ConversationList=jd,exports.CreateGroupDialog=Dd,exports.ErrorBoundary=Wd,exports.LoadMoreTrigger=Id,exports.MessageBubble=Pd,exports.MessageInput=Vd,exports.MessageList=Bd,exports.MessageSkeleton=Fd,exports.UnreadBadge=qd,exports.db=e.d,exports.disconnectSDK=e.i,exports.fetchSummaries=e.t,exports.getSDK=e.a,exports.getTheme=$d,exports.initSDK=e.o,exports.isSDKInitialized=e.s,exports.theme=ef,exports.useMessages=Hd,exports.useSenderNames=zd,exports.useUnreadCount=Jd,exports.useWebSocket=Gd;
package/dist/index.mjs CHANGED
@@ -6194,11 +6194,11 @@ var qf = ({ messages: e, currentUserId: t, loading: n = !1, error: r = null, aut
6194
6194
  /* @__PURE__ */ N("div", { ref: c })
6195
6195
  ]
6196
6196
  });
6197
- }, Jf = ({ onSend: e, sending: t = !1, placeholder: n = "Type a message...", disabled: r = !1 }) => {
6198
- let [i, a] = E(""), o = T(null), s = () => {
6199
- let n = i.trim();
6200
- n && !t && !r && (e(n), a(""), setTimeout(() => {
6201
- o.current?.querySelector("textarea")?.focus();
6197
+ }, Jf = ({ onSend: e, sending: t = !1, placeholder: n = "Type a message...", disabled: r = !1, disableReason: i }) => {
6198
+ let [a, o] = E(""), s = T(null), c = () => {
6199
+ let n = a.trim();
6200
+ n && !t && !r && (e(n), o(""), setTimeout(() => {
6201
+ s.current?.querySelector("textarea")?.focus();
6202
6202
  }, 300));
6203
6203
  };
6204
6204
  return /* @__PURE__ */ P(j, {
@@ -6208,23 +6208,23 @@ var qf = ({ messages: e, currentUserId: t, loading: n = !1, error: r = null, aut
6208
6208
  borderTop: 1,
6209
6209
  borderColor: "divider",
6210
6210
  children: [/* @__PURE__ */ N(Oe, {
6211
- ref: o,
6211
+ ref: s,
6212
6212
  fullWidth: !0,
6213
6213
  multiline: !0,
6214
6214
  maxRows: 4,
6215
- value: i,
6216
- onChange: (e) => a(e.target.value),
6215
+ value: a,
6216
+ onChange: (e) => o(e.target.value),
6217
6217
  onKeyDown: (e) => {
6218
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), s());
6218
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), c());
6219
6219
  },
6220
- placeholder: n,
6220
+ placeholder: r && i ? i : n,
6221
6221
  disabled: r || t,
6222
6222
  variant: "outlined",
6223
6223
  size: "small"
6224
6224
  }), /* @__PURE__ */ N(me, {
6225
6225
  color: "primary",
6226
- onClick: s,
6227
- disabled: !i.trim() || t || r,
6226
+ onClick: c,
6227
+ disabled: !a.trim() || t || r,
6228
6228
  size: "large",
6229
6229
  children: t ? /* @__PURE__ */ N(se, { size: 24 }) : /* @__PURE__ */ N(ua, {})
6230
6230
  })]
@@ -6338,7 +6338,9 @@ var Xf = ({ conversation: e, user: n, isConnected: i, onBack: a }) => {
6338
6338
  }
6339
6339
  te(!1), setTimeout(() => O(!1), 100);
6340
6340
  },
6341
- sending: w
6341
+ sending: w,
6342
+ disabled: !i,
6343
+ disableReason: i ? void 0 : "You're offline. You need to be online to send messages"
6342
6344
  })
6343
6345
  ]
6344
6346
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@college-africa/chat-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "React chat UI component library for College Africa Chat",
@@ -34,8 +34,8 @@
34
34
  "@emotion/react": "^11.0.0",
35
35
  "@emotion/styled": "^11.0.0",
36
36
  "@mui/material": "^6.0.0 || ^7.0.0",
37
- "react": "^19.0.0",
38
- "react-dom": "^19.0.0"
37
+ "react": "^17.0.0||^18.0.0||^19.0.0",
38
+ "react-dom": "^17.0.0||^18.0.0||^19.0.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "@mui/icons-material": "^7.0.0",