@blocklet/discuss-kit-ux 1.6.253 → 1.6.255
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/components/chat/chat-client.d.ts +1 -1
- package/dist/components/chat/context.d.ts +1 -1
- package/dist/components/chat/hooks.d.ts +1 -0
- package/dist/components/chat/unread-notification.d.ts +1 -0
- package/dist/components/editor/preview.d.ts +3 -0
- package/dist/components/posts/comment.d.ts +1 -1
- package/dist/{editor-CxgvO4o6.mjs → editor-DHGKk8sm.mjs} +1 -1
- package/dist/{index-CNu5t46j.mjs → index-DxtzXjYS.mjs} +38 -911
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +178 -1052
- package/package.json +8 -7
package/dist/index.umd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("react-dom"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("semver-compare"), require("@arcblock/bridge"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "react-dom", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "semver-compare", "@arcblock/bridge", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "@mui/icons-material/Add", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.Theme, global.
|
|
3
|
-
})(this, function(exports2, labels, jsxRuntime, styles, Theme,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@blocklet/labels"), require("react/jsx-runtime"), require("@mui/material/styles"), require("@arcblock/ux/lib/Theme"), require("react"), require("@mui/material"), require("lodash/isNil"), require("@blocklet/editor/lib/config"), require("react-lazy-with-preload"), require("@lexical/react/LexicalComposerContext"), require("lexical"), require("ahooks"), require("@mui/material/Box"), require("@mui/lab/LoadingButton"), require("@mui/icons-material"), require("@arcblock/ux/lib/Locale/context"), require("@mui/material/Alert"), require("lodash/isBoolean"), require("@mui/material/Button"), require("@arcblock/did-connect/lib/Avatar"), require("@mui/material/AvatarGroup"), require("@mui/material/colors"), require("@mui/material/useMediaQuery"), require("@arcblock/ux/lib/DID"), require("@mui/material/Tooltip"), require("react-router-dom"), require("@arcblock/ux/lib/RelativeTime"), require("@mui/material/Chip"), require("@mui/material/Stack"), require("lodash/groupBy"), require("lodash/flatMap"), require("lodash/uniqBy"), require("lodash/trim"), require("@mui/material/Avatar"), require("@mui/icons-material/BrokenImage"), require("@iconify/react"), require("@arcblock/ux/lib/Empty"), require("@arcblock/did-connect/lib/Session"), require("@mui/icons-material/NotificationsActiveOutlined"), require("@blocklet/editor/lib/ext/CheckboxPlugin"), require("@arcblock/did-connect/lib/Address"), require("@mui/material/MenuItem"), require("clsx"), require("@mui/material/IconButton"), require("@mui/material/Menu"), require("@arcblock/ux/lib/Dialog"), require("lodash/orderBy"), require("@mui/material/Typography"), require("@mui/material/Skeleton"), require("url-join"), require("react-dom"), require("dayjs"), require("dayjs/plugin/relativeTime"), require("mitt"), require("@mui/material/CircularProgress"), require("react-helmet"), require("react-flip-toolkit"), require("@mui/material/colors/grey"), require("semver-compare"), require("@arcblock/bridge"), require("@arcblock/react-hooks"), require("@mui/material/Fab"), require("lodash/debounce"), require("@mui/material/TextField"), require("@mui/icons-material/Add"), require("axios"), require("@arcblock/ux/lib/Toast"), require("@mui/material/Pagination"), require("unstated-next"), require("js-cookie"), require("@arcblock/ws"), require("@emotion/css"), require("@blocklet/editor/lib/ext/OnContentChangePlugin"), require("@blocklet/editor/lib/ext/ShortcutPlugin"), require("@blocklet/editor/lib/ext/SafeAreaPlugin"), require("@lexical/text"), require("@blocklet/editor/lib/main/nodes/ImageNode"), require("@blocklet/editor/lib/ext/VideoPlugin/VideoNode")) : typeof define === "function" && define.amd ? define(["exports", "@blocklet/labels", "react/jsx-runtime", "@mui/material/styles", "@arcblock/ux/lib/Theme", "react", "@mui/material", "lodash/isNil", "@blocklet/editor/lib/config", "react-lazy-with-preload", "@lexical/react/LexicalComposerContext", "lexical", "ahooks", "@mui/material/Box", "@mui/lab/LoadingButton", "@mui/icons-material", "@arcblock/ux/lib/Locale/context", "@mui/material/Alert", "lodash/isBoolean", "@mui/material/Button", "@arcblock/did-connect/lib/Avatar", "@mui/material/AvatarGroup", "@mui/material/colors", "@mui/material/useMediaQuery", "@arcblock/ux/lib/DID", "@mui/material/Tooltip", "react-router-dom", "@arcblock/ux/lib/RelativeTime", "@mui/material/Chip", "@mui/material/Stack", "lodash/groupBy", "lodash/flatMap", "lodash/uniqBy", "lodash/trim", "@mui/material/Avatar", "@mui/icons-material/BrokenImage", "@iconify/react", "@arcblock/ux/lib/Empty", "@arcblock/did-connect/lib/Session", "@mui/icons-material/NotificationsActiveOutlined", "@blocklet/editor/lib/ext/CheckboxPlugin", "@arcblock/did-connect/lib/Address", "@mui/material/MenuItem", "clsx", "@mui/material/IconButton", "@mui/material/Menu", "@arcblock/ux/lib/Dialog", "lodash/orderBy", "@mui/material/Typography", "@mui/material/Skeleton", "url-join", "react-dom", "dayjs", "dayjs/plugin/relativeTime", "mitt", "@mui/material/CircularProgress", "react-helmet", "react-flip-toolkit", "@mui/material/colors/grey", "semver-compare", "@arcblock/bridge", "@arcblock/react-hooks", "@mui/material/Fab", "lodash/debounce", "@mui/material/TextField", "@mui/icons-material/Add", "axios", "@arcblock/ux/lib/Toast", "@mui/material/Pagination", "unstated-next", "js-cookie", "@arcblock/ws", "@emotion/css", "@blocklet/editor/lib/ext/OnContentChangePlugin", "@blocklet/editor/lib/ext/ShortcutPlugin", "@blocklet/editor/lib/ext/SafeAreaPlugin", "@lexical/text", "@blocklet/editor/lib/main/nodes/ImageNode", "@blocklet/editor/lib/ext/VideoPlugin/VideoNode"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.DiscussKitComponents = {}, global.labels, global.jsxRuntime, global.styles, global.Theme, global.react, global.material, global.isNil, global.config, global.reactLazyWithPreload, global.LexicalComposerContext, global.lexical$1, global.ahooks, global.Box, global.LoadingButton, global.iconsMaterial, global.context, global.Alert, global.isBoolean, global.Button, global.DidAvatar, global.AvatarGroup, global.colors, global.useMediaQuery, global.DID, global.Tooltip, global.reactRouterDom, global.UxRelativeTime, global.Chip, global.Stack, global.groupBy, global.flatMap, global.uniqBy, global.trim, global.Avatar$1, global.BrokenImageIcon, global.react$1, global.Empty$3, global.Session, global.NotificationsActiveOutlinedIcon, global.CheckboxPlugin, global.DIDAddress, global.MuiMenuItem, global.clsx, global.IconButton$1, global.MuiMenu, global.Dialog, global.orderBy, global.Typography, global.Skeleton, global.joinUrl, global.ReactDOM, global.dayjs, global.relativeTime, global.mitt, global.CircularProgress, global.reactHelmet, global.reactFlipToolkit, global.grey, global.cmp, global.bridge, global.reactHooks, global.Fab, global.debounce, global.TextField, global.AddIcon, global.axios, global.Toast, global.MuiPagination, global.unstatedNext, global.Cookie, global.ws, global.css, global.OnContentChangePlugin, global.ShortcutPlugin, global.SafeAreaPlugin, global.text, global.ImageNode, global.VideoNode));
|
|
3
|
+
})(this, function(exports2, labels, jsxRuntime, styles, Theme, react, material, isNil, config, reactLazyWithPreload, LexicalComposerContext, lexical$1, ahooks, Box, LoadingButton, iconsMaterial, context, Alert, isBoolean, Button, DidAvatar, AvatarGroup, colors, useMediaQuery, DID, Tooltip, reactRouterDom, UxRelativeTime, Chip, Stack, groupBy, flatMap, uniqBy, trim, Avatar$1, BrokenImageIcon, react$1, Empty$3, Session, NotificationsActiveOutlinedIcon, CheckboxPlugin, DIDAddress, MuiMenuItem, clsx, IconButton$1, MuiMenu, Dialog, orderBy, Typography, Skeleton, joinUrl, ReactDOM, dayjs, relativeTime, mitt, CircularProgress, reactHelmet, reactFlipToolkit, grey, cmp, bridge, reactHooks, Fab, debounce, TextField, AddIcon, axios, Toast, MuiPagination, unstatedNext, Cookie, ws, css, OnContentChangePlugin, ShortcutPlugin, SafeAreaPlugin, text, ImageNode, VideoNode) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => {
|
|
@@ -365,7 +365,7 @@ var __publicField = (obj, key, value) => {
|
|
|
365
365
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
366
366
|
function CmdEnterShortcutPlugin({ callback, shortcut = "CMD_ENTER" }) {
|
|
367
367
|
const [editor2] = LexicalComposerContext.useLexicalComposerContext();
|
|
368
|
-
|
|
368
|
+
react.useEffect(() => {
|
|
369
369
|
return editor2.registerCommand(
|
|
370
370
|
lexical$1.KEY_ENTER_COMMAND,
|
|
371
371
|
(e) => {
|
|
@@ -406,7 +406,7 @@ var __publicField = (obj, key, value) => {
|
|
|
406
406
|
}
|
|
407
407
|
function ImagePathFixerPlugin() {
|
|
408
408
|
const [editor2] = LexicalComposerContext.useLexicalComposerContext();
|
|
409
|
-
|
|
409
|
+
react.useEffect(() => {
|
|
410
410
|
return editor2.registerNodeTransform(ImageNode.ImageNode, imageNodeTransform);
|
|
411
411
|
}, [editor2]);
|
|
412
412
|
return null;
|
|
@@ -431,14 +431,14 @@ var __publicField = (obj, key, value) => {
|
|
|
431
431
|
}
|
|
432
432
|
function VideoPathFixerPlugin() {
|
|
433
433
|
const [editor2] = LexicalComposerContext.useLexicalComposerContext();
|
|
434
|
-
|
|
434
|
+
react.useEffect(() => {
|
|
435
435
|
return editor2.registerNodeTransform(VideoNode.VideoNode, VideoNodeTransform);
|
|
436
436
|
}, [editor2]);
|
|
437
437
|
return null;
|
|
438
438
|
}
|
|
439
439
|
function AutoClearPlugin({ value, isChanged }) {
|
|
440
440
|
const [editor2] = LexicalComposerContext.useLexicalComposerContext();
|
|
441
|
-
|
|
441
|
+
react.useEffect(() => {
|
|
442
442
|
try {
|
|
443
443
|
if (!isChanged)
|
|
444
444
|
return;
|
|
@@ -463,7 +463,7 @@ var __publicField = (obj, key, value) => {
|
|
|
463
463
|
return null;
|
|
464
464
|
}
|
|
465
465
|
const useMeasure = () => {
|
|
466
|
-
const ref =
|
|
466
|
+
const ref = react.useRef(null);
|
|
467
467
|
const size = ahooks.useSize(ref);
|
|
468
468
|
return [ref, size || { width: 0, height: 0 }];
|
|
469
469
|
};
|
|
@@ -484,11 +484,11 @@ var __publicField = (obj, key, value) => {
|
|
|
484
484
|
}) => {
|
|
485
485
|
var _a2;
|
|
486
486
|
const sessionKey = draftKey ? `${getDraftSessionKeyPrefix()}${draftKey}` : "";
|
|
487
|
-
const [content, setContent] =
|
|
488
|
-
const [error, setError] =
|
|
489
|
-
const [loading, setLoading] =
|
|
487
|
+
const [content, setContent] = react.useState(null);
|
|
488
|
+
const [error, setError] = react.useState("");
|
|
489
|
+
const [loading, setLoading] = react.useState(false);
|
|
490
490
|
const [ref, { width }] = useMeasure();
|
|
491
|
-
const isChanged =
|
|
491
|
+
const isChanged = react.useRef(false);
|
|
492
492
|
const editorConfig = config.useEditorConfig();
|
|
493
493
|
const inSmallView = width < 700;
|
|
494
494
|
const draftContent = sessionStorage.getItem(sessionKey);
|
|
@@ -573,7 +573,7 @@ var __publicField = (obj, key, value) => {
|
|
|
573
573
|
},
|
|
574
574
|
rest.sx
|
|
575
575
|
);
|
|
576
|
-
return /* @__PURE__ */
|
|
576
|
+
return /* @__PURE__ */ react.createElement(material.Box, { ref, ...rest, key: draftKey, sx: mergedSx }, /* @__PURE__ */ jsxRuntime.jsx(config.EditorConfigProvider, { value: mergedEditorConfig, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
577
577
|
BlockletEditor$3,
|
|
578
578
|
{
|
|
579
579
|
placeholder,
|
|
@@ -612,7 +612,7 @@ var __publicField = (obj, key, value) => {
|
|
|
612
612
|
draftKey = "",
|
|
613
613
|
...rest
|
|
614
614
|
}) {
|
|
615
|
-
const { t } =
|
|
615
|
+
const { t } = react.useContext(context.LocaleContext);
|
|
616
616
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
617
617
|
StyledInput,
|
|
618
618
|
{
|
|
@@ -690,7 +690,7 @@ var __publicField = (obj, key, value) => {
|
|
|
690
690
|
);
|
|
691
691
|
}
|
|
692
692
|
function PostEdit({ content, send, onCancel, onSuccess, ...rest }) {
|
|
693
|
-
const { t } =
|
|
693
|
+
const { t } = react.useContext(context.LocaleContext);
|
|
694
694
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
695
695
|
Input,
|
|
696
696
|
{
|
|
@@ -885,7 +885,7 @@ var __publicField = (obj, key, value) => {
|
|
|
885
885
|
if (badgeIcon) {
|
|
886
886
|
const isHttpIcon = ["http", "/", "data"].some((prefix2) => badgeIcon.startsWith(prefix2));
|
|
887
887
|
if (!isHttpIcon) {
|
|
888
|
-
icon = /* @__PURE__ */ jsxRuntime.jsx(react.Icon, { className: "badge-icon", icon: badgeIcon, color: badgeColor, style: { ...iconStyle } });
|
|
888
|
+
icon = /* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { className: "badge-icon", icon: badgeIcon, color: badgeColor, style: { ...iconStyle } });
|
|
889
889
|
} else {
|
|
890
890
|
icon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
891
891
|
Avatar$1,
|
|
@@ -958,9 +958,9 @@ var __publicField = (obj, key, value) => {
|
|
|
958
958
|
}
|
|
959
959
|
const useSessionContext = () => {
|
|
960
960
|
var _a2, _b2, _c, _d;
|
|
961
|
-
const ctx =
|
|
961
|
+
const ctx = react.useContext(Session.SessionContext) || {};
|
|
962
962
|
const loginRole = (_b2 = (_a2 = ctx == null ? void 0 : ctx.session) == null ? void 0 : _a2.user) == null ? void 0 : _b2.role;
|
|
963
|
-
const permissionSet =
|
|
963
|
+
const permissionSet = react.useMemo(() => {
|
|
964
964
|
var _a3, _b3;
|
|
965
965
|
return new Set(((_b3 = (_a3 = ctx.session) == null ? void 0 : _a3.user) == null ? void 0 : _b3.permissions) || []);
|
|
966
966
|
}, [(_d = (_c = ctx.session) == null ? void 0 : _c.user) == null ? void 0 : _d.permissions]);
|
|
@@ -990,9 +990,9 @@ var __publicField = (obj, key, value) => {
|
|
|
990
990
|
return a === b;
|
|
991
991
|
};
|
|
992
992
|
const useChanged = (values2, options) => {
|
|
993
|
-
const [trackingStarted, setTrackingStarted] =
|
|
994
|
-
const [changed, setChanged] =
|
|
995
|
-
const initialValues =
|
|
993
|
+
const [trackingStarted, setTrackingStarted] = react.useState(false);
|
|
994
|
+
const [changed, setChanged] = react.useState(false);
|
|
995
|
+
const initialValues = react.useRef(values2);
|
|
996
996
|
const detectChanges = () => {
|
|
997
997
|
var _a2;
|
|
998
998
|
const changesDetected = Object.keys(initialValues.current).some(
|
|
@@ -1007,7 +1007,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1007
1007
|
initialValues.current = { ...values2, ...overrides };
|
|
1008
1008
|
detectChanges();
|
|
1009
1009
|
};
|
|
1010
|
-
|
|
1010
|
+
react.useEffect(() => {
|
|
1011
1011
|
if (trackingStarted) {
|
|
1012
1012
|
detectChanges();
|
|
1013
1013
|
} else if (options.tracking(values2) && !trackingStarted) {
|
|
@@ -1018,9 +1018,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1018
1018
|
return { changed, reset, initialValues: initialValues.current };
|
|
1019
1019
|
};
|
|
1020
1020
|
const useNow = (interval = 1e3) => {
|
|
1021
|
-
const [time, setTime] =
|
|
1021
|
+
const [time, setTime] = react.useState(/* @__PURE__ */ new Date());
|
|
1022
1022
|
const updateTime = () => setTime(/* @__PURE__ */ new Date());
|
|
1023
|
-
|
|
1023
|
+
react.useEffect(() => {
|
|
1024
1024
|
const timer = setInterval(updateTime, interval);
|
|
1025
1025
|
return () => clearInterval(timer);
|
|
1026
1026
|
}, [interval]);
|
|
@@ -1164,7 +1164,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1164
1164
|
const theme = styles.useTheme();
|
|
1165
1165
|
const downMd = useMediaQuery(theme.breakpoints.down("md"));
|
|
1166
1166
|
const navigate = reactRouterDom.useNavigate();
|
|
1167
|
-
const [open, setOpen] =
|
|
1167
|
+
const [open, setOpen] = react.useState(false);
|
|
1168
1168
|
const sm = size === "sm";
|
|
1169
1169
|
let fontSize = sm ? 12 : 14;
|
|
1170
1170
|
let avatarSize = profileUse ? 24 : sm ? 40 : 48;
|
|
@@ -1176,7 +1176,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1176
1176
|
if (!createdAt) {
|
|
1177
1177
|
return null;
|
|
1178
1178
|
}
|
|
1179
|
-
if (
|
|
1179
|
+
if (react.isValidElement(createdAt)) {
|
|
1180
1180
|
return createdAt;
|
|
1181
1181
|
}
|
|
1182
1182
|
createdAt = typeof createdAt === "string" ? new Date(createdAt) : createdAt;
|
|
@@ -1332,7 +1332,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1332
1332
|
`;
|
|
1333
1333
|
function ViewMore({ children, ...rest }) {
|
|
1334
1334
|
const { t } = context.useLocaleContext();
|
|
1335
|
-
const [collapsed, setCollapsed] =
|
|
1335
|
+
const [collapsed, setCollapsed] = react.useState(true);
|
|
1336
1336
|
const [ref, { height }] = useMeasure();
|
|
1337
1337
|
const _collapsed = collapsed && height > MAX_HEIGHT;
|
|
1338
1338
|
return /* @__PURE__ */ jsxRuntime.jsxs(Root$3, { ...rest, className: `${rest.className || ""} ${_collapsed ? "markdown-viewer-collapsed" : ""}`, children: [
|
|
@@ -1357,7 +1357,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1357
1357
|
)
|
|
1358
1358
|
] });
|
|
1359
1359
|
}
|
|
1360
|
-
const BlockletEditor$2 =
|
|
1360
|
+
const BlockletEditor$2 = react.lazy(() => import("@blocklet/editor"));
|
|
1361
1361
|
const StyledBlockletEditor = styles.styled(BlockletEditor$2)`
|
|
1362
1362
|
.editor-scroller {
|
|
1363
1363
|
min-height: initial;
|
|
@@ -1389,7 +1389,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1389
1389
|
);
|
|
1390
1390
|
}
|
|
1391
1391
|
if (!autoCollapse) {
|
|
1392
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1392
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1393
1393
|
StyledBlockletEditor,
|
|
1394
1394
|
{
|
|
1395
1395
|
editable: false,
|
|
@@ -1404,7 +1404,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1404
1404
|
}
|
|
1405
1405
|
) });
|
|
1406
1406
|
}
|
|
1407
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1407
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(ViewMore, { ...rest, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1408
1408
|
StyledBlockletEditor,
|
|
1409
1409
|
{
|
|
1410
1410
|
editable: false,
|
|
@@ -1426,7 +1426,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1426
1426
|
}
|
|
1427
1427
|
`;
|
|
1428
1428
|
function Menu({ items = [], ...rest }) {
|
|
1429
|
-
const [anchorEl, setAnchorEl] =
|
|
1429
|
+
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
1430
1430
|
const open = Boolean(anchorEl);
|
|
1431
1431
|
const handleClick = (event) => {
|
|
1432
1432
|
setAnchorEl(event.currentTarget);
|
|
@@ -1519,10 +1519,10 @@ var __publicField = (obj, key, value) => {
|
|
|
1519
1519
|
const isAuthor = post.author.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
1520
1520
|
const commentUrl = window.location.hash.substring(1);
|
|
1521
1521
|
const { t } = context.useLocaleContext();
|
|
1522
|
-
const [editing, setEditing] =
|
|
1522
|
+
const [editing, setEditing] = react.useState(false);
|
|
1523
1523
|
const postContext = { isAdmin, isAuthor, interactive, post };
|
|
1524
1524
|
const [inViewport] = ahooks.useInViewport(() => document == null ? void 0 : document.getElementById(post.id));
|
|
1525
|
-
const [hasEnteredViewport, setHasEnteredViewport] =
|
|
1525
|
+
const [hasEnteredViewport, setHasEnteredViewport] = react.useState(false);
|
|
1526
1526
|
let menuItems = [];
|
|
1527
1527
|
if (isAuthor && !post.deletedAt) {
|
|
1528
1528
|
menuItems.push(
|
|
@@ -1558,7 +1558,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1558
1558
|
systemTip = t("emptyContent");
|
|
1559
1559
|
}
|
|
1560
1560
|
const showSystemTip = systemTip && !editing;
|
|
1561
|
-
|
|
1561
|
+
react.useEffect(() => {
|
|
1562
1562
|
if (inViewport) {
|
|
1563
1563
|
setHasEnteredViewport(inViewport);
|
|
1564
1564
|
}
|
|
@@ -1662,7 +1662,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1662
1662
|
countPerValue: { ...prevState.countPerValue, [value]: (prevState.countPerValue[value] || 0) + inc }
|
|
1663
1663
|
}));
|
|
1664
1664
|
};
|
|
1665
|
-
|
|
1665
|
+
react.useEffect(() => {
|
|
1666
1666
|
setState({
|
|
1667
1667
|
countPerValue: countPerValue || {},
|
|
1668
1668
|
selectedValue
|
|
@@ -1702,15 +1702,15 @@ var __publicField = (obj, key, value) => {
|
|
|
1702
1702
|
const values = ["1", "-1"];
|
|
1703
1703
|
function BinaryThumb({ data = [], variant = "default", size = "sm", ...rest }) {
|
|
1704
1704
|
const { session } = useSessionContext();
|
|
1705
|
-
const [raterListVisible, setRaterListVisible] =
|
|
1706
|
-
const [loading, setLoading] =
|
|
1707
|
-
const countPerValue =
|
|
1705
|
+
const [raterListVisible, setRaterListVisible] = react.useState(null);
|
|
1706
|
+
const [loading, setLoading] = react.useState(false);
|
|
1707
|
+
const countPerValue = react.useMemo(() => {
|
|
1708
1708
|
return data.reduce((acc, cur) => {
|
|
1709
1709
|
acc[cur.value] = (acc[cur.value] || 0) + 1;
|
|
1710
1710
|
return acc;
|
|
1711
1711
|
}, {});
|
|
1712
1712
|
}, [data]);
|
|
1713
|
-
const selectedValue =
|
|
1713
|
+
const selectedValue = react.useMemo(() => {
|
|
1714
1714
|
var _a2;
|
|
1715
1715
|
return (_a2 = data.find((x) => {
|
|
1716
1716
|
var _a3, _b2;
|
|
@@ -1868,9 +1868,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1868
1868
|
...rest
|
|
1869
1869
|
}) {
|
|
1870
1870
|
const { session } = useSessionContext();
|
|
1871
|
-
const [open, setOpen] =
|
|
1872
|
-
const [raters, setRaters] =
|
|
1873
|
-
const [myReaction, setMyReaction] =
|
|
1871
|
+
const [open, setOpen] = react.useState(false);
|
|
1872
|
+
const [raters, setRaters] = react.useState(null);
|
|
1873
|
+
const [myReaction, setMyReaction] = react.useState(null);
|
|
1874
1874
|
const options = [
|
|
1875
1875
|
{ value: "thumbs_up", label: "👍" },
|
|
1876
1876
|
{ value: "thumbs_down", label: "👎" },
|
|
@@ -1881,7 +1881,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1881
1881
|
{ value: "rocket", label: "🚀" },
|
|
1882
1882
|
{ value: "eyes", label: "👀" }
|
|
1883
1883
|
];
|
|
1884
|
-
const ratings =
|
|
1884
|
+
const ratings = react.useMemo(() => {
|
|
1885
1885
|
var _a2;
|
|
1886
1886
|
const mapped = data.map((x) => {
|
|
1887
1887
|
var _a3;
|
|
@@ -1898,7 +1898,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1898
1898
|
}
|
|
1899
1899
|
return mapped;
|
|
1900
1900
|
}, [data, myReaction, session.user]);
|
|
1901
|
-
const countPerValue =
|
|
1901
|
+
const countPerValue = react.useMemo(() => {
|
|
1902
1902
|
return ratings.reduce((acc, cur) => {
|
|
1903
1903
|
cur.value.forEach((item) => {
|
|
1904
1904
|
acc[item] = (acc[item] || 0) + 1;
|
|
@@ -1906,14 +1906,14 @@ var __publicField = (obj, key, value) => {
|
|
|
1906
1906
|
return acc;
|
|
1907
1907
|
}, {});
|
|
1908
1908
|
}, [ratings]);
|
|
1909
|
-
const selectedValues =
|
|
1909
|
+
const selectedValues = react.useMemo(() => {
|
|
1910
1910
|
var _a2;
|
|
1911
1911
|
return ((_a2 = ratings.find((x) => {
|
|
1912
1912
|
var _a3, _b2;
|
|
1913
1913
|
return ((_a3 = x.rater) == null ? void 0 : _a3.did) === ((_b2 = session == null ? void 0 : session.user) == null ? void 0 : _b2.did);
|
|
1914
1914
|
})) == null ? void 0 : _a2.value) || [];
|
|
1915
1915
|
}, [ratings, session.user]);
|
|
1916
|
-
const selectedValuesMap =
|
|
1916
|
+
const selectedValuesMap = react.useMemo(() => {
|
|
1917
1917
|
return selectedValues.reduce((acc, cur) => ({ ...acc, [cur]: true }), {});
|
|
1918
1918
|
}, [selectedValues]);
|
|
1919
1919
|
const toggleRate = (value) => {
|
|
@@ -2082,7 +2082,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2082
2082
|
const fullScreen = material.useMediaQuery(theme.breakpoints.down("md"));
|
|
2083
2083
|
const { t } = context.useLocaleContext();
|
|
2084
2084
|
const renderDesc = () => {
|
|
2085
|
-
if (
|
|
2085
|
+
if (react.isValidElement(description)) {
|
|
2086
2086
|
return description;
|
|
2087
2087
|
}
|
|
2088
2088
|
return /* @__PURE__ */ jsxRuntime.jsx(material.DialogContentText, { children: description });
|
|
@@ -2106,12 +2106,12 @@ var __publicField = (obj, key, value) => {
|
|
|
2106
2106
|
/* @__PURE__ */ jsxRuntime.jsx(material.DialogActions, { children: renderActions() })
|
|
2107
2107
|
] });
|
|
2108
2108
|
}
|
|
2109
|
-
const ConfirmContext =
|
|
2110
|
-
const useConfirm = () =>
|
|
2109
|
+
const ConfirmContext = react.createContext({});
|
|
2110
|
+
const useConfirm = () => react.useContext(ConfirmContext);
|
|
2111
2111
|
function ConfirmProvider({ children }) {
|
|
2112
|
-
const [open, setOpen] =
|
|
2113
|
-
const [currentOptions, setCurrentOptions] =
|
|
2114
|
-
const resolver =
|
|
2112
|
+
const [open, setOpen] = react.useState(false);
|
|
2113
|
+
const [currentOptions, setCurrentOptions] = react.useState({});
|
|
2114
|
+
const resolver = react.useRef();
|
|
2115
2115
|
const handleOk = () => {
|
|
2116
2116
|
var _a2;
|
|
2117
2117
|
(_a2 = resolver.current) == null ? void 0 : _a2.call(resolver, true);
|
|
@@ -2129,7 +2129,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2129
2129
|
resolver.current = resolve;
|
|
2130
2130
|
});
|
|
2131
2131
|
};
|
|
2132
|
-
const value =
|
|
2132
|
+
const value = react.useMemo(
|
|
2133
2133
|
() => ({
|
|
2134
2134
|
open,
|
|
2135
2135
|
confirm
|
|
@@ -2168,7 +2168,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2168
2168
|
}) {
|
|
2169
2169
|
const { session } = useSessionContext();
|
|
2170
2170
|
const { t } = context.useLocaleContext();
|
|
2171
|
-
const [inputVisible, setInputVisible] =
|
|
2171
|
+
const [inputVisible, setInputVisible] = react.useState(false);
|
|
2172
2172
|
const { confirm } = useConfirm();
|
|
2173
2173
|
const handleDelete = async (...args) => {
|
|
2174
2174
|
const proceed = await confirm({
|
|
@@ -2309,9 +2309,9 @@ var __publicField = (obj, key, value) => {
|
|
|
2309
2309
|
return sorted;
|
|
2310
2310
|
};
|
|
2311
2311
|
const useAutoScroll = (data, containerHeight) => {
|
|
2312
|
-
const highlightedRef =
|
|
2313
|
-
const lastHeightRef =
|
|
2314
|
-
const autoScrolledRef =
|
|
2312
|
+
const highlightedRef = react.useRef(window.location.hash.substring(1));
|
|
2313
|
+
const lastHeightRef = react.useRef(containerHeight);
|
|
2314
|
+
const autoScrolledRef = react.useRef(false);
|
|
2315
2315
|
const matchTargetedPost = (posts) => {
|
|
2316
2316
|
return posts.some((item) => {
|
|
2317
2317
|
var _a2;
|
|
@@ -2331,7 +2331,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2331
2331
|
lastHeightRef.current = containerHeight;
|
|
2332
2332
|
return false;
|
|
2333
2333
|
};
|
|
2334
|
-
|
|
2334
|
+
react.useEffect(() => {
|
|
2335
2335
|
let interval;
|
|
2336
2336
|
if (containerHeight && !autoScrolledRef.current) {
|
|
2337
2337
|
interval = window.setInterval(() => {
|
|
@@ -2352,8 +2352,8 @@ var __publicField = (obj, key, value) => {
|
|
|
2352
2352
|
};
|
|
2353
2353
|
}, [containerHeight]);
|
|
2354
2354
|
};
|
|
2355
|
-
const CommentsContext =
|
|
2356
|
-
const useCommentsContext = () =>
|
|
2355
|
+
const CommentsContext = react.createContext({});
|
|
2356
|
+
const useCommentsContext = () => react.useContext(CommentsContext);
|
|
2357
2357
|
function CommentsProvider({
|
|
2358
2358
|
target,
|
|
2359
2359
|
api,
|
|
@@ -2370,7 +2370,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2370
2370
|
var _a2;
|
|
2371
2371
|
const [state, setState] = ahooks.useSetState(getInitialState(order ? { order } : {}));
|
|
2372
2372
|
const containerHeight = (_a2 = ahooks.useSize(containerRef)) == null ? void 0 : _a2.height;
|
|
2373
|
-
const commentsKeyById =
|
|
2373
|
+
const commentsKeyById = react.useMemo(() => {
|
|
2374
2374
|
return state.comments.reduce((acc, cur) => {
|
|
2375
2375
|
var _a3;
|
|
2376
2376
|
acc[cur.id] = cur;
|
|
@@ -2382,10 +2382,10 @@ var __publicField = (obj, key, value) => {
|
|
|
2382
2382
|
return acc;
|
|
2383
2383
|
}, {});
|
|
2384
2384
|
}, [state]);
|
|
2385
|
-
const highlightedRef =
|
|
2385
|
+
const highlightedRef = react.useRef(window.location.hash.substring(1));
|
|
2386
2386
|
const limit = 15;
|
|
2387
2387
|
const initialRepliesLimit = -1;
|
|
2388
|
-
|
|
2388
|
+
react.useEffect(() => {
|
|
2389
2389
|
const init = async () => {
|
|
2390
2390
|
if (!autoLoadComments) {
|
|
2391
2391
|
setState({ initialized: true });
|
|
@@ -2544,7 +2544,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2544
2544
|
setTimeout(() => add(result), 800);
|
|
2545
2545
|
};
|
|
2546
2546
|
const findById = (id2) => commentsKeyById[id2];
|
|
2547
|
-
const value =
|
|
2547
|
+
const value = react.useMemo(
|
|
2548
2548
|
() => ({
|
|
2549
2549
|
target,
|
|
2550
2550
|
state,
|
|
@@ -2598,7 +2598,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2598
2598
|
const hiddenComments = highlighted.position - comments.findIndex((item) => item.id === highlighted.id) + headIndex;
|
|
2599
2599
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ...rest, className: "comment-list", children: [
|
|
2600
2600
|
comments.map((comment) => {
|
|
2601
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2601
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
2602
2602
|
comment.id === (highlighted == null ? void 0 : highlighted.id) && hiddenComments > 0 && nextCursor && /* @__PURE__ */ jsxRuntime.jsx(LoadMoreButtonWrapper, { sx: { my: 4, textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2603
2603
|
Box,
|
|
2604
2604
|
{
|
|
@@ -2720,10 +2720,10 @@ var __publicField = (obj, key, value) => {
|
|
|
2720
2720
|
}
|
|
2721
2721
|
return result;
|
|
2722
2722
|
};
|
|
2723
|
-
const UploaderComponent =
|
|
2724
|
-
const UploaderContext =
|
|
2723
|
+
const UploaderComponent = react.lazy(() => import("@blocklet/uploader/react").then((res) => ({ default: res.Uploader })));
|
|
2724
|
+
const UploaderContext = react.createContext(null);
|
|
2725
2725
|
function useUploader() {
|
|
2726
|
-
const uploaderRef =
|
|
2726
|
+
const uploaderRef = react.useContext(UploaderContext);
|
|
2727
2727
|
if (!uploaderRef) {
|
|
2728
2728
|
throw new Error("useUploader must be used within an UploaderProvider");
|
|
2729
2729
|
}
|
|
@@ -2756,7 +2756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2756
2756
|
return /* @__PURE__ */ jsxRuntime.jsx(material.Box, { onClick: handleOpen, children });
|
|
2757
2757
|
}
|
|
2758
2758
|
function UploaderProvider({ children }) {
|
|
2759
|
-
const uploaderRef =
|
|
2759
|
+
const uploaderRef = react.useRef(null);
|
|
2760
2760
|
window.uploaderRef = uploaderRef;
|
|
2761
2761
|
return /* @__PURE__ */ jsxRuntime.jsxs(UploaderContext.Provider, { value: uploaderRef, children: [
|
|
2762
2762
|
children,
|
|
@@ -2789,11 +2789,11 @@ var __publicField = (obj, key, value) => {
|
|
|
2789
2789
|
fetchpriority = "auto",
|
|
2790
2790
|
loading = "eager",
|
|
2791
2791
|
shadow = true,
|
|
2792
|
-
fallback,
|
|
2792
|
+
fallback: fallback2,
|
|
2793
2793
|
...rest
|
|
2794
2794
|
}) {
|
|
2795
|
-
const [loaded, setLoaded] =
|
|
2796
|
-
const [errored, setErrored] =
|
|
2795
|
+
const [loaded, setLoaded] = react.useState(false);
|
|
2796
|
+
const [errored, setErrored] = react.useState(false);
|
|
2797
2797
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2798
2798
|
material.Box,
|
|
2799
2799
|
{
|
|
@@ -2858,7 +2858,7 @@ var __publicField = (obj, key, value) => {
|
|
|
2858
2858
|
width: "100%",
|
|
2859
2859
|
height: "100%"
|
|
2860
2860
|
},
|
|
2861
|
-
children:
|
|
2861
|
+
children: fallback2
|
|
2862
2862
|
}
|
|
2863
2863
|
)
|
|
2864
2864
|
]
|
|
@@ -3138,7 +3138,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3138
3138
|
}
|
|
3139
3139
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { ...rest, children: content });
|
|
3140
3140
|
}
|
|
3141
|
-
const BlogCard =
|
|
3141
|
+
const BlogCard = react.forwardRef(
|
|
3142
3142
|
({ post, hideAuthor, linkTarget, compactLayout, loading = false }, ref) => {
|
|
3143
3143
|
if (loading) {
|
|
3144
3144
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { sx: { display: "flex", justifyContent: "center", color: "inherit", textDecoration: "none" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -3428,22 +3428,22 @@ var __publicField = (obj, key, value) => {
|
|
|
3428
3428
|
}
|
|
3429
3429
|
) });
|
|
3430
3430
|
}
|
|
3431
|
-
const AuthzContext =
|
|
3431
|
+
const AuthzContext = react.createContext({
|
|
3432
3432
|
permissions: [],
|
|
3433
3433
|
hasPermission: () => false,
|
|
3434
3434
|
isAdmin: false,
|
|
3435
3435
|
hasAnyPassport: () => false
|
|
3436
3436
|
});
|
|
3437
|
-
const useAuthzContext = () =>
|
|
3437
|
+
const useAuthzContext = () => react.useContext(AuthzContext);
|
|
3438
3438
|
const AuthzProvider = ({ ...rest }) => {
|
|
3439
3439
|
var _a2;
|
|
3440
3440
|
const { session, isAdmin, hasAnyPassport } = useSessionContext();
|
|
3441
|
-
const permissions =
|
|
3441
|
+
const permissions = react.useMemo(() => {
|
|
3442
3442
|
var _a3;
|
|
3443
3443
|
return ((_a3 = session == null ? void 0 : session.user) == null ? void 0 : _a3.permissions) || [];
|
|
3444
3444
|
}, [(_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.permissions]);
|
|
3445
|
-
const permissionSet =
|
|
3446
|
-
const hasPermission =
|
|
3445
|
+
const permissionSet = react.useMemo(() => new Set(permissions), [permissions]);
|
|
3446
|
+
const hasPermission = react.useCallback(
|
|
3447
3447
|
(perms) => {
|
|
3448
3448
|
if (!perms || perms.length === 0) {
|
|
3449
3449
|
return true;
|
|
@@ -3453,7 +3453,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3453
3453
|
},
|
|
3454
3454
|
[permissionSet]
|
|
3455
3455
|
);
|
|
3456
|
-
const value =
|
|
3456
|
+
const value = react.useMemo(
|
|
3457
3457
|
() => ({ permissions, hasPermission, isAdmin, hasAnyPassport }),
|
|
3458
3458
|
[hasPermission, permissions, isAdmin, hasAnyPassport]
|
|
3459
3459
|
);
|
|
@@ -3512,35 +3512,42 @@ var __publicField = (obj, key, value) => {
|
|
|
3512
3512
|
}
|
|
3513
3513
|
}
|
|
3514
3514
|
const iconoirChatBubbleEmpty = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12c0 1.821.487 3.53 1.338 5L2.5 21.5l4.5-.838A9.955 9.955 0 0 0 12 22Z" }) });
|
|
3515
|
-
const UnreadNotificationContext =
|
|
3515
|
+
const UnreadNotificationContext = react.createContext(
|
|
3516
3516
|
{}
|
|
3517
3517
|
);
|
|
3518
|
-
const useUnreadNotification = () =>
|
|
3518
|
+
const useUnreadNotification = () => react.useContext(UnreadNotificationContext);
|
|
3519
3519
|
function UnreadNotificationProvider({ fetchUnreadState, children }) {
|
|
3520
3520
|
const { session } = useSessionContext();
|
|
3521
|
-
const [unread, setUnread] =
|
|
3522
|
-
const
|
|
3521
|
+
const [unread, setUnread] = react.useState(false);
|
|
3522
|
+
const [initialUnread, setInitialState] = react.useState(void 0);
|
|
3523
|
+
const markAsUnread = react.useCallback((value2 = true) => setUnread(value2), []);
|
|
3523
3524
|
const update = async () => {
|
|
3524
3525
|
const unreadState = await fetchUnreadState();
|
|
3525
3526
|
setUnread(unreadState);
|
|
3527
|
+
return unreadState;
|
|
3526
3528
|
};
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3529
|
+
react.useEffect(() => {
|
|
3530
|
+
const init = async () => {
|
|
3531
|
+
if (session.user && !preferences.disableNotificationBadge) {
|
|
3532
|
+
const unreadState = await update();
|
|
3533
|
+
setInitialState(unreadState);
|
|
3534
|
+
}
|
|
3535
|
+
};
|
|
3536
|
+
init();
|
|
3531
3537
|
}, [session.user]);
|
|
3532
|
-
const value =
|
|
3538
|
+
const value = react.useMemo(
|
|
3533
3539
|
() => ({
|
|
3534
3540
|
unread,
|
|
3541
|
+
initialUnread,
|
|
3535
3542
|
markAsUnread
|
|
3536
3543
|
}),
|
|
3537
3544
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3538
|
-
[unread]
|
|
3545
|
+
[unread, initialUnread]
|
|
3539
3546
|
);
|
|
3540
3547
|
return /* @__PURE__ */ jsxRuntime.jsx(UnreadNotificationContext.Provider, { value, children });
|
|
3541
3548
|
}
|
|
3542
|
-
const ChatContext =
|
|
3543
|
-
const useChatContext = () =>
|
|
3549
|
+
const ChatContext = react.createContext({});
|
|
3550
|
+
const useChatContext = () => react.useContext(ChatContext);
|
|
3544
3551
|
const uniqAndSort = (list, order = "asc") => {
|
|
3545
3552
|
const unique = uniqBy(list, "id");
|
|
3546
3553
|
const sorted = orderBy(unique, ["createdAt", "id"], [order, order]);
|
|
@@ -3557,7 +3564,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3557
3564
|
const navigate = reactRouterDom.useNavigate();
|
|
3558
3565
|
const { session } = useSessionContext();
|
|
3559
3566
|
const currentUser = session == null ? void 0 : session.user;
|
|
3560
|
-
const orderedChats =
|
|
3567
|
+
const orderedChats = react.useMemo(() => {
|
|
3561
3568
|
return orderBy(state.chats, (x) => x.lastMessageAt || "", "desc");
|
|
3562
3569
|
}, [state.chats]);
|
|
3563
3570
|
const hasUnreadMessages = ({ lastMessageAt, lastAckTime }) => {
|
|
@@ -3566,7 +3573,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3566
3573
|
}
|
|
3567
3574
|
return false;
|
|
3568
3575
|
};
|
|
3569
|
-
const hasAnyUnreadMessages =
|
|
3576
|
+
const hasAnyUnreadMessages = react.useMemo(
|
|
3570
3577
|
() => state.chats.filter((chat) => chat.type !== "channel" || chat.hasJoined).some(hasUnreadMessages),
|
|
3571
3578
|
[state.chats]
|
|
3572
3579
|
);
|
|
@@ -3739,7 +3746,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3739
3746
|
addChat(chat);
|
|
3740
3747
|
return chat;
|
|
3741
3748
|
};
|
|
3742
|
-
|
|
3749
|
+
react.useEffect(() => {
|
|
3743
3750
|
if (currentUser == null ? void 0 : currentUser.did) {
|
|
3744
3751
|
init();
|
|
3745
3752
|
} else {
|
|
@@ -3752,7 +3759,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3752
3759
|
}
|
|
3753
3760
|
return () => client2.destroy();
|
|
3754
3761
|
}, [currentUser == null ? void 0 : currentUser.did]);
|
|
3755
|
-
|
|
3762
|
+
react.useEffect(() => {
|
|
3756
3763
|
if (activeChatId) {
|
|
3757
3764
|
if (activeChatId !== state.activeChatId) {
|
|
3758
3765
|
const matched = state.chats.find((chat) => chat.id === activeChatId);
|
|
@@ -3764,7 +3771,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3764
3771
|
setState((prev) => ({ ...prev, activeChatId: void 0 }));
|
|
3765
3772
|
}
|
|
3766
3773
|
}, [state, activeChatId]);
|
|
3767
|
-
|
|
3774
|
+
react.useEffect(() => {
|
|
3768
3775
|
const cancels = [
|
|
3769
3776
|
client2.onMessage(({ chatId, message }) => {
|
|
3770
3777
|
addMessage(chatId, message);
|
|
@@ -3783,12 +3790,12 @@ var __publicField = (obj, key, value) => {
|
|
|
3783
3790
|
cancels.forEach((cancel) => cancel == null ? void 0 : cancel());
|
|
3784
3791
|
};
|
|
3785
3792
|
}, [state]);
|
|
3786
|
-
|
|
3793
|
+
react.useEffect(() => {
|
|
3787
3794
|
if (state.initialized) {
|
|
3788
3795
|
markAsUnread(hasAnyUnreadMessages);
|
|
3789
3796
|
}
|
|
3790
3797
|
}, [state.initialized, hasAnyUnreadMessages, markAsUnread]);
|
|
3791
|
-
const value =
|
|
3798
|
+
const value = react.useMemo(() => {
|
|
3792
3799
|
return {
|
|
3793
3800
|
...state,
|
|
3794
3801
|
client: client2,
|
|
@@ -3846,902 +3853,10 @@ var __publicField = (obj, key, value) => {
|
|
|
3846
3853
|
] })
|
|
3847
3854
|
] });
|
|
3848
3855
|
}
|
|
3849
|
-
function getAugmentedNamespace(n) {
|
|
3850
|
-
if (n.__esModule)
|
|
3851
|
-
return n;
|
|
3852
|
-
var f = n.default;
|
|
3853
|
-
if (typeof f == "function") {
|
|
3854
|
-
var a = function a2() {
|
|
3855
|
-
if (this instanceof a2) {
|
|
3856
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
3857
|
-
}
|
|
3858
|
-
return f.apply(this, arguments);
|
|
3859
|
-
};
|
|
3860
|
-
a.prototype = f.prototype;
|
|
3861
|
-
} else
|
|
3862
|
-
a = {};
|
|
3863
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
3864
|
-
Object.keys(n).forEach(function(k) {
|
|
3865
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
3866
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
3867
|
-
enumerable: true,
|
|
3868
|
-
get: function() {
|
|
3869
|
-
return n[k];
|
|
3870
|
-
}
|
|
3871
|
-
});
|
|
3872
|
-
});
|
|
3873
|
-
return a;
|
|
3874
|
-
}
|
|
3875
|
-
var lib = {};
|
|
3876
|
-
var useInterval$1 = {};
|
|
3877
|
-
Object.defineProperty(useInterval$1, "__esModule", {
|
|
3878
|
-
value: true
|
|
3879
|
-
});
|
|
3880
|
-
useInterval$1.default = useInterval;
|
|
3881
|
-
var _react$2 = require$$0;
|
|
3882
|
-
function useInterval(callback, delay) {
|
|
3883
|
-
const savedCallback = (0, _react$2.useRef)();
|
|
3884
|
-
(0, _react$2.useEffect)(() => {
|
|
3885
|
-
savedCallback.current = callback;
|
|
3886
|
-
}, [callback]);
|
|
3887
|
-
(0, _react$2.useEffect)(() => {
|
|
3888
|
-
function tick() {
|
|
3889
|
-
savedCallback.current();
|
|
3890
|
-
}
|
|
3891
|
-
if (delay !== null) {
|
|
3892
|
-
const id2 = setInterval(tick, delay);
|
|
3893
|
-
return () => clearInterval(id2);
|
|
3894
|
-
}
|
|
3895
|
-
}, [delay]);
|
|
3896
|
-
}
|
|
3897
|
-
var useStorage$1 = {};
|
|
3898
|
-
const privateData = /* @__PURE__ */ new WeakMap();
|
|
3899
|
-
const wrappers = /* @__PURE__ */ new WeakMap();
|
|
3900
|
-
function pd(event) {
|
|
3901
|
-
const retv = privateData.get(event);
|
|
3902
|
-
console.assert(
|
|
3903
|
-
retv != null,
|
|
3904
|
-
"'this' is expected an Event object, but got",
|
|
3905
|
-
event
|
|
3906
|
-
);
|
|
3907
|
-
return retv;
|
|
3908
|
-
}
|
|
3909
|
-
function setCancelFlag(data) {
|
|
3910
|
-
if (data.passiveListener != null) {
|
|
3911
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
3912
|
-
console.error(
|
|
3913
|
-
"Unable to preventDefault inside passive event listener invocation.",
|
|
3914
|
-
data.passiveListener
|
|
3915
|
-
);
|
|
3916
|
-
}
|
|
3917
|
-
return;
|
|
3918
|
-
}
|
|
3919
|
-
if (!data.event.cancelable) {
|
|
3920
|
-
return;
|
|
3921
|
-
}
|
|
3922
|
-
data.canceled = true;
|
|
3923
|
-
if (typeof data.event.preventDefault === "function") {
|
|
3924
|
-
data.event.preventDefault();
|
|
3925
|
-
}
|
|
3926
|
-
}
|
|
3927
|
-
function Event(eventTarget, event) {
|
|
3928
|
-
privateData.set(this, {
|
|
3929
|
-
eventTarget,
|
|
3930
|
-
event,
|
|
3931
|
-
eventPhase: 2,
|
|
3932
|
-
currentTarget: eventTarget,
|
|
3933
|
-
canceled: false,
|
|
3934
|
-
stopped: false,
|
|
3935
|
-
immediateStopped: false,
|
|
3936
|
-
passiveListener: null,
|
|
3937
|
-
timeStamp: event.timeStamp || Date.now()
|
|
3938
|
-
});
|
|
3939
|
-
Object.defineProperty(this, "isTrusted", { value: false, enumerable: true });
|
|
3940
|
-
const keys = Object.keys(event);
|
|
3941
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
3942
|
-
const key = keys[i];
|
|
3943
|
-
if (!(key in this)) {
|
|
3944
|
-
Object.defineProperty(this, key, defineRedirectDescriptor(key));
|
|
3945
|
-
}
|
|
3946
|
-
}
|
|
3947
|
-
}
|
|
3948
|
-
Event.prototype = {
|
|
3949
|
-
/**
|
|
3950
|
-
* The type of this event.
|
|
3951
|
-
* @type {string}
|
|
3952
|
-
*/
|
|
3953
|
-
get type() {
|
|
3954
|
-
return pd(this).event.type;
|
|
3955
|
-
},
|
|
3956
|
-
/**
|
|
3957
|
-
* The target of this event.
|
|
3958
|
-
* @type {EventTarget}
|
|
3959
|
-
*/
|
|
3960
|
-
get target() {
|
|
3961
|
-
return pd(this).eventTarget;
|
|
3962
|
-
},
|
|
3963
|
-
/**
|
|
3964
|
-
* The target of this event.
|
|
3965
|
-
* @type {EventTarget}
|
|
3966
|
-
*/
|
|
3967
|
-
get currentTarget() {
|
|
3968
|
-
return pd(this).currentTarget;
|
|
3969
|
-
},
|
|
3970
|
-
/**
|
|
3971
|
-
* @returns {EventTarget[]} The composed path of this event.
|
|
3972
|
-
*/
|
|
3973
|
-
composedPath() {
|
|
3974
|
-
const currentTarget = pd(this).currentTarget;
|
|
3975
|
-
if (currentTarget == null) {
|
|
3976
|
-
return [];
|
|
3977
|
-
}
|
|
3978
|
-
return [currentTarget];
|
|
3979
|
-
},
|
|
3980
|
-
/**
|
|
3981
|
-
* Constant of NONE.
|
|
3982
|
-
* @type {number}
|
|
3983
|
-
*/
|
|
3984
|
-
get NONE() {
|
|
3985
|
-
return 0;
|
|
3986
|
-
},
|
|
3987
|
-
/**
|
|
3988
|
-
* Constant of CAPTURING_PHASE.
|
|
3989
|
-
* @type {number}
|
|
3990
|
-
*/
|
|
3991
|
-
get CAPTURING_PHASE() {
|
|
3992
|
-
return 1;
|
|
3993
|
-
},
|
|
3994
|
-
/**
|
|
3995
|
-
* Constant of AT_TARGET.
|
|
3996
|
-
* @type {number}
|
|
3997
|
-
*/
|
|
3998
|
-
get AT_TARGET() {
|
|
3999
|
-
return 2;
|
|
4000
|
-
},
|
|
4001
|
-
/**
|
|
4002
|
-
* Constant of BUBBLING_PHASE.
|
|
4003
|
-
* @type {number}
|
|
4004
|
-
*/
|
|
4005
|
-
get BUBBLING_PHASE() {
|
|
4006
|
-
return 3;
|
|
4007
|
-
},
|
|
4008
|
-
/**
|
|
4009
|
-
* The target of this event.
|
|
4010
|
-
* @type {number}
|
|
4011
|
-
*/
|
|
4012
|
-
get eventPhase() {
|
|
4013
|
-
return pd(this).eventPhase;
|
|
4014
|
-
},
|
|
4015
|
-
/**
|
|
4016
|
-
* Stop event bubbling.
|
|
4017
|
-
* @returns {void}
|
|
4018
|
-
*/
|
|
4019
|
-
stopPropagation() {
|
|
4020
|
-
const data = pd(this);
|
|
4021
|
-
data.stopped = true;
|
|
4022
|
-
if (typeof data.event.stopPropagation === "function") {
|
|
4023
|
-
data.event.stopPropagation();
|
|
4024
|
-
}
|
|
4025
|
-
},
|
|
4026
|
-
/**
|
|
4027
|
-
* Stop event bubbling.
|
|
4028
|
-
* @returns {void}
|
|
4029
|
-
*/
|
|
4030
|
-
stopImmediatePropagation() {
|
|
4031
|
-
const data = pd(this);
|
|
4032
|
-
data.stopped = true;
|
|
4033
|
-
data.immediateStopped = true;
|
|
4034
|
-
if (typeof data.event.stopImmediatePropagation === "function") {
|
|
4035
|
-
data.event.stopImmediatePropagation();
|
|
4036
|
-
}
|
|
4037
|
-
},
|
|
4038
|
-
/**
|
|
4039
|
-
* The flag to be bubbling.
|
|
4040
|
-
* @type {boolean}
|
|
4041
|
-
*/
|
|
4042
|
-
get bubbles() {
|
|
4043
|
-
return Boolean(pd(this).event.bubbles);
|
|
4044
|
-
},
|
|
4045
|
-
/**
|
|
4046
|
-
* The flag to be cancelable.
|
|
4047
|
-
* @type {boolean}
|
|
4048
|
-
*/
|
|
4049
|
-
get cancelable() {
|
|
4050
|
-
return Boolean(pd(this).event.cancelable);
|
|
4051
|
-
},
|
|
4052
|
-
/**
|
|
4053
|
-
* Cancel this event.
|
|
4054
|
-
* @returns {void}
|
|
4055
|
-
*/
|
|
4056
|
-
preventDefault() {
|
|
4057
|
-
setCancelFlag(pd(this));
|
|
4058
|
-
},
|
|
4059
|
-
/**
|
|
4060
|
-
* The flag to indicate cancellation state.
|
|
4061
|
-
* @type {boolean}
|
|
4062
|
-
*/
|
|
4063
|
-
get defaultPrevented() {
|
|
4064
|
-
return pd(this).canceled;
|
|
4065
|
-
},
|
|
4066
|
-
/**
|
|
4067
|
-
* The flag to be composed.
|
|
4068
|
-
* @type {boolean}
|
|
4069
|
-
*/
|
|
4070
|
-
get composed() {
|
|
4071
|
-
return Boolean(pd(this).event.composed);
|
|
4072
|
-
},
|
|
4073
|
-
/**
|
|
4074
|
-
* The unix time of this event.
|
|
4075
|
-
* @type {number}
|
|
4076
|
-
*/
|
|
4077
|
-
get timeStamp() {
|
|
4078
|
-
return pd(this).timeStamp;
|
|
4079
|
-
},
|
|
4080
|
-
/**
|
|
4081
|
-
* The target of this event.
|
|
4082
|
-
* @type {EventTarget}
|
|
4083
|
-
* @deprecated
|
|
4084
|
-
*/
|
|
4085
|
-
get srcElement() {
|
|
4086
|
-
return pd(this).eventTarget;
|
|
4087
|
-
},
|
|
4088
|
-
/**
|
|
4089
|
-
* The flag to stop event bubbling.
|
|
4090
|
-
* @type {boolean}
|
|
4091
|
-
* @deprecated
|
|
4092
|
-
*/
|
|
4093
|
-
get cancelBubble() {
|
|
4094
|
-
return pd(this).stopped;
|
|
4095
|
-
},
|
|
4096
|
-
set cancelBubble(value) {
|
|
4097
|
-
if (!value) {
|
|
4098
|
-
return;
|
|
4099
|
-
}
|
|
4100
|
-
const data = pd(this);
|
|
4101
|
-
data.stopped = true;
|
|
4102
|
-
if (typeof data.event.cancelBubble === "boolean") {
|
|
4103
|
-
data.event.cancelBubble = true;
|
|
4104
|
-
}
|
|
4105
|
-
},
|
|
4106
|
-
/**
|
|
4107
|
-
* The flag to indicate cancellation state.
|
|
4108
|
-
* @type {boolean}
|
|
4109
|
-
* @deprecated
|
|
4110
|
-
*/
|
|
4111
|
-
get returnValue() {
|
|
4112
|
-
return !pd(this).canceled;
|
|
4113
|
-
},
|
|
4114
|
-
set returnValue(value) {
|
|
4115
|
-
if (!value) {
|
|
4116
|
-
setCancelFlag(pd(this));
|
|
4117
|
-
}
|
|
4118
|
-
},
|
|
4119
|
-
/**
|
|
4120
|
-
* Initialize this event object. But do nothing under event dispatching.
|
|
4121
|
-
* @param {string} type The event type.
|
|
4122
|
-
* @param {boolean} [bubbles=false] The flag to be possible to bubble up.
|
|
4123
|
-
* @param {boolean} [cancelable=false] The flag to be possible to cancel.
|
|
4124
|
-
* @deprecated
|
|
4125
|
-
*/
|
|
4126
|
-
initEvent() {
|
|
4127
|
-
}
|
|
4128
|
-
};
|
|
4129
|
-
Object.defineProperty(Event.prototype, "constructor", {
|
|
4130
|
-
value: Event,
|
|
4131
|
-
configurable: true,
|
|
4132
|
-
writable: true
|
|
4133
|
-
});
|
|
4134
|
-
if (typeof window !== "undefined" && typeof window.Event !== "undefined") {
|
|
4135
|
-
Object.setPrototypeOf(Event.prototype, window.Event.prototype);
|
|
4136
|
-
wrappers.set(window.Event.prototype, Event);
|
|
4137
|
-
}
|
|
4138
|
-
function defineRedirectDescriptor(key) {
|
|
4139
|
-
return {
|
|
4140
|
-
get() {
|
|
4141
|
-
return pd(this).event[key];
|
|
4142
|
-
},
|
|
4143
|
-
set(value) {
|
|
4144
|
-
pd(this).event[key] = value;
|
|
4145
|
-
},
|
|
4146
|
-
configurable: true,
|
|
4147
|
-
enumerable: true
|
|
4148
|
-
};
|
|
4149
|
-
}
|
|
4150
|
-
function defineCallDescriptor(key) {
|
|
4151
|
-
return {
|
|
4152
|
-
value() {
|
|
4153
|
-
const event = pd(this).event;
|
|
4154
|
-
return event[key].apply(event, arguments);
|
|
4155
|
-
},
|
|
4156
|
-
configurable: true,
|
|
4157
|
-
enumerable: true
|
|
4158
|
-
};
|
|
4159
|
-
}
|
|
4160
|
-
function defineWrapper(BaseEvent, proto) {
|
|
4161
|
-
const keys = Object.keys(proto);
|
|
4162
|
-
if (keys.length === 0) {
|
|
4163
|
-
return BaseEvent;
|
|
4164
|
-
}
|
|
4165
|
-
function CustomEvent2(eventTarget, event) {
|
|
4166
|
-
BaseEvent.call(this, eventTarget, event);
|
|
4167
|
-
}
|
|
4168
|
-
CustomEvent2.prototype = Object.create(BaseEvent.prototype, {
|
|
4169
|
-
constructor: { value: CustomEvent2, configurable: true, writable: true }
|
|
4170
|
-
});
|
|
4171
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
4172
|
-
const key = keys[i];
|
|
4173
|
-
if (!(key in BaseEvent.prototype)) {
|
|
4174
|
-
const descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
|
4175
|
-
const isFunc = typeof descriptor.value === "function";
|
|
4176
|
-
Object.defineProperty(
|
|
4177
|
-
CustomEvent2.prototype,
|
|
4178
|
-
key,
|
|
4179
|
-
isFunc ? defineCallDescriptor(key) : defineRedirectDescriptor(key)
|
|
4180
|
-
);
|
|
4181
|
-
}
|
|
4182
|
-
}
|
|
4183
|
-
return CustomEvent2;
|
|
4184
|
-
}
|
|
4185
|
-
function getWrapper(proto) {
|
|
4186
|
-
if (proto == null || proto === Object.prototype) {
|
|
4187
|
-
return Event;
|
|
4188
|
-
}
|
|
4189
|
-
let wrapper = wrappers.get(proto);
|
|
4190
|
-
if (wrapper == null) {
|
|
4191
|
-
wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto);
|
|
4192
|
-
wrappers.set(proto, wrapper);
|
|
4193
|
-
}
|
|
4194
|
-
return wrapper;
|
|
4195
|
-
}
|
|
4196
|
-
function wrapEvent(eventTarget, event) {
|
|
4197
|
-
const Wrapper = getWrapper(Object.getPrototypeOf(event));
|
|
4198
|
-
return new Wrapper(eventTarget, event);
|
|
4199
|
-
}
|
|
4200
|
-
function isStopped(event) {
|
|
4201
|
-
return pd(event).immediateStopped;
|
|
4202
|
-
}
|
|
4203
|
-
function setEventPhase(event, eventPhase) {
|
|
4204
|
-
pd(event).eventPhase = eventPhase;
|
|
4205
|
-
}
|
|
4206
|
-
function setCurrentTarget(event, currentTarget) {
|
|
4207
|
-
pd(event).currentTarget = currentTarget;
|
|
4208
|
-
}
|
|
4209
|
-
function setPassiveListener(event, passiveListener) {
|
|
4210
|
-
pd(event).passiveListener = passiveListener;
|
|
4211
|
-
}
|
|
4212
|
-
const listenersMap = /* @__PURE__ */ new WeakMap();
|
|
4213
|
-
const CAPTURE = 1;
|
|
4214
|
-
const BUBBLE = 2;
|
|
4215
|
-
const ATTRIBUTE = 3;
|
|
4216
|
-
function isObject(x) {
|
|
4217
|
-
return x !== null && typeof x === "object";
|
|
4218
|
-
}
|
|
4219
|
-
function getListeners(eventTarget) {
|
|
4220
|
-
const listeners = listenersMap.get(eventTarget);
|
|
4221
|
-
if (listeners == null) {
|
|
4222
|
-
throw new TypeError(
|
|
4223
|
-
"'this' is expected an EventTarget object, but got another value."
|
|
4224
|
-
);
|
|
4225
|
-
}
|
|
4226
|
-
return listeners;
|
|
4227
|
-
}
|
|
4228
|
-
function defineEventAttributeDescriptor(eventName) {
|
|
4229
|
-
return {
|
|
4230
|
-
get() {
|
|
4231
|
-
const listeners = getListeners(this);
|
|
4232
|
-
let node = listeners.get(eventName);
|
|
4233
|
-
while (node != null) {
|
|
4234
|
-
if (node.listenerType === ATTRIBUTE) {
|
|
4235
|
-
return node.listener;
|
|
4236
|
-
}
|
|
4237
|
-
node = node.next;
|
|
4238
|
-
}
|
|
4239
|
-
return null;
|
|
4240
|
-
},
|
|
4241
|
-
set(listener) {
|
|
4242
|
-
if (typeof listener !== "function" && !isObject(listener)) {
|
|
4243
|
-
listener = null;
|
|
4244
|
-
}
|
|
4245
|
-
const listeners = getListeners(this);
|
|
4246
|
-
let prev = null;
|
|
4247
|
-
let node = listeners.get(eventName);
|
|
4248
|
-
while (node != null) {
|
|
4249
|
-
if (node.listenerType === ATTRIBUTE) {
|
|
4250
|
-
if (prev !== null) {
|
|
4251
|
-
prev.next = node.next;
|
|
4252
|
-
} else if (node.next !== null) {
|
|
4253
|
-
listeners.set(eventName, node.next);
|
|
4254
|
-
} else {
|
|
4255
|
-
listeners.delete(eventName);
|
|
4256
|
-
}
|
|
4257
|
-
} else {
|
|
4258
|
-
prev = node;
|
|
4259
|
-
}
|
|
4260
|
-
node = node.next;
|
|
4261
|
-
}
|
|
4262
|
-
if (listener !== null) {
|
|
4263
|
-
const newNode = {
|
|
4264
|
-
listener,
|
|
4265
|
-
listenerType: ATTRIBUTE,
|
|
4266
|
-
passive: false,
|
|
4267
|
-
once: false,
|
|
4268
|
-
next: null
|
|
4269
|
-
};
|
|
4270
|
-
if (prev === null) {
|
|
4271
|
-
listeners.set(eventName, newNode);
|
|
4272
|
-
} else {
|
|
4273
|
-
prev.next = newNode;
|
|
4274
|
-
}
|
|
4275
|
-
}
|
|
4276
|
-
},
|
|
4277
|
-
configurable: true,
|
|
4278
|
-
enumerable: true
|
|
4279
|
-
};
|
|
4280
|
-
}
|
|
4281
|
-
function defineEventAttribute(eventTargetPrototype, eventName) {
|
|
4282
|
-
Object.defineProperty(
|
|
4283
|
-
eventTargetPrototype,
|
|
4284
|
-
`on${eventName}`,
|
|
4285
|
-
defineEventAttributeDescriptor(eventName)
|
|
4286
|
-
);
|
|
4287
|
-
}
|
|
4288
|
-
function defineCustomEventTarget(eventNames) {
|
|
4289
|
-
function CustomEventTarget() {
|
|
4290
|
-
EventTarget.call(this);
|
|
4291
|
-
}
|
|
4292
|
-
CustomEventTarget.prototype = Object.create(EventTarget.prototype, {
|
|
4293
|
-
constructor: {
|
|
4294
|
-
value: CustomEventTarget,
|
|
4295
|
-
configurable: true,
|
|
4296
|
-
writable: true
|
|
4297
|
-
}
|
|
4298
|
-
});
|
|
4299
|
-
for (let i = 0; i < eventNames.length; ++i) {
|
|
4300
|
-
defineEventAttribute(CustomEventTarget.prototype, eventNames[i]);
|
|
4301
|
-
}
|
|
4302
|
-
return CustomEventTarget;
|
|
4303
|
-
}
|
|
4304
|
-
function EventTarget() {
|
|
4305
|
-
if (this instanceof EventTarget) {
|
|
4306
|
-
listenersMap.set(this, /* @__PURE__ */ new Map());
|
|
4307
|
-
return;
|
|
4308
|
-
}
|
|
4309
|
-
if (arguments.length === 1 && Array.isArray(arguments[0])) {
|
|
4310
|
-
return defineCustomEventTarget(arguments[0]);
|
|
4311
|
-
}
|
|
4312
|
-
if (arguments.length > 0) {
|
|
4313
|
-
const types = new Array(arguments.length);
|
|
4314
|
-
for (let i = 0; i < arguments.length; ++i) {
|
|
4315
|
-
types[i] = arguments[i];
|
|
4316
|
-
}
|
|
4317
|
-
return defineCustomEventTarget(types);
|
|
4318
|
-
}
|
|
4319
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4320
|
-
}
|
|
4321
|
-
EventTarget.prototype = {
|
|
4322
|
-
/**
|
|
4323
|
-
* Add a given listener to this event target.
|
|
4324
|
-
* @param {string} eventName The event name to add.
|
|
4325
|
-
* @param {Function} listener The listener to add.
|
|
4326
|
-
* @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
|
|
4327
|
-
* @returns {void}
|
|
4328
|
-
*/
|
|
4329
|
-
addEventListener(eventName, listener, options) {
|
|
4330
|
-
if (listener == null) {
|
|
4331
|
-
return;
|
|
4332
|
-
}
|
|
4333
|
-
if (typeof listener !== "function" && !isObject(listener)) {
|
|
4334
|
-
throw new TypeError("'listener' should be a function or an object.");
|
|
4335
|
-
}
|
|
4336
|
-
const listeners = getListeners(this);
|
|
4337
|
-
const optionsIsObj = isObject(options);
|
|
4338
|
-
const capture = optionsIsObj ? Boolean(options.capture) : Boolean(options);
|
|
4339
|
-
const listenerType = capture ? CAPTURE : BUBBLE;
|
|
4340
|
-
const newNode = {
|
|
4341
|
-
listener,
|
|
4342
|
-
listenerType,
|
|
4343
|
-
passive: optionsIsObj && Boolean(options.passive),
|
|
4344
|
-
once: optionsIsObj && Boolean(options.once),
|
|
4345
|
-
next: null
|
|
4346
|
-
};
|
|
4347
|
-
let node = listeners.get(eventName);
|
|
4348
|
-
if (node === void 0) {
|
|
4349
|
-
listeners.set(eventName, newNode);
|
|
4350
|
-
return;
|
|
4351
|
-
}
|
|
4352
|
-
let prev = null;
|
|
4353
|
-
while (node != null) {
|
|
4354
|
-
if (node.listener === listener && node.listenerType === listenerType) {
|
|
4355
|
-
return;
|
|
4356
|
-
}
|
|
4357
|
-
prev = node;
|
|
4358
|
-
node = node.next;
|
|
4359
|
-
}
|
|
4360
|
-
prev.next = newNode;
|
|
4361
|
-
},
|
|
4362
|
-
/**
|
|
4363
|
-
* Remove a given listener from this event target.
|
|
4364
|
-
* @param {string} eventName The event name to remove.
|
|
4365
|
-
* @param {Function} listener The listener to remove.
|
|
4366
|
-
* @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
|
|
4367
|
-
* @returns {void}
|
|
4368
|
-
*/
|
|
4369
|
-
removeEventListener(eventName, listener, options) {
|
|
4370
|
-
if (listener == null) {
|
|
4371
|
-
return;
|
|
4372
|
-
}
|
|
4373
|
-
const listeners = getListeners(this);
|
|
4374
|
-
const capture = isObject(options) ? Boolean(options.capture) : Boolean(options);
|
|
4375
|
-
const listenerType = capture ? CAPTURE : BUBBLE;
|
|
4376
|
-
let prev = null;
|
|
4377
|
-
let node = listeners.get(eventName);
|
|
4378
|
-
while (node != null) {
|
|
4379
|
-
if (node.listener === listener && node.listenerType === listenerType) {
|
|
4380
|
-
if (prev !== null) {
|
|
4381
|
-
prev.next = node.next;
|
|
4382
|
-
} else if (node.next !== null) {
|
|
4383
|
-
listeners.set(eventName, node.next);
|
|
4384
|
-
} else {
|
|
4385
|
-
listeners.delete(eventName);
|
|
4386
|
-
}
|
|
4387
|
-
return;
|
|
4388
|
-
}
|
|
4389
|
-
prev = node;
|
|
4390
|
-
node = node.next;
|
|
4391
|
-
}
|
|
4392
|
-
},
|
|
4393
|
-
/**
|
|
4394
|
-
* Dispatch a given event.
|
|
4395
|
-
* @param {Event|{type:string}} event The event to dispatch.
|
|
4396
|
-
* @returns {boolean} `false` if canceled.
|
|
4397
|
-
*/
|
|
4398
|
-
dispatchEvent(event) {
|
|
4399
|
-
if (event == null || typeof event.type !== "string") {
|
|
4400
|
-
throw new TypeError('"event.type" should be a string.');
|
|
4401
|
-
}
|
|
4402
|
-
const listeners = getListeners(this);
|
|
4403
|
-
const eventName = event.type;
|
|
4404
|
-
let node = listeners.get(eventName);
|
|
4405
|
-
if (node == null) {
|
|
4406
|
-
return true;
|
|
4407
|
-
}
|
|
4408
|
-
const wrappedEvent = wrapEvent(this, event);
|
|
4409
|
-
let prev = null;
|
|
4410
|
-
while (node != null) {
|
|
4411
|
-
if (node.once) {
|
|
4412
|
-
if (prev !== null) {
|
|
4413
|
-
prev.next = node.next;
|
|
4414
|
-
} else if (node.next !== null) {
|
|
4415
|
-
listeners.set(eventName, node.next);
|
|
4416
|
-
} else {
|
|
4417
|
-
listeners.delete(eventName);
|
|
4418
|
-
}
|
|
4419
|
-
} else {
|
|
4420
|
-
prev = node;
|
|
4421
|
-
}
|
|
4422
|
-
setPassiveListener(
|
|
4423
|
-
wrappedEvent,
|
|
4424
|
-
node.passive ? node.listener : null
|
|
4425
|
-
);
|
|
4426
|
-
if (typeof node.listener === "function") {
|
|
4427
|
-
try {
|
|
4428
|
-
node.listener.call(this, wrappedEvent);
|
|
4429
|
-
} catch (err) {
|
|
4430
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
4431
|
-
console.error(err);
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
} else if (node.listenerType !== ATTRIBUTE && typeof node.listener.handleEvent === "function") {
|
|
4435
|
-
node.listener.handleEvent(wrappedEvent);
|
|
4436
|
-
}
|
|
4437
|
-
if (isStopped(wrappedEvent)) {
|
|
4438
|
-
break;
|
|
4439
|
-
}
|
|
4440
|
-
node = node.next;
|
|
4441
|
-
}
|
|
4442
|
-
setPassiveListener(wrappedEvent, null);
|
|
4443
|
-
setEventPhase(wrappedEvent, 0);
|
|
4444
|
-
setCurrentTarget(wrappedEvent, null);
|
|
4445
|
-
return !wrappedEvent.defaultPrevented;
|
|
4446
|
-
}
|
|
4447
|
-
};
|
|
4448
|
-
Object.defineProperty(EventTarget.prototype, "constructor", {
|
|
4449
|
-
value: EventTarget,
|
|
4450
|
-
configurable: true,
|
|
4451
|
-
writable: true
|
|
4452
|
-
});
|
|
4453
|
-
if (typeof window !== "undefined" && typeof window.EventTarget !== "undefined") {
|
|
4454
|
-
Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype);
|
|
4455
|
-
}
|
|
4456
|
-
const eventTargetShim = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4457
|
-
__proto__: null,
|
|
4458
|
-
EventTarget,
|
|
4459
|
-
default: EventTarget,
|
|
4460
|
-
defineEventAttribute
|
|
4461
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
4462
|
-
const require$$1$1 = /* @__PURE__ */ getAugmentedNamespace(eventTargetShim);
|
|
4463
|
-
Object.defineProperty(useStorage$1, "__esModule", {
|
|
4464
|
-
value: true
|
|
4465
|
-
});
|
|
4466
|
-
useStorage$1.default = useStorage;
|
|
4467
|
-
var _react$1 = require$$0;
|
|
4468
|
-
var _eventTargetShim = require$$1$1;
|
|
4469
|
-
const evtTarget = new _eventTargetShim.EventTarget();
|
|
4470
|
-
function useStorage(storage, keyPrefix) {
|
|
4471
|
-
return (key, defaultValue) => {
|
|
4472
|
-
const storeKey = "".concat(keyPrefix, ".").concat(key);
|
|
4473
|
-
const raw = storage.getItem(storeKey);
|
|
4474
|
-
const [value, setValue] = (0, _react$1.useState)(raw ? JSON.parse(raw) : defaultValue);
|
|
4475
|
-
const updater = (updatedValue) => {
|
|
4476
|
-
setValue(updatedValue);
|
|
4477
|
-
storage.setItem(storeKey, JSON.stringify(updatedValue));
|
|
4478
|
-
evtTarget.dispatchEvent(new CustomEvent("storage_change", {
|
|
4479
|
-
detail: {
|
|
4480
|
-
key
|
|
4481
|
-
}
|
|
4482
|
-
}));
|
|
4483
|
-
};
|
|
4484
|
-
if (defaultValue != null && !raw) {
|
|
4485
|
-
updater(defaultValue);
|
|
4486
|
-
}
|
|
4487
|
-
(0, _react$1.useEffect)(() => {
|
|
4488
|
-
const listener = (_ref) => {
|
|
4489
|
-
let {
|
|
4490
|
-
detail
|
|
4491
|
-
} = _ref;
|
|
4492
|
-
if (detail.key === key) {
|
|
4493
|
-
const _raw = storage.getItem(storeKey);
|
|
4494
|
-
if (_raw !== raw) {
|
|
4495
|
-
setValue(JSON.parse(_raw));
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
};
|
|
4499
|
-
evtTarget.addEventListener("storage_change", listener);
|
|
4500
|
-
return () => evtTarget.removeEventListener("storage_change", listener);
|
|
4501
|
-
});
|
|
4502
|
-
return [value, updater];
|
|
4503
|
-
};
|
|
4504
|
-
}
|
|
4505
|
-
var useBrowser$1 = {};
|
|
4506
|
-
var appleIphone = /iPhone/i;
|
|
4507
|
-
var appleIpod = /iPod/i;
|
|
4508
|
-
var appleTablet = /iPad/i;
|
|
4509
|
-
var appleUniversal = /\biOS-universal(?:.+)Mac\b/i;
|
|
4510
|
-
var androidPhone = /\bAndroid(?:.+)Mobile\b/i;
|
|
4511
|
-
var androidTablet = /Android/i;
|
|
4512
|
-
var amazonPhone = /(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i;
|
|
4513
|
-
var amazonTablet = /Silk/i;
|
|
4514
|
-
var windowsPhone = /Windows Phone/i;
|
|
4515
|
-
var windowsTablet = /\bWindows(?:.+)ARM\b/i;
|
|
4516
|
-
var otherBlackBerry = /BlackBerry/i;
|
|
4517
|
-
var otherBlackBerry10 = /BB10/i;
|
|
4518
|
-
var otherOpera = /Opera Mini/i;
|
|
4519
|
-
var otherChrome = /\b(CriOS|Chrome)(?:.+)Mobile/i;
|
|
4520
|
-
var otherFirefox = /Mobile(?:.+)Firefox\b/i;
|
|
4521
|
-
var isAppleTabletOnIos13 = function(navigator2) {
|
|
4522
|
-
return typeof navigator2 !== "undefined" && navigator2.platform === "MacIntel" && typeof navigator2.maxTouchPoints === "number" && navigator2.maxTouchPoints > 1 && typeof MSStream === "undefined";
|
|
4523
|
-
};
|
|
4524
|
-
function createMatch(userAgent) {
|
|
4525
|
-
return function(regex) {
|
|
4526
|
-
return regex.test(userAgent);
|
|
4527
|
-
};
|
|
4528
|
-
}
|
|
4529
|
-
function isMobile(param) {
|
|
4530
|
-
var nav = {
|
|
4531
|
-
userAgent: "",
|
|
4532
|
-
platform: "",
|
|
4533
|
-
maxTouchPoints: 0
|
|
4534
|
-
};
|
|
4535
|
-
if (!param && typeof navigator !== "undefined") {
|
|
4536
|
-
nav = {
|
|
4537
|
-
userAgent: navigator.userAgent,
|
|
4538
|
-
platform: navigator.platform,
|
|
4539
|
-
maxTouchPoints: navigator.maxTouchPoints || 0
|
|
4540
|
-
};
|
|
4541
|
-
} else if (typeof param === "string") {
|
|
4542
|
-
nav.userAgent = param;
|
|
4543
|
-
} else if (param && param.userAgent) {
|
|
4544
|
-
nav = {
|
|
4545
|
-
userAgent: param.userAgent,
|
|
4546
|
-
platform: param.platform,
|
|
4547
|
-
maxTouchPoints: param.maxTouchPoints || 0
|
|
4548
|
-
};
|
|
4549
|
-
}
|
|
4550
|
-
var userAgent = nav.userAgent;
|
|
4551
|
-
var tmp = userAgent.split("[FBAN");
|
|
4552
|
-
if (typeof tmp[1] !== "undefined") {
|
|
4553
|
-
userAgent = tmp[0];
|
|
4554
|
-
}
|
|
4555
|
-
tmp = userAgent.split("Twitter");
|
|
4556
|
-
if (typeof tmp[1] !== "undefined") {
|
|
4557
|
-
userAgent = tmp[0];
|
|
4558
|
-
}
|
|
4559
|
-
var match = createMatch(userAgent);
|
|
4560
|
-
var result = {
|
|
4561
|
-
apple: {
|
|
4562
|
-
phone: match(appleIphone) && !match(windowsPhone),
|
|
4563
|
-
ipod: match(appleIpod),
|
|
4564
|
-
tablet: !match(appleIphone) && (match(appleTablet) || isAppleTabletOnIos13(nav)) && !match(windowsPhone),
|
|
4565
|
-
universal: match(appleUniversal),
|
|
4566
|
-
device: (match(appleIphone) || match(appleIpod) || match(appleTablet) || match(appleUniversal) || isAppleTabletOnIos13(nav)) && !match(windowsPhone)
|
|
4567
|
-
},
|
|
4568
|
-
amazon: {
|
|
4569
|
-
phone: match(amazonPhone),
|
|
4570
|
-
tablet: !match(amazonPhone) && match(amazonTablet),
|
|
4571
|
-
device: match(amazonPhone) || match(amazonTablet)
|
|
4572
|
-
},
|
|
4573
|
-
android: {
|
|
4574
|
-
phone: !match(windowsPhone) && match(amazonPhone) || !match(windowsPhone) && match(androidPhone),
|
|
4575
|
-
tablet: !match(windowsPhone) && !match(amazonPhone) && !match(androidPhone) && (match(amazonTablet) || match(androidTablet)),
|
|
4576
|
-
device: !match(windowsPhone) && (match(amazonPhone) || match(amazonTablet) || match(androidPhone) || match(androidTablet)) || match(/\bokhttp\b/i)
|
|
4577
|
-
},
|
|
4578
|
-
windows: {
|
|
4579
|
-
phone: match(windowsPhone),
|
|
4580
|
-
tablet: match(windowsTablet),
|
|
4581
|
-
device: match(windowsPhone) || match(windowsTablet)
|
|
4582
|
-
},
|
|
4583
|
-
other: {
|
|
4584
|
-
blackberry: match(otherBlackBerry),
|
|
4585
|
-
blackberry10: match(otherBlackBerry10),
|
|
4586
|
-
opera: match(otherOpera),
|
|
4587
|
-
firefox: match(otherFirefox),
|
|
4588
|
-
chrome: match(otherChrome),
|
|
4589
|
-
device: match(otherBlackBerry) || match(otherBlackBerry10) || match(otherOpera) || match(otherFirefox) || match(otherChrome)
|
|
4590
|
-
},
|
|
4591
|
-
any: false,
|
|
4592
|
-
phone: false,
|
|
4593
|
-
tablet: false
|
|
4594
|
-
};
|
|
4595
|
-
result.any = result.apple.device || result.android.device || result.windows.device || result.other.device;
|
|
4596
|
-
result.phone = result.apple.phone || result.android.phone || result.windows.phone;
|
|
4597
|
-
result.tablet = result.apple.tablet || result.android.tablet || result.windows.tablet;
|
|
4598
|
-
return result;
|
|
4599
|
-
}
|
|
4600
|
-
const esm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4601
|
-
__proto__: null,
|
|
4602
|
-
default: isMobile
|
|
4603
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
4604
|
-
const require$$1 = /* @__PURE__ */ getAugmentedNamespace(esm);
|
|
4605
|
-
Object.defineProperty(useBrowser$1, "__esModule", {
|
|
4606
|
-
value: true
|
|
4607
|
-
});
|
|
4608
|
-
useBrowser$1.default = useBrowser;
|
|
4609
|
-
var _react = require$$0;
|
|
4610
|
-
var _ismobilejs = _interopRequireDefault(require$$1);
|
|
4611
|
-
function _interopRequireDefault(obj) {
|
|
4612
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
4613
|
-
}
|
|
4614
|
-
function ownKeys(e, r) {
|
|
4615
|
-
var t = Object.keys(e);
|
|
4616
|
-
if (Object.getOwnPropertySymbols) {
|
|
4617
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
4618
|
-
r && (o = o.filter(function(r2) {
|
|
4619
|
-
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
4620
|
-
})), t.push.apply(t, o);
|
|
4621
|
-
}
|
|
4622
|
-
return t;
|
|
4623
|
-
}
|
|
4624
|
-
function _objectSpread(e) {
|
|
4625
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
4626
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
4627
|
-
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
|
|
4628
|
-
_defineProperty(e, r2, t[r2]);
|
|
4629
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
|
|
4630
|
-
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
|
|
4631
|
-
});
|
|
4632
|
-
}
|
|
4633
|
-
return e;
|
|
4634
|
-
}
|
|
4635
|
-
function _defineProperty(obj, key, value) {
|
|
4636
|
-
key = _toPropertyKey(key);
|
|
4637
|
-
if (key in obj) {
|
|
4638
|
-
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
4639
|
-
} else {
|
|
4640
|
-
obj[key] = value;
|
|
4641
|
-
}
|
|
4642
|
-
return obj;
|
|
4643
|
-
}
|
|
4644
|
-
function _toPropertyKey(t) {
|
|
4645
|
-
var i = _toPrimitive(t, "string");
|
|
4646
|
-
return "symbol" == typeof i ? i : String(i);
|
|
4647
|
-
}
|
|
4648
|
-
function _toPrimitive(t, r) {
|
|
4649
|
-
if ("object" != typeof t || !t)
|
|
4650
|
-
return t;
|
|
4651
|
-
var e = t[Symbol.toPrimitive];
|
|
4652
|
-
if (void 0 !== e) {
|
|
4653
|
-
var i = e.call(t, r || "default");
|
|
4654
|
-
if ("object" != typeof i)
|
|
4655
|
-
return i;
|
|
4656
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
4657
|
-
}
|
|
4658
|
-
return ("string" === r ? String : Number)(t);
|
|
4659
|
-
}
|
|
4660
|
-
const DID_WALLET_TAG = "ABTWallet";
|
|
4661
|
-
function getDIDWalletVersion(userAgent) {
|
|
4662
|
-
var _result$groups;
|
|
4663
|
-
const reg = new RegExp("".concat(DID_WALLET_TAG, "/(?<version>[0-9.]+)"), "g");
|
|
4664
|
-
const result = reg.exec(userAgent);
|
|
4665
|
-
const version = result === null || result === void 0 ? void 0 : (_result$groups = result.groups) === null || _result$groups === void 0 ? void 0 : _result$groups.version;
|
|
4666
|
-
return version;
|
|
4667
|
-
}
|
|
4668
|
-
function useBrowser() {
|
|
4669
|
-
var _window, _window$navigator;
|
|
4670
|
-
const userAgent = (_window = window) === null || _window === void 0 ? void 0 : (_window$navigator = _window.navigator) === null || _window$navigator === void 0 ? void 0 : _window$navigator.userAgent;
|
|
4671
|
-
const [browser] = (0, _react.useState)({
|
|
4672
|
-
wallet: userAgent.indexOf(DID_WALLET_TAG) > -1,
|
|
4673
|
-
walletVersion: getDIDWalletVersion(userAgent),
|
|
4674
|
-
wechat: /MicroMessenger/i.test(userAgent),
|
|
4675
|
-
mobile: _objectSpread({
|
|
4676
|
-
apple: {
|
|
4677
|
-
phone: false,
|
|
4678
|
-
ipod: false,
|
|
4679
|
-
tablet: false,
|
|
4680
|
-
device: false
|
|
4681
|
-
},
|
|
4682
|
-
amazon: {
|
|
4683
|
-
phone: false,
|
|
4684
|
-
tablet: false,
|
|
4685
|
-
device: false
|
|
4686
|
-
},
|
|
4687
|
-
android: {
|
|
4688
|
-
phone: false,
|
|
4689
|
-
tablet: false,
|
|
4690
|
-
device: false
|
|
4691
|
-
},
|
|
4692
|
-
windows: {
|
|
4693
|
-
phone: false,
|
|
4694
|
-
tablet: false,
|
|
4695
|
-
device: false
|
|
4696
|
-
},
|
|
4697
|
-
other: {
|
|
4698
|
-
blackberry: false,
|
|
4699
|
-
blackberry10: false,
|
|
4700
|
-
opera: false,
|
|
4701
|
-
firefox: false,
|
|
4702
|
-
chrome: false,
|
|
4703
|
-
device: false
|
|
4704
|
-
},
|
|
4705
|
-
phone: false,
|
|
4706
|
-
tablet: false,
|
|
4707
|
-
any: false
|
|
4708
|
-
}, (0, _ismobilejs.default)(userAgent))
|
|
4709
|
-
});
|
|
4710
|
-
return browser;
|
|
4711
|
-
}
|
|
4712
|
-
(function(exports3) {
|
|
4713
|
-
Object.defineProperty(exports3, "__esModule", {
|
|
4714
|
-
value: true
|
|
4715
|
-
});
|
|
4716
|
-
Object.defineProperty(exports3, "useBrowser", {
|
|
4717
|
-
enumerable: true,
|
|
4718
|
-
get: function get() {
|
|
4719
|
-
return _useBrowser.default;
|
|
4720
|
-
}
|
|
4721
|
-
});
|
|
4722
|
-
Object.defineProperty(exports3, "useInterval", {
|
|
4723
|
-
enumerable: true,
|
|
4724
|
-
get: function get() {
|
|
4725
|
-
return _useInterval.default;
|
|
4726
|
-
}
|
|
4727
|
-
});
|
|
4728
|
-
Object.defineProperty(exports3, "useStorage", {
|
|
4729
|
-
enumerable: true,
|
|
4730
|
-
get: function get() {
|
|
4731
|
-
return _useStorage.default;
|
|
4732
|
-
}
|
|
4733
|
-
});
|
|
4734
|
-
var _useInterval = _interopRequireDefault2(useInterval$1);
|
|
4735
|
-
var _useStorage = _interopRequireDefault2(useStorage$1);
|
|
4736
|
-
var _useBrowser = _interopRequireDefault2(useBrowser$1);
|
|
4737
|
-
function _interopRequireDefault2(obj) {
|
|
4738
|
-
return obj && obj.__esModule ? obj : { default: obj };
|
|
4739
|
-
}
|
|
4740
|
-
})(lib);
|
|
4741
3856
|
const useChatInWallet = () => {
|
|
4742
3857
|
const navigate = reactRouterDom.useNavigate();
|
|
4743
|
-
const { walletVersion, mobile } =
|
|
4744
|
-
const isChatInWalletV2 =
|
|
3858
|
+
const { walletVersion, mobile } = reactHooks.useBrowser();
|
|
3859
|
+
const isChatInWalletV2 = react.useMemo(() => {
|
|
4745
3860
|
try {
|
|
4746
3861
|
const targetVersion = mobile.apple.device ? "5.3.5" : "5.3.1";
|
|
4747
3862
|
return !!walletVersion && cmp(walletVersion, targetVersion) === 1;
|
|
@@ -4760,7 +3875,10 @@ var __publicField = (obj, key, value) => {
|
|
|
4760
3875
|
const navigateToChatList = () => {
|
|
4761
3876
|
navigate("/chat-in-wallet");
|
|
4762
3877
|
};
|
|
4763
|
-
|
|
3878
|
+
const updateUnreadState = react.useCallback((unread) => {
|
|
3879
|
+
bridge.call("updateUnreadState", { unread });
|
|
3880
|
+
}, []);
|
|
3881
|
+
return { navigateToChat, navigateToChatList, isChatInWalletV2, updateUnreadState };
|
|
4764
3882
|
};
|
|
4765
3883
|
function ChatList({ inWallet, ...rest }) {
|
|
4766
3884
|
const { t } = context.useLocaleContext();
|
|
@@ -5051,7 +4169,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5051
4169
|
},
|
|
5052
4170
|
children: [
|
|
5053
4171
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5054
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:news", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4172
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:news", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5055
4173
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5056
4174
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("chat.newPost") })
|
|
5057
4175
|
] }),
|
|
@@ -5084,7 +4202,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5084
4202
|
},
|
|
5085
4203
|
children: [
|
|
5086
4204
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5087
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4205
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5088
4206
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5089
4207
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: (message == null ? void 0 : message.cc) ? t("chat.commentedPost") : t("chat.commentedYourPost") })
|
|
5090
4208
|
] }),
|
|
@@ -5118,7 +4236,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5118
4236
|
},
|
|
5119
4237
|
children: [
|
|
5120
4238
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5121
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4239
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5122
4240
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5123
4241
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: (message == null ? void 0 : message.cc) ? t("chat.replyComment") : t("chat.replyYourComment") })
|
|
5124
4242
|
] }),
|
|
@@ -5152,7 +4270,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5152
4270
|
},
|
|
5153
4271
|
children: [
|
|
5154
4272
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5155
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4273
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5156
4274
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5157
4275
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
5158
4276
|
" ",
|
|
@@ -5189,7 +4307,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5189
4307
|
},
|
|
5190
4308
|
children: [
|
|
5191
4309
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5192
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4310
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:message-circle-2", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5193
4311
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5194
4312
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("chat.mentionInPost") })
|
|
5195
4313
|
] }),
|
|
@@ -5239,7 +4357,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5239
4357
|
},
|
|
5240
4358
|
children: [
|
|
5241
4359
|
/* @__PURE__ */ jsxRuntime.jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
5242
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.Icon, { icon: "tabler:arrow-forward-up", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
4360
|
+
/* @__PURE__ */ jsxRuntime.jsx(react$1.Icon, { icon: "tabler:arrow-forward-up", style: { height: 15, width: 15, marginRight: 4 } }),
|
|
5243
4361
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { component: "span", sx: { mr: 0.5 }, children: message.sourceUser.fullName }),
|
|
5244
4362
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: titles[message.subtype] })
|
|
5245
4363
|
] }),
|
|
@@ -5264,15 +4382,15 @@ var __publicField = (obj, key, value) => {
|
|
|
5264
4382
|
const { isActiveChat, loadMessages } = useChatContext();
|
|
5265
4383
|
const { t } = context.useLocaleContext();
|
|
5266
4384
|
const isActive = isActiveChat(chat.id);
|
|
5267
|
-
const containerRef =
|
|
5268
|
-
const [isAtBottom, setIsAtBottom] =
|
|
5269
|
-
const [isLoadingMore, setIsLoadingMore] =
|
|
4385
|
+
const containerRef = react.useRef(null);
|
|
4386
|
+
const [isAtBottom, setIsAtBottom] = react.useState(true);
|
|
4387
|
+
const [isLoadingMore, setIsLoadingMore] = react.useState(false);
|
|
5270
4388
|
const scrollToBottom = () => {
|
|
5271
4389
|
var _a3, _b3;
|
|
5272
4390
|
(_b3 = containerRef.current) == null ? void 0 : _b3.scrollTo({ top: ((_a3 = containerRef.current) == null ? void 0 : _a3.scrollHeight) || 0, behavior: "smooth" });
|
|
5273
4391
|
setIsAtBottom(true);
|
|
5274
4392
|
};
|
|
5275
|
-
|
|
4393
|
+
react.useEffect(() => {
|
|
5276
4394
|
const handleScroll = debounce(() => {
|
|
5277
4395
|
setIsAtBottom(checkIsAtBottom(containerRef.current));
|
|
5278
4396
|
}, 300);
|
|
@@ -5280,14 +4398,14 @@ var __publicField = (obj, key, value) => {
|
|
|
5280
4398
|
containerRef.current.addEventListener("scroll", handleScroll);
|
|
5281
4399
|
}
|
|
5282
4400
|
}, []);
|
|
5283
|
-
|
|
4401
|
+
react.useEffect(() => {
|
|
5284
4402
|
setTimeout(() => {
|
|
5285
4403
|
if (isAtBottom) {
|
|
5286
4404
|
scrollToBottom();
|
|
5287
4405
|
}
|
|
5288
4406
|
}, 100);
|
|
5289
4407
|
});
|
|
5290
|
-
|
|
4408
|
+
react.useEffect(() => {
|
|
5291
4409
|
if (isActive) {
|
|
5292
4410
|
setIsAtBottom(checkIsAtBottom(containerRef.current));
|
|
5293
4411
|
}
|
|
@@ -5406,7 +4524,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5406
4524
|
}
|
|
5407
4525
|
}));
|
|
5408
4526
|
function Participants({ users, sx, ...rest }) {
|
|
5409
|
-
const [open, setOpen] =
|
|
4527
|
+
const [open, setOpen] = react.useState(false);
|
|
5410
4528
|
const handleTooltipClose = () => {
|
|
5411
4529
|
setOpen(false);
|
|
5412
4530
|
};
|
|
@@ -5502,8 +4620,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5502
4620
|
const isActive = isActiveChat(chat.id);
|
|
5503
4621
|
const { session, isAdmin } = useSessionContext();
|
|
5504
4622
|
const isCreator = chat.creator.did === ((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.did);
|
|
5505
|
-
const [input, setInput] =
|
|
5506
|
-
|
|
4623
|
+
const [input, setInput] = react.useState("");
|
|
4624
|
+
react.useEffect(() => {
|
|
5507
4625
|
if (chat.isActivated) {
|
|
5508
4626
|
initChatRoom(chat.id);
|
|
5509
4627
|
}
|
|
@@ -5678,7 +4796,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5678
4796
|
});
|
|
5679
4797
|
const { t } = context.useLocaleContext();
|
|
5680
4798
|
const theme = styles.useTheme();
|
|
5681
|
-
const canSubmit =
|
|
4799
|
+
const canSubmit = react.useMemo(() => {
|
|
5682
4800
|
return state.name;
|
|
5683
4801
|
}, [state]);
|
|
5684
4802
|
const handleSubmit = () => {
|
|
@@ -5765,8 +4883,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5765
4883
|
const { session } = useSessionContext();
|
|
5766
4884
|
const navigate = reactRouterDom.useNavigate();
|
|
5767
4885
|
const { client: client2, isInWallet, chats, setActiveChat, createDM } = useChatContext();
|
|
5768
|
-
const [inputValue, setInputValue] =
|
|
5769
|
-
const [open, setOpen] =
|
|
4886
|
+
const [inputValue, setInputValue] = react.useState("");
|
|
4887
|
+
const [open, setOpen] = react.useState(false);
|
|
5770
4888
|
const { navigateToChat } = useChatInWallet();
|
|
5771
4889
|
const { data, loading } = ahooks.useRequest(
|
|
5772
4890
|
async () => {
|
|
@@ -5803,7 +4921,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5803
4921
|
filterOptions: (x) => x,
|
|
5804
4922
|
options: data || [],
|
|
5805
4923
|
getOptionLabel: () => "",
|
|
5806
|
-
renderOption: (props, option) => /* @__PURE__ */
|
|
4924
|
+
renderOption: (props, option) => /* @__PURE__ */ react.createElement(material.Box, { component: "li", ...props, key: option.did, sx: { px: "8px!important" } }, /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { display: "flex", alignItems: "center", width: 1 }, children: [
|
|
5807
4925
|
/* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mt: 0.25, lineHeight: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(Avatar, { did: option.did, src: option.avatar, size: 28, shape: "circle", variant: "circle" }) }),
|
|
5808
4926
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5809
4927
|
material.Box,
|
|
@@ -5912,7 +5030,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5912
5030
|
function Chat({ sx, ...rest }) {
|
|
5913
5031
|
var _a2;
|
|
5914
5032
|
const { client: client2, initialized, chats, activeChatId, addChat, setActiveChat, getOppositeUser } = useChatContext();
|
|
5915
|
-
const [newChannelVisible, setNewChannelVisible] =
|
|
5033
|
+
const [newChannelVisible, setNewChannelVisible] = react.useState(false);
|
|
5916
5034
|
const downMd = material.useMediaQuery((theme) => theme.breakpoints.down("sm"));
|
|
5917
5035
|
const { t } = context.useLocaleContext();
|
|
5918
5036
|
const activeChat = (_a2 = chats == null ? void 0 : chats.filter((chat) => (chat == null ? void 0 : chat.id) === activeChatId)) == null ? void 0 : _a2[0];
|
|
@@ -5932,7 +5050,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5932
5050
|
const getTitle = webTitleMap[activeChat.type] || webTitleMap.default;
|
|
5933
5051
|
return getTitle();
|
|
5934
5052
|
};
|
|
5935
|
-
const show =
|
|
5053
|
+
const show = react.useMemo(() => {
|
|
5936
5054
|
if (downMd) {
|
|
5937
5055
|
return {
|
|
5938
5056
|
left: !activeChatId,
|
|
@@ -6048,7 +5166,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6048
5166
|
const { initialized, chats } = useChatContext();
|
|
6049
5167
|
const downMd = material.useMediaQuery((theme) => theme.breakpoints.down("sm"));
|
|
6050
5168
|
const activeChat = (_a2 = chats == null ? void 0 : chats.filter((chat) => (chat == null ? void 0 : chat.id) === activeChatId)) == null ? void 0 : _a2[0];
|
|
6051
|
-
const show =
|
|
5169
|
+
const show = react.useMemo(() => {
|
|
6052
5170
|
if (downMd) {
|
|
6053
5171
|
return {
|
|
6054
5172
|
left: !activeChatId,
|
|
@@ -6089,7 +5207,13 @@ var __publicField = (obj, key, value) => {
|
|
|
6089
5207
|
}
|
|
6090
5208
|
function ChatListInWallet({ sx, ...rest }) {
|
|
6091
5209
|
const { initialized, chats, activeChatId } = useChatContext();
|
|
6092
|
-
const {
|
|
5210
|
+
const { initialUnread } = useUnreadNotification();
|
|
5211
|
+
const { navigateToChatList, updateUnreadState } = useChatInWallet();
|
|
5212
|
+
react.useEffect(() => {
|
|
5213
|
+
if (typeof initialUnread === "boolean") {
|
|
5214
|
+
updateUnreadState(initialUnread);
|
|
5215
|
+
}
|
|
5216
|
+
}, [initialUnread, updateUnreadState]);
|
|
6093
5217
|
if (!initialized) {
|
|
6094
5218
|
return /* @__PURE__ */ jsxRuntime.jsx(CircularProgress, {});
|
|
6095
5219
|
}
|
|
@@ -6111,6 +5235,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6111
5235
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6112
5236
|
material.SwipeableDrawer,
|
|
6113
5237
|
{
|
|
5238
|
+
disableSwipeToOpen: true,
|
|
6114
5239
|
PaperProps: { sx: { width: 1 } },
|
|
6115
5240
|
anchor: "right",
|
|
6116
5241
|
open: !!activeChatId,
|
|
@@ -6180,11 +5305,11 @@ var __publicField = (obj, key, value) => {
|
|
|
6180
5305
|
return response;
|
|
6181
5306
|
};
|
|
6182
5307
|
const useApiErrorHandler = ({ request, errorHandler }) => {
|
|
6183
|
-
const errorHandlerRef =
|
|
6184
|
-
|
|
5308
|
+
const errorHandlerRef = react.useRef(errorHandler);
|
|
5309
|
+
react.useEffect(() => {
|
|
6185
5310
|
errorHandlerRef.current = errorHandler;
|
|
6186
5311
|
}, [errorHandler]);
|
|
6187
|
-
|
|
5312
|
+
react.useEffect(() => {
|
|
6188
5313
|
const interceptor = request.interceptors.response.use(jsonValidationInterceptor, (error) => {
|
|
6189
5314
|
let handled = false;
|
|
6190
5315
|
error.markAsHandled = () => {
|
|
@@ -6275,7 +5400,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6275
5400
|
const { session } = useSessionContext();
|
|
6276
5401
|
const isAdmin = ["owner", "admin"].includes((_a2 = session == null ? void 0 : session.user) == null ? void 0 : _a2.role);
|
|
6277
5402
|
const uploaderRef = useUploader();
|
|
6278
|
-
const config$1 =
|
|
5403
|
+
const config$1 = react.useMemo(() => {
|
|
6279
5404
|
const userService = {
|
|
6280
5405
|
search: async (text2) => {
|
|
6281
5406
|
const { data } = await request.get(`/api/mention?search=${text2}`, { baseURL });
|
|
@@ -6416,25 +5541,25 @@ var __publicField = (obj, key, value) => {
|
|
|
6416
5541
|
}
|
|
6417
5542
|
);
|
|
6418
5543
|
}
|
|
6419
|
-
const Editor$1 =
|
|
5544
|
+
const Editor$1 = react.lazy(() => Promise.resolve().then(() => editor));
|
|
6420
5545
|
function LazyEditor(props) {
|
|
6421
|
-
const
|
|
5546
|
+
const fallback2 = /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: { px: 3 }, children: [
|
|
6422
5547
|
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, {}),
|
|
6423
5548
|
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "80%" }),
|
|
6424
5549
|
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "60%" }),
|
|
6425
5550
|
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "40%" })
|
|
6426
5551
|
] });
|
|
6427
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6428
|
-
}
|
|
6429
|
-
const BlockletEditor$1 =
|
|
5552
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback: fallback2, children: /* @__PURE__ */ jsxRuntime.jsx(Editor$1, { ...props }) });
|
|
5553
|
+
}
|
|
5554
|
+
const BlockletEditor$1 = react.lazy(() => import("@blocklet/editor"));
|
|
5555
|
+
const fallback = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5556
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, {}),
|
|
5557
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "80%" }),
|
|
5558
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "60%" }),
|
|
5559
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "40%" })
|
|
5560
|
+
] });
|
|
6430
5561
|
function EditorPreview({ content, children, ...rest }) {
|
|
6431
|
-
|
|
6432
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, {}),
|
|
6433
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "80%" }),
|
|
6434
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "60%" }),
|
|
6435
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Skeleton, { width: "40%" })
|
|
6436
|
-
] });
|
|
6437
|
-
return /* @__PURE__ */ jsxRuntime.jsx(require$$0.Suspense, { fallback, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5562
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Suspense, { fallback, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
6438
5563
|
BlockletEditor$1,
|
|
6439
5564
|
{
|
|
6440
5565
|
editorState: inferInitialEditorState(content),
|
|
@@ -6449,8 +5574,9 @@ var __publicField = (obj, key, value) => {
|
|
|
6449
5574
|
}
|
|
6450
5575
|
) });
|
|
6451
5576
|
}
|
|
5577
|
+
EditorPreview.fallback = fallback;
|
|
6452
5578
|
const useBeforeUnloadPrompt = (dirty) => {
|
|
6453
|
-
|
|
5579
|
+
react.useEffect(() => {
|
|
6454
5580
|
const showPrompt = (e) => {
|
|
6455
5581
|
if (dirty) {
|
|
6456
5582
|
e.preventDefault();
|
|
@@ -6467,24 +5593,24 @@ var __publicField = (obj, key, value) => {
|
|
|
6467
5593
|
const { t } = context.useLocaleContext();
|
|
6468
5594
|
const [dirty, setDirty, getDirty] = ahooks.useGetState(false);
|
|
6469
5595
|
const { confirm } = useConfirm();
|
|
6470
|
-
const resetCallbackRef =
|
|
5596
|
+
const resetCallbackRef = react.useRef(null);
|
|
6471
5597
|
useBeforeUnloadPrompt(dirty);
|
|
6472
|
-
const reset =
|
|
5598
|
+
const reset = react.useCallback(
|
|
6473
5599
|
(callback) => {
|
|
6474
5600
|
resetCallbackRef.current = callback;
|
|
6475
5601
|
setDirty(false);
|
|
6476
5602
|
},
|
|
6477
5603
|
[setDirty]
|
|
6478
5604
|
);
|
|
6479
|
-
|
|
5605
|
+
react.useEffect(() => {
|
|
6480
5606
|
var _a2;
|
|
6481
5607
|
if (!dirty) {
|
|
6482
5608
|
(_a2 = resetCallbackRef.current) == null ? void 0 : _a2.call(resetCallbackRef);
|
|
6483
5609
|
resetCallbackRef.current = null;
|
|
6484
5610
|
}
|
|
6485
5611
|
}, [dirty]);
|
|
6486
|
-
const markDirty =
|
|
6487
|
-
const check =
|
|
5612
|
+
const markDirty = react.useCallback(() => setDirty(true), [setDirty]);
|
|
5613
|
+
const check = react.useCallback(async () => {
|
|
6488
5614
|
if (getDirty()) {
|
|
6489
5615
|
const proceed = await confirm({
|
|
6490
5616
|
title: t("unsaved.title"),
|
|
@@ -6507,7 +5633,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6507
5633
|
const { t } = context.useLocaleContext();
|
|
6508
5634
|
const { dirty, reset } = DirtyPromptContainer.useContainer();
|
|
6509
5635
|
const blocker = reactRouterDom.useBlocker(dirty);
|
|
6510
|
-
|
|
5636
|
+
react.useEffect(() => {
|
|
6511
5637
|
if (blocker.state === "blocked" && !dirty) {
|
|
6512
5638
|
blocker.reset();
|
|
6513
5639
|
}
|
|
@@ -6698,7 +5824,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6698
5824
|
}
|
|
6699
5825
|
};
|
|
6700
5826
|
const translations = { zh, en };
|
|
6701
|
-
const Lottie =
|
|
5827
|
+
const Lottie = react.lazy(() => import("lottie-react"));
|
|
6702
5828
|
function LottieComponent({ src, ...restProps }) {
|
|
6703
5829
|
return /* @__PURE__ */ jsxRuntime.jsx(Lottie, { animationData: src, loop: true, ...restProps });
|
|
6704
5830
|
}
|
|
@@ -12213,7 +11339,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12213
11339
|
}
|
|
12214
11340
|
const useSubscription = (event, cb = () => {
|
|
12215
11341
|
}, deps = [], prefix2 = ((_d) => (_d = window.blocklet) == null ? void 0 : _d.prefix)() || "/") => {
|
|
12216
|
-
|
|
11342
|
+
react.useEffect(() => {
|
|
12217
11343
|
if (event) {
|
|
12218
11344
|
if (!client) {
|
|
12219
11345
|
client = getWsClient(prefix2);
|
|
@@ -12228,11 +11354,11 @@ var __publicField = (obj, key, value) => {
|
|
|
12228
11354
|
}, [event, ...deps]);
|
|
12229
11355
|
};
|
|
12230
11356
|
const id = "point-up-component";
|
|
12231
|
-
const PointUpContext =
|
|
11357
|
+
const PointUpContext = react.createContext({});
|
|
12232
11358
|
const WsEvents = Object.freeze({
|
|
12233
11359
|
POINT_UP: "point.up"
|
|
12234
11360
|
});
|
|
12235
|
-
const usePointUpContext = () =>
|
|
11361
|
+
const usePointUpContext = () => react.useContext(PointUpContext);
|
|
12236
11362
|
function PointUp({ points }) {
|
|
12237
11363
|
const { t } = context.useLocaleContext();
|
|
12238
11364
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -12287,7 +11413,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12287
11413
|
});
|
|
12288
11414
|
const { session } = useSessionContext();
|
|
12289
11415
|
const wsClient = getWsClient();
|
|
12290
|
-
const pointUp =
|
|
11416
|
+
const pointUp = react.useCallback(({ points }) => {
|
|
12291
11417
|
state.pointsList.push(points);
|
|
12292
11418
|
}, []);
|
|
12293
11419
|
const pointUpComponent = (_c = (_b2 = (_a2 = window.blocklet) == null ? void 0 : _a2.componentMountPoints) == null ? void 0 : _b2.find) == null ? void 0 : _c.call(
|
|
@@ -12299,19 +11425,19 @@ var __publicField = (obj, key, value) => {
|
|
|
12299
11425
|
pointUp(payload);
|
|
12300
11426
|
}
|
|
12301
11427
|
};
|
|
12302
|
-
|
|
11428
|
+
react.useEffect(() => {
|
|
12303
11429
|
wsClient.connect();
|
|
12304
11430
|
return () => {
|
|
12305
11431
|
if (wsClient.isConnected())
|
|
12306
11432
|
;
|
|
12307
11433
|
};
|
|
12308
11434
|
}, []);
|
|
12309
|
-
const value =
|
|
11435
|
+
const value = react.useMemo(() => {
|
|
12310
11436
|
return {
|
|
12311
11437
|
pointUp
|
|
12312
11438
|
};
|
|
12313
11439
|
}, []);
|
|
12314
|
-
|
|
11440
|
+
react.useEffect(() => {
|
|
12315
11441
|
if (state.pointsList.length > 0) {
|
|
12316
11442
|
state.visible = true;
|
|
12317
11443
|
state.currentPoints = +state.pointsList[0];
|
|
@@ -12384,8 +11510,8 @@ var __publicField = (obj, key, value) => {
|
|
|
12384
11510
|
const selectedString = searchParams.get(urlName);
|
|
12385
11511
|
const dataWithDefault = defaultButton && (data == null ? void 0 : data.length) > 0 ? [defaultButton, ...data] : data;
|
|
12386
11512
|
const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault == null ? void 0 : dataWithDefault.map((item) => item.id);
|
|
12387
|
-
const [selectTab, setSelectTab] =
|
|
12388
|
-
const [selectAll, setSelectAll] =
|
|
11513
|
+
const [selectTab, setSelectTab] = react.useState(urlParams ? selectedArray : [boardId]);
|
|
11514
|
+
const [selectAll, setSelectAll] = react.useState(false);
|
|
12389
11515
|
const updateUrl = (url, newSelectTab) => {
|
|
12390
11516
|
const formatNewSelectTab = newSelectTab.filter(Boolean);
|
|
12391
11517
|
if (urlParams) {
|
|
@@ -12412,7 +11538,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12412
11538
|
return newSelectAll;
|
|
12413
11539
|
});
|
|
12414
11540
|
};
|
|
12415
|
-
|
|
11541
|
+
react.useEffect(() => {
|
|
12416
11542
|
if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
|
|
12417
11543
|
if (urlParams) {
|
|
12418
11544
|
setSelectTab(selectedArray || []);
|
|
@@ -12427,7 +11553,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12427
11553
|
}
|
|
12428
11554
|
}
|
|
12429
11555
|
}, [data, boardId]);
|
|
12430
|
-
|
|
11556
|
+
react.useEffect(() => {
|
|
12431
11557
|
if (urlParams) {
|
|
12432
11558
|
if (selectedString === null || selectedString === "") {
|
|
12433
11559
|
setSelectAll(true);
|
|
@@ -12595,7 +11721,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12595
11721
|
}
|
|
12596
11722
|
) });
|
|
12597
11723
|
}
|
|
12598
|
-
const BlockletEditor =
|
|
11724
|
+
const BlockletEditor = react.lazy(() => import("@blocklet/editor"));
|
|
12599
11725
|
const Root = material.styled(material.Box)`
|
|
12600
11726
|
.be-editable,
|
|
12601
11727
|
.be-content {
|