@availity/mui-spaces 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -17,6 +17,18 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
  var __async = (__this, __arguments, generator) => {
21
33
  return new Promise((resolve, reject) => {
22
34
  var fulfilled = (value) => {
@@ -39,7 +51,7 @@ var __async = (__this, __arguments, generator) => {
39
51
  };
40
52
 
41
53
  // src/lib/Spaces.tsx
42
- import { createContext, useContext, useReducer, useEffect } from "react";
54
+ import { createContext as createContext2, useContext as useContext2, useReducer as useReducer2, useEffect as useEffect3 } from "react";
43
55
  import { useQueries } from "@tanstack/react-query";
44
56
 
45
57
  // src/lib/spaces-data.tsx
@@ -211,13 +223,373 @@ var configurationFindMany_default = `query configurationFindMany($ids: [String!]
211
223
  }
212
224
  }`;
213
225
 
226
+ // src/lib/modals/ModalProvider.tsx
227
+ import { createContext, useContext, useReducer } from "react";
228
+ import { isAbsoluteUrl } from "@availity/resolve-url";
229
+ import { Dialog, DialogTitle, DialogActions } from "@availity/mui-dialog";
230
+ import { Button } from "@availity/mui-button";
231
+
232
+ // src/lib/helpers.tsx
233
+ import qs from "qs";
234
+ var updateUrl = (url, key, value) => {
235
+ const [uri, queryString] = url.split("?");
236
+ const currentParams = qs.parse(queryString);
237
+ const additionalParams = key && value && { [key]: value };
238
+ const newParams = qs.stringify(__spreadValues(__spreadValues({}, currentParams), additionalParams), { sort: (a, b) => a.localeCompare(b) });
239
+ return `${uri}?${newParams}`;
240
+ };
241
+ var getUrl = (url = "", loadApp, absolute) => {
242
+ if (absolute || !loadApp)
243
+ return url;
244
+ return `/public/apps/home/#!/loadApp?appUrl=${encodeURIComponent(url)}`;
245
+ };
246
+ var getTarget = (target) => {
247
+ if (target && !target.startsWith("_")) {
248
+ if (target === "BODY") {
249
+ return "_self";
250
+ }
251
+ if (target === "TAB") {
252
+ return "_blank";
253
+ }
254
+ }
255
+ return target || "_self";
256
+ };
257
+ var isFunction = (children) => typeof children === "function";
258
+ var isReactNodeFunction = (children) => typeof children === "function";
259
+
260
+ // src/lib/topApps.tsx
261
+ import avMessage from "@availity/message-core";
262
+ import dayjs from "dayjs";
263
+ var TOP_APPS = {
264
+ ALLOWED_TYPES: ["APPLICATION", "RESOURCE", "NAVIGATION"],
265
+ DISALLOWED_TYPES: ["reporting", "how_to_guide_dental_providers", "my_account_profile", "my_administrators"],
266
+ KEYS: {
267
+ VALUES: "myTopApps",
268
+ LAST_UPDATED: "top-apps-updated"
269
+ },
270
+ UPDATE_EVENT: "av:topApps:updated"
271
+ };
272
+ var getItemLocalStorage = (key) => {
273
+ try {
274
+ const value = window.localStorage.getItem(key);
275
+ if (value === null) {
276
+ return null;
277
+ }
278
+ return JSON.parse(value);
279
+ } catch (e) {
280
+ return null;
281
+ }
282
+ };
283
+ var canTrackSpace = (spaceId, type) => TOP_APPS.ALLOWED_TYPES.some((t) => t === type) && !TOP_APPS.DISALLOWED_TYPES.some((id) => id === spaceId);
284
+ var getLocalStorageTopApps = (akaname) => {
285
+ const topAppsValues = getItemLocalStorage(`${TOP_APPS.KEYS.VALUES}-${akaname}`);
286
+ return topAppsValues;
287
+ };
288
+ var updateTopApps = (space, akaname) => __async(void 0, null, function* () {
289
+ if (!space.configurationId || !space.type)
290
+ return;
291
+ if (canTrackSpace(space.configurationId, space.type)) {
292
+ const today = dayjs();
293
+ const topApps = (yield getLocalStorageTopApps(akaname)) || {};
294
+ window.localStorage.setItem(`${TOP_APPS.KEYS.LAST_UPDATED}-${akaname}`, today.format());
295
+ const currentCount = topApps[space.configurationId] && typeof topApps[space.configurationId].count === "number" ? topApps[space.configurationId].count : 0;
296
+ topApps[space.configurationId] = __spreadProps(__spreadValues({}, topApps == null ? void 0 : topApps[space.configurationId]), {
297
+ count: currentCount + 1,
298
+ lastUse: today.format()
299
+ });
300
+ window.localStorage.setItem(`${TOP_APPS.KEYS.VALUES}-${akaname}`, JSON.stringify(topApps));
301
+ avMessage.send(TOP_APPS.UPDATE_EVENT);
302
+ }
303
+ });
304
+
305
+ // src/lib/modals/DisclaimerModal.tsx
306
+ import { useState as useState2, useEffect as useEffect2 } from "react";
307
+ import { avWebQLApi as avWebQLApi2 } from "@availity/api-axios";
308
+ import ReactMarkdown from "react-markdown";
309
+
310
+ // ../progress/src/lib/CircularProgress.tsx
311
+ import { useEffect, useState } from "react";
312
+ import {
313
+ default as MuiCircularProgress
314
+ } from "@mui/material/CircularProgress";
315
+ import Stack from "@mui/material/Stack";
316
+ import { SuccessCircleIcon, WarningCircleIcon } from "@availity/mui-icon";
317
+ import { Typography } from "@availity/mui-typography";
318
+ import { jsx, jsxs } from "react/jsx-runtime";
319
+ var StatusIcon = ({ status, size }) => {
320
+ const fontSize = size === "small" ? "medium" : "large";
321
+ switch (status) {
322
+ case "error":
323
+ return /* @__PURE__ */ jsx(WarningCircleIcon, { color: "error", fontSize, titleAccess: "loading error" });
324
+ case "success":
325
+ return /* @__PURE__ */ jsx(SuccessCircleIcon, { color: "success", fontSize, titleAccess: "loading successful" });
326
+ default:
327
+ return null;
328
+ }
329
+ };
330
+ var getCaptionText = (status) => ({
331
+ loading: "Loading",
332
+ error: "Loading error",
333
+ success: "Loading successful"
334
+ })[status] || "";
335
+ var CircularProgress = (_a) => {
336
+ var _b = _a, {
337
+ loadingCaption = true,
338
+ error = false,
339
+ success = false,
340
+ size = "default"
341
+ } = _b, props = __objRest(_b, [
342
+ "loadingCaption",
343
+ "error",
344
+ "success",
345
+ "size"
346
+ ]);
347
+ const [status, setStatus] = useState("loading");
348
+ useEffect(() => {
349
+ if (error) {
350
+ setStatus("error");
351
+ } else if (success) {
352
+ setStatus("success");
353
+ } else {
354
+ setStatus("loading");
355
+ }
356
+ }, [error, success]);
357
+ return /* @__PURE__ */ jsxs(Stack, { width: "fit-content", alignItems: "center", children: [
358
+ status === "loading" ? /* @__PURE__ */ jsx(
359
+ MuiCircularProgress,
360
+ __spreadProps(__spreadValues({
361
+ "aria-label": "Loading"
362
+ }, props), {
363
+ size: size === "small" ? 24 : 40,
364
+ variant: "indeterminate"
365
+ })
366
+ ) : /* @__PURE__ */ jsx(StatusIcon, { status, size }),
367
+ /* @__PURE__ */ jsx(Typography, { marginTop: "8px", variant: "caption", children: loadingCaption || error || success ? getCaptionText(status) : null })
368
+ ] });
369
+ };
370
+
371
+ // src/lib/modals/DisclaimerModal.tsx
372
+ import { DialogContent } from "@availity/mui-dialog";
373
+ import { jsx as jsx2 } from "react/jsx-runtime";
374
+ var disclaimerQuery = `query disclaimerFindOne($id: ID!) {
375
+ configurationFindOne(id: $id) {
376
+ ... on Text {
377
+ description
378
+ }
379
+ }
380
+ }`;
381
+ var DisclaimerModal = ({ disclaimerId }) => {
382
+ const [disclaimer, setDisclaimer] = useState2("");
383
+ useEffect2(() => {
384
+ const fetchDisclaimer = () => __async(void 0, null, function* () {
385
+ if (disclaimerId) {
386
+ const result = yield avWebQLApi2.create({ query: disclaimerQuery, variables: { id: disclaimerId } });
387
+ setDisclaimer(result.data.data.configurationFindOne.description);
388
+ }
389
+ });
390
+ fetchDisclaimer();
391
+ }, [disclaimerId]);
392
+ return /* @__PURE__ */ jsx2(DialogContent, { children: disclaimer ? /* @__PURE__ */ jsx2(ReactMarkdown, { children: disclaimer }) : /* @__PURE__ */ jsx2(CircularProgress, {}) });
393
+ };
394
+
395
+ // src/lib/modals/MultiPayerModal.tsx
396
+ import { DialogContent as DialogContent2 } from "@availity/mui-dialog";
397
+ import { Grid, Box } from "@availity/mui-layout";
398
+ import { Typography as Typography2 } from "@availity/mui-typography";
399
+
400
+ // src/lib/SpacesImage.tsx
401
+ import { Img } from "react-image";
402
+ import { jsx as jsx3 } from "react/jsx-runtime";
403
+ var SpacesImage = (_a) => {
404
+ var _b = _a, { spaceId, payerId, imageType = "url", fallback } = _b, props = __objRest(_b, ["spaceId", "payerId", "imageType", "fallback"]);
405
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
406
+ let spaces;
407
+ if (spaceId) {
408
+ spaces = useSpaces(spaceId);
409
+ } else if (payerId) {
410
+ spaces = useSpaces(payerId);
411
+ }
412
+ const { loading } = useSpacesContext();
413
+ const id = spaceId || payerId || (spaces == null ? void 0 : spaces[0].id) || (spaces == null ? void 0 : spaces[0].configurationId);
414
+ const imageMap = {
415
+ "images.logo": (_b2 = (_a2 = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _a2.images) == null ? void 0 : _b2.logo,
416
+ "images.tile": (_d = (_c = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _c.images) == null ? void 0 : _d.tile,
417
+ "images.billboard": (_f = (_e = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _e.images) == null ? void 0 : _f.billboard,
418
+ "images.promotional": (_h = (_g = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _g.images) == null ? void 0 : _h.promotional,
419
+ "images.promotionalHover": (_j = (_i = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _i.images) == null ? void 0 : _j.promotionalHover,
420
+ url: (_k = spaces == null ? void 0 : spaces[0]) == null ? void 0 : _k.url
421
+ };
422
+ let url = imageMap[imageType];
423
+ if (!url && loading) {
424
+ return /* @__PURE__ */ jsx3(CircularProgress, { id: `app-${id}-loading` });
425
+ }
426
+ if (!url && !loading && fallback) {
427
+ url = fallback;
428
+ }
429
+ if (!url || !id)
430
+ return null;
431
+ return /* @__PURE__ */ jsx3(
432
+ Img,
433
+ __spreadValues({
434
+ id: props.id || `app-img-${id}`,
435
+ src: url,
436
+ alt: `Space ${imageType}`,
437
+ loader: /* @__PURE__ */ jsx3(CircularProgress, { id: `app-img-${id}-loading` })
438
+ }, props)
439
+ );
440
+ };
441
+
442
+ // src/lib/modals/MultiPayerModal.tsx
443
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
444
+ var MultiPayerModal = ({ parentPayerSpaces, name, state: { selectedOption }, setState }) => /* @__PURE__ */ jsxs2(DialogContent2, { children: [
445
+ /* @__PURE__ */ jsx4(Typography2, { children: `Open ${name} as: ${selectedOption ? selectedOption.name || selectedOption.id : ""}` }),
446
+ /* @__PURE__ */ jsx4(Grid, { direction: "row", children: parentPayerSpaces && parentPayerSpaces.map((payerSpace) => /* @__PURE__ */ jsx4(Box, { onClick: () => setState({ selectedOption: payerSpace }), children: /* @__PURE__ */ jsx4(SpacesImage, { spaceId: payerSpace.configurationId, imageType: "images.tile" }) })) })
447
+ ] });
448
+
449
+ // src/lib/modals/modal-types.tsx
450
+ var isModalOptions = (action) => action.spaceType !== void 0;
451
+ var isModalState = (action) => action.selectedOption !== void 0;
452
+
453
+ // src/lib/modals/ModalProvider.tsx
454
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
455
+ var MODAL_INITIAL_STATE = {
456
+ isOpen: false,
457
+ modalOptions: void 0,
458
+ modalState: { selectedOption: { id: "", name: "" } },
459
+ selectedModal: {}
460
+ };
461
+ var ModalContext = createContext(null);
462
+ var useModal = () => {
463
+ const ctx = useContext(ModalContext);
464
+ if (!ctx)
465
+ throw new Error("ModalContext be used inside a Provider");
466
+ return ctx;
467
+ };
468
+ var MODAL_TYPES = {
469
+ DISCLAIMER: {
470
+ body: DisclaimerModal,
471
+ buttonProps: () => ({
472
+ children: "Accept"
473
+ }),
474
+ onSubmit: ({ link, id: spaceId }) => {
475
+ var _a;
476
+ window.open(((_a = link.url) == null ? void 0 : _a[0]) === "/" ? updateUrl(link.url, "spaceId", spaceId) : link.url, link.target);
477
+ }
478
+ },
479
+ MULTI_PAYER: {
480
+ body: MultiPayerModal,
481
+ buttonProps: ({ selectedOption }) => ({
482
+ children: "Continue",
483
+ disabled: selectedOption === void 0
484
+ }),
485
+ onSubmit: ({ metadata, link, id: spaceId, name }, modalState, dispatch) => {
486
+ if (metadata == null ? void 0 : metadata.disclaimerId) {
487
+ dispatch({ type: "OPEN_DISCLAIMER_MODAL", disclaimerId: metadata.disclaimerId, link, id: spaceId, name });
488
+ return;
489
+ }
490
+ const target = getTarget(link.target);
491
+ if (link.url) {
492
+ window.open(
493
+ !isAbsoluteUrl(link.url) ? getUrl(updateUrl(link.url, "spaceId", modalState.selectedOption.id), false, false) : link.url,
494
+ target
495
+ );
496
+ }
497
+ }
498
+ }
499
+ };
500
+ var modalActions = {
501
+ RESET: () => MODAL_INITIAL_STATE,
502
+ OPEN_DISCLAIMER_MODAL: (state, modalOptions) => __spreadProps(__spreadValues({}, state), {
503
+ isOpen: true,
504
+ selectedModal: MODAL_TYPES.DISCLAIMER,
505
+ modalOptions: __spreadProps(__spreadValues({}, modalOptions), { type: modalOptions.spaceType })
506
+ }),
507
+ OPEN_MULTI_PAYER_MODAL: (state, modalOptions) => __spreadProps(__spreadValues({}, state), {
508
+ isOpen: true,
509
+ selectedModal: MODAL_TYPES.MULTI_PAYER,
510
+ modalOptions: __spreadProps(__spreadValues({}, modalOptions), {
511
+ type: modalOptions.spaceType
512
+ })
513
+ }),
514
+ UPDATE_MODAL_STATE: (state, modalState) => __spreadProps(__spreadValues({}, state), {
515
+ modalState
516
+ })
517
+ };
518
+ var modalReducer = (state, _a) => {
519
+ var _b = _a, { type } = _b, action = __objRest(_b, ["type"]);
520
+ if (type === "RESET")
521
+ return modalActions.RESET();
522
+ if (isModalOptions(action)) {
523
+ if (type === "OPEN_MULTI_PAYER_MODAL")
524
+ return modalActions.OPEN_MULTI_PAYER_MODAL(state, action);
525
+ else if (type === "OPEN_DISCLAIMER_MODAL")
526
+ return modalActions.OPEN_DISCLAIMER_MODAL(state, action);
527
+ } else if (isModalState(action)) {
528
+ if (type === "UPDATE_MODAL_STATE")
529
+ return modalActions.UPDATE_MODAL_STATE(state, action);
530
+ }
531
+ return state;
532
+ };
533
+ var ModalProvider = ({ children }) => {
534
+ const [{ selectedModal, modalOptions, modalState, isOpen }, dispatch] = useReducer(modalReducer, MODAL_INITIAL_STATE);
535
+ const toggle = () => dispatch({ type: "RESET" });
536
+ const buttonProps = (selectedModal == null ? void 0 : selectedModal.buttonProps) && (selectedModal == null ? void 0 : selectedModal.buttonProps(__spreadProps(__spreadValues({}, modalState), { modalOptions })));
537
+ const Body = selectedModal == null ? void 0 : selectedModal.body;
538
+ return /* @__PURE__ */ jsxs3(
539
+ ModalContext.Provider,
540
+ {
541
+ value: (modalType, modalOptions2) => dispatch(__spreadValues({ type: `OPEN_${modalType}` }, modalOptions2)),
542
+ children: [
543
+ /* @__PURE__ */ jsxs3(Dialog, { open: isOpen, children: [
544
+ /* @__PURE__ */ jsx5(DialogTitle, { id: "disclaimer-header", children: modalOptions == null ? void 0 : modalOptions.title }),
545
+ Body && /* @__PURE__ */ jsx5(
546
+ Body,
547
+ __spreadProps(__spreadValues({}, modalOptions), {
548
+ setState: (newState) => dispatch(__spreadValues({ type: "UPDATE_MODAL_STATE" }, newState)),
549
+ state: modalState
550
+ })
551
+ ),
552
+ /* @__PURE__ */ jsxs3(DialogActions, { children: [
553
+ /* @__PURE__ */ jsx5(Button, { onClick: toggle, children: "Cancel" }),
554
+ /* @__PURE__ */ jsx5(
555
+ Button,
556
+ __spreadProps(__spreadValues({
557
+ color: "primary"
558
+ }, buttonProps), {
559
+ onClick: () => {
560
+ if ((selectedModal == null ? void 0 : selectedModal.onSubmit) && modalOptions && modalState) {
561
+ selectedModal.onSubmit(modalOptions, modalState, dispatch);
562
+ }
563
+ if (modalOptions) {
564
+ updateTopApps(
565
+ {
566
+ configurationId: modalOptions.id,
567
+ type: modalOptions.type,
568
+ name: modalOptions.name,
569
+ id: modalOptions.id
570
+ },
571
+ modalOptions.user
572
+ );
573
+ }
574
+ toggle();
575
+ }
576
+ })
577
+ )
578
+ ] })
579
+ ] }),
580
+ children
581
+ ]
582
+ }
583
+ );
584
+ };
585
+
214
586
  // src/lib/Spaces.tsx
215
- import { jsx } from "react/jsx-runtime";
587
+ import { jsx as jsx6 } from "react/jsx-runtime";
216
588
  var INITIAL_STATE = {
217
589
  loading: true
218
590
  };
219
- var SpacesContext = createContext(INITIAL_STATE);
220
- var useSpacesContext = () => useContext(SpacesContext);
591
+ var SpacesContext = createContext2(INITIAL_STATE);
592
+ var useSpacesContext = () => useContext2(SpacesContext);
221
593
  var Spaces = ({
222
594
  query = configurationFindMany_default,
223
595
  variables = { types: ["PAYERSPACE"] },
@@ -227,7 +599,7 @@ var Spaces = ({
227
599
  spaceIds,
228
600
  spaces: spacesFromProps
229
601
  }) => {
230
- const [{ previousSpacesMap, previousSpacesByConfigMap, previousSpacesByPayerMap, loading, error }, dispatch] = useReducer(spacesReducer, INITIAL_STATE);
602
+ const [{ previousSpacesMap, previousSpacesByConfigMap, previousSpacesByPayerMap, loading, error }, dispatch] = useReducer2(spacesReducer, INITIAL_STATE);
231
603
  const spacesMap = new Map(previousSpacesMap);
232
604
  const configIdsMap = new Map(previousSpacesByConfigMap);
233
605
  const payerIdsMap = new Map(previousSpacesByPayerMap);
@@ -286,7 +658,7 @@ var Spaces = ({
286
658
  }
287
659
  ]
288
660
  });
289
- useEffect(() => {
661
+ useEffect3(() => {
290
662
  if (isErrorByPayerIds || isErrorBySpaceIds) {
291
663
  dispatch({
292
664
  type: "ERROR",
@@ -295,7 +667,7 @@ var Spaces = ({
295
667
  });
296
668
  }
297
669
  }, [isErrorByPayerIds, isErrorBySpaceIds]);
298
- useEffect(() => {
670
+ useEffect3(() => {
299
671
  dispatch({
300
672
  type: "LOADING",
301
673
  loading: true
@@ -357,17 +729,22 @@ var Spaces = ({
357
729
  loading: false
358
730
  });
359
731
  }, [spacesBySpaceIds, spacesByPayerIds, payerIds, spaceIds]);
360
- return /* @__PURE__ */ jsx(
732
+ const spacesChildren = () => {
733
+ if (children) {
734
+ return isReactNodeFunction(children) ? (() => children({ spaces: [spacesMap.values()], loading, error }))() : children;
735
+ }
736
+ };
737
+ return /* @__PURE__ */ jsx6(
361
738
  SpacesContext.Provider,
362
739
  {
363
- children,
364
740
  value: {
365
741
  spaces: spacesMap,
366
742
  spacesByConfig: configIdsMap,
367
743
  spacesByPayer: payerIdsMap,
368
744
  loading: loading || isLoadingByPayerIds || isLoadingBySpaceIds,
369
745
  error
370
- }
746
+ },
747
+ children: /* @__PURE__ */ jsx6(ModalProvider, { children: spacesChildren() })
371
748
  }
372
749
  );
373
750
  };
@@ -393,10 +770,821 @@ var useSpaces = (...ids) => {
393
770
  }
394
771
  }, []);
395
772
  };
773
+
774
+ // src/lib/SpacesLink/SpacesLink.tsx
775
+ import dayjs2 from "dayjs";
776
+
777
+ // ../card/src/lib/Card.tsx
778
+ import { default as MuiCard } from "@mui/material/Card";
779
+ import { jsx as jsx7 } from "react/jsx-runtime";
780
+ var Card = (_a) => {
781
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
782
+ return /* @__PURE__ */ jsx7(MuiCard, __spreadProps(__spreadValues({}, rest), { children }));
783
+ };
784
+
785
+ // ../card/src/lib/CardActionArea.tsx
786
+ import {
787
+ default as MuiCardActionArea
788
+ } from "@mui/material/CardActionArea";
789
+ import { jsx as jsx8 } from "react/jsx-runtime";
790
+
791
+ // ../card/src/lib/CardActions.tsx
792
+ import { default as MuiCardActions } from "@mui/material/CardActions";
793
+ import { jsx as jsx9 } from "react/jsx-runtime";
794
+
795
+ // ../card/src/lib/CardContent.tsx
796
+ import { default as MuiCardContent } from "@mui/material/CardContent";
797
+ import { jsx as jsx10 } from "react/jsx-runtime";
798
+ var CardContent = (_a) => {
799
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
800
+ return /* @__PURE__ */ jsx10(MuiCardContent, __spreadProps(__spreadValues({}, rest), { children }));
801
+ };
802
+
803
+ // ../card/src/lib/CardHeader.tsx
804
+ import { useTheme } from "@mui/material/styles";
805
+ import { default as MuiCardHeader } from "@mui/material/CardHeader";
806
+ import { jsx as jsx11 } from "react/jsx-runtime";
807
+ var CardHeader = (_a) => {
808
+ var _b = _a, {
809
+ titleTypographyProps,
810
+ subheaderTypographyProps
811
+ } = _b, rest = __objRest(_b, [
812
+ "titleTypographyProps",
813
+ "subheaderTypographyProps"
814
+ ]);
815
+ var _a2, _b2, _c, _d;
816
+ const theme = useTheme();
817
+ const titleVariant = (_d = (_c = (_b2 = (_a2 = theme.components) == null ? void 0 : _a2.MuiCardHeader) == null ? void 0 : _b2.defaultProps) == null ? void 0 : _c.titleTypographyProps) == null ? void 0 : _d.variant;
818
+ return /* @__PURE__ */ jsx11(
819
+ MuiCardHeader,
820
+ __spreadProps(__spreadValues({}, rest), {
821
+ titleTypographyProps: __spreadValues({
822
+ variant: titleVariant
823
+ }, titleTypographyProps),
824
+ subheaderTypographyProps: __spreadValues({ variant: "subtitle2" }, subheaderTypographyProps)
825
+ })
826
+ );
827
+ };
828
+
829
+ // ../card/src/lib/CardMedia.tsx
830
+ import { default as MuiCardMedia } from "@mui/material/CardMedia";
831
+ import { jsx as jsx12 } from "react/jsx-runtime";
832
+
833
+ // src/lib/SpacesLink/SpacesLink.tsx
834
+ import { Typography as Typography3 } from "@availity/mui-typography";
835
+ import { NavigateTopIcon, FileIcon } from "@availity/mui-icon";
836
+ import { useMemo as useMemo2, cloneElement } from "react";
837
+
838
+ // ../chip/src/lib/Chip.tsx
839
+ import { default as MuiChip } from "@mui/material/Chip";
840
+ import { jsx as jsx13 } from "react/jsx-runtime";
841
+ var Chip = (props) => {
842
+ return /* @__PURE__ */ jsx13(MuiChip, __spreadProps(__spreadValues({}, props), { color: "default", size: "medium" }));
843
+ };
844
+
845
+ // ../chip/src/lib/StatusChip.tsx
846
+ import { default as MuiChip2 } from "@mui/material/Chip";
847
+ import { jsx as jsx14 } from "react/jsx-runtime";
848
+ var StatusChip = (_a) => {
849
+ var _b = _a, { color = "default" } = _b, rest = __objRest(_b, ["color"]);
850
+ return /* @__PURE__ */ jsx14(MuiChip2, __spreadProps(__spreadValues({ color }, rest), { size: "small" }));
851
+ };
852
+
853
+ // ../link/src/lib/Link.tsx
854
+ import { forwardRef } from "react";
855
+ import { default as MuiLink } from "@mui/material/Link";
856
+ import { OpenInNewIcon } from "@availity/mui-icon";
857
+ import { jsx as jsx15, jsxs as jsxs4 } from "react/jsx-runtime";
858
+ var ABSOLUTE_URL_REGEX = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/;
859
+ var WINDOWS_PATH_REGEX = /^[a-zA-Z]:\\/;
860
+ function isAbsoluteUrl2(url) {
861
+ if (WINDOWS_PATH_REGEX.test(url)) {
862
+ return false;
863
+ }
864
+ return ABSOLUTE_URL_REGEX.test(url);
865
+ }
866
+ var getUrl2 = (url = "") => {
867
+ return `/public/apps/home/#!/loadApp?appUrl=${encodeURIComponent(url)}`;
868
+ };
869
+ var getLocation = (href) => {
870
+ const location = document.createElement("a");
871
+ location.href = href;
872
+ return location;
873
+ };
874
+ var setRel = (url, target, absolute) => {
875
+ if (target === "_blank" && absolute) {
876
+ const dest = getLocation(url);
877
+ if (dest.hostname !== window.location.hostname) {
878
+ return "noopener noreferrer";
879
+ }
880
+ }
881
+ return void 0;
882
+ };
883
+ var Link = forwardRef((props, ref) => {
884
+ const _a = props, { href, target = "_self", children, onClick, loadApp = true, rel, iconPosition = "start" } = _a, rest = __objRest(_a, ["href", "target", "children", "onClick", "loadApp", "rel", "iconPosition"]);
885
+ const absolute = isAbsoluteUrl2(href);
886
+ const encode = !(absolute || !loadApp);
887
+ const url = encode ? getUrl2(href) : href;
888
+ const NewWindowIcon = target === "_blank" ? /* @__PURE__ */ jsx15(OpenInNewIcon, {}) : null;
889
+ const startIcon = iconPosition === "start";
890
+ const endIcon = iconPosition === "end";
891
+ return /* @__PURE__ */ jsx15(
892
+ MuiLink,
893
+ __spreadProps(__spreadValues({
894
+ href: url,
895
+ target,
896
+ onClick: (event) => onClick && onClick(event, url),
897
+ rel: rel || setRel(url, target, absolute)
898
+ }, rest), {
899
+ ref,
900
+ children: /* @__PURE__ */ jsxs4("span", { children: [
901
+ startIcon && NewWindowIcon,
902
+ " ",
903
+ children,
904
+ " ",
905
+ endIcon && NewWindowIcon
906
+ ] })
907
+ })
908
+ );
909
+ });
910
+
911
+ // ../favorites/src/lib/Favorites.tsx
912
+ import { createContext as createContext3, useContext as useContext3, useEffect as useEffect4, useState as useState3, useMemo } from "react";
913
+ import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
914
+ import avMessages2 from "@availity/message-core";
915
+
916
+ // ../favorites/src/lib/utils.ts
917
+ import avMessages from "@availity/message-core";
918
+ import { avSettingsApi } from "@availity/api-axios";
919
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
920
+
921
+ // ../favorites/src/lib/Favorites.tsx
922
+ import { jsx as jsx16 } from "react/jsx-runtime";
923
+ var FavoritesContext = createContext3(null);
924
+ var noOp = () => {
925
+ };
926
+ var useFavorites = (id) => {
927
+ const context = useContext3(FavoritesContext);
928
+ if (context === null) {
929
+ throw new Error("useFavorites must be used within a FavoritesProvider");
930
+ }
931
+ const { favorites, queryStatus, mutationStatus, lastClickedFavoriteId, deleteFavorite, addFavorite } = context;
932
+ const isLastClickedFavorite = lastClickedFavoriteId === id;
933
+ const isFavorited = useMemo(() => {
934
+ const fav = favorites == null ? void 0 : favorites.find((f) => f.id === id);
935
+ return !!fav;
936
+ }, [favorites, id]);
937
+ const toggleFavorite = () => isFavorited ? deleteFavorite(id) : addFavorite(id);
938
+ const isDisabled = queryStatus === "loading" || queryStatus === "idle" || mutationStatus === "loading";
939
+ let status = "initLoading";
940
+ if (queryStatus === "loading")
941
+ status = "initLoading";
942
+ if (mutationStatus === "loading")
943
+ status = "reloading";
944
+ if (queryStatus === "error" || mutationStatus === "error")
945
+ status = "error";
946
+ if (queryStatus === "success" && (mutationStatus === "success" || mutationStatus === "idle"))
947
+ status = "success";
948
+ return {
949
+ isFavorited,
950
+ status,
951
+ isLastClickedFavorite,
952
+ toggleFavorite: isDisabled ? noOp : toggleFavorite
953
+ };
954
+ };
955
+
956
+ // ../tooltip/src/lib/Tooltip.tsx
957
+ import { default as MuiTooltip } from "@mui/material/Tooltip";
958
+ import { jsx as jsx17 } from "react/jsx-runtime";
959
+ var Tooltip = (props) => {
960
+ const _a = props, { children, dangerouslySetTransitionTimer } = _a, rest = __objRest(_a, ["children", "dangerouslySetTransitionTimer"]);
961
+ return /* @__PURE__ */ jsx17(
962
+ MuiTooltip,
963
+ __spreadProps(__spreadValues({}, rest), {
964
+ TransitionProps: { timeout: dangerouslySetTransitionTimer !== void 0 ? dangerouslySetTransitionTimer : 100 },
965
+ arrow: true,
966
+ children
967
+ })
968
+ );
969
+ };
970
+
971
+ // ../favorites/src/lib/FavoriteHeart.tsx
972
+ import { HeartIcon, HeartEmptyIcon } from "@availity/mui-icon";
973
+ import { styled } from "@mui/material/styles";
974
+ import { jsx as jsx18, jsxs as jsxs5 } from "react/jsx-runtime";
975
+ var icons = {
976
+ spinner: /* @__PURE__ */ jsx18(CircularProgress, { "aria-hidden": true, size: "small", loadingCaption: false }),
977
+ unknownDisabledHeart: /* @__PURE__ */ jsx18(HeartIcon, { "aria-hidden": true, color: "disabled" }),
978
+ favoritedDisabledHeart: /* @__PURE__ */ jsx18(HeartIcon, { "aria-hidden": true, color: "error", opacity: "0.6" }),
979
+ unfavoritedDisabledHeart: /* @__PURE__ */ jsx18(HeartEmptyIcon, { "aria-hidden": true, color: "disabled", opacity: "0.6" }),
980
+ favoritedHeart: /* @__PURE__ */ jsx18(HeartIcon, { "aria-hidden": true, color: "error" }),
981
+ unfavoritedHeart: /* @__PURE__ */ jsx18(HeartEmptyIcon, { "aria-hidden": true, color: "secondary" })
982
+ };
983
+ var FavoriteHeartContainer = styled("div", { name: "AvFavoriteHeart", slot: "root" })({});
984
+ var FavoriteInput = styled("input", {
985
+ name: "AvFavoriteHeart",
986
+ slot: "input"
987
+ })({});
988
+ var FavoriteIcon = styled("div", {
989
+ name: "AvFavoriteHeart",
990
+ slot: "icon"
991
+ })({});
992
+ var FavoriteHeart = ({
993
+ id,
994
+ name,
995
+ onChange,
996
+ onMouseDown,
997
+ disabled = false
998
+ }) => {
999
+ const { isFavorited, isLastClickedFavorite, status, toggleFavorite } = useFavorites(id);
1000
+ const handleChange = (event) => {
1001
+ onChange == null ? void 0 : onChange(isFavorited, event);
1002
+ toggleFavorite();
1003
+ };
1004
+ const handleKeyPress = (event) => {
1005
+ if (event.code === "Enter" || event.key === "Enter") {
1006
+ onChange == null ? void 0 : onChange(isFavorited, event);
1007
+ toggleFavorite();
1008
+ }
1009
+ };
1010
+ const iconKey = (() => {
1011
+ if (status === "initLoading")
1012
+ return "unknownDisabledHeart";
1013
+ if (status === "reloading") {
1014
+ if (isLastClickedFavorite)
1015
+ return "spinner";
1016
+ return isFavorited ? "favoritedDisabledHeart" : "unfavoritedDisabledHeart";
1017
+ }
1018
+ if (disabled) {
1019
+ return isFavorited ? "favoritedDisabledHeart" : "unfavoritedDisabledHeart";
1020
+ }
1021
+ if (isFavorited)
1022
+ return "favoritedHeart";
1023
+ return "unfavoritedHeart";
1024
+ })();
1025
+ const cursor = disabled || !isLastClickedFavorite && (status === "initLoading" || status === "reloading") ? "not-allowed" : void 0;
1026
+ const tooltipContent = `${isFavorited ? "Remove from" : "Add to"} My Favorites`;
1027
+ const favoriteInputProps = {
1028
+ onKeyDown: handleKeyPress,
1029
+ type: "checkbox",
1030
+ "aria-label": `Favorite ${name}`,
1031
+ id: `av-favorite-heart-${id}`,
1032
+ disabled,
1033
+ checked: isFavorited,
1034
+ onChange: handleChange,
1035
+ onMouseDown,
1036
+ style: { cursor }
1037
+ };
1038
+ return /* @__PURE__ */ jsxs5(FavoriteHeartContainer, { children: [
1039
+ /* @__PURE__ */ jsx18(FavoriteIcon, { children: icons[iconKey] }),
1040
+ /* @__PURE__ */ jsx18(
1041
+ "span",
1042
+ {
1043
+ style: {
1044
+ position: "absolute",
1045
+ width: "1px",
1046
+ height: "1px",
1047
+ padding: 0,
1048
+ margin: "-1px",
1049
+ overflow: "hidden",
1050
+ clip: "rect(0,0,0,0)",
1051
+ whiteSpace: "nowrap",
1052
+ border: 0
1053
+ },
1054
+ "aria-live": isLastClickedFavorite && (status === "reloading" || status === "error") ? "polite" : "off",
1055
+ children: isLastClickedFavorite && status === "reloading" ? "Loading..." : isLastClickedFavorite && status === "error" ? "An error has occurred. Please try again." : ""
1056
+ }
1057
+ ),
1058
+ disabled ? /* @__PURE__ */ jsx18(FavoriteInput, __spreadValues({}, favoriteInputProps)) : /* @__PURE__ */ jsx18(Tooltip, { title: tooltipContent, placement: "top", children: /* @__PURE__ */ jsx18(FavoriteInput, __spreadValues({}, favoriteInputProps)) })
1059
+ ] });
1060
+ };
1061
+
1062
+ // src/lib/SpacesLink/SpacesLink.tsx
1063
+ import { Grid as Grid2, Box as Box2 } from "@availity/mui-layout";
1064
+
1065
+ // ../list/src/lib/List.tsx
1066
+ import MuiList from "@mui/material/List";
1067
+ import { jsx as jsx19 } from "react/jsx-runtime";
1068
+
1069
+ // ../list/src/lib/ListItem.tsx
1070
+ import MuiListItem from "@mui/material/ListItem";
1071
+ import { forwardRef as forwardRef2 } from "react";
1072
+ import { jsx as jsx20 } from "react/jsx-runtime";
1073
+ var ListItem = forwardRef2((props, ref) => {
1074
+ return /* @__PURE__ */ jsx20(MuiListItem, __spreadProps(__spreadValues({}, props), { ref }));
1075
+ });
1076
+
1077
+ // ../list/src/lib/ListItemAvatar.tsx
1078
+ import MuiListItemAvatar from "@mui/material/ListItemAvatar";
1079
+ import { jsx as jsx21 } from "react/jsx-runtime";
1080
+
1081
+ // ../list/src/lib/ListItemButton.tsx
1082
+ import MuiListItemButton from "@mui/material/ListItemButton";
1083
+ import { forwardRef as forwardRef3 } from "react";
1084
+ import { jsx as jsx22 } from "react/jsx-runtime";
1085
+ var ListItemButton = forwardRef3((props, ref) => {
1086
+ return /* @__PURE__ */ jsx22(MuiListItemButton, __spreadProps(__spreadValues({}, props), { ref }));
1087
+ });
1088
+
1089
+ // ../list/src/lib/ListItemIcon.tsx
1090
+ import MuiListItemIcon from "@mui/material/ListItemIcon";
1091
+ import { jsx as jsx23 } from "react/jsx-runtime";
1092
+
1093
+ // ../list/src/lib/ListItemStatusCard.tsx
1094
+ import { forwardRef as forwardRef4 } from "react";
1095
+ import { styled as styled2, useThemeProps } from "@mui/material/styles";
1096
+ import MuiListItem2 from "@mui/material/ListItem";
1097
+ import { jsx as jsx24, jsxs as jsxs6 } from "react/jsx-runtime";
1098
+ var ListItemStatusCardSlot = styled2(MuiListItem2, {
1099
+ name: "AvListItemStatusCard",
1100
+ slot: "root",
1101
+ overridesResolver: (props, styles) => [styles.root, props.color && styles.color]
1102
+ })(({ theme, ownerState }) => __spreadValues({
1103
+ backgroundColor: theme.palette.background.paper,
1104
+ border: `1px solid ${theme.palette.divider}`,
1105
+ borderRadius: "4px",
1106
+ marginBottom: "4px",
1107
+ paddingLeft: "8px",
1108
+ "&.MuiListItem-padding.MuiListItem-gutters": {
1109
+ paddingLeft: "calc(16px + 8px)"
1110
+ }
1111
+ }, ownerState.color && ownerState.color !== "default" && {
1112
+ ".AvListItemStatusCard-statusAccent": {
1113
+ backgroundColor: `${theme.palette[ownerState.color].main}`
1114
+ }
1115
+ }));
1116
+ var StatusAccent = styled2("div", {
1117
+ name: "AvListItemStatusCard",
1118
+ slot: "statusAccent",
1119
+ overridesResolver: (props, styles) => [styles.statusAccent, props.color && styles.color]
1120
+ })(({ theme }) => ({
1121
+ position: "absolute",
1122
+ left: 0,
1123
+ top: 0,
1124
+ height: "100%",
1125
+ width: "8px",
1126
+ backgroundColor: theme.palette.divider,
1127
+ backgroundClip: "border-box",
1128
+ borderTopLeftRadius: "3px",
1129
+ borderBottomLeftRadius: "3px",
1130
+ content: "''"
1131
+ }));
1132
+ var ListItemStatusCard = forwardRef4((props, ref) => {
1133
+ const _a = props, { alignItems = "flex-start", children, color } = _a, rest = __objRest(_a, ["alignItems", "children", "color"]);
1134
+ const themeProps = useThemeProps({ props, name: "AvListItemStatusCard" });
1135
+ const ownerState = __spreadProps(__spreadValues({}, themeProps), { color });
1136
+ return /* @__PURE__ */ jsxs6(ListItemStatusCardSlot, __spreadProps(__spreadValues({ alignItems, divider: false, ownerState }, rest), { ref, children: [
1137
+ /* @__PURE__ */ jsx24(StatusAccent, { className: "AvListItemStatusCard-statusAccent" }),
1138
+ children
1139
+ ] }));
1140
+ });
1141
+
1142
+ // ../list/src/lib/ListItemText.tsx
1143
+ import MuiListItemText from "@mui/material/ListItemText";
1144
+ import { jsx as jsx25 } from "react/jsx-runtime";
1145
+ var ListItemText = (_a) => {
1146
+ var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
1147
+ return /* @__PURE__ */ jsx25(MuiListItemText, __spreadProps(__spreadValues({}, rest), { children }));
1148
+ };
1149
+
1150
+ // ../list/src/lib/ListSubheader.tsx
1151
+ import MuiListSubheader from "@mui/material/ListSubheader";
1152
+ import { jsx as jsx26 } from "react/jsx-runtime";
1153
+
1154
+ // src/lib/SpacesLink/SpacesLink.tsx
1155
+ import ReactMarkdown2 from "react-markdown";
1156
+
1157
+ // src/lib/SpacesLink/useLink.tsx
1158
+ import { useCurrentUser } from "@availity/hooks";
1159
+
1160
+ // src/lib/SpacesLink/linkHandlers.tsx
1161
+ import nativeForm from "@availity/native-form";
1162
+ import { isAbsoluteUrl as isAbsoluteUrl3 } from "@availity/resolve-url";
1163
+ var openLink = (space, params) => __async(void 0, null, function* () {
1164
+ var _a, _b, _c;
1165
+ if (!((_a = space == null ? void 0 : space.link) == null ? void 0 : _a.url)) {
1166
+ return;
1167
+ }
1168
+ if (params == null ? void 0 : params.akaname)
1169
+ yield updateTopApps(space, params.akaname);
1170
+ const url = !isAbsoluteUrl3(space.link.url) ? getUrl(updateUrl(space.link.url, "spaceId", (params == null ? void 0 : params.payerSpaceId) || ((_c = (_b = space.parents) == null ? void 0 : _b[0]) == null ? void 0 : _c.id)), false, false) : space.link.url;
1171
+ const target = getTarget(space.link.target);
1172
+ window.open(url, target);
1173
+ });
1174
+ var openLinkWithSso = (_0, _1) => __async(void 0, [_0, _1], function* (space, { akaname, clientId, payerSpaceId, ssoParams }) {
1175
+ var _a;
1176
+ if (space.meta && space.meta.ssoId) {
1177
+ const options = ((_a = space.link) == null ? void 0 : _a.target) ? { target: getTarget(space.link.target) } : void 0;
1178
+ const attributes = __spreadValues({
1179
+ X_Client_ID: clientId,
1180
+ X_XSRF_TOKEN: document.cookie.replace(/(?:(?:^|.*;\s*)XSRF-TOKEN\s*=\s*([^;]*).*$)|^.*$/, "$1"),
1181
+ spaceId: payerSpaceId
1182
+ }, ssoParams);
1183
+ try {
1184
+ if (akaname)
1185
+ yield updateTopApps(space, akaname);
1186
+ yield nativeForm(space.meta.ssoId, attributes, options, space.type);
1187
+ } catch (e) {
1188
+ console.warn("Something went wrong");
1189
+ }
1190
+ return false;
1191
+ }
1192
+ return false;
1193
+ });
1194
+
1195
+ // src/lib/SpacesLink/useLink.tsx
1196
+ var isSsoSpace = (space) => (space == null ? void 0 : space.type) === "saml" || (space == null ? void 0 : space.type) === "openid";
1197
+ var useLink = (spaceOrSpaceId, options) => {
1198
+ var _a, _b, _c, _d;
1199
+ const spaceFromSpacesProvider = useSpaces(
1200
+ (typeof spaceOrSpaceId === "string" ? spaceOrSpaceId : spaceOrSpaceId == null ? void 0 : spaceOrSpaceId.id) || ""
1201
+ );
1202
+ const { data: user } = useCurrentUser();
1203
+ const openModal = useModal();
1204
+ const space = spaceFromSpacesProvider == null ? void 0 : spaceFromSpacesProvider[0];
1205
+ const parentPayerSpaces = (_a = space == null ? void 0 : space.parents) == null ? void 0 : _a.filter(
1206
+ (p) => p.type && (p.type.toLowerCase() === "space" || p.type.toLowerCase() === "payerspace")
1207
+ );
1208
+ const legacySso = () => {
1209
+ var _a2;
1210
+ if (space && ((_a2 = space.meta) == null ? void 0 : _a2.disclaimerId) && space.link) {
1211
+ openModal("DISCLAIMER_MODAL", {
1212
+ disclaimerId: space.meta.disclaimerId,
1213
+ name: space.name,
1214
+ spaceType: space.type,
1215
+ id: space.configurationId,
1216
+ title: space.name,
1217
+ description: space.description,
1218
+ link: space.link,
1219
+ user: user == null ? void 0 : user.akaname
1220
+ });
1221
+ }
1222
+ };
1223
+ const openMultiPayerModal = () => {
1224
+ if (space && space.link)
1225
+ openModal("MULTI_PAYER_MODAL", {
1226
+ title: "Open Link as Payer",
1227
+ name: space == null ? void 0 : space.name,
1228
+ parentPayerSpaces,
1229
+ link: space == null ? void 0 : space.link,
1230
+ id: space == null ? void 0 : space.configurationId,
1231
+ spaceType: space == null ? void 0 : space.type,
1232
+ metadata: space == null ? void 0 : space.meta,
1233
+ user: user == null ? void 0 : user.akaname
1234
+ });
1235
+ };
1236
+ const mediaProps = {
1237
+ role: "link"
1238
+ };
1239
+ if (isSsoSpace(space) && ((_b = space == null ? void 0 : space.meta) == null ? void 0 : _b.ssoId)) {
1240
+ if (!(options == null ? void 0 : options.clientId)) {
1241
+ throw new Error("clientId is required for SSO spaces");
1242
+ }
1243
+ if (!options.linkAttributes) {
1244
+ throw new Error("linkAttributes are required for SSO spaces");
1245
+ }
1246
+ mediaProps.onClick = (event) => {
1247
+ event.preventDefault();
1248
+ if (options.clientId && options.linkAttributes) {
1249
+ openLinkWithSso(space, {
1250
+ akaname: user == null ? void 0 : user.akaname,
1251
+ clientId: options.clientId,
1252
+ payerSpaceId: options.linkAttributes.spaceId,
1253
+ ssoParams: options.linkAttributes
1254
+ });
1255
+ }
1256
+ };
1257
+ mediaProps.onKeyDown = (event) => {
1258
+ if (event.key === "Enter") {
1259
+ event.preventDefault();
1260
+ if (options.clientId && options.linkAttributes) {
1261
+ openLinkWithSso(space, {
1262
+ akaname: user == null ? void 0 : user.akaname,
1263
+ clientId: options.clientId,
1264
+ payerSpaceId: options.linkAttributes.spaceId,
1265
+ ssoParams: options.linkAttributes
1266
+ });
1267
+ }
1268
+ }
1269
+ };
1270
+ } else if ((_c = space == null ? void 0 : space.meta) == null ? void 0 : _c.disclaimerId) {
1271
+ mediaProps.onClick = legacySso;
1272
+ mediaProps.onKeyDown = (event) => {
1273
+ if (event.key === "Enter")
1274
+ return legacySso();
1275
+ };
1276
+ } else if (parentPayerSpaces && parentPayerSpaces.length > 1 && !((_d = options == null ? void 0 : options.linkAttributes) == null ? void 0 : _d.spaceId)) {
1277
+ mediaProps.onClick = openMultiPayerModal;
1278
+ mediaProps.onKeyDown = (event) => {
1279
+ if (event.key === "Enter")
1280
+ return openMultiPayerModal();
1281
+ };
1282
+ } else {
1283
+ mediaProps.onClick = () => {
1284
+ var _a2;
1285
+ if (space)
1286
+ return openLink(space, { akaname: user == null ? void 0 : user.akaname, payerSpaceId: (_a2 = options == null ? void 0 : options.linkAttributes) == null ? void 0 : _a2.spaceId });
1287
+ };
1288
+ mediaProps.onKeyDown = (event) => {
1289
+ var _a2;
1290
+ if (event.key === "Enter" && space)
1291
+ return openLink(space, { akaname: user == null ? void 0 : user.akaname, payerSpaceId: (_a2 = options == null ? void 0 : options.linkAttributes) == null ? void 0 : _a2.spaceId });
1292
+ };
1293
+ }
1294
+ return [space, mediaProps];
1295
+ };
1296
+
1297
+ // src/lib/SpacesLink/SpacesLink.tsx
1298
+ import { jsx as jsx27, jsxs as jsxs7 } from "react/jsx-runtime";
1299
+ var getDisplayDate = (date) => dayjs2(date).format("MM/DD/YYYY");
1300
+ var getContainerTag = (propTag, variant) => {
1301
+ if (variant && variant !== "default")
1302
+ return { card: Card, list: ListItem }[variant];
1303
+ return propTag || "div";
1304
+ };
1305
+ var getBodyTag = (propTag, variant) => {
1306
+ if (variant && variant !== "default")
1307
+ return { card: CardContent, list: "div" }[variant];
1308
+ return propTag || "div";
1309
+ };
1310
+ var getTitleTag = (propTag, variant) => {
1311
+ if (variant && variant !== "default")
1312
+ return { card: CardHeader, list: Typography3 }[variant];
1313
+ return propTag || "div";
1314
+ };
1315
+ var getTextTag = (propTag, variant) => {
1316
+ if (variant && variant !== "default")
1317
+ return { card: Typography3, list: ListItemText }[variant];
1318
+ return propTag || "div";
1319
+ };
1320
+ var SpacesLink = (_a) => {
1321
+ var _b = _a, {
1322
+ spaceId,
1323
+ space: propSpace,
1324
+ className,
1325
+ children,
1326
+ favorite,
1327
+ icon,
1328
+ showName = true,
1329
+ showNew,
1330
+ showDate,
1331
+ stacked,
1332
+ body = true,
1333
+ description: showDescription,
1334
+ tag,
1335
+ bodyTag,
1336
+ titleTag,
1337
+ textTag,
1338
+ titleClassName,
1339
+ variant = "default",
1340
+ loading: propsLoading,
1341
+ clientId: propsClientId,
1342
+ maxDescriptionWidth,
1343
+ style,
1344
+ linkAttributes,
1345
+ role,
1346
+ analytics,
1347
+ customBadgeText,
1348
+ customBadgeColor,
1349
+ idPrefix = ""
1350
+ } = _b, rest = __objRest(_b, [
1351
+ "spaceId",
1352
+ "space",
1353
+ "className",
1354
+ "children",
1355
+ "favorite",
1356
+ "icon",
1357
+ "showName",
1358
+ "showNew",
1359
+ "showDate",
1360
+ "stacked",
1361
+ "body",
1362
+ "description",
1363
+ "tag",
1364
+ "bodyTag",
1365
+ "titleTag",
1366
+ "textTag",
1367
+ "titleClassName",
1368
+ "variant",
1369
+ "loading",
1370
+ "clientId",
1371
+ "maxDescriptionWidth",
1372
+ "style",
1373
+ "linkAttributes",
1374
+ "role",
1375
+ "analytics",
1376
+ "customBadgeText",
1377
+ "customBadgeColor",
1378
+ "idPrefix"
1379
+ ]);
1380
+ var _a2, _b2;
1381
+ const { loading } = useSpacesContext();
1382
+ const isLoading = loading || propsLoading;
1383
+ const [linkSpace, props] = useLink(propSpace || spaceId, { clientId: propsClientId, linkAttributes });
1384
+ const showUrl = !(linkSpace == null ? void 0 : linkSpace.isGhosted) && ((_a2 = linkSpace == null ? void 0 : linkSpace.link) == null ? void 0 : _a2.url);
1385
+ const favoriteIcon = useMemo2(
1386
+ () => (linkSpace == null ? void 0 : linkSpace.configurationId) && favorite && /* @__PURE__ */ jsx27(
1387
+ FavoriteHeart,
1388
+ {
1389
+ id: `${idPrefix}${linkSpace == null ? void 0 : linkSpace.configurationId}`,
1390
+ name: linkSpace == null ? void 0 : linkSpace.name,
1391
+ onChange: (_, e) => e.stopPropagation()
1392
+ }
1393
+ ),
1394
+ [favorite, linkSpace == null ? void 0 : linkSpace.configurationId, linkSpace == null ? void 0 : linkSpace.name, idPrefix]
1395
+ );
1396
+ const dateInfo = useMemo2(
1397
+ () => (showNew || showDate) && /* @__PURE__ */ jsxs7(Grid2, { textAlign: stacked ? "center" : "inherit", children: [
1398
+ showNew && (linkSpace == null ? void 0 : linkSpace.isNew) && /* @__PURE__ */ jsx27(Chip, { id: `${idPrefix}app-new-badge-${linkSpace == null ? void 0 : linkSpace.configurationId}`, label: "New!" }),
1399
+ showDate && /* @__PURE__ */ jsx27(
1400
+ Typography3,
1401
+ {
1402
+ id: `${idPrefix}app-date-badge-${linkSpace == null ? void 0 : linkSpace.configurationId}`,
1403
+ variant: "caption",
1404
+ color: "textSecondary",
1405
+ children: getDisplayDate(linkSpace == null ? void 0 : linkSpace.activeDate)
1406
+ }
1407
+ )
1408
+ ] }),
1409
+ [linkSpace == null ? void 0 : linkSpace.activeDate, linkSpace == null ? void 0 : linkSpace.isNew, showDate, showNew, stacked, linkSpace == null ? void 0 : linkSpace.configurationId, idPrefix]
1410
+ );
1411
+ const customBadgeDisplay = useMemo2(
1412
+ () => customBadgeText && /* @__PURE__ */ jsx27(
1413
+ Box2,
1414
+ {
1415
+ textAlign: stacked ? "center" : "inherit",
1416
+ marginRight: variant !== "card" && (showDate || showNew && (linkSpace == null ? void 0 : linkSpace.isNew)) ? 2 : void 0,
1417
+ children: /* @__PURE__ */ jsx27(
1418
+ StatusChip,
1419
+ {
1420
+ color: customBadgeColor || "info",
1421
+ id: `${idPrefix}app-custom-badge-${linkSpace == null ? void 0 : linkSpace.configurationId}-${customBadgeText}`,
1422
+ label: customBadgeText
1423
+ }
1424
+ )
1425
+ }
1426
+ ),
1427
+ [
1428
+ customBadgeColor,
1429
+ customBadgeText,
1430
+ showDate,
1431
+ showNew,
1432
+ stacked,
1433
+ variant,
1434
+ linkSpace == null ? void 0 : linkSpace.isNew,
1435
+ idPrefix,
1436
+ linkSpace == null ? void 0 : linkSpace.configurationId
1437
+ ]
1438
+ );
1439
+ if (isLoading) {
1440
+ return /* @__PURE__ */ jsx27(CircularProgress, __spreadValues({ id: `${idPrefix}app-${linkSpace == null ? void 0 : linkSpace.configurationId}-loading` }, rest));
1441
+ }
1442
+ const Tag = getContainerTag(tag, variant);
1443
+ const BodyTag = getBodyTag(bodyTag, variant);
1444
+ const TitleTag = getTitleTag(titleTag, variant);
1445
+ const TextTag = getTextTag(textTag, variant);
1446
+ const renderChildren = () => {
1447
+ if (children) {
1448
+ return isFunction(children) ? (() => children(__spreadValues(__spreadValues(__spreadValues({}, linkSpace), analytics), props)))() : cloneElement(children, __spreadValues(__spreadValues({
1449
+ role: "link",
1450
+ tabIndex: 0,
1451
+ style: { cursor: showUrl ? "pointer" : "not-allowed" },
1452
+ "aria-label": linkSpace == null ? void 0 : linkSpace.name
1453
+ }, analytics), props));
1454
+ }
1455
+ };
1456
+ return /* @__PURE__ */ jsx27(
1457
+ Tag,
1458
+ __spreadProps(__spreadValues({
1459
+ title: linkSpace == null ? void 0 : linkSpace.name,
1460
+ className
1461
+ }, rest), {
1462
+ style: __spreadValues({}, style),
1463
+ role: variant === "list" ? "listitem" : role,
1464
+ children: /* @__PURE__ */ jsx27(BodyTag, { children: /* @__PURE__ */ jsxs7(Grid2, { alignItems: !showDescription || stacked ? "center" : "start", direction: stacked ? "column" : "row", children: [
1465
+ !stacked && favoriteIcon,
1466
+ icon && (linkSpace == null ? void 0 : linkSpace.url) && ((_b2 = linkSpace == null ? void 0 : linkSpace.type) == null ? void 0 : _b2.toUpperCase()) === "FILE" ? /* @__PURE__ */ jsx27(Link, { target: "_blank", href: linkSpace == null ? void 0 : linkSpace.url, children: /* @__PURE__ */ jsx27(FileIcon, { "data-testid": "icon" }) }) : /* @__PURE__ */ jsx27(NavigateTopIcon, { "data-testid": "icon" }),
1467
+ children ? renderChildren() : body && /* @__PURE__ */ jsxs7(Grid2, { id: `${idPrefix}${linkSpace == null ? void 0 : linkSpace.type}-${linkSpace == null ? void 0 : linkSpace.configurationId}`, children: [
1468
+ /* @__PURE__ */ jsx27(
1469
+ Box2,
1470
+ {
1471
+ marginBottom: !customBadgeDisplay && (!showDescription || !(linkSpace == null ? void 0 : linkSpace.description)) ? 0 : void 0,
1472
+ paddingTop: stacked ? 3 : void 0,
1473
+ textAlign: stacked ? "center" : void 0,
1474
+ children: /* @__PURE__ */ jsx27(
1475
+ TitleTag,
1476
+ __spreadProps(__spreadValues(__spreadValues({
1477
+ id: `${idPrefix}app-title-${linkSpace == null ? void 0 : linkSpace.configurationId}`,
1478
+ className: titleClassName,
1479
+ tabIndex: 0,
1480
+ style: {
1481
+ cursor: showUrl ? "pointer" : "not-allowed"
1482
+ }
1483
+ }, analytics), props), {
1484
+ role: showUrl ? "link" : role,
1485
+ "aria-label": linkSpace == null ? void 0 : linkSpace.name,
1486
+ "aria-describedby": showNew && (linkSpace == null ? void 0 : linkSpace.isNew) ? `${idPrefix}app-new-badge-${linkSpace == null ? void 0 : linkSpace.configurationId}` : void 0,
1487
+ variant: variant === "list" ? "h5" : "h6",
1488
+ title: showName ? linkSpace == null ? void 0 : linkSpace.name : void 0,
1489
+ children: showName ? linkSpace == null ? void 0 : linkSpace.name : void 0
1490
+ })
1491
+ )
1492
+ }
1493
+ ),
1494
+ stacked && dateInfo,
1495
+ showDescription && (linkSpace == null ? void 0 : linkSpace.description) && /* @__PURE__ */ jsx27(
1496
+ TextTag,
1497
+ {
1498
+ marginTop: 1,
1499
+ textAlign: stacked ? "center" : void 0,
1500
+ overflow: "hidden",
1501
+ whiteSpace: maxDescriptionWidth ? "nowrap" : void 0,
1502
+ width: maxDescriptionWidth,
1503
+ textOverflow: "ellipsis",
1504
+ id: `${idPrefix}app-description-${linkSpace == null ? void 0 : linkSpace.configurationId}`,
1505
+ children: /* @__PURE__ */ jsx27(ReactMarkdown2, { className: "Card-text", children: linkSpace == null ? void 0 : linkSpace.description })
1506
+ }
1507
+ ),
1508
+ variant === "card" && customBadgeDisplay
1509
+ ] }),
1510
+ variant !== "card" && customBadgeDisplay,
1511
+ !stacked && dateInfo
1512
+ ] }) })
1513
+ })
1514
+ );
1515
+ };
1516
+
1517
+ // src/lib/SpacesAgreement.tsx
1518
+ import { Typography as Typography4 } from "@availity/mui-typography";
1519
+ import ReactMarkdown3 from "react-markdown";
1520
+ import { jsx as jsx28 } from "react/jsx-runtime";
1521
+ var SpacesAgreement = ({ spaceId, markdown = false, id: elementId }) => {
1522
+ const spaces = useSpaces(spaceId);
1523
+ if (spaces && spaces.length > 0) {
1524
+ const { description: agreement, id } = spaces[0];
1525
+ if (agreement) {
1526
+ const children = markdown ? /* @__PURE__ */ jsx28(ReactMarkdown3, { children: agreement }) : agreement;
1527
+ return /* @__PURE__ */ jsx28(Typography4, { variant: "agreement", id: elementId || `spaces-agreement-${spaceId || id}`, children });
1528
+ }
1529
+ }
1530
+ return null;
1531
+ };
1532
+
1533
+ // src/lib/SpacesDisclaimer.tsx
1534
+ import { Disclaimer } from "@availity/mui-disclaimer";
1535
+ import ReactMarkdown4 from "react-markdown";
1536
+ import { jsx as jsx29 } from "react/jsx-runtime";
1537
+ var SpacesDisclaimer = (_a) => {
1538
+ var _b = _a, {
1539
+ accent = true,
1540
+ spaceId,
1541
+ markdown = false,
1542
+ id: elementId
1543
+ } = _b, props = __objRest(_b, [
1544
+ "accent",
1545
+ "spaceId",
1546
+ "markdown",
1547
+ "id"
1548
+ ]);
1549
+ const spaces = useSpaces(spaceId);
1550
+ if (spaces && spaces.length > 0) {
1551
+ const { description: disclaimer, id } = spaces[0];
1552
+ if (disclaimer) {
1553
+ const children = markdown ? /* @__PURE__ */ jsx29(ReactMarkdown4, { children: disclaimer }) : disclaimer;
1554
+ return /* @__PURE__ */ jsx29(
1555
+ Disclaimer,
1556
+ __spreadValues({
1557
+ accent,
1558
+ id: elementId || `spaces-disclaimer-${spaceId || id}`,
1559
+ description: children
1560
+ }, props)
1561
+ );
1562
+ }
1563
+ }
1564
+ return null;
1565
+ };
1566
+
1567
+ // src/lib/SpacesGhostText.tsx
1568
+ import { jsx as jsx30 } from "react/jsx-runtime";
1569
+ var SpacesGhostText = (_a) => {
1570
+ var _b = _a, { spaceId, id } = _b, props = __objRest(_b, ["spaceId", "id"]);
1571
+ var _a2;
1572
+ const spaces = useSpaces(spaceId);
1573
+ const space = spaces == null ? void 0 : spaces[0];
1574
+ if (space == null ? void 0 : space.isGhosted) {
1575
+ return /* @__PURE__ */ jsx30("small", __spreadProps(__spreadValues({ id: id || `app-ghost-text-${spaceId}` }, props), { children: /* @__PURE__ */ jsx30("em", { children: (_a2 = space == null ? void 0 : space.meta) == null ? void 0 : _a2.ghostText }) }));
1576
+ }
1577
+ return null;
1578
+ };
396
1579
  export {
397
1580
  INITIAL_STATE,
398
1581
  Spaces,
1582
+ SpacesAgreement,
399
1583
  SpacesContext,
1584
+ SpacesDisclaimer,
1585
+ SpacesGhostText,
1586
+ SpacesImage,
1587
+ SpacesLink,
400
1588
  useSpaces,
401
1589
  useSpacesContext
402
1590
  };