@layerfi/components 0.1.114 → 0.1.115-alpha

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.
@@ -70,7 +70,7 @@ const reactAriaComponents = require("react-aria-components");
70
70
  const lucideReact = require("lucide-react");
71
71
  const pluralize = require("pluralize");
72
72
  const useResizeObserver = require("@react-hook/resize-observer");
73
- const Select$1 = require("react-select");
73
+ const ReactSelect = require("react-select");
74
74
  const reactDropzone = require("react-dropzone");
75
75
  const reactForm = require("@tanstack/react-form");
76
76
  const BaseCreatableSelect = require("react-select/creatable");
@@ -202,7 +202,7 @@ class ErrorHandlerClass {
202
202
  }
203
203
  const errorHandler = new ErrorHandlerClass();
204
204
  const reportError = (payload) => errorHandler.onError(payload);
205
- const version = "0.1.114";
205
+ const version = "0.1.115-alpha";
206
206
  const pkg = {
207
207
  version
208
208
  };
@@ -673,7 +673,7 @@ function requestOAuthToken(_0) {
673
673
  }).then((res) => res.json());
674
674
  });
675
675
  }
676
- function buildKey$10({
676
+ function buildKey$14({
677
677
  appId,
678
678
  appSecret,
679
679
  businessAccessToken,
@@ -716,7 +716,7 @@ function useAuth() {
716
716
  businessAccessToken
717
717
  } = useAuthInput();
718
718
  return useSWR(
719
- () => buildKey$10({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }),
719
+ () => buildKey$14({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }),
720
720
  (key) => {
721
721
  if (key.mode === "explicit") {
722
722
  const { businessAccessToken: businessAccessToken2, apiUrl: apiUrl3 } = key;
@@ -751,7 +751,7 @@ const useLayerContext = () => {
751
751
  return ctx;
752
752
  };
753
753
  const EXTERNAL_ACCOUNTS_TAG_KEY = "#external-accounts";
754
- function buildKey$$({
754
+ function buildKey$13({
755
755
  access_token: accessToken,
756
756
  apiUrl,
757
757
  businessId
@@ -770,7 +770,7 @@ function useListExternalAccounts() {
770
770
  const { apiUrl } = useEnvironment();
771
771
  const { data: auth } = useAuth();
772
772
  return useSWR(
773
- () => buildKey$$(__spreadProps(__spreadValues({}, auth), {
773
+ () => buildKey$13(__spreadProps(__spreadValues({}, auth), {
774
774
  apiUrl,
775
775
  businessId
776
776
  })),
@@ -4053,7 +4053,7 @@ const BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
4053
4053
  const getBankAccounts = get$1(
4054
4054
  ({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
4055
4055
  );
4056
- function buildKey$_({
4056
+ function buildKey$12({
4057
4057
  access_token: accessToken,
4058
4058
  apiUrl,
4059
4059
  businessId
@@ -4074,7 +4074,7 @@ const useBankAccounts = () => {
4074
4074
  const { apiUrl } = useEnvironment();
4075
4075
  const { data: auth } = useAuth();
4076
4076
  const { data, error, isLoading } = useSWR(
4077
- () => buildKey$_(__spreadProps(__spreadValues({}, auth), {
4077
+ () => buildKey$12(__spreadProps(__spreadValues({}, auth), {
4078
4078
  apiUrl,
4079
4079
  businessId
4080
4080
  })),
@@ -5515,7 +5515,7 @@ class ProfitAndLossReportSWRResponse {
5515
5515
  return this.swrResponse.mutate;
5516
5516
  }
5517
5517
  }
5518
- function buildKey$Z({
5518
+ function buildKey$11({
5519
5519
  access_token: accessToken,
5520
5520
  apiUrl,
5521
5521
  businessId,
@@ -5559,7 +5559,7 @@ function useProfitAndLossReport({ startDate, endDate, tagKey, tagValues, reporti
5559
5559
  const { data } = useAuth();
5560
5560
  const { businessId } = useLayerContext();
5561
5561
  const response = useSWR(
5562
- () => buildKey$Z(__spreadProps(__spreadValues({}, data), {
5562
+ () => buildKey$11(__spreadProps(__spreadValues({}, data), {
5563
5563
  businessId,
5564
5564
  startDate,
5565
5565
  endDate,
@@ -5625,7 +5625,7 @@ class ProfitAndLossSummariesSWRResponse {
5625
5625
  return this.swrResponse.mutate;
5626
5626
  }
5627
5627
  }
5628
- function buildKey$Y({
5628
+ function buildKey$10({
5629
5629
  access_token: accessToken,
5630
5630
  apiUrl,
5631
5631
  businessId,
@@ -5672,7 +5672,7 @@ function useProfitAndLossSummaries({ startYear, startMonth, endYear, endMonth, t
5672
5672
  const { data } = useAuth();
5673
5673
  const { businessId } = useLayerContext();
5674
5674
  const response = useSWR(
5675
- () => buildKey$Y(__spreadProps(__spreadValues({}, data), {
5675
+ () => buildKey$10(__spreadProps(__spreadValues({}, data), {
5676
5676
  businessId,
5677
5677
  startYear,
5678
5678
  startMonth,
@@ -5742,7 +5742,7 @@ const useProfitAndLossGlobalInvalidator = () => {
5742
5742
  return { invalidateProfitAndLoss, debouncedInvalidateProfitAndLoss };
5743
5743
  };
5744
5744
  const CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
5745
- function buildKey$X({
5745
+ function buildKey$$({
5746
5746
  access_token: accessToken,
5747
5747
  apiUrl,
5748
5748
  businessId
@@ -5765,7 +5765,7 @@ function useCategorizeBankTransaction({
5765
5765
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
5766
5766
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
5767
5767
  const mutationResponse = useSWRMutation(
5768
- () => buildKey$X({
5768
+ () => buildKey$$({
5769
5769
  access_token: auth == null ? void 0 : auth.access_token,
5770
5770
  apiUrl: auth == null ? void 0 : auth.apiUrl,
5771
5771
  businessId
@@ -5813,7 +5813,7 @@ function useCategorizeBankTransaction({
5813
5813
  });
5814
5814
  }
5815
5815
  const MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
5816
- function buildKey$W({
5816
+ function buildKey$_({
5817
5817
  access_token: accessToken,
5818
5818
  apiUrl,
5819
5819
  businessId
@@ -5835,7 +5835,7 @@ function useMatchBankTransaction({
5835
5835
  const { mutate } = useSWR.useSWRConfig();
5836
5836
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
5837
5837
  const mutationResponse = useSWRMutation(
5838
- () => buildKey$W({
5838
+ () => buildKey$_({
5839
5839
  access_token: auth == null ? void 0 : auth.access_token,
5840
5840
  apiUrl: auth == null ? void 0 : auth.apiUrl,
5841
5841
  businessId
@@ -6301,16 +6301,24 @@ const useAugmentedBankTransactions = (params) => {
6301
6301
  }
6302
6302
  return filtered;
6303
6303
  }, [filters, data]);
6304
- const updateOneLocal = (newBankTransaction) => {
6305
- if (newBankTransaction.update_categorization_rules_suggestion) {
6306
- const decodedRuleSuggestion = decodeRulesSuggestion(newBankTransaction.update_categorization_rules_suggestion);
6307
- setRuleSuggestion(decodedRuleSuggestion);
6304
+ const updateLocalBankTransactions = (newBankTransactions) => {
6305
+ const transactionsById = new Map(
6306
+ newBankTransactions.map((bt) => [bt.id, bt])
6307
+ );
6308
+ for (const bt of newBankTransactions) {
6309
+ if (bt.update_categorization_rules_suggestion) {
6310
+ const decodedRuleSuggestion = decodeRulesSuggestion(bt.update_categorization_rules_suggestion);
6311
+ setRuleSuggestion(decodedRuleSuggestion);
6312
+ }
6308
6313
  }
6309
6314
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
6310
6315
  var _a2;
6311
6316
  return __spreadProps(__spreadValues({}, page), {
6312
6317
  data: (_a2 = page.data) == null ? void 0 : _a2.map(
6313
- (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
6318
+ (bt) => {
6319
+ var _a3;
6320
+ return (_a3 = transactionsById.get(bt.id)) != null ? _a3 : bt;
6321
+ }
6314
6322
  )
6315
6323
  });
6316
6324
  });
@@ -6322,25 +6330,29 @@ const useAugmentedBankTransactions = (params) => {
6322
6330
  const categorizeWithOptimisticUpdate = (bankTransactionId, newCategory, notify) => __async(null, null, function* () {
6323
6331
  const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
6324
6332
  if (existingTransaction) {
6325
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), { update_categorization_rules_suggestion: void 0, processing: true, error: void 0 }));
6333
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, existingTransaction), {
6334
+ update_categorization_rules_suggestion: void 0,
6335
+ processing: true,
6336
+ error: void 0
6337
+ })]);
6326
6338
  }
6327
6339
  return categorizeBankTransaction2(__spreadValues({
6328
6340
  bankTransactionId
6329
6341
  }, newCategory)).then((updatedTransaction) => {
6330
- updateOneLocal(__spreadProps(__spreadValues({}, updatedTransaction), {
6342
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, updatedTransaction), {
6331
6343
  processing: false,
6332
6344
  recently_categorized: true
6333
- }));
6345
+ })]);
6334
6346
  if (notify) {
6335
6347
  addToast({ content: "Transaction confirmed" });
6336
6348
  }
6337
6349
  }).catch((error) => {
6338
6350
  const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
6339
6351
  if (targetedTransaction) {
6340
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
6352
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, targetedTransaction), {
6341
6353
  error: error instanceof Error ? error.message : "An unknown error occurred",
6342
6354
  processing: false
6343
- }));
6355
+ })]);
6344
6356
  }
6345
6357
  }).finally(() => {
6346
6358
  var _a2;
@@ -6350,71 +6362,76 @@ const useAugmentedBankTransactions = (params) => {
6350
6362
  const { trigger: matchBankTransaction2 } = useMatchBankTransaction({
6351
6363
  mutateBankTransactions: mutate
6352
6364
  });
6353
- const matchWithOptimisticUpdate = (bankTransactionId, suggestedMatchId, notify) => __async(null, null, function* () {
6354
- const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
6355
- if (existingTransaction) {
6356
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), {
6357
- processing: true,
6358
- error: void 0
6359
- }));
6360
- }
6361
- const transferBankTransaction = data == null ? void 0 : data.find(
6362
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
6365
+ const matchWithOptimisticUpdate = (bankTransaction, suggestedMatchId, notify) => __async(null, null, function* () {
6366
+ var _a2, _b;
6367
+ const suggestedMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
6368
+ (sm) => sm.id === suggestedMatchId
6363
6369
  );
6364
- if (transferBankTransaction) {
6365
- updateOneLocal(__spreadProps(__spreadValues({}, transferBankTransaction), {
6370
+ const matchedTransferBankTransactionId = (_b = suggestedMatch == null ? void 0 : suggestedMatch.details) == null ? void 0 : _b.id;
6371
+ const matchedTransferBankTransaction = matchedTransferBankTransactionId ? data == null ? void 0 : data.find(({ id }) => id === matchedTransferBankTransactionId) : void 0;
6372
+ const transactionsToSetProcessing = [
6373
+ __spreadProps(__spreadValues({}, bankTransaction), { processing: true, error: void 0 })
6374
+ ];
6375
+ if (matchedTransferBankTransaction) {
6376
+ transactionsToSetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
6366
6377
  processing: true,
6367
6378
  error: void 0
6368
6379
  }));
6369
6380
  }
6381
+ updateLocalBankTransactions(transactionsToSetProcessing);
6370
6382
  return matchBankTransaction2({
6371
- bankTransactionId,
6383
+ bankTransactionId: bankTransaction.id,
6372
6384
  match_id: suggestedMatchId,
6373
6385
  type: "Confirm_Match"
6374
6386
  }).then((match) => {
6375
- const matchedTransaction = data == null ? void 0 : data.find(({ id }) => id === match.bank_transaction.id);
6376
- if (matchedTransaction) {
6377
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransaction), {
6387
+ const transactionsToUpdate = [
6388
+ __spreadProps(__spreadValues({}, bankTransaction), {
6378
6389
  categorization_status: CategorizationStatus.MATCHED,
6379
6390
  match,
6380
6391
  processing: false,
6381
6392
  recently_categorized: true
6382
- }));
6383
- }
6384
- const matchedTransferTransaction = data == null ? void 0 : data.find(
6385
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
6386
- );
6387
- if (matchedTransferTransaction) {
6388
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransferTransaction), {
6393
+ })
6394
+ ];
6395
+ if (matchedTransferBankTransaction) {
6396
+ transactionsToUpdate.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
6397
+ categorization_status: CategorizationStatus.MATCHED,
6398
+ match,
6389
6399
  processing: false,
6390
6400
  recently_categorized: true
6391
6401
  }));
6392
6402
  }
6403
+ updateLocalBankTransactions(transactionsToUpdate);
6393
6404
  if (notify) {
6394
6405
  addToast({ content: "Transaction saved" });
6395
6406
  }
6396
6407
  }).catch((error) => {
6397
- const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
6398
- if (targetedTransaction) {
6399
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
6408
+ const transactionsToResetProcessing = [
6409
+ __spreadProps(__spreadValues({}, bankTransaction), {
6400
6410
  error: error instanceof Error ? error.message : "An unknown error occurred",
6401
6411
  processing: false
6412
+ })
6413
+ ];
6414
+ if (matchedTransferBankTransaction) {
6415
+ transactionsToResetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
6416
+ error: void 0,
6417
+ processing: false
6402
6418
  }));
6403
6419
  }
6420
+ updateLocalBankTransactions(transactionsToResetProcessing);
6404
6421
  }).finally(() => {
6405
- var _a2;
6406
- (_a2 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a2.call(eventCallbacks);
6422
+ var _a3;
6423
+ (_a3 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a3.call(eventCallbacks);
6407
6424
  });
6408
6425
  });
6409
6426
  const shouldHideAfterCategorize = () => {
6410
6427
  return (filters == null ? void 0 : filters.categorizationStatus) === DisplayState.review;
6411
6428
  };
6412
- const removeAfterCategorize = (bankTransaction) => {
6429
+ const removeAfterCategorize = (transactionIds) => {
6413
6430
  if (shouldHideAfterCategorize()) {
6414
6431
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
6415
6432
  var _a2;
6416
6433
  return __spreadProps(__spreadValues({}, page), {
6417
- data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => bt.id !== bankTransaction.id)
6434
+ data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => !transactionIds.includes(bt.id))
6418
6435
  });
6419
6436
  });
6420
6437
  void mutate(updatedData, { revalidate: false });
@@ -6493,7 +6510,7 @@ const useAugmentedBankTransactions = (params) => {
6493
6510
  isError: !!responseError,
6494
6511
  categorize: categorizeWithOptimisticUpdate,
6495
6512
  match: matchWithOptimisticUpdate,
6496
- updateOneLocal,
6513
+ updateLocalBankTransactions,
6497
6514
  shouldHideAfterCategorize,
6498
6515
  removeAfterCategorize,
6499
6516
  display,
@@ -7861,7 +7878,7 @@ const getBookkeepingStatus = get$1(({ businessId }) => {
7861
7878
  });
7862
7879
  const BOOKKEEPING_TAG_KEY = "#bookkeeping";
7863
7880
  const BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
7864
- function buildKey$V({
7881
+ function buildKey$Z({
7865
7882
  access_token: accessToken,
7866
7883
  apiUrl,
7867
7884
  businessId
@@ -7879,7 +7896,7 @@ function useBookkeepingStatus() {
7879
7896
  const { data: auth } = useAuth();
7880
7897
  const { businessId } = useLayerContext();
7881
7898
  return useSWR(
7882
- () => buildKey$V(__spreadProps(__spreadValues({}, auth), {
7899
+ () => buildKey$Z(__spreadProps(__spreadValues({}, auth), {
7883
7900
  businessId
7884
7901
  })),
7885
7902
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingStatus(
@@ -7919,6 +7936,50 @@ function isCategorizationEnabledForStatus(status) {
7919
7936
  }
7920
7937
  }
7921
7938
  }
7939
+ const CATEGORIES_TAG_KEY = "#categories";
7940
+ function buildKey$Y({
7941
+ access_token: accessToken,
7942
+ apiUrl,
7943
+ businessId,
7944
+ mode
7945
+ }) {
7946
+ if (accessToken && apiUrl) {
7947
+ return {
7948
+ accessToken,
7949
+ apiUrl,
7950
+ businessId,
7951
+ mode,
7952
+ tags: [CATEGORIES_TAG_KEY]
7953
+ };
7954
+ }
7955
+ }
7956
+ const getCategories = get$1(({ businessId, mode }) => {
7957
+ const parameters = toDefinedSearchParameters({ mode });
7958
+ return `/v1/businesses/${businessId}/categories?${parameters}`;
7959
+ });
7960
+ function useCategories({ mode } = {}) {
7961
+ const { data: auth } = useAuth();
7962
+ const { businessId } = useLayerContext();
7963
+ return useSWR(
7964
+ () => buildKey$Y(__spreadProps(__spreadValues({}, auth), {
7965
+ businessId,
7966
+ mode
7967
+ })),
7968
+ ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
7969
+ apiUrl,
7970
+ accessToken,
7971
+ {
7972
+ params: {
7973
+ businessId: businessId2,
7974
+ mode: mode2
7975
+ }
7976
+ }
7977
+ )().then(({ data }) => effect.Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
7978
+ );
7979
+ }
7980
+ function usePreloadCategories(options2) {
7981
+ useCategories(options2);
7982
+ }
7922
7983
  const useElementSize = (callback) => {
7923
7984
  const ref = react.useRef(null);
7924
7985
  const resizeTimeout = react.useRef(null);
@@ -8046,15 +8107,15 @@ const BankTransactionsContext = react.createContext({
8046
8107
  isError: false,
8047
8108
  refetch: () => {
8048
8109
  },
8049
- categorize: () => Promise.resolve(void 0),
8050
- match: () => Promise.resolve(void 0),
8110
+ categorize: () => Promise.resolve(),
8111
+ match: () => Promise.resolve(),
8051
8112
  metadata: {
8052
8113
  pagination: {
8053
8114
  cursor: void 0,
8054
8115
  has_more: false
8055
8116
  }
8056
8117
  },
8057
- updateOneLocal: () => void 0,
8118
+ updateLocalBankTransactions: () => void 0,
8058
8119
  shouldHideAfterCategorize: () => false,
8059
8120
  removeAfterCategorize: () => void 0,
8060
8121
  display: DisplayState.review,
@@ -8337,7 +8398,7 @@ const useBusinessActivationDate = () => {
8337
8398
  const { business } = useLayerContext();
8338
8399
  return react.useMemo(() => getActivationDate(business), [business]);
8339
8400
  };
8340
- function buildKey$U({
8401
+ function buildKey$X({
8341
8402
  access_token: accessToken,
8342
8403
  apiUrl,
8343
8404
  businessId
@@ -8355,7 +8416,7 @@ function useBankTransactionsDownload() {
8355
8416
  const { data } = useAuth();
8356
8417
  const { businessId } = useLayerContext();
8357
8418
  return useSWRMutation(
8358
- () => buildKey$U(__spreadProps(__spreadValues({}, data), {
8419
+ () => buildKey$X(__spreadProps(__spreadValues({}, data), {
8359
8420
  businessId
8360
8421
  })),
8361
8422
  ({
@@ -8513,7 +8574,7 @@ const BulkCategorizeRequestSchema = effect.Schema.Struct({
8513
8574
  transactions: effect.Schema.Array(CategorizeTransactionRequestSchema$1)
8514
8575
  });
8515
8576
  const bulkCategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-categorize`);
8516
- function buildKey$T({
8577
+ function buildKey$W({
8517
8578
  access_token: accessToken,
8518
8579
  apiUrl,
8519
8580
  businessId
@@ -8532,7 +8593,7 @@ const useBulkCategorize = () => {
8532
8593
  const { businessId, eventCallbacks } = useLayerContext();
8533
8594
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
8534
8595
  const mutationResponse = useSWRMutation(
8535
- () => buildKey$T(__spreadProps(__spreadValues({}, data), {
8596
+ () => buildKey$W(__spreadProps(__spreadValues({}, data), {
8536
8597
  businessId
8537
8598
  })),
8538
8599
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkCategorize(
@@ -8802,50 +8863,6 @@ const Span = react.forwardRef(
8802
8863
  );
8803
8864
  }
8804
8865
  );
8805
- const CATEGORIES_TAG_KEY = "#categories";
8806
- function buildKey$S({
8807
- access_token: accessToken,
8808
- apiUrl,
8809
- businessId,
8810
- mode
8811
- }) {
8812
- if (accessToken && apiUrl) {
8813
- return {
8814
- accessToken,
8815
- apiUrl,
8816
- businessId,
8817
- mode,
8818
- tags: [CATEGORIES_TAG_KEY]
8819
- };
8820
- }
8821
- }
8822
- const getCategories = get$1(({ businessId, mode }) => {
8823
- const parameters = toDefinedSearchParameters({ mode });
8824
- return `/v1/businesses/${businessId}/categories?${parameters}`;
8825
- });
8826
- function useCategories({ mode } = {}) {
8827
- const { data: auth } = useAuth();
8828
- const { businessId } = useLayerContext();
8829
- return useSWR(
8830
- () => buildKey$S(__spreadProps(__spreadValues({}, auth), {
8831
- businessId,
8832
- mode
8833
- })),
8834
- ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
8835
- apiUrl,
8836
- accessToken,
8837
- {
8838
- params: {
8839
- businessId: businessId2,
8840
- mode: mode2
8841
- }
8842
- }
8843
- )().then(({ data }) => effect.Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
8844
- );
8845
- }
8846
- function usePreloadCategories(options2) {
8847
- useCategories(options2);
8848
- }
8849
8866
  const Check = (_R) => {
8850
8867
  var _S = _R, { size = 18 } = _S, props = __objRest(_S, ["size"]);
8851
8868
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -8902,7 +8919,7 @@ function buildCustomGroupHeading({
8902
8919
  const defaultRenderedGroupHeading = react.useMemo(() => /* @__PURE__ */ jsxRuntime.jsx(Header$2, { size: "xs", variant: "subtle", children }), [children]);
8903
8920
  const content = GroupHeading ? /* @__PURE__ */ jsxRuntime.jsx(GroupHeading, { group: restProps.data, fallback: defaultRenderedGroupHeading }) : defaultRenderedGroupHeading;
8904
8921
  return /* @__PURE__ */ jsxRuntime.jsx(
8905
- Select$1.components.GroupHeading,
8922
+ ReactSelect.components.GroupHeading,
8906
8923
  __spreadProps(__spreadValues({}, restProps), {
8907
8924
  className: COMBO_BOX_CLASS_NAMES.GROUP_HEADING,
8908
8925
  children: content
@@ -8927,7 +8944,7 @@ function buildCustomComboBoxOption({
8927
8944
  /* @__PURE__ */ jsxRuntime.jsx(Span, { variant: "inherit", children })
8928
8945
  ] }), [children]);
8929
8946
  return /* @__PURE__ */ jsxRuntime.jsx(
8930
- Select$1.components.Option,
8947
+ ReactSelect.components.Option,
8931
8948
  __spreadProps(__spreadValues({}, restProps), {
8932
8949
  className: classNames(
8933
8950
  COMBO_BOX_CLASS_NAMES.OPTION,
@@ -8949,7 +8966,7 @@ function buildCustomClearIndicator() {
8949
8966
  "children"
8950
8967
  ]);
8951
8968
  return /* @__PURE__ */ jsxRuntime.jsx(
8952
- Select$1.components.ClearIndicator,
8969
+ ReactSelect.components.ClearIndicator,
8953
8970
  __spreadProps(__spreadValues({}, restProps), {
8954
8971
  className: COMBO_BOX_CLASS_NAMES.CLEAR_INDICATOR,
8955
8972
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 16 })
@@ -8971,7 +8988,7 @@ function buildCustomDropdownIndicator() {
8971
8988
  ]);
8972
8989
  const { isDisabled } = restProps;
8973
8990
  return /* @__PURE__ */ jsxRuntime.jsx(
8974
- Select$1.components.DropdownIndicator,
8991
+ ReactSelect.components.DropdownIndicator,
8975
8992
  __spreadProps(__spreadValues({}, restProps), {
8976
8993
  className: COMBO_BOX_CLASS_NAMES.DROPDOWN_INDICATOR,
8977
8994
  children: !isDisabled ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
@@ -8987,7 +9004,7 @@ function buildCustomNoOptionsMessage({ EmptyMessage }) {
8987
9004
  "children"
8988
9005
  ]);
8989
9006
  return /* @__PURE__ */ jsxRuntime.jsx(
8990
- Select$1.components.NoOptionsMessage,
9007
+ ReactSelect.components.NoOptionsMessage,
8991
9008
  __spreadProps(__spreadValues({}, restProps), {
8992
9009
  className: COMBO_BOX_CLASS_NAMES.NO_OPTIONS_MESSAGE,
8993
9010
  children: EmptyMessage != null ? EmptyMessage : /* @__PURE__ */ jsxRuntime.jsx(Span, { children: "No matching options" })
@@ -9004,7 +9021,7 @@ function buildCustomPlaceholder({ placeholder }) {
9004
9021
  ]);
9005
9022
  if (!placeholder) return null;
9006
9023
  return /* @__PURE__ */ jsxRuntime.jsx(
9007
- Select$1.components.Placeholder,
9024
+ ReactSelect.components.Placeholder,
9008
9025
  __spreadProps(__spreadValues({}, restProps), {
9009
9026
  className: COMBO_BOX_CLASS_NAMES.PLACEHOLDER,
9010
9027
  children: /* @__PURE__ */ jsxRuntime.jsx(Span, { variant: "placeholder", ellipsis: true, children: placeholder })
@@ -9020,7 +9037,7 @@ function buildCustomSingleValue({ SelectedValue }) {
9020
9037
  "children"
9021
9038
  ]);
9022
9039
  return /* @__PURE__ */ jsxRuntime.jsx(
9023
- Select$1.components.SingleValue,
9040
+ ReactSelect.components.SingleValue,
9024
9041
  __spreadProps(__spreadValues({}, restProps), {
9025
9042
  children: SelectedValue != null ? SelectedValue : children
9026
9043
  })
@@ -9036,7 +9053,7 @@ function buildCustomMenuPortal() {
9036
9053
  ]);
9037
9054
  const dataProperties = toDataProperties({ "react-aria-top-layer": true });
9038
9055
  return /* @__PURE__ */ jsxRuntime.jsx(
9039
- Select$1.components.MenuPortal,
9056
+ ReactSelect.components.MenuPortal,
9040
9057
  __spreadProps(__spreadValues({}, restProps), {
9041
9058
  innerProps: dataProperties,
9042
9059
  children
@@ -9111,7 +9128,7 @@ function ComboBox(_T) {
9111
9128
  const CustomDropdownIndicatorRef = react.useRef(buildCustomDropdownIndicator());
9112
9129
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "3xs", fluid: true, className: className ? `${className}__Container` : void 0, children: [
9113
9130
  /* @__PURE__ */ jsxRuntime.jsx(
9114
- Select$1,
9131
+ ReactSelect,
9115
9132
  __spreadProps(__spreadValues({
9116
9133
  inputId: effectiveInputId
9117
9134
  }, ariaProps), {
@@ -10524,7 +10541,7 @@ const bulkMatchOrCategorize = post(
10524
10541
  return `/v1/businesses/${businessId}/bank-transactions/bulk-match-or-categorize?${parameters}`;
10525
10542
  }
10526
10543
  );
10527
- function buildKey$R({
10544
+ function buildKey$V({
10528
10545
  access_token: accessToken,
10529
10546
  apiUrl,
10530
10547
  businessId
@@ -10549,7 +10566,7 @@ const useBulkMatchOrCategorize = () => {
10549
10566
  return { transactions };
10550
10567
  }, [selectedIds, transactionCategories]);
10551
10568
  const mutationResponse = useSWRMutation(
10552
- () => buildKey$R(__spreadProps(__spreadValues({}, data), {
10569
+ () => buildKey$V(__spreadProps(__spreadValues({}, data), {
10553
10570
  businessId
10554
10571
  })),
10555
10572
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkMatchOrCategorize(
@@ -10619,7 +10636,7 @@ const BulkUncategorizeRequestSchema = effect.Schema.Struct({
10619
10636
  )
10620
10637
  });
10621
10638
  const bulkUncategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-uncategorize`);
10622
- function buildKey$Q({
10639
+ function buildKey$U({
10623
10640
  access_token: accessToken,
10624
10641
  apiUrl,
10625
10642
  businessId
@@ -10638,7 +10655,7 @@ const useBulkUncategorize = () => {
10638
10655
  const { businessId, eventCallbacks } = useLayerContext();
10639
10656
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
10640
10657
  const mutationResponse = useSWRMutation(
10641
- () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
10658
+ () => buildKey$U(__spreadProps(__spreadValues({}, data), {
10642
10659
  businessId
10643
10660
  })),
10644
10661
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkUncategorize(
@@ -11042,7 +11059,7 @@ const mapRawCustomAccountToCustomAccount = (raw) => ({
11042
11059
  userCreated: raw.user_created
11043
11060
  });
11044
11061
  const CUSTOM_ACCOUNTS_TAG_KEY = "#custom-accounts";
11045
- function buildKey$P({
11062
+ function buildKey$T({
11046
11063
  access_token: accessToken,
11047
11064
  apiUrl,
11048
11065
  businessId,
@@ -11069,7 +11086,7 @@ function useCustomAccounts({ userCreated } = {}) {
11069
11086
  const { data } = useAuth();
11070
11087
  const { businessId } = useLayerContext();
11071
11088
  return useSWR(
11072
- () => buildKey$P(__spreadProps(__spreadValues({}, data), {
11089
+ () => buildKey$T(__spreadProps(__spreadValues({}, data), {
11073
11090
  businessId,
11074
11091
  userCreated
11075
11092
  })),
@@ -11082,7 +11099,7 @@ function useCustomAccounts({ userCreated } = {}) {
11082
11099
  )().then(({ data: data2 }) => data2 == null ? void 0 : data2.custom_accounts.map((account) => mapRawCustomAccountToCustomAccount(account)))
11083
11100
  );
11084
11101
  }
11085
- function buildKey$O({
11102
+ function buildKey$S({
11086
11103
  access_token: accessToken,
11087
11104
  apiUrl,
11088
11105
  businessId
@@ -11115,7 +11132,7 @@ function useCustomAccountParseCsv() {
11115
11132
  const { data } = useAuth();
11116
11133
  const { businessId } = useLayerContext();
11117
11134
  return useSWRMutation(
11118
- () => buildKey$O(__spreadProps(__spreadValues({}, data), {
11135
+ () => buildKey$S(__spreadProps(__spreadValues({}, data), {
11119
11136
  businessId
11120
11137
  })),
11121
11138
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { customAccountId, file } }) => parseCsv(
@@ -11360,7 +11377,7 @@ function flattenValidationErrors(errors) {
11360
11377
  );
11361
11378
  }
11362
11379
  const createCustomAccount = post(({ businessId }) => `/v1/businesses/${businessId}/custom-accounts`);
11363
- function buildKey$N({
11380
+ function buildKey$R({
11364
11381
  access_token: accessToken,
11365
11382
  apiUrl,
11366
11383
  businessId
@@ -11379,7 +11396,7 @@ function useCreateCustomAccount() {
11379
11396
  const { businessId } = useLayerContext();
11380
11397
  const { mutate } = useSWR.useSWRConfig();
11381
11398
  const mutationResponse = useSWRMutation(
11382
- () => buildKey$N(__spreadProps(__spreadValues({}, data), {
11399
+ () => buildKey$R(__spreadProps(__spreadValues({}, data), {
11383
11400
  businessId
11384
11401
  })),
11385
11402
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createCustomAccount(
@@ -11916,10 +11933,63 @@ function FormNumberField({
11916
11933
  })
11917
11934
  );
11918
11935
  }
11936
+ const SWITCH_CLASS_NAME = "Layer__UI__Switch";
11937
+ const Switch = react.forwardRef((_Va, ref) => {
11938
+ var _Wa = _Va, {
11939
+ children,
11940
+ className
11941
+ } = _Wa, props = __objRest(_Wa, [
11942
+ "children",
11943
+ "className"
11944
+ ]);
11945
+ return /* @__PURE__ */ jsxRuntime.jsx(
11946
+ reactAriaComponents.Switch,
11947
+ __spreadProps(__spreadValues({}, props), {
11948
+ className: classNames(SWITCH_CLASS_NAME, className),
11949
+ ref,
11950
+ children: withRenderProp(children, (node) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11951
+ /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "indicator" }),
11952
+ node
11953
+ ] }))
11954
+ })
11955
+ );
11956
+ });
11957
+ Switch.displayName = "Switch";
11958
+ const FORM_SWITCH_FIELD_CLASSNAME = "Layer__FormSwitchField";
11959
+ function FormSwitchField({
11960
+ label,
11961
+ className,
11962
+ inline = false,
11963
+ showLabel = true,
11964
+ isReadOnly = false
11965
+ }) {
11966
+ const field = useFieldContext();
11967
+ const { name, state, handleChange } = field;
11968
+ const { value } = state;
11969
+ const additionalAriaProps = !showLabel && { "aria-label": label };
11970
+ const switchClassNames = classNames(
11971
+ FORM_SWITCH_FIELD_CLASSNAME,
11972
+ inline && `${FORM_SWITCH_FIELD_CLASSNAME}--inline`,
11973
+ className
11974
+ );
11975
+ return /* @__PURE__ */ jsxRuntime.jsx(
11976
+ Switch,
11977
+ __spreadProps(__spreadValues({
11978
+ className: switchClassNames,
11979
+ isSelected: value,
11980
+ onChange: handleChange,
11981
+ name,
11982
+ isReadOnly,
11983
+ slot: "switch"
11984
+ }, additionalAriaProps), {
11985
+ children: showLabel && /* @__PURE__ */ jsxRuntime.jsx(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
11986
+ })
11987
+ );
11988
+ }
11919
11989
  const TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
11920
11990
  const TextArea = react.forwardRef(
11921
- function TextArea2(_Va, ref) {
11922
- var _Wa = _Va, { resize = "none" } = _Wa, restProps = __objRest(_Wa, ["resize"]);
11991
+ function TextArea2(_Xa, ref) {
11992
+ var _Ya = _Xa, { resize = "none" } = _Ya, restProps = __objRest(_Ya, ["resize"]);
11923
11993
  const dataProperties = toDataProperties({ resize });
11924
11994
  return /* @__PURE__ */ jsxRuntime.jsx(
11925
11995
  reactAriaComponents.TextArea,
@@ -11930,8 +12000,8 @@ const TextArea = react.forwardRef(
11930
12000
  );
11931
12001
  }
11932
12002
  );
11933
- function FormTextAreaField(_Xa) {
11934
- var _Ya = _Xa, { placeholder } = _Ya, props = __objRest(_Ya, ["placeholder"]);
12003
+ function FormTextAreaField(_Za) {
12004
+ var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
11935
12005
  const field = useFieldContext();
11936
12006
  const { name, state, handleChange, handleBlur } = field;
11937
12007
  const { value } = state;
@@ -11951,8 +12021,8 @@ function FormTextAreaField(_Xa) {
11951
12021
  }
11952
12022
  ) }));
11953
12023
  }
11954
- function FormTextField(_Za) {
11955
- var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
12024
+ function FormTextField(_$a) {
12025
+ var _ab = _$a, { placeholder } = _ab, props = __objRest(_ab, ["placeholder"]);
11956
12026
  const field = useFieldContext();
11957
12027
  const { name, state, handleChange, handleBlur } = field;
11958
12028
  const { value } = state;
@@ -11980,6 +12050,7 @@ const { useAppForm: useRawAppForm } = reactForm.createFormHook({
11980
12050
  FormCheckboxField,
11981
12051
  FormDateField,
11982
12052
  FormNumberField,
12053
+ FormSwitchField,
11983
12054
  FormTextAreaField,
11984
12055
  FormTextField
11985
12056
  },
@@ -12040,13 +12111,13 @@ const useCustomAccountForm = ({ onSuccess }) => {
12040
12111
  const isFormValid = reactForm.useStore(form.store, (state) => state.isValid);
12041
12112
  return { form, submitError, isFormValid };
12042
12113
  };
12043
- const Input = (_$a) => {
12044
- var _ab = _$a, {
12114
+ const Input = (_bb) => {
12115
+ var _cb = _bb, {
12045
12116
  className,
12046
12117
  isInvalid,
12047
12118
  errorMessage,
12048
12119
  leftText
12049
- } = _ab, props = __objRest(_ab, [
12120
+ } = _cb, props = __objRest(_cb, [
12050
12121
  "className",
12051
12122
  "isInvalid",
12052
12123
  "errorMessage",
@@ -12092,8 +12163,8 @@ const InputGroup = ({
12092
12163
  children
12093
12164
  ] });
12094
12165
  };
12095
- const ChevronDownFill = (_bb) => {
12096
- var _cb = _bb, { size = 18 } = _cb, props = __objRest(_cb, ["size"]);
12166
+ const ChevronDownFill = (_db) => {
12167
+ var _eb = _db, { size = 18 } = _eb, props = __objRest(_eb, ["size"]);
12097
12168
  return /* @__PURE__ */ jsxRuntime.jsxs(
12098
12169
  "svg",
12099
12170
  __spreadProps(__spreadValues({
@@ -12118,6 +12189,21 @@ const ChevronDownFill = (_bb) => {
12118
12189
  })
12119
12190
  );
12120
12191
  };
12192
+ const SelectMenuPortal = (_fb) => {
12193
+ var _gb = _fb, {
12194
+ children
12195
+ } = _gb, restProps = __objRest(_gb, [
12196
+ "children"
12197
+ ]);
12198
+ const dataProperties = toDataProperties({ "react-aria-top-layer": true });
12199
+ return /* @__PURE__ */ jsxRuntime.jsx(
12200
+ ReactSelect.components.MenuPortal,
12201
+ __spreadProps(__spreadValues({}, restProps), {
12202
+ innerProps: dataProperties,
12203
+ children
12204
+ })
12205
+ );
12206
+ };
12121
12207
  const Select = ({
12122
12208
  name,
12123
12209
  options: options2,
@@ -12138,10 +12224,10 @@ const Select = ({
12138
12224
  isInvalid ? "Layer__select--error" : "",
12139
12225
  className
12140
12226
  );
12141
- const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(Select$1.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
12227
+ const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
12142
12228
  return /* @__PURE__ */ jsxRuntime.jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
12143
12229
  /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsxRuntime.jsx(
12144
- Select$1,
12230
+ ReactSelect,
12145
12231
  {
12146
12232
  inputId,
12147
12233
  name,
@@ -12154,7 +12240,7 @@ const Select = ({
12154
12240
  onChange: (newValue) => newValue && onChange(newValue),
12155
12241
  menuPortalTarget: document.body,
12156
12242
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
12157
- components: { DropdownIndicator },
12243
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
12158
12244
  isLoading,
12159
12245
  isDisabled: disabled
12160
12246
  }
@@ -12162,8 +12248,8 @@ const Select = ({
12162
12248
  /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipContent, { className: "Layer__tooltip", children: errorMessage })
12163
12249
  ] });
12164
12250
  };
12165
- const ErrorText = (_db) => {
12166
- var _eb = _db, { className } = _eb, props = __objRest(_eb, ["className"]);
12251
+ const ErrorText = (_hb) => {
12252
+ var _ib = _hb, { className } = _ib, props = __objRest(_ib, ["className"]);
12167
12253
  return /* @__PURE__ */ jsxRuntime.jsx(Text, __spreadProps(__spreadValues({}, props), { status: "error", className }));
12168
12254
  };
12169
12255
  const accountTypeOptions = [
@@ -12298,7 +12384,7 @@ const CreatableSelect = ({
12298
12384
  isInvalid ? "Layer__select--error" : "",
12299
12385
  className
12300
12386
  );
12301
- const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(Select$1.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
12387
+ const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
12302
12388
  return /* @__PURE__ */ jsxRuntime.jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
12303
12389
  /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsxRuntime.jsx(
12304
12390
  BaseCreatableSelect,
@@ -12317,7 +12403,7 @@ const CreatableSelect = ({
12317
12403
  formatCreateLabel: formatCreateLabel2,
12318
12404
  menuPortalTarget: document.body,
12319
12405
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
12320
- components: { DropdownIndicator },
12406
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
12321
12407
  isLoading,
12322
12408
  isDisabled: disabled,
12323
12409
  isClearable,
@@ -12502,7 +12588,7 @@ function UploadTransactionsUploadCsvStep({ selectedAccount, onSelectAccount, sel
12502
12588
  const createCustomAccountTransactions = post(
12503
12589
  ({ businessId, customAccountId }) => `/v1/businesses/${businessId}/custom-accounts/${customAccountId}/transactions`
12504
12590
  );
12505
- function buildKey$M({
12591
+ function buildKey$Q({
12506
12592
  access_token: accessToken,
12507
12593
  apiUrl,
12508
12594
  businessId
@@ -12521,7 +12607,7 @@ function useCreateCustomAccountTransactions() {
12521
12607
  const { data } = useAuth();
12522
12608
  const { businessId } = useLayerContext();
12523
12609
  return useSWRMutation(
12524
- () => buildKey$M(__spreadProps(__spreadValues({}, data), {
12610
+ () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
12525
12611
  businessId
12526
12612
  })),
12527
12613
  ({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
@@ -13021,8 +13107,8 @@ const BulkActionsModule = ({ slots }) => {
13021
13107
  /* @__PURE__ */ jsxRuntime.jsx(slots.BulkActions, {})
13022
13108
  ] });
13023
13109
  };
13024
- const DownloadCloud = (_fb) => {
13025
- var _gb = _fb, { size = 18 } = _gb, props = __objRest(_gb, ["size"]);
13110
+ const DownloadCloud = (_jb) => {
13111
+ var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
13026
13112
  return /* @__PURE__ */ jsxRuntime.jsxs(
13027
13113
  "svg",
13028
13114
  __spreadProps(__spreadValues({
@@ -13274,8 +13360,8 @@ function MonthCalendar({
13274
13360
  const POPOVER_CLASS_NAME = "Layer__Popover";
13275
13361
  const POPOVER_CLASS_NAMES = `Layer__Portal ${POPOVER_CLASS_NAME}`;
13276
13362
  const Popover = react.forwardRef(
13277
- function Popover2(_hb, ref) {
13278
- var _ib = _hb, { flexInline = false } = _ib, restProps = __objRest(_ib, ["flexInline"]);
13363
+ function Popover2(_lb, ref) {
13364
+ var _mb = _lb, { flexInline = false } = _mb, restProps = __objRest(_mb, ["flexInline"]);
13279
13365
  const dataProperties = toDataProperties({ "flex-inline": flexInline });
13280
13366
  return /* @__PURE__ */ jsxRuntime.jsx(
13281
13367
  reactAriaComponents.Popover,
@@ -13672,8 +13758,8 @@ const BankTransactionsHeader = ({
13672
13758
  }
13673
13759
  );
13674
13760
  };
13675
- const Inbox = (_jb) => {
13676
- var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
13761
+ const Inbox = (_nb) => {
13762
+ var _ob = _nb, { size = 18 } = _ob, props = __objRest(_ob, ["size"]);
13677
13763
  return /* @__PURE__ */ jsxRuntime.jsxs(
13678
13764
  "svg",
13679
13765
  __spreadProps(__spreadValues({
@@ -13757,7 +13843,7 @@ function BankTransactionsTableEmptyStates({
13757
13843
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "Layer__table-state-container", children: StateComponent });
13758
13844
  }
13759
13845
  const REJECT_CATEGORIZATION_RULE_SUGGESTION_TAG = "#reject-categorization-rule-suggestion";
13760
- function buildKey$L({
13846
+ function buildKey$P({
13761
13847
  access_token: accessToken,
13762
13848
  apiUrl,
13763
13849
  businessId
@@ -13778,7 +13864,7 @@ function useRejectCategorizationRulesUpdateSuggestion() {
13778
13864
  const { data: auth } = useAuth();
13779
13865
  const { businessId } = useLayerContext();
13780
13866
  const mutationResponse = useSWRMutation(
13781
- () => buildKey$L({
13867
+ () => buildKey$P({
13782
13868
  access_token: auth == null ? void 0 : auth.access_token,
13783
13869
  apiUrl: auth == null ? void 0 : auth.apiUrl,
13784
13870
  businessId
@@ -13997,7 +14083,7 @@ function useCategorizationRulesGlobalCacheActions() {
13997
14083
  return { patchCategorizationRuleByKey, forceReloadCategorizationRules };
13998
14084
  }
13999
14085
  const CREATE_CATEGORIZATION_RULE_TAG = "#create-categorization-rule";
14000
- function buildKey$K({
14086
+ function buildKey$O({
14001
14087
  access_token: accessToken,
14002
14088
  apiUrl,
14003
14089
  businessId
@@ -14025,7 +14111,7 @@ function useCreateCategorizationRule() {
14025
14111
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
14026
14112
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
14027
14113
  const mutationResponse = useSWRMutation(
14028
- () => buildKey$K({
14114
+ () => buildKey$O({
14029
14115
  access_token: auth == null ? void 0 : auth.access_token,
14030
14116
  apiUrl: auth == null ? void 0 : auth.apiUrl,
14031
14117
  businessId
@@ -14155,8 +14241,8 @@ function asMutable(a) {
14155
14241
  const CSS_PREFIX$1 = "Layer__UI__Table";
14156
14242
  const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
14157
14243
  const Table$1 = react.forwardRef(
14158
- (_lb, ref) => {
14159
- var _mb = _lb, { children, className } = _mb, restProps = __objRest(_mb, ["children", "className"]);
14244
+ (_pb, ref) => {
14245
+ var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
14160
14246
  return /* @__PURE__ */ jsxRuntime.jsx(
14161
14247
  reactAriaComponents.Table,
14162
14248
  __spreadProps(__spreadValues({
@@ -14169,8 +14255,8 @@ const Table$1 = react.forwardRef(
14169
14255
  }
14170
14256
  );
14171
14257
  Table$1.displayName = "Table";
14172
- const TableHeaderInner = (_nb, ref) => {
14173
- var _ob = _nb, { children, className, hideHeader } = _ob, restProps = __objRest(_ob, ["children", "className", "hideHeader"]);
14258
+ const TableHeaderInner = (_rb, ref) => {
14259
+ var _sb = _rb, { children, className, hideHeader } = _sb, restProps = __objRest(_sb, ["children", "className", "hideHeader"]);
14174
14260
  return /* @__PURE__ */ jsxRuntime.jsx(
14175
14261
  reactAriaComponents.TableHeader,
14176
14262
  __spreadProps(__spreadValues({
@@ -14183,8 +14269,8 @@ const TableHeaderInner = (_nb, ref) => {
14183
14269
  };
14184
14270
  const TableHeader = react.forwardRef(TableHeaderInner);
14185
14271
  TableHeader.displayName = "TableHeader";
14186
- const TableBodyInner = (_pb, ref) => {
14187
- var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
14272
+ const TableBodyInner = (_tb, ref) => {
14273
+ var _ub = _tb, { children, className } = _ub, restProps = __objRest(_ub, ["children", "className"]);
14188
14274
  return /* @__PURE__ */ jsxRuntime.jsx(
14189
14275
  reactAriaComponents.TableBody,
14190
14276
  __spreadProps(__spreadValues({
@@ -14197,8 +14283,8 @@ const TableBodyInner = (_pb, ref) => {
14197
14283
  };
14198
14284
  const TableBody$1 = react.forwardRef(TableBodyInner);
14199
14285
  TableBody$1.displayName = "TableBody";
14200
- const RowInner = (_rb, ref) => {
14201
- var _sb = _rb, { children, className, depth = 0 } = _sb, restProps = __objRest(_sb, ["children", "className", "depth"]);
14286
+ const RowInner = (_vb, ref) => {
14287
+ var _wb = _vb, { children, className, depth = 0 } = _wb, restProps = __objRest(_wb, ["children", "className", "depth"]);
14202
14288
  const dataProperties = toDataProperties({ depth });
14203
14289
  return /* @__PURE__ */ jsxRuntime.jsx(
14204
14290
  reactAriaComponents.Row,
@@ -14213,8 +14299,8 @@ const RowInner = (_rb, ref) => {
14213
14299
  const Row = react.forwardRef(RowInner);
14214
14300
  Row.displayName = "Row";
14215
14301
  const Column = react.forwardRef(
14216
- (_tb, ref) => {
14217
- var _ub = _tb, { children, className, textAlign = "left" } = _ub, restProps = __objRest(_ub, ["children", "className", "textAlign"]);
14302
+ (_xb, ref) => {
14303
+ var _yb = _xb, { children, className, textAlign = "left" } = _yb, restProps = __objRest(_yb, ["children", "className", "textAlign"]);
14218
14304
  const dataProperties = toDataProperties({ "text-align": textAlign });
14219
14305
  return /* @__PURE__ */ jsxRuntime.jsx(
14220
14306
  reactAriaComponents.Column,
@@ -14229,8 +14315,8 @@ const Column = react.forwardRef(
14229
14315
  );
14230
14316
  Column.displayName = "Column";
14231
14317
  const Cell = react.forwardRef(
14232
- (_vb, ref) => {
14233
- var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
14318
+ (_zb, ref) => {
14319
+ var _Ab = _zb, { children, className } = _Ab, restProps = __objRest(_Ab, ["children", "className"]);
14234
14320
  return /* @__PURE__ */ jsxRuntime.jsx(
14235
14321
  reactAriaComponents.Cell,
14236
14322
  __spreadProps(__spreadValues({
@@ -14255,7 +14341,7 @@ const DEFAULT_NUM_ROWS = 15;
14255
14341
  const HEADER_HEIGHT = 52;
14256
14342
  const DEFAULT_TABLE_HEIGHT = DEFAULT_ROW_HEIGHT * DEFAULT_NUM_ROWS + HEADER_HEIGHT - 2;
14257
14343
  const CSS_PREFIX = "Layer__UI__VirtualizedTable";
14258
- const EMPTY_ARRAY$3 = [];
14344
+ const EMPTY_ARRAY$2 = [];
14259
14345
  const VirtualizedDataTable = ({
14260
14346
  columnConfig,
14261
14347
  data,
@@ -14280,7 +14366,7 @@ const VirtualizedDataTable = ({
14280
14366
  }, [data, height, rowHeight, shrinkHeightToFitRows]);
14281
14367
  const columnHelper = reactTable.createColumnHelper();
14282
14368
  const columns = Object.values(columnConfig);
14283
- const tableData = data != null ? data : EMPTY_ARRAY$3;
14369
+ const tableData = data != null ? data : EMPTY_ARRAY$2;
14284
14370
  const columnDefs = columns.map((col) => {
14285
14371
  return columnHelper.display({
14286
14372
  id: col.id,
@@ -14571,7 +14657,7 @@ const useSaveBankTransactionRow = () => {
14571
14657
  return;
14572
14658
  }
14573
14659
  if (isSuggestedMatchAsOption(selectedCategory)) {
14574
- return matchBankTransaction2(bankTransaction.id, selectedCategory.original.id);
14660
+ return matchBankTransaction2(bankTransaction, selectedCategory.original.id);
14575
14661
  }
14576
14662
  if (isSplitAsOption(selectedCategory)) {
14577
14663
  const splitCategorizationRequest = buildCategorizeBankTransactionPayloadForSplit(selectedCategory.original);
@@ -14607,8 +14693,8 @@ function useDelayedVisibility({
14607
14693
  );
14608
14694
  return { isVisible };
14609
14695
  }
14610
- const File = (_xb) => {
14611
- var _yb = _xb, { size = 12 } = _yb, props = __objRest(_yb, ["size"]);
14696
+ const File = (_Bb) => {
14697
+ var _Cb = _Bb, { size = 12 } = _Cb, props = __objRest(_Cb, ["size"]);
14612
14698
  return /* @__PURE__ */ jsxRuntime.jsxs(
14613
14699
  "svg",
14614
14700
  __spreadProps(__spreadValues({
@@ -14691,14 +14777,14 @@ const variants = {
14691
14777
  }
14692
14778
  }
14693
14779
  };
14694
- const AnimatedPresenceDiv = (_zb) => {
14695
- var _Ab = _zb, {
14780
+ const AnimatedPresenceDiv = (_Db) => {
14781
+ var _Eb = _Db, {
14696
14782
  children,
14697
14783
  variant,
14698
14784
  isOpen,
14699
14785
  slotProps = { AnimatePresence: { initial: false } },
14700
14786
  key
14701
- } = _Ab, props = __objRest(_Ab, [
14787
+ } = _Eb, props = __objRest(_Eb, [
14702
14788
  "children",
14703
14789
  "variant",
14704
14790
  "isOpen",
@@ -14773,7 +14859,7 @@ const getBookkeepingPeriods = get$1(({ businessId }) => {
14773
14859
  return `/v1/businesses/${businessId}/bookkeeping/periods`;
14774
14860
  });
14775
14861
  const BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
14776
- function buildKey$J({
14862
+ function buildKey$N({
14777
14863
  access_token: accessToken,
14778
14864
  apiUrl,
14779
14865
  businessId,
@@ -14794,7 +14880,7 @@ function useBookkeepingPeriods() {
14794
14880
  const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
14795
14881
  const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
14796
14882
  const swrResponse = useSWR(
14797
- () => buildKey$J(__spreadProps(__spreadValues({}, auth), {
14883
+ () => buildKey$N(__spreadProps(__spreadValues({}, auth), {
14798
14884
  businessId,
14799
14885
  isActiveOrPaused
14800
14886
  })),
@@ -14818,8 +14904,8 @@ function useBookkeepingPeriods() {
14818
14904
  }
14819
14905
  });
14820
14906
  }
14821
- const Clock = (_Bb) => {
14822
- var _Cb = _Bb, { size = 18 } = _Cb, props = __objRest(_Cb, ["size"]);
14907
+ const Clock = (_Fb) => {
14908
+ var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
14823
14909
  return /* @__PURE__ */ jsxRuntime.jsxs(
14824
14910
  "svg",
14825
14911
  __spreadProps(__spreadValues({
@@ -15145,8 +15231,8 @@ const useSplitsForm = ({
15145
15231
  saveLocalSplitsToCategoryStore
15146
15232
  };
15147
15233
  };
15148
- const ScissorsFullOpen = (_Db) => {
15149
- var _Eb = _Db, { size = 12 } = _Eb, props = __objRest(_Eb, ["size"]);
15234
+ const ScissorsFullOpen = (_Hb) => {
15235
+ var _Ib = _Hb, { size = 12 } = _Ib, props = __objRest(_Ib, ["size"]);
15150
15236
  return /* @__PURE__ */ jsxRuntime.jsx(
15151
15237
  "svg",
15152
15238
  __spreadProps(__spreadValues({
@@ -15211,8 +15297,8 @@ const ScissorsFullOpen = (_Db) => {
15211
15297
  })
15212
15298
  );
15213
15299
  };
15214
- const Trash = (_Fb) => {
15215
- var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
15300
+ const Trash = (_Jb) => {
15301
+ var _Kb = _Jb, { size = 18 } = _Kb, props = __objRest(_Kb, ["size"]);
15216
15302
  return /* @__PURE__ */ jsxRuntime.jsxs(
15217
15303
  "svg",
15218
15304
  __spreadProps(__spreadValues({
@@ -15274,7 +15360,7 @@ const useReceipts = ({
15274
15360
  const { businessId } = useLayerContext();
15275
15361
  const { apiUrl } = useEnvironment();
15276
15362
  const { data: auth } = useAuth();
15277
- const { updateOneLocal: updateBankTransaction } = useBankTransactionsContext();
15363
+ const { updateLocalBankTransactions } = useBankTransactionsContext();
15278
15364
  const [receiptUrls, setReceiptUrls] = react.useState([]);
15279
15365
  react.useEffect(() => {
15280
15366
  if (isActive && receiptUrls.length === 0 && hasReceipts(bankTransaction)) {
@@ -15330,10 +15416,10 @@ const useReceipts = ({
15330
15416
  documentType: "RECEIPT"
15331
15417
  });
15332
15418
  yield fetchDocuments();
15333
- if (updateBankTransaction && ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.id) && (bankTransaction == null ? void 0 : bankTransaction.document_ids) && bankTransaction.document_ids.length === 0) {
15334
- updateBankTransaction(__spreadProps(__spreadValues({}, bankTransaction), {
15419
+ if (((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.id) && (bankTransaction == null ? void 0 : bankTransaction.document_ids) && bankTransaction.document_ids.length === 0) {
15420
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, bankTransaction), {
15335
15421
  document_ids: [result.data.id]
15336
- }));
15422
+ })]);
15337
15423
  }
15338
15424
  } catch (_err) {
15339
15425
  const newReceiptUrls = receipts.map((url) => {
@@ -15407,8 +15493,8 @@ const ReceiptsProvider = ({
15407
15493
  const contextData = useReceipts({ bankTransaction, isActive });
15408
15494
  return /* @__PURE__ */ jsxRuntime.jsx(ReceiptsContext.Provider, { value: contextData, children });
15409
15495
  };
15410
- const Eye = (_Hb) => {
15411
- var _Ib = _Hb, { size = 18 } = _Ib, props = __objRest(_Ib, ["size"]);
15496
+ const Eye = (_Lb) => {
15497
+ var _Mb = _Lb, { size = 18 } = _Mb, props = __objRest(_Mb, ["size"]);
15412
15498
  return /* @__PURE__ */ jsxRuntime.jsx(
15413
15499
  "svg",
15414
15500
  __spreadProps(__spreadValues({
@@ -15544,11 +15630,11 @@ const FileThumb = ({
15544
15630
  }
15545
15631
  );
15546
15632
  };
15547
- const TextButton = (_Jb) => {
15548
- var _Kb = _Jb, {
15633
+ const TextButton = (_Nb) => {
15634
+ var _Ob = _Nb, {
15549
15635
  className,
15550
15636
  children
15551
- } = _Kb, props = __objRest(_Kb, [
15637
+ } = _Ob, props = __objRest(_Ob, [
15552
15638
  "className",
15553
15639
  "children"
15554
15640
  ]);
@@ -15632,8 +15718,8 @@ const openReceiptInNewTab = (url, index2) => (e) => {
15632
15718
  `);
15633
15719
  }
15634
15720
  };
15635
- const BankTransactionReceiptsWithProvider = react.forwardRef((_Lb, ref) => {
15636
- var _Mb = _Lb, { bankTransaction, isActive } = _Mb, props = __objRest(_Mb, ["bankTransaction", "isActive"]);
15721
+ const BankTransactionReceiptsWithProvider = react.forwardRef((_Pb, ref) => {
15722
+ var _Qb = _Pb, { bankTransaction, isActive } = _Qb, props = __objRest(_Qb, ["bankTransaction", "isActive"]);
15637
15723
  return /* @__PURE__ */ jsxRuntime.jsx(ReceiptsProvider, { bankTransaction, isActive, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionReceipts, __spreadProps(__spreadValues({}, props), { ref })) });
15638
15724
  });
15639
15725
  BankTransactionReceiptsWithProvider.displayName = "BankTransactionReceiptsWithProvider";
@@ -15800,8 +15886,8 @@ const transformCurrencyValue = (rawValue) => {
15800
15886
  }
15801
15887
  return cleaned;
15802
15888
  };
15803
- const AmountInput = (_Nb) => {
15804
- var _Ob = _Nb, {
15889
+ const AmountInput = (_Rb) => {
15890
+ var _Sb = _Rb, {
15805
15891
  onChange,
15806
15892
  className,
15807
15893
  leftText,
@@ -15809,7 +15895,7 @@ const AmountInput = (_Nb) => {
15809
15895
  isInvalid,
15810
15896
  badge,
15811
15897
  placeholder = "$0.00"
15812
- } = _Ob, props = __objRest(_Ob, [
15898
+ } = _Sb, props = __objRest(_Sb, [
15813
15899
  "onChange",
15814
15900
  "className",
15815
15901
  "leftText",
@@ -16129,7 +16215,7 @@ const ToggleOption = ({
16129
16215
  ] });
16130
16216
  };
16131
16217
  const GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
16132
- function buildKey$I({
16218
+ function buildKey$M({
16133
16219
  access_token: accessToken,
16134
16220
  apiUrl,
16135
16221
  businessId,
@@ -16149,7 +16235,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
16149
16235
  const { data: auth } = useAuth();
16150
16236
  const { businessId } = useLayerContext();
16151
16237
  return useSWR(
16152
- () => buildKey$I(__spreadProps(__spreadValues({}, auth), {
16238
+ () => buildKey$M(__spreadProps(__spreadValues({}, auth), {
16153
16239
  businessId,
16154
16240
  bankTransactionId
16155
16241
  })),
@@ -16179,7 +16265,7 @@ class UpdateBankTransactionMetadataSWRResponse {
16179
16265
  return this.swrResponse.error !== void 0;
16180
16266
  }
16181
16267
  }
16182
- function buildKey$H({
16268
+ function buildKey$L({
16183
16269
  access_token: accessToken,
16184
16270
  apiUrl,
16185
16271
  businessId,
@@ -16200,7 +16286,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
16200
16286
  const { businessId } = useLayerContext();
16201
16287
  const { mutate } = useSWR.useSWRConfig();
16202
16288
  const rawMutationResponse = useSWRMutation(
16203
- () => buildKey$H({
16289
+ () => buildKey$L({
16204
16290
  access_token: auth == null ? void 0 : auth.access_token,
16205
16291
  apiUrl: auth == null ? void 0 : auth.apiUrl,
16206
16292
  businessId,
@@ -16283,12 +16369,12 @@ const useBankTransactionMemo = ({ bankTransactionId }) => {
16283
16369
  isSaved
16284
16370
  }), [form, isErrorUpdatingMemo, isUpdatingMemo, isSaved]);
16285
16371
  };
16286
- const Textarea = (_Pb) => {
16287
- var _Qb = _Pb, {
16372
+ const Textarea = (_Tb) => {
16373
+ var _Ub = _Tb, {
16288
16374
  className,
16289
16375
  isInvalid,
16290
16376
  errorMessage
16291
- } = _Qb, props = __objRest(_Qb, [
16377
+ } = _Ub, props = __objRest(_Ub, [
16292
16378
  "className",
16293
16379
  "isInvalid",
16294
16380
  "errorMessage"
@@ -16381,7 +16467,7 @@ function useMinMutatingMutation({
16381
16467
  });
16382
16468
  }
16383
16469
  const SET_METADATA_ON_BANK_TRANSACTION_TAG_KEY = "#set-metadata-on-bank-transaction";
16384
- function buildKey$G({
16470
+ function buildKey$K({
16385
16471
  access_token: accessToken,
16386
16472
  apiUrl,
16387
16473
  businessId,
@@ -16407,7 +16493,7 @@ function useSetMetadataOnBankTransaction({
16407
16493
  const { data } = useAuth();
16408
16494
  const { businessId } = useLayerContext();
16409
16495
  const mutationResponse = useSWRMutation(
16410
- () => buildKey$G(__spreadProps(__spreadValues({}, data), {
16496
+ () => buildKey$K(__spreadProps(__spreadValues({}, data), {
16411
16497
  businessId,
16412
16498
  bankTransactionId
16413
16499
  })),
@@ -16990,7 +17076,7 @@ function BankTransactionCustomerVendorVisibilityProvider({
16990
17076
  }
16991
17077
  const REMOVE_TAG_FROM_BANK_TRANSACTION_TAG_KEY = "#remove-tag-from-bank-transaction";
16992
17078
  const removeTagFromBankTransaction = del(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
16993
- function buildKey$F({
17079
+ function buildKey$J({
16994
17080
  access_token: accessToken,
16995
17081
  apiUrl,
16996
17082
  businessId,
@@ -17010,7 +17096,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
17010
17096
  const { data } = useAuth();
17011
17097
  const { businessId } = useLayerContext();
17012
17098
  const mutationResponse = useSWRMutation(
17013
- () => buildKey$F(__spreadProps(__spreadValues({}, data), {
17099
+ () => buildKey$J(__spreadProps(__spreadValues({}, data), {
17014
17100
  businessId,
17015
17101
  bankTransactionId
17016
17102
  })),
@@ -17069,7 +17155,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
17069
17155
  }
17070
17156
  const TAG_BANK_TRANSACTION_TAG_KEY = "#tag-bank-transaction";
17071
17157
  const tagBankTransaction = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
17072
- function buildKey$E({
17158
+ function buildKey$I({
17073
17159
  access_token: accessToken,
17074
17160
  apiUrl,
17075
17161
  businessId,
@@ -17089,7 +17175,7 @@ function useTagBankTransaction({ bankTransactionId }) {
17089
17175
  const { data } = useAuth();
17090
17176
  const { businessId } = useLayerContext();
17091
17177
  const mutationResponse = useSWRMutation(
17092
- () => buildKey$E(__spreadProps(__spreadValues({}, data), {
17178
+ () => buildKey$I(__spreadProps(__spreadValues({}, data), {
17093
17179
  businessId,
17094
17180
  bankTransactionId
17095
17181
  })),
@@ -17204,7 +17290,7 @@ const FallbackWithSkeletonLoader = ({
17204
17290
  return children;
17205
17291
  };
17206
17292
  const TAG_DIMENSION_BY_KEY_TAG_KEY = "#tag-dimension-by-key";
17207
- function buildKey$D({
17293
+ function buildKey$H({
17208
17294
  access_token: accessToken,
17209
17295
  apiUrl,
17210
17296
  businessId,
@@ -17248,7 +17334,7 @@ function useTagDimensionByKey({ isEnabled = true, dimensionKey }) {
17248
17334
  const { apiUrl } = useEnvironment();
17249
17335
  const { businessId } = useLayerContext();
17250
17336
  const swrResponse = useSWR(
17251
- () => buildKey$D(__spreadProps(__spreadValues({}, auth), {
17337
+ () => buildKey$H(__spreadProps(__spreadValues({}, auth), {
17252
17338
  apiUrl,
17253
17339
  isEnabled,
17254
17340
  businessId,
@@ -17591,7 +17677,7 @@ const ExpandedBankTransactionRow = react.forwardRef(
17591
17677
  if (!foundMatch) {
17592
17678
  return;
17593
17679
  }
17594
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id);
17680
+ yield matchBankTransaction2(bankTransaction, foundMatch.id);
17595
17681
  deselect(bankTransaction.id);
17596
17682
  close2();
17597
17683
  });
@@ -17871,7 +17957,8 @@ const BankTransactionRow = ({
17871
17957
  const { setTransactionCategory } = useBankTransactionsCategoryActions();
17872
17958
  const { selectedCategory } = useGetBankTransactionCategory(bankTransaction.id);
17873
17959
  const { saveBankTransactionRow } = useSaveBankTransactionRow();
17874
- const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
17960
+ const isBeingRemoved = bankTransaction.recently_categorized && shouldHideAfterCategorize();
17961
+ const displayAsCategorized = isBeingRemoved ? false : categorized;
17875
17962
  react.useEffect(() => {
17876
17963
  if (bankTransaction.error) {
17877
17964
  setShowRetry(true);
@@ -17905,7 +17992,7 @@ const BankTransactionRow = ({
17905
17992
  const openClassName = open ? `${className}--expanded` : "";
17906
17993
  const rowClassName = classNames(
17907
17994
  className,
17908
- bankTransaction.recently_categorized && editable && shouldHideAfterCategorize() ? "Layer__bank-transaction-row--removing" : "",
17995
+ isBeingRemoved && editable ? "Layer__bank-transaction-row--removing" : "",
17909
17996
  open ? openClassName : "",
17910
17997
  initialLoad ? "initial-load" : "",
17911
17998
  isVisible ? "show" : ""
@@ -18078,7 +18165,7 @@ const BankTransactionRow = ({
18078
18165
  children: "Retry"
18079
18166
  }
18080
18167
  ),
18081
- !displayAsCategorized && categorizationEnabled && !showRetry && /* @__PURE__ */ jsxRuntime.jsx(
18168
+ !displayAsCategorized && categorizationEnabled && !showRetry && !isBeingRemoved && /* @__PURE__ */ jsxRuntime.jsx(
18082
18169
  SubmitButton,
18083
18170
  {
18084
18171
  onClick: () => {
@@ -18094,8 +18181,8 @@ const BankTransactionRow = ({
18094
18181
  children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
18095
18182
  }
18096
18183
  ),
18097
- !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18098
- /* @__PURE__ */ jsxRuntime.jsx(
18184
+ !categorizationEnabled && !displayAsCategorized && !isBeingRemoved && /* @__PURE__ */ jsxRuntime.jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsProcessingInfo, {}) }),
18185
+ !isBeingRemoved && /* @__PURE__ */ jsxRuntime.jsx(
18099
18186
  IconButton,
18100
18187
  {
18101
18188
  onClick: toggleOpen,
@@ -18432,26 +18519,6 @@ const BankTransactionsList = ({
18432
18519
  ) })
18433
18520
  ] });
18434
18521
  };
18435
- const SWITCH_CLASS_NAME = "Layer__Switch";
18436
- const Switch = react.forwardRef((_Rb, ref) => {
18437
- var _Sb = _Rb, {
18438
- children
18439
- } = _Sb, props = __objRest(_Sb, [
18440
- "children"
18441
- ]);
18442
- return /* @__PURE__ */ jsxRuntime.jsx(
18443
- reactAriaComponents.Switch,
18444
- __spreadProps(__spreadValues({}, props), {
18445
- className: SWITCH_CLASS_NAME,
18446
- ref,
18447
- children: withRenderProp(children, (node) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18448
- /* @__PURE__ */ jsxRuntime.jsx("div", { slot: "indicator" }),
18449
- node
18450
- ] }))
18451
- })
18452
- );
18453
- });
18454
- Switch.displayName = "Switch";
18455
18522
  const BankTransactionsMobileBulkActionsHeader = ({
18456
18523
  bankTransactions,
18457
18524
  bulkActionsEnabled,
@@ -18575,8 +18642,8 @@ const BankTransactionsMobileListItemCheckbox = ({
18575
18642
  }
18576
18643
  ) });
18577
18644
  };
18578
- const Paperclip = (_Tb) => {
18579
- var _Ub = _Tb, { size = 20 } = _Ub, props = __objRest(_Ub, ["size"]);
18645
+ const Paperclip = (_Vb) => {
18646
+ var _Wb = _Vb, { size = 20 } = _Wb, props = __objRest(_Wb, ["size"]);
18580
18647
  return /* @__PURE__ */ jsxRuntime.jsx(
18581
18648
  "svg",
18582
18649
  __spreadProps(__spreadValues({
@@ -19024,7 +19091,7 @@ const BankTransactionsMobileListMatchForm = ({
19024
19091
  if (!foundMatch) {
19025
19092
  return;
19026
19093
  }
19027
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id, true);
19094
+ yield matchBankTransaction2(bankTransaction, foundMatch.id, true);
19028
19095
  });
19029
19096
  const save = () => {
19030
19097
  var _a2;
@@ -19833,8 +19900,8 @@ const BankTransactionsTable = ({
19833
19900
  }
19834
19901
  );
19835
19902
  };
19836
- const BackArrow = (_Vb) => {
19837
- var _Wb = _Vb, { size = 18 } = _Wb, props = __objRest(_Wb, ["size"]);
19903
+ const BackArrow = (_Xb) => {
19904
+ var _Yb = _Xb, { size = 18 } = _Yb, props = __objRest(_Yb, ["size"]);
19838
19905
  return /* @__PURE__ */ jsxRuntime.jsx(
19839
19906
  "svg",
19840
19907
  __spreadProps(__spreadValues({
@@ -19867,7 +19934,7 @@ const BaseDetailView = ({ name, onGoBack, slots, children, borderless = false })
19867
19934
  ] });
19868
19935
  };
19869
19936
  const ARCHIVE_CATEGORIZATION_RULE_TAG = "#archive-categorization-rule";
19870
- function buildKey$C({
19937
+ function buildKey$G({
19871
19938
  access_token: accessToken,
19872
19939
  apiUrl,
19873
19940
  businessId
@@ -19892,7 +19959,7 @@ function useArchiveCategorizationRule() {
19892
19959
  const { businessId } = useLayerContext();
19893
19960
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
19894
19961
  const mutationResponse = useSWRMutation(
19895
- () => buildKey$C({
19962
+ () => buildKey$G({
19896
19963
  access_token: auth == null ? void 0 : auth.access_token,
19897
19964
  apiUrl: auth == null ? void 0 : auth.apiUrl,
19898
19965
  businessId
@@ -20002,8 +20069,8 @@ const usePaginationRange = ({
20002
20069
  }, [totalCount, pageSize, siblingCount, currentPage]);
20003
20070
  return paginationRange;
20004
20071
  };
20005
- const ChevronLeft = (_Xb) => {
20006
- var props = __objRest(_Xb, []);
20072
+ const ChevronLeft = (_Zb) => {
20073
+ var props = __objRest(_Zb, []);
20007
20074
  return /* @__PURE__ */ jsxRuntime.jsx(
20008
20075
  "svg",
20009
20076
  __spreadProps(__spreadValues({
@@ -20025,8 +20092,8 @@ const ChevronLeft = (_Xb) => {
20025
20092
  })
20026
20093
  );
20027
20094
  };
20028
- const PaginationButton = (_Yb) => {
20029
- var _Zb = _Yb, { children, isSelected } = _Zb, buttonProps = __objRest(_Zb, ["children", "isSelected"]);
20095
+ const PaginationButton = (__b) => {
20096
+ var _$b = __b, { children, isSelected } = _$b, buttonProps = __objRest(_$b, ["children", "isSelected"]);
20030
20097
  return /* @__PURE__ */ jsxRuntime.jsx(
20031
20098
  Button,
20032
20099
  __spreadProps(__spreadValues({
@@ -20108,7 +20175,6 @@ const Pagination = ({
20108
20175
  ) }, "page-next")
20109
20176
  ] }) }) });
20110
20177
  };
20111
- const EMPTY_ARRAY$2 = [];
20112
20178
  function PaginatedTable({
20113
20179
  data,
20114
20180
  isLoading,
@@ -20119,7 +20185,8 @@ function PaginatedTable({
20119
20185
  paginationProps,
20120
20186
  slots
20121
20187
  }) {
20122
- const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage } = paginationProps;
20188
+ var _a;
20189
+ const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
20123
20190
  const [pagination, setPagination] = react.useState({ pageIndex: initialPage, pageSize });
20124
20191
  const columnHelper = reactTable.createColumnHelper();
20125
20192
  const columns = Object.values(columnConfig);
@@ -20131,7 +20198,7 @@ function PaginatedTable({
20131
20198
  });
20132
20199
  });
20133
20200
  const table2 = reactTable.useReactTable({
20134
- data: data != null ? data : EMPTY_ARRAY$2,
20201
+ data: data != null ? data : [],
20135
20202
  columns: columnDefs,
20136
20203
  state: { pagination },
20137
20204
  onPaginationChange: (updaterOrValue) => {
@@ -20141,7 +20208,7 @@ function PaginatedTable({
20141
20208
  },
20142
20209
  getPaginationRowModel: reactTable.getPaginationRowModel(),
20143
20210
  getCoreRowModel: reactTable.getCoreRowModel(),
20144
- autoResetPageIndex: false
20211
+ autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
20145
20212
  });
20146
20213
  const { rows } = table2.getRowModel();
20147
20214
  const rowData = react.useMemo(() => rows.map((r) => r.original), [rows]);
@@ -20387,7 +20454,7 @@ const SuggestedCategorizationRuleUpdatesDrawer = ({
20387
20454
  ] }) });
20388
20455
  };
20389
20456
  const TAG_DIMENSIONS_TAG_KEY = "#tag-dimensions";
20390
- function buildKey$B({
20457
+ function buildKey$F({
20391
20458
  access_token: accessToken,
20392
20459
  apiUrl,
20393
20460
  businessId,
@@ -20430,7 +20497,7 @@ function useTagDimensions({ isEnabled = true } = {}) {
20430
20497
  const { apiUrl } = useEnvironment();
20431
20498
  const { businessId } = useLayerContext();
20432
20499
  const swrResponse = useSWR(
20433
- () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
20500
+ () => buildKey$F(__spreadProps(__spreadValues({}, auth), {
20434
20501
  apiUrl,
20435
20502
  businessId,
20436
20503
  isEnabled
@@ -20455,8 +20522,8 @@ function usePreloadTagDimensions(parameters) {
20455
20522
  useTagDimensions(parameters);
20456
20523
  }
20457
20524
  const COMPONENT_NAME$c = "bank-transactions";
20458
- const BankTransactions = (__b) => {
20459
- var _$b = __b, {
20525
+ const BankTransactions = (_ac) => {
20526
+ var _bc = _ac, {
20460
20527
  onError,
20461
20528
  showTags = false,
20462
20529
  showCustomerVendor = false,
@@ -20464,7 +20531,7 @@ const BankTransactions = (__b) => {
20464
20531
  applyGlobalDateRange = false,
20465
20532
  mode,
20466
20533
  renderInAppLink
20467
- } = _$b, props = __objRest(_$b, [
20534
+ } = _bc, props = __objRest(_bc, [
20468
20535
  "onError",
20469
20536
  "showTags",
20470
20537
  "showCustomerVendor",
@@ -20476,6 +20543,7 @@ const BankTransactions = (__b) => {
20476
20543
  usePreloadTagDimensions({ isEnabled: showTags });
20477
20544
  usePreloadCustomers({ isEnabled: showCustomerVendor });
20478
20545
  usePreloadVendors({ isEnabled: showCustomerVendor });
20546
+ usePreloadCategories();
20479
20547
  return /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { onError, children: /* @__PURE__ */ jsxRuntime.jsx(CategorizationRulesProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BankTransactionsRouteStoreProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
20480
20548
  BankTransactionsProvider,
20481
20549
  {
@@ -20622,7 +20690,7 @@ const BankTransactionsTableView = ({
20622
20690
  const [listView, setListView] = react.useState(false);
20623
20691
  const [containerWidth, setContainerWidth] = react.useState(0);
20624
20692
  const debounceContainerWidth = debounce(setContainerWidth, 500);
20625
- const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
20693
+ const removeTransaction = (bankTransaction) => removeAfterCategorize([bankTransaction.id]);
20626
20694
  const containerRef = useElementSize((_el, _en, size) => {
20627
20695
  if ((size == null ? void 0 : size.height) && (size == null ? void 0 : size.height) >= 90) {
20628
20696
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -20829,8 +20897,8 @@ function QuickbooksContextProvider({ children }) {
20829
20897
  const quickbooksContextData = useQuickbooks();
20830
20898
  return /* @__PURE__ */ jsxRuntime.jsx(QuickbooksContext.Provider, { value: quickbooksContextData, children });
20831
20899
  }
20832
- const Cog = (_ac) => {
20833
- var _bc = _ac, { size = 12 } = _bc, props = __objRest(_bc, ["size"]);
20900
+ const Cog = (_cc) => {
20901
+ var _dc = _cc, { size = 12 } = _dc, props = __objRest(_dc, ["size"]);
20834
20902
  const id = react.useId();
20835
20903
  return /* @__PURE__ */ jsxRuntime.jsxs(
20836
20904
  "svg",
@@ -20851,8 +20919,8 @@ const Cog = (_ac) => {
20851
20919
  })
20852
20920
  );
20853
20921
  };
20854
- const QuickbooksIcon = (_cc) => {
20855
- var _dc = _cc, { size = 24 } = _dc, props = __objRest(_dc, ["size"]);
20922
+ const QuickbooksIcon = (_ec) => {
20923
+ var _fc = _ec, { size = 24 } = _fc, props = __objRest(_fc, ["size"]);
20856
20924
  return /* @__PURE__ */ jsxRuntime.jsxs(
20857
20925
  "svg",
20858
20926
  __spreadProps(__spreadValues({
@@ -21011,8 +21079,8 @@ function IntegrationsQuickbooksUnlinkConfirmationModal({ isOpen, onOpenChange })
21011
21079
  }
21012
21080
  );
21013
21081
  }
21014
- const MoreVertical = (_ec) => {
21015
- var _fc = _ec, { size = 18 } = _fc, props = __objRest(_fc, ["size"]);
21082
+ const MoreVertical = (_gc) => {
21083
+ var _hc = _gc, { size = 18 } = _hc, props = __objRest(_hc, ["size"]);
21016
21084
  return /* @__PURE__ */ jsxRuntime.jsxs(
21017
21085
  "svg",
21018
21086
  __spreadProps(__spreadValues({
@@ -21241,8 +21309,8 @@ const IntegrationsComponent = ({
21241
21309
  (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ jsxRuntime.jsx(IntegrationsContent, {})
21242
21310
  ] });
21243
21311
  };
21244
- const PlusIcon = (_gc) => {
21245
- var _hc = _gc, { size = 14 } = _hc, props = __objRest(_hc, ["size"]);
21312
+ const PlusIcon = (_ic) => {
21313
+ var _jc = _ic, { size = 14 } = _jc, props = __objRest(_jc, ["size"]);
21246
21314
  return /* @__PURE__ */ jsxRuntime.jsxs(
21247
21315
  "svg",
21248
21316
  __spreadProps(__spreadValues({
@@ -21284,8 +21352,8 @@ const PlusIcon = (_gc) => {
21284
21352
  })
21285
21353
  );
21286
21354
  };
21287
- const InstitutionIcon = (_ic) => {
21288
- var _jc = _ic, { size = 18 } = _jc, props = __objRest(_jc, ["size"]);
21355
+ const InstitutionIcon = (_kc) => {
21356
+ var _lc = _kc, { size = 18 } = _lc, props = __objRest(_lc, ["size"]);
21289
21357
  return /* @__PURE__ */ jsxRuntime.jsxs(
21290
21358
  "svg",
21291
21359
  __spreadProps(__spreadValues({
@@ -21645,7 +21713,7 @@ function LinkedAccountToConfirm({
21645
21713
  ) })
21646
21714
  ] });
21647
21715
  }
21648
- function buildKey$A({
21716
+ function buildKey$E({
21649
21717
  access_token: accessToken,
21650
21718
  apiUrl,
21651
21719
  businessId
@@ -21703,7 +21771,7 @@ function useConfirmAndExcludeMultiple({ onSuccess }) {
21703
21771
  const { data: auth } = useAuth();
21704
21772
  const { businessId } = useLayerContext();
21705
21773
  return useSWRMutation(
21706
- () => buildKey$A({
21774
+ () => buildKey$E({
21707
21775
  access_token: auth == null ? void 0 : auth.access_token,
21708
21776
  apiUrl: auth == null ? void 0 : auth.apiUrl,
21709
21777
  businessId
@@ -21903,8 +21971,8 @@ const MenuItem = react.forwardRef(
21903
21971
  );
21904
21972
  const PILL_CLASS_NAME = "Layer__Pill";
21905
21973
  const Pill = react.forwardRef(
21906
- function Pill2(_kc, ref) {
21907
- var _lc = _kc, { children, status } = _lc, restProps = __objRest(_lc, ["children", "status"]);
21974
+ function Pill2(_mc, ref) {
21975
+ var _nc = _mc, { children, status } = _nc, restProps = __objRest(_nc, ["children", "status"]);
21908
21976
  const dataProperties = toDataProperties({ status });
21909
21977
  return /* @__PURE__ */ jsxRuntime.jsx(
21910
21978
  reactAriaComponents.Button,
@@ -22267,8 +22335,8 @@ const LinkedAccountsContent = ({
22267
22335
  };
22268
22336
  const CALENDAR_CLASS_NAME = "Layer__UI__Calendar";
22269
22337
  const Calendar = react.forwardRef(
22270
- function Calendar2(_mc, ref) {
22271
- var _nc = _mc, { className, isReadOnly } = _nc, restProps = __objRest(_nc, ["className", "isReadOnly"]);
22338
+ function Calendar2(_oc, ref) {
22339
+ var _pc = _oc, { className, isReadOnly } = _pc, restProps = __objRest(_pc, ["className", "isReadOnly"]);
22272
22340
  const dataProperties = toDataProperties({ readonly: isReadOnly });
22273
22341
  return /* @__PURE__ */ jsxRuntime.jsx(
22274
22342
  reactAriaComponents.Calendar,
@@ -22282,8 +22350,8 @@ const Calendar = react.forwardRef(
22282
22350
  );
22283
22351
  const CALENDAR_GRID_CLASS_NAME = "Layer__UI__CalendarGrid";
22284
22352
  const CalendarGrid = react.forwardRef(
22285
- function CalendarGrid2(_oc, ref) {
22286
- var _pc = _oc, { className } = _pc, restProps = __objRest(_pc, ["className"]);
22353
+ function CalendarGrid2(_qc, ref) {
22354
+ var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
22287
22355
  return /* @__PURE__ */ jsxRuntime.jsx(
22288
22356
  reactAriaComponents.CalendarGrid,
22289
22357
  __spreadProps(__spreadValues({}, restProps), {
@@ -22295,8 +22363,8 @@ const CalendarGrid = react.forwardRef(
22295
22363
  );
22296
22364
  const CALENDAR_GRID_BODY_CLASS_NAME = "Layer__UI__CalendarGridBody";
22297
22365
  const CalendarGridBody = react.forwardRef(
22298
- function CalendarGridBody2(_qc, ref) {
22299
- var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
22366
+ function CalendarGridBody2(_sc, ref) {
22367
+ var _tc = _sc, { className } = _tc, restProps = __objRest(_tc, ["className"]);
22300
22368
  return /* @__PURE__ */ jsxRuntime.jsx(
22301
22369
  reactAriaComponents.CalendarGridBody,
22302
22370
  __spreadProps(__spreadValues({}, restProps), {
@@ -22308,8 +22376,8 @@ const CalendarGridBody = react.forwardRef(
22308
22376
  );
22309
22377
  const CALENDAR_CELL_CLASS_NAME = "Layer__UI__CalendarCell";
22310
22378
  const CalendarCell = react.forwardRef(
22311
- function CalendarCell2(_sc, ref) {
22312
- var _tc = _sc, { className, size = "sm" } = _tc, restProps = __objRest(_tc, ["className", "size"]);
22379
+ function CalendarCell2(_uc, ref) {
22380
+ var _vc = _uc, { className, size = "sm" } = _vc, restProps = __objRest(_vc, ["className", "size"]);
22313
22381
  const dataProperties = toDataProperties({ size });
22314
22382
  return /* @__PURE__ */ jsxRuntime.jsx(
22315
22383
  reactAriaComponents.CalendarCell,
@@ -22322,8 +22390,8 @@ const CalendarCell = react.forwardRef(
22322
22390
  );
22323
22391
  const CALENDAR_GRID_HEADER_CLASS_NAME = "Layer__UI__CalendarGridHeader";
22324
22392
  const CalendarGridHeader = react.forwardRef(
22325
- function CalendarGridHeader2(_uc, ref) {
22326
- var _vc = _uc, { className } = _vc, restProps = __objRest(_vc, ["className"]);
22393
+ function CalendarGridHeader2(_wc, ref) {
22394
+ var _xc = _wc, { className } = _xc, restProps = __objRest(_xc, ["className"]);
22327
22395
  return /* @__PURE__ */ jsxRuntime.jsx(
22328
22396
  reactAriaComponents.CalendarGridHeader,
22329
22397
  __spreadProps(__spreadValues({}, restProps), {
@@ -22335,8 +22403,8 @@ const CalendarGridHeader = react.forwardRef(
22335
22403
  );
22336
22404
  const CALENDAR_HEADER_CELL_CLASS_NAME = "Layer__UI__CalendarHeaderCell";
22337
22405
  const CalendarHeaderCell = react.forwardRef(
22338
- function CalendarHeaderCell2(_wc, ref) {
22339
- var _xc = _wc, { className, size = "sm" } = _xc, restProps = __objRest(_xc, ["className", "size"]);
22406
+ function CalendarHeaderCell2(_yc, ref) {
22407
+ var _zc = _yc, { className, size = "sm" } = _zc, restProps = __objRest(_zc, ["className", "size"]);
22340
22408
  const dataProperties = toDataProperties({ size });
22341
22409
  return /* @__PURE__ */ jsxRuntime.jsx(
22342
22410
  reactAriaComponents.CalendarHeaderCell,
@@ -22578,7 +22646,7 @@ const AccountFormBox = ({
22578
22646
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${CLASS_NAME$3}__success-banner`, children: /* @__PURE__ */ jsxRuntime.jsx(CheckCircle, { size: 36 }) })
22579
22647
  ] }));
22580
22648
  };
22581
- function buildKey$z({
22649
+ function buildKey$D({
22582
22650
  access_token: accessToken,
22583
22651
  apiUrl,
22584
22652
  businessId,
@@ -22634,7 +22702,7 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
22634
22702
  return errors;
22635
22703
  };
22636
22704
  return useSWRMutation(
22637
- () => buildKey$z({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
22705
+ () => buildKey$D({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
22638
22706
  ({ accessToken, apiUrl, businessId: businessId2, data: data2 }) => Promise.allSettled(
22639
22707
  data2.map(
22640
22708
  ({ accountId, openingDate, openingBalance, isDateInvalid }) => {
@@ -22906,6 +22974,33 @@ const applyShare = (items, total) => {
22906
22974
  });
22907
22975
  });
22908
22976
  };
22977
+ const createPnlLineItemComparator = (filters) => {
22978
+ return (a, b) => {
22979
+ switch (filters == null ? void 0 : filters.sortBy) {
22980
+ case "category":
22981
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
22982
+ return a.displayName.localeCompare(b.displayName);
22983
+ }
22984
+ return b.displayName.localeCompare(a.displayName);
22985
+ case "type":
22986
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
22987
+ return a.type.localeCompare(b.type);
22988
+ }
22989
+ return b.type.localeCompare(a.type);
22990
+ default:
22991
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
22992
+ return a.value - b.value;
22993
+ }
22994
+ return b.value - a.value;
22995
+ }
22996
+ };
22997
+ };
22998
+ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
22999
+ const sorted = items.sort(createPnlLineItemComparator(filter));
23000
+ const total = sorted.reduce((x, { value }) => x + value, 0);
23001
+ const withShare = applyShare(sorted, total);
23002
+ return { items: withShare, total };
23003
+ };
22909
23004
  const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
22910
23005
  var _a;
22911
23006
  const [displayMode, setDisplayMode] = react.useState("month");
@@ -22931,85 +23026,20 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
22931
23026
  })
22932
23027
  }));
22933
23028
  };
22934
- const setFilterTypes = (scope, types) => {
22935
- setFilters(__spreadProps(__spreadValues({}, filters), {
22936
- [scope]: __spreadProps(__spreadValues({}, filters[scope]), {
22937
- types
22938
- })
22939
- }));
22940
- };
22941
23029
  const { filteredDataRevenue, filteredTotalRevenue } = react.useMemo(() => {
22942
- var _a2;
22943
23030
  if (!data) {
22944
23031
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
22945
23032
  }
22946
23033
  const items = collectRevenueItems(data);
22947
- const revenueTypeFilters = (_a2 = filters["revenue"]) == null ? void 0 : _a2.types;
22948
- const filtered = items.map((x) => {
22949
- if (revenueTypeFilters && revenueTypeFilters.length > 0 && !revenueTypeFilters.includes(x.type)) {
22950
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
22951
- }
22952
- return x;
22953
- });
22954
- const sorted = filtered.sort((a, b) => {
22955
- var _a3, _b, _c, _d;
22956
- switch ((_a3 = filters["revenue"]) == null ? void 0 : _a3.sortBy) {
22957
- case "category":
22958
- if (((_b = filters["revenue"]) == null ? void 0 : _b.sortDirection) === "asc") {
22959
- return a.displayName.localeCompare(b.displayName);
22960
- }
22961
- return b.displayName.localeCompare(a.displayName);
22962
- case "type":
22963
- if (((_c = filters["revenue"]) == null ? void 0 : _c.sortDirection) === "asc") {
22964
- return a.type.localeCompare(b.type);
22965
- }
22966
- return b.type.localeCompare(a.type);
22967
- default:
22968
- if (((_d = filters["revenue"]) == null ? void 0 : _d.sortDirection) === "asc") {
22969
- return a.value - b.value;
22970
- }
22971
- return b.value - a.value;
22972
- }
22973
- });
22974
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
22975
- const withShare = applyShare(sorted, total);
23034
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["revenue"]);
22976
23035
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
22977
23036
  }, [data, filters]);
22978
23037
  const { filteredDataExpenses, filteredTotalExpenses } = react.useMemo(() => {
22979
- var _a2;
22980
23038
  if (!data) {
22981
23039
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
22982
23040
  }
22983
23041
  const items = collectExpensesItems(data);
22984
- const expenseTypeFilters = (_a2 = filters["expenses"]) == null ? void 0 : _a2.types;
22985
- const filtered = items.map((x) => {
22986
- if (expenseTypeFilters && expenseTypeFilters.length > 0 && !expenseTypeFilters.includes(x.type)) {
22987
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
22988
- }
22989
- return x;
22990
- });
22991
- const sorted = filtered.sort((a, b) => {
22992
- var _a3, _b, _c, _d;
22993
- switch ((_a3 = filters["expenses"]) == null ? void 0 : _a3.sortBy) {
22994
- case "category":
22995
- if (((_b = filters["expenses"]) == null ? void 0 : _b.sortDirection) === "asc") {
22996
- return a.displayName.localeCompare(b.displayName);
22997
- }
22998
- return b.displayName.localeCompare(a.displayName);
22999
- case "type":
23000
- if (((_c = filters["expenses"]) == null ? void 0 : _c.sortDirection) === "asc") {
23001
- return a.type.localeCompare(b.type);
23002
- }
23003
- return b.type.localeCompare(a.type);
23004
- default:
23005
- if (((_d = filters["expenses"]) == null ? void 0 : _d.sortDirection) === "asc") {
23006
- return a.value - b.value;
23007
- }
23008
- return b.value - a.value;
23009
- }
23010
- });
23011
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
23012
- const withShare = applyShare(sorted, total);
23042
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["expenses"]);
23013
23043
  return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
23014
23044
  }, [data, filters]);
23015
23045
  const refetch = react.useCallback(() => {
@@ -23029,7 +23059,6 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
23029
23059
  setSidebarScope,
23030
23060
  sortBy,
23031
23061
  filters,
23032
- setFilterTypes,
23033
23062
  tagFilter,
23034
23063
  dateRange,
23035
23064
  selectedLineItem,
@@ -23214,8 +23243,6 @@ const ProfitAndLossContext = react.createContext({
23214
23243
  },
23215
23244
  sortBy: () => {
23216
23245
  },
23217
- setFilterTypes: () => {
23218
- },
23219
23246
  filters: {
23220
23247
  expenses: void 0,
23221
23248
  revenue: void 0
@@ -23233,7 +23260,7 @@ const isNotOnlyNoneTag = (compareOptions) => {
23233
23260
  compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
23234
23261
  );
23235
23262
  };
23236
- function buildKey$y({
23263
+ function buildKey$C({
23237
23264
  access_token: accessToken,
23238
23265
  apiUrl,
23239
23266
  businessId,
@@ -23291,7 +23318,7 @@ function useProfitAndLossComparison({
23291
23318
  const { data: auth } = useAuth();
23292
23319
  const periods = preparePeriodsBody(dateRange, comparePeriods, comparisonPeriodMode);
23293
23320
  const tagFilters = prepareFiltersBody(selectedCompareOptions);
23294
- const queryKey = buildKey$y(__spreadProps(__spreadValues({}, auth), {
23321
+ const queryKey = buildKey$C(__spreadProps(__spreadValues({}, auth), {
23295
23322
  businessId,
23296
23323
  periods,
23297
23324
  tagFilters,
@@ -23451,8 +23478,8 @@ const useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
23451
23478
  refetch
23452
23479
  };
23453
23480
  };
23454
- const BarChart2 = (_yc) => {
23455
- var _zc = _yc, { size = 12 } = _zc, props = __objRest(_zc, ["size"]);
23481
+ const BarChart2 = (_Ac) => {
23482
+ var _Bc = _Ac, { size = 12 } = _Bc, props = __objRest(_Bc, ["size"]);
23456
23483
  return /* @__PURE__ */ jsxRuntime.jsxs(
23457
23484
  "svg",
23458
23485
  __spreadProps(__spreadValues({
@@ -24242,11 +24269,11 @@ const ProfitAndLossChart = ({
24242
24269
  isSyncing && !hasNonZeroData ? /* @__PURE__ */ jsxRuntime.jsx(ChartStateCard, {}) : null
24243
24270
  ] });
24244
24271
  };
24245
- const BackButton = (_Ac) => {
24246
- var _Bc = _Ac, {
24272
+ const BackButton = (_Cc) => {
24273
+ var _Dc = _Cc, {
24247
24274
  className,
24248
24275
  textOnly = false
24249
- } = _Bc, props = __objRest(_Bc, [
24276
+ } = _Dc, props = __objRest(_Dc, [
24250
24277
  "className",
24251
24278
  "textOnly"
24252
24279
  ]);
@@ -24294,8 +24321,8 @@ const TASKS_CHARTS_COLORS = {
24294
24321
  done: "#3B9C63",
24295
24322
  pending: "#DFA000"
24296
24323
  };
24297
- const SortArrows = (_Cc) => {
24298
- var _Dc = _Cc, { size = 13 } = _Dc, props = __objRest(_Dc, ["size"]);
24324
+ const SortArrows = (_Ec) => {
24325
+ var _Fc = _Ec, { size = 13 } = _Fc, props = __objRest(_Fc, ["size"]);
24299
24326
  return /* @__PURE__ */ jsxRuntime.jsxs(
24300
24327
  "svg",
24301
24328
  __spreadProps(__spreadValues({
@@ -24362,39 +24389,12 @@ const SortArrows = (_Cc) => {
24362
24389
  );
24363
24390
  };
24364
24391
  const UNCATEGORIZED_TYPES = ["UNCATEGORIZED_INFLOWS", "UNCATEGORIZED_OUTFLOWS"];
24365
- const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
24366
- const typeToColor = {};
24367
- const typeToLastOpacity = {};
24368
- let colorIndex = 0;
24369
- return data.map((obj) => {
24370
- var _a;
24371
- const type = (_a = obj.name) != null ? _a : obj.type;
24372
- if (type === "Uncategorized") {
24373
- return {
24374
- color: "#EEEEF0",
24375
- opacity: 1
24376
- };
24377
- }
24378
- if (!typeToColor[type]) {
24379
- typeToColor[type] = colorList[colorIndex % colorList.length];
24380
- colorIndex++;
24381
- typeToLastOpacity[type] = 1;
24382
- } else {
24383
- typeToLastOpacity[type] -= 0.1;
24384
- }
24385
- const opacity = typeToLastOpacity[type];
24386
- return {
24387
- color: typeToColor[type],
24388
- opacity
24389
- };
24390
- });
24391
- };
24392
24392
  const ValueIcon = ({
24393
24393
  item,
24394
24394
  typeColorMapping,
24395
24395
  idx
24396
24396
  }) => {
24397
- if (item.type === "Uncategorized") {
24397
+ if (isLineItemUncategorized(item)) {
24398
24398
  return /* @__PURE__ */ jsxRuntime.jsxs(
24399
24399
  "svg",
24400
24400
  {
@@ -24461,7 +24461,7 @@ const DetailedTable = ({
24461
24461
  );
24462
24462
  };
24463
24463
  const typeColorMapping = mapTypesToColors(filteredData, chartColorsList);
24464
- const positiveTotal = filteredData.filter((x) => !x.isHidden && x.value > 0).reduce((sum, x) => sum + x.value, 0);
24464
+ const positiveTotal = filteredData.filter((x) => x.value > 0).reduce((sum, x) => sum + x.value, 0);
24465
24465
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "details-container", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "table", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { children: [
24466
24466
  /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
24467
24467
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -24502,16 +24502,16 @@ const DetailedTable = ({
24502
24502
  }
24503
24503
  )
24504
24504
  ] }) }),
24505
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: filteredData.filter((x) => !x.isHidden).map((item, idx) => {
24505
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: filteredData.map((item, idx) => {
24506
24506
  const share = item.value > 0 ? item.value / positiveTotal : 0;
24507
24507
  return /* @__PURE__ */ jsxRuntime.jsxs(
24508
24508
  "tr",
24509
24509
  {
24510
24510
  className: classNames(
24511
24511
  "Layer__profit-and-loss-detailed-table__row",
24512
- hoveredItem && hoveredItem === item.displayName ? "active" : ""
24512
+ hoveredItem && hoveredItem.name === item.name ? "active" : ""
24513
24513
  ),
24514
- onMouseEnter: () => setHoveredItem(item.displayName),
24514
+ onMouseEnter: () => setHoveredItem(item),
24515
24515
  onMouseLeave: () => setHoveredItem(void 0),
24516
24516
  children: [
24517
24517
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "category-col", children: item.displayName }),
@@ -24543,6 +24543,35 @@ const DetailedTable = ({
24543
24543
  }) })
24544
24544
  ] }) }) });
24545
24545
  };
24546
+ const isLineItemUncategorized = (item) => {
24547
+ return UNCATEGORIZED_TYPES.includes(item.name);
24548
+ };
24549
+ const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
24550
+ const nameToColor = {};
24551
+ const nameToLastOpacity = {};
24552
+ let colorIndex = 0;
24553
+ return data.map((lineItem) => {
24554
+ if (isLineItemUncategorized(lineItem)) {
24555
+ return {
24556
+ color: "#EEEEF0",
24557
+ opacity: 1
24558
+ };
24559
+ }
24560
+ const name = lineItem.name;
24561
+ if (!nameToColor[name]) {
24562
+ nameToColor[name] = colorList[colorIndex % colorList.length];
24563
+ colorIndex++;
24564
+ nameToLastOpacity[name] = 1;
24565
+ } else {
24566
+ nameToLastOpacity[name] -= 0.1;
24567
+ }
24568
+ const opacity = nameToLastOpacity[name];
24569
+ return {
24570
+ color: nameToColor[name],
24571
+ opacity
24572
+ };
24573
+ });
24574
+ };
24546
24575
  const DetailedChart = ({
24547
24576
  filteredData,
24548
24577
  filteredTotal,
@@ -24553,18 +24582,9 @@ const DetailedChart = ({
24553
24582
  showDatePicker = true
24554
24583
  }) => {
24555
24584
  const chartData = react.useMemo(
24556
- () => filteredData.map((x) => {
24557
- if (x.isHidden) {
24558
- return __spreadProps(__spreadValues({}, x), {
24559
- name: x.displayName,
24560
- value: 0
24561
- });
24562
- }
24563
- return __spreadProps(__spreadValues({}, x), {
24564
- name: x.displayName,
24565
- value: x.value > 0 ? x.value : 0
24566
- });
24567
- }),
24585
+ () => filteredData.map((x) => __spreadProps(__spreadValues({}, x), {
24586
+ value: x.value > 0 ? x.value : 0
24587
+ })),
24568
24588
  [filteredData]
24569
24589
  );
24570
24590
  const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
@@ -24610,7 +24630,7 @@ const DetailedChart = ({
24610
24630
  {
24611
24631
  data: chartData,
24612
24632
  dataKey: "value",
24613
- nameKey: "name",
24633
+ nameKey: "displayName",
24614
24634
  cx: "50%",
24615
24635
  cy: "50%",
24616
24636
  innerRadius: "91%",
@@ -24623,7 +24643,7 @@ const DetailedChart = ({
24623
24643
  chartData.map((entry, index2) => {
24624
24644
  let fill = typeColorMapping[index2].color;
24625
24645
  let active = true;
24626
- if (hoveredItem && entry.name !== hoveredItem) {
24646
+ if (hoveredItem && entry.name !== hoveredItem.name) {
24627
24647
  active = false;
24628
24648
  fill = void 0;
24629
24649
  }
@@ -24633,13 +24653,13 @@ const DetailedChart = ({
24633
24653
  className: classNames(
24634
24654
  "Layer__profit-and-loss-detailed-charts__pie",
24635
24655
  hoveredItem && active ? "active" : "inactive",
24636
- entry.type === "Uncategorized" && "Layer__profit-and-loss-detailed-charts__pie--border"
24656
+ isLineItemUncategorized(entry) && "Layer__profit-and-loss-detailed-charts__pie--border"
24637
24657
  ),
24638
24658
  style: {
24639
- fill: entry.type === "Uncategorized" && fill ? "url(#layer-pie-dots-pattern)" : fill
24659
+ fill: isLineItemUncategorized(entry) && fill ? "url(#layer-pie-dots-pattern)" : fill
24640
24660
  },
24641
24661
  opacity: typeColorMapping[index2].opacity,
24642
- onMouseEnter: () => setHoveredItem(entry.name),
24662
+ onMouseEnter: () => setHoveredItem(entry),
24643
24663
  onMouseLeave: () => setHoveredItem(void 0)
24644
24664
  },
24645
24665
  `cell-${index2}`
@@ -24665,7 +24685,7 @@ const DetailedChart = ({
24665
24685
  };
24666
24686
  let text = "Total";
24667
24687
  if (hoveredItem) {
24668
- text = hoveredItem;
24688
+ text = hoveredItem.displayName;
24669
24689
  }
24670
24690
  return /* @__PURE__ */ jsxRuntime.jsx(
24671
24691
  recharts.Text,
@@ -24698,7 +24718,7 @@ const DetailedChart = ({
24698
24718
  let value = filteredTotal;
24699
24719
  if (hoveredItem) {
24700
24720
  value = (_b = filteredData.find(
24701
- (x) => x.displayName === hoveredItem
24721
+ (x) => x.name === hoveredItem.name
24702
24722
  )) == null ? void 0 : _b.value;
24703
24723
  }
24704
24724
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -24732,7 +24752,7 @@ const DetailedChart = ({
24732
24752
  };
24733
24753
  if (hoveredItem) {
24734
24754
  const item = filteredData.find(
24735
- (x) => x.displayName === hoveredItem
24755
+ (x) => x.name === hoveredItem.name
24736
24756
  );
24737
24757
  const positiveTotal = chartData.reduce((sum, x) => sum + x.value, 0);
24738
24758
  const value = (_b = item == null ? void 0 : item.value) != null ? _b : 0;
@@ -24757,7 +24777,7 @@ const DetailedChart = ({
24757
24777
  {
24758
24778
  data: [{ name: "Total", value: 1 }],
24759
24779
  dataKey: "value",
24760
- nameKey: "name",
24780
+ nameKey: "displayName",
24761
24781
  cx: "50%",
24762
24782
  cy: "50%",
24763
24783
  innerRadius: "91%",
@@ -24787,7 +24807,7 @@ const DetailedChart = ({
24787
24807
  };
24788
24808
  let text = "Total";
24789
24809
  if (hoveredItem) {
24790
- text = hoveredItem;
24810
+ text = hoveredItem.displayName;
24791
24811
  }
24792
24812
  return /* @__PURE__ */ jsxRuntime.jsx(
24793
24813
  recharts.Text,
@@ -24820,7 +24840,7 @@ const DetailedChart = ({
24820
24840
  let value = filteredTotal;
24821
24841
  if (hoveredItem) {
24822
24842
  value = (_b = filteredData.find(
24823
- (x) => x.displayName === hoveredItem
24843
+ (x) => x.name === hoveredItem.name
24824
24844
  )) == null ? void 0 : _b.value;
24825
24845
  }
24826
24846
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -24841,7 +24861,7 @@ const DetailedChart = ({
24841
24861
  {
24842
24862
  data: [{ name: "loading...", value: 1 }],
24843
24863
  dataKey: "value",
24844
- nameKey: "name",
24864
+ nameKey: "displayName",
24845
24865
  cx: "50%",
24846
24866
  cy: "50%",
24847
24867
  innerRadius: "91%",
@@ -24960,11 +24980,11 @@ const LedgerAccountsContext = react.createContext({
24960
24980
  fetchMore: () => {
24961
24981
  }
24962
24982
  });
24963
- const CloseButton = (_Ec) => {
24964
- var _Fc = _Ec, {
24983
+ const CloseButton = (_Gc) => {
24984
+ var _Hc = _Gc, {
24965
24985
  className,
24966
24986
  textOnly = false
24967
- } = _Fc, props = __objRest(_Fc, [
24987
+ } = _Hc, props = __objRest(_Hc, [
24968
24988
  "className",
24969
24989
  "textOnly"
24970
24990
  ]);
@@ -25739,44 +25759,6 @@ function DetailReportModal({
25739
25759
  }
25740
25760
  );
25741
25761
  }
25742
- const Filters = ({
25743
- filteredData,
25744
- sidebarScope,
25745
- filters,
25746
- setFilterTypes
25747
- }) => {
25748
- var _a, _b, _c;
25749
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "filters", children: [
25750
- /* @__PURE__ */ jsxRuntime.jsx(Text, { size: TextSize.sm, className: "Layer__label", children: "Filters" }),
25751
- /* @__PURE__ */ jsxRuntime.jsx(
25752
- Select$1,
25753
- {
25754
- className: "Layer__select type-select",
25755
- classNamePrefix: "Layer__select",
25756
- value: sidebarScope && ((_a = filters[sidebarScope]) == null ? void 0 : _a.types) ? sidebarScope && ((_c = (_b = filters[sidebarScope]) == null ? void 0 : _b.types) == null ? void 0 : _c.map((x) => ({
25757
- value: x,
25758
- label: x
25759
- }))) : [],
25760
- isMulti: true,
25761
- isClearable: false,
25762
- options: [...new Set(filteredData == null ? void 0 : filteredData.map((x) => x.type))].map((x) => ({
25763
- label: x,
25764
- value: x
25765
- })),
25766
- onChange: (selected) => {
25767
- setFilterTypes(
25768
- sidebarScope != null ? sidebarScope : "expenses",
25769
- selected.map((x) => x.value)
25770
- );
25771
- },
25772
- components: {
25773
- DropdownIndicator: (props) => /* @__PURE__ */ jsxRuntime.jsx(Select$1.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown, {}) })),
25774
- Placeholder: (props) => /* @__PURE__ */ jsxRuntime.jsx(Select$1.components.Placeholder, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "Layer__select__multi-all-placeholder-badge", children: "All" }) }))
25775
- }
25776
- }
25777
- )
25778
- ] });
25779
- };
25780
25762
  const ProfitAndLossDetailedCharts = ({
25781
25763
  scope,
25782
25764
  hideClose = false,
@@ -25794,13 +25776,12 @@ const ProfitAndLossDetailedCharts = ({
25794
25776
  filters,
25795
25777
  dateRange,
25796
25778
  sidebarScope,
25797
- setSidebarScope,
25798
- setFilterTypes
25779
+ setSidebarScope
25799
25780
  } = react.useContext(ProfitAndLossContext);
25800
25781
  const theScope = scope ? scope : sidebarScope;
25801
25782
  const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
25802
25783
  const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
25803
- const [hoveredItem, setHoveredItem] = react.useState();
25784
+ const [hoveredItem, setHoveredItem] = react.useState(void 0);
25804
25785
  const [selectedItem, setSelectedItem] = react.useState(null);
25805
25786
  const [isModalOpen, setIsModalOpen] = react.useState(false);
25806
25787
  const handleValueClick = react.useCallback((item) => {
@@ -25849,31 +25830,20 @@ const ProfitAndLossDetailedCharts = ({
25849
25830
  showDatePicker
25850
25831
  }
25851
25832
  ),
25852
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: [
25853
- /* @__PURE__ */ jsxRuntime.jsx(
25854
- Filters,
25855
- {
25856
- filteredData: data,
25857
- sidebarScope: theScope,
25858
- filters,
25859
- setFilterTypes
25860
- }
25861
- ),
25862
- /* @__PURE__ */ jsxRuntime.jsx(
25863
- DetailedTable,
25864
- {
25865
- filteredData: data,
25866
- sidebarScope: theScope,
25867
- filters,
25868
- sortBy,
25869
- hoveredItem,
25870
- setHoveredItem,
25871
- chartColorsList,
25872
- stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
25873
- onValueClick: handleValueClick
25874
- }
25875
- )
25876
- ] })
25833
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(
25834
+ DetailedTable,
25835
+ {
25836
+ filteredData: data,
25837
+ sidebarScope: theScope,
25838
+ filters,
25839
+ sortBy,
25840
+ hoveredItem,
25841
+ setHoveredItem,
25842
+ chartColorsList,
25843
+ stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
25844
+ onValueClick: handleValueClick
25845
+ }
25846
+ ) })
25877
25847
  ] }),
25878
25848
  /* @__PURE__ */ jsxRuntime.jsx(
25879
25849
  DetailReportModal,
@@ -26136,7 +26106,7 @@ const getProfitAndLossDetailLinesExcel = (apiUrl, accessToken, params) => {
26136
26106
  ({ businessId: businessId2 }) => `/v1/businesses/${businessId2}/reports/profit-and-loss/lines/exports/excel?${queryParams.toString()}`
26137
26107
  )(apiUrl, accessToken, { params: { businessId } });
26138
26108
  };
26139
- function buildKey$x({
26109
+ function buildKey$B({
26140
26110
  access_token: accessToken,
26141
26111
  apiUrl,
26142
26112
  businessId,
@@ -26175,7 +26145,7 @@ function useProfitAndLossDetailLinesExport({
26175
26145
  const { businessId } = useLayerContext();
26176
26146
  const { apiUrl } = useEnvironment();
26177
26147
  return useSWRMutation(
26178
- () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
26148
+ () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
26179
26149
  apiUrl,
26180
26150
  businessId,
26181
26151
  startDate,
@@ -26392,10 +26362,10 @@ const MultiSelect = ({
26392
26362
  isInvalid ? "Layer__select--error" : "",
26393
26363
  className
26394
26364
  );
26395
- const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(Select$1.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
26365
+ const DropdownIndicator = react.useCallback((props) => /* @__PURE__ */ jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsxRuntime.jsx(ChevronDownFill, {}) })), []);
26396
26366
  return /* @__PURE__ */ jsxRuntime.jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
26397
26367
  /* @__PURE__ */ jsxRuntime.jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsxRuntime.jsx(
26398
- Select$1,
26368
+ ReactSelect,
26399
26369
  {
26400
26370
  inputId,
26401
26371
  name,
@@ -26410,7 +26380,7 @@ const MultiSelect = ({
26410
26380
  styles: __spreadValues({
26411
26381
  menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 })
26412
26382
  }, styles),
26413
- components: { DropdownIndicator },
26383
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
26414
26384
  isLoading,
26415
26385
  isDisabled: disabled,
26416
26386
  isMulti: true
@@ -27211,7 +27181,13 @@ function ProfitAndLossSummariesMiniChart({
27211
27181
  chartColorsList,
27212
27182
  variants: variants2
27213
27183
  }) {
27214
- const typeColorMapping = mapTypesToColors(data, chartColorsList);
27184
+ const chartData = react.useMemo(
27185
+ () => data.map((x) => __spreadProps(__spreadValues({}, x), {
27186
+ value: x.value > 0 ? x.value : 0
27187
+ })),
27188
+ [data]
27189
+ );
27190
+ const typeColorMapping = mapTypesToColors(chartData, chartColorsList);
27215
27191
  let chartDimension = 52;
27216
27192
  let innerRadius = 10;
27217
27193
  let outerRadius = 16;
@@ -27230,9 +27206,9 @@ function ProfitAndLossSummariesMiniChart({
27230
27206
  return /* @__PURE__ */ jsxRuntime.jsx(recharts.PieChart, { width: chartDimension, height: chartDimension, children: /* @__PURE__ */ jsxRuntime.jsx(
27231
27207
  recharts.Pie,
27232
27208
  {
27233
- data,
27209
+ data: chartData,
27234
27210
  dataKey: "value",
27235
- nameKey: "name",
27211
+ nameKey: "displayName",
27236
27212
  cx: "50%",
27237
27213
  cy: "50%",
27238
27214
  innerRadius,
@@ -27243,7 +27219,7 @@ function ProfitAndLossSummariesMiniChart({
27243
27219
  height: 36,
27244
27220
  animationDuration: 250,
27245
27221
  animationEasing: "ease-in-out",
27246
- children: data.map((entry, index2) => {
27222
+ children: chartData.map((entry, index2) => {
27247
27223
  const colorConfig = typeColorMapping[index2];
27248
27224
  return /* @__PURE__ */ jsxRuntime.jsx(
27249
27225
  recharts.Cell,
@@ -27280,7 +27256,7 @@ function ProfitAndLossSummariesSummary({
27280
27256
  const showPercentChange = percentChange !== void 0 && percentChange !== null && comparisonMonth;
27281
27257
  const isGoodChange = showPercentChange && (isExpense ? percentChange < 0 : percentChange >= 0);
27282
27258
  const arrow = showPercentChange && percentChange >= 0 ? "↑" : "↓";
27283
- return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", align: "center", children: [
27259
+ return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", align: "center", overflow: "hidden", children: [
27284
27260
  Chart && /* @__PURE__ */ jsxRuntime.jsx(
27285
27261
  HStack,
27286
27262
  {
@@ -27532,10 +27508,10 @@ function Internal_ProfitAndLossSummaries({
27532
27508
  unstable_AdditionalListItems.map((item, index2) => /* @__PURE__ */ jsxRuntime.jsx(ProfitAndLossSummariesListItem, { children: item }, index2))
27533
27509
  ] }) });
27534
27510
  }
27535
- function ProfitAndLossSummaries(_Gc) {
27536
- var _Hc = _Gc, {
27511
+ function ProfitAndLossSummaries(_Ic) {
27512
+ var _Jc = _Ic, {
27537
27513
  onTransactionsToReviewClick
27538
- } = _Hc, restProps = __objRest(_Hc, [
27514
+ } = _Jc, restProps = __objRest(_Jc, [
27539
27515
  "onTransactionsToReviewClick"
27540
27516
  ]);
27541
27517
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -27573,7 +27549,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
27573
27549
  ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
27574
27550
  ProfitAndLoss.Header = ProfitAndLossHeader;
27575
27551
  ProfitAndLoss.Report = ProfitAndLossReport;
27576
- function buildKey$w({
27552
+ function buildKey$A({
27577
27553
  access_token: accessToken,
27578
27554
  apiUrl,
27579
27555
  businessId,
@@ -27596,7 +27572,7 @@ function useBalanceSheet({
27596
27572
  const { apiUrl } = useEnvironment();
27597
27573
  const { businessId } = useLayerContext();
27598
27574
  return useSWR(
27599
- () => buildKey$w(__spreadProps(__spreadValues({}, auth), {
27575
+ () => buildKey$A(__spreadProps(__spreadValues({}, auth), {
27600
27576
  apiUrl,
27601
27577
  businessId,
27602
27578
  effectiveDate
@@ -27662,7 +27638,7 @@ const BALANCE_SHEET_ROWS = [
27662
27638
  }
27663
27639
  ];
27664
27640
  const DOWNLOAD_BALANCE_SHEET_TAG_KEY = "#download-balance-sheet";
27665
- function buildKey$v({
27641
+ function buildKey$z({
27666
27642
  access_token: accessToken,
27667
27643
  apiUrl,
27668
27644
  businessId,
@@ -27685,7 +27661,7 @@ function useBalanceSheetDownload({
27685
27661
  const { data: auth } = useAuth();
27686
27662
  const { businessId } = useLayerContext();
27687
27663
  return useSWRMutation(
27688
- () => buildKey$v(__spreadProps(__spreadValues({}, auth), {
27664
+ () => buildKey$z(__spreadProps(__spreadValues({}, auth), {
27689
27665
  businessId,
27690
27666
  effectiveDate
27691
27667
  })),
@@ -27735,8 +27711,8 @@ function BalanceSheetDownloadButton({
27735
27711
  /* @__PURE__ */ jsxRuntime.jsx(InvisibleDownload, { ref: invisibleDownloadRef })
27736
27712
  ] });
27737
27713
  }
27738
- const Collapse = (_Ic) => {
27739
- var props = __objRest(_Ic, []);
27714
+ const Collapse = (_Kc) => {
27715
+ var props = __objRest(_Kc, []);
27740
27716
  return /* @__PURE__ */ jsxRuntime.jsxs(
27741
27717
  "svg",
27742
27718
  __spreadProps(__spreadValues({
@@ -27769,8 +27745,8 @@ const Collapse = (_Ic) => {
27769
27745
  })
27770
27746
  );
27771
27747
  };
27772
- const Expand = (_Jc) => {
27773
- var props = __objRest(_Jc, []);
27748
+ const Expand = (_Lc) => {
27749
+ var props = __objRest(_Lc, []);
27774
27750
  return /* @__PURE__ */ jsxRuntime.jsxs(
27775
27751
  "svg",
27776
27752
  __spreadProps(__spreadValues({
@@ -28040,7 +28016,7 @@ const BalanceSheetView = ({
28040
28016
  }
28041
28017
  ) });
28042
28018
  };
28043
- function buildKey$u({
28019
+ function buildKey$y({
28044
28020
  access_token: accessToken,
28045
28021
  apiUrl,
28046
28022
  businessId,
@@ -28066,7 +28042,7 @@ function useStatementOfCashFlow({
28066
28042
  const { apiUrl } = useEnvironment();
28067
28043
  const { businessId } = useLayerContext();
28068
28044
  return useSWR(
28069
- buildKey$u(__spreadProps(__spreadValues({}, auth), {
28045
+ buildKey$y(__spreadProps(__spreadValues({}, auth), {
28070
28046
  apiUrl,
28071
28047
  businessId,
28072
28048
  startDate,
@@ -28130,7 +28106,7 @@ const STATEMENT_OF_CASH_FLOW_ROWS = [
28130
28106
  }
28131
28107
  ];
28132
28108
  const DOWNLOAD_CASHFLOW_STATEMENT_TAG_KEY = "#download-cashflow-statement";
28133
- function buildKey$t({
28109
+ function buildKey$x({
28134
28110
  access_token: accessToken,
28135
28111
  apiUrl,
28136
28112
  businessId,
@@ -28156,7 +28132,7 @@ function useCashflowStatementDownload({
28156
28132
  const { data: auth } = useAuth();
28157
28133
  const { businessId } = useLayerContext();
28158
28134
  return useSWRMutation(
28159
- () => buildKey$t(__spreadProps(__spreadValues({}, auth), {
28135
+ () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
28160
28136
  businessId,
28161
28137
  startDate,
28162
28138
  endDate
@@ -28360,7 +28336,7 @@ const getLedgerAccountBalances = get$1(
28360
28336
  return `/v1/businesses/${businessId}/ledger/balances?${parameters}`;
28361
28337
  }
28362
28338
  );
28363
- function buildKey$s({
28339
+ function buildKey$w({
28364
28340
  access_token: accessToken,
28365
28341
  apiUrl,
28366
28342
  businessId,
@@ -28382,7 +28358,7 @@ function useLedgerBalances(withDates, startDate, endDate) {
28382
28358
  const { data } = useAuth();
28383
28359
  const { businessId } = useLayerContext();
28384
28360
  const response = useSWR(
28385
- () => buildKey$s(__spreadProps(__spreadValues({}, data), {
28361
+ () => buildKey$w(__spreadProps(__spreadValues({}, data), {
28386
28362
  businessId,
28387
28363
  startDate: withDates ? startDate : void 0,
28388
28364
  endDate: withDates ? endDate : void 0
@@ -28724,7 +28700,7 @@ const LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
28724
28700
  EXPENSE: EXPENSE_LEDGER_ACCOUNT_SUBTYPES
28725
28701
  };
28726
28702
  const deleteAccountFromLedger = del(({ businessId, accountId }) => `/v1/businesses/${businessId}/ledger/accounts/${accountId}`);
28727
- function buildKey$r({
28703
+ function buildKey$v({
28728
28704
  access_token: accessToken,
28729
28705
  apiUrl,
28730
28706
  businessId
@@ -28742,7 +28718,7 @@ function useDeleteAccountFromLedger() {
28742
28718
  const { data } = useAuth();
28743
28719
  const { businessId } = useLayerContext();
28744
28720
  const mutationResponse = useSWRMutation(
28745
- () => buildKey$r(__spreadProps(__spreadValues({}, data), {
28721
+ () => buildKey$v(__spreadProps(__spreadValues({}, data), {
28746
28722
  businessId
28747
28723
  })),
28748
28724
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { accountId } }) => deleteAccountFromLedger(
@@ -29418,8 +29394,8 @@ const ChartOfAccountsContext = react.createContext(
29418
29394
  }
29419
29395
  }
29420
29396
  );
29421
- const Plus = (_Kc) => {
29422
- var _Lc = _Kc, { size = 14 } = _Lc, props = __objRest(_Lc, ["size"]);
29397
+ const Plus = (_Mc) => {
29398
+ var _Nc = _Mc, { size = 14 } = _Nc, props = __objRest(_Nc, ["size"]);
29423
29399
  return /* @__PURE__ */ jsxRuntime.jsxs(
29424
29400
  "svg",
29425
29401
  __spreadProps(__spreadValues({
@@ -29452,7 +29428,7 @@ const Plus = (_Kc) => {
29452
29428
  })
29453
29429
  );
29454
29430
  };
29455
- function buildKey$q({
29431
+ function buildKey$u({
29456
29432
  access_token: accessToken,
29457
29433
  apiUrl,
29458
29434
  businessId,
@@ -29478,7 +29454,7 @@ function useAccountBalancesDownload({
29478
29454
  const { data: auth } = useAuth();
29479
29455
  const { businessId } = useLayerContext();
29480
29456
  return useSWRMutation(
29481
- () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
29457
+ () => buildKey$u(__spreadProps(__spreadValues({}, auth), {
29482
29458
  businessId,
29483
29459
  startCutoff,
29484
29460
  endCutoff
@@ -29786,8 +29762,8 @@ var LedgerAccountNodeType = /* @__PURE__ */ ((LedgerAccountNodeType2) => {
29786
29762
  LedgerAccountNodeType2["Parent"] = "Parent";
29787
29763
  return LedgerAccountNodeType2;
29788
29764
  })(LedgerAccountNodeType || {});
29789
- const Edit2 = (_Mc) => {
29790
- var _Nc = _Mc, { size = 18 } = _Nc, props = __objRest(_Nc, ["size"]);
29765
+ const Edit2 = (_Oc) => {
29766
+ var _Pc = _Oc, { size = 18 } = _Pc, props = __objRest(_Pc, ["size"]);
29791
29767
  return /* @__PURE__ */ jsxRuntime.jsx(
29792
29768
  "svg",
29793
29769
  __spreadProps(__spreadValues({
@@ -31510,7 +31486,7 @@ var UpsertJournalEntryMode = /* @__PURE__ */ ((UpsertJournalEntryMode2) => {
31510
31486
  return UpsertJournalEntryMode2;
31511
31487
  })(UpsertJournalEntryMode || {});
31512
31488
  const createJournalEntry = post(({ businessId }) => `/v1/businesses/${businessId}/ledger/journal-entries`);
31513
- function buildKey$p({
31489
+ function buildKey$t({
31514
31490
  access_token: accessToken,
31515
31491
  apiUrl,
31516
31492
  businessId
@@ -31537,7 +31513,7 @@ const useUpsertJournalEntry = (props) => {
31537
31513
  const { debouncedInvalidateProfitAndLossSummaries } = useProfitAndLossSummariesCacheActions();
31538
31514
  const { invalidate } = useGlobalCacheActions();
31539
31515
  const rawMutationResponse = useSWRMutation(
31540
- () => buildKey$p(__spreadProps(__spreadValues({}, data), {
31516
+ () => buildKey$t(__spreadProps(__spreadValues({}, data), {
31541
31517
  businessId
31542
31518
  })),
31543
31519
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => {
@@ -31851,7 +31827,7 @@ const JournalEntryDrawerHeader = ({ onSubmit, formState }) => {
31851
31827
  ] })
31852
31828
  ] });
31853
31829
  };
31854
- function buildKey$o({
31830
+ function buildKey$s({
31855
31831
  access_token: accessToken,
31856
31832
  apiUrl,
31857
31833
  businessId,
@@ -31877,7 +31853,7 @@ function useJournalEntriesDownload({
31877
31853
  const { data: auth } = useAuth();
31878
31854
  const { businessId } = useLayerContext();
31879
31855
  return useSWRMutation(
31880
- () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
31856
+ () => buildKey$s(__spreadProps(__spreadValues({}, auth), {
31881
31857
  businessId,
31882
31858
  startCutoff,
31883
31859
  endCutoff
@@ -32468,8 +32444,8 @@ function usePaginatedList(list, pageSize) {
32468
32444
  reset
32469
32445
  };
32470
32446
  }
32471
- const SmileIcon = (_Oc) => {
32472
- var _Pc = _Oc, { size = 12 } = _Pc, props = __objRest(_Pc, ["size"]);
32447
+ const SmileIcon = (_Qc) => {
32448
+ var _Rc = _Qc, { size = 12 } = _Rc, props = __objRest(_Rc, ["size"]);
32473
32449
  return /* @__PURE__ */ jsxRuntime.jsxs(
32474
32450
  "svg",
32475
32451
  __spreadProps(__spreadValues({
@@ -32565,7 +32541,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
32565
32541
  accessToken
32566
32542
  );
32567
32543
  }
32568
- function buildKey$n({
32544
+ function buildKey$r({
32569
32545
  access_token: accessToken,
32570
32546
  apiUrl,
32571
32547
  businessId
@@ -32584,7 +32560,7 @@ function useDeleteUploadsOnTask() {
32584
32560
  const { businessId } = useLayerContext();
32585
32561
  const { mutate } = useSWR.useSWRConfig();
32586
32562
  const mutationResponse = useSWRMutation(
32587
- () => buildKey$n(__spreadProps(__spreadValues({}, auth), {
32563
+ () => buildKey$r(__spreadProps(__spreadValues({}, auth), {
32588
32564
  businessId
32589
32565
  })),
32590
32566
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId } }) => deleteUploadsOnTask(
@@ -32623,7 +32599,7 @@ function useDeleteUploadsOnTask() {
32623
32599
  }
32624
32600
  });
32625
32601
  }
32626
- function buildKey$m({
32602
+ function buildKey$q({
32627
32603
  access_token: accessToken,
32628
32604
  apiUrl,
32629
32605
  businessId
@@ -32642,7 +32618,7 @@ function useSubmitUserResponseForTask() {
32642
32618
  const { businessId } = useLayerContext();
32643
32619
  const { mutate } = useSWR.useSWRConfig();
32644
32620
  const mutationResponse = useSWRMutation(
32645
- () => buildKey$m(__spreadProps(__spreadValues({}, auth), {
32621
+ () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
32646
32622
  businessId
32647
32623
  })),
32648
32624
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, userResponse } }) => submitUserResponseForTask(
@@ -32688,7 +32664,7 @@ function useSubmitUserResponseForTask() {
32688
32664
  }
32689
32665
  });
32690
32666
  }
32691
- function buildKey$l({
32667
+ function buildKey$p({
32692
32668
  access_token: accessToken,
32693
32669
  apiUrl,
32694
32670
  businessId
@@ -32707,7 +32683,7 @@ function useUpdateTaskUploadDescription() {
32707
32683
  const { businessId } = useLayerContext();
32708
32684
  const { mutate } = useSWR.useSWRConfig();
32709
32685
  const mutationResponse = useSWRMutation(
32710
- () => buildKey$l(__spreadProps(__spreadValues({}, auth), {
32686
+ () => buildKey$p(__spreadProps(__spreadValues({}, auth), {
32711
32687
  businessId
32712
32688
  })),
32713
32689
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, description } }) => updateTaskUploadsDescription(
@@ -32750,7 +32726,7 @@ function useUpdateTaskUploadDescription() {
32750
32726
  }
32751
32727
  });
32752
32728
  }
32753
- function buildKey$k({
32729
+ function buildKey$o({
32754
32730
  access_token: accessToken,
32755
32731
  apiUrl,
32756
32732
  businessId
@@ -32769,7 +32745,7 @@ function useUploadDocumentsForTask() {
32769
32745
  const { businessId } = useLayerContext();
32770
32746
  const { mutate } = useSWR.useSWRConfig();
32771
32747
  const mutationResponse = useSWRMutation(
32772
- () => buildKey$k(__spreadProps(__spreadValues({}, auth), {
32748
+ () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
32773
32749
  businessId
32774
32750
  })),
32775
32751
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, files, description } }) => completeTaskWithUpload(
@@ -33314,8 +33290,8 @@ const useBookkeepingYearsStatus = () => {
33314
33290
  isLoading
33315
33291
  };
33316
33292
  };
33317
- const ArrowRightCircle = (_Qc) => {
33318
- var _Rc = _Qc, { size = 18 } = _Rc, props = __objRest(_Rc, ["size"]);
33293
+ const ArrowRightCircle = (_Sc) => {
33294
+ var _Tc = _Sc, { size = 18 } = _Tc, props = __objRest(_Tc, ["size"]);
33319
33295
  return /* @__PURE__ */ jsxRuntime.jsxs(
33320
33296
  "svg",
33321
33297
  __spreadProps(__spreadValues({
@@ -34797,7 +34773,7 @@ class BookkeepingConfigurationSWRResponse {
34797
34773
  return this.swrResponse.mutate;
34798
34774
  }
34799
34775
  }
34800
- function buildKey$j({
34776
+ function buildKey$n({
34801
34777
  access_token: accessToken,
34802
34778
  apiUrl,
34803
34779
  businessId
@@ -34818,7 +34794,7 @@ function useBookkeepingConfiguration() {
34818
34794
  const { apiUrl } = useEnvironment();
34819
34795
  const { data: auth } = useAuth();
34820
34796
  const { businessId } = useLayerContext();
34821
- const queryKey = buildKey$j(__spreadProps(__spreadValues({}, auth), {
34797
+ const queryKey = buildKey$n(__spreadProps(__spreadValues({}, auth), {
34822
34798
  apiUrl,
34823
34799
  businessId
34824
34800
  }));
@@ -35005,7 +34981,7 @@ const BookOnboardingCallStep = ({ title = defaultTitle$3, description = defaultD
35005
34981
  ] });
35006
34982
  };
35007
34983
  const BUSINESS_TAG_KEY = "business";
35008
- function buildKey$i({
34984
+ function buildKey$m({
35009
34985
  access_token: accessToken,
35010
34986
  apiUrl,
35011
34987
  businessId
@@ -35024,7 +35000,7 @@ function useUpdateBusiness() {
35024
35000
  const { businessId } = useLayerContext();
35025
35001
  const { mutate } = useSWR.useSWRConfig();
35026
35002
  const mutationResponse = useSWRMutation(
35027
- () => buildKey$i(__spreadProps(__spreadValues({}, data), {
35003
+ () => buildKey$m(__spreadProps(__spreadValues({}, data), {
35028
35004
  businessId
35029
35005
  })),
35030
35006
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => updateBusiness(
@@ -35075,7 +35051,7 @@ function isPersonnelRole(role) {
35075
35051
  return PERSONNEL_ROLES.includes(role);
35076
35052
  }
35077
35053
  const BUSINESS_PERSONNEL_TAG_KEY = "#business-personnel";
35078
- function buildKey$h({
35054
+ function buildKey$l({
35079
35055
  access_token: accessToken,
35080
35056
  apiUrl,
35081
35057
  businessId
@@ -35094,7 +35070,7 @@ function useBusinessPersonnel() {
35094
35070
  const { data } = useAuth();
35095
35071
  const { businessId } = useLayerContext();
35096
35072
  return useSWR(
35097
- () => buildKey$h(__spreadProps(__spreadValues({}, data), {
35073
+ () => buildKey$l(__spreadProps(__spreadValues({}, data), {
35098
35074
  businessId
35099
35075
  })),
35100
35076
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBusinessPersonnel(
@@ -35132,7 +35108,7 @@ function useBusinessPersonnel() {
35132
35108
  );
35133
35109
  }
35134
35110
  const createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
35135
- function buildKey$g({
35111
+ function buildKey$k({
35136
35112
  access_token: accessToken,
35137
35113
  apiUrl,
35138
35114
  businessId
@@ -35151,7 +35127,7 @@ function useCreateBusinessPersonnel() {
35151
35127
  const { businessId } = useLayerContext();
35152
35128
  const { mutate } = useSWR.useSWRConfig();
35153
35129
  const mutationResponse = useSWRMutation(
35154
- () => buildKey$g(__spreadProps(__spreadValues({}, data), {
35130
+ () => buildKey$k(__spreadProps(__spreadValues({}, data), {
35155
35131
  businessId
35156
35132
  })),
35157
35133
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createBusinessPersonnel(
@@ -35194,7 +35170,7 @@ function useCreateBusinessPersonnel() {
35194
35170
  const updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
35195
35171
  return `/v1/businesses/${businessId}/personnel/${businessPersonnelId}/update`;
35196
35172
  });
35197
- function buildKey$f({
35173
+ function buildKey$j({
35198
35174
  access_token: accessToken,
35199
35175
  apiUrl,
35200
35176
  businessId,
@@ -35215,7 +35191,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
35215
35191
  const { businessId } = useLayerContext();
35216
35192
  const { mutate } = useSWR.useSWRConfig();
35217
35193
  const mutationResponse = useSWRMutation(
35218
- () => buildKey$f(__spreadProps(__spreadValues({}, data), {
35194
+ () => buildKey$j(__spreadProps(__spreadValues({}, data), {
35219
35195
  businessId,
35220
35196
  businessPersonnelId
35221
35197
  })),
@@ -35363,12 +35339,12 @@ const FormSection = ({ children, title }) => {
35363
35339
  children
35364
35340
  ] });
35365
35341
  };
35366
- const PhoneInput = (_Sc) => {
35367
- var _Tc = _Sc, {
35342
+ const PhoneInput = (_Uc) => {
35343
+ var _Vc = _Uc, {
35368
35344
  value,
35369
35345
  onChange,
35370
35346
  placeholder = "Phone number"
35371
- } = _Tc, props = __objRest(_Tc, [
35347
+ } = _Vc, props = __objRest(_Vc, [
35372
35348
  "value",
35373
35349
  "onChange",
35374
35350
  "placeholder"
@@ -35660,8 +35636,8 @@ const SummaryStep = ({ onNext, title = defaultTitle$1, description = defaultDesc
35660
35636
  /* @__PURE__ */ jsxRuntime.jsx(Button$1, { onClick: onNext, children: nextBtnText })
35661
35637
  ] });
35662
35638
  };
35663
- const Document = (_Uc) => {
35664
- var _Vc = _Uc, { size = 20 } = _Vc, props = __objRest(_Vc, ["size"]);
35639
+ const Document = (_Wc) => {
35640
+ var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
35665
35641
  return /* @__PURE__ */ jsxRuntime.jsxs(
35666
35642
  "svg",
35667
35643
  __spreadProps(__spreadValues({
@@ -35766,8 +35742,8 @@ const Document = (_Uc) => {
35766
35742
  })
35767
35743
  );
35768
35744
  };
35769
- const TrendingUp = (_Wc) => {
35770
- var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
35745
+ const TrendingUp = (_Yc) => {
35746
+ var _Zc = _Yc, { size = 20 } = _Zc, props = __objRest(_Zc, ["size"]);
35771
35747
  return /* @__PURE__ */ jsxRuntime.jsxs(
35772
35748
  "svg",
35773
35749
  __spreadProps(__spreadValues({
@@ -36024,8 +36000,8 @@ const PlatformOnboarding = ({ onComplete }) => {
36024
36000
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "Layer__platform-onboarding-layout__footer", children: renderStepFooter() })
36025
36001
  ] }) });
36026
36002
  };
36027
- const CoffeeIcon = (_Yc) => {
36028
- var _Zc = _Yc, { size = 11 } = _Zc, props = __objRest(_Zc, ["size"]);
36003
+ const CoffeeIcon = (__c) => {
36004
+ var _$c = __c, { size = 11 } = _$c, props = __objRest(_$c, ["size"]);
36029
36005
  return /* @__PURE__ */ jsxRuntime.jsxs(
36030
36006
  "svg",
36031
36007
  __spreadProps(__spreadValues({
@@ -36096,8 +36072,8 @@ const CoffeeIcon = (_Yc) => {
36096
36072
  })
36097
36073
  );
36098
36074
  };
36099
- const Link$1 = (__c) => {
36100
- var _$c = __c, {
36075
+ const Link$1 = (_ad) => {
36076
+ var _bd = _ad, {
36101
36077
  className,
36102
36078
  children,
36103
36079
  variant = ButtonVariant.primary,
@@ -36107,7 +36083,7 @@ const Link$1 = (__c) => {
36107
36083
  iconAsPrimary = false,
36108
36084
  justify = "center",
36109
36085
  fullWidth
36110
- } = _$c, props = __objRest(_$c, [
36086
+ } = _bd, props = __objRest(_bd, [
36111
36087
  "className",
36112
36088
  "children",
36113
36089
  "variant",
@@ -36199,8 +36175,8 @@ const BookkeepingUpsellBar = ({
36199
36175
  onClick ? /* @__PURE__ */ jsxRuntime.jsx(Button$1, { variant: ButtonVariant.secondary, onClick, children: "Schedule a demo" }) : href ? /* @__PURE__ */ jsxRuntime.jsx(Link$1, { href, target: "_blank", variant: ButtonVariant.secondary, children: "Schedule a demo" }) : null
36200
36176
  ] });
36201
36177
  };
36202
- const ChevronRightFill = (_ad) => {
36203
- var _bd = _ad, { size = 18 } = _bd, props = __objRest(_bd, ["size"]);
36178
+ const ChevronRightFill = (_cd) => {
36179
+ var _dd = _cd, { size = 18 } = _dd, props = __objRest(_dd, ["size"]);
36204
36180
  return /* @__PURE__ */ jsxRuntime.jsxs(
36205
36181
  "svg",
36206
36182
  __spreadProps(__spreadValues({
@@ -36227,7 +36203,7 @@ const ChevronRightFill = (_ad) => {
36227
36203
  };
36228
36204
  const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
36229
36205
  const { showCount, totalCount } = count != null ? count : {};
36230
- const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
36206
+ const { Filters, HeaderActions, HeaderFilters } = slots;
36231
36207
  return /* @__PURE__ */ jsxRuntime.jsxs(VStack, { children: [
36232
36208
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "center", gap: "xs", className: "Layer__DataTableHeader__Header", children: [
36233
36209
  /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pis: "md", align: "center", gap: "xl", children: [
@@ -36242,8 +36218,8 @@ const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
36242
36218
  HeaderActions && /* @__PURE__ */ jsxRuntime.jsx(HeaderActions, {})
36243
36219
  ] })
36244
36220
  ] }),
36245
- Filters2 && /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
36246
- /* @__PURE__ */ jsxRuntime.jsx(Filters2, {}),
36221
+ Filters && /* @__PURE__ */ jsxRuntime.jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
36222
+ /* @__PURE__ */ jsxRuntime.jsx(Filters, {}),
36247
36223
  slotProps.ClearFiltersButton && /* @__PURE__ */ jsxRuntime.jsx(Button, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
36248
36224
  ] })
36249
36225
  ] });
@@ -37168,7 +37144,7 @@ class InvoiceSummaryStatsSWRResponse {
37168
37144
  return this.swrResponse.error !== void 0;
37169
37145
  }
37170
37146
  }
37171
- function buildKey$e({
37147
+ function buildKey$i({
37172
37148
  access_token: accessToken,
37173
37149
  apiUrl,
37174
37150
  businessId
@@ -37187,7 +37163,7 @@ function useInvoiceSummaryStats() {
37187
37163
  const { data } = useAuth();
37188
37164
  const { businessId } = useLayerContext();
37189
37165
  const response = useSWR(
37190
- () => buildKey$e(__spreadProps(__spreadValues({}, data), {
37166
+ () => buildKey$i(__spreadProps(__spreadValues({}, data), {
37191
37167
  businessId
37192
37168
  })),
37193
37169
  ({ accessToken, apiUrl, businessId: businessId2 }) => getInvoiceSummaryStats(
@@ -37218,7 +37194,7 @@ var UpsertInvoiceMode = /* @__PURE__ */ ((UpsertInvoiceMode2) => {
37218
37194
  })(UpsertInvoiceMode || {});
37219
37195
  const createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
37220
37196
  const updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
37221
- function buildKey$d({
37197
+ function buildKey$h({
37222
37198
  access_token: accessToken,
37223
37199
  apiUrl,
37224
37200
  businessId,
@@ -37290,7 +37266,7 @@ const useUpsertInvoice = (props) => {
37290
37266
  const { mode } = props;
37291
37267
  const invoiceId = mode === "Update" ? props.invoiceId : void 0;
37292
37268
  const rawMutationResponse = useSWRMutation(
37293
- () => buildKey$d(__spreadProps(__spreadValues({}, data), {
37269
+ () => buildKey$h(__spreadProps(__spreadValues({}, data), {
37294
37270
  businessId,
37295
37271
  invoiceId
37296
37272
  })),
@@ -37559,7 +37535,7 @@ const RefundInvoiceReturnSchema = effect.Schema.Struct({
37559
37535
  data: CustomerRefundSchema
37560
37536
  });
37561
37537
  const refundInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/refund`);
37562
- function buildKey$c({
37538
+ function buildKey$g({
37563
37539
  access_token: accessToken,
37564
37540
  apiUrl,
37565
37541
  businessId,
@@ -37604,7 +37580,7 @@ const useRefundInvoice = ({ invoiceId }) => {
37604
37580
  return updateInvoiceWithRefund(invoice);
37605
37581
  }, [invoiceId]);
37606
37582
  const rawMutationResponse = useSWRMutation(
37607
- () => buildKey$c(__spreadProps(__spreadValues({}, data), {
37583
+ () => buildKey$g(__spreadProps(__spreadValues({}, data), {
37608
37584
  businessId,
37609
37585
  invoiceId
37610
37586
  })),
@@ -37792,7 +37768,7 @@ const ResetInvoiceReturnSchema = effect.Schema.Struct({
37792
37768
  data: InvoiceSchema
37793
37769
  });
37794
37770
  const resetInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/reset`);
37795
- function buildKey$b({
37771
+ function buildKey$f({
37796
37772
  access_token: accessToken,
37797
37773
  apiUrl,
37798
37774
  businessId,
@@ -37830,7 +37806,7 @@ const useResetInvoice = ({ invoiceId }) => {
37830
37806
  const { data } = useAuth();
37831
37807
  const { businessId } = useLayerContext();
37832
37808
  const rawMutationResponse = useSWRMutation(
37833
- () => buildKey$b(__spreadProps(__spreadValues({}, data), {
37809
+ () => buildKey$f(__spreadProps(__spreadValues({}, data), {
37834
37810
  businessId,
37835
37811
  invoiceId
37836
37812
  })),
@@ -37893,7 +37869,7 @@ const VoidInvoiceReturnSchema = effect.Schema.Struct({
37893
37869
  data: InvoiceSchema
37894
37870
  });
37895
37871
  const voidInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/void`);
37896
- function buildKey$a({
37872
+ function buildKey$e({
37897
37873
  access_token: accessToken,
37898
37874
  apiUrl,
37899
37875
  businessId,
@@ -37931,7 +37907,7 @@ const useVoidInvoice = ({ invoiceId }) => {
37931
37907
  const { data } = useAuth();
37932
37908
  const { businessId } = useLayerContext();
37933
37909
  const rawMutationResponse = useSWRMutation(
37934
- () => buildKey$a(__spreadProps(__spreadValues({}, data), {
37910
+ () => buildKey$e(__spreadProps(__spreadValues({}, data), {
37935
37911
  businessId,
37936
37912
  invoiceId
37937
37913
  })),
@@ -38050,7 +38026,7 @@ const InvoiceWriteoffSchema = effect.Schema.Struct({
38050
38026
  });
38051
38027
  const CREATE_INVOICE_WRITEOFF_TAG_KEY = "#writeoff-invoice";
38052
38028
  const writeoffInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/write-off`);
38053
- function buildKey$9({
38029
+ function buildKey$d({
38054
38030
  access_token: accessToken,
38055
38031
  apiUrl,
38056
38032
  businessId,
@@ -38101,7 +38077,7 @@ const useWriteoffInvoice = ({ invoiceId }) => {
38101
38077
  return updateInvoiceWithWriteoff(invoice);
38102
38078
  }, [invoiceId]);
38103
38079
  const rawMutationResponse = useSWRMutation(
38104
- () => buildKey$9(__spreadProps(__spreadValues({}, data), {
38080
+ () => buildKey$d(__spreadProps(__spreadValues({}, data), {
38105
38081
  businessId,
38106
38082
  invoiceId
38107
38083
  })),
@@ -39097,7 +39073,7 @@ var UpsertDedicatedInvoicePaymentMode = /* @__PURE__ */ ((UpsertDedicatedInvoice
39097
39073
  })(UpsertDedicatedInvoicePaymentMode || {});
39098
39074
  const createDedicatedInvoicePayment = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/`);
39099
39075
  const updateDedicatedInvoicePayment = put(({ businessId, invoiceId, invoicePaymentId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/${invoicePaymentId}`);
39100
- function buildKey$8({
39076
+ function buildKey$c({
39101
39077
  access_token: accessToken,
39102
39078
  apiUrl,
39103
39079
  businessId,
@@ -39182,7 +39158,7 @@ const useUpsertDedicatedInvoicePayment = (props) => {
39182
39158
  return updateInvoiceWithPayment(invoice, invoicePayment);
39183
39159
  }, [invoiceId]);
39184
39160
  const rawMutationResponse = useSWRMutation(
39185
- () => buildKey$8(__spreadProps(__spreadValues({}, data), {
39161
+ () => buildKey$c(__spreadProps(__spreadValues({}, data), {
39186
39162
  businessId,
39187
39163
  invoiceId,
39188
39164
  invoicePaymentId
@@ -39482,8 +39458,8 @@ const getClassnameForSubComponent = (className, suffix) => {
39482
39458
  };
39483
39459
  const METER_CLASS_NAME = "Layer__Meter";
39484
39460
  const Meter = react.forwardRef(
39485
- function Meter2(_cd, ref) {
39486
- var _dd = _cd, { className, label, meterOnly } = _dd, restProps = __objRest(_dd, ["className", "label", "meterOnly"]);
39461
+ function Meter2(_ed, ref) {
39462
+ var _fd = _ed, { className, label, meterOnly } = _fd, restProps = __objRest(_fd, ["className", "label", "meterOnly"]);
39487
39463
  return /* @__PURE__ */ jsxRuntime.jsx(reactAriaComponents.Meter, __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, restProps), { className: classNames(METER_CLASS_NAME, className), ref }), meterOnly && { "aria-label": label }), { children: ({ percentage, valueText }) => /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "3xs", fluid: true, children: [
39488
39464
  !meterOnly && /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", children: [
39489
39465
  /* @__PURE__ */ jsxRuntime.jsx(Label, { slot: "label", children: label }),
@@ -39598,11 +39574,11 @@ const ProfitAndLossView = (props) => {
39598
39574
  const containerRef = react.useRef(null);
39599
39575
  return /* @__PURE__ */ jsxRuntime.jsx(Container, { name: COMPONENT_NAME$3, ref: containerRef, children: /* @__PURE__ */ jsxRuntime.jsx(ProfitAndLoss, { children: /* @__PURE__ */ jsxRuntime.jsx(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
39600
39576
  };
39601
- const ProfitAndLossPanel = (_ed) => {
39602
- var _fd = _ed, {
39577
+ const ProfitAndLossPanel = (_gd) => {
39578
+ var _hd = _gd, {
39603
39579
  containerRef,
39604
39580
  stringOverrides
39605
- } = _fd, props = __objRest(_fd, [
39581
+ } = _hd, props = __objRest(_hd, [
39606
39582
  "containerRef",
39607
39583
  "stringOverrides"
39608
39584
  ]);
@@ -39865,13 +39841,13 @@ function ExpandableDataTable({
39865
39841
  );
39866
39842
  }
39867
39843
  const UNIFIED_REPORT_TAG_KEY = "#unified-report";
39868
- function buildKey$7(_gd) {
39869
- var _hd = _gd, {
39844
+ function buildKey$b(_id) {
39845
+ var _jd = _id, {
39870
39846
  access_token: accessToken,
39871
39847
  apiUrl,
39872
39848
  businessId,
39873
39849
  report
39874
- } = _hd, dateParams = __objRest(_hd, [
39850
+ } = _jd, dateParams = __objRest(_jd, [
39875
39851
  "access_token",
39876
39852
  "apiUrl",
39877
39853
  "businessId",
@@ -39887,8 +39863,8 @@ function buildKey$7(_gd) {
39887
39863
  }, dateParams);
39888
39864
  }
39889
39865
  }
39890
- const getUnifiedReport = get$1((_id) => {
39891
- var _jd = _id, { businessId, report } = _jd, dateParams = __objRest(_jd, ["businessId", "report"]);
39866
+ const getUnifiedReport = get$1((_kd) => {
39867
+ var _ld = _kd, { businessId, report } = _ld, dateParams = __objRest(_ld, ["businessId", "report"]);
39892
39868
  const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
39893
39869
  return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
39894
39870
  });
@@ -39917,13 +39893,13 @@ class UnifiedReportSWRResponse {
39917
39893
  return this.swrResponse.mutate;
39918
39894
  }
39919
39895
  }
39920
- function useUnifiedReport(_kd) {
39921
- var _ld = _kd, { report } = _ld, dateParams = __objRest(_ld, ["report"]);
39896
+ function useUnifiedReport(_md) {
39897
+ var _nd = _md, { report } = _nd, dateParams = __objRest(_nd, ["report"]);
39922
39898
  const { data: auth } = useAuth();
39923
39899
  const { apiUrl } = useEnvironment();
39924
39900
  const { businessId } = useLayerContext();
39925
39901
  const swrResponse = useSWR(
39926
- () => buildKey$7(__spreadValues(__spreadProps(__spreadValues({}, auth), {
39902
+ () => buildKey$b(__spreadValues(__spreadProps(__spreadValues({}, auth), {
39927
39903
  apiUrl,
39928
39904
  businessId,
39929
39905
  report
@@ -40039,7 +40015,7 @@ class DownloadUnifiedReportSWRResponse {
40039
40015
  return this.swrResponse.error !== void 0;
40040
40016
  }
40041
40017
  }
40042
- function buildKey$6({
40018
+ function buildKey$a({
40043
40019
  access_token: accessToken,
40044
40020
  apiUrl,
40045
40021
  businessId,
@@ -40090,7 +40066,7 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
40090
40066
  const { businessId } = useLayerContext();
40091
40067
  const reportWithDateParams = useUnifiedReportWithDateParams();
40092
40068
  const rawMutationResponse = useSWRMutation(
40093
- () => buildKey$6(__spreadProps(__spreadValues({}, auth), {
40069
+ () => buildKey$a(__spreadProps(__spreadValues({}, auth), {
40094
40070
  businessId,
40095
40071
  reportWithDateParams
40096
40072
  })),
@@ -40466,7 +40442,7 @@ const useBills = () => {
40466
40442
  refetch
40467
40443
  };
40468
40444
  };
40469
- function buildKey$5({
40445
+ function buildKey$9({
40470
40446
  access_token: accessToken,
40471
40447
  apiUrl,
40472
40448
  businessId,
@@ -40600,7 +40576,7 @@ const useBillsRecordPayment = ({ refetchAllBills }) => {
40600
40576
  };
40601
40577
  }, [billsToPay, paymentDate, paymentMethod]);
40602
40578
  const createPaymentMutation = useSWRMutation(
40603
- () => buildKey$5({
40579
+ () => buildKey$9({
40604
40580
  access_token: auth == null ? void 0 : auth.access_token,
40605
40581
  apiUrl: auth == null ? void 0 : auth.apiUrl,
40606
40582
  businessId,
@@ -40929,7 +40905,7 @@ const BillsPaymentRecorded = ({
40929
40905
  ] })
40930
40906
  ] });
40931
40907
  };
40932
- function buildKey$4({
40908
+ function buildKey$8({
40933
40909
  access_token: accessToken,
40934
40910
  apiUrl,
40935
40911
  businessId,
@@ -40950,7 +40926,7 @@ const useUnpaidBillsByVendor = ({ vendorId }) => {
40950
40926
  const { data: auth } = useAuth();
40951
40927
  const { apiUrl } = useEnvironment();
40952
40928
  return useSWR(
40953
- () => buildKey$4(__spreadProps(__spreadValues({}, auth), {
40929
+ () => buildKey$8(__spreadProps(__spreadValues({}, auth), {
40954
40930
  apiUrl,
40955
40931
  businessId,
40956
40932
  vendorId
@@ -41448,19 +41424,19 @@ const VendorsProvider = ({ children }) => {
41448
41424
  const vendors = useVendors();
41449
41425
  return /* @__PURE__ */ jsxRuntime.jsx(VendorsContext.Provider, { value: vendors, children });
41450
41426
  };
41451
- const SelectVendor = (_md) => {
41452
- var _nd = _md, { withContext = true } = _nd, props = __objRest(_nd, ["withContext"]);
41427
+ const SelectVendor = (_od) => {
41428
+ var _pd = _od, { withContext = true } = _pd, props = __objRest(_pd, ["withContext"]);
41453
41429
  if (withContext) {
41454
41430
  return /* @__PURE__ */ jsxRuntime.jsx(VendorsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectVendorContent, __spreadValues({}, props)) });
41455
41431
  }
41456
41432
  return /* @__PURE__ */ jsxRuntime.jsx(SelectVendorContent, __spreadValues({}, props));
41457
41433
  };
41458
- const SelectVendorContent = (_od) => {
41459
- var _pd = _od, {
41434
+ const SelectVendorContent = (_qd) => {
41435
+ var _rd = _qd, {
41460
41436
  value,
41461
41437
  onChange,
41462
41438
  placeholder = "Select vendor"
41463
- } = _pd, props = __objRest(_pd, [
41439
+ } = _rd, props = __objRest(_rd, [
41464
41440
  "value",
41465
41441
  "onChange",
41466
41442
  "placeholder"
@@ -42227,8 +42203,8 @@ const BillsTableWithPanel = ({
42227
42203
  }
42228
42204
  );
42229
42205
  };
42230
- const Bills = (_qd) => {
42231
- var _rd = _qd, { context = true } = _rd, props = __objRest(_rd, ["context"]);
42206
+ const Bills = (_sd) => {
42207
+ var _td = _sd, { context = true } = _td, props = __objRest(_td, ["context"]);
42232
42208
  if (context) {
42233
42209
  return /* @__PURE__ */ jsxRuntime.jsx(BillsProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(BillsContent, __spreadValues({}, props)) });
42234
42210
  }
@@ -42286,8 +42262,8 @@ const getTimezoneDisplay = (date2) => {
42286
42262
  };
42287
42263
  const LINK_CLASS_NAME = "Layer__UI__Link";
42288
42264
  const Link = react.forwardRef(
42289
- function Link2(_sd, ref) {
42290
- var _td = _sd, {
42265
+ function Link2(_ud, ref) {
42266
+ var _vd = _ud, {
42291
42267
  children,
42292
42268
  size = "md",
42293
42269
  ellipsis,
@@ -42296,7 +42272,7 @@ const Link = react.forwardRef(
42296
42272
  href,
42297
42273
  target,
42298
42274
  rel
42299
- } = _td, restProps = __objRest(_td, [
42275
+ } = _vd, restProps = __objRest(_vd, [
42300
42276
  "children",
42301
42277
  "size",
42302
42278
  "ellipsis",
@@ -42821,6 +42797,18 @@ const VehicleSchema = effect.Schema.Struct({
42821
42797
  deletedAt: effect.pipe(
42822
42798
  effect.Schema.propertySignature(effect.Schema.NullishOr(effect.Schema.Date)),
42823
42799
  effect.Schema.fromKey("deleted_at")
42800
+ ),
42801
+ archivedAt: effect.pipe(
42802
+ effect.Schema.propertySignature(effect.Schema.NullishOr(effect.Schema.Date)),
42803
+ effect.Schema.fromKey("archived_at")
42804
+ ),
42805
+ isPrimary: effect.pipe(
42806
+ effect.Schema.propertySignature(effect.Schema.Boolean),
42807
+ effect.Schema.fromKey("is_primary")
42808
+ ),
42809
+ isEligibleForDeletion: effect.pipe(
42810
+ effect.Schema.propertySignature(effect.Schema.Boolean),
42811
+ effect.Schema.fromKey("is_eligible_for_deletion")
42824
42812
  )
42825
42813
  });
42826
42814
  effect.Schema.Struct({
@@ -42828,7 +42816,8 @@ effect.Schema.Struct({
42828
42816
  year: effect.Schema.Number,
42829
42817
  licensePlate: effect.Schema.String,
42830
42818
  vin: effect.Schema.String,
42831
- description: effect.Schema.String
42819
+ description: effect.Schema.String,
42820
+ isPrimary: effect.Schema.Boolean
42832
42821
  });
42833
42822
  const UpsertVehicleSchema = effect.Schema.Struct({
42834
42823
  makeAndModel: effect.pipe(
@@ -42841,7 +42830,11 @@ const UpsertVehicleSchema = effect.Schema.Struct({
42841
42830
  effect.Schema.fromKey("license_plate")
42842
42831
  ),
42843
42832
  vin: effect.Schema.NullishOr(effect.Schema.String),
42844
- description: effect.Schema.NullishOr(effect.Schema.String)
42833
+ description: effect.Schema.NullishOr(effect.Schema.String),
42834
+ isPrimary: effect.pipe(
42835
+ effect.Schema.propertySignature(effect.Schema.Boolean),
42836
+ effect.Schema.fromKey("is_primary")
42837
+ )
42845
42838
  });
42846
42839
  const CalendarDateFromSelf = effect.Schema.declare(
42847
42840
  (input) => input instanceof date.CalendarDate
@@ -42988,6 +42981,7 @@ const TripsRouteStoreContext = react.createContext(
42988
42981
  selectedVehicle: null,
42989
42982
  purposeFilter: TripPurposeFilterValue.All
42990
42983
  },
42984
+ currentTripsPage: 0,
42991
42985
  setTableFilters: () => {
42992
42986
  },
42993
42987
  navigate: {
@@ -42995,6 +42989,10 @@ const TripsRouteStoreContext = react.createContext(
42995
42989
  },
42996
42990
  toVehicleManagement: () => {
42997
42991
  }
42992
+ },
42993
+ actions: {
42994
+ setCurrentTripsPage: () => {
42995
+ }
42998
42996
  }
42999
42997
  }))
43000
42998
  );
@@ -43012,6 +43010,15 @@ function useTripsNavigation() {
43012
43010
  const store = react.useContext(TripsRouteStoreContext);
43013
43011
  return zustand.useStore(store, (state) => state.navigate);
43014
43012
  }
43013
+ function useCurrentTripsPage() {
43014
+ const store = react.useContext(TripsRouteStoreContext);
43015
+ const currentTripsPage = zustand.useStore(store, (state) => state.currentTripsPage);
43016
+ const setCurrentTripsPage = zustand.useStore(store, (state) => state.actions.setCurrentTripsPage);
43017
+ return react.useMemo(
43018
+ () => ({ currentTripsPage, setCurrentTripsPage }),
43019
+ [currentTripsPage, setCurrentTripsPage]
43020
+ );
43021
+ }
43015
43022
  function TripsRouteStoreProvider(props) {
43016
43023
  const [store] = react.useState(
43017
43024
  () => zustand.createStore((set) => ({
@@ -43024,6 +43031,7 @@ function TripsRouteStoreProvider(props) {
43024
43031
  selectedVehicle: null,
43025
43032
  purposeFilter: TripPurposeFilterValue.All
43026
43033
  },
43034
+ currentTripsPage: 0,
43027
43035
  setTableFilters: (patchFilters) => {
43028
43036
  set((state) => ({
43029
43037
  tableFilters: __spreadValues(__spreadValues({}, state.tableFilters), patchFilters)
@@ -43046,65 +43054,28 @@ function TripsRouteStoreProvider(props) {
43046
43054
  }
43047
43055
  }));
43048
43056
  }
43057
+ },
43058
+ actions: {
43059
+ setCurrentTripsPage: (page) => {
43060
+ set({ currentTripsPage: page });
43061
+ }
43049
43062
  }
43050
43063
  }))
43051
43064
  );
43052
43065
  return /* @__PURE__ */ jsxRuntime.jsx(TripsRouteStoreContext.Provider, { value: store, children: props.children });
43053
43066
  }
43054
- const getTripFormDefaultValues = (trip) => {
43055
- if (trip) {
43056
- return {
43057
- vehicle: trip.vehicle,
43058
- tripDate: trip.tripDate,
43059
- distance: trip.distance,
43060
- purpose: trip.purpose,
43061
- startAddress: trip.startAddress || "",
43062
- endAddress: trip.endAddress || "",
43063
- description: trip.description || ""
43064
- };
43065
- }
43066
- return {
43067
- vehicle: null,
43068
- tripDate: date.today(date.getLocalTimeZone()),
43069
- distance: BIG_DECIMAL_ZERO,
43070
- purpose: TripPurpose.Business,
43071
- startAddress: "",
43072
- endAddress: "",
43073
- description: ""
43074
- };
43075
- };
43076
- const validateTripForm = ({ trip }) => {
43077
- const { vehicle, tripDate, distance, purpose } = trip;
43078
- const errors = [];
43079
- if (tripDate === null) {
43080
- errors.push({ tripDate: "Trip date is a required field." });
43081
- }
43082
- if (tripDate && tripDate.compare(date.today(date.getLocalTimeZone())) > 0) {
43083
- errors.push({ tripDate: "Trip date cannot be in the future." });
43084
- }
43085
- if (!effect.BigDecimal.isPositive(distance)) {
43086
- errors.push({ distance: "Distance must be greater than zero." });
43087
- }
43088
- if (!purpose) {
43089
- errors.push({ purpose: "Purpose is a required field." });
43090
- }
43091
- if (vehicle === null) {
43092
- errors.push({ vehicle: "Vehicle is a required field." });
43067
+ function useAutoResetPageIndex(filters, data) {
43068
+ const autoResetPageIndexRef = react.useRef(false);
43069
+ const prevFiltersRef = react.useRef(filters);
43070
+ if (prevFiltersRef.current !== filters) {
43071
+ autoResetPageIndexRef.current = true;
43072
+ prevFiltersRef.current = filters;
43093
43073
  }
43094
- return errors.length > 0 ? errors : null;
43095
- };
43096
- const convertTripFormToUpsertTrip = (form) => {
43097
- var _a;
43098
- return {
43099
- vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
43100
- tripDate: form.tripDate,
43101
- distance: form.distance,
43102
- purpose: form.purpose,
43103
- startAddress: form.startAddress.trim() || null,
43104
- endAddress: form.endAddress.trim() || null,
43105
- description: form.description.trim() || null
43106
- };
43107
- };
43074
+ react.useEffect(() => {
43075
+ autoResetPageIndexRef.current = false;
43076
+ }, [data]);
43077
+ return autoResetPageIndexRef;
43078
+ }
43108
43079
  const LIST_TRIPS_TAG_KEY = "#list-trips";
43109
43080
  const ListTripsResponseSchema = effect.Schema.Struct({
43110
43081
  data: effect.Schema.Array(TripSchema),
@@ -43228,6 +43199,243 @@ function useTripsGlobalCacheActions() {
43228
43199
  );
43229
43200
  return { patchTripByKey, forceReloadTrips };
43230
43201
  }
43202
+ const ListVehiclesResponseSchema = effect.Schema.Struct({
43203
+ data: effect.Schema.Array(VehicleSchema)
43204
+ });
43205
+ const listVehicles = get$1(({ businessId, allowArchived }) => {
43206
+ const parameters = toDefinedSearchParameters({ allowArchived });
43207
+ return `/v1/businesses/${businessId}/mileage/vehicles?${parameters}`;
43208
+ });
43209
+ const VEHICLES_TAG_KEY = "#list-vehicles";
43210
+ function buildKey$7({
43211
+ access_token: accessToken,
43212
+ apiUrl,
43213
+ businessId,
43214
+ allowArchived
43215
+ }) {
43216
+ if (accessToken && apiUrl) {
43217
+ return {
43218
+ accessToken,
43219
+ apiUrl,
43220
+ businessId,
43221
+ allowArchived,
43222
+ tags: [VEHICLES_TAG_KEY]
43223
+ };
43224
+ }
43225
+ }
43226
+ class ListVehiclesSWRResponse {
43227
+ constructor(swrResponse) {
43228
+ __publicField(this, "swrResponse");
43229
+ this.swrResponse = swrResponse;
43230
+ }
43231
+ get data() {
43232
+ var _a;
43233
+ return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
43234
+ }
43235
+ get isLoading() {
43236
+ return this.swrResponse.isLoading;
43237
+ }
43238
+ get isValidating() {
43239
+ return this.swrResponse.isValidating;
43240
+ }
43241
+ get isError() {
43242
+ return this.swrResponse.error !== void 0;
43243
+ }
43244
+ }
43245
+ function useListVehicles({ allowArchived } = {}) {
43246
+ const { data } = useAuth();
43247
+ const { businessId } = useLayerContext();
43248
+ const response = useSWR(
43249
+ () => buildKey$7(__spreadProps(__spreadValues({}, data), {
43250
+ businessId,
43251
+ allowArchived
43252
+ })),
43253
+ ({ accessToken, apiUrl, businessId: businessId2, allowArchived: allowArchived2 }) => listVehicles(
43254
+ apiUrl,
43255
+ accessToken,
43256
+ {
43257
+ params: {
43258
+ businessId: businessId2,
43259
+ allowArchived: allowArchived2
43260
+ }
43261
+ }
43262
+ )().then(effect.Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
43263
+ );
43264
+ return new ListVehiclesSWRResponse(response);
43265
+ }
43266
+ const withUpdatedVehicle = (updated) => (vehicle) => vehicle.id === updated.id ? updated : vehicle;
43267
+ function useVehiclesGlobalCacheActions() {
43268
+ const { patchCache, forceReload } = useGlobalCacheActions();
43269
+ const patchVehicleByKey = react.useCallback(
43270
+ (updatedVehicle) => patchCache(
43271
+ (tags) => tags.includes(VEHICLES_TAG_KEY),
43272
+ (currentData) => {
43273
+ if (!currentData) return currentData;
43274
+ return __spreadProps(__spreadValues({}, currentData), {
43275
+ data: currentData.data.map(withUpdatedVehicle(updatedVehicle))
43276
+ });
43277
+ }
43278
+ ),
43279
+ [patchCache]
43280
+ );
43281
+ const forceReloadVehicles = react.useCallback(
43282
+ () => forceReload((tags) => tags.includes(VEHICLES_TAG_KEY)),
43283
+ [forceReload]
43284
+ );
43285
+ return { patchVehicleByKey, forceReloadVehicles };
43286
+ }
43287
+ const DELETE_TRIP_TAG_KEY = "#delete-trip";
43288
+ const deleteTrip = del(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
43289
+ function buildKey$6({
43290
+ access_token: accessToken,
43291
+ apiUrl,
43292
+ businessId,
43293
+ tripId
43294
+ }) {
43295
+ if (accessToken && apiUrl) {
43296
+ return {
43297
+ accessToken,
43298
+ apiUrl,
43299
+ businessId,
43300
+ tripId,
43301
+ tags: [DELETE_TRIP_TAG_KEY]
43302
+ };
43303
+ }
43304
+ }
43305
+ class DeleteTripSWRResponse {
43306
+ constructor(swrResponse) {
43307
+ __publicField(this, "swrResponse");
43308
+ this.swrResponse = swrResponse;
43309
+ }
43310
+ get trigger() {
43311
+ return this.swrResponse.trigger;
43312
+ }
43313
+ get isMutating() {
43314
+ return this.swrResponse.isMutating;
43315
+ }
43316
+ get isError() {
43317
+ return this.swrResponse.error !== void 0;
43318
+ }
43319
+ }
43320
+ const useDeleteTrip = ({ tripId }) => {
43321
+ const { data } = useAuth();
43322
+ const { businessId } = useLayerContext();
43323
+ const rawMutationResponse = useSWRMutation(
43324
+ () => buildKey$6(__spreadProps(__spreadValues({}, data), {
43325
+ businessId,
43326
+ tripId
43327
+ })),
43328
+ ({ accessToken, apiUrl, businessId: businessId2, tripId: tripId2 }) => {
43329
+ return deleteTrip(
43330
+ apiUrl,
43331
+ accessToken,
43332
+ { params: { businessId: businessId2, tripId: tripId2 } }
43333
+ );
43334
+ },
43335
+ {
43336
+ revalidate: false,
43337
+ throwOnError: true
43338
+ }
43339
+ );
43340
+ const mutationResponse = new DeleteTripSWRResponse(rawMutationResponse);
43341
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
43342
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
43343
+ const originalTrigger = mutationResponse.trigger;
43344
+ const stableProxiedTrigger = react.useCallback(
43345
+ (...triggerParameters) => __async(null, null, function* () {
43346
+ const triggerResult = yield originalTrigger(...triggerParameters);
43347
+ void forceReloadTrips();
43348
+ void forceReloadVehicles();
43349
+ return triggerResult;
43350
+ }),
43351
+ [originalTrigger, forceReloadTrips, forceReloadVehicles]
43352
+ );
43353
+ return new Proxy(mutationResponse, {
43354
+ get(target, prop) {
43355
+ if (prop === "trigger") {
43356
+ return stableProxiedTrigger;
43357
+ }
43358
+ return Reflect.get(target, prop);
43359
+ }
43360
+ });
43361
+ };
43362
+ function TripDeleteConfirmationModal({
43363
+ isOpen,
43364
+ onOpenChange,
43365
+ trip
43366
+ }) {
43367
+ const { trigger: deleteTrip2 } = useDeleteTrip({ tripId: trip.id });
43368
+ const onConfirm = react.useCallback(() => __async(null, null, function* () {
43369
+ yield deleteTrip2();
43370
+ }), [deleteTrip2]);
43371
+ return /* @__PURE__ */ jsxRuntime.jsx(
43372
+ BaseConfirmationModal,
43373
+ {
43374
+ isOpen,
43375
+ onOpenChange,
43376
+ title: "Delete this trip?",
43377
+ description: "This trip will be permanently deleted. This action cannot be undone.",
43378
+ onConfirm,
43379
+ confirmLabel: "Delete trip",
43380
+ cancelLabel: "Cancel",
43381
+ errorText: "Failed to delete trip. Please check your connection and try again."
43382
+ }
43383
+ );
43384
+ }
43385
+ const getTripFormDefaultValues = (trip) => {
43386
+ if (trip) {
43387
+ return {
43388
+ vehicle: trip.vehicle,
43389
+ tripDate: trip.tripDate,
43390
+ distance: trip.distance,
43391
+ purpose: trip.purpose,
43392
+ startAddress: trip.startAddress || "",
43393
+ endAddress: trip.endAddress || "",
43394
+ description: trip.description || ""
43395
+ };
43396
+ }
43397
+ return {
43398
+ vehicle: null,
43399
+ tripDate: date.today(date.getLocalTimeZone()),
43400
+ distance: BIG_DECIMAL_ZERO,
43401
+ purpose: TripPurpose.Business,
43402
+ startAddress: "",
43403
+ endAddress: "",
43404
+ description: ""
43405
+ };
43406
+ };
43407
+ const validateTripForm = ({ trip }) => {
43408
+ const { vehicle, tripDate, distance, purpose } = trip;
43409
+ const errors = [];
43410
+ if (tripDate === null) {
43411
+ errors.push({ tripDate: "Trip date is a required field." });
43412
+ }
43413
+ if (tripDate && tripDate.compare(date.today(date.getLocalTimeZone())) > 0) {
43414
+ errors.push({ tripDate: "Trip date cannot be in the future." });
43415
+ }
43416
+ if (!effect.BigDecimal.isPositive(distance)) {
43417
+ errors.push({ distance: "Distance must be greater than zero." });
43418
+ }
43419
+ if (!purpose) {
43420
+ errors.push({ purpose: "Purpose is a required field." });
43421
+ }
43422
+ if (vehicle === null) {
43423
+ errors.push({ vehicle: "Vehicle is a required field." });
43424
+ }
43425
+ return errors.length > 0 ? errors : null;
43426
+ };
43427
+ const convertTripFormToUpsertTrip = (form) => {
43428
+ var _a;
43429
+ return {
43430
+ vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
43431
+ tripDate: form.tripDate,
43432
+ distance: form.distance,
43433
+ purpose: form.purpose,
43434
+ startAddress: form.startAddress.trim() || null,
43435
+ endAddress: form.endAddress.trim() || null,
43436
+ description: form.description.trim() || null
43437
+ };
43438
+ };
43231
43439
  const UPSERT_TRIP_TAG_KEY = "#upsert-trip";
43232
43440
  var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
43233
43441
  UpsertTripMode2["Create"] = "Create";
@@ -43236,7 +43444,7 @@ var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
43236
43444
  })(UpsertTripMode || {});
43237
43445
  const createTrip = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/trips`);
43238
43446
  const updateTrip = patch(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
43239
- function buildKey$3({
43447
+ function buildKey$5({
43240
43448
  access_token: accessToken,
43241
43449
  apiUrl,
43242
43450
  businessId,
@@ -43308,7 +43516,7 @@ const useUpsertTrip = (props) => {
43308
43516
  const { mode } = props;
43309
43517
  const tripId = mode === "Update" ? props.tripId : void 0;
43310
43518
  const rawMutationResponse = useSWRMutation(
43311
- () => buildKey$3(__spreadProps(__spreadValues({}, data), {
43519
+ () => buildKey$5(__spreadProps(__spreadValues({}, data), {
43312
43520
  businessId,
43313
43521
  tripId
43314
43522
  })),
@@ -43327,6 +43535,7 @@ const useUpsertTrip = (props) => {
43327
43535
  );
43328
43536
  const mutationResponse = new UpsertTripSWRResponse(rawMutationResponse);
43329
43537
  const { patchTripByKey, forceReloadTrips } = useTripsGlobalCacheActions();
43538
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
43330
43539
  const originalTrigger = mutationResponse.trigger;
43331
43540
  const stableProxiedTrigger = react.useCallback(
43332
43541
  (...triggerParameters) => __async(null, null, function* () {
@@ -43336,9 +43545,10 @@ const useUpsertTrip = (props) => {
43336
43545
  } else {
43337
43546
  void forceReloadTrips();
43338
43547
  }
43548
+ void forceReloadVehicles();
43339
43549
  return triggerResult;
43340
43550
  }),
43341
- [originalTrigger, mode, patchTripByKey, forceReloadTrips]
43551
+ [originalTrigger, mode, patchTripByKey, forceReloadTrips, forceReloadVehicles]
43342
43552
  );
43343
43553
  return new Proxy(mutationResponse, {
43344
43554
  get(target, prop) {
@@ -43441,67 +43651,6 @@ const TripPurposeComboBox = ({ value, onValueChange, isReadOnly, className }) =>
43441
43651
  )
43442
43652
  ] });
43443
43653
  };
43444
- const ListVehiclesResponseSchema = effect.Schema.Struct({
43445
- data: effect.Schema.Array(VehicleSchema)
43446
- });
43447
- const listVehicles = get$1(({ businessId }) => {
43448
- return `/v1/businesses/${businessId}/mileage/vehicles`;
43449
- });
43450
- const VEHICLES_TAG_KEY = "#list-vehicles";
43451
- function buildKey$2({
43452
- access_token: accessToken,
43453
- apiUrl,
43454
- businessId,
43455
- query
43456
- }) {
43457
- if (accessToken && apiUrl) {
43458
- return {
43459
- accessToken,
43460
- apiUrl,
43461
- businessId,
43462
- query,
43463
- tags: [VEHICLES_TAG_KEY]
43464
- };
43465
- }
43466
- }
43467
- class ListVehiclesSWRResponse {
43468
- constructor(swrResponse) {
43469
- __publicField(this, "swrResponse");
43470
- this.swrResponse = swrResponse;
43471
- }
43472
- get data() {
43473
- var _a;
43474
- return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
43475
- }
43476
- get isLoading() {
43477
- return this.swrResponse.isLoading;
43478
- }
43479
- get isValidating() {
43480
- return this.swrResponse.isValidating;
43481
- }
43482
- get isError() {
43483
- return this.swrResponse.error !== void 0;
43484
- }
43485
- }
43486
- function useListVehicles() {
43487
- const { data } = useAuth();
43488
- const { businessId } = useLayerContext();
43489
- const response = useSWR(
43490
- () => buildKey$2(__spreadProps(__spreadValues({}, data), {
43491
- businessId
43492
- })),
43493
- ({ accessToken, apiUrl, businessId: businessId2 }) => listVehicles(
43494
- apiUrl,
43495
- accessToken,
43496
- {
43497
- params: {
43498
- businessId: businessId2
43499
- }
43500
- }
43501
- )().then(effect.Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
43502
- );
43503
- return new ListVehiclesSWRResponse(response);
43504
- }
43505
43654
  const getVehicleDisplayName = (vehicle) => `${vehicle.year} ${vehicle.makeAndModel}`;
43506
43655
  class VehicleAsOption {
43507
43656
  constructor(vehicle) {
@@ -43720,7 +43869,7 @@ const TripsTableHeaderMenu = () => {
43720
43869
  );
43721
43870
  };
43722
43871
  const COMPONENT_NAME = "TripsTable";
43723
- const getColumnConfig = (onSelectTrip) => ({
43872
+ const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => ({
43724
43873
  [
43725
43874
  "TripDate"
43726
43875
  /* TripDate */
@@ -43784,27 +43933,32 @@ const getColumnConfig = (onSelectTrip) => ({
43784
43933
  cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
43785
43934
  },
43786
43935
  [
43787
- "Expand"
43788
- /* Expand */
43936
+ "Actions"
43937
+ /* Actions */
43789
43938
  ]: {
43790
- id: "Expand",
43791
- cell: (row) => /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(ChevronRightFill, {}) })
43939
+ id: "Actions",
43940
+ cell: (row) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "3xs", children: [
43941
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { size: 20 }) }),
43942
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 20 }) })
43943
+ ] })
43792
43944
  }
43793
43945
  });
43794
43946
  const TripsTable = () => {
43795
43947
  var _a;
43796
43948
  const [isTripDrawerOpen, setIsTripDrawerOpen] = react.useState(false);
43797
43949
  const [selectedTrip, setSelectedTrip] = react.useState(null);
43950
+ const [tripToDelete, setTripToDelete] = react.useState(null);
43798
43951
  const { tableFilters, setTableFilters } = useTripsTableFilters();
43799
43952
  const { query, selectedVehicle, purposeFilter } = tableFilters;
43953
+ const { currentTripsPage, setCurrentTripsPage } = useCurrentTripsPage();
43800
43954
  const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: query });
43801
43955
  react.useEffect(() => {
43802
43956
  setTableFilters({ query: searchQuery });
43803
43957
  }, [searchQuery, setTableFilters]);
43804
43958
  const filterParams = react.useMemo(() => {
43805
43959
  const params = {};
43806
- if (searchQuery) {
43807
- params.query = searchQuery;
43960
+ if (query) {
43961
+ params.query = query;
43808
43962
  }
43809
43963
  if (selectedVehicle) {
43810
43964
  params.vehicleId = selectedVehicle.id;
@@ -43813,9 +43967,10 @@ const TripsTable = () => {
43813
43967
  params.purpose = purposeFilter;
43814
43968
  }
43815
43969
  return params;
43816
- }, [searchQuery, selectedVehicle, purposeFilter]);
43970
+ }, [query, selectedVehicle, purposeFilter]);
43817
43971
  const { data, isLoading, isError, size, setSize } = useListTrips(filterParams);
43818
43972
  const trips = react.useMemo(() => data == null ? void 0 : data.flatMap(({ data: data2 }) => data2), [data]);
43973
+ const autoResetPageIndexRef = useAutoResetPageIndex(filterParams, data);
43819
43974
  const paginationMeta = (_a = data == null ? void 0 : data[data.length - 1]) == null ? void 0 : _a.meta.pagination;
43820
43975
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
43821
43976
  const fetchMore = react.useCallback(() => {
@@ -43827,17 +43982,23 @@ const TripsTable = () => {
43827
43982
  setSelectedTrip(trip);
43828
43983
  setIsTripDrawerOpen(true);
43829
43984
  }, []);
43985
+ const onDeleteTrip = react.useCallback((trip) => {
43986
+ setTripToDelete(trip);
43987
+ }, []);
43830
43988
  const onRecordTrip = react.useCallback(() => {
43831
43989
  setSelectedTrip(null);
43832
43990
  setIsTripDrawerOpen(true);
43833
43991
  }, []);
43834
43992
  const paginationProps = react.useMemo(() => {
43835
43993
  return {
43994
+ initialPage: currentTripsPage,
43995
+ onSetPage: setCurrentTripsPage,
43836
43996
  pageSize: 20,
43837
43997
  hasMore,
43838
- fetchMore
43998
+ fetchMore,
43999
+ autoResetPageIndexRef
43839
44000
  };
43840
- }, [fetchMore, hasMore]);
44001
+ }, [currentTripsPage, setCurrentTripsPage, fetchMore, hasMore, autoResetPageIndexRef]);
43841
44002
  const handlePurposeFilterChange = react.useCallback((newPurposeFilter) => {
43842
44003
  setTableFilters({ purposeFilter: newPurposeFilter });
43843
44004
  }, [setTableFilters]);
@@ -43888,7 +44049,7 @@ const TripsTable = () => {
43888
44049
  spacing: true
43889
44050
  }
43890
44051
  );
43891
- const columnConfig = react.useMemo(() => getColumnConfig(onSelectTrip), [onSelectTrip]);
44052
+ const columnConfig = react.useMemo(() => getColumnConfig({ onSelectTrip, onDeleteTrip }), [onSelectTrip, onDeleteTrip]);
43892
44053
  const HeaderFilters = react.useCallback(() => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "sm", align: "center", children: [
43893
44054
  /* @__PURE__ */ jsxRuntime.jsx(PurposeToggle, {}),
43894
44055
  /* @__PURE__ */ jsxRuntime.jsx(VehicleFilter, {})
@@ -43957,6 +44118,18 @@ const TripsTable = () => {
43957
44118
  )
43958
44119
  ] })
43959
44120
  }
44121
+ ),
44122
+ tripToDelete && /* @__PURE__ */ jsxRuntime.jsx(
44123
+ TripDeleteConfirmationModal,
44124
+ {
44125
+ isOpen: !!tripToDelete,
44126
+ onOpenChange: (isOpen) => {
44127
+ if (!isOpen) {
44128
+ setTripToDelete(null);
44129
+ }
44130
+ },
44131
+ trip: tripToDelete
44132
+ }
43960
44133
  )
43961
44134
  ] });
43962
44135
  };
@@ -43967,7 +44140,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
43967
44140
  year: vehicle.year,
43968
44141
  licensePlate: vehicle.licensePlate || "",
43969
44142
  vin: vehicle.vin || "",
43970
- description: vehicle.description || ""
44143
+ description: vehicle.description || "",
44144
+ isPrimary: vehicle.isPrimary
43971
44145
  };
43972
44146
  }
43973
44147
  return {
@@ -43975,7 +44149,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
43975
44149
  year: Number.NaN,
43976
44150
  licensePlate: "",
43977
44151
  vin: "",
43978
- description: ""
44152
+ description: "",
44153
+ isPrimary: false
43979
44154
  };
43980
44155
  };
43981
44156
  const validateVehicleForm = ({ vehicle }) => {
@@ -43999,7 +44174,8 @@ const convertVehicleFormToUpsertVehicle = (form) => {
43999
44174
  year: form.year,
44000
44175
  licensePlate: form.licensePlate.trim() || null,
44001
44176
  vin: form.vin.trim() || null,
44002
- description: form.description.trim() || null
44177
+ description: form.description.trim() || null,
44178
+ isPrimary: form.isPrimary
44003
44179
  };
44004
44180
  };
44005
44181
  const UPSERT_VEHICLE_TAG_KEY = "#upsert-vehicle";
@@ -44010,7 +44186,7 @@ var UpsertVehicleMode = /* @__PURE__ */ ((UpsertVehicleMode2) => {
44010
44186
  })(UpsertVehicleMode || {});
44011
44187
  const createVehicle = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/vehicles`);
44012
44188
  const updateVehicle = patch(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
44013
- function buildKey$1({
44189
+ function buildKey$4({
44014
44190
  access_token: accessToken,
44015
44191
  apiUrl,
44016
44192
  businessId,
@@ -44029,6 +44205,24 @@ function buildKey$1({
44029
44205
  const UpsertVehicleReturnSchema = effect.Schema.Struct({
44030
44206
  data: VehicleSchema
44031
44207
  });
44208
+ class UpsertVehicleSWRResponse {
44209
+ constructor(swrResponse) {
44210
+ __publicField(this, "swrResponse");
44211
+ this.swrResponse = swrResponse;
44212
+ }
44213
+ get trigger() {
44214
+ return this.swrResponse.trigger;
44215
+ }
44216
+ get isMutating() {
44217
+ return this.swrResponse.isMutating;
44218
+ }
44219
+ get data() {
44220
+ return this.swrResponse.data;
44221
+ }
44222
+ get error() {
44223
+ return this.swrResponse.error;
44224
+ }
44225
+ }
44032
44226
  const CreateParamsSchema = effect.Schema.Struct({
44033
44227
  businessId: effect.Schema.UUID,
44034
44228
  vehicleId: effect.Schema.Undefined
@@ -44062,11 +44256,10 @@ function getRequestFn(mode, params) {
44062
44256
  const useUpsertVehicle = (props) => {
44063
44257
  const { data } = useAuth();
44064
44258
  const { businessId } = useLayerContext();
44065
- const { mutate } = useSWR.useSWRConfig();
44066
44259
  const { mode } = props;
44067
44260
  const vehicleId = mode === "Update" ? props.vehicleId : void 0;
44068
44261
  const rawMutationResponse = useSWRMutation(
44069
- () => buildKey$1(__spreadProps(__spreadValues({}, data), {
44262
+ () => buildKey$4(__spreadProps(__spreadValues({}, data), {
44070
44263
  businessId,
44071
44264
  vehicleId
44072
44265
  })),
@@ -44084,43 +44277,31 @@ const useUpsertVehicle = (props) => {
44084
44277
  }
44085
44278
  );
44086
44279
  const mutationResponse = new UpsertVehicleSWRResponse(rawMutationResponse);
44280
+ const { patchVehicleByKey, forceReloadVehicles } = useVehiclesGlobalCacheActions();
44281
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
44087
44282
  const originalTrigger = mutationResponse.trigger;
44088
44283
  const stableProxiedTrigger = react.useCallback(
44089
44284
  (...triggerParameters) => __async(null, null, function* () {
44090
44285
  const triggerResult = yield originalTrigger(...triggerParameters);
44091
- void mutate((key) => {
44092
- if (typeof key === "object" && key !== null && "tags" in key) {
44093
- const tags = key.tags;
44094
- return tags.includes(VEHICLES_TAG_KEY);
44095
- }
44096
- return false;
44097
- });
44286
+ if (mode === "Update") {
44287
+ void patchVehicleByKey(triggerResult.data);
44288
+ void forceReloadTrips();
44289
+ } else {
44290
+ void forceReloadVehicles();
44291
+ }
44098
44292
  return triggerResult;
44099
44293
  }),
44100
- [originalTrigger, mutate]
44294
+ [originalTrigger, mode, patchVehicleByKey, forceReloadTrips, forceReloadVehicles]
44101
44295
  );
44102
- return __spreadProps(__spreadValues({}, mutationResponse), {
44103
- trigger: stableProxiedTrigger
44296
+ return new Proxy(mutationResponse, {
44297
+ get(target, prop) {
44298
+ if (prop === "trigger") {
44299
+ return stableProxiedTrigger;
44300
+ }
44301
+ return Reflect.get(target, prop);
44302
+ }
44104
44303
  });
44105
44304
  };
44106
- class UpsertVehicleSWRResponse {
44107
- constructor(swrResponse) {
44108
- __publicField(this, "swrResponse");
44109
- this.swrResponse = swrResponse;
44110
- }
44111
- get trigger() {
44112
- return this.swrResponse.trigger;
44113
- }
44114
- get isMutating() {
44115
- return this.swrResponse.isMutating;
44116
- }
44117
- get data() {
44118
- return this.swrResponse.data;
44119
- }
44120
- get error() {
44121
- return this.swrResponse.error;
44122
- }
44123
- }
44124
44305
  const useVehicleForm = (props) => {
44125
44306
  const [submitError, setSubmitError] = react.useState(void 0);
44126
44307
  const { onSuccess, vehicle } = props;
@@ -44236,6 +44417,15 @@ const VehicleForm = (props) => {
44236
44417
  className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__Description`
44237
44418
  }
44238
44419
  ) }),
44420
+ /* @__PURE__ */ jsxRuntime.jsx(form.AppField, { name: "isPrimary", children: (field) => /* @__PURE__ */ jsxRuntime.jsx(
44421
+ field.FormSwitchField,
44422
+ {
44423
+ label: "Set as primary vehicle",
44424
+ inline: true,
44425
+ isReadOnly,
44426
+ className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__IsPrimary`
44427
+ }
44428
+ ) }),
44239
44429
  /* @__PURE__ */ jsxRuntime.jsx(VStack, { justify: "end", className: `${VEHICLE_FORM_CSS_PREFIX}__Submit`, children: /* @__PURE__ */ jsxRuntime.jsx(form.Subscribe, { selector: (state) => [state.canSubmit, state.isSubmitting], children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ jsxRuntime.jsx(
44240
44430
  Button,
44241
44431
  {
@@ -44250,6 +44440,309 @@ const VehicleForm = (props) => {
44250
44440
  ) }) })
44251
44441
  ] });
44252
44442
  };
44443
+ const ARCHIVE_VEHICLE_TAG_KEY = "#archive-vehicle";
44444
+ const ArchiveVehicleReturnSchema = effect.Schema.Struct({
44445
+ data: VehicleSchema
44446
+ });
44447
+ const archiveVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/archive`);
44448
+ function buildKey$3({
44449
+ access_token: accessToken,
44450
+ apiUrl,
44451
+ businessId,
44452
+ vehicleId
44453
+ }) {
44454
+ if (accessToken && apiUrl) {
44455
+ return {
44456
+ accessToken,
44457
+ apiUrl,
44458
+ businessId,
44459
+ vehicleId,
44460
+ tags: [ARCHIVE_VEHICLE_TAG_KEY]
44461
+ };
44462
+ }
44463
+ }
44464
+ class ArchiveVehicleSWRResponse {
44465
+ constructor(swrResponse) {
44466
+ __publicField(this, "swrResponse");
44467
+ this.swrResponse = swrResponse;
44468
+ }
44469
+ get data() {
44470
+ return this.swrResponse.data;
44471
+ }
44472
+ get trigger() {
44473
+ return this.swrResponse.trigger;
44474
+ }
44475
+ get isMutating() {
44476
+ return this.swrResponse.isMutating;
44477
+ }
44478
+ get isError() {
44479
+ return this.swrResponse.error !== void 0;
44480
+ }
44481
+ }
44482
+ const useArchiveVehicle = ({ vehicleId }) => {
44483
+ const { data } = useAuth();
44484
+ const { businessId } = useLayerContext();
44485
+ const rawMutationResponse = useSWRMutation(
44486
+ () => buildKey$3(__spreadProps(__spreadValues({}, data), {
44487
+ businessId,
44488
+ vehicleId
44489
+ })),
44490
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
44491
+ return archiveVehicle(
44492
+ apiUrl,
44493
+ accessToken,
44494
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
44495
+ ).then(effect.Schema.decodeUnknownPromise(ArchiveVehicleReturnSchema));
44496
+ },
44497
+ {
44498
+ revalidate: false,
44499
+ throwOnError: true
44500
+ }
44501
+ );
44502
+ const mutationResponse = new ArchiveVehicleSWRResponse(rawMutationResponse);
44503
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
44504
+ const originalTrigger = mutationResponse.trigger;
44505
+ const stableProxiedTrigger = react.useCallback(
44506
+ (...triggerParameters) => __async(null, null, function* () {
44507
+ const triggerResult = yield originalTrigger(...triggerParameters);
44508
+ void patchVehicleByKey(triggerResult.data);
44509
+ return triggerResult;
44510
+ }),
44511
+ [originalTrigger, patchVehicleByKey]
44512
+ );
44513
+ return new Proxy(mutationResponse, {
44514
+ get(target, prop) {
44515
+ if (prop === "trigger") {
44516
+ return stableProxiedTrigger;
44517
+ }
44518
+ return Reflect.get(target, prop);
44519
+ }
44520
+ });
44521
+ };
44522
+ function VehicleArchiveConfirmationModal({
44523
+ isOpen,
44524
+ onOpenChange,
44525
+ vehicle
44526
+ }) {
44527
+ const { trigger: archiveVehicle2 } = useArchiveVehicle({ vehicleId: vehicle.id });
44528
+ const onConfirm = react.useCallback(() => __async(null, null, function* () {
44529
+ yield archiveVehicle2();
44530
+ }), [archiveVehicle2]);
44531
+ const vehicleName = getVehicleDisplayName(vehicle);
44532
+ return /* @__PURE__ */ jsxRuntime.jsx(
44533
+ BaseConfirmationModal,
44534
+ {
44535
+ isOpen,
44536
+ onOpenChange,
44537
+ title: "Archive this vehicle?",
44538
+ description: `${vehicleName} will be hidden from your active vehicles list. You can reactivate it at any time.`,
44539
+ onConfirm,
44540
+ confirmLabel: "Archive vehicle",
44541
+ cancelLabel: "Cancel",
44542
+ errorText: "Failed to archive vehicle. Please check your connection and try again."
44543
+ }
44544
+ );
44545
+ }
44546
+ const DELETE_VEHICLE_TAG_KEY = "#delete-vehicle";
44547
+ const deleteVehicle = del(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
44548
+ function buildKey$2({
44549
+ access_token: accessToken,
44550
+ apiUrl,
44551
+ businessId,
44552
+ vehicleId
44553
+ }) {
44554
+ if (accessToken && apiUrl) {
44555
+ return {
44556
+ accessToken,
44557
+ apiUrl,
44558
+ businessId,
44559
+ vehicleId,
44560
+ tags: [DELETE_VEHICLE_TAG_KEY]
44561
+ };
44562
+ }
44563
+ }
44564
+ class DeleteVehicleSWRResponse {
44565
+ constructor(swrResponse) {
44566
+ __publicField(this, "swrResponse");
44567
+ this.swrResponse = swrResponse;
44568
+ }
44569
+ get trigger() {
44570
+ return this.swrResponse.trigger;
44571
+ }
44572
+ get isMutating() {
44573
+ return this.swrResponse.isMutating;
44574
+ }
44575
+ get isError() {
44576
+ return this.swrResponse.error !== void 0;
44577
+ }
44578
+ }
44579
+ const useDeleteVehicle = ({ vehicleId }) => {
44580
+ const { data } = useAuth();
44581
+ const { businessId } = useLayerContext();
44582
+ const rawMutationResponse = useSWRMutation(
44583
+ () => buildKey$2(__spreadProps(__spreadValues({}, data), {
44584
+ businessId,
44585
+ vehicleId
44586
+ })),
44587
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
44588
+ return deleteVehicle(
44589
+ apiUrl,
44590
+ accessToken,
44591
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
44592
+ );
44593
+ },
44594
+ {
44595
+ revalidate: false,
44596
+ throwOnError: true
44597
+ }
44598
+ );
44599
+ const mutationResponse = new DeleteVehicleSWRResponse(rawMutationResponse);
44600
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
44601
+ const originalTrigger = mutationResponse.trigger;
44602
+ const stableProxiedTrigger = react.useCallback(
44603
+ (...triggerParameters) => __async(null, null, function* () {
44604
+ const triggerResult = yield originalTrigger(...triggerParameters);
44605
+ void forceReloadVehicles();
44606
+ return triggerResult;
44607
+ }),
44608
+ [originalTrigger, forceReloadVehicles]
44609
+ );
44610
+ return new Proxy(mutationResponse, {
44611
+ get(target, prop) {
44612
+ if (prop === "trigger") {
44613
+ return stableProxiedTrigger;
44614
+ }
44615
+ return Reflect.get(target, prop);
44616
+ }
44617
+ });
44618
+ };
44619
+ function VehicleDeleteConfirmationModal({
44620
+ isOpen,
44621
+ onOpenChange,
44622
+ vehicle
44623
+ }) {
44624
+ const { trigger: deleteVehicle2 } = useDeleteVehicle({ vehicleId: vehicle.id });
44625
+ const onConfirm = react.useCallback(() => __async(null, null, function* () {
44626
+ yield deleteVehicle2();
44627
+ }), [deleteVehicle2]);
44628
+ const vehicleName = getVehicleDisplayName(vehicle);
44629
+ return /* @__PURE__ */ jsxRuntime.jsx(
44630
+ BaseConfirmationModal,
44631
+ {
44632
+ isOpen,
44633
+ onOpenChange,
44634
+ title: "Delete this vehicle?",
44635
+ description: `${vehicleName} will be permanently deleted. This action cannot be undone.`,
44636
+ onConfirm,
44637
+ confirmLabel: "Delete vehicle",
44638
+ cancelLabel: "Cancel",
44639
+ errorText: "Failed to delete vehicle. Please check your connection and try again."
44640
+ }
44641
+ );
44642
+ }
44643
+ const REACTIVATE_VEHICLE_TAG_KEY = "#reactivate-vehicle";
44644
+ const ReactivateVehicleReturnSchema = effect.Schema.Struct({
44645
+ data: VehicleSchema
44646
+ });
44647
+ const reactivateVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/reactivate`);
44648
+ function buildKey$1({
44649
+ access_token: accessToken,
44650
+ apiUrl,
44651
+ businessId,
44652
+ vehicleId
44653
+ }) {
44654
+ if (accessToken && apiUrl) {
44655
+ return {
44656
+ accessToken,
44657
+ apiUrl,
44658
+ businessId,
44659
+ vehicleId,
44660
+ tags: [REACTIVATE_VEHICLE_TAG_KEY]
44661
+ };
44662
+ }
44663
+ }
44664
+ class ReactivateVehicleSWRResponse {
44665
+ constructor(swrResponse) {
44666
+ __publicField(this, "swrResponse");
44667
+ this.swrResponse = swrResponse;
44668
+ }
44669
+ get data() {
44670
+ return this.swrResponse.data;
44671
+ }
44672
+ get trigger() {
44673
+ return this.swrResponse.trigger;
44674
+ }
44675
+ get isMutating() {
44676
+ return this.swrResponse.isMutating;
44677
+ }
44678
+ get isError() {
44679
+ return this.swrResponse.error !== void 0;
44680
+ }
44681
+ }
44682
+ const useReactivateVehicle = ({ vehicleId }) => {
44683
+ const { data } = useAuth();
44684
+ const { businessId } = useLayerContext();
44685
+ const rawMutationResponse = useSWRMutation(
44686
+ () => buildKey$1(__spreadProps(__spreadValues({}, data), {
44687
+ businessId,
44688
+ vehicleId
44689
+ })),
44690
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
44691
+ return reactivateVehicle(
44692
+ apiUrl,
44693
+ accessToken,
44694
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
44695
+ ).then(effect.Schema.decodeUnknownPromise(ReactivateVehicleReturnSchema));
44696
+ },
44697
+ {
44698
+ revalidate: false,
44699
+ throwOnError: true
44700
+ }
44701
+ );
44702
+ const mutationResponse = new ReactivateVehicleSWRResponse(rawMutationResponse);
44703
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
44704
+ const originalTrigger = mutationResponse.trigger;
44705
+ const stableProxiedTrigger = react.useCallback(
44706
+ (...triggerParameters) => __async(null, null, function* () {
44707
+ const triggerResult = yield originalTrigger(...triggerParameters);
44708
+ void patchVehicleByKey(triggerResult.data);
44709
+ return triggerResult;
44710
+ }),
44711
+ [originalTrigger, patchVehicleByKey]
44712
+ );
44713
+ return new Proxy(mutationResponse, {
44714
+ get(target, prop) {
44715
+ if (prop === "trigger") {
44716
+ return stableProxiedTrigger;
44717
+ }
44718
+ return Reflect.get(target, prop);
44719
+ }
44720
+ });
44721
+ };
44722
+ function VehicleReactivateConfirmationModal({
44723
+ isOpen,
44724
+ onOpenChange,
44725
+ vehicle
44726
+ }) {
44727
+ const { trigger: reactivateVehicle2 } = useReactivateVehicle({ vehicleId: vehicle.id });
44728
+ const onConfirm = react.useCallback(() => __async(null, null, function* () {
44729
+ yield reactivateVehicle2();
44730
+ }), [reactivateVehicle2]);
44731
+ const vehicleName = getVehicleDisplayName(vehicle);
44732
+ return /* @__PURE__ */ jsxRuntime.jsx(
44733
+ BaseConfirmationModal,
44734
+ {
44735
+ isOpen,
44736
+ onOpenChange,
44737
+ title: "Reactivate this vehicle?",
44738
+ description: `${vehicleName} will be restored to your active vehicles list and available for tracking trips.`,
44739
+ onConfirm,
44740
+ confirmLabel: "Reactivate vehicle",
44741
+ cancelLabel: "Cancel",
44742
+ errorText: "Failed to reactivate vehicle. Please check your connection and try again."
44743
+ }
44744
+ );
44745
+ }
44253
44746
  const VEHICLE_CARD_FIELDS = [
44254
44747
  { label: "Make and model", key: "makeAndModel" },
44255
44748
  { label: "Year", key: "year" },
@@ -44258,20 +44751,73 @@ const VEHICLE_CARD_FIELDS = [
44258
44751
  { label: "Description", key: "description" }
44259
44752
  ];
44260
44753
  const VehicleCard = ({ vehicle, onEdit }) => {
44261
- return /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "md", pi: "md", pb: "md", children: [
44262
- /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
44263
- /* @__PURE__ */ jsxRuntime.jsx(Heading$1, { size: "sm", ellipsis: true, children: getVehicleDisplayName(vehicle) }),
44264
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Car, { size: 20, className: "Layer__VehicleCard__icon" })
44265
- ] }),
44266
- /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", gap: "md", children: [
44267
- /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", variant: "subtle", children: label }),
44268
- /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
44269
- ] }, key)) }),
44270
- /* @__PURE__ */ jsxRuntime.jsx(Button, { variant: "text", onPress: () => onEdit(vehicle), children: "Edit vehicle" })
44271
- ] }) });
44754
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = react.useState(false);
44755
+ const [isArchiveModalOpen, setIsArchiveModalOpen] = react.useState(false);
44756
+ const [isReactivateModalOpen, setIsReactivateModalOpen] = react.useState(false);
44757
+ const vehicleName = getVehicleDisplayName(vehicle);
44758
+ const isArchived = vehicle.archivedAt !== null && vehicle.archivedAt !== void 0;
44759
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
44760
+ /* @__PURE__ */ jsxRuntime.jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxRuntime.jsxs(VStack, { pi: "md", pbs: "md", pbe: "xs", children: [
44761
+ /* @__PURE__ */ jsxRuntime.jsxs(VStack, { gap: "md", children: [
44762
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
44763
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "xs", className: "Layer__VehicleCard__Header", children: [
44764
+ /* @__PURE__ */ jsxRuntime.jsx(Heading$1, { size: "sm", ellipsis: true, children: vehicleName }),
44765
+ vehicle.isPrimary && /* @__PURE__ */ jsxRuntime.jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.INFO, children: "Primary" }),
44766
+ isArchived && /* @__PURE__ */ jsxRuntime.jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.WARNING, children: "Archived" })
44767
+ ] }),
44768
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Car, { size: 20, className: "Layer__VehicleCard__Icon" })
44769
+ ] }),
44770
+ /* @__PURE__ */ jsxRuntime.jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", gap: "md", children: [
44771
+ /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", variant: "subtle", children: label }),
44772
+ /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
44773
+ ] }, key)) })
44774
+ ] }),
44775
+ /* @__PURE__ */ jsxRuntime.jsx(VStack, { pbs: "md", pbe: "xs", children: /* @__PURE__ */ jsxRuntime.jsx(Separator, {}) }),
44776
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "3xs", justify: "end", children: [
44777
+ !isArchived && /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onPress: () => onEdit(vehicle), children: [
44778
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Edit, { size: 16 }),
44779
+ "Edit"
44780
+ ] }),
44781
+ isArchived ? /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onPress: () => setIsReactivateModalOpen(true), children: [
44782
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: 16 }),
44783
+ "Reactivate"
44784
+ ] }) : vehicle.isEligibleForDeletion ? /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onPress: () => setIsDeleteModalOpen(true), children: [
44785
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 16 }),
44786
+ "Delete"
44787
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "ghost", onPress: () => setIsArchiveModalOpen(true), children: [
44788
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Archive, { size: 16 }),
44789
+ "Archive"
44790
+ ] })
44791
+ ] })
44792
+ ] }) }),
44793
+ /* @__PURE__ */ jsxRuntime.jsx(
44794
+ VehicleDeleteConfirmationModal,
44795
+ {
44796
+ isOpen: isDeleteModalOpen,
44797
+ onOpenChange: setIsDeleteModalOpen,
44798
+ vehicle
44799
+ }
44800
+ ),
44801
+ /* @__PURE__ */ jsxRuntime.jsx(
44802
+ VehicleArchiveConfirmationModal,
44803
+ {
44804
+ isOpen: isArchiveModalOpen,
44805
+ onOpenChange: setIsArchiveModalOpen,
44806
+ vehicle
44807
+ }
44808
+ ),
44809
+ /* @__PURE__ */ jsxRuntime.jsx(
44810
+ VehicleReactivateConfirmationModal,
44811
+ {
44812
+ isOpen: isReactivateModalOpen,
44813
+ onOpenChange: setIsReactivateModalOpen,
44814
+ vehicle
44815
+ }
44816
+ )
44817
+ ] });
44272
44818
  };
44273
- const VehicleManagementGrid = ({ onEditVehicle }) => {
44274
- const { data, isLoading, isError } = useListVehicles();
44819
+ const VehicleManagementGrid = ({ onEditVehicle, showArchived }) => {
44820
+ const { data, isLoading, isError } = useListVehicles({ allowArchived: showArchived });
44275
44821
  const vehicles = react.useMemo(() => data ? asMutable(data) : void 0, [data]);
44276
44822
  if (isLoading) {
44277
44823
  return /* @__PURE__ */ jsxRuntime.jsx(VStack, { align: "center", justify: "center", pi: "lg", pb: "lg", children: /* @__PURE__ */ jsxRuntime.jsx(Loader, {}) });
@@ -44301,9 +44847,12 @@ const VehicleManagementGrid = ({ onEditVehicle }) => {
44301
44847
  }
44302
44848
  return /* @__PURE__ */ jsxRuntime.jsx(HStack, { className: "Layer__VehicleManagementGrid", children: vehicles.map((vehicle) => /* @__PURE__ */ jsxRuntime.jsx(VehicleCard, { vehicle, onEdit: onEditVehicle }, vehicle.id)) });
44303
44849
  };
44304
- const VehicleManagementDetailHeader = ({ onAddVehicle }) => {
44305
- return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
44306
- /* @__PURE__ */ jsxRuntime.jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
44850
+ const VehicleManagementDetailHeader = ({ onAddVehicle, showArchived, onShowArchivedChange }) => {
44851
+ return /* @__PURE__ */ jsxRuntime.jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", gap: "3xl", children: [
44852
+ /* @__PURE__ */ jsxRuntime.jsxs(HStack, { gap: "md", align: "center", children: [
44853
+ /* @__PURE__ */ jsxRuntime.jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
44854
+ /* @__PURE__ */ jsxRuntime.jsx(Switch, { isSelected: showArchived, onChange: onShowArchivedChange, children: /* @__PURE__ */ jsxRuntime.jsx(Span, { size: "sm", noWrap: true, children: "Show archived" }) })
44855
+ ] }),
44307
44856
  /* @__PURE__ */ jsxRuntime.jsxs(Button, { variant: "solid", onPress: onAddVehicle, children: [
44308
44857
  "Add Vehicle",
44309
44858
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { size: 14 })
@@ -44314,6 +44863,7 @@ const VehicleManagementDetail = () => {
44314
44863
  const { toTripsTable } = useTripsNavigation();
44315
44864
  const [isVehicleDrawerOpen, setIsVehicleDrawerOpen] = react.useState(false);
44316
44865
  const [selectedVehicle, setSelectedVehicle] = react.useState(void 0);
44866
+ const [showArchived, setShowArchived] = react.useState(false);
44317
44867
  const handleAddVehicle = react.useCallback(() => {
44318
44868
  setSelectedVehicle(void 0);
44319
44869
  setIsVehicleDrawerOpen(true);
@@ -44326,9 +44876,20 @@ const VehicleManagementDetail = () => {
44326
44876
  setIsVehicleDrawerOpen(false);
44327
44877
  setSelectedVehicle(void 0);
44328
44878
  }, []);
44329
- const Header3 = react.useCallback(() => {
44330
- return /* @__PURE__ */ jsxRuntime.jsx(VehicleManagementDetailHeader, { onAddVehicle: handleAddVehicle });
44331
- }, [handleAddVehicle]);
44879
+ const stateRef = react.useRef({ showArchived, setShowArchived, handleAddVehicle });
44880
+ stateRef.current = { showArchived, setShowArchived, handleAddVehicle };
44881
+ const HeaderRef = react.useRef(() => {
44882
+ const { showArchived: currentShowArchived, setShowArchived: currentSetShowArchived, handleAddVehicle: currentHandleAddVehicle } = stateRef.current;
44883
+ return /* @__PURE__ */ jsxRuntime.jsx(
44884
+ VehicleManagementDetailHeader,
44885
+ {
44886
+ onAddVehicle: currentHandleAddVehicle,
44887
+ showArchived: currentShowArchived,
44888
+ onShowArchivedChange: currentSetShowArchived
44889
+ }
44890
+ );
44891
+ });
44892
+ const Header3 = HeaderRef.current;
44332
44893
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
44333
44894
  /* @__PURE__ */ jsxRuntime.jsx(
44334
44895
  BaseDetailView,
@@ -44336,7 +44897,7 @@ const VehicleManagementDetail = () => {
44336
44897
  slots: { Header: Header3, BackIcon: BackArrow },
44337
44898
  name: "VehicleManagementDetail",
44338
44899
  onGoBack: toTripsTable,
44339
- children: /* @__PURE__ */ jsxRuntime.jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle })
44900
+ children: /* @__PURE__ */ jsxRuntime.jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle, showArchived })
44340
44901
  }
44341
44902
  ),
44342
44903
  /* @__PURE__ */ jsxRuntime.jsx(Drawer, { isOpen: isVehicleDrawerOpen, onOpenChange: setIsVehicleDrawerOpen, "aria-label": selectedVehicle ? "Vehicle details" : "Add vehicle", children: ({ close: close2 }) => /* @__PURE__ */ jsxRuntime.jsxs(VStack, { pb: "lg", children: [
@@ -44415,7 +44976,7 @@ const ProjectProfitabilityView = ({
44415
44976
  }
44416
44977
  ) }),
44417
44978
  /* @__PURE__ */ jsxRuntime.jsx(
44418
- Select$1,
44979
+ ReactSelect,
44419
44980
  {
44420
44981
  className: "Layer__category-menu Layer__select",
44421
44982
  classNamePrefix: "Layer__select",
@@ -45002,14 +45563,14 @@ const BusinessProvider = ({
45002
45563
  }
45003
45564
  );
45004
45565
  };
45005
- const LayerProvider = (_ud) => {
45006
- var _vd = _ud, {
45566
+ const LayerProvider = (_wd) => {
45567
+ var _xd = _wd, {
45007
45568
  appId,
45008
45569
  appSecret,
45009
45570
  businessAccessToken,
45010
45571
  environment,
45011
45572
  usePlaidSandbox
45012
- } = _vd, restProps = __objRest(_vd, [
45573
+ } = _xd, restProps = __objRest(_xd, [
45013
45574
  "appId",
45014
45575
  "appSecret",
45015
45576
  "businessAccessToken",