warqadui 0.0.68 → 0.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -98,6 +98,7 @@ __export(index_exports, {
98
98
  useA4StatementView: () => useA4DataView_default,
99
99
  useAntdImageUpload: () => useAntdImageUpload_default,
100
100
  useApi: () => useApis_default,
101
+ useApp: () => useApp_default,
101
102
  useAuth: () => useAuth_default,
102
103
  useAuthStore: () => useAuthStore,
103
104
  useLogin: () => useLogin,
@@ -1514,8 +1515,8 @@ var useModal = (initialState = false) => {
1514
1515
  resetState();
1515
1516
  }, []);
1516
1517
  const toggle = (0, import_react10.useCallback)(() => setIsOpen((prev) => !prev), []);
1517
- const openState = (0, import_react10.useCallback)((data2) => {
1518
- setState(data2);
1518
+ const openState = (0, import_react10.useCallback)((data) => {
1519
+ setState(data);
1519
1520
  open();
1520
1521
  }, []);
1521
1522
  const ModalComponent = (0, import_react10.useMemo)(() => {
@@ -2192,7 +2193,7 @@ var useApi = () => {
2192
2193
  withCredentials: true
2193
2194
  });
2194
2195
  }, [configApi]);
2195
- const [data2, setData] = (0, import_react14.useState)();
2196
+ const [data, setData] = (0, import_react14.useState)();
2196
2197
  const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
2197
2198
  const [pdfLoading, setPdfLoading] = (0, import_react14.useState)(false);
2198
2199
  const [error, setError] = (0, import_react14.useState)(null);
@@ -2332,7 +2333,7 @@ var useApi = () => {
2332
2333
  }
2333
2334
  };
2334
2335
  return {
2335
- data: data2,
2336
+ data,
2336
2337
  error,
2337
2338
  isLoading,
2338
2339
  pdfLoading,
@@ -3143,7 +3144,7 @@ var import_lucide_react11 = require("lucide-react");
3143
3144
  var import_jsx_runtime24 = require("react/jsx-runtime");
3144
3145
  function DataTable({
3145
3146
  columns: userColumns,
3146
- data: data2,
3147
+ data,
3147
3148
  isLoading = false,
3148
3149
  pageRows,
3149
3150
  searchPlaceholder = "Search all columns...",
@@ -3191,8 +3192,8 @@ function DataTable({
3191
3192
  }, [pageRows]);
3192
3193
  const [expanded, setExpanded] = (0, import_react17.useState)(() => {
3193
3194
  const initialState = {};
3194
- if (defaultExpanded && renderSubComponent && data2) {
3195
- data2.forEach((row, idx) => {
3195
+ if (defaultExpanded && renderSubComponent && data) {
3196
+ data.forEach((row, idx) => {
3196
3197
  if (hasSubComponent(row)) {
3197
3198
  initialState[idx] = true;
3198
3199
  }
@@ -3223,7 +3224,7 @@ function DataTable({
3223
3224
  ];
3224
3225
  }, [userColumns, index, selectable]);
3225
3226
  const table = (0, import_react_table.useReactTable)({
3226
- data: data2,
3227
+ data,
3227
3228
  columns,
3228
3229
  onSortingChange: setSorting,
3229
3230
  onColumnFiltersChange: setColumnFilters,
@@ -3331,7 +3332,7 @@ function DataTable({
3331
3332
  },
3332
3333
  header.id
3333
3334
  )) }, headerGroup.id)) }),
3334
- /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tbody", { className: "", children: isLoading && table.getRowModel().rows?.length === 0 ? Array.from({ length: pageRows || 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3335
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("tbody", { className: "", children: isLoading ? Array.from({ length: pageRows || 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
3335
3336
  "tr",
3336
3337
  {
3337
3338
  className: "border-b border-gray-100 dark:border-zinc-800/50",
@@ -3562,16 +3563,16 @@ function PostTable({
3562
3563
  });
3563
3564
  const [internalData, setInternalData] = (0, import_react18.useState)(controlledData || []);
3564
3565
  const isControlled = controlledData !== void 0;
3565
- const data2 = isControlled ? controlledData : internalData;
3566
+ const data = isControlled ? controlledData : internalData;
3566
3567
  const entryRowRef = (0, import_react18.useRef)(null);
3567
3568
  (0, import_react18.useEffect)(() => {
3568
- if (defaultExpanded && renderSubComponent && (data2 || []).length > 0) {
3569
+ if (defaultExpanded && renderSubComponent && (data || []).length > 0) {
3569
3570
  setExpanded((prev) => {
3570
3571
  const isAllExpanded = prev === true;
3571
3572
  if (isAllExpanded) return prev;
3572
3573
  const newState = typeof prev === "object" ? { ...prev } : {};
3573
3574
  let changed = false;
3574
- data2.forEach((row, idx) => {
3575
+ data.forEach((row, idx) => {
3575
3576
  const id = idx.toString();
3576
3577
  if (hasSubComponent(row) && newState[id] === void 0) {
3577
3578
  newState[id] = true;
@@ -3581,7 +3582,7 @@ function PostTable({
3581
3582
  return changed ? newState : prev;
3582
3583
  });
3583
3584
  }
3584
- }, [data2, defaultExpanded, hasSubComponent, renderSubComponent]);
3585
+ }, [data, defaultExpanded, hasSubComponent, renderSubComponent]);
3585
3586
  const focusAndScrollEntryRow = () => {
3586
3587
  setTimeout(() => {
3587
3588
  if (entryRowRef.current) {
@@ -3606,7 +3607,7 @@ function PostTable({
3606
3607
  const [isSavingAsync, setIsSavingAsync] = (0, import_react18.useState)(false);
3607
3608
  const [fieldErrors, setFieldErrors] = (0, import_react18.useState)({});
3608
3609
  const latestStateRef = (0, import_react18.useRef)({
3609
- data: data2,
3610
+ data,
3610
3611
  entryData,
3611
3612
  editingIndex,
3612
3613
  isSavingAsync,
@@ -3619,7 +3620,7 @@ function PostTable({
3619
3620
  });
3620
3621
  (0, import_react18.useEffect)(() => {
3621
3622
  latestStateRef.current = {
3622
- data: data2,
3623
+ data,
3623
3624
  entryData,
3624
3625
  editingIndex,
3625
3626
  isSavingAsync,
@@ -3632,11 +3633,11 @@ function PostTable({
3632
3633
  };
3633
3634
  });
3634
3635
  const handleSaveField = (0, import_react18.useCallback)(async () => {
3635
- const { data: data3, entryData: entryData2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
3636
+ const { data: data2, entryData: entryData2, editingIndex: editingIndex2, onChange: onChange2 } = latestStateRef.current;
3636
3637
  if (Object.keys(entryData2).length === 0) return;
3637
3638
  const actionType = editingIndex2 !== null ? "edit" : "add";
3638
3639
  const entryToSave = { ...entryData2 };
3639
- const updated = [...data3];
3640
+ const updated = [...data2];
3640
3641
  let entryToPass;
3641
3642
  if (actionType === "edit" && editingIndex2 !== null) {
3642
3643
  updated[editingIndex2] = {
@@ -3712,9 +3713,9 @@ function PostTable({
3712
3713
  }, []);
3713
3714
  const handleDelete = (0, import_react18.useCallback)(
3714
3715
  async (index2) => {
3715
- const { data: data3, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
3716
- const rowToDelete = data3[index2];
3717
- const updated = data3.filter((_, i) => i !== index2);
3716
+ const { data: data2, editingIndex: editingIndex2, onChange: onChange2, onDelete: onDelete2 } = latestStateRef.current;
3717
+ const rowToDelete = data2[index2];
3718
+ const updated = data2.filter((_, i) => i !== index2);
3718
3719
  if (onChange2) {
3719
3720
  setIsSavingAsync(true);
3720
3721
  try {
@@ -3830,7 +3831,7 @@ function PostTable({
3830
3831
  return finalColumns;
3831
3832
  }, [userColumns, actionColumn, index, renderSubComponent, hasSubComponent]);
3832
3833
  const table = (0, import_react_table2.useReactTable)({
3833
- data: data2,
3834
+ data,
3834
3835
  columns,
3835
3836
  onSortingChange: setSorting,
3836
3837
  onColumnFiltersChange: setColumnFilters,
@@ -4140,7 +4141,7 @@ var import_react_table3 = require("@tanstack/react-table");
4140
4141
  var import_jsx_runtime26 = require("react/jsx-runtime");
4141
4142
  function SimpleTable({
4142
4143
  columns: userColumns,
4143
- data: data2,
4144
+ data,
4144
4145
  className = "",
4145
4146
  renderFooter: componentFooter,
4146
4147
  rowPadding = "py-3",
@@ -4175,7 +4176,7 @@ function SimpleTable({
4175
4176
  return cols;
4176
4177
  }, [userColumns, index, startIndex]);
4177
4178
  const table = (0, import_react_table3.useReactTable)({
4178
- data: data2,
4179
+ data,
4179
4180
  columns,
4180
4181
  getCoreRowModel: (0, import_react_table3.getCoreRowModel)()
4181
4182
  });
@@ -4215,7 +4216,7 @@ function SimpleTable({
4215
4216
  },
4216
4217
  headerGroup.id
4217
4218
  )) }),
4218
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading && data2.length === 0 ? Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4219
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tbody", { className: "text-black dark:text-white font-semibold font-sans tabular-nums", children: isLoading && data.length === 0 ? Array.from({ length: skeletonCount }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4219
4220
  "tr",
4220
4221
  {
4221
4222
  className: `border-b ${verticalLines ? "border-black dark:border-white" : "border-gray-100 dark:border-zinc-800/60 last:border-0"}`,
@@ -4234,7 +4235,7 @@ function SimpleTable({
4234
4235
  ))
4235
4236
  },
4236
4237
  `skeleton-row-${i}`
4237
- )) : data2.length === 0 && !isLoading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4238
+ )) : data.length === 0 && !isLoading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
4238
4239
  "td",
4239
4240
  {
4240
4241
  colSpan: columns.length,
@@ -5296,7 +5297,7 @@ var useA4StatementView = ({
5296
5297
  renderFooter: (value) => value.reduce((acc, item) => acc + item.amount, 0)
5297
5298
  }
5298
5299
  ],
5299
- data: data2 = [],
5300
+ data = [],
5300
5301
  error = apiError,
5301
5302
  info,
5302
5303
  index,
@@ -5319,7 +5320,7 @@ var useA4StatementView = ({
5319
5320
  const [currentPageIndex, setCurrentPageIndex] = (0, import_react26.useState)(0);
5320
5321
  const [pageSearch, setPageSearch] = (0, import_react26.useState)("");
5321
5322
  const displayColumnsForSearch = columns.filter((col) => !col.hide);
5322
- const filteredDisplayData = data2.filter((row) => {
5323
+ const filteredDisplayData = data.filter((row) => {
5323
5324
  if (!globalFilter) return true;
5324
5325
  const lowerFilter = globalFilter.toLowerCase();
5325
5326
  return displayColumnsForSearch.some((col) => {
@@ -5462,7 +5463,7 @@ var useA4StatementView = ({
5462
5463
  isLoading: isActuallyLoading
5463
5464
  }
5464
5465
  ) }) : null;
5465
- const statusOverlay = isActuallyLoading || error || !data2 || data2.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
5466
+ const statusOverlay = isActuallyLoading || error || !data || data.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "flex flex-col relative w-full items-center justify-center py-12 min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col items-center justify-center p-8 bg-gray-50/50 dark:bg-zinc-900/30 rounded-2xl border border-dashed border-gray-300 dark:border-zinc-700 w-full max-w-lg text-center shadow-sm", children: [
5466
5467
  isActuallyLoading ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ClassicSpin, {}) }) : error ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "w-14 h-14 bg-red-100 dark:bg-red-500/10 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react16.AlertCircle, { className: "w-7 h-7 text-red-600 dark:text-red-500" }) }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "w-14 h-14 bg-gray-200 dark:bg-zinc-800 rounded-full flex items-center justify-center mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_lucide_react16.FileX, { className: "w-7 h-7 text-gray-500 dark:text-gray-400" }) }),
5467
5468
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-lg font-bold text-gray-900 dark:text-white mb-2", children: isActuallyLoading ? "Loading data..." : error ? "Failed to Load Statement" : "No Records Found" }),
5468
5469
  /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-xs mb-6 leading-relaxed", children: isActuallyLoading ? "Please wait while we prepare your statement." : error ? typeof error === "string" ? error : "An unexpected error occurred while fetching the statement data." : "There are no transactions or records available in this requested statement." }),
@@ -5705,7 +5706,7 @@ var useA4CategoryView = ({
5705
5706
  getData();
5706
5707
  }, [url, v, JSON.stringify(params), delay]);
5707
5708
  const A4CategoryView = ({
5708
- data: data2,
5709
+ data,
5709
5710
  groups: incomingGroups,
5710
5711
  error = apiError,
5711
5712
  info,
@@ -5728,7 +5729,7 @@ var useA4CategoryView = ({
5728
5729
  const [pageSearch, setPageSearch] = (0, import_react27.useState)("");
5729
5730
  const groups = incomingGroups ? [...incomingGroups].sort(
5730
5731
  (a, b) => a.title.localeCompare(b.title)
5731
- ) : data2 ? [{ title: gridTitle, items: data2 }] : [];
5732
+ ) : data ? [{ title: gridTitle, items: data }] : [];
5732
5733
  const flattenedNodes = groups.map((group) => {
5733
5734
  const sortedItems = [...group.items].sort(
5734
5735
  (a, b) => String(a.name).localeCompare(String(b.name))
@@ -6073,7 +6074,7 @@ var useTransaction = ({
6073
6074
  hide: true
6074
6075
  }
6075
6076
  ],
6076
- data: data2 = [],
6077
+ data = [],
6077
6078
  error = apiError,
6078
6079
  pageRows,
6079
6080
  searchPlaceholder = "Search transactions...",
@@ -6090,7 +6091,7 @@ var useTransaction = ({
6090
6091
  createTitle = "Add New",
6091
6092
  ...rest
6092
6093
  }) => {
6093
- const emptyState = !isLoading && (error || !data2 || data2.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6094
+ const emptyState = !isLoading && (error || !data || data.length === 0) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
6094
6095
  "div",
6095
6096
  {
6096
6097
  className: `flex flex-col relative w-full items-center justify-center py-12 min-h-[300px] ${className}`,
@@ -6157,7 +6158,7 @@ var useTransaction = ({
6157
6158
  DataTable,
6158
6159
  {
6159
6160
  columns,
6160
- data: data2,
6161
+ data,
6161
6162
  isLoading,
6162
6163
  pageRows,
6163
6164
  searchPlaceholder,
@@ -7863,11 +7864,11 @@ var useAuthStore = (0, import_zustand.create)((set, get) => ({
7863
7864
  isLoggedIn: false,
7864
7865
  isFetched: true
7865
7866
  }),
7866
- updateAuth: (data2) => set((state) => ({
7867
- auth: state.auth ? { ...state.auth, ...data2 } : state.auth
7867
+ updateAuth: (data) => set((state) => ({
7868
+ auth: state.auth ? { ...state.auth, ...data } : state.auth
7868
7869
  })),
7869
- updateAccount: (data2) => set((state) => ({
7870
- account: state.account ? { ...state.account, ...data2 } : state.account
7870
+ updateAccount: (data) => set((state) => ({
7871
+ account: state.account ? { ...state.account, ...data } : state.account
7871
7872
  })),
7872
7873
  hasPermission: (key) => !!get().auth?.permissions?.[key]
7873
7874
  }));
@@ -7911,13 +7912,13 @@ var useAuth = () => {
7911
7912
  setIsLoggedIn,
7912
7913
  setIsFetched,
7913
7914
  setAuth,
7914
- login: (data2) => {
7915
- if (data2?.auth && data2?.account) {
7916
- setAuth(data2.auth, data2.account);
7917
- } else if (data2?.user && data2?.account) {
7918
- setAuth(data2.user, data2.account);
7915
+ login: (data) => {
7916
+ if (data?.auth && data?.account) {
7917
+ setAuth(data.auth, data.account);
7918
+ } else if (data?.user && data?.account) {
7919
+ setAuth(data.user, data.account);
7919
7920
  } else {
7920
- setAuth(data2, data2?.account || data2);
7921
+ setAuth(data, data?.account || data);
7921
7922
  }
7922
7923
  },
7923
7924
  updateAuth,
@@ -7991,28 +7992,28 @@ function Accounts({ v, url }) {
7991
7992
  const [deleteAccount, setDeleteAccount] = (0, import_react33.useState)(null);
7992
7993
  const { isLoading, remove } = useApis_default();
7993
7994
  const isEmployee = type === "employee";
7994
- const { data: data2, TransactionViewComponent, reload } = useTransaction_default({
7995
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
7995
7996
  url: url || `/accounts/get/${type}`,
7996
7997
  v,
7997
7998
  dateFilter: false
7998
7999
  });
7999
8000
  const { Modal: Modal2 } = useModal();
8000
8001
  const navigate = (0, import_react_router_dom5.useNavigate)();
8001
- const items = (data3) => [
8002
+ const items = (data2) => [
8002
8003
  {
8003
8004
  label: `Edit ${type}`,
8004
8005
  icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react19.FilePenLine, { size: 16 }),
8005
- onClick: () => navigate(`update?id=${data3?._id}`)
8006
+ onClick: () => navigate(`update?id=${data2?._id}`)
8006
8007
  },
8007
8008
  {
8008
8009
  label: `Delete ${type}`,
8009
8010
  icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react19.Trash2, { className: "text-red-500", size: 16 }),
8010
- onClick: () => setDeleteAccount(data3)
8011
+ onClick: () => setDeleteAccount(data2)
8011
8012
  },
8012
- isEmployee && !data3?.user && {
8013
+ isEmployee && !data2?.user && {
8013
8014
  label: `Link User`,
8014
8015
  icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react19.Cable, { size: 16 }),
8015
- onClick: () => navigate(`link-user?id=${data3?._id}`)
8016
+ onClick: () => navigate(`link-user?id=${data2?._id}`)
8016
8017
  }
8017
8018
  ].filter(Boolean);
8018
8019
  const columns = [
@@ -8060,12 +8061,12 @@ function Accounts({ v, url }) {
8060
8061
  accessorKey: "actions",
8061
8062
  header: "Actions",
8062
8063
  cell: ({ row }) => {
8063
- const data3 = row.original;
8064
+ const data2 = row.original;
8064
8065
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
8065
8066
  Dropdown,
8066
8067
  {
8067
8068
  className: "cursor-pointer w-[150px]",
8068
- items: items(data3),
8069
+ items: items(data2),
8069
8070
  triggerMode: "hover",
8070
8071
  children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_lucide_react19.EllipsisVertical, {})
8071
8072
  }
@@ -8073,7 +8074,7 @@ function Accounts({ v, url }) {
8073
8074
  }
8074
8075
  }
8075
8076
  ].filter(Boolean);
8076
- const accounts = data2?.data || [];
8077
+ const accounts = data?.data || [];
8077
8078
  const onDelete = async (id) => {
8078
8079
  try {
8079
8080
  await remove({ url: `/accounts/delete/${id}` });
@@ -8118,2501 +8119,114 @@ function Accounts({ v, url }) {
8118
8119
  }
8119
8120
  var Accounts_default = Accounts;
8120
8121
 
8121
- // ../../node_modules/react-router/dist/development/chunk-LFPYN7LY.mjs
8122
- var React24 = __toESM(require("react"), 1);
8123
- var React25 = __toESM(require("react"), 1);
8124
- var React32 = __toESM(require("react"), 1);
8125
- var React42 = __toESM(require("react"), 1);
8126
- var React92 = __toESM(require("react"), 1);
8127
- var React82 = __toESM(require("react"), 1);
8128
- var React72 = __toESM(require("react"), 1);
8129
- var React62 = __toESM(require("react"), 1);
8130
- var React52 = __toESM(require("react"), 1);
8131
- var React102 = __toESM(require("react"), 1);
8132
- var React112 = __toESM(require("react"), 1);
8133
- var import_meta = {};
8134
- function invariant(value, message13) {
8135
- if (value === false || value === null || typeof value === "undefined") {
8136
- throw new Error(message13);
8137
- }
8138
- }
8139
- function warning3(cond, message13) {
8140
- if (!cond) {
8141
- if (typeof console !== "undefined") console.warn(message13);
8142
- try {
8143
- throw new Error(message13);
8144
- } catch (e) {
8145
- }
8146
- }
8147
- }
8148
- function createPath({
8149
- pathname = "/",
8150
- search = "",
8151
- hash = ""
8152
- }) {
8153
- if (search && search !== "?")
8154
- pathname += search.charAt(0) === "?" ? search : "?" + search;
8155
- if (hash && hash !== "#")
8156
- pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
8157
- return pathname;
8158
- }
8159
- function parsePath(path) {
8160
- let parsedPath = {};
8161
- if (path) {
8162
- let hashIndex = path.indexOf("#");
8163
- if (hashIndex >= 0) {
8164
- parsedPath.hash = path.substring(hashIndex);
8165
- path = path.substring(0, hashIndex);
8166
- }
8167
- let searchIndex = path.indexOf("?");
8168
- if (searchIndex >= 0) {
8169
- parsedPath.search = path.substring(searchIndex);
8170
- path = path.substring(0, searchIndex);
8171
- }
8172
- if (path) {
8173
- parsedPath.pathname = path;
8174
- }
8175
- }
8176
- return parsedPath;
8177
- }
8178
- var _map;
8179
- _map = /* @__PURE__ */ new WeakMap();
8180
- function matchRoutes(routes, locationArg, basename = "/") {
8181
- return matchRoutesImpl(routes, locationArg, basename, false);
8182
- }
8183
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
8184
- let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
8185
- let pathname = stripBasename(location.pathname || "/", basename);
8186
- if (pathname == null) {
8187
- return null;
8188
- }
8189
- let branches = flattenRoutes(routes);
8190
- rankRouteBranches(branches);
8191
- let matches = null;
8192
- for (let i = 0; matches == null && i < branches.length; ++i) {
8193
- let decoded = decodePath(pathname);
8194
- matches = matchRouteBranch(
8195
- branches[i],
8196
- decoded,
8197
- allowPartial
8198
- );
8199
- }
8200
- return matches;
8201
- }
8202
- function convertRouteMatchToUiMatch(match, loaderData) {
8203
- let { route, pathname, params } = match;
8204
- return {
8205
- id: route.id,
8206
- pathname,
8207
- params,
8208
- data: loaderData[route.id],
8209
- loaderData: loaderData[route.id],
8210
- handle: route.handle
8211
- };
8212
- }
8213
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
8214
- let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
8215
- let meta = {
8216
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
8217
- caseSensitive: route.caseSensitive === true,
8218
- childrenIndex: index,
8219
- route
8220
- };
8221
- if (meta.relativePath.startsWith("/")) {
8222
- if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
8223
- return;
8224
- }
8225
- invariant(
8226
- meta.relativePath.startsWith(parentPath),
8227
- `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
8228
- );
8229
- meta.relativePath = meta.relativePath.slice(parentPath.length);
8230
- }
8231
- let path = joinPaths([parentPath, meta.relativePath]);
8232
- let routesMeta = parentsMeta.concat(meta);
8233
- if (route.children && route.children.length > 0) {
8234
- invariant(
8235
- // Our types know better, but runtime JS may not!
8236
- // @ts-expect-error
8237
- route.index !== true,
8238
- `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
8239
- );
8240
- flattenRoutes(
8241
- route.children,
8242
- branches,
8243
- routesMeta,
8244
- path,
8245
- hasParentOptionalSegments
8246
- );
8247
- }
8248
- if (route.path == null && !route.index) {
8249
- return;
8250
- }
8251
- branches.push({
8252
- path,
8253
- score: computeScore(path, route.index),
8254
- routesMeta
8255
- });
8122
+ // src/hooks/useApp.tsx
8123
+ var import_react_router_dom6 = require("react-router-dom");
8124
+ var useApp = () => {
8125
+ const [searchParams] = (0, import_react_router_dom6.useSearchParams)();
8126
+ const navigate = (0, import_react_router_dom6.useNavigate)();
8127
+ const getParams = (key) => {
8128
+ const params = (0, import_react_router_dom6.useParams)();
8129
+ if (key) return params[key];
8130
+ return params;
8256
8131
  };
8257
- routes.forEach((route, index) => {
8258
- if (route.path === "" || !route.path?.includes("?")) {
8259
- flattenRoute(route, index);
8260
- } else {
8261
- for (let exploded of explodeOptionalSegments(route.path)) {
8262
- flattenRoute(route, index, true, exploded);
8263
- }
8264
- }
8265
- });
8266
- return branches;
8267
- }
8268
- function explodeOptionalSegments(path) {
8269
- let segments = path.split("/");
8270
- if (segments.length === 0) return [];
8271
- let [first, ...rest] = segments;
8272
- let isOptional = first.endsWith("?");
8273
- let required = first.replace(/\?$/, "");
8274
- if (rest.length === 0) {
8275
- return isOptional ? [required, ""] : [required];
8276
- }
8277
- let restExploded = explodeOptionalSegments(rest.join("/"));
8278
- let result = [];
8279
- result.push(
8280
- ...restExploded.map(
8281
- (subpath) => subpath === "" ? required : [required, subpath].join("/")
8282
- )
8283
- );
8284
- if (isOptional) {
8285
- result.push(...restExploded);
8286
- }
8287
- return result.map(
8288
- (exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
8289
- );
8290
- }
8291
- function rankRouteBranches(branches) {
8292
- branches.sort(
8293
- (a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
8294
- a.routesMeta.map((meta) => meta.childrenIndex),
8295
- b.routesMeta.map((meta) => meta.childrenIndex)
8296
- )
8297
- );
8298
- }
8299
- var paramRe = /^:[\w-]+$/;
8300
- var dynamicSegmentValue = 3;
8301
- var indexRouteValue = 2;
8302
- var emptySegmentValue = 1;
8303
- var staticSegmentValue = 10;
8304
- var splatPenalty = -2;
8305
- var isSplat = (s) => s === "*";
8306
- function computeScore(path, index) {
8307
- let segments = path.split("/");
8308
- let initialScore = segments.length;
8309
- if (segments.some(isSplat)) {
8310
- initialScore += splatPenalty;
8311
- }
8312
- if (index) {
8313
- initialScore += indexRouteValue;
8314
- }
8315
- return segments.filter((s) => !isSplat(s)).reduce(
8316
- (score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
8317
- initialScore
8318
- );
8319
- }
8320
- function compareIndexes(a, b) {
8321
- let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
8322
- return siblings ? (
8323
- // If two routes are siblings, we should try to match the earlier sibling
8324
- // first. This allows people to have fine-grained control over the matching
8325
- // behavior by simply putting routes with identical paths in the order they
8326
- // want them tried.
8327
- a[a.length - 1] - b[b.length - 1]
8328
- ) : (
8329
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
8330
- // so they sort equally.
8331
- 0
8332
- );
8333
- }
8334
- function matchRouteBranch(branch, pathname, allowPartial = false) {
8335
- let { routesMeta } = branch;
8336
- let matchedParams = {};
8337
- let matchedPathname = "/";
8338
- let matches = [];
8339
- for (let i = 0; i < routesMeta.length; ++i) {
8340
- let meta = routesMeta[i];
8341
- let end = i === routesMeta.length - 1;
8342
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
8343
- let match = matchPath(
8344
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
8345
- remainingPathname
8346
- );
8347
- let route = meta.route;
8348
- if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
8349
- match = matchPath(
8350
- {
8351
- path: meta.relativePath,
8352
- caseSensitive: meta.caseSensitive,
8353
- end: false
8354
- },
8355
- remainingPathname
8356
- );
8357
- }
8358
- if (!match) {
8359
- return null;
8360
- }
8361
- Object.assign(matchedParams, match.params);
8362
- matches.push({
8363
- // TODO: Can this as be avoided?
8364
- params: matchedParams,
8365
- pathname: joinPaths([matchedPathname, match.pathname]),
8366
- pathnameBase: normalizePathname(
8367
- joinPaths([matchedPathname, match.pathnameBase])
8368
- ),
8369
- route
8370
- });
8371
- if (match.pathnameBase !== "/") {
8372
- matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
8373
- }
8374
- }
8375
- return matches;
8376
- }
8377
- function matchPath(pattern, pathname) {
8378
- if (typeof pattern === "string") {
8379
- pattern = { path: pattern, caseSensitive: false, end: true };
8380
- }
8381
- let [matcher, compiledParams] = compilePath(
8382
- pattern.path,
8383
- pattern.caseSensitive,
8384
- pattern.end
8385
- );
8386
- let match = pathname.match(matcher);
8387
- if (!match) return null;
8388
- let matchedPathname = match[0];
8389
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
8390
- let captureGroups = match.slice(1);
8391
- let params = compiledParams.reduce(
8392
- (memo2, { paramName, isOptional }, index) => {
8393
- if (paramName === "*") {
8394
- let splatValue = captureGroups[index] || "";
8395
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
8396
- }
8397
- const value = captureGroups[index];
8398
- if (isOptional && !value) {
8399
- memo2[paramName] = void 0;
8400
- } else {
8401
- memo2[paramName] = (value || "").replace(/%2F/g, "/");
8402
- }
8403
- return memo2;
8404
- },
8405
- {}
8406
- );
8407
- return {
8408
- params,
8409
- pathname: matchedPathname,
8410
- pathnameBase,
8411
- pattern
8132
+ const getQuery = (key) => {
8133
+ if (key) return searchParams.get(key);
8134
+ return Object.fromEntries(searchParams.entries());
8412
8135
  };
8413
- }
8414
- function compilePath(path, caseSensitive = false, end = true) {
8415
- warning3(
8416
- path === "*" || !path.endsWith("*") || path.endsWith("/*"),
8417
- `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`
8418
- );
8419
- let params = [];
8420
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
8421
- /\/:([\w-]+)(\?)?/g,
8422
- (match, paramName, isOptional, index, str) => {
8423
- params.push({ paramName, isOptional: isOptional != null });
8424
- if (isOptional) {
8425
- let nextChar = str.charAt(index + match.length);
8426
- if (nextChar && nextChar !== "/") {
8427
- return "/([^\\/]*)";
8428
- }
8429
- return "(?:/([^\\/]*))?";
8430
- }
8431
- return "/([^\\/]+)";
8432
- }
8433
- ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
8434
- if (path.endsWith("*")) {
8435
- params.push({ paramName: "*" });
8436
- regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
8437
- } else if (end) {
8438
- regexpSource += "\\/*$";
8439
- } else if (path !== "" && path !== "/") {
8440
- regexpSource += "(?:(?=\\/|$))";
8441
- } else {
8442
- }
8443
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
8444
- return [matcher, params];
8445
- }
8446
- function decodePath(value) {
8447
- try {
8448
- return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
8449
- } catch (error) {
8450
- warning3(
8451
- false,
8452
- `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
8453
- );
8454
- return value;
8455
- }
8456
- }
8457
- function stripBasename(pathname, basename) {
8458
- if (basename === "/") return pathname;
8459
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
8460
- return null;
8461
- }
8462
- let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
8463
- let nextChar = pathname.charAt(startIndex);
8464
- if (nextChar && nextChar !== "/") {
8465
- return null;
8466
- }
8467
- return pathname.slice(startIndex) || "/";
8468
- }
8469
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
8470
- function resolvePath(to, fromPathname = "/") {
8471
- let {
8472
- pathname: toPathname,
8473
- search = "",
8474
- hash = ""
8475
- } = typeof to === "string" ? parsePath(to) : to;
8476
- let pathname;
8477
- if (toPathname) {
8478
- toPathname = toPathname.replace(/\/\/+/g, "/");
8479
- if (toPathname.startsWith("/")) {
8480
- pathname = resolvePathname(toPathname.substring(1), "/");
8481
- } else {
8482
- pathname = resolvePathname(toPathname, fromPathname);
8483
- }
8484
- } else {
8485
- pathname = fromPathname;
8486
- }
8487
8136
  return {
8488
- pathname,
8489
- search: normalizeSearch(search),
8490
- hash: normalizeHash(hash)
8137
+ navigate,
8138
+ getQuery,
8139
+ getParams
8491
8140
  };
8492
- }
8493
- function resolvePathname(relativePath, fromPathname) {
8494
- let segments = fromPathname.replace(/\/+$/, "").split("/");
8495
- let relativeSegments = relativePath.split("/");
8496
- relativeSegments.forEach((segment) => {
8497
- if (segment === "..") {
8498
- if (segments.length > 1) segments.pop();
8499
- } else if (segment !== ".") {
8500
- segments.push(segment);
8501
- }
8502
- });
8503
- return segments.length > 1 ? segments.join("/") : "/";
8504
- }
8505
- function getInvalidPathError(char, field, dest, path) {
8506
- return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
8507
- path
8508
- )}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
8509
- }
8510
- function getPathContributingMatches(matches) {
8511
- return matches.filter(
8512
- (match, index) => index === 0 || match.route.path && match.route.path.length > 0
8513
- );
8514
- }
8515
- function getResolveToMatches(matches) {
8516
- let pathMatches = getPathContributingMatches(matches);
8517
- return pathMatches.map(
8518
- (match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
8519
- );
8520
- }
8521
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
8522
- let to;
8523
- if (typeof toArg === "string") {
8524
- to = parsePath(toArg);
8525
- } else {
8526
- to = { ...toArg };
8527
- invariant(
8528
- !to.pathname || !to.pathname.includes("?"),
8529
- getInvalidPathError("?", "pathname", "search", to)
8530
- );
8531
- invariant(
8532
- !to.pathname || !to.pathname.includes("#"),
8533
- getInvalidPathError("#", "pathname", "hash", to)
8534
- );
8535
- invariant(
8536
- !to.search || !to.search.includes("#"),
8537
- getInvalidPathError("#", "search", "hash", to)
8538
- );
8539
- }
8540
- let isEmptyPath = toArg === "" || to.pathname === "";
8541
- let toPathname = isEmptyPath ? "/" : to.pathname;
8542
- let from;
8543
- if (toPathname == null) {
8544
- from = locationPathname;
8545
- } else {
8546
- let routePathnameIndex = routePathnames.length - 1;
8547
- if (!isPathRelative && toPathname.startsWith("..")) {
8548
- let toSegments = toPathname.split("/");
8549
- while (toSegments[0] === "..") {
8550
- toSegments.shift();
8551
- routePathnameIndex -= 1;
8552
- }
8553
- to.pathname = toSegments.join("/");
8554
- }
8555
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
8556
- }
8557
- let path = resolvePath(to, from);
8558
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
8559
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
8560
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
8561
- path.pathname += "/";
8562
- }
8563
- return path;
8564
- }
8565
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
8566
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
8567
- var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
8568
- var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
8569
- var ErrorResponseImpl = class {
8570
- constructor(status, statusText, data2, internal = false) {
8571
- this.status = status;
8572
- this.statusText = statusText || "";
8573
- this.internal = internal;
8574
- if (data2 instanceof Error) {
8575
- this.data = data2.toString();
8576
- this.error = data2;
8577
- } else {
8578
- this.data = data2;
8579
- }
8580
- }
8581
8141
  };
8582
- function isRouteErrorResponse(error) {
8583
- return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
8584
- }
8585
- function getRoutePattern(matches) {
8586
- return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
8587
- }
8588
- var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
8589
- function parseToInfo(_to, basename) {
8590
- let to = _to;
8591
- if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
8592
- return {
8593
- absoluteURL: void 0,
8594
- isExternal: false,
8595
- to
8596
- };
8597
- }
8598
- let absoluteURL = to;
8599
- let isExternal = false;
8600
- if (isBrowser2) {
8142
+ var useApp_default = useApp;
8143
+
8144
+ // src/utils/Enums.ts
8145
+ var Enums = {
8146
+ roles: ["admin", "staff"],
8147
+ sex: ["male", "female"],
8148
+ accountTypes: ["employee", "supplier", "customer", "investor"],
8149
+ verificationTypes: ["email_verification", "password_reset"],
8150
+ auditActions: ["create", "update", "delete", "login", "logout"]
8151
+ };
8152
+ var Enums_default = Enums;
8153
+
8154
+ // src/components/accounts/schema.tsx
8155
+ var import_zod2 = require("zod");
8156
+ var createAccountSchema = import_zod2.z.object({
8157
+ name: import_zod2.z.string().min(2, { message: "Name must be at least 2 characters" }),
8158
+ email: import_zod2.z.string().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
8159
+ message: "Please enter a valid email address"
8160
+ }).transform((val) => val?.toLowerCase()),
8161
+ phoneNumber: import_zod2.z.string().optional(),
8162
+ sex: import_zod2.z.enum(Enums_default.sex),
8163
+ owner: import_zod2.z.string().min(1, { message: "Owner is required" }),
8164
+ host: import_zod2.z.string().min(1, { message: "Host is required" })
8165
+ });
8166
+
8167
+ // src/components/accounts/AccountForm.tsx
8168
+ var import_react_hook_form8 = require("react-hook-form");
8169
+ var import_zod3 = require("@hookform/resolvers/zod");
8170
+ var import_antd7 = require("antd");
8171
+ var import_react34 = require("react");
8172
+ var import_jsx_runtime43 = require("react/jsx-runtime");
8173
+ function AccountForm() {
8174
+ const { getQuery, getParams, navigate } = useApp_default();
8175
+ const id = getQuery("id");
8176
+ const type = getParams("type");
8177
+ const isEdit = !!id;
8178
+ const { post, put, isLoading } = useApis_default();
8179
+ const { isLoading: isLoadingGet, get } = useApis_default();
8180
+ const methods = (0, import_react_hook_form8.useForm)({
8181
+ resolver: (0, import_zod3.zodResolver)(createAccountSchema),
8182
+ defaultValues: {
8183
+ name: "",
8184
+ email: "",
8185
+ phoneNumber: "",
8186
+ sex: "male",
8187
+ owner: "",
8188
+ host: ""
8189
+ },
8190
+ shouldUnregister: false
8191
+ });
8192
+ const { handleSubmit } = methods;
8193
+ const onSubmit = async (data) => {
8601
8194
  try {
8602
- let currentUrl = new URL(window.location.href);
8603
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
8604
- let path = stripBasename(targetUrl.pathname, basename);
8605
- if (targetUrl.origin === currentUrl.origin && path != null) {
8606
- to = path + targetUrl.search + targetUrl.hash;
8195
+ const payload = {
8196
+ ...data,
8197
+ type
8198
+ };
8199
+ if (isEdit) {
8200
+ await put({
8201
+ url: `/accounts/update/${id}`,
8202
+ body: payload
8203
+ });
8607
8204
  } else {
8608
- isExternal = true;
8205
+ await post({
8206
+ url: "/accounts/create",
8207
+ body: payload
8208
+ });
8609
8209
  }
8610
- } catch (e) {
8611
- warning3(
8612
- false,
8613
- `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
8614
- );
8210
+ import_antd7.message.success(`${type} ${isEdit ? "updated" : "created"} successfully`);
8211
+ navigate(-1);
8212
+ } catch (error) {
8213
+ import_antd7.message.error(error?.message || "Something went wrong");
8615
8214
  }
8616
- }
8617
- return {
8618
- absoluteURL,
8619
- isExternal,
8620
- to
8621
8215
  };
8622
- }
8623
- var objectProtoNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
8624
- var validMutationMethodsArr = [
8625
- "POST",
8626
- "PUT",
8627
- "PATCH",
8628
- "DELETE"
8629
- ];
8630
- var validMutationMethods = new Set(
8631
- validMutationMethodsArr
8632
- );
8633
- var validRequestMethodsArr = [
8634
- "GET",
8635
- ...validMutationMethodsArr
8636
- ];
8637
- var validRequestMethods = new Set(validRequestMethodsArr);
8638
- var DataRouterContext = React24.createContext(null);
8639
- DataRouterContext.displayName = "DataRouter";
8640
- var DataRouterStateContext = React24.createContext(null);
8641
- DataRouterStateContext.displayName = "DataRouterState";
8642
- var RSCRouterContext = React24.createContext(false);
8643
- var ViewTransitionContext = React24.createContext({
8644
- isTransitioning: false
8645
- });
8646
- ViewTransitionContext.displayName = "ViewTransition";
8647
- var FetchersContext = React24.createContext(
8648
- /* @__PURE__ */ new Map()
8649
- );
8650
- FetchersContext.displayName = "Fetchers";
8651
- var AwaitContext = React24.createContext(null);
8652
- AwaitContext.displayName = "Await";
8653
- var NavigationContext = React24.createContext(
8654
- null
8655
- );
8656
- NavigationContext.displayName = "Navigation";
8657
- var LocationContext = React24.createContext(
8658
- null
8659
- );
8660
- LocationContext.displayName = "Location";
8661
- var RouteContext = React24.createContext({
8662
- outlet: null,
8663
- matches: [],
8664
- isDataRoute: false
8665
- });
8666
- RouteContext.displayName = "Route";
8667
- var RouteErrorContext = React24.createContext(null);
8668
- RouteErrorContext.displayName = "RouteError";
8669
- var ENABLE_DEV_WARNINGS = true;
8670
- var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
8671
- var ERROR_DIGEST_REDIRECT = "REDIRECT";
8672
- var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
8673
- function decodeRedirectErrorDigest(digest) {
8674
- if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
8216
+ const fetches = async () => {
8675
8217
  try {
8676
- let parsed = JSON.parse(digest.slice(28));
8677
- if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
8678
- return parsed;
8679
- }
8680
- } catch {
8218
+ const res = await get({
8219
+ url: `/accounts/get/${type}?id=${id}`
8220
+ });
8221
+ const data = res.data;
8222
+ methods.reset(data);
8223
+ } catch (error) {
8224
+ import_antd7.message.error(error?.message || "Something went wrong");
8681
8225
  }
8682
- }
8683
- }
8684
- function decodeRouteErrorResponseDigest(digest) {
8685
- if (digest.startsWith(
8686
- `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
8687
- )) {
8688
- try {
8689
- let parsed = JSON.parse(digest.slice(40));
8690
- if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
8691
- return new ErrorResponseImpl(
8692
- parsed.status,
8693
- parsed.statusText,
8694
- parsed.data
8695
- );
8696
- }
8697
- } catch {
8698
- }
8699
- }
8700
- }
8701
- function useHref(to, { relative } = {}) {
8702
- invariant(
8703
- useInRouterContext(),
8704
- // TODO: This error is probably because they somehow have 2 versions of the
8705
- // router loaded. We can help them understand how to avoid that.
8706
- `useHref() may be used only in the context of a <Router> component.`
8707
- );
8708
- let { basename, navigator: navigator2 } = React25.useContext(NavigationContext);
8709
- let { hash, pathname, search } = useResolvedPath(to, { relative });
8710
- let joinedPathname = pathname;
8711
- if (basename !== "/") {
8712
- joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
8713
- }
8714
- return navigator2.createHref({ pathname: joinedPathname, search, hash });
8715
- }
8716
- function useInRouterContext() {
8717
- return React25.useContext(LocationContext) != null;
8718
- }
8719
- function useLocation3() {
8720
- invariant(
8721
- useInRouterContext(),
8722
- // TODO: This error is probably because they somehow have 2 versions of the
8723
- // router loaded. We can help them understand how to avoid that.
8724
- `useLocation() may be used only in the context of a <Router> component.`
8725
- );
8726
- return React25.useContext(LocationContext).location;
8727
- }
8728
- var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
8729
- function useIsomorphicLayoutEffect(cb) {
8730
- let isStatic = React25.useContext(NavigationContext).static;
8731
- if (!isStatic) {
8732
- React25.useLayoutEffect(cb);
8733
- }
8734
- }
8735
- function useNavigate5() {
8736
- let { isDataRoute } = React25.useContext(RouteContext);
8737
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
8738
- }
8739
- function useNavigateUnstable() {
8740
- invariant(
8741
- useInRouterContext(),
8742
- // TODO: This error is probably because they somehow have 2 versions of the
8743
- // router loaded. We can help them understand how to avoid that.
8744
- `useNavigate() may be used only in the context of a <Router> component.`
8745
- );
8746
- let dataRouterContext = React25.useContext(DataRouterContext);
8747
- let { basename, navigator: navigator2 } = React25.useContext(NavigationContext);
8748
- let { matches } = React25.useContext(RouteContext);
8749
- let { pathname: locationPathname } = useLocation3();
8750
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
8751
- let activeRef = React25.useRef(false);
8752
- useIsomorphicLayoutEffect(() => {
8753
- activeRef.current = true;
8754
- });
8755
- let navigate = React25.useCallback(
8756
- (to, options = {}) => {
8757
- warning3(activeRef.current, navigateEffectWarning);
8758
- if (!activeRef.current) return;
8759
- if (typeof to === "number") {
8760
- navigator2.go(to);
8761
- return;
8762
- }
8763
- let path = resolveTo(
8764
- to,
8765
- JSON.parse(routePathnamesJson),
8766
- locationPathname,
8767
- options.relative === "path"
8768
- );
8769
- if (dataRouterContext == null && basename !== "/") {
8770
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
8771
- }
8772
- (!!options.replace ? navigator2.replace : navigator2.push)(
8773
- path,
8774
- options.state,
8775
- options
8776
- );
8777
- },
8778
- [
8779
- basename,
8780
- navigator2,
8781
- routePathnamesJson,
8782
- locationPathname,
8783
- dataRouterContext
8784
- ]
8785
- );
8786
- return navigate;
8787
- }
8788
- var OutletContext = React25.createContext(null);
8789
- function useParams2() {
8790
- let { matches } = React25.useContext(RouteContext);
8791
- let routeMatch = matches[matches.length - 1];
8792
- return routeMatch ? routeMatch.params : {};
8793
- }
8794
- function useResolvedPath(to, { relative } = {}) {
8795
- let { matches } = React25.useContext(RouteContext);
8796
- let { pathname: locationPathname } = useLocation3();
8797
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
8798
- return React25.useMemo(
8799
- () => resolveTo(
8800
- to,
8801
- JSON.parse(routePathnamesJson),
8802
- locationPathname,
8803
- relative === "path"
8804
- ),
8805
- [to, routePathnamesJson, locationPathname, relative]
8806
- );
8807
- }
8808
- function useRoutesImpl(routes, locationArg, dataRouterOpts) {
8809
- invariant(
8810
- useInRouterContext(),
8811
- // TODO: This error is probably because they somehow have 2 versions of the
8812
- // router loaded. We can help them understand how to avoid that.
8813
- `useRoutes() may be used only in the context of a <Router> component.`
8814
- );
8815
- let { navigator: navigator2 } = React25.useContext(NavigationContext);
8816
- let { matches: parentMatches } = React25.useContext(RouteContext);
8817
- let routeMatch = parentMatches[parentMatches.length - 1];
8818
- let parentParams = routeMatch ? routeMatch.params : {};
8819
- let parentPathname = routeMatch ? routeMatch.pathname : "/";
8820
- let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
8821
- let parentRoute = routeMatch && routeMatch.route;
8822
- if (ENABLE_DEV_WARNINGS) {
8823
- let parentPath = parentRoute && parentRoute.path || "";
8824
- warningOnce2(
8825
- parentPathname,
8826
- !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
8827
- `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
8828
-
8829
- Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
8830
- );
8831
- }
8832
- let locationFromContext = useLocation3();
8833
- let location;
8834
- if (locationArg) {
8835
- let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
8836
- invariant(
8837
- parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase),
8838
- `When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${parentPathnameBase}" but pathname "${parsedLocationArg.pathname}" was given in the \`location\` prop.`
8839
- );
8840
- location = parsedLocationArg;
8841
- } else {
8842
- location = locationFromContext;
8843
- }
8844
- let pathname = location.pathname || "/";
8845
- let remainingPathname = pathname;
8846
- if (parentPathnameBase !== "/") {
8847
- let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
8848
- let segments = pathname.replace(/^\//, "").split("/");
8849
- remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
8850
- }
8851
- let matches = matchRoutes(routes, { pathname: remainingPathname });
8852
- if (ENABLE_DEV_WARNINGS) {
8853
- warning3(
8854
- parentRoute || matches != null,
8855
- `No routes matched location "${location.pathname}${location.search}${location.hash}" `
8856
- );
8857
- warning3(
8858
- matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
8859
- `Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
8860
- );
8861
- }
8862
- let renderedMatches = _renderMatches(
8863
- matches && matches.map(
8864
- (match) => Object.assign({}, match, {
8865
- params: Object.assign({}, parentParams, match.params),
8866
- pathname: joinPaths([
8867
- parentPathnameBase,
8868
- // Re-encode pathnames that were decoded inside matchRoutes.
8869
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
8870
- // `new URL()` internally and we need to prevent it from treating
8871
- // them as separators
8872
- navigator2.encodeLocation ? navigator2.encodeLocation(
8873
- match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
8874
- ).pathname : match.pathname
8875
- ]),
8876
- pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
8877
- parentPathnameBase,
8878
- // Re-encode pathnames that were decoded inside matchRoutes
8879
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
8880
- // `new URL()` internally and we need to prevent it from treating
8881
- // them as separators
8882
- navigator2.encodeLocation ? navigator2.encodeLocation(
8883
- match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
8884
- ).pathname : match.pathnameBase
8885
- ])
8886
- })
8887
- ),
8888
- parentMatches,
8889
- dataRouterOpts
8890
- );
8891
- if (locationArg && renderedMatches) {
8892
- return /* @__PURE__ */ React25.createElement(
8893
- LocationContext.Provider,
8894
- {
8895
- value: {
8896
- location: {
8897
- pathname: "/",
8898
- search: "",
8899
- hash: "",
8900
- state: null,
8901
- key: "default",
8902
- unstable_mask: void 0,
8903
- ...location
8904
- },
8905
- navigationType: "POP"
8906
- /* Pop */
8907
- }
8908
- },
8909
- renderedMatches
8910
- );
8911
- }
8912
- return renderedMatches;
8913
- }
8914
- function DefaultErrorComponent() {
8915
- let error = useRouteError();
8916
- let message13 = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
8917
- let stack = error instanceof Error ? error.stack : null;
8918
- let lightgrey = "rgba(200,200,200, 0.5)";
8919
- let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
8920
- let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
8921
- let devInfo = null;
8922
- if (ENABLE_DEV_WARNINGS) {
8923
- console.error(
8924
- "Error handled by React Router default ErrorBoundary:",
8925
- error
8926
- );
8927
- devInfo = /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React25.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React25.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React25.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
8928
- }
8929
- return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React25.createElement("h3", { style: { fontStyle: "italic" } }, message13), stack ? /* @__PURE__ */ React25.createElement("pre", { style: preStyles }, stack) : null, devInfo);
8930
- }
8931
- var defaultErrorElement = /* @__PURE__ */ React25.createElement(DefaultErrorComponent, null);
8932
- var RenderErrorBoundary = class extends React25.Component {
8933
- constructor(props) {
8934
- super(props);
8935
- this.state = {
8936
- location: props.location,
8937
- revalidation: props.revalidation,
8938
- error: props.error
8939
- };
8940
- }
8941
- static getDerivedStateFromError(error) {
8942
- return { error };
8943
- }
8944
- static getDerivedStateFromProps(props, state) {
8945
- if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
8946
- return {
8947
- error: props.error,
8948
- location: props.location,
8949
- revalidation: props.revalidation
8950
- };
8951
- }
8952
- return {
8953
- error: props.error !== void 0 ? props.error : state.error,
8954
- location: state.location,
8955
- revalidation: props.revalidation || state.revalidation
8956
- };
8957
- }
8958
- componentDidCatch(error, errorInfo) {
8959
- if (this.props.onError) {
8960
- this.props.onError(error, errorInfo);
8961
- } else {
8962
- console.error(
8963
- "React Router caught the following error during render",
8964
- error
8965
- );
8966
- }
8967
- }
8968
- render() {
8969
- let error = this.state.error;
8970
- if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
8971
- const decoded = decodeRouteErrorResponseDigest(error.digest);
8972
- if (decoded) error = decoded;
8973
- }
8974
- let result = error !== void 0 ? /* @__PURE__ */ React25.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React25.createElement(
8975
- RouteErrorContext.Provider,
8976
- {
8977
- value: error,
8978
- children: this.props.component
8979
- }
8980
- )) : this.props.children;
8981
- if (this.context) {
8982
- return /* @__PURE__ */ React25.createElement(RSCErrorHandler, { error }, result);
8983
- }
8984
- return result;
8985
- }
8986
- };
8987
- RenderErrorBoundary.contextType = RSCRouterContext;
8988
- var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
8989
- function RSCErrorHandler({
8990
- children,
8991
- error
8992
- }) {
8993
- let { basename } = React25.useContext(NavigationContext);
8994
- if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
8995
- let redirect2 = decodeRedirectErrorDigest(error.digest);
8996
- if (redirect2) {
8997
- let existingRedirect = errorRedirectHandledMap.get(error);
8998
- if (existingRedirect) throw existingRedirect;
8999
- let parsed = parseToInfo(redirect2.location, basename);
9000
- if (isBrowser2 && !errorRedirectHandledMap.get(error)) {
9001
- if (parsed.isExternal || redirect2.reloadDocument) {
9002
- window.location.href = parsed.absoluteURL || parsed.to;
9003
- } else {
9004
- const redirectPromise = Promise.resolve().then(
9005
- () => window.__reactRouterDataRouter.navigate(parsed.to, {
9006
- replace: redirect2.replace
9007
- })
9008
- );
9009
- errorRedirectHandledMap.set(error, redirectPromise);
9010
- throw redirectPromise;
9011
- }
9012
- }
9013
- return /* @__PURE__ */ React25.createElement(
9014
- "meta",
9015
- {
9016
- httpEquiv: "refresh",
9017
- content: `0;url=${parsed.absoluteURL || parsed.to}`
9018
- }
9019
- );
9020
- }
9021
- }
9022
- return children;
9023
- }
9024
- function RenderedRoute({ routeContext, match, children }) {
9025
- let dataRouterContext = React25.useContext(DataRouterContext);
9026
- if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
9027
- dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
9028
- }
9029
- return /* @__PURE__ */ React25.createElement(RouteContext.Provider, { value: routeContext }, children);
9030
- }
9031
- function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
9032
- let dataRouterState = dataRouterOpts?.state;
9033
- if (matches == null) {
9034
- if (!dataRouterState) {
9035
- return null;
9036
- }
9037
- if (dataRouterState.errors) {
9038
- matches = dataRouterState.matches;
9039
- } else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
9040
- matches = dataRouterState.matches;
9041
- } else {
9042
- return null;
9043
- }
9044
- }
9045
- let renderedMatches = matches;
9046
- let errors = dataRouterState?.errors;
9047
- if (errors != null) {
9048
- let errorIndex = renderedMatches.findIndex(
9049
- (m) => m.route.id && errors?.[m.route.id] !== void 0
9050
- );
9051
- invariant(
9052
- errorIndex >= 0,
9053
- `Could not find a matching route for errors on route IDs: ${Object.keys(
9054
- errors
9055
- ).join(",")}`
9056
- );
9057
- renderedMatches = renderedMatches.slice(
9058
- 0,
9059
- Math.min(renderedMatches.length, errorIndex + 1)
9060
- );
9061
- }
9062
- let renderFallback = false;
9063
- let fallbackIndex = -1;
9064
- if (dataRouterOpts && dataRouterState) {
9065
- renderFallback = dataRouterState.renderFallback;
9066
- for (let i = 0; i < renderedMatches.length; i++) {
9067
- let match = renderedMatches[i];
9068
- if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
9069
- fallbackIndex = i;
9070
- }
9071
- if (match.route.id) {
9072
- let { loaderData, errors: errors2 } = dataRouterState;
9073
- let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
9074
- if (match.route.lazy || needsToRunLoader) {
9075
- if (dataRouterOpts.isStatic) {
9076
- renderFallback = true;
9077
- }
9078
- if (fallbackIndex >= 0) {
9079
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
9080
- } else {
9081
- renderedMatches = [renderedMatches[0]];
9082
- }
9083
- break;
9084
- }
9085
- }
9086
- }
9087
- }
9088
- let onErrorHandler = dataRouterOpts?.onError;
9089
- let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
9090
- onErrorHandler(error, {
9091
- location: dataRouterState.location,
9092
- params: dataRouterState.matches?.[0]?.params ?? {},
9093
- unstable_pattern: getRoutePattern(dataRouterState.matches),
9094
- errorInfo
9095
- });
9096
- } : void 0;
9097
- return renderedMatches.reduceRight(
9098
- (outlet, match, index) => {
9099
- let error;
9100
- let shouldRenderHydrateFallback = false;
9101
- let errorElement = null;
9102
- let hydrateFallbackElement = null;
9103
- if (dataRouterState) {
9104
- error = errors && match.route.id ? errors[match.route.id] : void 0;
9105
- errorElement = match.route.errorElement || defaultErrorElement;
9106
- if (renderFallback) {
9107
- if (fallbackIndex < 0 && index === 0) {
9108
- warningOnce2(
9109
- "route-fallback",
9110
- false,
9111
- "No `HydrateFallback` element provided to render during initial hydration"
9112
- );
9113
- shouldRenderHydrateFallback = true;
9114
- hydrateFallbackElement = null;
9115
- } else if (fallbackIndex === index) {
9116
- shouldRenderHydrateFallback = true;
9117
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
9118
- }
9119
- }
9120
- }
9121
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
9122
- let getChildren = () => {
9123
- let children;
9124
- if (error) {
9125
- children = errorElement;
9126
- } else if (shouldRenderHydrateFallback) {
9127
- children = hydrateFallbackElement;
9128
- } else if (match.route.Component) {
9129
- children = /* @__PURE__ */ React25.createElement(match.route.Component, null);
9130
- } else if (match.route.element) {
9131
- children = match.route.element;
9132
- } else {
9133
- children = outlet;
9134
- }
9135
- return /* @__PURE__ */ React25.createElement(
9136
- RenderedRoute,
9137
- {
9138
- match,
9139
- routeContext: {
9140
- outlet,
9141
- matches: matches2,
9142
- isDataRoute: dataRouterState != null
9143
- },
9144
- children
9145
- }
9146
- );
9147
- };
9148
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React25.createElement(
9149
- RenderErrorBoundary,
9150
- {
9151
- location: dataRouterState.location,
9152
- revalidation: dataRouterState.revalidation,
9153
- component: errorElement,
9154
- error,
9155
- children: getChildren(),
9156
- routeContext: { outlet: null, matches: matches2, isDataRoute: true },
9157
- onError
9158
- }
9159
- ) : getChildren();
9160
- },
9161
- null
9162
- );
9163
- }
9164
- function getDataRouterConsoleError(hookName) {
9165
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
9166
- }
9167
- function useDataRouterContext(hookName) {
9168
- let ctx = React25.useContext(DataRouterContext);
9169
- invariant(ctx, getDataRouterConsoleError(hookName));
9170
- return ctx;
9171
- }
9172
- function useDataRouterState(hookName) {
9173
- let state = React25.useContext(DataRouterStateContext);
9174
- invariant(state, getDataRouterConsoleError(hookName));
9175
- return state;
9176
- }
9177
- function useRouteContext(hookName) {
9178
- let route = React25.useContext(RouteContext);
9179
- invariant(route, getDataRouterConsoleError(hookName));
9180
- return route;
9181
- }
9182
- function useCurrentRouteId(hookName) {
9183
- let route = useRouteContext(hookName);
9184
- let thisRoute = route.matches[route.matches.length - 1];
9185
- invariant(
9186
- thisRoute.route.id,
9187
- `${hookName} can only be used on routes that contain a unique "id"`
9188
- );
9189
- return thisRoute.route.id;
9190
- }
9191
- function useRouteId() {
9192
- return useCurrentRouteId(
9193
- "useRouteId"
9194
- /* UseRouteId */
9195
- );
9196
- }
9197
- function useNavigation() {
9198
- let state = useDataRouterState(
9199
- "useNavigation"
9200
- /* UseNavigation */
9201
- );
9202
- return state.navigation;
9203
- }
9204
- function useMatches() {
9205
- let { matches, loaderData } = useDataRouterState(
9206
- "useMatches"
9207
- /* UseMatches */
9208
- );
9209
- return React25.useMemo(
9210
- () => matches.map((m) => convertRouteMatchToUiMatch(m, loaderData)),
9211
- [matches, loaderData]
9212
- );
9213
- }
9214
- function useRouteError() {
9215
- let error = React25.useContext(RouteErrorContext);
9216
- let state = useDataRouterState(
9217
- "useRouteError"
9218
- /* UseRouteError */
9219
- );
9220
- let routeId = useCurrentRouteId(
9221
- "useRouteError"
9222
- /* UseRouteError */
9223
- );
9224
- if (error !== void 0) {
9225
- return error;
9226
- }
9227
- return state.errors?.[routeId];
9228
- }
9229
- function useNavigateStable() {
9230
- let { router } = useDataRouterContext(
9231
- "useNavigate"
9232
- /* UseNavigateStable */
9233
- );
9234
- let id = useCurrentRouteId(
9235
- "useNavigate"
9236
- /* UseNavigateStable */
9237
- );
9238
- let activeRef = React25.useRef(false);
9239
- useIsomorphicLayoutEffect(() => {
9240
- activeRef.current = true;
9241
- });
9242
- let navigate = React25.useCallback(
9243
- async (to, options = {}) => {
9244
- warning3(activeRef.current, navigateEffectWarning);
9245
- if (!activeRef.current) return;
9246
- if (typeof to === "number") {
9247
- await router.navigate(to);
9248
- } else {
9249
- await router.navigate(to, { fromRouteId: id, ...options });
9250
- }
9251
- },
9252
- [router, id]
9253
- );
9254
- return navigate;
9255
- }
9256
- var alreadyWarned = {};
9257
- function warningOnce2(key, cond, message13) {
9258
- if (!cond && !alreadyWarned[key]) {
9259
- alreadyWarned[key] = true;
9260
- warning3(false, message13);
9261
- }
9262
- }
9263
- var USE_OPTIMISTIC = "useOptimistic";
9264
- var useOptimisticImpl = React32[USE_OPTIMISTIC];
9265
- var MemoizedDataRoutes = React32.memo(DataRoutes);
9266
- function DataRoutes({
9267
- routes,
9268
- future,
9269
- state,
9270
- isStatic,
9271
- onError
9272
- }) {
9273
- return useRoutesImpl(routes, void 0, { state, isStatic, onError, future });
9274
- }
9275
- function Router({
9276
- basename: basenameProp = "/",
9277
- children = null,
9278
- location: locationProp,
9279
- navigationType = "POP",
9280
- navigator: navigator2,
9281
- static: staticProp = false,
9282
- unstable_useTransitions
9283
- }) {
9284
- invariant(
9285
- !useInRouterContext(),
9286
- `You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`
9287
- );
9288
- let basename = basenameProp.replace(/^\/*/, "/");
9289
- let navigationContext = React32.useMemo(
9290
- () => ({
9291
- basename,
9292
- navigator: navigator2,
9293
- static: staticProp,
9294
- unstable_useTransitions,
9295
- future: {}
9296
- }),
9297
- [basename, navigator2, staticProp, unstable_useTransitions]
9298
- );
9299
- if (typeof locationProp === "string") {
9300
- locationProp = parsePath(locationProp);
9301
- }
9302
- let {
9303
- pathname = "/",
9304
- search = "",
9305
- hash = "",
9306
- state = null,
9307
- key = "default",
9308
- unstable_mask
9309
- } = locationProp;
9310
- let locationContext = React32.useMemo(() => {
9311
- let trailingPathname = stripBasename(pathname, basename);
9312
- if (trailingPathname == null) {
9313
- return null;
9314
- }
9315
- return {
9316
- location: {
9317
- pathname: trailingPathname,
9318
- search,
9319
- hash,
9320
- state,
9321
- key,
9322
- unstable_mask
9323
- },
9324
- navigationType
9325
- };
9326
- }, [
9327
- basename,
9328
- pathname,
9329
- search,
9330
- hash,
9331
- state,
9332
- key,
9333
- navigationType,
9334
- unstable_mask
9335
- ]);
9336
- warning3(
9337
- locationContext != null,
9338
- `<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
9339
- );
9340
- if (locationContext == null) {
9341
- return null;
9342
- }
9343
- return /* @__PURE__ */ React32.createElement(NavigationContext.Provider, { value: navigationContext }, /* @__PURE__ */ React32.createElement(LocationContext.Provider, { children, value: locationContext }));
9344
- }
9345
- var defaultMethod = "get";
9346
- var defaultEncType = "application/x-www-form-urlencoded";
9347
- function isHtmlElement(object3) {
9348
- return typeof HTMLElement !== "undefined" && object3 instanceof HTMLElement;
9349
- }
9350
- function isButtonElement(object3) {
9351
- return isHtmlElement(object3) && object3.tagName.toLowerCase() === "button";
9352
- }
9353
- function isFormElement(object3) {
9354
- return isHtmlElement(object3) && object3.tagName.toLowerCase() === "form";
9355
- }
9356
- function isInputElement(object3) {
9357
- return isHtmlElement(object3) && object3.tagName.toLowerCase() === "input";
9358
- }
9359
- function isModifiedEvent(event) {
9360
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
9361
- }
9362
- function shouldProcessLinkClick(event, target) {
9363
- return event.button === 0 && // Ignore everything but left clicks
9364
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
9365
- !isModifiedEvent(event);
9366
- }
9367
- function createSearchParams(init = "") {
9368
- return new URLSearchParams(
9369
- typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo2, key) => {
9370
- let value = init[key];
9371
- return memo2.concat(
9372
- Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
9373
- );
9374
- }, [])
9375
- );
9376
- }
9377
- function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
9378
- let searchParams = createSearchParams(locationSearch);
9379
- if (defaultSearchParams) {
9380
- defaultSearchParams.forEach((_, key) => {
9381
- if (!searchParams.has(key)) {
9382
- defaultSearchParams.getAll(key).forEach((value) => {
9383
- searchParams.append(key, value);
9384
- });
9385
- }
9386
- });
9387
- }
9388
- return searchParams;
9389
- }
9390
- var _formDataSupportsSubmitter = null;
9391
- function isFormDataSubmitterSupported() {
9392
- if (_formDataSupportsSubmitter === null) {
9393
- try {
9394
- new FormData(
9395
- document.createElement("form"),
9396
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
9397
- 0
9398
- );
9399
- _formDataSupportsSubmitter = false;
9400
- } catch (e) {
9401
- _formDataSupportsSubmitter = true;
9402
- }
9403
- }
9404
- return _formDataSupportsSubmitter;
9405
- }
9406
- var supportedFormEncTypes = /* @__PURE__ */ new Set([
9407
- "application/x-www-form-urlencoded",
9408
- "multipart/form-data",
9409
- "text/plain"
9410
- ]);
9411
- function getFormEncType(encType) {
9412
- if (encType != null && !supportedFormEncTypes.has(encType)) {
9413
- warning3(
9414
- false,
9415
- `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
9416
- );
9417
- return null;
9418
- }
9419
- return encType;
9420
- }
9421
- function getFormSubmissionInfo(target, basename) {
9422
- let method;
9423
- let action;
9424
- let encType;
9425
- let formData;
9426
- let body;
9427
- if (isFormElement(target)) {
9428
- let attr = target.getAttribute("action");
9429
- action = attr ? stripBasename(attr, basename) : null;
9430
- method = target.getAttribute("method") || defaultMethod;
9431
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
9432
- formData = new FormData(target);
9433
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
9434
- let form = target.form;
9435
- if (form == null) {
9436
- throw new Error(
9437
- `Cannot submit a <button> or <input type="submit"> without a <form>`
9438
- );
9439
- }
9440
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
9441
- action = attr ? stripBasename(attr, basename) : null;
9442
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
9443
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
9444
- formData = new FormData(form, target);
9445
- if (!isFormDataSubmitterSupported()) {
9446
- let { name, type, value } = target;
9447
- if (type === "image") {
9448
- let prefix = name ? `${name}.` : "";
9449
- formData.append(`${prefix}x`, "0");
9450
- formData.append(`${prefix}y`, "0");
9451
- } else if (name) {
9452
- formData.append(name, value);
9453
- }
9454
- }
9455
- } else if (isHtmlElement(target)) {
9456
- throw new Error(
9457
- `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
9458
- );
9459
- } else {
9460
- method = defaultMethod;
9461
- action = null;
9462
- encType = defaultEncType;
9463
- body = target;
9464
- }
9465
- if (formData && encType === "text/plain") {
9466
- body = formData;
9467
- formData = void 0;
9468
- }
9469
- return { action, method: method.toLowerCase(), encType, formData, body };
9470
- }
9471
- var objectProtoNames2 = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
9472
- var ESCAPE_LOOKUP = {
9473
- "&": "\\u0026",
9474
- ">": "\\u003e",
9475
- "<": "\\u003c",
9476
- "\u2028": "\\u2028",
9477
- "\u2029": "\\u2029"
9478
- };
9479
- var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
9480
- function escapeHtml(html) {
9481
- return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
9482
- }
9483
- function invariant2(value, message13) {
9484
- if (value === false || value === null || typeof value === "undefined") {
9485
- throw new Error(message13);
9486
- }
9487
- }
9488
- function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
9489
- let url = typeof reqUrl === "string" ? new URL(
9490
- reqUrl,
9491
- // This can be called during the SSR flow via PrefetchPageLinksImpl so
9492
- // don't assume window is available
9493
- typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
9494
- ) : reqUrl;
9495
- if (trailingSlashAware) {
9496
- if (url.pathname.endsWith("/")) {
9497
- url.pathname = `${url.pathname}_.${extension}`;
9498
- } else {
9499
- url.pathname = `${url.pathname}.${extension}`;
9500
- }
9501
- } else {
9502
- if (url.pathname === "/") {
9503
- url.pathname = `_root.${extension}`;
9504
- } else if (basename && stripBasename(url.pathname, basename) === "/") {
9505
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
9506
- } else {
9507
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
9508
- }
9509
- }
9510
- return url;
9511
- }
9512
- async function loadRouteModule(route, routeModulesCache) {
9513
- if (route.id in routeModulesCache) {
9514
- return routeModulesCache[route.id];
9515
- }
9516
- try {
9517
- let routeModule = await import(
9518
- /* @vite-ignore */
9519
- /* webpackIgnore: true */
9520
- route.module
9521
- );
9522
- routeModulesCache[route.id] = routeModule;
9523
- return routeModule;
9524
- } catch (error) {
9525
- console.error(
9526
- `Error loading route module \`${route.module}\`, reloading page...`
9527
- );
9528
- console.error(error);
9529
- if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
9530
- import_meta.hot) {
9531
- throw error;
9532
- }
9533
- window.location.reload();
9534
- return new Promise(() => {
9535
- });
9536
- }
9537
- }
9538
- function isPageLinkDescriptor(object3) {
9539
- return object3 != null && typeof object3.page === "string";
9540
- }
9541
- function isHtmlLinkDescriptor(object3) {
9542
- if (object3 == null) {
9543
- return false;
9544
- }
9545
- if (object3.href == null) {
9546
- return object3.rel === "preload" && typeof object3.imageSrcSet === "string" && typeof object3.imageSizes === "string";
9547
- }
9548
- return typeof object3.rel === "string" && typeof object3.href === "string";
9549
- }
9550
- async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
9551
- let links = await Promise.all(
9552
- matches.map(async (match) => {
9553
- let route = manifest.routes[match.route.id];
9554
- if (route) {
9555
- let mod = await loadRouteModule(route, routeModules);
9556
- return mod.links ? mod.links() : [];
9557
- }
9558
- return [];
9559
- })
9560
- );
9561
- return dedupeLinkDescriptors(
9562
- links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
9563
- (link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
9564
- )
9565
- );
9566
- }
9567
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
9568
- let isNew = (match, index) => {
9569
- if (!currentMatches[index]) return true;
9570
- return match.route.id !== currentMatches[index].route.id;
9571
- };
9572
- let matchPathChanged = (match, index) => {
9573
- return (
9574
- // param change, /users/123 -> /users/456
9575
- currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
9576
- // e.g. /files/images/avatar.jpg -> files/finances.xls
9577
- currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
9578
- );
9579
- };
9580
- if (mode === "assets") {
9581
- return nextMatches.filter(
9582
- (match, index) => isNew(match, index) || matchPathChanged(match, index)
9583
- );
9584
- }
9585
- if (mode === "data") {
9586
- return nextMatches.filter((match, index) => {
9587
- let manifestRoute = manifest.routes[match.route.id];
9588
- if (!manifestRoute || !manifestRoute.hasLoader) {
9589
- return false;
9590
- }
9591
- if (isNew(match, index) || matchPathChanged(match, index)) {
9592
- return true;
9593
- }
9594
- if (match.route.shouldRevalidate) {
9595
- let routeChoice = match.route.shouldRevalidate({
9596
- currentUrl: new URL(
9597
- location.pathname + location.search + location.hash,
9598
- window.origin
9599
- ),
9600
- currentParams: currentMatches[0]?.params || {},
9601
- nextUrl: new URL(page, window.origin),
9602
- nextParams: match.params,
9603
- defaultShouldRevalidate: true
9604
- });
9605
- if (typeof routeChoice === "boolean") {
9606
- return routeChoice;
9607
- }
9608
- }
9609
- return true;
9610
- });
9611
- }
9612
- return [];
9613
- }
9614
- function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
9615
- return dedupeHrefs(
9616
- matches.map((match) => {
9617
- let route = manifest.routes[match.route.id];
9618
- if (!route) return [];
9619
- let hrefs = [route.module];
9620
- if (route.clientActionModule) {
9621
- hrefs = hrefs.concat(route.clientActionModule);
9622
- }
9623
- if (route.clientLoaderModule) {
9624
- hrefs = hrefs.concat(route.clientLoaderModule);
9625
- }
9626
- if (includeHydrateFallback && route.hydrateFallbackModule) {
9627
- hrefs = hrefs.concat(route.hydrateFallbackModule);
9628
- }
9629
- if (route.imports) {
9630
- hrefs = hrefs.concat(route.imports);
9631
- }
9632
- return hrefs;
9633
- }).flat(1)
9634
- );
9635
- }
9636
- function dedupeHrefs(hrefs) {
9637
- return [...new Set(hrefs)];
9638
- }
9639
- function sortKeys(obj) {
9640
- let sorted = {};
9641
- let keys = Object.keys(obj).sort();
9642
- for (let key of keys) {
9643
- sorted[key] = obj[key];
9644
- }
9645
- return sorted;
9646
- }
9647
- function dedupeLinkDescriptors(descriptors, preloads) {
9648
- let set = /* @__PURE__ */ new Set();
9649
- let preloadsSet = new Set(preloads);
9650
- return descriptors.reduce((deduped, descriptor) => {
9651
- let alreadyModulePreload = preloads && !isPageLinkDescriptor(descriptor) && descriptor.as === "script" && descriptor.href && preloadsSet.has(descriptor.href);
9652
- if (alreadyModulePreload) {
9653
- return deduped;
9654
- }
9655
- let key = JSON.stringify(sortKeys(descriptor));
9656
- if (!set.has(key)) {
9657
- set.add(key);
9658
- deduped.push({ key, link: descriptor });
9659
- }
9660
- return deduped;
9661
- }, []);
9662
- }
9663
- function useDataRouterContext2() {
9664
- let context = React82.useContext(DataRouterContext);
9665
- invariant2(
9666
- context,
9667
- "You must render this element inside a <DataRouterContext.Provider> element"
9668
- );
9669
- return context;
9670
- }
9671
- function useDataRouterStateContext() {
9672
- let context = React82.useContext(DataRouterStateContext);
9673
- invariant2(
9674
- context,
9675
- "You must render this element inside a <DataRouterStateContext.Provider> element"
9676
- );
9677
- return context;
9678
- }
9679
- var FrameworkContext = React82.createContext(void 0);
9680
- FrameworkContext.displayName = "FrameworkContext";
9681
- function useFrameworkContext() {
9682
- let context = React82.useContext(FrameworkContext);
9683
- invariant2(
9684
- context,
9685
- "You must render this element inside a <HydratedRouter> element"
9686
- );
9687
- return context;
9688
- }
9689
- function usePrefetchBehavior(prefetch, theirElementProps) {
9690
- let frameworkContext = React82.useContext(FrameworkContext);
9691
- let [maybePrefetch, setMaybePrefetch] = React82.useState(false);
9692
- let [shouldPrefetch, setShouldPrefetch] = React82.useState(false);
9693
- let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
9694
- let ref = React82.useRef(null);
9695
- React82.useEffect(() => {
9696
- if (prefetch === "render") {
9697
- setShouldPrefetch(true);
9698
- }
9699
- if (prefetch === "viewport") {
9700
- let callback = (entries) => {
9701
- entries.forEach((entry) => {
9702
- setShouldPrefetch(entry.isIntersecting);
9703
- });
9704
- };
9705
- let observer = new IntersectionObserver(callback, { threshold: 0.5 });
9706
- if (ref.current) observer.observe(ref.current);
9707
- return () => {
9708
- observer.disconnect();
9709
- };
9710
- }
9711
- }, [prefetch]);
9712
- React82.useEffect(() => {
9713
- if (maybePrefetch) {
9714
- let id = setTimeout(() => {
9715
- setShouldPrefetch(true);
9716
- }, 100);
9717
- return () => {
9718
- clearTimeout(id);
9719
- };
9720
- }
9721
- }, [maybePrefetch]);
9722
- let setIntent = () => {
9723
- setMaybePrefetch(true);
9724
- };
9725
- let cancelIntent = () => {
9726
- setMaybePrefetch(false);
9727
- setShouldPrefetch(false);
9728
- };
9729
- if (!frameworkContext) {
9730
- return [false, ref, {}];
9731
- }
9732
- if (prefetch !== "intent") {
9733
- return [shouldPrefetch, ref, {}];
9734
- }
9735
- return [
9736
- shouldPrefetch,
9737
- ref,
9738
- {
9739
- onFocus: composeEventHandlers(onFocus, setIntent),
9740
- onBlur: composeEventHandlers(onBlur, cancelIntent),
9741
- onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
9742
- onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
9743
- onTouchStart: composeEventHandlers(onTouchStart, setIntent)
9744
- }
9745
- ];
9746
- }
9747
- function composeEventHandlers(theirHandler, ourHandler) {
9748
- return (event) => {
9749
- theirHandler && theirHandler(event);
9750
- if (!event.defaultPrevented) {
9751
- ourHandler(event);
9752
- }
9753
- };
9754
- }
9755
- function PrefetchPageLinks({ page, ...linkProps }) {
9756
- let { router } = useDataRouterContext2();
9757
- let matches = React82.useMemo(
9758
- () => matchRoutes(router.routes, page, router.basename),
9759
- [router.routes, page, router.basename]
9760
- );
9761
- if (!matches) {
9762
- return null;
9763
- }
9764
- return /* @__PURE__ */ React82.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
9765
- }
9766
- function useKeyedPrefetchLinks(matches) {
9767
- let { manifest, routeModules } = useFrameworkContext();
9768
- let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React82.useState([]);
9769
- React82.useEffect(() => {
9770
- let interrupted = false;
9771
- void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
9772
- (links) => {
9773
- if (!interrupted) {
9774
- setKeyedPrefetchLinks(links);
9775
- }
9776
- }
9777
- );
9778
- return () => {
9779
- interrupted = true;
9780
- };
9781
- }, [matches, manifest, routeModules]);
9782
- return keyedPrefetchLinks;
9783
- }
9784
- function PrefetchPageLinksImpl({
9785
- page,
9786
- matches: nextMatches,
9787
- ...linkProps
9788
- }) {
9789
- let location = useLocation3();
9790
- let { future, manifest, routeModules } = useFrameworkContext();
9791
- let { basename } = useDataRouterContext2();
9792
- let { loaderData, matches } = useDataRouterStateContext();
9793
- let newMatchesForData = React82.useMemo(
9794
- () => getNewMatchesForLinks(
9795
- page,
9796
- nextMatches,
9797
- matches,
9798
- manifest,
9799
- location,
9800
- "data"
9801
- ),
9802
- [page, nextMatches, matches, manifest, location]
9803
- );
9804
- let newMatchesForAssets = React82.useMemo(
9805
- () => getNewMatchesForLinks(
9806
- page,
9807
- nextMatches,
9808
- matches,
9809
- manifest,
9810
- location,
9811
- "assets"
9812
- ),
9813
- [page, nextMatches, matches, manifest, location]
9814
- );
9815
- let dataHrefs = React82.useMemo(() => {
9816
- if (page === location.pathname + location.search + location.hash) {
9817
- return [];
9818
- }
9819
- let routesParams = /* @__PURE__ */ new Set();
9820
- let foundOptOutRoute = false;
9821
- nextMatches.forEach((m) => {
9822
- let manifestRoute = manifest.routes[m.route.id];
9823
- if (!manifestRoute || !manifestRoute.hasLoader) {
9824
- return;
9825
- }
9826
- if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
9827
- foundOptOutRoute = true;
9828
- } else if (manifestRoute.hasClientLoader) {
9829
- foundOptOutRoute = true;
9830
- } else {
9831
- routesParams.add(m.route.id);
9832
- }
9833
- });
9834
- if (routesParams.size === 0) {
9835
- return [];
9836
- }
9837
- let url = singleFetchUrl(
9838
- page,
9839
- basename,
9840
- future.unstable_trailingSlashAwareDataRequests,
9841
- "data"
9842
- );
9843
- if (foundOptOutRoute && routesParams.size > 0) {
9844
- url.searchParams.set(
9845
- "_routes",
9846
- nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
9847
- );
9848
- }
9849
- return [url.pathname + url.search];
9850
- }, [
9851
- basename,
9852
- future.unstable_trailingSlashAwareDataRequests,
9853
- loaderData,
9854
- location,
9855
- manifest,
9856
- newMatchesForData,
9857
- nextMatches,
9858
- page,
9859
- routeModules
9860
- ]);
9861
- let moduleHrefs = React82.useMemo(
9862
- () => getModuleLinkHrefs(newMatchesForAssets, manifest),
9863
- [newMatchesForAssets, manifest]
9864
- );
9865
- let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
9866
- return /* @__PURE__ */ React82.createElement(React82.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React82.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React82.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
9867
- // these don't spread `linkProps` because they are full link descriptors
9868
- // already with their own props
9869
- /* @__PURE__ */ React82.createElement(
9870
- "link",
9871
- {
9872
- key,
9873
- nonce: linkProps.nonce,
9874
- ...link,
9875
- crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
9876
- }
9877
- )
9878
- )));
9879
- }
9880
- function mergeRefs(...refs) {
9881
- return (value) => {
9882
- refs.forEach((ref) => {
9883
- if (typeof ref === "function") {
9884
- ref(value);
9885
- } else if (ref != null) {
9886
- ref.current = value;
9887
- }
9888
- });
9889
- };
9890
- }
9891
- var isBrowser22 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
9892
- try {
9893
- if (isBrowser22) {
9894
- window.__reactRouterVersion = // @ts-expect-error
9895
- "7.13.1";
9896
- }
9897
- } catch (e) {
9898
- }
9899
- function HistoryRouter({
9900
- basename,
9901
- children,
9902
- history,
9903
- unstable_useTransitions
9904
- }) {
9905
- let [state, setStateImpl] = React102.useState({
9906
- action: history.action,
9907
- location: history.location
9908
- });
9909
- let setState = React102.useCallback(
9910
- (newState) => {
9911
- if (unstable_useTransitions === false) {
9912
- setStateImpl(newState);
9913
- } else {
9914
- React102.startTransition(() => setStateImpl(newState));
9915
- }
9916
- },
9917
- [unstable_useTransitions]
9918
- );
9919
- React102.useLayoutEffect(() => history.listen(setState), [history, setState]);
9920
- return /* @__PURE__ */ React102.createElement(
9921
- Router,
9922
- {
9923
- basename,
9924
- children,
9925
- location: state.location,
9926
- navigationType: state.action,
9927
- navigator: history,
9928
- unstable_useTransitions
9929
- }
9930
- );
9931
- }
9932
- HistoryRouter.displayName = "unstable_HistoryRouter";
9933
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
9934
- var Link = React102.forwardRef(
9935
- function LinkWithRef({
9936
- onClick,
9937
- discover = "render",
9938
- prefetch = "none",
9939
- relative,
9940
- reloadDocument,
9941
- replace: replace2,
9942
- unstable_mask,
9943
- state,
9944
- target,
9945
- to,
9946
- preventScrollReset,
9947
- viewTransition,
9948
- unstable_defaultShouldRevalidate,
9949
- ...rest
9950
- }, forwardedRef) {
9951
- let { basename, navigator: navigator2, unstable_useTransitions } = React102.useContext(NavigationContext);
9952
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
9953
- let parsed = parseToInfo(to, basename);
9954
- to = parsed.to;
9955
- let href = useHref(to, { relative });
9956
- let location = useLocation3();
9957
- let maskedHref = null;
9958
- if (unstable_mask) {
9959
- let resolved = resolveTo(
9960
- unstable_mask,
9961
- [],
9962
- location.unstable_mask ? location.unstable_mask.pathname : "/",
9963
- true
9964
- );
9965
- if (basename !== "/") {
9966
- resolved.pathname = resolved.pathname === "/" ? basename : joinPaths([basename, resolved.pathname]);
9967
- }
9968
- maskedHref = navigator2.createHref(resolved);
9969
- }
9970
- let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
9971
- prefetch,
9972
- rest
9973
- );
9974
- let internalOnClick = useLinkClickHandler(to, {
9975
- replace: replace2,
9976
- unstable_mask,
9977
- state,
9978
- target,
9979
- preventScrollReset,
9980
- relative,
9981
- viewTransition,
9982
- unstable_defaultShouldRevalidate,
9983
- unstable_useTransitions
9984
- });
9985
- function handleClick(event) {
9986
- if (onClick) onClick(event);
9987
- if (!event.defaultPrevented) {
9988
- internalOnClick(event);
9989
- }
9990
- }
9991
- let isSpaLink = !(parsed.isExternal || reloadDocument);
9992
- let link = (
9993
- // eslint-disable-next-line jsx-a11y/anchor-has-content
9994
- /* @__PURE__ */ React102.createElement(
9995
- "a",
9996
- {
9997
- ...rest,
9998
- ...prefetchHandlers,
9999
- href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
10000
- onClick: isSpaLink ? handleClick : onClick,
10001
- ref: mergeRefs(forwardedRef, prefetchRef),
10002
- target,
10003
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
10004
- }
10005
- )
10006
- );
10007
- return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React102.createElement(React102.Fragment, null, link, /* @__PURE__ */ React102.createElement(PrefetchPageLinks, { page: href })) : link;
10008
- }
10009
- );
10010
- Link.displayName = "Link";
10011
- var NavLink = React102.forwardRef(
10012
- function NavLinkWithRef({
10013
- "aria-current": ariaCurrentProp = "page",
10014
- caseSensitive = false,
10015
- className: classNameProp = "",
10016
- end = false,
10017
- style: styleProp,
10018
- to,
10019
- viewTransition,
10020
- children,
10021
- ...rest
10022
- }, ref) {
10023
- let path = useResolvedPath(to, { relative: rest.relative });
10024
- let location = useLocation3();
10025
- let routerState = React102.useContext(DataRouterStateContext);
10026
- let { navigator: navigator2, basename } = React102.useContext(NavigationContext);
10027
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
10028
- // eslint-disable-next-line react-hooks/rules-of-hooks
10029
- useViewTransitionState(path) && viewTransition === true;
10030
- let toPathname = navigator2.encodeLocation ? navigator2.encodeLocation(path).pathname : path.pathname;
10031
- let locationPathname = location.pathname;
10032
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
10033
- if (!caseSensitive) {
10034
- locationPathname = locationPathname.toLowerCase();
10035
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
10036
- toPathname = toPathname.toLowerCase();
10037
- }
10038
- if (nextLocationPathname && basename) {
10039
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
10040
- }
10041
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
10042
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
10043
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
10044
- let renderProps = {
10045
- isActive,
10046
- isPending,
10047
- isTransitioning
10048
- };
10049
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
10050
- let className;
10051
- if (typeof classNameProp === "function") {
10052
- className = classNameProp(renderProps);
10053
- } else {
10054
- className = [
10055
- classNameProp,
10056
- isActive ? "active" : null,
10057
- isPending ? "pending" : null,
10058
- isTransitioning ? "transitioning" : null
10059
- ].filter(Boolean).join(" ");
10060
- }
10061
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
10062
- return /* @__PURE__ */ React102.createElement(
10063
- Link,
10064
- {
10065
- ...rest,
10066
- "aria-current": ariaCurrent,
10067
- className,
10068
- ref,
10069
- style,
10070
- to,
10071
- viewTransition
10072
- },
10073
- typeof children === "function" ? children(renderProps) : children
10074
- );
10075
- }
10076
- );
10077
- NavLink.displayName = "NavLink";
10078
- var Form = React102.forwardRef(
10079
- ({
10080
- discover = "render",
10081
- fetcherKey,
10082
- navigate,
10083
- reloadDocument,
10084
- replace: replace2,
10085
- state,
10086
- method = defaultMethod,
10087
- action,
10088
- onSubmit,
10089
- relative,
10090
- preventScrollReset,
10091
- viewTransition,
10092
- unstable_defaultShouldRevalidate,
10093
- ...props
10094
- }, forwardedRef) => {
10095
- let { unstable_useTransitions } = React102.useContext(NavigationContext);
10096
- let submit = useSubmit();
10097
- let formAction = useFormAction(action, { relative });
10098
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
10099
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
10100
- let submitHandler = (event) => {
10101
- onSubmit && onSubmit(event);
10102
- if (event.defaultPrevented) return;
10103
- event.preventDefault();
10104
- let submitter = event.nativeEvent.submitter;
10105
- let submitMethod = submitter?.getAttribute("formmethod") || method;
10106
- let doSubmit = () => submit(submitter || event.currentTarget, {
10107
- fetcherKey,
10108
- method: submitMethod,
10109
- navigate,
10110
- replace: replace2,
10111
- state,
10112
- relative,
10113
- preventScrollReset,
10114
- viewTransition,
10115
- unstable_defaultShouldRevalidate
10116
- });
10117
- if (unstable_useTransitions && navigate !== false) {
10118
- React102.startTransition(() => doSubmit());
10119
- } else {
10120
- doSubmit();
10121
- }
10122
- };
10123
- return /* @__PURE__ */ React102.createElement(
10124
- "form",
10125
- {
10126
- ref: forwardedRef,
10127
- method: formMethod,
10128
- action: formAction,
10129
- onSubmit: reloadDocument ? onSubmit : submitHandler,
10130
- ...props,
10131
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
10132
- }
10133
- );
10134
- }
10135
- );
10136
- Form.displayName = "Form";
10137
- function ScrollRestoration({
10138
- getKey,
10139
- storageKey,
10140
- ...props
10141
- }) {
10142
- let remixContext = React102.useContext(FrameworkContext);
10143
- let { basename } = React102.useContext(NavigationContext);
10144
- let location = useLocation3();
10145
- let matches = useMatches();
10146
- useScrollRestoration({ getKey, storageKey });
10147
- let ssrKey = React102.useMemo(
10148
- () => {
10149
- if (!remixContext || !getKey) return null;
10150
- let userKey = getScrollRestorationKey(
10151
- location,
10152
- matches,
10153
- basename,
10154
- getKey
10155
- );
10156
- return userKey !== location.key ? userKey : null;
10157
- },
10158
- // Nah, we only need this the first time for the SSR render
10159
- // eslint-disable-next-line react-hooks/exhaustive-deps
10160
- []
10161
- );
10162
- if (!remixContext || remixContext.isSpaMode) {
10163
- return null;
10164
- }
10165
- let restoreScroll = ((storageKey2, restoreKey) => {
10166
- if (!window.history.state || !window.history.state.key) {
10167
- let key = Math.random().toString(32).slice(2);
10168
- window.history.replaceState({ key }, "");
10169
- }
10170
- try {
10171
- let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
10172
- let storedY = positions[restoreKey || window.history.state.key];
10173
- if (typeof storedY === "number") {
10174
- window.scrollTo(0, storedY);
10175
- }
10176
- } catch (error) {
10177
- console.error(error);
10178
- sessionStorage.removeItem(storageKey2);
10179
- }
10180
- }).toString();
10181
- return /* @__PURE__ */ React102.createElement(
10182
- "script",
10183
- {
10184
- ...props,
10185
- suppressHydrationWarning: true,
10186
- dangerouslySetInnerHTML: {
10187
- __html: `(${restoreScroll})(${escapeHtml(
10188
- JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
10189
- )}, ${escapeHtml(JSON.stringify(ssrKey))})`
10190
- }
10191
- }
10192
- );
10193
- }
10194
- ScrollRestoration.displayName = "ScrollRestoration";
10195
- function getDataRouterConsoleError2(hookName) {
10196
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
10197
- }
10198
- function useDataRouterContext3(hookName) {
10199
- let ctx = React102.useContext(DataRouterContext);
10200
- invariant(ctx, getDataRouterConsoleError2(hookName));
10201
- return ctx;
10202
- }
10203
- function useDataRouterState2(hookName) {
10204
- let state = React102.useContext(DataRouterStateContext);
10205
- invariant(state, getDataRouterConsoleError2(hookName));
10206
- return state;
10207
- }
10208
- function useLinkClickHandler(to, {
10209
- target,
10210
- replace: replaceProp,
10211
- unstable_mask,
10212
- state,
10213
- preventScrollReset,
10214
- relative,
10215
- viewTransition,
10216
- unstable_defaultShouldRevalidate,
10217
- unstable_useTransitions
10218
- } = {}) {
10219
- let navigate = useNavigate5();
10220
- let location = useLocation3();
10221
- let path = useResolvedPath(to, { relative });
10222
- return React102.useCallback(
10223
- (event) => {
10224
- if (shouldProcessLinkClick(event, target)) {
10225
- event.preventDefault();
10226
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
10227
- let doNavigate = () => navigate(to, {
10228
- replace: replace2,
10229
- unstable_mask,
10230
- state,
10231
- preventScrollReset,
10232
- relative,
10233
- viewTransition,
10234
- unstable_defaultShouldRevalidate
10235
- });
10236
- if (unstable_useTransitions) {
10237
- React102.startTransition(() => doNavigate());
10238
- } else {
10239
- doNavigate();
10240
- }
10241
- }
10242
- },
10243
- [
10244
- location,
10245
- navigate,
10246
- path,
10247
- replaceProp,
10248
- unstable_mask,
10249
- state,
10250
- target,
10251
- to,
10252
- preventScrollReset,
10253
- relative,
10254
- viewTransition,
10255
- unstable_defaultShouldRevalidate,
10256
- unstable_useTransitions
10257
- ]
10258
- );
10259
- }
10260
- function useSearchParams(defaultInit) {
10261
- warning3(
10262
- typeof URLSearchParams !== "undefined",
10263
- `You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
10264
- );
10265
- let defaultSearchParamsRef = React102.useRef(createSearchParams(defaultInit));
10266
- let hasSetSearchParamsRef = React102.useRef(false);
10267
- let location = useLocation3();
10268
- let searchParams = React102.useMemo(
10269
- () => (
10270
- // Only merge in the defaults if we haven't yet called setSearchParams.
10271
- // Once we call that we want those to take precedence, otherwise you can't
10272
- // remove a param with setSearchParams({}) if it has an initial value
10273
- getSearchParamsForLocation(
10274
- location.search,
10275
- hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
10276
- )
10277
- ),
10278
- [location.search]
10279
- );
10280
- let navigate = useNavigate5();
10281
- let setSearchParams = React102.useCallback(
10282
- (nextInit, navigateOptions) => {
10283
- const newSearchParams = createSearchParams(
10284
- typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
10285
- );
10286
- hasSetSearchParamsRef.current = true;
10287
- navigate("?" + newSearchParams, navigateOptions);
10288
- },
10289
- [navigate, searchParams]
10290
- );
10291
- return [searchParams, setSearchParams];
10292
- }
10293
- var fetcherId = 0;
10294
- var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
10295
- function useSubmit() {
10296
- let { router } = useDataRouterContext3(
10297
- "useSubmit"
10298
- /* UseSubmit */
10299
- );
10300
- let { basename } = React102.useContext(NavigationContext);
10301
- let currentRouteId = useRouteId();
10302
- let routerFetch = router.fetch;
10303
- let routerNavigate = router.navigate;
10304
- return React102.useCallback(
10305
- async (target, options = {}) => {
10306
- let { action, method, encType, formData, body } = getFormSubmissionInfo(
10307
- target,
10308
- basename
10309
- );
10310
- if (options.navigate === false) {
10311
- let key = options.fetcherKey || getUniqueFetcherId();
10312
- await routerFetch(key, currentRouteId, options.action || action, {
10313
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
10314
- preventScrollReset: options.preventScrollReset,
10315
- formData,
10316
- body,
10317
- formMethod: options.method || method,
10318
- formEncType: options.encType || encType,
10319
- flushSync: options.flushSync
10320
- });
10321
- } else {
10322
- await routerNavigate(options.action || action, {
10323
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
10324
- preventScrollReset: options.preventScrollReset,
10325
- formData,
10326
- body,
10327
- formMethod: options.method || method,
10328
- formEncType: options.encType || encType,
10329
- replace: options.replace,
10330
- state: options.state,
10331
- fromRouteId: currentRouteId,
10332
- flushSync: options.flushSync,
10333
- viewTransition: options.viewTransition
10334
- });
10335
- }
10336
- },
10337
- [routerFetch, routerNavigate, basename, currentRouteId]
10338
- );
10339
- }
10340
- function useFormAction(action, { relative } = {}) {
10341
- let { basename } = React102.useContext(NavigationContext);
10342
- let routeContext = React102.useContext(RouteContext);
10343
- invariant(routeContext, "useFormAction must be used inside a RouteContext");
10344
- let [match] = routeContext.matches.slice(-1);
10345
- let path = { ...useResolvedPath(action ? action : ".", { relative }) };
10346
- let location = useLocation3();
10347
- if (action == null) {
10348
- path.search = location.search;
10349
- let params = new URLSearchParams(path.search);
10350
- let indexValues = params.getAll("index");
10351
- let hasNakedIndexParam = indexValues.some((v) => v === "");
10352
- if (hasNakedIndexParam) {
10353
- params.delete("index");
10354
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
10355
- let qs = params.toString();
10356
- path.search = qs ? `?${qs}` : "";
10357
- }
10358
- }
10359
- if ((!action || action === ".") && match.route.index) {
10360
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
10361
- }
10362
- if (basename !== "/") {
10363
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
10364
- }
10365
- return createPath(path);
10366
- }
10367
- var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
10368
- var savedScrollPositions = {};
10369
- function getScrollRestorationKey(location, matches, basename, getKey) {
10370
- let key = null;
10371
- if (getKey) {
10372
- if (basename !== "/") {
10373
- key = getKey(
10374
- {
10375
- ...location,
10376
- pathname: stripBasename(location.pathname, basename) || location.pathname
10377
- },
10378
- matches
10379
- );
10380
- } else {
10381
- key = getKey(location, matches);
10382
- }
10383
- }
10384
- if (key == null) {
10385
- key = location.key;
10386
- }
10387
- return key;
10388
- }
10389
- function useScrollRestoration({
10390
- getKey,
10391
- storageKey
10392
- } = {}) {
10393
- let { router } = useDataRouterContext3(
10394
- "useScrollRestoration"
10395
- /* UseScrollRestoration */
10396
- );
10397
- let { restoreScrollPosition, preventScrollReset } = useDataRouterState2(
10398
- "useScrollRestoration"
10399
- /* UseScrollRestoration */
10400
- );
10401
- let { basename } = React102.useContext(NavigationContext);
10402
- let location = useLocation3();
10403
- let matches = useMatches();
10404
- let navigation = useNavigation();
10405
- React102.useEffect(() => {
10406
- window.history.scrollRestoration = "manual";
10407
- return () => {
10408
- window.history.scrollRestoration = "auto";
10409
- };
10410
- }, []);
10411
- usePageHide(
10412
- React102.useCallback(() => {
10413
- if (navigation.state === "idle") {
10414
- let key = getScrollRestorationKey(location, matches, basename, getKey);
10415
- savedScrollPositions[key] = window.scrollY;
10416
- }
10417
- try {
10418
- sessionStorage.setItem(
10419
- storageKey || SCROLL_RESTORATION_STORAGE_KEY,
10420
- JSON.stringify(savedScrollPositions)
10421
- );
10422
- } catch (error) {
10423
- warning3(
10424
- false,
10425
- `Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
10426
- );
10427
- }
10428
- window.history.scrollRestoration = "auto";
10429
- }, [navigation.state, getKey, basename, location, matches, storageKey])
10430
- );
10431
- if (typeof document !== "undefined") {
10432
- React102.useLayoutEffect(() => {
10433
- try {
10434
- let sessionPositions = sessionStorage.getItem(
10435
- storageKey || SCROLL_RESTORATION_STORAGE_KEY
10436
- );
10437
- if (sessionPositions) {
10438
- savedScrollPositions = JSON.parse(sessionPositions);
10439
- }
10440
- } catch (e) {
10441
- }
10442
- }, [storageKey]);
10443
- React102.useLayoutEffect(() => {
10444
- let disableScrollRestoration = router?.enableScrollRestoration(
10445
- savedScrollPositions,
10446
- () => window.scrollY,
10447
- getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
10448
- );
10449
- return () => disableScrollRestoration && disableScrollRestoration();
10450
- }, [router, basename, getKey]);
10451
- React102.useLayoutEffect(() => {
10452
- if (restoreScrollPosition === false) {
10453
- return;
10454
- }
10455
- if (typeof restoreScrollPosition === "number") {
10456
- window.scrollTo(0, restoreScrollPosition);
10457
- return;
10458
- }
10459
- try {
10460
- if (location.hash) {
10461
- let el = document.getElementById(
10462
- decodeURIComponent(location.hash.slice(1))
10463
- );
10464
- if (el) {
10465
- el.scrollIntoView();
10466
- return;
10467
- }
10468
- }
10469
- } catch {
10470
- warning3(
10471
- false,
10472
- `"${location.hash.slice(
10473
- 1
10474
- )}" is not a decodable element ID. The view will not scroll to it.`
10475
- );
10476
- }
10477
- if (preventScrollReset === true) {
10478
- return;
10479
- }
10480
- window.scrollTo(0, 0);
10481
- }, [location, restoreScrollPosition, preventScrollReset]);
10482
- }
10483
- }
10484
- function usePageHide(callback, options) {
10485
- let { capture } = options || {};
10486
- React102.useEffect(() => {
10487
- let opts = capture != null ? { capture } : void 0;
10488
- window.addEventListener("pagehide", callback, opts);
10489
- return () => {
10490
- window.removeEventListener("pagehide", callback, opts);
10491
- };
10492
- }, [callback, capture]);
10493
- }
10494
- function useViewTransitionState(to, { relative } = {}) {
10495
- let vtContext = React102.useContext(ViewTransitionContext);
10496
- invariant(
10497
- vtContext != null,
10498
- "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
10499
- );
10500
- let { basename } = useDataRouterContext3(
10501
- "useViewTransitionState"
10502
- /* useViewTransitionState */
10503
- );
10504
- let path = useResolvedPath(to, { relative });
10505
- if (!vtContext.isTransitioning) {
10506
- return false;
10507
- }
10508
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
10509
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
10510
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
10511
- }
10512
-
10513
- // src/hooks/useApp.tsx
10514
- var useApp = () => {
10515
- const [searchParams] = useSearchParams();
10516
- const navigate = useNavigate5();
10517
- const getParams = (key) => {
10518
- const params = useParams2();
10519
- if (key) return params[key];
10520
- return params;
10521
- };
10522
- const getQuery = (key) => {
10523
- if (key) return searchParams.get(key);
10524
- return Object.fromEntries(searchParams.entries());
10525
- };
10526
- return {
10527
- navigate,
10528
- getQuery,
10529
- getParams
10530
- };
10531
- };
10532
- var useApp_default = useApp;
10533
-
10534
- // src/utils/Enums.ts
10535
- var Enums = {
10536
- roles: ["admin", "staff"],
10537
- sex: ["male", "female"],
10538
- accountTypes: ["employee", "supplier", "customer", "investor"],
10539
- verificationTypes: ["email_verification", "password_reset"],
10540
- auditActions: ["create", "update", "delete", "login", "logout"]
10541
- };
10542
- var Enums_default = Enums;
10543
-
10544
- // src/components/accounts/schema.tsx
10545
- var import_zod2 = require("zod");
10546
- var createAccountSchema = import_zod2.z.object({
10547
- name: import_zod2.z.string().min(2, { message: "Name must be at least 2 characters" }),
10548
- email: import_zod2.z.string().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
10549
- message: "Please enter a valid email address"
10550
- }).transform((val) => val?.toLowerCase()),
10551
- phoneNumber: import_zod2.z.string().optional(),
10552
- sex: import_zod2.z.enum(Enums_default.sex)
10553
- });
10554
-
10555
- // src/components/accounts/AccountForm.tsx
10556
- var import_react_hook_form8 = require("react-hook-form");
10557
- var import_zod3 = require("@hookform/resolvers/zod");
10558
- var import_antd7 = require("antd");
10559
- var import_react34 = require("react");
10560
- var import_jsx_runtime43 = require("react/jsx-runtime");
10561
- function AccountForm() {
10562
- const { getQuery, getParams, navigate } = useApp_default();
10563
- const id = getQuery("id");
10564
- const type = getParams("type");
10565
- const isEdit = !!id;
10566
- const { post, put, isLoading } = useApis_default();
10567
- const { isLoading: isLoadingGet, get } = useApis_default();
10568
- const methods = (0, import_react_hook_form8.useForm)({
10569
- resolver: (0, import_zod3.zodResolver)(createAccountSchema),
10570
- defaultValues: {
10571
- name: "",
10572
- email: "",
10573
- phoneNumber: "",
10574
- sex: "male"
10575
- },
10576
- shouldUnregister: false
10577
- });
10578
- const { handleSubmit } = methods;
10579
- const onSubmit = async (data2) => {
10580
- try {
10581
- const payload = {
10582
- ...data2,
10583
- type
10584
- };
10585
- if (isEdit) {
10586
- await put({
10587
- url: `/accounts/update/${id}`,
10588
- body: payload
10589
- });
10590
- } else {
10591
- await post({
10592
- url: "/accounts/create",
10593
- body: payload
10594
- });
10595
- }
10596
- import_antd7.message.success(`${type} ${isEdit ? "updated" : "created"} successfully`);
10597
- navigate(-1);
10598
- } catch (error) {
10599
- import_antd7.message.error(error?.message || "Something went wrong");
10600
- }
10601
- };
10602
- const fetches = async () => {
10603
- try {
10604
- const res = await get({
10605
- url: `/accounts/get/${type}?id=${id}`
10606
- });
10607
- const data2 = res.data;
10608
- methods.reset(data2);
10609
- } catch (error) {
10610
- import_antd7.message.error(error?.message || "Something went wrong");
10611
- }
10612
- };
10613
- (0, import_react34.useEffect)(() => {
10614
- if (isEdit) {
10615
- fetches();
8226
+ };
8227
+ (0, import_react34.useEffect)(() => {
8228
+ if (isEdit) {
8229
+ fetches();
10616
8230
  }
10617
8231
  }, [id]);
10618
8232
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
@@ -10673,6 +8287,28 @@ function AccountForm() {
10673
8287
  name: "phoneNumber",
10674
8288
  placeholder: "Enter phone number"
10675
8289
  }
8290
+ ),
8291
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8292
+ Fields_default.SearchApi,
8293
+ {
8294
+ label: "Owner",
8295
+ form: methods,
8296
+ name: "owner",
8297
+ api: "/accounts/get/customer",
8298
+ placeholder: "Search for account owner...",
8299
+ required: true
8300
+ }
8301
+ ),
8302
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
8303
+ Fields_default.Input,
8304
+ {
8305
+ label: "Host",
8306
+ form: methods,
8307
+ name: "host",
8308
+ type: "text",
8309
+ placeholder: "Unique host name",
8310
+ required: true
8311
+ }
10676
8312
  )
10677
8313
  ] }),
10678
8314
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("footer", { className: "flex justify-end mt-4", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
@@ -10742,10 +8378,10 @@ function LinkUser({ type: initialType = "employee" }) {
10742
8378
  shouldUnregister: false
10743
8379
  });
10744
8380
  const { handleSubmit } = methods;
10745
- const onSubmit = async (data2) => {
8381
+ const onSubmit = async (data) => {
10746
8382
  try {
10747
8383
  const payload = {
10748
- ...data2
8384
+ ...data
10749
8385
  };
10750
8386
  await post({
10751
8387
  url: `/accounts/link-user/${id}`,
@@ -10762,13 +8398,13 @@ function LinkUser({ type: initialType = "employee" }) {
10762
8398
  const res = await get({
10763
8399
  url: `/accounts/get/${type}?id=${id}`
10764
8400
  });
10765
- const data2 = res.data;
10766
- if (data2?.user) {
8401
+ const data = res.data;
8402
+ if (data?.user) {
10767
8403
  import_antd8.message.error("Account Already Has A Login User");
10768
8404
  navigate(-1);
10769
8405
  return;
10770
8406
  }
10771
- methods.reset(data2);
8407
+ methods.reset(data);
10772
8408
  } catch (error) {
10773
8409
  import_antd8.message.error(error?.message || "Something went wrong");
10774
8410
  }
@@ -10855,23 +8491,23 @@ var import_react36 = require("react");
10855
8491
  var import_jsx_runtime45 = require("react/jsx-runtime");
10856
8492
  var { Countdown } = import_antd9.Statistic;
10857
8493
  function VerifyEmailForm({
10858
- data: data2,
8494
+ data,
10859
8495
  close,
10860
8496
  reload
10861
8497
  }) {
10862
8498
  const { put, isLoading } = useApis_default();
10863
- const [datas, setDatas] = (0, import_react36.useState)(data2);
8499
+ const [datas, setDatas] = (0, import_react36.useState)(data);
10864
8500
  const [hasPassed, setHasPassed] = (0, import_react36.useState)(
10865
- data2?.emailVerification?.passed || !data2?.emailVerification?.createdAt
8501
+ data?.emailVerification?.passed || !data?.emailVerification?.createdAt
10866
8502
  );
10867
8503
  (0, import_react36.useEffect)(() => {
10868
- setDatas(data2);
8504
+ setDatas(data);
10869
8505
  setHasPassed(
10870
- data2?.emailVerification?.passed || !data2?.emailVerification?.createdAt
8506
+ data?.emailVerification?.passed || !data?.emailVerification?.createdAt
10871
8507
  );
10872
- }, [data2]);
10873
- const email = data2?.emailVerification?.email;
10874
- const oldEmail = data2?.emailVerification?.email !== data2?.email ? data2?.emailVerification?.email : null;
8508
+ }, [data]);
8509
+ const email = data?.emailVerification?.email;
8510
+ const oldEmail = data?.emailVerification?.email !== data?.email ? data?.emailVerification?.email : null;
10875
8511
  const methods = (0, import_react_hook_form10.useForm)({
10876
8512
  resolver: (0, import_zod6.zodResolver)(verifyUserEmailSchema),
10877
8513
  defaultValues: {
@@ -10887,7 +8523,7 @@ function VerifyEmailForm({
10887
8523
  ...datas2
10888
8524
  };
10889
8525
  await put({
10890
- url: `/users/verify_email/${data2._id}`,
8526
+ url: `/users/verify_email/${data._id}`,
10891
8527
  body: payload
10892
8528
  });
10893
8529
  import_antd9.message.success(`Email Verified successfully`);
@@ -10904,9 +8540,9 @@ function VerifyEmailForm({
10904
8540
  const resend = async () => {
10905
8541
  try {
10906
8542
  const res = await put({
10907
- url: `/users/resend_email_verification/${data2._id}`,
8543
+ url: `/users/resend_email_verification/${data._id}`,
10908
8544
  body: {
10909
- email: data2?.emailVerification?.email || data2?.email
8545
+ email: data?.emailVerification?.email || data?.email
10910
8546
  }
10911
8547
  });
10912
8548
  setDatas((prev) => ({
@@ -10996,12 +8632,12 @@ var import_zod7 = require("@hookform/resolvers/zod");
10996
8632
  var import_antd10 = require("antd");
10997
8633
  var import_jsx_runtime46 = require("react/jsx-runtime");
10998
8634
  function UpdateEmailForm({
10999
- data: data2,
8635
+ data,
11000
8636
  close,
11001
8637
  reload
11002
8638
  }) {
11003
8639
  const { put, isLoading } = useApis_default();
11004
- const currentEmail = data2?.email;
8640
+ const currentEmail = data?.email;
11005
8641
  const methods = (0, import_react_hook_form11.useForm)({
11006
8642
  resolver: (0, import_zod7.zodResolver)(updateUserEmailSchema),
11007
8643
  defaultValues: {
@@ -11013,7 +8649,7 @@ function UpdateEmailForm({
11013
8649
  const onSubmit = async (formData) => {
11014
8650
  try {
11015
8651
  await put({
11016
- url: `/users/change_email/${data2._id}`,
8652
+ url: `/users/change_email/${data._id}`,
11017
8653
  body: {
11018
8654
  email: formData.newEmail
11019
8655
  }
@@ -11084,20 +8720,20 @@ var import_react37 = require("react");
11084
8720
  var import_jsx_runtime47 = require("react/jsx-runtime");
11085
8721
  var { Countdown: Countdown2 } = import_antd11.Statistic;
11086
8722
  function ResetPasswordForm({
11087
- data: data2,
8723
+ data,
11088
8724
  close,
11089
8725
  reload
11090
8726
  }) {
11091
8727
  const { put, isLoading } = useApis_default();
11092
- const [datas, setDatas] = (0, import_react37.useState)(data2);
8728
+ const [datas, setDatas] = (0, import_react37.useState)(data);
11093
8729
  const [hasPassed, setHasPassed] = (0, import_react37.useState)(
11094
- data2?.passwordReset?.passed || !data2?.passwordReset?.createdAt
8730
+ data?.passwordReset?.passed || !data?.passwordReset?.createdAt
11095
8731
  );
11096
8732
  (0, import_react37.useEffect)(() => {
11097
- setDatas(data2);
11098
- setHasPassed(data2?.passwordReset?.passed || !data2?.passwordReset?.createdAt);
11099
- }, [data2]);
11100
- const userEmail = data2?.email;
8733
+ setDatas(data);
8734
+ setHasPassed(data?.passwordReset?.passed || !data?.passwordReset?.createdAt);
8735
+ }, [data]);
8736
+ const userEmail = data?.email;
11101
8737
  const methods = (0, import_react_hook_form12.useForm)({
11102
8738
  defaultValues: {
11103
8739
  email: userEmail
@@ -11118,7 +8754,7 @@ function ResetPasswordForm({
11118
8754
  const resendToken = async () => {
11119
8755
  try {
11120
8756
  const res = await put({
11121
- url: `/users/reset_password/${data2._id}`,
8757
+ url: `/users/reset_password/${data._id}`,
11122
8758
  body: {
11123
8759
  email: userEmail
11124
8760
  }
@@ -11189,15 +8825,15 @@ var ResetPasswordForm_default = ResetPasswordForm;
11189
8825
  var import_antd12 = require("antd");
11190
8826
  var import_react38 = require("react");
11191
8827
  var import_jsx_runtime48 = require("react/jsx-runtime");
11192
- var ActivateUser = ({ data: data2 }) => {
11193
- const [checked, setChecked] = (0, import_react38.useState)(data2?.isActive);
8828
+ var ActivateUser = ({ data }) => {
8829
+ const [checked, setChecked] = (0, import_react38.useState)(data?.isActive);
11194
8830
  const { put, isLoading } = useApis_default();
11195
8831
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_jsx_runtime48.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
11196
8832
  import_antd12.Switch,
11197
8833
  {
11198
8834
  onChange: async (e) => {
11199
8835
  const res = await put({
11200
- url: `/users/activate/${data2?._id}`,
8836
+ url: `/users/activate/${data?._id}`,
11201
8837
  v: 1,
11202
8838
  body: { isActive: e }
11203
8839
  });
@@ -11217,14 +8853,14 @@ var Activate_default = ActivateUser;
11217
8853
  // src/components/users/users.tsx
11218
8854
  var import_jsx_runtime49 = require("react/jsx-runtime");
11219
8855
  function Users() {
11220
- const { data: data2, TransactionViewComponent, reload } = useTransaction_default({
8856
+ const { data, TransactionViewComponent, reload } = useTransaction_default({
11221
8857
  url: "/users/get",
11222
8858
  v: 1,
11223
8859
  dateFilter: false
11224
8860
  });
11225
8861
  const { Modal: Modal2, openState, close } = useModal();
11226
8862
  const { put, isLoading } = useApis_default();
11227
- const items = (data3) => [
8863
+ const items = (data2) => [
11228
8864
  {
11229
8865
  label: `Reset Password`,
11230
8866
  icon: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react20.Key, { size: 16 }),
@@ -11234,7 +8870,7 @@ function Users() {
11234
8870
  content: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11235
8871
  ResetPasswordForm_default,
11236
8872
  {
11237
- data: data3,
8873
+ data: data2,
11238
8874
  close: () => close(),
11239
8875
  reload: () => reload()
11240
8876
  }
@@ -11251,7 +8887,7 @@ function Users() {
11251
8887
  content: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11252
8888
  UpdateEmailForm_default,
11253
8889
  {
11254
- data: data3,
8890
+ data: data2,
11255
8891
  close: () => close(),
11256
8892
  reload: () => reload()
11257
8893
  }
@@ -11259,7 +8895,7 @@ function Users() {
11259
8895
  width: 600
11260
8896
  })
11261
8897
  },
11262
- data3?.emailVerification && {
8898
+ data2?.emailVerification && {
11263
8899
  label: `Verify Email`,
11264
8900
  icon: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react20.ShieldCheck, {}),
11265
8901
  onClick: () => openState({
@@ -11268,7 +8904,7 @@ function Users() {
11268
8904
  content: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11269
8905
  VerifyEmailForm_default,
11270
8906
  {
11271
- data: data3,
8907
+ data: data2,
11272
8908
  close: () => close(),
11273
8909
  reload: () => reload()
11274
8910
  }
@@ -11283,15 +8919,15 @@ function Users() {
11283
8919
  accessorKey: "email",
11284
8920
  header: "Email",
11285
8921
  cell: ({ row }) => {
11286
- const data3 = row.original;
11287
- const emailVerification = data3?.emailVerification;
11288
- const newEmail = emailVerification?.email !== data3?.email ? emailVerification?.email : null;
8922
+ const data2 = row.original;
8923
+ const emailVerification = data2?.emailVerification;
8924
+ const newEmail = emailVerification?.email !== data2?.email ? emailVerification?.email : null;
11289
8925
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "space-y-1", children: [
11290
8926
  /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("section", { className: "flex items-center gap-2", children: [
11291
8927
  " ",
11292
- /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { children: data3?.email }),
11293
- data3?.isEmailVerified && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Badge, { variant: "success", size: "sm", children: "Verified" }),
11294
- !data3?.isEmailVerified && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Badge, { variant: "warning", size: "sm", children: "Not Verified" })
8928
+ /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { children: data2?.email }),
8929
+ data2?.isEmailVerified && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Badge, { variant: "success", size: "sm", children: "Verified" }),
8930
+ !data2?.isEmailVerified && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Badge, { variant: "warning", size: "sm", children: "Not Verified" })
11295
8931
  ] }),
11296
8932
  newEmail && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("section", { className: "flex items-center gap-2", children: [
11297
8933
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react20.Info, { size: 16, className: "text-orange-600" }),
@@ -11312,20 +8948,20 @@ function Users() {
11312
8948
  accessorKey: "status",
11313
8949
  header: "Status",
11314
8950
  cell: ({ row }) => {
11315
- const data3 = row.original;
11316
- return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Activate_default, { data: data3 });
8951
+ const data2 = row.original;
8952
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Activate_default, { data: data2 });
11317
8953
  }
11318
8954
  },
11319
8955
  {
11320
8956
  accessorKey: "actions",
11321
8957
  header: "Actions",
11322
8958
  cell: ({ row }) => {
11323
- const data3 = row.original;
8959
+ const data2 = row.original;
11324
8960
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
11325
8961
  Dropdown,
11326
8962
  {
11327
8963
  className: "w-fit! cursor-pointer",
11328
- items: items(data3),
8964
+ items: items(data2),
11329
8965
  triggerMode: "hover",
11330
8966
  children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_lucide_react20.EllipsisVertical, {})
11331
8967
  }
@@ -11335,7 +8971,7 @@ function Users() {
11335
8971
  ],
11336
8972
  [items]
11337
8973
  );
11338
- const users = data2?.data || [];
8974
+ const users = data?.data || [];
11339
8975
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
11340
8976
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Modal2, {}),
11341
8977
  /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
@@ -11355,7 +8991,7 @@ var users_default = Users;
11355
8991
 
11356
8992
  // src/components/users/ResetPasswordPage.tsx
11357
8993
  var import_react40 = require("react");
11358
- var import_react_router_dom6 = require("react-router-dom");
8994
+ var import_react_router_dom7 = require("react-router-dom");
11359
8995
  var import_lucide_react21 = require("lucide-react");
11360
8996
  var import_react_hook_form13 = require("react-hook-form");
11361
8997
  var import_zod8 = require("@hookform/resolvers/zod");
@@ -11365,13 +9001,13 @@ var import_jsx_runtime50 = require("react/jsx-runtime");
11365
9001
  var resetPageSchema = z4.object({
11366
9002
  password: z4.string().min(6, "Password must be at least 6 characters"),
11367
9003
  confirmPassword: z4.string().min(6, "Password must be at least 6 characters")
11368
- }).refine((data2) => data2.password === data2.confirmPassword, {
9004
+ }).refine((data) => data.password === data.confirmPassword, {
11369
9005
  message: "Passwords don't match",
11370
9006
  path: ["confirmPassword"]
11371
9007
  });
11372
9008
  function ResetPasswordPage() {
11373
- const [searchParams] = (0, import_react_router_dom6.useSearchParams)();
11374
- const navigate = (0, import_react_router_dom6.useNavigate)();
9009
+ const [searchParams] = (0, import_react_router_dom7.useSearchParams)();
9010
+ const navigate = (0, import_react_router_dom7.useNavigate)();
11375
9011
  const { put, isLoading } = useApis_default();
11376
9012
  const [isVerified, setIsVerified] = (0, import_react40.useState)(false);
11377
9013
  const [verifying, setVerifying] = (0, import_react40.useState)(true);
@@ -11408,14 +9044,14 @@ function ResetPasswordPage() {
11408
9044
  };
11409
9045
  verifyToken();
11410
9046
  }, [token, email]);
11411
- const onSubmit = async (data2) => {
9047
+ const onSubmit = async (data) => {
11412
9048
  try {
11413
9049
  await put({
11414
9050
  url: `/users/set_password/${id}`,
11415
9051
  body: {
11416
9052
  token,
11417
9053
  email,
11418
- password: data2.password
9054
+ password: data.password
11419
9055
  }
11420
9056
  });
11421
9057
  import_antd13.message.success(
@@ -11543,7 +9179,7 @@ var ResetPasswordPage_default = ResetPasswordPage;
11543
9179
 
11544
9180
  // src/components/users/UserProfile.tsx
11545
9181
  var import_lucide_react22 = require("lucide-react");
11546
- var import_react_router_dom7 = require("react-router-dom");
9182
+ var import_react_router_dom8 = require("react-router-dom");
11547
9183
  var import_antd14 = require("antd");
11548
9184
  var import_jsx_runtime51 = require("react/jsx-runtime");
11549
9185
  var UserProfile = ({
@@ -11556,7 +9192,7 @@ var UserProfile = ({
11556
9192
  }) => {
11557
9193
  const { post } = useApis_default();
11558
9194
  const { user, logout: authLogout, account } = useAuth_default();
11559
- const navigate = (0, import_react_router_dom7.useNavigate)();
9195
+ const navigate = (0, import_react_router_dom8.useNavigate)();
11560
9196
  const logout = async () => {
11561
9197
  if (onLogout) {
11562
9198
  onLogout();
@@ -11608,8 +9244,11 @@ var UserProfile = ({
11608
9244
  var UserProfile_default = UserProfile;
11609
9245
 
11610
9246
  // src/components/users/ProfilePage.tsx
9247
+ var import_react_router_dom9 = require("react-router-dom");
9248
+ var import_lucide_react23 = require("lucide-react");
11611
9249
  var import_jsx_runtime52 = require("react/jsx-runtime");
11612
9250
  var ProfilePage = () => {
9251
+ const navigate = (0, import_react_router_dom9.useNavigate)();
11613
9252
  const { user, account } = useAuth();
11614
9253
  if (!user) {
11615
9254
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("h1", { children: "Please login to view your profile" }) });
@@ -11631,17 +9270,30 @@ var ProfilePage = () => {
11631
9270
  copiable: false
11632
9271
  }
11633
9272
  ];
11634
- return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "p-4 sm:p-8", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
11635
- ProfileView,
11636
- {
11637
- name: account?.name || "User Account",
11638
- email: user.email || account?.email,
11639
- role: user.role,
11640
- info: extraInfo,
11641
- title: "User Profile",
11642
- description: "View your profile information"
11643
- }
11644
- ) });
9273
+ return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "p-4 sm:p-8 space-y-6", children: [
9274
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "max-w-5xl mx-auto", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9275
+ Button,
9276
+ {
9277
+ variant: "outline",
9278
+ size: "sm",
9279
+ onClick: () => navigate(-1),
9280
+ icon: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_lucide_react23.ArrowLeft, { size: 16 }),
9281
+ className: "rounded-full font-bold px-5",
9282
+ children: "Back"
9283
+ }
9284
+ ) }),
9285
+ /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9286
+ ProfileView,
9287
+ {
9288
+ name: account?.name || "User Account",
9289
+ email: user.email || account?.email,
9290
+ role: user.role,
9291
+ info: extraInfo,
9292
+ title: "User Profile",
9293
+ description: "View your profile information"
9294
+ }
9295
+ )
9296
+ ] });
11645
9297
  };
11646
9298
  var ProfilePage_default = ProfilePage;
11647
9299
  // Annotate the CommonJS export names for ESM import in node:
@@ -11714,6 +9366,7 @@ var ProfilePage_default = ProfilePage;
11714
9366
  useA4StatementView,
11715
9367
  useAntdImageUpload,
11716
9368
  useApi,
9369
+ useApp,
11717
9370
  useAuth,
11718
9371
  useAuthStore,
11719
9372
  useLogin,
@@ -11725,18 +9378,3 @@ var ProfilePage_default = ProfilePage;
11725
9378
  useWarqadConfig,
11726
9379
  verifyUserEmailSchema
11727
9380
  });
11728
- /*! Bundled license information:
11729
-
11730
- react-router/dist/development/chunk-LFPYN7LY.mjs:
11731
- react-router/dist/development/index.mjs:
11732
- (**
11733
- * react-router v7.13.1
11734
- *
11735
- * Copyright (c) Remix Software Inc.
11736
- *
11737
- * This source code is licensed under the MIT license found in the
11738
- * LICENSE.md file in the root directory of this source tree.
11739
- *
11740
- * @license MIT
11741
- *)
11742
- */