@layerfi/components 0.1.114-alpha.6 → 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.
@@ -65,12 +65,12 @@ import useSWRInfinite from "swr/infinite";
65
65
  import useSWRMutation from "swr/mutation";
66
66
  import { useStoreWithEqualityFn } from "zustand/traditional";
67
67
  import { useFloating, offset, flip, shift, autoUpdate, useHover, useFocus, useDismiss, useRole, useInteractions, useTransitionStyles, useMergeRefs, FloatingPortal } from "@floating-ui/react";
68
- import { Button as Button$2, Header as Header$3, Label as Label$1, Text as Text$1, ModalOverlay as ModalOverlay$1, Modal as Modal$1, Dialog as Dialog$1, Heading as Heading$2, Group, SearchField as SearchField$1, Input as Input$2, Form as Form$1, TextField as TextField$1, FieldError as FieldError$1, Checkbox as Checkbox$1, DateField as DateField$1, DateInput as DateInput$1, DateSegment as DateSegment$1, DatePicker as DatePicker$2, NumberField as NumberField$1, TextArea as TextArea$1, MenuTrigger, Popover as Popover$1, Menu as Menu$1, MenuItem as MenuItem$2, GridList, GridListItem, DialogTrigger, ToggleButton, SelectionIndicator, ToggleButtonGroup, Table as Table$2, Column as Column$1, Cell as Cell$1, TableHeader as TableHeader$1, TableBody as TableBody$2, Row as Row$1, Switch as Switch$1, Calendar as Calendar$1, CalendarGrid as CalendarGrid$1, CalendarGridBody as CalendarGridBody$1, CalendarCell as CalendarCell$1, CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell as CalendarHeaderCell$1, Meter as Meter$1, Link as Link$3 } from "react-aria-components";
69
- import { LoaderCircle, X as X$1, ChevronDown as ChevronDown$1, Layers2Icon, UploadCloud as UploadCloud$1, Search, ChevronLeft as ChevronLeft$1, CopyIcon, FileSpreadsheet, FileDownIcon, Minus, Check as Check$1, RefreshCcw as RefreshCcw$1, MenuIcon, ChevronRight as ChevronRight$1, PencilRuler, SearchX, Trash2, CheckIcon, AlertCircle as AlertCircle$1, TriangleAlert, List, AlertTriangle, Save as Save$1, Plus as Plus$1, HandCoins, Menu as Menu$2, Trash as Trash$1, Send, Calendar as Calendar$2, Download, Users, Milestone, Video, Clock as Clock$1, Link as Link$4, Car } from "lucide-react";
68
+ import { Button as Button$2, Header as Header$3, Label as Label$1, Text as Text$1, ModalOverlay as ModalOverlay$1, Modal as Modal$1, Dialog as Dialog$1, Heading as Heading$2, Group, SearchField as SearchField$1, Input as Input$2, Form as Form$1, TextField as TextField$1, FieldError as FieldError$1, Checkbox as Checkbox$1, DateField as DateField$1, DateInput as DateInput$1, DateSegment as DateSegment$1, DatePicker as DatePicker$2, NumberField as NumberField$1, Switch as Switch$1, TextArea as TextArea$1, MenuTrigger, Popover as Popover$1, Menu as Menu$1, MenuItem as MenuItem$2, GridList, GridListItem, DialogTrigger, ToggleButton, SelectionIndicator, ToggleButtonGroup, Table as Table$2, Column as Column$1, Cell as Cell$1, TableHeader as TableHeader$1, TableBody as TableBody$2, Row as Row$1, Calendar as Calendar$1, CalendarGrid as CalendarGrid$1, CalendarGridBody as CalendarGridBody$1, CalendarCell as CalendarCell$1, CalendarGridHeader as CalendarGridHeader$1, CalendarHeaderCell as CalendarHeaderCell$1, Meter as Meter$1, Link as Link$3 } from "react-aria-components";
69
+ import { LoaderCircle, X as X$1, ChevronDown as ChevronDown$1, Layers2Icon, UploadCloud as UploadCloud$1, Search, ChevronLeft as ChevronLeft$1, CopyIcon, FileSpreadsheet, FileDownIcon, Minus, Check as Check$1, RefreshCcw as RefreshCcw$1, MenuIcon, ChevronRight as ChevronRight$1, PencilRuler, SearchX, Trash2, CheckIcon, AlertCircle as AlertCircle$1, TriangleAlert, List, AlertTriangle, Save as Save$1, Plus as Plus$1, HandCoins, Menu as Menu$2, Trash as Trash$1, Send, Calendar as Calendar$2, Download, Users, Milestone, Video, Clock as Clock$1, Link as Link$4, Car, Edit, RotateCcw, Archive } from "lucide-react";
70
70
  import pluralize from "pluralize";
71
71
  import { mergeRefs } from "react-merge-refs";
72
72
  import useResizeObserver from "@react-hook/resize-observer";
73
- import Select$1, { components } from "react-select";
73
+ import ReactSelect, { components } from "react-select";
74
74
  import { useDropzone } from "react-dropzone";
75
75
  import { createFormHookContexts, createFormHook, useForm as useForm$1, useStore as useStore$1, revalidateLogic } from "@tanstack/react-form";
76
76
  import BaseCreatableSelect from "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-alpha.6";
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
  })),
@@ -2603,7 +2603,7 @@ const BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
2603
2603
  const getBankAccounts = get(
2604
2604
  ({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`
2605
2605
  );
2606
- function buildKey$_({
2606
+ function buildKey$12({
2607
2607
  access_token: accessToken,
2608
2608
  apiUrl,
2609
2609
  businessId
@@ -2624,7 +2624,7 @@ const useBankAccounts = () => {
2624
2624
  const { apiUrl } = useEnvironment();
2625
2625
  const { data: auth } = useAuth();
2626
2626
  const { data, error, isLoading } = useSWR(
2627
- () => buildKey$_(__spreadProps(__spreadValues({}, auth), {
2627
+ () => buildKey$12(__spreadProps(__spreadValues({}, auth), {
2628
2628
  apiUrl,
2629
2629
  businessId
2630
2630
  })),
@@ -4065,7 +4065,7 @@ class ProfitAndLossReportSWRResponse {
4065
4065
  return this.swrResponse.mutate;
4066
4066
  }
4067
4067
  }
4068
- function buildKey$Z({
4068
+ function buildKey$11({
4069
4069
  access_token: accessToken,
4070
4070
  apiUrl,
4071
4071
  businessId,
@@ -4109,7 +4109,7 @@ function useProfitAndLossReport({ startDate, endDate, tagKey, tagValues, reporti
4109
4109
  const { data } = useAuth();
4110
4110
  const { businessId } = useLayerContext();
4111
4111
  const response = useSWR(
4112
- () => buildKey$Z(__spreadProps(__spreadValues({}, data), {
4112
+ () => buildKey$11(__spreadProps(__spreadValues({}, data), {
4113
4113
  businessId,
4114
4114
  startDate,
4115
4115
  endDate,
@@ -4175,7 +4175,7 @@ class ProfitAndLossSummariesSWRResponse {
4175
4175
  return this.swrResponse.mutate;
4176
4176
  }
4177
4177
  }
4178
- function buildKey$Y({
4178
+ function buildKey$10({
4179
4179
  access_token: accessToken,
4180
4180
  apiUrl,
4181
4181
  businessId,
@@ -4222,7 +4222,7 @@ function useProfitAndLossSummaries({ startYear, startMonth, endYear, endMonth, t
4222
4222
  const { data } = useAuth();
4223
4223
  const { businessId } = useLayerContext();
4224
4224
  const response = useSWR(
4225
- () => buildKey$Y(__spreadProps(__spreadValues({}, data), {
4225
+ () => buildKey$10(__spreadProps(__spreadValues({}, data), {
4226
4226
  businessId,
4227
4227
  startYear,
4228
4228
  startMonth,
@@ -4292,7 +4292,7 @@ const useProfitAndLossGlobalInvalidator = () => {
4292
4292
  return { invalidateProfitAndLoss, debouncedInvalidateProfitAndLoss };
4293
4293
  };
4294
4294
  const CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
4295
- function buildKey$X({
4295
+ function buildKey$$({
4296
4296
  access_token: accessToken,
4297
4297
  apiUrl,
4298
4298
  businessId
@@ -4315,7 +4315,7 @@ function useCategorizeBankTransaction({
4315
4315
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
4316
4316
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
4317
4317
  const mutationResponse = useSWRMutation(
4318
- () => buildKey$X({
4318
+ () => buildKey$$({
4319
4319
  access_token: auth == null ? void 0 : auth.access_token,
4320
4320
  apiUrl: auth == null ? void 0 : auth.apiUrl,
4321
4321
  businessId
@@ -4363,7 +4363,7 @@ function useCategorizeBankTransaction({
4363
4363
  });
4364
4364
  }
4365
4365
  const MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
4366
- function buildKey$W({
4366
+ function buildKey$_({
4367
4367
  access_token: accessToken,
4368
4368
  apiUrl,
4369
4369
  businessId
@@ -4385,7 +4385,7 @@ function useMatchBankTransaction({
4385
4385
  const { mutate } = useSWRConfig();
4386
4386
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
4387
4387
  const mutationResponse = useSWRMutation(
4388
- () => buildKey$W({
4388
+ () => buildKey$_({
4389
4389
  access_token: auth == null ? void 0 : auth.access_token,
4390
4390
  apiUrl: auth == null ? void 0 : auth.apiUrl,
4391
4391
  businessId
@@ -4851,16 +4851,24 @@ const useAugmentedBankTransactions = (params) => {
4851
4851
  }
4852
4852
  return filtered;
4853
4853
  }, [filters, data]);
4854
- const updateOneLocal = (newBankTransaction) => {
4855
- if (newBankTransaction.update_categorization_rules_suggestion) {
4856
- const decodedRuleSuggestion = decodeRulesSuggestion(newBankTransaction.update_categorization_rules_suggestion);
4857
- setRuleSuggestion(decodedRuleSuggestion);
4854
+ const updateLocalBankTransactions = (newBankTransactions) => {
4855
+ const transactionsById = new Map(
4856
+ newBankTransactions.map((bt) => [bt.id, bt])
4857
+ );
4858
+ for (const bt of newBankTransactions) {
4859
+ if (bt.update_categorization_rules_suggestion) {
4860
+ const decodedRuleSuggestion = decodeRulesSuggestion(bt.update_categorization_rules_suggestion);
4861
+ setRuleSuggestion(decodedRuleSuggestion);
4862
+ }
4858
4863
  }
4859
4864
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
4860
4865
  var _a2;
4861
4866
  return __spreadProps(__spreadValues({}, page), {
4862
4867
  data: (_a2 = page.data) == null ? void 0 : _a2.map(
4863
- (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
4868
+ (bt) => {
4869
+ var _a3;
4870
+ return (_a3 = transactionsById.get(bt.id)) != null ? _a3 : bt;
4871
+ }
4864
4872
  )
4865
4873
  });
4866
4874
  });
@@ -4872,25 +4880,29 @@ const useAugmentedBankTransactions = (params) => {
4872
4880
  const categorizeWithOptimisticUpdate = (bankTransactionId, newCategory, notify) => __async(null, null, function* () {
4873
4881
  const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4874
4882
  if (existingTransaction) {
4875
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), { update_categorization_rules_suggestion: void 0, processing: true, error: void 0 }));
4883
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, existingTransaction), {
4884
+ update_categorization_rules_suggestion: void 0,
4885
+ processing: true,
4886
+ error: void 0
4887
+ })]);
4876
4888
  }
4877
4889
  return categorizeBankTransaction2(__spreadValues({
4878
4890
  bankTransactionId
4879
4891
  }, newCategory)).then((updatedTransaction) => {
4880
- updateOneLocal(__spreadProps(__spreadValues({}, updatedTransaction), {
4892
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, updatedTransaction), {
4881
4893
  processing: false,
4882
4894
  recently_categorized: true
4883
- }));
4895
+ })]);
4884
4896
  if (notify) {
4885
4897
  addToast({ content: "Transaction confirmed" });
4886
4898
  }
4887
4899
  }).catch((error) => {
4888
4900
  const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4889
4901
  if (targetedTransaction) {
4890
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
4902
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, targetedTransaction), {
4891
4903
  error: error instanceof Error ? error.message : "An unknown error occurred",
4892
4904
  processing: false
4893
- }));
4905
+ })]);
4894
4906
  }
4895
4907
  }).finally(() => {
4896
4908
  var _a2;
@@ -4900,71 +4912,76 @@ const useAugmentedBankTransactions = (params) => {
4900
4912
  const { trigger: matchBankTransaction2 } = useMatchBankTransaction({
4901
4913
  mutateBankTransactions: mutate
4902
4914
  });
4903
- const matchWithOptimisticUpdate = (bankTransactionId, suggestedMatchId, notify) => __async(null, null, function* () {
4904
- const existingTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4905
- if (existingTransaction) {
4906
- updateOneLocal(__spreadProps(__spreadValues({}, existingTransaction), {
4907
- processing: true,
4908
- error: void 0
4909
- }));
4910
- }
4911
- const transferBankTransaction = data == null ? void 0 : data.find(
4912
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
4915
+ const matchWithOptimisticUpdate = (bankTransaction, suggestedMatchId, notify) => __async(null, null, function* () {
4916
+ var _a2, _b;
4917
+ const suggestedMatch = (_a2 = bankTransaction.suggested_matches) == null ? void 0 : _a2.find(
4918
+ (sm) => sm.id === suggestedMatchId
4913
4919
  );
4914
- if (transferBankTransaction) {
4915
- updateOneLocal(__spreadProps(__spreadValues({}, transferBankTransaction), {
4920
+ const matchedTransferBankTransactionId = (_b = suggestedMatch == null ? void 0 : suggestedMatch.details) == null ? void 0 : _b.id;
4921
+ const matchedTransferBankTransaction = matchedTransferBankTransactionId ? data == null ? void 0 : data.find(({ id }) => id === matchedTransferBankTransactionId) : void 0;
4922
+ const transactionsToSetProcessing = [
4923
+ __spreadProps(__spreadValues({}, bankTransaction), { processing: true, error: void 0 })
4924
+ ];
4925
+ if (matchedTransferBankTransaction) {
4926
+ transactionsToSetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4916
4927
  processing: true,
4917
4928
  error: void 0
4918
4929
  }));
4919
4930
  }
4931
+ updateLocalBankTransactions(transactionsToSetProcessing);
4920
4932
  return matchBankTransaction2({
4921
- bankTransactionId,
4933
+ bankTransactionId: bankTransaction.id,
4922
4934
  match_id: suggestedMatchId,
4923
4935
  type: "Confirm_Match"
4924
4936
  }).then((match) => {
4925
- const matchedTransaction = data == null ? void 0 : data.find(({ id }) => id === match.bank_transaction.id);
4926
- if (matchedTransaction) {
4927
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransaction), {
4937
+ const transactionsToUpdate = [
4938
+ __spreadProps(__spreadValues({}, bankTransaction), {
4928
4939
  categorization_status: CategorizationStatus.MATCHED,
4929
4940
  match,
4930
4941
  processing: false,
4931
4942
  recently_categorized: true
4932
- }));
4933
- }
4934
- const matchedTransferTransaction = data == null ? void 0 : data.find(
4935
- ({ id, suggested_matches }) => id !== bankTransactionId && (suggested_matches == null ? void 0 : suggested_matches.some(({ id: id2 }) => id2 === suggestedMatchId))
4936
- );
4937
- if (matchedTransferTransaction) {
4938
- updateOneLocal(__spreadProps(__spreadValues({}, matchedTransferTransaction), {
4943
+ })
4944
+ ];
4945
+ if (matchedTransferBankTransaction) {
4946
+ transactionsToUpdate.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4947
+ categorization_status: CategorizationStatus.MATCHED,
4948
+ match,
4939
4949
  processing: false,
4940
4950
  recently_categorized: true
4941
4951
  }));
4942
4952
  }
4953
+ updateLocalBankTransactions(transactionsToUpdate);
4943
4954
  if (notify) {
4944
4955
  addToast({ content: "Transaction saved" });
4945
4956
  }
4946
4957
  }).catch((error) => {
4947
- const targetedTransaction = data == null ? void 0 : data.find(({ id }) => id === bankTransactionId);
4948
- if (targetedTransaction) {
4949
- updateOneLocal(__spreadProps(__spreadValues({}, targetedTransaction), {
4958
+ const transactionsToResetProcessing = [
4959
+ __spreadProps(__spreadValues({}, bankTransaction), {
4950
4960
  error: error instanceof Error ? error.message : "An unknown error occurred",
4951
4961
  processing: false
4962
+ })
4963
+ ];
4964
+ if (matchedTransferBankTransaction) {
4965
+ transactionsToResetProcessing.push(__spreadProps(__spreadValues({}, matchedTransferBankTransaction), {
4966
+ error: void 0,
4967
+ processing: false
4952
4968
  }));
4953
4969
  }
4970
+ updateLocalBankTransactions(transactionsToResetProcessing);
4954
4971
  }).finally(() => {
4955
- var _a2;
4956
- (_a2 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a2.call(eventCallbacks);
4972
+ var _a3;
4973
+ (_a3 = eventCallbacks == null ? void 0 : eventCallbacks.onTransactionCategorized) == null ? void 0 : _a3.call(eventCallbacks);
4957
4974
  });
4958
4975
  });
4959
4976
  const shouldHideAfterCategorize = () => {
4960
4977
  return (filters == null ? void 0 : filters.categorizationStatus) === DisplayState.review;
4961
4978
  };
4962
- const removeAfterCategorize = (bankTransaction) => {
4979
+ const removeAfterCategorize = (transactionIds) => {
4963
4980
  if (shouldHideAfterCategorize()) {
4964
4981
  const updatedData = rawResponseData == null ? void 0 : rawResponseData.map((page) => {
4965
4982
  var _a2;
4966
4983
  return __spreadProps(__spreadValues({}, page), {
4967
- data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => bt.id !== bankTransaction.id)
4984
+ data: (_a2 = page.data) == null ? void 0 : _a2.filter((bt) => !transactionIds.includes(bt.id))
4968
4985
  });
4969
4986
  });
4970
4987
  void mutate(updatedData, { revalidate: false });
@@ -5043,7 +5060,7 @@ const useAugmentedBankTransactions = (params) => {
5043
5060
  isError: !!responseError,
5044
5061
  categorize: categorizeWithOptimisticUpdate,
5045
5062
  match: matchWithOptimisticUpdate,
5046
- updateOneLocal,
5063
+ updateLocalBankTransactions,
5047
5064
  shouldHideAfterCategorize,
5048
5065
  removeAfterCategorize,
5049
5066
  display,
@@ -6411,7 +6428,7 @@ const getBookkeepingStatus = get(({ businessId }) => {
6411
6428
  });
6412
6429
  const BOOKKEEPING_TAG_KEY = "#bookkeeping";
6413
6430
  const BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
6414
- function buildKey$V({
6431
+ function buildKey$Z({
6415
6432
  access_token: accessToken,
6416
6433
  apiUrl,
6417
6434
  businessId
@@ -6429,7 +6446,7 @@ function useBookkeepingStatus() {
6429
6446
  const { data: auth } = useAuth();
6430
6447
  const { businessId } = useLayerContext();
6431
6448
  return useSWR(
6432
- () => buildKey$V(__spreadProps(__spreadValues({}, auth), {
6449
+ () => buildKey$Z(__spreadProps(__spreadValues({}, auth), {
6433
6450
  businessId
6434
6451
  })),
6435
6452
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBookkeepingStatus(
@@ -6469,6 +6486,50 @@ function isCategorizationEnabledForStatus(status) {
6469
6486
  }
6470
6487
  }
6471
6488
  }
6489
+ const CATEGORIES_TAG_KEY = "#categories";
6490
+ function buildKey$Y({
6491
+ access_token: accessToken,
6492
+ apiUrl,
6493
+ businessId,
6494
+ mode
6495
+ }) {
6496
+ if (accessToken && apiUrl) {
6497
+ return {
6498
+ accessToken,
6499
+ apiUrl,
6500
+ businessId,
6501
+ mode,
6502
+ tags: [CATEGORIES_TAG_KEY]
6503
+ };
6504
+ }
6505
+ }
6506
+ const getCategories = get(({ businessId, mode }) => {
6507
+ const parameters = toDefinedSearchParameters({ mode });
6508
+ return `/v1/businesses/${businessId}/categories?${parameters}`;
6509
+ });
6510
+ function useCategories({ mode } = {}) {
6511
+ const { data: auth } = useAuth();
6512
+ const { businessId } = useLayerContext();
6513
+ return useSWR(
6514
+ () => buildKey$Y(__spreadProps(__spreadValues({}, auth), {
6515
+ businessId,
6516
+ mode
6517
+ })),
6518
+ ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
6519
+ apiUrl,
6520
+ accessToken,
6521
+ {
6522
+ params: {
6523
+ businessId: businessId2,
6524
+ mode: mode2
6525
+ }
6526
+ }
6527
+ )().then(({ data }) => Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
6528
+ );
6529
+ }
6530
+ function usePreloadCategories(options2) {
6531
+ useCategories(options2);
6532
+ }
6472
6533
  const useElementSize = (callback) => {
6473
6534
  const ref = useRef(null);
6474
6535
  const resizeTimeout = useRef(null);
@@ -6596,15 +6657,15 @@ const BankTransactionsContext = createContext({
6596
6657
  isError: false,
6597
6658
  refetch: () => {
6598
6659
  },
6599
- categorize: () => Promise.resolve(void 0),
6600
- match: () => Promise.resolve(void 0),
6660
+ categorize: () => Promise.resolve(),
6661
+ match: () => Promise.resolve(),
6601
6662
  metadata: {
6602
6663
  pagination: {
6603
6664
  cursor: void 0,
6604
6665
  has_more: false
6605
6666
  }
6606
6667
  },
6607
- updateOneLocal: () => void 0,
6668
+ updateLocalBankTransactions: () => void 0,
6608
6669
  shouldHideAfterCategorize: () => false,
6609
6670
  removeAfterCategorize: () => void 0,
6610
6671
  display: DisplayState.review,
@@ -6887,7 +6948,7 @@ const useBusinessActivationDate = () => {
6887
6948
  const { business } = useLayerContext();
6888
6949
  return useMemo(() => getActivationDate(business), [business]);
6889
6950
  };
6890
- function buildKey$U({
6951
+ function buildKey$X({
6891
6952
  access_token: accessToken,
6892
6953
  apiUrl,
6893
6954
  businessId
@@ -6905,7 +6966,7 @@ function useBankTransactionsDownload() {
6905
6966
  const { data } = useAuth();
6906
6967
  const { businessId } = useLayerContext();
6907
6968
  return useSWRMutation(
6908
- () => buildKey$U(__spreadProps(__spreadValues({}, data), {
6969
+ () => buildKey$X(__spreadProps(__spreadValues({}, data), {
6909
6970
  businessId
6910
6971
  })),
6911
6972
  ({
@@ -7063,7 +7124,7 @@ const BulkCategorizeRequestSchema = Schema.Struct({
7063
7124
  transactions: Schema.Array(CategorizeTransactionRequestSchema$1)
7064
7125
  });
7065
7126
  const bulkCategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-categorize`);
7066
- function buildKey$T({
7127
+ function buildKey$W({
7067
7128
  access_token: accessToken,
7068
7129
  apiUrl,
7069
7130
  businessId
@@ -7082,7 +7143,7 @@ const useBulkCategorize = () => {
7082
7143
  const { businessId, eventCallbacks } = useLayerContext();
7083
7144
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
7084
7145
  const mutationResponse = useSWRMutation(
7085
- () => buildKey$T(__spreadProps(__spreadValues({}, data), {
7146
+ () => buildKey$W(__spreadProps(__spreadValues({}, data), {
7086
7147
  businessId
7087
7148
  })),
7088
7149
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkCategorize(
@@ -7326,50 +7387,6 @@ const Span = forwardRef(
7326
7387
  );
7327
7388
  }
7328
7389
  );
7329
- const CATEGORIES_TAG_KEY = "#categories";
7330
- function buildKey$S({
7331
- access_token: accessToken,
7332
- apiUrl,
7333
- businessId,
7334
- mode
7335
- }) {
7336
- if (accessToken && apiUrl) {
7337
- return {
7338
- accessToken,
7339
- apiUrl,
7340
- businessId,
7341
- mode,
7342
- tags: [CATEGORIES_TAG_KEY]
7343
- };
7344
- }
7345
- }
7346
- const getCategories = get(({ businessId, mode }) => {
7347
- const parameters = toDefinedSearchParameters({ mode });
7348
- return `/v1/businesses/${businessId}/categories?${parameters}`;
7349
- });
7350
- function useCategories({ mode } = {}) {
7351
- const { data: auth } = useAuth();
7352
- const { businessId } = useLayerContext();
7353
- return useSWR(
7354
- () => buildKey$S(__spreadProps(__spreadValues({}, auth), {
7355
- businessId,
7356
- mode
7357
- })),
7358
- ({ accessToken, apiUrl, businessId: businessId2, mode: mode2 }) => getCategories(
7359
- apiUrl,
7360
- accessToken,
7361
- {
7362
- params: {
7363
- businessId: businessId2,
7364
- mode: mode2
7365
- }
7366
- }
7367
- )().then(({ data }) => Schema.decodeUnknownPromise(CategoryListSchema)(data)).then((categoryList) => categoryList.categories)
7368
- );
7369
- }
7370
- function usePreloadCategories(options2) {
7371
- useCategories(options2);
7372
- }
7373
7390
  const Check = (_R) => {
7374
7391
  var _S = _R, { size = 18 } = _S, props = __objRest(_S, ["size"]);
7375
7392
  return /* @__PURE__ */ jsx(
@@ -7498,7 +7515,7 @@ function buildCustomDropdownIndicator() {
7498
7515
  components.DropdownIndicator,
7499
7516
  __spreadProps(__spreadValues({}, restProps), {
7500
7517
  className: COMBO_BOX_CLASS_NAMES.DROPDOWN_INDICATOR,
7501
- children: !isDisabled && /* @__PURE__ */ jsx(ChevronDown$1, { size: 16 })
7518
+ children: !isDisabled ? /* @__PURE__ */ jsx(ChevronDown$1, { size: 16 }) : /* @__PURE__ */ jsx(Fragment, {})
7502
7519
  })
7503
7520
  );
7504
7521
  };
@@ -7635,7 +7652,7 @@ function ComboBox(_T) {
7635
7652
  const CustomDropdownIndicatorRef = useRef(buildCustomDropdownIndicator());
7636
7653
  return /* @__PURE__ */ jsxs(VStack, { gap: "3xs", fluid: true, className: className ? `${className}__Container` : void 0, children: [
7637
7654
  /* @__PURE__ */ jsx(
7638
- Select$1,
7655
+ ReactSelect,
7639
7656
  __spreadProps(__spreadValues({
7640
7657
  inputId: effectiveInputId
7641
7658
  }, ariaProps), {
@@ -8947,7 +8964,7 @@ const BankTransactionsCategorizeAllModal = ({
8947
8964
  const { selectedIds } = useSelectedIds();
8948
8965
  const { clearSelection } = useBulkSelectionActions();
8949
8966
  const [selectedCategory, setSelectedCategory] = useState(null);
8950
- const { trigger } = useBulkCategorize();
8967
+ const { trigger, isMutating } = useBulkCategorize();
8951
8968
  const handleCategorizeModalClose = useCallback((isOpen2) => {
8952
8969
  onOpenChange(isOpen2);
8953
8970
  if (!isOpen2) {
@@ -8983,7 +9000,7 @@ const BankTransactionsCategorizeAllModal = ({
8983
9000
  title: mode === "Categorize" ? "Categorize all selected transactions?" : "Recategorize all selected transactions?",
8984
9001
  content: /* @__PURE__ */ jsxs(VStack, { gap: "xs", children: [
8985
9002
  /* @__PURE__ */ jsxs(VStack, { gap: "3xs", children: [
8986
- /* @__PURE__ */ jsx(Label, { htmlFor: categorySelectId, children: "Select category" }),
9003
+ /* @__PURE__ */ jsx(Label, { size: "sm", htmlFor: categorySelectId, children: "Select category" }),
8987
9004
  useCategorySelectDrawer ? /* @__PURE__ */ jsx(
8988
9005
  CategorySelectDrawerWithTrigger,
8989
9006
  {
@@ -8998,7 +9015,8 @@ const BankTransactionsCategorizeAllModal = ({
8998
9015
  inputId: categorySelectId,
8999
9016
  selectedValue: selectedCategory,
9000
9017
  onSelectedValueChange: setSelectedCategory,
9001
- includeSuggestedMatches: false
9018
+ includeSuggestedMatches: false,
9019
+ isDisabled: isMutating
9002
9020
  }
9003
9021
  )
9004
9022
  ] }),
@@ -9047,7 +9065,7 @@ const bulkMatchOrCategorize = post(
9047
9065
  return `/v1/businesses/${businessId}/bank-transactions/bulk-match-or-categorize?${parameters}`;
9048
9066
  }
9049
9067
  );
9050
- function buildKey$R({
9068
+ function buildKey$V({
9051
9069
  access_token: accessToken,
9052
9070
  apiUrl,
9053
9071
  businessId
@@ -9072,7 +9090,7 @@ const useBulkMatchOrCategorize = () => {
9072
9090
  return { transactions };
9073
9091
  }, [selectedIds, transactionCategories]);
9074
9092
  const mutationResponse = useSWRMutation(
9075
- () => buildKey$R(__spreadProps(__spreadValues({}, data), {
9093
+ () => buildKey$V(__spreadProps(__spreadValues({}, data), {
9076
9094
  businessId
9077
9095
  })),
9078
9096
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkMatchOrCategorize(
@@ -9142,7 +9160,7 @@ const BulkUncategorizeRequestSchema = Schema.Struct({
9142
9160
  )
9143
9161
  });
9144
9162
  const bulkUncategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-uncategorize`);
9145
- function buildKey$Q({
9163
+ function buildKey$U({
9146
9164
  access_token: accessToken,
9147
9165
  apiUrl,
9148
9166
  businessId
@@ -9161,7 +9179,7 @@ const useBulkUncategorize = () => {
9161
9179
  const { businessId, eventCallbacks } = useLayerContext();
9162
9180
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
9163
9181
  const mutationResponse = useSWRMutation(
9164
- () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
9182
+ () => buildKey$U(__spreadProps(__spreadValues({}, data), {
9165
9183
  businessId
9166
9184
  })),
9167
9185
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg }) => bulkUncategorize(
@@ -9565,7 +9583,7 @@ const mapRawCustomAccountToCustomAccount = (raw) => ({
9565
9583
  userCreated: raw.user_created
9566
9584
  });
9567
9585
  const CUSTOM_ACCOUNTS_TAG_KEY = "#custom-accounts";
9568
- function buildKey$P({
9586
+ function buildKey$T({
9569
9587
  access_token: accessToken,
9570
9588
  apiUrl,
9571
9589
  businessId,
@@ -9592,7 +9610,7 @@ function useCustomAccounts({ userCreated } = {}) {
9592
9610
  const { data } = useAuth();
9593
9611
  const { businessId } = useLayerContext();
9594
9612
  return useSWR(
9595
- () => buildKey$P(__spreadProps(__spreadValues({}, data), {
9613
+ () => buildKey$T(__spreadProps(__spreadValues({}, data), {
9596
9614
  businessId,
9597
9615
  userCreated
9598
9616
  })),
@@ -9605,7 +9623,7 @@ function useCustomAccounts({ userCreated } = {}) {
9605
9623
  )().then(({ data: data2 }) => data2 == null ? void 0 : data2.custom_accounts.map((account) => mapRawCustomAccountToCustomAccount(account)))
9606
9624
  );
9607
9625
  }
9608
- function buildKey$O({
9626
+ function buildKey$S({
9609
9627
  access_token: accessToken,
9610
9628
  apiUrl,
9611
9629
  businessId
@@ -9638,7 +9656,7 @@ function useCustomAccountParseCsv() {
9638
9656
  const { data } = useAuth();
9639
9657
  const { businessId } = useLayerContext();
9640
9658
  return useSWRMutation(
9641
- () => buildKey$O(__spreadProps(__spreadValues({}, data), {
9659
+ () => buildKey$S(__spreadProps(__spreadValues({}, data), {
9642
9660
  businessId
9643
9661
  })),
9644
9662
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { customAccountId, file } }) => parseCsv(
@@ -9883,7 +9901,7 @@ function flattenValidationErrors(errors) {
9883
9901
  );
9884
9902
  }
9885
9903
  const createCustomAccount = post(({ businessId }) => `/v1/businesses/${businessId}/custom-accounts`);
9886
- function buildKey$N({
9904
+ function buildKey$R({
9887
9905
  access_token: accessToken,
9888
9906
  apiUrl,
9889
9907
  businessId
@@ -9902,7 +9920,7 @@ function useCreateCustomAccount() {
9902
9920
  const { businessId } = useLayerContext();
9903
9921
  const { mutate } = useSWRConfig();
9904
9922
  const mutationResponse = useSWRMutation(
9905
- () => buildKey$N(__spreadProps(__spreadValues({}, data), {
9923
+ () => buildKey$R(__spreadProps(__spreadValues({}, data), {
9906
9924
  businessId
9907
9925
  })),
9908
9926
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createCustomAccount(
@@ -10439,10 +10457,63 @@ function FormNumberField({
10439
10457
  })
10440
10458
  );
10441
10459
  }
10460
+ const SWITCH_CLASS_NAME = "Layer__UI__Switch";
10461
+ const Switch = forwardRef((_Va, ref) => {
10462
+ var _Wa = _Va, {
10463
+ children,
10464
+ className
10465
+ } = _Wa, props = __objRest(_Wa, [
10466
+ "children",
10467
+ "className"
10468
+ ]);
10469
+ return /* @__PURE__ */ jsx(
10470
+ Switch$1,
10471
+ __spreadProps(__spreadValues({}, props), {
10472
+ className: classNames(SWITCH_CLASS_NAME, className),
10473
+ ref,
10474
+ children: withRenderProp(children, (node) => /* @__PURE__ */ jsxs(Fragment, { children: [
10475
+ /* @__PURE__ */ jsx("div", { slot: "indicator" }),
10476
+ node
10477
+ ] }))
10478
+ })
10479
+ );
10480
+ });
10481
+ Switch.displayName = "Switch";
10482
+ const FORM_SWITCH_FIELD_CLASSNAME = "Layer__FormSwitchField";
10483
+ function FormSwitchField({
10484
+ label,
10485
+ className,
10486
+ inline = false,
10487
+ showLabel = true,
10488
+ isReadOnly = false
10489
+ }) {
10490
+ const field = useFieldContext();
10491
+ const { name, state, handleChange } = field;
10492
+ const { value } = state;
10493
+ const additionalAriaProps = !showLabel && { "aria-label": label };
10494
+ const switchClassNames = classNames(
10495
+ FORM_SWITCH_FIELD_CLASSNAME,
10496
+ inline && `${FORM_SWITCH_FIELD_CLASSNAME}--inline`,
10497
+ className
10498
+ );
10499
+ return /* @__PURE__ */ jsx(
10500
+ Switch,
10501
+ __spreadProps(__spreadValues({
10502
+ className: switchClassNames,
10503
+ isSelected: value,
10504
+ onChange: handleChange,
10505
+ name,
10506
+ isReadOnly,
10507
+ slot: "switch"
10508
+ }, additionalAriaProps), {
10509
+ children: showLabel && /* @__PURE__ */ jsx(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
10510
+ })
10511
+ );
10512
+ }
10442
10513
  const TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
10443
10514
  const TextArea = forwardRef(
10444
- function TextArea2(_Va, ref) {
10445
- var _Wa = _Va, { resize = "none" } = _Wa, restProps = __objRest(_Wa, ["resize"]);
10515
+ function TextArea2(_Xa, ref) {
10516
+ var _Ya = _Xa, { resize = "none" } = _Ya, restProps = __objRest(_Ya, ["resize"]);
10446
10517
  const dataProperties = toDataProperties({ resize });
10447
10518
  return /* @__PURE__ */ jsx(
10448
10519
  TextArea$1,
@@ -10453,8 +10524,8 @@ const TextArea = forwardRef(
10453
10524
  );
10454
10525
  }
10455
10526
  );
10456
- function FormTextAreaField(_Xa) {
10457
- var _Ya = _Xa, { placeholder } = _Ya, props = __objRest(_Ya, ["placeholder"]);
10527
+ function FormTextAreaField(_Za) {
10528
+ var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
10458
10529
  const field = useFieldContext();
10459
10530
  const { name, state, handleChange, handleBlur } = field;
10460
10531
  const { value } = state;
@@ -10474,8 +10545,8 @@ function FormTextAreaField(_Xa) {
10474
10545
  }
10475
10546
  ) }));
10476
10547
  }
10477
- function FormTextField(_Za) {
10478
- var __a = _Za, { placeholder } = __a, props = __objRest(__a, ["placeholder"]);
10548
+ function FormTextField(_$a) {
10549
+ var _ab = _$a, { placeholder } = _ab, props = __objRest(_ab, ["placeholder"]);
10479
10550
  const field = useFieldContext();
10480
10551
  const { name, state, handleChange, handleBlur } = field;
10481
10552
  const { value } = state;
@@ -10503,6 +10574,7 @@ const { useAppForm: useRawAppForm } = createFormHook({
10503
10574
  FormCheckboxField,
10504
10575
  FormDateField,
10505
10576
  FormNumberField,
10577
+ FormSwitchField,
10506
10578
  FormTextAreaField,
10507
10579
  FormTextField
10508
10580
  },
@@ -10563,13 +10635,13 @@ const useCustomAccountForm = ({ onSuccess }) => {
10563
10635
  const isFormValid = useStore$1(form.store, (state) => state.isValid);
10564
10636
  return { form, submitError, isFormValid };
10565
10637
  };
10566
- const Input = (_$a) => {
10567
- var _ab = _$a, {
10638
+ const Input = (_bb) => {
10639
+ var _cb = _bb, {
10568
10640
  className,
10569
10641
  isInvalid,
10570
10642
  errorMessage,
10571
10643
  leftText
10572
- } = _ab, props = __objRest(_ab, [
10644
+ } = _cb, props = __objRest(_cb, [
10573
10645
  "className",
10574
10646
  "isInvalid",
10575
10647
  "errorMessage",
@@ -10615,8 +10687,8 @@ const InputGroup = ({
10615
10687
  children
10616
10688
  ] });
10617
10689
  };
10618
- const ChevronDownFill = (_bb) => {
10619
- var _cb = _bb, { size = 18 } = _cb, props = __objRest(_cb, ["size"]);
10690
+ const ChevronDownFill = (_db) => {
10691
+ var _eb = _db, { size = 18 } = _eb, props = __objRest(_eb, ["size"]);
10620
10692
  return /* @__PURE__ */ jsxs(
10621
10693
  "svg",
10622
10694
  __spreadProps(__spreadValues({
@@ -10641,6 +10713,21 @@ const ChevronDownFill = (_bb) => {
10641
10713
  })
10642
10714
  );
10643
10715
  };
10716
+ const SelectMenuPortal = (_fb) => {
10717
+ var _gb = _fb, {
10718
+ children
10719
+ } = _gb, restProps = __objRest(_gb, [
10720
+ "children"
10721
+ ]);
10722
+ const dataProperties = toDataProperties({ "react-aria-top-layer": true });
10723
+ return /* @__PURE__ */ jsx(
10724
+ components.MenuPortal,
10725
+ __spreadProps(__spreadValues({}, restProps), {
10726
+ innerProps: dataProperties,
10727
+ children
10728
+ })
10729
+ );
10730
+ };
10644
10731
  const Select = ({
10645
10732
  name,
10646
10733
  options: options2,
@@ -10664,7 +10751,7 @@ const Select = ({
10664
10751
  const DropdownIndicator = useCallback((props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDownFill, {}) })), []);
10665
10752
  return /* @__PURE__ */ jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
10666
10753
  /* @__PURE__ */ jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx(
10667
- Select$1,
10754
+ ReactSelect,
10668
10755
  {
10669
10756
  inputId,
10670
10757
  name,
@@ -10677,7 +10764,7 @@ const Select = ({
10677
10764
  onChange: (newValue) => newValue && onChange(newValue),
10678
10765
  menuPortalTarget: document.body,
10679
10766
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
10680
- components: { DropdownIndicator },
10767
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
10681
10768
  isLoading,
10682
10769
  isDisabled: disabled
10683
10770
  }
@@ -10685,8 +10772,8 @@ const Select = ({
10685
10772
  /* @__PURE__ */ jsx(DeprecatedTooltipContent, { className: "Layer__tooltip", children: errorMessage })
10686
10773
  ] });
10687
10774
  };
10688
- const ErrorText = (_db) => {
10689
- var _eb = _db, { className } = _eb, props = __objRest(_eb, ["className"]);
10775
+ const ErrorText = (_hb) => {
10776
+ var _ib = _hb, { className } = _ib, props = __objRest(_ib, ["className"]);
10690
10777
  return /* @__PURE__ */ jsx(Text, __spreadProps(__spreadValues({}, props), { status: "error", className }));
10691
10778
  };
10692
10779
  const accountTypeOptions = [
@@ -10840,7 +10927,7 @@ const CreatableSelect = ({
10840
10927
  formatCreateLabel: formatCreateLabel2,
10841
10928
  menuPortalTarget: document.body,
10842
10929
  styles: { menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 }) },
10843
- components: { DropdownIndicator },
10930
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
10844
10931
  isLoading,
10845
10932
  isDisabled: disabled,
10846
10933
  isClearable,
@@ -11025,7 +11112,7 @@ function UploadTransactionsUploadCsvStep({ selectedAccount, onSelectAccount, sel
11025
11112
  const createCustomAccountTransactions = post(
11026
11113
  ({ businessId, customAccountId }) => `/v1/businesses/${businessId}/custom-accounts/${customAccountId}/transactions`
11027
11114
  );
11028
- function buildKey$M({
11115
+ function buildKey$Q({
11029
11116
  access_token: accessToken,
11030
11117
  apiUrl,
11031
11118
  businessId
@@ -11044,7 +11131,7 @@ function useCreateCustomAccountTransactions() {
11044
11131
  const { data } = useAuth();
11045
11132
  const { businessId } = useLayerContext();
11046
11133
  return useSWRMutation(
11047
- () => buildKey$M(__spreadProps(__spreadValues({}, data), {
11134
+ () => buildKey$Q(__spreadProps(__spreadValues({}, data), {
11048
11135
  businessId
11049
11136
  })),
11050
11137
  ({ accessToken, apiUrl, businessId: businessId2 }, _a) => {
@@ -11544,8 +11631,8 @@ const BulkActionsModule = ({ slots }) => {
11544
11631
  /* @__PURE__ */ jsx(slots.BulkActions, {})
11545
11632
  ] });
11546
11633
  };
11547
- const DownloadCloud = (_fb) => {
11548
- var _gb = _fb, { size = 18 } = _gb, props = __objRest(_gb, ["size"]);
11634
+ const DownloadCloud = (_jb) => {
11635
+ var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
11549
11636
  return /* @__PURE__ */ jsxs(
11550
11637
  "svg",
11551
11638
  __spreadProps(__spreadValues({
@@ -11797,8 +11884,8 @@ function MonthCalendar({
11797
11884
  const POPOVER_CLASS_NAME = "Layer__Popover";
11798
11885
  const POPOVER_CLASS_NAMES = `Layer__Portal ${POPOVER_CLASS_NAME}`;
11799
11886
  const Popover = forwardRef(
11800
- function Popover2(_hb, ref) {
11801
- var _ib = _hb, { flexInline = false } = _ib, restProps = __objRest(_ib, ["flexInline"]);
11887
+ function Popover2(_lb, ref) {
11888
+ var _mb = _lb, { flexInline = false } = _mb, restProps = __objRest(_mb, ["flexInline"]);
11802
11889
  const dataProperties = toDataProperties({ "flex-inline": flexInline });
11803
11890
  return /* @__PURE__ */ jsx(
11804
11891
  Popover$1,
@@ -12195,8 +12282,8 @@ const BankTransactionsHeader = ({
12195
12282
  }
12196
12283
  );
12197
12284
  };
12198
- const Inbox = (_jb) => {
12199
- var _kb = _jb, { size = 18 } = _kb, props = __objRest(_kb, ["size"]);
12285
+ const Inbox = (_nb) => {
12286
+ var _ob = _nb, { size = 18 } = _ob, props = __objRest(_ob, ["size"]);
12200
12287
  return /* @__PURE__ */ jsxs(
12201
12288
  "svg",
12202
12289
  __spreadProps(__spreadValues({
@@ -12280,7 +12367,7 @@ function BankTransactionsTableEmptyStates({
12280
12367
  return /* @__PURE__ */ jsx("div", { className: "Layer__table-state-container", children: StateComponent });
12281
12368
  }
12282
12369
  const REJECT_CATEGORIZATION_RULE_SUGGESTION_TAG = "#reject-categorization-rule-suggestion";
12283
- function buildKey$L({
12370
+ function buildKey$P({
12284
12371
  access_token: accessToken,
12285
12372
  apiUrl,
12286
12373
  businessId
@@ -12301,7 +12388,7 @@ function useRejectCategorizationRulesUpdateSuggestion() {
12301
12388
  const { data: auth } = useAuth();
12302
12389
  const { businessId } = useLayerContext();
12303
12390
  const mutationResponse = useSWRMutation(
12304
- () => buildKey$L({
12391
+ () => buildKey$P({
12305
12392
  access_token: auth == null ? void 0 : auth.access_token,
12306
12393
  apiUrl: auth == null ? void 0 : auth.apiUrl,
12307
12394
  businessId
@@ -12520,7 +12607,7 @@ function useCategorizationRulesGlobalCacheActions() {
12520
12607
  return { patchCategorizationRuleByKey, forceReloadCategorizationRules };
12521
12608
  }
12522
12609
  const CREATE_CATEGORIZATION_RULE_TAG = "#create-categorization-rule";
12523
- function buildKey$K({
12610
+ function buildKey$O({
12524
12611
  access_token: accessToken,
12525
12612
  apiUrl,
12526
12613
  businessId
@@ -12548,7 +12635,7 @@ function useCreateCategorizationRule() {
12548
12635
  const { invalidatePnlDetailLines } = usePnlDetailLinesInvalidator();
12549
12636
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
12550
12637
  const mutationResponse = useSWRMutation(
12551
- () => buildKey$K({
12638
+ () => buildKey$O({
12552
12639
  access_token: auth == null ? void 0 : auth.access_token,
12553
12640
  apiUrl: auth == null ? void 0 : auth.apiUrl,
12554
12641
  businessId
@@ -12678,8 +12765,8 @@ function asMutable(a) {
12678
12765
  const CSS_PREFIX$1 = "Layer__UI__Table";
12679
12766
  const getClassName = (component, additionalClassNames, withHidden) => classNames(`${CSS_PREFIX$1}-${component}`, withHidden && `${CSS_PREFIX$1}-${component}--hidden`, additionalClassNames);
12680
12767
  const Table$1 = forwardRef(
12681
- (_lb, ref) => {
12682
- var _mb = _lb, { children, className } = _mb, restProps = __objRest(_mb, ["children", "className"]);
12768
+ (_pb, ref) => {
12769
+ var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
12683
12770
  return /* @__PURE__ */ jsx(
12684
12771
  Table$2,
12685
12772
  __spreadProps(__spreadValues({
@@ -12692,8 +12779,8 @@ const Table$1 = forwardRef(
12692
12779
  }
12693
12780
  );
12694
12781
  Table$1.displayName = "Table";
12695
- const TableHeaderInner = (_nb, ref) => {
12696
- var _ob = _nb, { children, className, hideHeader } = _ob, restProps = __objRest(_ob, ["children", "className", "hideHeader"]);
12782
+ const TableHeaderInner = (_rb, ref) => {
12783
+ var _sb = _rb, { children, className, hideHeader } = _sb, restProps = __objRest(_sb, ["children", "className", "hideHeader"]);
12697
12784
  return /* @__PURE__ */ jsx(
12698
12785
  TableHeader$1,
12699
12786
  __spreadProps(__spreadValues({
@@ -12706,8 +12793,8 @@ const TableHeaderInner = (_nb, ref) => {
12706
12793
  };
12707
12794
  const TableHeader = forwardRef(TableHeaderInner);
12708
12795
  TableHeader.displayName = "TableHeader";
12709
- const TableBodyInner = (_pb, ref) => {
12710
- var _qb = _pb, { children, className } = _qb, restProps = __objRest(_qb, ["children", "className"]);
12796
+ const TableBodyInner = (_tb, ref) => {
12797
+ var _ub = _tb, { children, className } = _ub, restProps = __objRest(_ub, ["children", "className"]);
12711
12798
  return /* @__PURE__ */ jsx(
12712
12799
  TableBody$2,
12713
12800
  __spreadProps(__spreadValues({
@@ -12720,8 +12807,8 @@ const TableBodyInner = (_pb, ref) => {
12720
12807
  };
12721
12808
  const TableBody$1 = forwardRef(TableBodyInner);
12722
12809
  TableBody$1.displayName = "TableBody";
12723
- const RowInner = (_rb, ref) => {
12724
- var _sb = _rb, { children, className, depth = 0 } = _sb, restProps = __objRest(_sb, ["children", "className", "depth"]);
12810
+ const RowInner = (_vb, ref) => {
12811
+ var _wb = _vb, { children, className, depth = 0 } = _wb, restProps = __objRest(_wb, ["children", "className", "depth"]);
12725
12812
  const dataProperties = toDataProperties({ depth });
12726
12813
  return /* @__PURE__ */ jsx(
12727
12814
  Row$1,
@@ -12736,8 +12823,8 @@ const RowInner = (_rb, ref) => {
12736
12823
  const Row = forwardRef(RowInner);
12737
12824
  Row.displayName = "Row";
12738
12825
  const Column = forwardRef(
12739
- (_tb, ref) => {
12740
- var _ub = _tb, { children, className, textAlign = "left" } = _ub, restProps = __objRest(_ub, ["children", "className", "textAlign"]);
12826
+ (_xb, ref) => {
12827
+ var _yb = _xb, { children, className, textAlign = "left" } = _yb, restProps = __objRest(_yb, ["children", "className", "textAlign"]);
12741
12828
  const dataProperties = toDataProperties({ "text-align": textAlign });
12742
12829
  return /* @__PURE__ */ jsx(
12743
12830
  Column$1,
@@ -12752,8 +12839,8 @@ const Column = forwardRef(
12752
12839
  );
12753
12840
  Column.displayName = "Column";
12754
12841
  const Cell = forwardRef(
12755
- (_vb, ref) => {
12756
- var _wb = _vb, { children, className } = _wb, restProps = __objRest(_wb, ["children", "className"]);
12842
+ (_zb, ref) => {
12843
+ var _Ab = _zb, { children, className } = _Ab, restProps = __objRest(_Ab, ["children", "className"]);
12757
12844
  return /* @__PURE__ */ jsx(
12758
12845
  Cell$1,
12759
12846
  __spreadProps(__spreadValues({
@@ -12778,7 +12865,7 @@ const DEFAULT_NUM_ROWS = 15;
12778
12865
  const HEADER_HEIGHT = 52;
12779
12866
  const DEFAULT_TABLE_HEIGHT = DEFAULT_ROW_HEIGHT * DEFAULT_NUM_ROWS + HEADER_HEIGHT - 2;
12780
12867
  const CSS_PREFIX = "Layer__UI__VirtualizedTable";
12781
- const EMPTY_ARRAY$3 = [];
12868
+ const EMPTY_ARRAY$2 = [];
12782
12869
  const VirtualizedDataTable = ({
12783
12870
  columnConfig,
12784
12871
  data,
@@ -12803,7 +12890,7 @@ const VirtualizedDataTable = ({
12803
12890
  }, [data, height, rowHeight, shrinkHeightToFitRows]);
12804
12891
  const columnHelper = createColumnHelper();
12805
12892
  const columns = Object.values(columnConfig);
12806
- const tableData = data != null ? data : EMPTY_ARRAY$3;
12893
+ const tableData = data != null ? data : EMPTY_ARRAY$2;
12807
12894
  const columnDefs = columns.map((col) => {
12808
12895
  return columnHelper.display({
12809
12896
  id: col.id,
@@ -13094,7 +13181,7 @@ const useSaveBankTransactionRow = () => {
13094
13181
  return;
13095
13182
  }
13096
13183
  if (isSuggestedMatchAsOption(selectedCategory)) {
13097
- return matchBankTransaction2(bankTransaction.id, selectedCategory.original.id);
13184
+ return matchBankTransaction2(bankTransaction, selectedCategory.original.id);
13098
13185
  }
13099
13186
  if (isSplitAsOption(selectedCategory)) {
13100
13187
  const splitCategorizationRequest = buildCategorizeBankTransactionPayloadForSplit(selectedCategory.original);
@@ -13130,8 +13217,8 @@ function useDelayedVisibility({
13130
13217
  );
13131
13218
  return { isVisible };
13132
13219
  }
13133
- const File = (_xb) => {
13134
- var _yb = _xb, { size = 12 } = _yb, props = __objRest(_yb, ["size"]);
13220
+ const File = (_Bb) => {
13221
+ var _Cb = _Bb, { size = 12 } = _Cb, props = __objRest(_Cb, ["size"]);
13135
13222
  return /* @__PURE__ */ jsxs(
13136
13223
  "svg",
13137
13224
  __spreadProps(__spreadValues({
@@ -13214,14 +13301,14 @@ const variants = {
13214
13301
  }
13215
13302
  }
13216
13303
  };
13217
- const AnimatedPresenceDiv = (_zb) => {
13218
- var _Ab = _zb, {
13304
+ const AnimatedPresenceDiv = (_Db) => {
13305
+ var _Eb = _Db, {
13219
13306
  children,
13220
13307
  variant,
13221
13308
  isOpen,
13222
13309
  slotProps = { AnimatePresence: { initial: false } },
13223
13310
  key
13224
- } = _Ab, props = __objRest(_Ab, [
13311
+ } = _Eb, props = __objRest(_Eb, [
13225
13312
  "children",
13226
13313
  "variant",
13227
13314
  "isOpen",
@@ -13296,7 +13383,7 @@ const getBookkeepingPeriods = get(({ businessId }) => {
13296
13383
  return `/v1/businesses/${businessId}/bookkeeping/periods`;
13297
13384
  });
13298
13385
  const BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
13299
- function buildKey$J({
13386
+ function buildKey$N({
13300
13387
  access_token: accessToken,
13301
13388
  apiUrl,
13302
13389
  businessId,
@@ -13317,7 +13404,7 @@ function useBookkeepingPeriods() {
13317
13404
  const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
13318
13405
  const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
13319
13406
  const swrResponse = useSWR(
13320
- () => buildKey$J(__spreadProps(__spreadValues({}, auth), {
13407
+ () => buildKey$N(__spreadProps(__spreadValues({}, auth), {
13321
13408
  businessId,
13322
13409
  isActiveOrPaused
13323
13410
  })),
@@ -13341,8 +13428,8 @@ function useBookkeepingPeriods() {
13341
13428
  }
13342
13429
  });
13343
13430
  }
13344
- const Clock = (_Bb) => {
13345
- var _Cb = _Bb, { size = 18 } = _Cb, props = __objRest(_Cb, ["size"]);
13431
+ const Clock = (_Fb) => {
13432
+ var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
13346
13433
  return /* @__PURE__ */ jsxs(
13347
13434
  "svg",
13348
13435
  __spreadProps(__spreadValues({
@@ -13668,8 +13755,8 @@ const useSplitsForm = ({
13668
13755
  saveLocalSplitsToCategoryStore
13669
13756
  };
13670
13757
  };
13671
- const ScissorsFullOpen = (_Db) => {
13672
- var _Eb = _Db, { size = 12 } = _Eb, props = __objRest(_Eb, ["size"]);
13758
+ const ScissorsFullOpen = (_Hb) => {
13759
+ var _Ib = _Hb, { size = 12 } = _Ib, props = __objRest(_Ib, ["size"]);
13673
13760
  return /* @__PURE__ */ jsx(
13674
13761
  "svg",
13675
13762
  __spreadProps(__spreadValues({
@@ -13734,8 +13821,8 @@ const ScissorsFullOpen = (_Db) => {
13734
13821
  })
13735
13822
  );
13736
13823
  };
13737
- const Trash = (_Fb) => {
13738
- var _Gb = _Fb, { size = 18 } = _Gb, props = __objRest(_Gb, ["size"]);
13824
+ const Trash = (_Jb) => {
13825
+ var _Kb = _Jb, { size = 18 } = _Kb, props = __objRest(_Kb, ["size"]);
13739
13826
  return /* @__PURE__ */ jsxs(
13740
13827
  "svg",
13741
13828
  __spreadProps(__spreadValues({
@@ -13797,7 +13884,7 @@ const useReceipts = ({
13797
13884
  const { businessId } = useLayerContext();
13798
13885
  const { apiUrl } = useEnvironment();
13799
13886
  const { data: auth } = useAuth();
13800
- const { updateOneLocal: updateBankTransaction } = useBankTransactionsContext();
13887
+ const { updateLocalBankTransactions } = useBankTransactionsContext();
13801
13888
  const [receiptUrls, setReceiptUrls] = useState([]);
13802
13889
  useEffect(() => {
13803
13890
  if (isActive && receiptUrls.length === 0 && hasReceipts(bankTransaction)) {
@@ -13853,10 +13940,10 @@ const useReceipts = ({
13853
13940
  documentType: "RECEIPT"
13854
13941
  });
13855
13942
  yield fetchDocuments();
13856
- 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) {
13857
- updateBankTransaction(__spreadProps(__spreadValues({}, bankTransaction), {
13943
+ 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) {
13944
+ updateLocalBankTransactions([__spreadProps(__spreadValues({}, bankTransaction), {
13858
13945
  document_ids: [result.data.id]
13859
- }));
13946
+ })]);
13860
13947
  }
13861
13948
  } catch (_err) {
13862
13949
  const newReceiptUrls = receipts.map((url) => {
@@ -13930,8 +14017,8 @@ const ReceiptsProvider = ({
13930
14017
  const contextData = useReceipts({ bankTransaction, isActive });
13931
14018
  return /* @__PURE__ */ jsx(ReceiptsContext.Provider, { value: contextData, children });
13932
14019
  };
13933
- const Eye = (_Hb) => {
13934
- var _Ib = _Hb, { size = 18 } = _Ib, props = __objRest(_Ib, ["size"]);
14020
+ const Eye = (_Lb) => {
14021
+ var _Mb = _Lb, { size = 18 } = _Mb, props = __objRest(_Mb, ["size"]);
13935
14022
  return /* @__PURE__ */ jsx(
13936
14023
  "svg",
13937
14024
  __spreadProps(__spreadValues({
@@ -14067,11 +14154,11 @@ const FileThumb = ({
14067
14154
  }
14068
14155
  );
14069
14156
  };
14070
- const TextButton = (_Jb) => {
14071
- var _Kb = _Jb, {
14157
+ const TextButton = (_Nb) => {
14158
+ var _Ob = _Nb, {
14072
14159
  className,
14073
14160
  children
14074
- } = _Kb, props = __objRest(_Kb, [
14161
+ } = _Ob, props = __objRest(_Ob, [
14075
14162
  "className",
14076
14163
  "children"
14077
14164
  ]);
@@ -14155,8 +14242,8 @@ const openReceiptInNewTab = (url, index) => (e) => {
14155
14242
  `);
14156
14243
  }
14157
14244
  };
14158
- const BankTransactionReceiptsWithProvider = forwardRef((_Lb, ref) => {
14159
- var _Mb = _Lb, { bankTransaction, isActive } = _Mb, props = __objRest(_Mb, ["bankTransaction", "isActive"]);
14245
+ const BankTransactionReceiptsWithProvider = forwardRef((_Pb, ref) => {
14246
+ var _Qb = _Pb, { bankTransaction, isActive } = _Qb, props = __objRest(_Qb, ["bankTransaction", "isActive"]);
14160
14247
  return /* @__PURE__ */ jsx(ReceiptsProvider, { bankTransaction, isActive, children: /* @__PURE__ */ jsx(BankTransactionReceipts, __spreadProps(__spreadValues({}, props), { ref })) });
14161
14248
  });
14162
14249
  BankTransactionReceiptsWithProvider.displayName = "BankTransactionReceiptsWithProvider";
@@ -14323,8 +14410,8 @@ const transformCurrencyValue = (rawValue) => {
14323
14410
  }
14324
14411
  return cleaned;
14325
14412
  };
14326
- const AmountInput = (_Nb) => {
14327
- var _Ob = _Nb, {
14413
+ const AmountInput = (_Rb) => {
14414
+ var _Sb = _Rb, {
14328
14415
  onChange,
14329
14416
  className,
14330
14417
  leftText,
@@ -14332,7 +14419,7 @@ const AmountInput = (_Nb) => {
14332
14419
  isInvalid,
14333
14420
  badge,
14334
14421
  placeholder = "$0.00"
14335
- } = _Ob, props = __objRest(_Ob, [
14422
+ } = _Sb, props = __objRest(_Sb, [
14336
14423
  "onChange",
14337
14424
  "className",
14338
14425
  "leftText",
@@ -14652,7 +14739,7 @@ const ToggleOption = ({
14652
14739
  ] });
14653
14740
  };
14654
14741
  const GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
14655
- function buildKey$I({
14742
+ function buildKey$M({
14656
14743
  access_token: accessToken,
14657
14744
  apiUrl,
14658
14745
  businessId,
@@ -14672,7 +14759,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
14672
14759
  const { data: auth } = useAuth();
14673
14760
  const { businessId } = useLayerContext();
14674
14761
  return useSWR(
14675
- () => buildKey$I(__spreadProps(__spreadValues({}, auth), {
14762
+ () => buildKey$M(__spreadProps(__spreadValues({}, auth), {
14676
14763
  businessId,
14677
14764
  bankTransactionId
14678
14765
  })),
@@ -14684,7 +14771,25 @@ function useBankTransactionMetadata({ bankTransactionId }) {
14684
14771
  );
14685
14772
  }
14686
14773
  const UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
14687
- function buildKey$H({
14774
+ class UpdateBankTransactionMetadataSWRResponse {
14775
+ constructor(swrResponse) {
14776
+ __publicField(this, "swrResponse");
14777
+ this.swrResponse = swrResponse;
14778
+ }
14779
+ get data() {
14780
+ return this.swrResponse.data;
14781
+ }
14782
+ get trigger() {
14783
+ return this.swrResponse.trigger;
14784
+ }
14785
+ get isMutating() {
14786
+ return this.swrResponse.isMutating;
14787
+ }
14788
+ get isError() {
14789
+ return this.swrResponse.error !== void 0;
14790
+ }
14791
+ }
14792
+ function buildKey$L({
14688
14793
  access_token: accessToken,
14689
14794
  apiUrl,
14690
14795
  businessId,
@@ -14704,8 +14809,8 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
14704
14809
  const { data: auth } = useAuth();
14705
14810
  const { businessId } = useLayerContext();
14706
14811
  const { mutate } = useSWRConfig();
14707
- const mutationResponse = useSWRMutation(
14708
- () => buildKey$H({
14812
+ const rawMutationResponse = useSWRMutation(
14813
+ () => buildKey$L({
14709
14814
  access_token: auth == null ? void 0 : auth.access_token,
14710
14815
  apiUrl: auth == null ? void 0 : auth.apiUrl,
14711
14816
  businessId,
@@ -14730,6 +14835,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
14730
14835
  throwOnError: false
14731
14836
  }
14732
14837
  );
14838
+ const mutationResponse = new UpdateBankTransactionMetadataSWRResponse(rawMutationResponse);
14733
14839
  const { trigger: originalTrigger } = mutationResponse;
14734
14840
  const stableProxiedTrigger = useCallback(
14735
14841
  (...triggerParameters) => __async(null, null, function* () {
@@ -14755,28 +14861,44 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
14755
14861
  });
14756
14862
  }
14757
14863
  const useBankTransactionMemo = ({ bankTransactionId }) => {
14758
- const { trigger: updateBankTransactionMetadata2 } = useUpdateBankTransactionMetadata({ bankTransactionId });
14759
- const { data: bankTransactionMetadata } = useBankTransactionMetadata({ bankTransactionId });
14864
+ const {
14865
+ trigger: updateBankTransactionMetadata2,
14866
+ isMutating: isUpdatingMemo,
14867
+ isError: isErrorUpdatingMemo,
14868
+ data: updateResult
14869
+ } = useUpdateBankTransactionMetadata({ bankTransactionId });
14870
+ const { data: bankTransactionMetadata, mutate: mutateBankTransactionMetadata } = useBankTransactionMetadata({ bankTransactionId });
14760
14871
  const form = useForm$1({
14761
14872
  defaultValues: {
14762
14873
  memo: bankTransactionMetadata == null ? void 0 : bankTransactionMetadata.memo
14763
14874
  },
14764
14875
  onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
14765
- var _a;
14876
+ var _a, _b;
14766
14877
  if (value.memo !== void 0 && form.state.isDirty) {
14767
- yield updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" });
14768
- form.reset(value);
14878
+ const result = yield mutateBankTransactionMetadata(
14879
+ updateBankTransactionMetadata2({ memo: (_a = value.memo) != null ? _a : "" }),
14880
+ { optimisticData: { memo: (_b = value.memo) != null ? _b : "" }, revalidate: false }
14881
+ );
14882
+ if (result !== void 0) {
14883
+ form.reset(value);
14884
+ }
14769
14885
  }
14770
14886
  })
14771
14887
  });
14772
- return form;
14888
+ const isSaved = !isUpdatingMemo && !isErrorUpdatingMemo && updateResult !== void 0 && !form.state.isDirty;
14889
+ return useMemo(() => ({
14890
+ form,
14891
+ isUpdatingMemo,
14892
+ isErrorUpdatingMemo,
14893
+ isSaved
14894
+ }), [form, isErrorUpdatingMemo, isUpdatingMemo, isSaved]);
14773
14895
  };
14774
- const Textarea = (_Pb) => {
14775
- var _Qb = _Pb, {
14896
+ const Textarea = (_Tb) => {
14897
+ var _Ub = _Tb, {
14776
14898
  className,
14777
14899
  isInvalid,
14778
14900
  errorMessage
14779
- } = _Qb, props = __objRest(_Qb, [
14901
+ } = _Ub, props = __objRest(_Ub, [
14780
14902
  "className",
14781
14903
  "isInvalid",
14782
14904
  "errorMessage"
@@ -14792,24 +14914,26 @@ const Textarea = (_Pb) => {
14792
14914
  ] });
14793
14915
  };
14794
14916
  const BankTransactionMemo = ({ bankTransactionId }) => {
14795
- const form = useBankTransactionMemo({ bankTransactionId });
14917
+ const { form, isUpdatingMemo, isErrorUpdatingMemo, isSaved } = useBankTransactionMemo({ bankTransactionId });
14796
14918
  return /* @__PURE__ */ jsx("form", { onBlur: () => void form.handleSubmit(), children: /* @__PURE__ */ jsx(form.Field, { name: "memo", children: (field) => {
14797
14919
  var _a;
14798
- return /* @__PURE__ */ jsx(
14799
- InputGroup,
14800
- {
14801
- name: "memo",
14802
- children: /* @__PURE__ */ jsx(
14803
- Textarea,
14804
- {
14805
- name: "memo",
14806
- placeholder: "Add description",
14807
- value: (_a = field.state.value) != null ? _a : void 0,
14808
- onChange: (e) => field.handleChange(e.target.value)
14809
- }
14810
- )
14811
- }
14812
- );
14920
+ return /* @__PURE__ */ jsxs(VStack, { gap: "3xs", children: [
14921
+ /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "baseline", children: [
14922
+ /* @__PURE__ */ jsx(Label, { htmlFor: "memo", size: "sm", weight: "bold", children: "Description" }),
14923
+ isUpdatingMemo && /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", variant: "subtle", children: "Saving..." }),
14924
+ !isUpdatingMemo && isSaved && /* @__PURE__ */ jsx(Span, { size: "sm", status: "success", children: "Saved" }),
14925
+ !isUpdatingMemo && !isSaved && isErrorUpdatingMemo && /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", status: "error", children: "Error saving" })
14926
+ ] }),
14927
+ /* @__PURE__ */ jsx(
14928
+ Textarea,
14929
+ {
14930
+ name: "memo",
14931
+ placeholder: "Add description",
14932
+ value: (_a = field.state.value) != null ? _a : void 0,
14933
+ onChange: (e) => field.handleChange(e.target.value)
14934
+ }
14935
+ )
14936
+ ] });
14813
14937
  } }) });
14814
14938
  };
14815
14939
  const range$1 = (start, end) => {
@@ -14867,7 +14991,7 @@ function useMinMutatingMutation({
14867
14991
  });
14868
14992
  }
14869
14993
  const SET_METADATA_ON_BANK_TRANSACTION_TAG_KEY = "#set-metadata-on-bank-transaction";
14870
- function buildKey$G({
14994
+ function buildKey$K({
14871
14995
  access_token: accessToken,
14872
14996
  apiUrl,
14873
14997
  businessId,
@@ -14893,7 +15017,7 @@ function useSetMetadataOnBankTransaction({
14893
15017
  const { data } = useAuth();
14894
15018
  const { businessId } = useLayerContext();
14895
15019
  const mutationResponse = useSWRMutation(
14896
- () => buildKey$G(__spreadProps(__spreadValues({}, data), {
15020
+ () => buildKey$K(__spreadProps(__spreadValues({}, data), {
14897
15021
  businessId,
14898
15022
  bankTransactionId
14899
15023
  })),
@@ -15476,7 +15600,7 @@ function BankTransactionCustomerVendorVisibilityProvider({
15476
15600
  }
15477
15601
  const REMOVE_TAG_FROM_BANK_TRANSACTION_TAG_KEY = "#remove-tag-from-bank-transaction";
15478
15602
  const removeTagFromBankTransaction = del(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
15479
- function buildKey$F({
15603
+ function buildKey$J({
15480
15604
  access_token: accessToken,
15481
15605
  apiUrl,
15482
15606
  businessId,
@@ -15496,7 +15620,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
15496
15620
  const { data } = useAuth();
15497
15621
  const { businessId } = useLayerContext();
15498
15622
  const mutationResponse = useSWRMutation(
15499
- () => buildKey$F(__spreadProps(__spreadValues({}, data), {
15623
+ () => buildKey$J(__spreadProps(__spreadValues({}, data), {
15500
15624
  businessId,
15501
15625
  bankTransactionId
15502
15626
  })),
@@ -15555,7 +15679,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
15555
15679
  }
15556
15680
  const TAG_BANK_TRANSACTION_TAG_KEY = "#tag-bank-transaction";
15557
15681
  const tagBankTransaction = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
15558
- function buildKey$E({
15682
+ function buildKey$I({
15559
15683
  access_token: accessToken,
15560
15684
  apiUrl,
15561
15685
  businessId,
@@ -15575,7 +15699,7 @@ function useTagBankTransaction({ bankTransactionId }) {
15575
15699
  const { data } = useAuth();
15576
15700
  const { businessId } = useLayerContext();
15577
15701
  const mutationResponse = useSWRMutation(
15578
- () => buildKey$E(__spreadProps(__spreadValues({}, data), {
15702
+ () => buildKey$I(__spreadProps(__spreadValues({}, data), {
15579
15703
  businessId,
15580
15704
  bankTransactionId
15581
15705
  })),
@@ -15690,7 +15814,7 @@ const FallbackWithSkeletonLoader = ({
15690
15814
  return children;
15691
15815
  };
15692
15816
  const TAG_DIMENSION_BY_KEY_TAG_KEY = "#tag-dimension-by-key";
15693
- function buildKey$D({
15817
+ function buildKey$H({
15694
15818
  access_token: accessToken,
15695
15819
  apiUrl,
15696
15820
  businessId,
@@ -15734,7 +15858,7 @@ function useTagDimensionByKey({ isEnabled = true, dimensionKey }) {
15734
15858
  const { apiUrl } = useEnvironment();
15735
15859
  const { businessId } = useLayerContext();
15736
15860
  const swrResponse = useSWR(
15737
- () => buildKey$D(__spreadProps(__spreadValues({}, auth), {
15861
+ () => buildKey$H(__spreadProps(__spreadValues({}, auth), {
15738
15862
  apiUrl,
15739
15863
  isEnabled,
15740
15864
  businessId,
@@ -15949,10 +16073,7 @@ function BankTransactionFormFields({
15949
16073
  isReadOnly
15950
16074
  }
15951
16075
  ),
15952
- showDescriptions && /* @__PURE__ */ jsxs(VStack, { gap: "sm", children: [
15953
- /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", children: "Description" }),
15954
- /* @__PURE__ */ jsx(BankTransactionMemo, { bankTransactionId: bankTransaction.id })
15955
- ] })
16076
+ showDescriptions && /* @__PURE__ */ jsx(VStack, { gap: "sm", children: /* @__PURE__ */ jsx(BankTransactionMemo, { bankTransactionId: bankTransaction.id }) })
15956
16077
  ] });
15957
16078
  }
15958
16079
  const ExpandedBankTransactionRow = forwardRef(
@@ -16080,7 +16201,7 @@ const ExpandedBankTransactionRow = forwardRef(
16080
16201
  if (!foundMatch) {
16081
16202
  return;
16082
16203
  }
16083
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id);
16204
+ yield matchBankTransaction2(bankTransaction, foundMatch.id);
16084
16205
  deselect(bankTransaction.id);
16085
16206
  close2();
16086
16207
  });
@@ -16181,8 +16302,7 @@ const ExpandedBankTransactionRow = forwardRef(
16181
16302
  onSelectedValueChange: (value) => {
16182
16303
  changeCategoryForSplitAtIndex(index, value);
16183
16304
  },
16184
- isLoading: bankTransaction.processing,
16185
- isDisabled: !categorizationEnabled,
16305
+ isDisabled: !categorizationEnabled || bankTransaction.processing,
16186
16306
  includeSuggestedMatches: false
16187
16307
  }
16188
16308
  ),
@@ -16361,6 +16481,8 @@ const BankTransactionRow = ({
16361
16481
  const { setTransactionCategory } = useBankTransactionsCategoryActions();
16362
16482
  const { selectedCategory } = useGetBankTransactionCategory(bankTransaction.id);
16363
16483
  const { saveBankTransactionRow } = useSaveBankTransactionRow();
16484
+ const isBeingRemoved = bankTransaction.recently_categorized && shouldHideAfterCategorize();
16485
+ const displayAsCategorized = isBeingRemoved ? false : categorized;
16364
16486
  useEffect(() => {
16365
16487
  if (bankTransaction.error) {
16366
16488
  setShowRetry(true);
@@ -16394,7 +16516,7 @@ const BankTransactionRow = ({
16394
16516
  const openClassName = open ? `${className}--expanded` : "";
16395
16517
  const rowClassName = classNames(
16396
16518
  className,
16397
- bankTransaction.recently_categorized && editable && shouldHideAfterCategorize() ? "Layer__bank-transaction-row--removing" : "",
16519
+ isBeingRemoved && editable ? "Layer__bank-transaction-row--removing" : "",
16398
16520
  open ? openClassName : "",
16399
16521
  initialLoad ? "initial-load" : "",
16400
16522
  isVisible ? "show" : ""
@@ -16503,12 +16625,12 @@ const BankTransactionRow = ({
16503
16625
  className: "Layer__bank-transaction__submit-btn",
16504
16626
  processing: bankTransaction.processing,
16505
16627
  active: open,
16506
- action: categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16628
+ action: displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16507
16629
  disabled: selectedCategory === null,
16508
- children: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
16630
+ children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
16509
16631
  }
16510
16632
  ),
16511
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsx(VStack, { pis: "lg", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16633
+ !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx(VStack, { pis: "lg", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16512
16634
  /* @__PURE__ */ jsx(
16513
16635
  IconButton,
16514
16636
  {
@@ -16530,7 +16652,7 @@ const BankTransactionRow = ({
16530
16652
  variant: "fade",
16531
16653
  isOpen: categorizationEnabled && !categorized,
16532
16654
  className: "Layer__BankTransactionRow__CategoryComboBoxMotionContent",
16533
- slotProps: { AnimatePresence: { mode: "wait" } },
16655
+ slotProps: { AnimatePresence: { mode: "wait", initial: false } },
16534
16656
  children: /* @__PURE__ */ jsx(
16535
16657
  BankTransactionCategoryComboBox,
16536
16658
  {
@@ -16540,20 +16662,20 @@ const BankTransactionRow = ({
16540
16662
  setTransactionCategory(bankTransaction.id, selectedCategory2);
16541
16663
  setShowRetry(false);
16542
16664
  },
16543
- isLoading: bankTransaction.processing
16665
+ isDisabled: bankTransaction.processing
16544
16666
  }
16545
16667
  )
16546
16668
  },
16547
16669
  "category-combobox"
16548
16670
  ),
16549
- categorized && /* @__PURE__ */ jsx(
16671
+ displayAsCategorized && /* @__PURE__ */ jsx(
16550
16672
  BankTransactionsCategorizedSelectedValue,
16551
16673
  {
16552
16674
  bankTransaction,
16553
16675
  className: "Layer__bank-transaction-row__category"
16554
16676
  }
16555
16677
  ),
16556
- categorizationEnabled && !categorized && showRetry && /* @__PURE__ */ jsx(
16678
+ !displayAsCategorized && categorizationEnabled && showRetry && /* @__PURE__ */ jsx(
16557
16679
  RetryButton,
16558
16680
  {
16559
16681
  onClick: () => {
@@ -16567,7 +16689,7 @@ const BankTransactionRow = ({
16567
16689
  children: "Retry"
16568
16690
  }
16569
16691
  ),
16570
- !categorized && categorizationEnabled && !showRetry && /* @__PURE__ */ jsx(
16692
+ !displayAsCategorized && categorizationEnabled && !showRetry && !isBeingRemoved && /* @__PURE__ */ jsx(
16571
16693
  SubmitButton,
16572
16694
  {
16573
16695
  onClick: () => {
@@ -16579,12 +16701,12 @@ const BankTransactionRow = ({
16579
16701
  processing: bankTransaction.processing,
16580
16702
  active: open,
16581
16703
  disabled: selectedCategory === null,
16582
- action: categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16583
- children: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
16704
+ action: displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16705
+ children: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Confirm"
16584
16706
  }
16585
16707
  ),
16586
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16587
- /* @__PURE__ */ jsx(
16708
+ !categorizationEnabled && !displayAsCategorized && !isBeingRemoved && /* @__PURE__ */ jsx(VStack, { pis: "xs", fluid: true, children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16709
+ !isBeingRemoved && /* @__PURE__ */ jsx(
16588
16710
  IconButton,
16589
16711
  {
16590
16712
  onClick: toggleOpen,
@@ -16607,7 +16729,7 @@ const BankTransactionRow = ({
16607
16729
  {
16608
16730
  ref: expandedRowRef,
16609
16731
  bankTransaction,
16610
- categorized,
16732
+ categorized: displayAsCategorized,
16611
16733
  isOpen: open,
16612
16734
  close: () => setOpen(false),
16613
16735
  containerWidth,
@@ -16713,6 +16835,7 @@ const BankTransactionsListItem = ({
16713
16835
  const bookkeepingStatus = useEffectiveBookkeepingStatus();
16714
16836
  const categorizationEnabled = isCategorizationEnabledForStatus(bookkeepingStatus);
16715
16837
  const categorized = isCategorized(bankTransaction);
16838
+ const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
16716
16839
  const { isVisible } = useDelayedVisibility({ delay: index * 80 });
16717
16840
  const { select, deselect } = useBulkSelectionActions();
16718
16841
  const isSelected = useIdIsSelected();
@@ -16809,7 +16932,7 @@ const BankTransactionsListItem = ({
16809
16932
  }
16810
16933
  )
16811
16934
  ] }),
16812
- !categorizationEnabled && !categorized && /* @__PURE__ */ jsx("span", { className: "Layer__bank-transaction-list-item__processing-info", children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16935
+ !categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("span", { className: "Layer__bank-transaction-list-item__processing-info", children: /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, {}) }),
16813
16936
  /* @__PURE__ */ jsx("span", { className: "Layer__bank-transaction-list-item__expanded-row", onClick: preventRowExpansion, children: /* @__PURE__ */ jsx(AnimatedPresenceDiv, { variant: "expand", isOpen: openExpandedRow, children: /* @__PURE__ */ jsx(
16814
16937
  ExpandedBankTransactionRow,
16815
16938
  {
@@ -16817,9 +16940,9 @@ const BankTransactionsListItem = ({
16817
16940
  bankTransaction,
16818
16941
  isOpen: openExpandedRow,
16819
16942
  close: () => setOpenExpandedRow(false),
16820
- categorized,
16943
+ categorized: displayAsCategorized,
16821
16944
  asListItem: true,
16822
- submitBtnText: categorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve",
16945
+ submitBtnText: displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update" : (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve",
16823
16946
  containerWidth,
16824
16947
  showDescriptions,
16825
16948
  showReceiptUploads,
@@ -16827,7 +16950,7 @@ const BankTransactionsListItem = ({
16827
16950
  variant: "list"
16828
16951
  }
16829
16952
  ) }, `expanded-${bankTransaction.id}`) }),
16830
- !openExpandedRow && categorizationEnabled && !categorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md", pb: "md", children: [
16953
+ !openExpandedRow && categorizationEnabled && !displayAsCategorized && /* @__PURE__ */ jsx("div", { onClick: preventRowExpansion, children: /* @__PURE__ */ jsxs(HStack, { pi: "md", gap: "md", pb: "md", children: [
16831
16954
  /* @__PURE__ */ jsx(
16832
16955
  BankTransactionCategoryComboBox,
16833
16956
  {
@@ -16837,7 +16960,7 @@ const BankTransactionsListItem = ({
16837
16960
  setTransactionCategory(bankTransaction.id, selectedCategory2);
16838
16961
  setShowRetry(false);
16839
16962
  },
16840
- isLoading: bankTransaction.processing
16963
+ isDisabled: bankTransaction.processing
16841
16964
  }
16842
16965
  ),
16843
16966
  /* @__PURE__ */ jsx(
@@ -16847,14 +16970,14 @@ const BankTransactionsListItem = ({
16847
16970
  onClick: handleSave,
16848
16971
  className: showRetry ? "Layer__bank-transaction__retry-btn" : "Layer__bank-transaction__submit-btn",
16849
16972
  processing: bankTransaction.processing,
16850
- action: !categorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16973
+ action: !displayAsCategorized ? SubmitAction.SAVE : SubmitAction.UPDATE,
16851
16974
  withRetry: true,
16852
16975
  error: showRetry ? "Approval failed. Check connection and retry in few seconds." : void 0,
16853
- children: showRetry ? "Retry" : !categorized ? (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve" : (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update"
16976
+ children: showRetry ? "Retry" : !displayAsCategorized ? (stringOverrides == null ? void 0 : stringOverrides.approveButtonText) || "Approve" : (stringOverrides == null ? void 0 : stringOverrides.updateButtonText) || "Update"
16854
16977
  }
16855
16978
  )
16856
16979
  ] }) }),
16857
- !openExpandedRow && categorized && /* @__PURE__ */ jsx(
16980
+ !openExpandedRow && displayAsCategorized && /* @__PURE__ */ jsx(
16858
16981
  BankTransactionsListItemCategory,
16859
16982
  {
16860
16983
  bankTransaction
@@ -16920,26 +17043,6 @@ const BankTransactionsList = ({
16920
17043
  ) })
16921
17044
  ] });
16922
17045
  };
16923
- const SWITCH_CLASS_NAME = "Layer__Switch";
16924
- const Switch = forwardRef((_Rb, ref) => {
16925
- var _Sb = _Rb, {
16926
- children
16927
- } = _Sb, props = __objRest(_Sb, [
16928
- "children"
16929
- ]);
16930
- return /* @__PURE__ */ jsx(
16931
- Switch$1,
16932
- __spreadProps(__spreadValues({}, props), {
16933
- className: SWITCH_CLASS_NAME,
16934
- ref,
16935
- children: withRenderProp(children, (node) => /* @__PURE__ */ jsxs(Fragment, { children: [
16936
- /* @__PURE__ */ jsx("div", { slot: "indicator" }),
16937
- node
16938
- ] }))
16939
- })
16940
- );
16941
- });
16942
- Switch.displayName = "Switch";
16943
17046
  const BankTransactionsMobileBulkActionsHeader = ({
16944
17047
  bankTransactions,
16945
17048
  bulkActionsEnabled,
@@ -17063,8 +17166,8 @@ const BankTransactionsMobileListItemCheckbox = ({
17063
17166
  }
17064
17167
  ) });
17065
17168
  };
17066
- const Paperclip = (_Tb) => {
17067
- var _Ub = _Tb, { size = 20 } = _Ub, props = __objRest(_Ub, ["size"]);
17169
+ const Paperclip = (_Vb) => {
17170
+ var _Wb = _Vb, { size = 20 } = _Wb, props = __objRest(_Wb, ["size"]);
17068
17171
  return /* @__PURE__ */ jsx(
17069
17172
  "svg",
17070
17173
  __spreadProps(__spreadValues({
@@ -17512,7 +17615,7 @@ const BankTransactionsMobileListMatchForm = ({
17512
17615
  if (!foundMatch) {
17513
17616
  return;
17514
17617
  }
17515
- yield matchBankTransaction2(bankTransaction.id, foundMatch.id, true);
17618
+ yield matchBankTransaction2(bankTransaction, foundMatch.id, true);
17516
17619
  });
17517
17620
  const save = () => {
17518
17621
  var _a2;
@@ -17948,6 +18051,7 @@ const BankTransactionsMobileListItem = ({
17948
18051
  const { shouldHideAfterCategorize } = useBankTransactionsContext();
17949
18052
  const categorized = isCategorized(bankTransaction);
17950
18053
  const itemRef = useRef(null);
18054
+ const displayAsCategorized = bankTransaction.recently_categorized && shouldHideAfterCategorize() ? false : categorized;
17951
18055
  const [open, setOpen] = useState(isFirstItem);
17952
18056
  const openNext = () => {
17953
18057
  if (editable && itemRef.current && itemRef.current.nextSibling) {
@@ -18034,11 +18138,11 @@ const BankTransactionsMobileListItem = ({
18034
18138
  const isTransactionSelected = isSelected(bankTransaction.id);
18035
18139
  const { renderInAppLink } = useInAppLinkContext();
18036
18140
  const inAppLink = useMemo(() => {
18037
- if (!categorized) {
18141
+ if (!displayAsCategorized) {
18038
18142
  return null;
18039
18143
  }
18040
18144
  return getInAppLink(bankTransaction, renderInAppLink);
18041
- }, [categorized, bankTransaction, renderInAppLink]);
18145
+ }, [displayAsCategorized, bankTransaction, renderInAppLink]);
18042
18146
  const { isVisible } = useDelayedVisibility({ delay: index * 20, initialVisibility: Boolean(initialLoad) });
18043
18147
  const className = "Layer__bank-transaction-mobile-list-item";
18044
18148
  const openClassName = open ? `${className}--expanded` : "";
@@ -18105,7 +18209,7 @@ const BankTransactionsMobileListItem = ({
18105
18209
  ]
18106
18210
  }
18107
18211
  ),
18108
- !open && (!categorizationEnabled && !categorized ? /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, { showAsBadge: true }) : /* @__PURE__ */ jsx(
18212
+ !open && (!categorizationEnabled && !displayAsCategorized ? /* @__PURE__ */ jsx(BankTransactionsProcessingInfo, { showAsBadge: true }) : /* @__PURE__ */ jsx(
18109
18213
  BankTransactionsListItemCategory,
18110
18214
  {
18111
18215
  bankTransaction,
@@ -18320,8 +18424,8 @@ const BankTransactionsTable = ({
18320
18424
  }
18321
18425
  );
18322
18426
  };
18323
- const BackArrow = (_Vb) => {
18324
- var _Wb = _Vb, { size = 18 } = _Wb, props = __objRest(_Wb, ["size"]);
18427
+ const BackArrow = (_Xb) => {
18428
+ var _Yb = _Xb, { size = 18 } = _Yb, props = __objRest(_Yb, ["size"]);
18325
18429
  return /* @__PURE__ */ jsx(
18326
18430
  "svg",
18327
18431
  __spreadProps(__spreadValues({
@@ -18354,7 +18458,7 @@ const BaseDetailView = ({ name, onGoBack, slots, children, borderless = false })
18354
18458
  ] });
18355
18459
  };
18356
18460
  const ARCHIVE_CATEGORIZATION_RULE_TAG = "#archive-categorization-rule";
18357
- function buildKey$C({
18461
+ function buildKey$G({
18358
18462
  access_token: accessToken,
18359
18463
  apiUrl,
18360
18464
  businessId
@@ -18379,7 +18483,7 @@ function useArchiveCategorizationRule() {
18379
18483
  const { businessId } = useLayerContext();
18380
18484
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
18381
18485
  const mutationResponse = useSWRMutation(
18382
- () => buildKey$C({
18486
+ () => buildKey$G({
18383
18487
  access_token: auth == null ? void 0 : auth.access_token,
18384
18488
  apiUrl: auth == null ? void 0 : auth.apiUrl,
18385
18489
  businessId
@@ -18489,8 +18593,8 @@ const usePaginationRange = ({
18489
18593
  }, [totalCount, pageSize, siblingCount, currentPage]);
18490
18594
  return paginationRange;
18491
18595
  };
18492
- const ChevronLeft = (_Xb) => {
18493
- var props = __objRest(_Xb, []);
18596
+ const ChevronLeft = (_Zb) => {
18597
+ var props = __objRest(_Zb, []);
18494
18598
  return /* @__PURE__ */ jsx(
18495
18599
  "svg",
18496
18600
  __spreadProps(__spreadValues({
@@ -18512,8 +18616,8 @@ const ChevronLeft = (_Xb) => {
18512
18616
  })
18513
18617
  );
18514
18618
  };
18515
- const PaginationButton = (_Yb) => {
18516
- var _Zb = _Yb, { children, isSelected } = _Zb, buttonProps = __objRest(_Zb, ["children", "isSelected"]);
18619
+ const PaginationButton = (__b) => {
18620
+ var _$b = __b, { children, isSelected } = _$b, buttonProps = __objRest(_$b, ["children", "isSelected"]);
18517
18621
  return /* @__PURE__ */ jsx(
18518
18622
  Button,
18519
18623
  __spreadProps(__spreadValues({
@@ -18595,7 +18699,6 @@ const Pagination = ({
18595
18699
  ) }, "page-next")
18596
18700
  ] }) }) });
18597
18701
  };
18598
- const EMPTY_ARRAY$2 = [];
18599
18702
  function PaginatedTable({
18600
18703
  data,
18601
18704
  isLoading,
@@ -18606,7 +18709,8 @@ function PaginatedTable({
18606
18709
  paginationProps,
18607
18710
  slots
18608
18711
  }) {
18609
- const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage } = paginationProps;
18712
+ var _a;
18713
+ const { pageSize = 20, hasMore, fetchMore, initialPage = 0, onSetPage, autoResetPageIndexRef } = paginationProps;
18610
18714
  const [pagination, setPagination] = useState({ pageIndex: initialPage, pageSize });
18611
18715
  const columnHelper = createColumnHelper();
18612
18716
  const columns = Object.values(columnConfig);
@@ -18618,7 +18722,7 @@ function PaginatedTable({
18618
18722
  });
18619
18723
  });
18620
18724
  const table2 = useReactTable({
18621
- data: data != null ? data : EMPTY_ARRAY$2,
18725
+ data: data != null ? data : [],
18622
18726
  columns: columnDefs,
18623
18727
  state: { pagination },
18624
18728
  onPaginationChange: (updaterOrValue) => {
@@ -18628,7 +18732,7 @@ function PaginatedTable({
18628
18732
  },
18629
18733
  getPaginationRowModel: getPaginationRowModel(),
18630
18734
  getCoreRowModel: getCoreRowModel(),
18631
- autoResetPageIndex: false
18735
+ autoResetPageIndex: (_a = autoResetPageIndexRef == null ? void 0 : autoResetPageIndexRef.current) != null ? _a : false
18632
18736
  });
18633
18737
  const { rows } = table2.getRowModel();
18634
18738
  const rowData = useMemo(() => rows.map((r) => r.original), [rows]);
@@ -18874,7 +18978,7 @@ const SuggestedCategorizationRuleUpdatesDrawer = ({
18874
18978
  ] }) });
18875
18979
  };
18876
18980
  const TAG_DIMENSIONS_TAG_KEY = "#tag-dimensions";
18877
- function buildKey$B({
18981
+ function buildKey$F({
18878
18982
  access_token: accessToken,
18879
18983
  apiUrl,
18880
18984
  businessId,
@@ -18917,7 +19021,7 @@ function useTagDimensions({ isEnabled = true } = {}) {
18917
19021
  const { apiUrl } = useEnvironment();
18918
19022
  const { businessId } = useLayerContext();
18919
19023
  const swrResponse = useSWR(
18920
- () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
19024
+ () => buildKey$F(__spreadProps(__spreadValues({}, auth), {
18921
19025
  apiUrl,
18922
19026
  businessId,
18923
19027
  isEnabled
@@ -18942,8 +19046,8 @@ function usePreloadTagDimensions(parameters) {
18942
19046
  useTagDimensions(parameters);
18943
19047
  }
18944
19048
  const COMPONENT_NAME$c = "bank-transactions";
18945
- const BankTransactions = (__b) => {
18946
- var _$b = __b, {
19049
+ const BankTransactions = (_ac) => {
19050
+ var _bc = _ac, {
18947
19051
  onError,
18948
19052
  showTags = false,
18949
19053
  showCustomerVendor = false,
@@ -18951,7 +19055,7 @@ const BankTransactions = (__b) => {
18951
19055
  applyGlobalDateRange = false,
18952
19056
  mode,
18953
19057
  renderInAppLink
18954
- } = _$b, props = __objRest(_$b, [
19058
+ } = _bc, props = __objRest(_bc, [
18955
19059
  "onError",
18956
19060
  "showTags",
18957
19061
  "showCustomerVendor",
@@ -18963,6 +19067,7 @@ const BankTransactions = (__b) => {
18963
19067
  usePreloadTagDimensions({ isEnabled: showTags });
18964
19068
  usePreloadCustomers({ isEnabled: showCustomerVendor });
18965
19069
  usePreloadVendors({ isEnabled: showCustomerVendor });
19070
+ usePreloadCategories();
18966
19071
  return /* @__PURE__ */ jsx(ErrorBoundary, { onError, children: /* @__PURE__ */ jsx(CategorizationRulesProvider, { children: /* @__PURE__ */ jsx(BankTransactionsRouteStoreProvider, { children: /* @__PURE__ */ jsx(
18967
19072
  BankTransactionsProvider,
18968
19073
  {
@@ -19109,7 +19214,7 @@ const BankTransactionsTableView = ({
19109
19214
  const [listView, setListView] = useState(false);
19110
19215
  const [containerWidth, setContainerWidth] = useState(0);
19111
19216
  const debounceContainerWidth = debounce(setContainerWidth, 500);
19112
- const removeTransaction = (bankTransaction) => removeAfterCategorize(bankTransaction);
19217
+ const removeTransaction = (bankTransaction) => removeAfterCategorize([bankTransaction.id]);
19113
19218
  const containerRef = useElementSize((_el, _en, size) => {
19114
19219
  if ((size == null ? void 0 : size.height) && (size == null ? void 0 : size.height) >= 90) {
19115
19220
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -19316,8 +19421,8 @@ function QuickbooksContextProvider({ children }) {
19316
19421
  const quickbooksContextData = useQuickbooks();
19317
19422
  return /* @__PURE__ */ jsx(QuickbooksContext.Provider, { value: quickbooksContextData, children });
19318
19423
  }
19319
- const Cog = (_ac) => {
19320
- var _bc = _ac, { size = 12 } = _bc, props = __objRest(_bc, ["size"]);
19424
+ const Cog = (_cc) => {
19425
+ var _dc = _cc, { size = 12 } = _dc, props = __objRest(_dc, ["size"]);
19321
19426
  const id = useId();
19322
19427
  return /* @__PURE__ */ jsxs(
19323
19428
  "svg",
@@ -19338,8 +19443,8 @@ const Cog = (_ac) => {
19338
19443
  })
19339
19444
  );
19340
19445
  };
19341
- const QuickbooksIcon = (_cc) => {
19342
- var _dc = _cc, { size = 24 } = _dc, props = __objRest(_dc, ["size"]);
19446
+ const QuickbooksIcon = (_ec) => {
19447
+ var _fc = _ec, { size = 24 } = _fc, props = __objRest(_fc, ["size"]);
19343
19448
  return /* @__PURE__ */ jsxs(
19344
19449
  "svg",
19345
19450
  __spreadProps(__spreadValues({
@@ -19498,8 +19603,8 @@ function IntegrationsQuickbooksUnlinkConfirmationModal({ isOpen, onOpenChange })
19498
19603
  }
19499
19604
  );
19500
19605
  }
19501
- const MoreVertical = (_ec) => {
19502
- var _fc = _ec, { size = 18 } = _fc, props = __objRest(_fc, ["size"]);
19606
+ const MoreVertical = (_gc) => {
19607
+ var _hc = _gc, { size = 18 } = _hc, props = __objRest(_hc, ["size"]);
19503
19608
  return /* @__PURE__ */ jsxs(
19504
19609
  "svg",
19505
19610
  __spreadProps(__spreadValues({
@@ -19728,8 +19833,8 @@ const IntegrationsComponent = ({
19728
19833
  (quickbooksConnectionStatus == null ? void 0 : quickbooksConnectionStatus.is_connected) && /* @__PURE__ */ jsx(IntegrationsContent, {})
19729
19834
  ] });
19730
19835
  };
19731
- const PlusIcon = (_gc) => {
19732
- var _hc = _gc, { size = 14 } = _hc, props = __objRest(_hc, ["size"]);
19836
+ const PlusIcon = (_ic) => {
19837
+ var _jc = _ic, { size = 14 } = _jc, props = __objRest(_jc, ["size"]);
19733
19838
  return /* @__PURE__ */ jsxs(
19734
19839
  "svg",
19735
19840
  __spreadProps(__spreadValues({
@@ -19771,8 +19876,8 @@ const PlusIcon = (_gc) => {
19771
19876
  })
19772
19877
  );
19773
19878
  };
19774
- const InstitutionIcon = (_ic) => {
19775
- var _jc = _ic, { size = 18 } = _jc, props = __objRest(_jc, ["size"]);
19879
+ const InstitutionIcon = (_kc) => {
19880
+ var _lc = _kc, { size = 18 } = _lc, props = __objRest(_lc, ["size"]);
19776
19881
  return /* @__PURE__ */ jsxs(
19777
19882
  "svg",
19778
19883
  __spreadProps(__spreadValues({
@@ -20132,7 +20237,7 @@ function LinkedAccountToConfirm({
20132
20237
  ) })
20133
20238
  ] });
20134
20239
  }
20135
- function buildKey$A({
20240
+ function buildKey$E({
20136
20241
  access_token: accessToken,
20137
20242
  apiUrl,
20138
20243
  businessId
@@ -20190,7 +20295,7 @@ function useConfirmAndExcludeMultiple({ onSuccess }) {
20190
20295
  const { data: auth } = useAuth();
20191
20296
  const { businessId } = useLayerContext();
20192
20297
  return useSWRMutation(
20193
- () => buildKey$A({
20298
+ () => buildKey$E({
20194
20299
  access_token: auth == null ? void 0 : auth.access_token,
20195
20300
  apiUrl: auth == null ? void 0 : auth.apiUrl,
20196
20301
  businessId
@@ -20390,8 +20495,8 @@ const MenuItem = forwardRef(
20390
20495
  );
20391
20496
  const PILL_CLASS_NAME = "Layer__Pill";
20392
20497
  const Pill = forwardRef(
20393
- function Pill2(_kc, ref) {
20394
- var _lc = _kc, { children, status } = _lc, restProps = __objRest(_lc, ["children", "status"]);
20498
+ function Pill2(_mc, ref) {
20499
+ var _nc = _mc, { children, status } = _nc, restProps = __objRest(_nc, ["children", "status"]);
20395
20500
  const dataProperties = toDataProperties({ status });
20396
20501
  return /* @__PURE__ */ jsx(
20397
20502
  Button$2,
@@ -20754,8 +20859,8 @@ const LinkedAccountsContent = ({
20754
20859
  };
20755
20860
  const CALENDAR_CLASS_NAME = "Layer__UI__Calendar";
20756
20861
  const Calendar = forwardRef(
20757
- function Calendar2(_mc, ref) {
20758
- var _nc = _mc, { className, isReadOnly } = _nc, restProps = __objRest(_nc, ["className", "isReadOnly"]);
20862
+ function Calendar2(_oc, ref) {
20863
+ var _pc = _oc, { className, isReadOnly } = _pc, restProps = __objRest(_pc, ["className", "isReadOnly"]);
20759
20864
  const dataProperties = toDataProperties({ readonly: isReadOnly });
20760
20865
  return /* @__PURE__ */ jsx(
20761
20866
  Calendar$1,
@@ -20769,8 +20874,8 @@ const Calendar = forwardRef(
20769
20874
  );
20770
20875
  const CALENDAR_GRID_CLASS_NAME = "Layer__UI__CalendarGrid";
20771
20876
  const CalendarGrid = forwardRef(
20772
- function CalendarGrid2(_oc, ref) {
20773
- var _pc = _oc, { className } = _pc, restProps = __objRest(_pc, ["className"]);
20877
+ function CalendarGrid2(_qc, ref) {
20878
+ var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
20774
20879
  return /* @__PURE__ */ jsx(
20775
20880
  CalendarGrid$1,
20776
20881
  __spreadProps(__spreadValues({}, restProps), {
@@ -20782,8 +20887,8 @@ const CalendarGrid = forwardRef(
20782
20887
  );
20783
20888
  const CALENDAR_GRID_BODY_CLASS_NAME = "Layer__UI__CalendarGridBody";
20784
20889
  const CalendarGridBody = forwardRef(
20785
- function CalendarGridBody2(_qc, ref) {
20786
- var _rc = _qc, { className } = _rc, restProps = __objRest(_rc, ["className"]);
20890
+ function CalendarGridBody2(_sc, ref) {
20891
+ var _tc = _sc, { className } = _tc, restProps = __objRest(_tc, ["className"]);
20787
20892
  return /* @__PURE__ */ jsx(
20788
20893
  CalendarGridBody$1,
20789
20894
  __spreadProps(__spreadValues({}, restProps), {
@@ -20795,8 +20900,8 @@ const CalendarGridBody = forwardRef(
20795
20900
  );
20796
20901
  const CALENDAR_CELL_CLASS_NAME = "Layer__UI__CalendarCell";
20797
20902
  const CalendarCell = forwardRef(
20798
- function CalendarCell2(_sc, ref) {
20799
- var _tc = _sc, { className, size = "sm" } = _tc, restProps = __objRest(_tc, ["className", "size"]);
20903
+ function CalendarCell2(_uc, ref) {
20904
+ var _vc = _uc, { className, size = "sm" } = _vc, restProps = __objRest(_vc, ["className", "size"]);
20800
20905
  const dataProperties = toDataProperties({ size });
20801
20906
  return /* @__PURE__ */ jsx(
20802
20907
  CalendarCell$1,
@@ -20809,8 +20914,8 @@ const CalendarCell = forwardRef(
20809
20914
  );
20810
20915
  const CALENDAR_GRID_HEADER_CLASS_NAME = "Layer__UI__CalendarGridHeader";
20811
20916
  const CalendarGridHeader = forwardRef(
20812
- function CalendarGridHeader2(_uc, ref) {
20813
- var _vc = _uc, { className } = _vc, restProps = __objRest(_vc, ["className"]);
20917
+ function CalendarGridHeader2(_wc, ref) {
20918
+ var _xc = _wc, { className } = _xc, restProps = __objRest(_xc, ["className"]);
20814
20919
  return /* @__PURE__ */ jsx(
20815
20920
  CalendarGridHeader$1,
20816
20921
  __spreadProps(__spreadValues({}, restProps), {
@@ -20822,8 +20927,8 @@ const CalendarGridHeader = forwardRef(
20822
20927
  );
20823
20928
  const CALENDAR_HEADER_CELL_CLASS_NAME = "Layer__UI__CalendarHeaderCell";
20824
20929
  const CalendarHeaderCell = forwardRef(
20825
- function CalendarHeaderCell2(_wc, ref) {
20826
- var _xc = _wc, { className, size = "sm" } = _xc, restProps = __objRest(_xc, ["className", "size"]);
20930
+ function CalendarHeaderCell2(_yc, ref) {
20931
+ var _zc = _yc, { className, size = "sm" } = _zc, restProps = __objRest(_zc, ["className", "size"]);
20827
20932
  const dataProperties = toDataProperties({ size });
20828
20933
  return /* @__PURE__ */ jsx(
20829
20934
  CalendarHeaderCell$1,
@@ -21065,7 +21170,7 @@ const AccountFormBox = ({
21065
21170
  /* @__PURE__ */ jsx("div", { className: `${CLASS_NAME$3}__success-banner`, children: /* @__PURE__ */ jsx(CheckCircle, { size: 36 }) })
21066
21171
  ] }));
21067
21172
  };
21068
- function buildKey$z({
21173
+ function buildKey$D({
21069
21174
  access_token: accessToken,
21070
21175
  apiUrl,
21071
21176
  businessId,
@@ -21121,7 +21226,7 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
21121
21226
  return errors;
21122
21227
  };
21123
21228
  return useSWRMutation(
21124
- () => buildKey$z({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
21229
+ () => buildKey$D({ access_token: auth == null ? void 0 : auth.access_token, apiUrl: auth == null ? void 0 : auth.apiUrl, businessId, data }),
21125
21230
  ({ accessToken, apiUrl, businessId: businessId2, data: data2 }) => Promise.allSettled(
21126
21231
  data2.map(
21127
21232
  ({ accountId, openingDate, openingBalance, isDateInvalid }) => {
@@ -21393,6 +21498,33 @@ const applyShare = (items, total) => {
21393
21498
  });
21394
21499
  });
21395
21500
  };
21501
+ const createPnlLineItemComparator = (filters) => {
21502
+ return (a, b) => {
21503
+ switch (filters == null ? void 0 : filters.sortBy) {
21504
+ case "category":
21505
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21506
+ return a.displayName.localeCompare(b.displayName);
21507
+ }
21508
+ return b.displayName.localeCompare(a.displayName);
21509
+ case "type":
21510
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21511
+ return a.type.localeCompare(b.type);
21512
+ }
21513
+ return b.type.localeCompare(a.type);
21514
+ default:
21515
+ if ((filters == null ? void 0 : filters.sortDirection) === "asc") {
21516
+ return a.value - b.value;
21517
+ }
21518
+ return b.value - a.value;
21519
+ }
21520
+ };
21521
+ };
21522
+ const sortPnlLineItemsAndCalculateTotal = (items, filter) => {
21523
+ const sorted = items.sort(createPnlLineItemComparator(filter));
21524
+ const total = sorted.reduce((x, { value }) => x + value, 0);
21525
+ const withShare = applyShare(sorted, total);
21526
+ return { items: withShare, total };
21527
+ };
21396
21528
  const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21397
21529
  var _a;
21398
21530
  const [displayMode, setDisplayMode] = useState("month");
@@ -21418,85 +21550,20 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21418
21550
  })
21419
21551
  }));
21420
21552
  };
21421
- const setFilterTypes = (scope, types) => {
21422
- setFilters(__spreadProps(__spreadValues({}, filters), {
21423
- [scope]: __spreadProps(__spreadValues({}, filters[scope]), {
21424
- types
21425
- })
21426
- }));
21427
- };
21428
21553
  const { filteredDataRevenue, filteredTotalRevenue } = useMemo(() => {
21429
- var _a2;
21430
21554
  if (!data) {
21431
21555
  return { filteredDataRevenue: [], filteredTotalRevenue: void 0 };
21432
21556
  }
21433
21557
  const items = collectRevenueItems(data);
21434
- const revenueTypeFilters = (_a2 = filters["revenue"]) == null ? void 0 : _a2.types;
21435
- const filtered = items.map((x) => {
21436
- if (revenueTypeFilters && revenueTypeFilters.length > 0 && !revenueTypeFilters.includes(x.type)) {
21437
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
21438
- }
21439
- return x;
21440
- });
21441
- const sorted = filtered.sort((a, b) => {
21442
- var _a3, _b, _c, _d;
21443
- switch ((_a3 = filters["revenue"]) == null ? void 0 : _a3.sortBy) {
21444
- case "category":
21445
- if (((_b = filters["revenue"]) == null ? void 0 : _b.sortDirection) === "asc") {
21446
- return a.displayName.localeCompare(b.displayName);
21447
- }
21448
- return b.displayName.localeCompare(a.displayName);
21449
- case "type":
21450
- if (((_c = filters["revenue"]) == null ? void 0 : _c.sortDirection) === "asc") {
21451
- return a.type.localeCompare(b.type);
21452
- }
21453
- return b.type.localeCompare(a.type);
21454
- default:
21455
- if (((_d = filters["revenue"]) == null ? void 0 : _d.sortDirection) === "asc") {
21456
- return a.value - b.value;
21457
- }
21458
- return b.value - a.value;
21459
- }
21460
- });
21461
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
21462
- const withShare = applyShare(sorted, total);
21558
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["revenue"]);
21463
21559
  return { filteredDataRevenue: withShare, filteredTotalRevenue: total };
21464
21560
  }, [data, filters]);
21465
21561
  const { filteredDataExpenses, filteredTotalExpenses } = useMemo(() => {
21466
- var _a2;
21467
21562
  if (!data) {
21468
21563
  return { filteredDataExpenses: [], filteredTotalExpenses: void 0 };
21469
21564
  }
21470
21565
  const items = collectExpensesItems(data);
21471
- const expenseTypeFilters = (_a2 = filters["expenses"]) == null ? void 0 : _a2.types;
21472
- const filtered = items.map((x) => {
21473
- if (expenseTypeFilters && expenseTypeFilters.length > 0 && !expenseTypeFilters.includes(x.type)) {
21474
- return __spreadProps(__spreadValues({}, x), { isHidden: true });
21475
- }
21476
- return x;
21477
- });
21478
- const sorted = filtered.sort((a, b) => {
21479
- var _a3, _b, _c, _d;
21480
- switch ((_a3 = filters["expenses"]) == null ? void 0 : _a3.sortBy) {
21481
- case "category":
21482
- if (((_b = filters["expenses"]) == null ? void 0 : _b.sortDirection) === "asc") {
21483
- return a.displayName.localeCompare(b.displayName);
21484
- }
21485
- return b.displayName.localeCompare(a.displayName);
21486
- case "type":
21487
- if (((_c = filters["expenses"]) == null ? void 0 : _c.sortDirection) === "asc") {
21488
- return a.type.localeCompare(b.type);
21489
- }
21490
- return b.type.localeCompare(a.type);
21491
- default:
21492
- if (((_d = filters["expenses"]) == null ? void 0 : _d.sortDirection) === "asc") {
21493
- return a.value - b.value;
21494
- }
21495
- return b.value - a.value;
21496
- }
21497
- });
21498
- const total = sorted.filter((x) => !x.isHidden).reduce((x, { value }) => x + value, 0);
21499
- const withShare = applyShare(sorted, total);
21566
+ const { items: withShare, total } = sortPnlLineItemsAndCalculateTotal(items, filters["expenses"]);
21500
21567
  return { filteredDataExpenses: withShare, filteredTotalExpenses: total };
21501
21568
  }, [data, filters]);
21502
21569
  const refetch = useCallback(() => {
@@ -21516,7 +21583,6 @@ const useProfitAndLoss = ({ tagFilter, reportingBasis }) => {
21516
21583
  setSidebarScope,
21517
21584
  sortBy,
21518
21585
  filters,
21519
- setFilterTypes,
21520
21586
  tagFilter,
21521
21587
  dateRange,
21522
21588
  selectedLineItem,
@@ -21701,8 +21767,6 @@ const ProfitAndLossContext = createContext({
21701
21767
  },
21702
21768
  sortBy: () => {
21703
21769
  },
21704
- setFilterTypes: () => {
21705
- },
21706
21770
  filters: {
21707
21771
  expenses: void 0,
21708
21772
  revenue: void 0
@@ -21720,7 +21784,7 @@ const isNotOnlyNoneTag = (compareOptions) => {
21720
21784
  compareOptions == null ? void 0 : compareOptions.some((option) => option.tagFilterConfig.tagFilters !== "None")
21721
21785
  );
21722
21786
  };
21723
- function buildKey$y({
21787
+ function buildKey$C({
21724
21788
  access_token: accessToken,
21725
21789
  apiUrl,
21726
21790
  businessId,
@@ -21778,7 +21842,7 @@ function useProfitAndLossComparison({
21778
21842
  const { data: auth } = useAuth();
21779
21843
  const periods = preparePeriodsBody(dateRange, comparePeriods, comparisonPeriodMode);
21780
21844
  const tagFilters = prepareFiltersBody(selectedCompareOptions);
21781
- const queryKey = buildKey$y(__spreadProps(__spreadValues({}, auth), {
21845
+ const queryKey = buildKey$C(__spreadProps(__spreadValues({}, auth), {
21782
21846
  businessId,
21783
21847
  periods,
21784
21848
  tagFilters,
@@ -21938,8 +22002,8 @@ const useProfitAndLossLTM = ({ currentDate, tagFilter, reportingBasis } = {
21938
22002
  refetch
21939
22003
  };
21940
22004
  };
21941
- const BarChart2 = (_yc) => {
21942
- var _zc = _yc, { size = 12 } = _zc, props = __objRest(_zc, ["size"]);
22005
+ const BarChart2 = (_Ac) => {
22006
+ var _Bc = _Ac, { size = 12 } = _Bc, props = __objRest(_Bc, ["size"]);
21943
22007
  return /* @__PURE__ */ jsxs(
21944
22008
  "svg",
21945
22009
  __spreadProps(__spreadValues({
@@ -22729,11 +22793,11 @@ const ProfitAndLossChart = ({
22729
22793
  isSyncing && !hasNonZeroData ? /* @__PURE__ */ jsx(ChartStateCard, {}) : null
22730
22794
  ] });
22731
22795
  };
22732
- const BackButton = (_Ac) => {
22733
- var _Bc = _Ac, {
22796
+ const BackButton = (_Cc) => {
22797
+ var _Dc = _Cc, {
22734
22798
  className,
22735
22799
  textOnly = false
22736
- } = _Bc, props = __objRest(_Bc, [
22800
+ } = _Dc, props = __objRest(_Dc, [
22737
22801
  "className",
22738
22802
  "textOnly"
22739
22803
  ]);
@@ -22781,8 +22845,8 @@ const TASKS_CHARTS_COLORS = {
22781
22845
  done: "#3B9C63",
22782
22846
  pending: "#DFA000"
22783
22847
  };
22784
- const SortArrows = (_Cc) => {
22785
- var _Dc = _Cc, { size = 13 } = _Dc, props = __objRest(_Dc, ["size"]);
22848
+ const SortArrows = (_Ec) => {
22849
+ var _Fc = _Ec, { size = 13 } = _Fc, props = __objRest(_Fc, ["size"]);
22786
22850
  return /* @__PURE__ */ jsxs(
22787
22851
  "svg",
22788
22852
  __spreadProps(__spreadValues({
@@ -22849,39 +22913,12 @@ const SortArrows = (_Cc) => {
22849
22913
  );
22850
22914
  };
22851
22915
  const UNCATEGORIZED_TYPES = ["UNCATEGORIZED_INFLOWS", "UNCATEGORIZED_OUTFLOWS"];
22852
- const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
22853
- const typeToColor = {};
22854
- const typeToLastOpacity = {};
22855
- let colorIndex = 0;
22856
- return data.map((obj) => {
22857
- var _a;
22858
- const type = (_a = obj.name) != null ? _a : obj.type;
22859
- if (type === "Uncategorized") {
22860
- return {
22861
- color: "#EEEEF0",
22862
- opacity: 1
22863
- };
22864
- }
22865
- if (!typeToColor[type]) {
22866
- typeToColor[type] = colorList[colorIndex % colorList.length];
22867
- colorIndex++;
22868
- typeToLastOpacity[type] = 1;
22869
- } else {
22870
- typeToLastOpacity[type] -= 0.1;
22871
- }
22872
- const opacity = typeToLastOpacity[type];
22873
- return {
22874
- color: typeToColor[type],
22875
- opacity
22876
- };
22877
- });
22878
- };
22879
22916
  const ValueIcon = ({
22880
22917
  item,
22881
22918
  typeColorMapping,
22882
22919
  idx
22883
22920
  }) => {
22884
- if (item.type === "Uncategorized") {
22921
+ if (isLineItemUncategorized(item)) {
22885
22922
  return /* @__PURE__ */ jsxs(
22886
22923
  "svg",
22887
22924
  {
@@ -22948,7 +22985,7 @@ const DetailedTable = ({
22948
22985
  );
22949
22986
  };
22950
22987
  const typeColorMapping = mapTypesToColors(filteredData, chartColorsList);
22951
- const positiveTotal = filteredData.filter((x) => !x.isHidden && x.value > 0).reduce((sum, x) => sum + x.value, 0);
22988
+ const positiveTotal = filteredData.filter((x) => x.value > 0).reduce((sum, x) => sum + x.value, 0);
22952
22989
  return /* @__PURE__ */ jsx("div", { className: "details-container", children: /* @__PURE__ */ jsx("div", { className: "table", children: /* @__PURE__ */ jsxs("table", { children: [
22953
22990
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
22954
22991
  /* @__PURE__ */ jsxs(
@@ -22989,16 +23026,16 @@ const DetailedTable = ({
22989
23026
  }
22990
23027
  )
22991
23028
  ] }) }),
22992
- /* @__PURE__ */ jsx("tbody", { children: filteredData.filter((x) => !x.isHidden).map((item, idx) => {
23029
+ /* @__PURE__ */ jsx("tbody", { children: filteredData.map((item, idx) => {
22993
23030
  const share = item.value > 0 ? item.value / positiveTotal : 0;
22994
23031
  return /* @__PURE__ */ jsxs(
22995
23032
  "tr",
22996
23033
  {
22997
23034
  className: classNames(
22998
23035
  "Layer__profit-and-loss-detailed-table__row",
22999
- hoveredItem && hoveredItem === item.displayName ? "active" : ""
23036
+ hoveredItem && hoveredItem.name === item.name ? "active" : ""
23000
23037
  ),
23001
- onMouseEnter: () => setHoveredItem(item.displayName),
23038
+ onMouseEnter: () => setHoveredItem(item),
23002
23039
  onMouseLeave: () => setHoveredItem(void 0),
23003
23040
  children: [
23004
23041
  /* @__PURE__ */ jsx("td", { className: "category-col", children: item.displayName }),
@@ -23030,6 +23067,35 @@ const DetailedTable = ({
23030
23067
  }) })
23031
23068
  ] }) }) });
23032
23069
  };
23070
+ const isLineItemUncategorized = (item) => {
23071
+ return UNCATEGORIZED_TYPES.includes(item.name);
23072
+ };
23073
+ const mapTypesToColors = (data, colorList = DEFAULT_CHART_COLOR_TYPE) => {
23074
+ const nameToColor = {};
23075
+ const nameToLastOpacity = {};
23076
+ let colorIndex = 0;
23077
+ return data.map((lineItem) => {
23078
+ if (isLineItemUncategorized(lineItem)) {
23079
+ return {
23080
+ color: "#EEEEF0",
23081
+ opacity: 1
23082
+ };
23083
+ }
23084
+ const name = lineItem.name;
23085
+ if (!nameToColor[name]) {
23086
+ nameToColor[name] = colorList[colorIndex % colorList.length];
23087
+ colorIndex++;
23088
+ nameToLastOpacity[name] = 1;
23089
+ } else {
23090
+ nameToLastOpacity[name] -= 0.1;
23091
+ }
23092
+ const opacity = nameToLastOpacity[name];
23093
+ return {
23094
+ color: nameToColor[name],
23095
+ opacity
23096
+ };
23097
+ });
23098
+ };
23033
23099
  const DetailedChart = ({
23034
23100
  filteredData,
23035
23101
  filteredTotal,
@@ -23040,18 +23106,9 @@ const DetailedChart = ({
23040
23106
  showDatePicker = true
23041
23107
  }) => {
23042
23108
  const chartData = useMemo(
23043
- () => filteredData.map((x) => {
23044
- if (x.isHidden) {
23045
- return __spreadProps(__spreadValues({}, x), {
23046
- name: x.displayName,
23047
- value: 0
23048
- });
23049
- }
23050
- return __spreadProps(__spreadValues({}, x), {
23051
- name: x.displayName,
23052
- value: x.value > 0 ? x.value : 0
23053
- });
23054
- }),
23109
+ () => filteredData.map((x) => __spreadProps(__spreadValues({}, x), {
23110
+ value: x.value > 0 ? x.value : 0
23111
+ })),
23055
23112
  [filteredData]
23056
23113
  );
23057
23114
  const noValue = chartData.length === 0 || !chartData.find((x) => x.value !== 0);
@@ -23097,7 +23154,7 @@ const DetailedChart = ({
23097
23154
  {
23098
23155
  data: chartData,
23099
23156
  dataKey: "value",
23100
- nameKey: "name",
23157
+ nameKey: "displayName",
23101
23158
  cx: "50%",
23102
23159
  cy: "50%",
23103
23160
  innerRadius: "91%",
@@ -23110,7 +23167,7 @@ const DetailedChart = ({
23110
23167
  chartData.map((entry, index) => {
23111
23168
  let fill = typeColorMapping[index].color;
23112
23169
  let active = true;
23113
- if (hoveredItem && entry.name !== hoveredItem) {
23170
+ if (hoveredItem && entry.name !== hoveredItem.name) {
23114
23171
  active = false;
23115
23172
  fill = void 0;
23116
23173
  }
@@ -23120,13 +23177,13 @@ const DetailedChart = ({
23120
23177
  className: classNames(
23121
23178
  "Layer__profit-and-loss-detailed-charts__pie",
23122
23179
  hoveredItem && active ? "active" : "inactive",
23123
- entry.type === "Uncategorized" && "Layer__profit-and-loss-detailed-charts__pie--border"
23180
+ isLineItemUncategorized(entry) && "Layer__profit-and-loss-detailed-charts__pie--border"
23124
23181
  ),
23125
23182
  style: {
23126
- fill: entry.type === "Uncategorized" && fill ? "url(#layer-pie-dots-pattern)" : fill
23183
+ fill: isLineItemUncategorized(entry) && fill ? "url(#layer-pie-dots-pattern)" : fill
23127
23184
  },
23128
23185
  opacity: typeColorMapping[index].opacity,
23129
- onMouseEnter: () => setHoveredItem(entry.name),
23186
+ onMouseEnter: () => setHoveredItem(entry),
23130
23187
  onMouseLeave: () => setHoveredItem(void 0)
23131
23188
  },
23132
23189
  `cell-${index}`
@@ -23152,7 +23209,7 @@ const DetailedChart = ({
23152
23209
  };
23153
23210
  let text = "Total";
23154
23211
  if (hoveredItem) {
23155
- text = hoveredItem;
23212
+ text = hoveredItem.displayName;
23156
23213
  }
23157
23214
  return /* @__PURE__ */ jsx(
23158
23215
  Text$2,
@@ -23185,7 +23242,7 @@ const DetailedChart = ({
23185
23242
  let value = filteredTotal;
23186
23243
  if (hoveredItem) {
23187
23244
  value = (_b = filteredData.find(
23188
- (x) => x.displayName === hoveredItem
23245
+ (x) => x.name === hoveredItem.name
23189
23246
  )) == null ? void 0 : _b.value;
23190
23247
  }
23191
23248
  return /* @__PURE__ */ jsx(
@@ -23219,7 +23276,7 @@ const DetailedChart = ({
23219
23276
  };
23220
23277
  if (hoveredItem) {
23221
23278
  const item = filteredData.find(
23222
- (x) => x.displayName === hoveredItem
23279
+ (x) => x.name === hoveredItem.name
23223
23280
  );
23224
23281
  const positiveTotal = chartData.reduce((sum, x) => sum + x.value, 0);
23225
23282
  const value = (_b = item == null ? void 0 : item.value) != null ? _b : 0;
@@ -23244,7 +23301,7 @@ const DetailedChart = ({
23244
23301
  {
23245
23302
  data: [{ name: "Total", value: 1 }],
23246
23303
  dataKey: "value",
23247
- nameKey: "name",
23304
+ nameKey: "displayName",
23248
23305
  cx: "50%",
23249
23306
  cy: "50%",
23250
23307
  innerRadius: "91%",
@@ -23274,7 +23331,7 @@ const DetailedChart = ({
23274
23331
  };
23275
23332
  let text = "Total";
23276
23333
  if (hoveredItem) {
23277
- text = hoveredItem;
23334
+ text = hoveredItem.displayName;
23278
23335
  }
23279
23336
  return /* @__PURE__ */ jsx(
23280
23337
  Text$2,
@@ -23307,7 +23364,7 @@ const DetailedChart = ({
23307
23364
  let value = filteredTotal;
23308
23365
  if (hoveredItem) {
23309
23366
  value = (_b = filteredData.find(
23310
- (x) => x.displayName === hoveredItem
23367
+ (x) => x.name === hoveredItem.name
23311
23368
  )) == null ? void 0 : _b.value;
23312
23369
  }
23313
23370
  return /* @__PURE__ */ jsx(
@@ -23328,7 +23385,7 @@ const DetailedChart = ({
23328
23385
  {
23329
23386
  data: [{ name: "loading...", value: 1 }],
23330
23387
  dataKey: "value",
23331
- nameKey: "name",
23388
+ nameKey: "displayName",
23332
23389
  cx: "50%",
23333
23390
  cy: "50%",
23334
23391
  innerRadius: "91%",
@@ -23447,11 +23504,11 @@ const LedgerAccountsContext = createContext({
23447
23504
  fetchMore: () => {
23448
23505
  }
23449
23506
  });
23450
- const CloseButton = (_Ec) => {
23451
- var _Fc = _Ec, {
23507
+ const CloseButton = (_Gc) => {
23508
+ var _Hc = _Gc, {
23452
23509
  className,
23453
23510
  textOnly = false
23454
- } = _Fc, props = __objRest(_Fc, [
23511
+ } = _Hc, props = __objRest(_Hc, [
23455
23512
  "className",
23456
23513
  "textOnly"
23457
23514
  ]);
@@ -24226,44 +24283,6 @@ function DetailReportModal({
24226
24283
  }
24227
24284
  );
24228
24285
  }
24229
- const Filters = ({
24230
- filteredData,
24231
- sidebarScope,
24232
- filters,
24233
- setFilterTypes
24234
- }) => {
24235
- var _a, _b, _c;
24236
- return /* @__PURE__ */ jsxs("div", { className: "filters", children: [
24237
- /* @__PURE__ */ jsx(Text, { size: TextSize.sm, className: "Layer__label", children: "Filters" }),
24238
- /* @__PURE__ */ jsx(
24239
- Select$1,
24240
- {
24241
- className: "Layer__select type-select",
24242
- classNamePrefix: "Layer__select",
24243
- 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) => ({
24244
- value: x,
24245
- label: x
24246
- }))) : [],
24247
- isMulti: true,
24248
- isClearable: false,
24249
- options: [...new Set(filteredData == null ? void 0 : filteredData.map((x) => x.type))].map((x) => ({
24250
- label: x,
24251
- value: x
24252
- })),
24253
- onChange: (selected) => {
24254
- setFilterTypes(
24255
- sidebarScope != null ? sidebarScope : "expenses",
24256
- selected.map((x) => x.value)
24257
- );
24258
- },
24259
- components: {
24260
- DropdownIndicator: (props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDown, {}) })),
24261
- Placeholder: (props) => /* @__PURE__ */ jsx(components.Placeholder, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx("div", { className: "Layer__select__multi-all-placeholder-badge", children: "All" }) }))
24262
- }
24263
- }
24264
- )
24265
- ] });
24266
- };
24267
24286
  const ProfitAndLossDetailedCharts = ({
24268
24287
  scope,
24269
24288
  hideClose = false,
@@ -24281,13 +24300,12 @@ const ProfitAndLossDetailedCharts = ({
24281
24300
  filters,
24282
24301
  dateRange,
24283
24302
  sidebarScope,
24284
- setSidebarScope,
24285
- setFilterTypes
24303
+ setSidebarScope
24286
24304
  } = useContext(ProfitAndLossContext);
24287
24305
  const theScope = scope ? scope : sidebarScope;
24288
24306
  const data = theScope === "revenue" ? filteredDataRevenue : filteredDataExpenses;
24289
24307
  const total = theScope === "revenue" ? filteredTotalRevenue : filteredTotalExpenses;
24290
- const [hoveredItem, setHoveredItem] = useState();
24308
+ const [hoveredItem, setHoveredItem] = useState(void 0);
24291
24309
  const [selectedItem, setSelectedItem] = useState(null);
24292
24310
  const [isModalOpen, setIsModalOpen] = useState(false);
24293
24311
  const handleValueClick = useCallback((item) => {
@@ -24336,31 +24354,20 @@ const ProfitAndLossDetailedCharts = ({
24336
24354
  showDatePicker
24337
24355
  }
24338
24356
  ),
24339
- /* @__PURE__ */ jsxs("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: [
24340
- /* @__PURE__ */ jsx(
24341
- Filters,
24342
- {
24343
- filteredData: data,
24344
- sidebarScope: theScope,
24345
- filters,
24346
- setFilterTypes
24347
- }
24348
- ),
24349
- /* @__PURE__ */ jsx(
24350
- DetailedTable,
24351
- {
24352
- filteredData: data,
24353
- sidebarScope: theScope,
24354
- filters,
24355
- sortBy,
24356
- hoveredItem,
24357
- setHoveredItem,
24358
- chartColorsList,
24359
- stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
24360
- onValueClick: handleValueClick
24361
- }
24362
- )
24363
- ] })
24357
+ /* @__PURE__ */ jsx("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper", children: /* @__PURE__ */ jsx(
24358
+ DetailedTable,
24359
+ {
24360
+ filteredData: data,
24361
+ sidebarScope: theScope,
24362
+ filters,
24363
+ sortBy,
24364
+ hoveredItem,
24365
+ setHoveredItem,
24366
+ chartColorsList,
24367
+ stringOverrides: stringOverrides == null ? void 0 : stringOverrides.detailedTableStringOverrides,
24368
+ onValueClick: handleValueClick
24369
+ }
24370
+ ) })
24364
24371
  ] }),
24365
24372
  /* @__PURE__ */ jsx(
24366
24373
  DetailReportModal,
@@ -24623,7 +24630,7 @@ const getProfitAndLossDetailLinesExcel = (apiUrl, accessToken, params) => {
24623
24630
  ({ businessId: businessId2 }) => `/v1/businesses/${businessId2}/reports/profit-and-loss/lines/exports/excel?${queryParams.toString()}`
24624
24631
  )(apiUrl, accessToken, { params: { businessId } });
24625
24632
  };
24626
- function buildKey$x({
24633
+ function buildKey$B({
24627
24634
  access_token: accessToken,
24628
24635
  apiUrl,
24629
24636
  businessId,
@@ -24662,7 +24669,7 @@ function useProfitAndLossDetailLinesExport({
24662
24669
  const { businessId } = useLayerContext();
24663
24670
  const { apiUrl } = useEnvironment();
24664
24671
  return useSWRMutation(
24665
- () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
24672
+ () => buildKey$B(__spreadProps(__spreadValues({}, auth), {
24666
24673
  apiUrl,
24667
24674
  businessId,
24668
24675
  startDate,
@@ -24882,7 +24889,7 @@ const MultiSelect = ({
24882
24889
  const DropdownIndicator = useCallback((props) => /* @__PURE__ */ jsx(components.DropdownIndicator, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx(ChevronDownFill, {}) })), []);
24883
24890
  return /* @__PURE__ */ jsxs(DeprecatedTooltip, { disabled: !isInvalid || !errorMessage, children: [
24884
24891
  /* @__PURE__ */ jsx(DeprecatedTooltipTrigger, { className: "Layer__input-tooltip", children: /* @__PURE__ */ jsx(
24885
- Select$1,
24892
+ ReactSelect,
24886
24893
  {
24887
24894
  inputId,
24888
24895
  name,
@@ -24897,7 +24904,7 @@ const MultiSelect = ({
24897
24904
  styles: __spreadValues({
24898
24905
  menuPortal: (base) => __spreadProps(__spreadValues({}, base), { zIndex: 9999 })
24899
24906
  }, styles),
24900
- components: { DropdownIndicator },
24907
+ components: { DropdownIndicator, MenuPortal: SelectMenuPortal },
24901
24908
  isLoading,
24902
24909
  isDisabled: disabled,
24903
24910
  isMulti: true
@@ -25698,7 +25705,13 @@ function ProfitAndLossSummariesMiniChart({
25698
25705
  chartColorsList,
25699
25706
  variants: variants2
25700
25707
  }) {
25701
- const typeColorMapping = mapTypesToColors(data, chartColorsList);
25708
+ const chartData = useMemo(
25709
+ () => data.map((x) => __spreadProps(__spreadValues({}, x), {
25710
+ value: x.value > 0 ? x.value : 0
25711
+ })),
25712
+ [data]
25713
+ );
25714
+ const typeColorMapping = mapTypesToColors(chartData, chartColorsList);
25702
25715
  let chartDimension = 52;
25703
25716
  let innerRadius = 10;
25704
25717
  let outerRadius = 16;
@@ -25717,9 +25730,9 @@ function ProfitAndLossSummariesMiniChart({
25717
25730
  return /* @__PURE__ */ jsx(PieChart, { width: chartDimension, height: chartDimension, children: /* @__PURE__ */ jsx(
25718
25731
  Pie,
25719
25732
  {
25720
- data,
25733
+ data: chartData,
25721
25734
  dataKey: "value",
25722
- nameKey: "name",
25735
+ nameKey: "displayName",
25723
25736
  cx: "50%",
25724
25737
  cy: "50%",
25725
25738
  innerRadius,
@@ -25730,7 +25743,7 @@ function ProfitAndLossSummariesMiniChart({
25730
25743
  height: 36,
25731
25744
  animationDuration: 250,
25732
25745
  animationEasing: "ease-in-out",
25733
- children: data.map((entry, index) => {
25746
+ children: chartData.map((entry, index) => {
25734
25747
  const colorConfig = typeColorMapping[index];
25735
25748
  return /* @__PURE__ */ jsx(
25736
25749
  Cell$2,
@@ -25767,7 +25780,7 @@ function ProfitAndLossSummariesSummary({
25767
25780
  const showPercentChange = percentChange !== void 0 && percentChange !== null && comparisonMonth;
25768
25781
  const isGoodChange = showPercentChange && (isExpense ? percentChange < 0 : percentChange >= 0);
25769
25782
  const arrow = showPercentChange && percentChange >= 0 ? "↑" : "↓";
25770
- return /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", children: [
25783
+ return /* @__PURE__ */ jsxs(HStack, { gap: "xs", align: "center", overflow: "hidden", children: [
25771
25784
  Chart && /* @__PURE__ */ jsx(
25772
25785
  HStack,
25773
25786
  {
@@ -26019,10 +26032,10 @@ function Internal_ProfitAndLossSummaries({
26019
26032
  unstable_AdditionalListItems.map((item, index) => /* @__PURE__ */ jsx(ProfitAndLossSummariesListItem, { children: item }, index))
26020
26033
  ] }) });
26021
26034
  }
26022
- function ProfitAndLossSummaries(_Gc) {
26023
- var _Hc = _Gc, {
26035
+ function ProfitAndLossSummaries(_Ic) {
26036
+ var _Jc = _Ic, {
26024
26037
  onTransactionsToReviewClick
26025
- } = _Hc, restProps = __objRest(_Hc, [
26038
+ } = _Jc, restProps = __objRest(_Jc, [
26026
26039
  "onTransactionsToReviewClick"
26027
26040
  ]);
26028
26041
  return /* @__PURE__ */ jsx(
@@ -26060,7 +26073,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
26060
26073
  ProfitAndLoss.DetailedCharts = ProfitAndLossDetailedCharts;
26061
26074
  ProfitAndLoss.Header = ProfitAndLossHeader;
26062
26075
  ProfitAndLoss.Report = ProfitAndLossReport;
26063
- function buildKey$w({
26076
+ function buildKey$A({
26064
26077
  access_token: accessToken,
26065
26078
  apiUrl,
26066
26079
  businessId,
@@ -26083,7 +26096,7 @@ function useBalanceSheet({
26083
26096
  const { apiUrl } = useEnvironment();
26084
26097
  const { businessId } = useLayerContext();
26085
26098
  return useSWR(
26086
- () => buildKey$w(__spreadProps(__spreadValues({}, auth), {
26099
+ () => buildKey$A(__spreadProps(__spreadValues({}, auth), {
26087
26100
  apiUrl,
26088
26101
  businessId,
26089
26102
  effectiveDate
@@ -26149,7 +26162,7 @@ const BALANCE_SHEET_ROWS = [
26149
26162
  }
26150
26163
  ];
26151
26164
  const DOWNLOAD_BALANCE_SHEET_TAG_KEY = "#download-balance-sheet";
26152
- function buildKey$v({
26165
+ function buildKey$z({
26153
26166
  access_token: accessToken,
26154
26167
  apiUrl,
26155
26168
  businessId,
@@ -26172,7 +26185,7 @@ function useBalanceSheetDownload({
26172
26185
  const { data: auth } = useAuth();
26173
26186
  const { businessId } = useLayerContext();
26174
26187
  return useSWRMutation(
26175
- () => buildKey$v(__spreadProps(__spreadValues({}, auth), {
26188
+ () => buildKey$z(__spreadProps(__spreadValues({}, auth), {
26176
26189
  businessId,
26177
26190
  effectiveDate
26178
26191
  })),
@@ -26222,8 +26235,8 @@ function BalanceSheetDownloadButton({
26222
26235
  /* @__PURE__ */ jsx(InvisibleDownload, { ref: invisibleDownloadRef })
26223
26236
  ] });
26224
26237
  }
26225
- const Collapse = (_Ic) => {
26226
- var props = __objRest(_Ic, []);
26238
+ const Collapse = (_Kc) => {
26239
+ var props = __objRest(_Kc, []);
26227
26240
  return /* @__PURE__ */ jsxs(
26228
26241
  "svg",
26229
26242
  __spreadProps(__spreadValues({
@@ -26256,8 +26269,8 @@ const Collapse = (_Ic) => {
26256
26269
  })
26257
26270
  );
26258
26271
  };
26259
- const Expand = (_Jc) => {
26260
- var props = __objRest(_Jc, []);
26272
+ const Expand = (_Lc) => {
26273
+ var props = __objRest(_Lc, []);
26261
26274
  return /* @__PURE__ */ jsxs(
26262
26275
  "svg",
26263
26276
  __spreadProps(__spreadValues({
@@ -26527,7 +26540,7 @@ const BalanceSheetView = ({
26527
26540
  }
26528
26541
  ) });
26529
26542
  };
26530
- function buildKey$u({
26543
+ function buildKey$y({
26531
26544
  access_token: accessToken,
26532
26545
  apiUrl,
26533
26546
  businessId,
@@ -26553,7 +26566,7 @@ function useStatementOfCashFlow({
26553
26566
  const { apiUrl } = useEnvironment();
26554
26567
  const { businessId } = useLayerContext();
26555
26568
  return useSWR(
26556
- buildKey$u(__spreadProps(__spreadValues({}, auth), {
26569
+ buildKey$y(__spreadProps(__spreadValues({}, auth), {
26557
26570
  apiUrl,
26558
26571
  businessId,
26559
26572
  startDate,
@@ -26617,7 +26630,7 @@ const STATEMENT_OF_CASH_FLOW_ROWS = [
26617
26630
  }
26618
26631
  ];
26619
26632
  const DOWNLOAD_CASHFLOW_STATEMENT_TAG_KEY = "#download-cashflow-statement";
26620
- function buildKey$t({
26633
+ function buildKey$x({
26621
26634
  access_token: accessToken,
26622
26635
  apiUrl,
26623
26636
  businessId,
@@ -26643,7 +26656,7 @@ function useCashflowStatementDownload({
26643
26656
  const { data: auth } = useAuth();
26644
26657
  const { businessId } = useLayerContext();
26645
26658
  return useSWRMutation(
26646
- () => buildKey$t(__spreadProps(__spreadValues({}, auth), {
26659
+ () => buildKey$x(__spreadProps(__spreadValues({}, auth), {
26647
26660
  businessId,
26648
26661
  startDate,
26649
26662
  endDate
@@ -26847,7 +26860,7 @@ const getLedgerAccountBalances = get(
26847
26860
  return `/v1/businesses/${businessId}/ledger/balances?${parameters}`;
26848
26861
  }
26849
26862
  );
26850
- function buildKey$s({
26863
+ function buildKey$w({
26851
26864
  access_token: accessToken,
26852
26865
  apiUrl,
26853
26866
  businessId,
@@ -26869,7 +26882,7 @@ function useLedgerBalances(withDates, startDate, endDate) {
26869
26882
  const { data } = useAuth();
26870
26883
  const { businessId } = useLayerContext();
26871
26884
  const response = useSWR(
26872
- () => buildKey$s(__spreadProps(__spreadValues({}, data), {
26885
+ () => buildKey$w(__spreadProps(__spreadValues({}, data), {
26873
26886
  businessId,
26874
26887
  startDate: withDates ? startDate : void 0,
26875
26888
  endDate: withDates ? endDate : void 0
@@ -27211,7 +27224,7 @@ const LEDGER_ACCOUNT_SUBTYPES_FOR_TYPE = {
27211
27224
  EXPENSE: EXPENSE_LEDGER_ACCOUNT_SUBTYPES
27212
27225
  };
27213
27226
  const deleteAccountFromLedger = del(({ businessId, accountId }) => `/v1/businesses/${businessId}/ledger/accounts/${accountId}`);
27214
- function buildKey$r({
27227
+ function buildKey$v({
27215
27228
  access_token: accessToken,
27216
27229
  apiUrl,
27217
27230
  businessId
@@ -27229,7 +27242,7 @@ function useDeleteAccountFromLedger() {
27229
27242
  const { data } = useAuth();
27230
27243
  const { businessId } = useLayerContext();
27231
27244
  const mutationResponse = useSWRMutation(
27232
- () => buildKey$r(__spreadProps(__spreadValues({}, data), {
27245
+ () => buildKey$v(__spreadProps(__spreadValues({}, data), {
27233
27246
  businessId
27234
27247
  })),
27235
27248
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { accountId } }) => deleteAccountFromLedger(
@@ -27905,8 +27918,8 @@ const ChartOfAccountsContext = createContext(
27905
27918
  }
27906
27919
  }
27907
27920
  );
27908
- const Plus = (_Kc) => {
27909
- var _Lc = _Kc, { size = 14 } = _Lc, props = __objRest(_Lc, ["size"]);
27921
+ const Plus = (_Mc) => {
27922
+ var _Nc = _Mc, { size = 14 } = _Nc, props = __objRest(_Nc, ["size"]);
27910
27923
  return /* @__PURE__ */ jsxs(
27911
27924
  "svg",
27912
27925
  __spreadProps(__spreadValues({
@@ -27939,7 +27952,7 @@ const Plus = (_Kc) => {
27939
27952
  })
27940
27953
  );
27941
27954
  };
27942
- function buildKey$q({
27955
+ function buildKey$u({
27943
27956
  access_token: accessToken,
27944
27957
  apiUrl,
27945
27958
  businessId,
@@ -27965,7 +27978,7 @@ function useAccountBalancesDownload({
27965
27978
  const { data: auth } = useAuth();
27966
27979
  const { businessId } = useLayerContext();
27967
27980
  return useSWRMutation(
27968
- () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
27981
+ () => buildKey$u(__spreadProps(__spreadValues({}, auth), {
27969
27982
  businessId,
27970
27983
  startCutoff,
27971
27984
  endCutoff
@@ -28273,8 +28286,8 @@ var LedgerAccountNodeType = /* @__PURE__ */ ((LedgerAccountNodeType2) => {
28273
28286
  LedgerAccountNodeType2["Parent"] = "Parent";
28274
28287
  return LedgerAccountNodeType2;
28275
28288
  })(LedgerAccountNodeType || {});
28276
- const Edit2 = (_Mc) => {
28277
- var _Nc = _Mc, { size = 18 } = _Nc, props = __objRest(_Nc, ["size"]);
28289
+ const Edit2 = (_Oc) => {
28290
+ var _Pc = _Oc, { size = 18 } = _Pc, props = __objRest(_Pc, ["size"]);
28278
28291
  return /* @__PURE__ */ jsx(
28279
28292
  "svg",
28280
28293
  __spreadProps(__spreadValues({
@@ -29997,7 +30010,7 @@ var UpsertJournalEntryMode = /* @__PURE__ */ ((UpsertJournalEntryMode2) => {
29997
30010
  return UpsertJournalEntryMode2;
29998
30011
  })(UpsertJournalEntryMode || {});
29999
30012
  const createJournalEntry = post(({ businessId }) => `/v1/businesses/${businessId}/ledger/journal-entries`);
30000
- function buildKey$p({
30013
+ function buildKey$t({
30001
30014
  access_token: accessToken,
30002
30015
  apiUrl,
30003
30016
  businessId
@@ -30024,7 +30037,7 @@ const useUpsertJournalEntry = (props) => {
30024
30037
  const { debouncedInvalidateProfitAndLossSummaries } = useProfitAndLossSummariesCacheActions();
30025
30038
  const { invalidate } = useGlobalCacheActions();
30026
30039
  const rawMutationResponse = useSWRMutation(
30027
- () => buildKey$p(__spreadProps(__spreadValues({}, data), {
30040
+ () => buildKey$t(__spreadProps(__spreadValues({}, data), {
30028
30041
  businessId
30029
30042
  })),
30030
30043
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => {
@@ -30338,7 +30351,7 @@ const JournalEntryDrawerHeader = ({ onSubmit, formState }) => {
30338
30351
  ] })
30339
30352
  ] });
30340
30353
  };
30341
- function buildKey$o({
30354
+ function buildKey$s({
30342
30355
  access_token: accessToken,
30343
30356
  apiUrl,
30344
30357
  businessId,
@@ -30364,7 +30377,7 @@ function useJournalEntriesDownload({
30364
30377
  const { data: auth } = useAuth();
30365
30378
  const { businessId } = useLayerContext();
30366
30379
  return useSWRMutation(
30367
- () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
30380
+ () => buildKey$s(__spreadProps(__spreadValues({}, auth), {
30368
30381
  businessId,
30369
30382
  startCutoff,
30370
30383
  endCutoff
@@ -30955,8 +30968,8 @@ function usePaginatedList(list, pageSize) {
30955
30968
  reset
30956
30969
  };
30957
30970
  }
30958
- const SmileIcon = (_Oc) => {
30959
- var _Pc = _Oc, { size = 12 } = _Pc, props = __objRest(_Pc, ["size"]);
30971
+ const SmileIcon = (_Qc) => {
30972
+ var _Rc = _Qc, { size = 12 } = _Rc, props = __objRest(_Rc, ["size"]);
30960
30973
  return /* @__PURE__ */ jsxs(
30961
30974
  "svg",
30962
30975
  __spreadProps(__spreadValues({
@@ -31052,7 +31065,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
31052
31065
  accessToken
31053
31066
  );
31054
31067
  }
31055
- function buildKey$n({
31068
+ function buildKey$r({
31056
31069
  access_token: accessToken,
31057
31070
  apiUrl,
31058
31071
  businessId
@@ -31071,7 +31084,7 @@ function useDeleteUploadsOnTask() {
31071
31084
  const { businessId } = useLayerContext();
31072
31085
  const { mutate } = useSWRConfig();
31073
31086
  const mutationResponse = useSWRMutation(
31074
- () => buildKey$n(__spreadProps(__spreadValues({}, auth), {
31087
+ () => buildKey$r(__spreadProps(__spreadValues({}, auth), {
31075
31088
  businessId
31076
31089
  })),
31077
31090
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId } }) => deleteUploadsOnTask(
@@ -31110,7 +31123,7 @@ function useDeleteUploadsOnTask() {
31110
31123
  }
31111
31124
  });
31112
31125
  }
31113
- function buildKey$m({
31126
+ function buildKey$q({
31114
31127
  access_token: accessToken,
31115
31128
  apiUrl,
31116
31129
  businessId
@@ -31129,7 +31142,7 @@ function useSubmitUserResponseForTask() {
31129
31142
  const { businessId } = useLayerContext();
31130
31143
  const { mutate } = useSWRConfig();
31131
31144
  const mutationResponse = useSWRMutation(
31132
- () => buildKey$m(__spreadProps(__spreadValues({}, auth), {
31145
+ () => buildKey$q(__spreadProps(__spreadValues({}, auth), {
31133
31146
  businessId
31134
31147
  })),
31135
31148
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, userResponse } }) => submitUserResponseForTask(
@@ -31175,7 +31188,7 @@ function useSubmitUserResponseForTask() {
31175
31188
  }
31176
31189
  });
31177
31190
  }
31178
- function buildKey$l({
31191
+ function buildKey$p({
31179
31192
  access_token: accessToken,
31180
31193
  apiUrl,
31181
31194
  businessId
@@ -31194,7 +31207,7 @@ function useUpdateTaskUploadDescription() {
31194
31207
  const { businessId } = useLayerContext();
31195
31208
  const { mutate } = useSWRConfig();
31196
31209
  const mutationResponse = useSWRMutation(
31197
- () => buildKey$l(__spreadProps(__spreadValues({}, auth), {
31210
+ () => buildKey$p(__spreadProps(__spreadValues({}, auth), {
31198
31211
  businessId
31199
31212
  })),
31200
31213
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, description } }) => updateTaskUploadsDescription(
@@ -31237,7 +31250,7 @@ function useUpdateTaskUploadDescription() {
31237
31250
  }
31238
31251
  });
31239
31252
  }
31240
- function buildKey$k({
31253
+ function buildKey$o({
31241
31254
  access_token: accessToken,
31242
31255
  apiUrl,
31243
31256
  businessId
@@ -31256,7 +31269,7 @@ function useUploadDocumentsForTask() {
31256
31269
  const { businessId } = useLayerContext();
31257
31270
  const { mutate } = useSWRConfig();
31258
31271
  const mutationResponse = useSWRMutation(
31259
- () => buildKey$k(__spreadProps(__spreadValues({}, auth), {
31272
+ () => buildKey$o(__spreadProps(__spreadValues({}, auth), {
31260
31273
  businessId
31261
31274
  })),
31262
31275
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: { taskId, files, description } }) => completeTaskWithUpload(
@@ -31801,8 +31814,8 @@ const useBookkeepingYearsStatus = () => {
31801
31814
  isLoading
31802
31815
  };
31803
31816
  };
31804
- const ArrowRightCircle = (_Qc) => {
31805
- var _Rc = _Qc, { size = 18 } = _Rc, props = __objRest(_Rc, ["size"]);
31817
+ const ArrowRightCircle = (_Sc) => {
31818
+ var _Tc = _Sc, { size = 18 } = _Tc, props = __objRest(_Tc, ["size"]);
31806
31819
  return /* @__PURE__ */ jsxs(
31807
31820
  "svg",
31808
31821
  __spreadProps(__spreadValues({
@@ -33284,7 +33297,7 @@ class BookkeepingConfigurationSWRResponse {
33284
33297
  return this.swrResponse.mutate;
33285
33298
  }
33286
33299
  }
33287
- function buildKey$j({
33300
+ function buildKey$n({
33288
33301
  access_token: accessToken,
33289
33302
  apiUrl,
33290
33303
  businessId
@@ -33305,7 +33318,7 @@ function useBookkeepingConfiguration() {
33305
33318
  const { apiUrl } = useEnvironment();
33306
33319
  const { data: auth } = useAuth();
33307
33320
  const { businessId } = useLayerContext();
33308
- const queryKey = buildKey$j(__spreadProps(__spreadValues({}, auth), {
33321
+ const queryKey = buildKey$n(__spreadProps(__spreadValues({}, auth), {
33309
33322
  apiUrl,
33310
33323
  businessId
33311
33324
  }));
@@ -33492,7 +33505,7 @@ const BookOnboardingCallStep = ({ title = defaultTitle$3, description = defaultD
33492
33505
  ] });
33493
33506
  };
33494
33507
  const BUSINESS_TAG_KEY = "business";
33495
- function buildKey$i({
33508
+ function buildKey$m({
33496
33509
  access_token: accessToken,
33497
33510
  apiUrl,
33498
33511
  businessId
@@ -33511,7 +33524,7 @@ function useUpdateBusiness() {
33511
33524
  const { businessId } = useLayerContext();
33512
33525
  const { mutate } = useSWRConfig();
33513
33526
  const mutationResponse = useSWRMutation(
33514
- () => buildKey$i(__spreadProps(__spreadValues({}, data), {
33527
+ () => buildKey$m(__spreadProps(__spreadValues({}, data), {
33515
33528
  businessId
33516
33529
  })),
33517
33530
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => updateBusiness(
@@ -33562,7 +33575,7 @@ function isPersonnelRole(role) {
33562
33575
  return PERSONNEL_ROLES.includes(role);
33563
33576
  }
33564
33577
  const BUSINESS_PERSONNEL_TAG_KEY = "#business-personnel";
33565
- function buildKey$h({
33578
+ function buildKey$l({
33566
33579
  access_token: accessToken,
33567
33580
  apiUrl,
33568
33581
  businessId
@@ -33581,7 +33594,7 @@ function useBusinessPersonnel() {
33581
33594
  const { data } = useAuth();
33582
33595
  const { businessId } = useLayerContext();
33583
33596
  return useSWR(
33584
- () => buildKey$h(__spreadProps(__spreadValues({}, data), {
33597
+ () => buildKey$l(__spreadProps(__spreadValues({}, data), {
33585
33598
  businessId
33586
33599
  })),
33587
33600
  ({ accessToken, apiUrl, businessId: businessId2 }) => getBusinessPersonnel(
@@ -33619,7 +33632,7 @@ function useBusinessPersonnel() {
33619
33632
  );
33620
33633
  }
33621
33634
  const createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
33622
- function buildKey$g({
33635
+ function buildKey$k({
33623
33636
  access_token: accessToken,
33624
33637
  apiUrl,
33625
33638
  businessId
@@ -33638,7 +33651,7 @@ function useCreateBusinessPersonnel() {
33638
33651
  const { businessId } = useLayerContext();
33639
33652
  const { mutate } = useSWRConfig();
33640
33653
  const mutationResponse = useSWRMutation(
33641
- () => buildKey$g(__spreadProps(__spreadValues({}, data), {
33654
+ () => buildKey$k(__spreadProps(__spreadValues({}, data), {
33642
33655
  businessId
33643
33656
  })),
33644
33657
  ({ accessToken, apiUrl, businessId: businessId2 }, { arg: body }) => createBusinessPersonnel(
@@ -33681,7 +33694,7 @@ function useCreateBusinessPersonnel() {
33681
33694
  const updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
33682
33695
  return `/v1/businesses/${businessId}/personnel/${businessPersonnelId}/update`;
33683
33696
  });
33684
- function buildKey$f({
33697
+ function buildKey$j({
33685
33698
  access_token: accessToken,
33686
33699
  apiUrl,
33687
33700
  businessId,
@@ -33702,7 +33715,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
33702
33715
  const { businessId } = useLayerContext();
33703
33716
  const { mutate } = useSWRConfig();
33704
33717
  const mutationResponse = useSWRMutation(
33705
- () => buildKey$f(__spreadProps(__spreadValues({}, data), {
33718
+ () => buildKey$j(__spreadProps(__spreadValues({}, data), {
33706
33719
  businessId,
33707
33720
  businessPersonnelId
33708
33721
  })),
@@ -33850,12 +33863,12 @@ const FormSection = ({ children, title }) => {
33850
33863
  children
33851
33864
  ] });
33852
33865
  };
33853
- const PhoneInput = (_Sc) => {
33854
- var _Tc = _Sc, {
33866
+ const PhoneInput = (_Uc) => {
33867
+ var _Vc = _Uc, {
33855
33868
  value,
33856
33869
  onChange,
33857
33870
  placeholder = "Phone number"
33858
- } = _Tc, props = __objRest(_Tc, [
33871
+ } = _Vc, props = __objRest(_Vc, [
33859
33872
  "value",
33860
33873
  "onChange",
33861
33874
  "placeholder"
@@ -34147,8 +34160,8 @@ const SummaryStep = ({ onNext, title = defaultTitle$1, description = defaultDesc
34147
34160
  /* @__PURE__ */ jsx(Button$1, { onClick: onNext, children: nextBtnText })
34148
34161
  ] });
34149
34162
  };
34150
- const Document = (_Uc) => {
34151
- var _Vc = _Uc, { size = 20 } = _Vc, props = __objRest(_Vc, ["size"]);
34163
+ const Document = (_Wc) => {
34164
+ var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
34152
34165
  return /* @__PURE__ */ jsxs(
34153
34166
  "svg",
34154
34167
  __spreadProps(__spreadValues({
@@ -34253,8 +34266,8 @@ const Document = (_Uc) => {
34253
34266
  })
34254
34267
  );
34255
34268
  };
34256
- const TrendingUp = (_Wc) => {
34257
- var _Xc = _Wc, { size = 20 } = _Xc, props = __objRest(_Xc, ["size"]);
34269
+ const TrendingUp = (_Yc) => {
34270
+ var _Zc = _Yc, { size = 20 } = _Zc, props = __objRest(_Zc, ["size"]);
34258
34271
  return /* @__PURE__ */ jsxs(
34259
34272
  "svg",
34260
34273
  __spreadProps(__spreadValues({
@@ -34511,8 +34524,8 @@ const PlatformOnboarding = ({ onComplete }) => {
34511
34524
  /* @__PURE__ */ jsx("div", { className: "Layer__platform-onboarding-layout__footer", children: renderStepFooter() })
34512
34525
  ] }) });
34513
34526
  };
34514
- const CoffeeIcon = (_Yc) => {
34515
- var _Zc = _Yc, { size = 11 } = _Zc, props = __objRest(_Zc, ["size"]);
34527
+ const CoffeeIcon = (__c) => {
34528
+ var _$c = __c, { size = 11 } = _$c, props = __objRest(_$c, ["size"]);
34516
34529
  return /* @__PURE__ */ jsxs(
34517
34530
  "svg",
34518
34531
  __spreadProps(__spreadValues({
@@ -34583,8 +34596,8 @@ const CoffeeIcon = (_Yc) => {
34583
34596
  })
34584
34597
  );
34585
34598
  };
34586
- const Link$1 = (__c) => {
34587
- var _$c = __c, {
34599
+ const Link$1 = (_ad) => {
34600
+ var _bd = _ad, {
34588
34601
  className,
34589
34602
  children,
34590
34603
  variant = ButtonVariant.primary,
@@ -34594,7 +34607,7 @@ const Link$1 = (__c) => {
34594
34607
  iconAsPrimary = false,
34595
34608
  justify = "center",
34596
34609
  fullWidth
34597
- } = _$c, props = __objRest(_$c, [
34610
+ } = _bd, props = __objRest(_bd, [
34598
34611
  "className",
34599
34612
  "children",
34600
34613
  "variant",
@@ -34686,8 +34699,8 @@ const BookkeepingUpsellBar = ({
34686
34699
  onClick ? /* @__PURE__ */ jsx(Button$1, { variant: ButtonVariant.secondary, onClick, children: "Schedule a demo" }) : href ? /* @__PURE__ */ jsx(Link$1, { href, target: "_blank", variant: ButtonVariant.secondary, children: "Schedule a demo" }) : null
34687
34700
  ] });
34688
34701
  };
34689
- const ChevronRightFill = (_ad) => {
34690
- var _bd = _ad, { size = 18 } = _bd, props = __objRest(_bd, ["size"]);
34702
+ const ChevronRightFill = (_cd) => {
34703
+ var _dd = _cd, { size = 18 } = _dd, props = __objRest(_dd, ["size"]);
34691
34704
  return /* @__PURE__ */ jsxs(
34692
34705
  "svg",
34693
34706
  __spreadProps(__spreadValues({
@@ -34714,7 +34727,7 @@ const ChevronRightFill = (_ad) => {
34714
34727
  };
34715
34728
  const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
34716
34729
  const { showCount, totalCount } = count != null ? count : {};
34717
- const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
34730
+ const { Filters, HeaderActions, HeaderFilters } = slots;
34718
34731
  return /* @__PURE__ */ jsxs(VStack, { children: [
34719
34732
  /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "xs", className: "Layer__DataTableHeader__Header", children: [
34720
34733
  /* @__PURE__ */ jsxs(HStack, { pis: "md", align: "center", gap: "xl", children: [
@@ -34729,8 +34742,8 @@ const DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
34729
34742
  HeaderActions && /* @__PURE__ */ jsx(HeaderActions, {})
34730
34743
  ] })
34731
34744
  ] }),
34732
- Filters2 && /* @__PURE__ */ jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
34733
- /* @__PURE__ */ jsx(Filters2, {}),
34745
+ Filters && /* @__PURE__ */ jsxs(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
34746
+ /* @__PURE__ */ jsx(Filters, {}),
34734
34747
  slotProps.ClearFiltersButton && /* @__PURE__ */ jsx(Button, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
34735
34748
  ] })
34736
34749
  ] });
@@ -35655,7 +35668,7 @@ class InvoiceSummaryStatsSWRResponse {
35655
35668
  return this.swrResponse.error !== void 0;
35656
35669
  }
35657
35670
  }
35658
- function buildKey$e({
35671
+ function buildKey$i({
35659
35672
  access_token: accessToken,
35660
35673
  apiUrl,
35661
35674
  businessId
@@ -35674,7 +35687,7 @@ function useInvoiceSummaryStats() {
35674
35687
  const { data } = useAuth();
35675
35688
  const { businessId } = useLayerContext();
35676
35689
  const response = useSWR(
35677
- () => buildKey$e(__spreadProps(__spreadValues({}, data), {
35690
+ () => buildKey$i(__spreadProps(__spreadValues({}, data), {
35678
35691
  businessId
35679
35692
  })),
35680
35693
  ({ accessToken, apiUrl, businessId: businessId2 }) => getInvoiceSummaryStats(
@@ -35705,7 +35718,7 @@ var UpsertInvoiceMode = /* @__PURE__ */ ((UpsertInvoiceMode2) => {
35705
35718
  })(UpsertInvoiceMode || {});
35706
35719
  const createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
35707
35720
  const updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
35708
- function buildKey$d({
35721
+ function buildKey$h({
35709
35722
  access_token: accessToken,
35710
35723
  apiUrl,
35711
35724
  businessId,
@@ -35777,7 +35790,7 @@ const useUpsertInvoice = (props) => {
35777
35790
  const { mode } = props;
35778
35791
  const invoiceId = mode === "Update" ? props.invoiceId : void 0;
35779
35792
  const rawMutationResponse = useSWRMutation(
35780
- () => buildKey$d(__spreadProps(__spreadValues({}, data), {
35793
+ () => buildKey$h(__spreadProps(__spreadValues({}, data), {
35781
35794
  businessId,
35782
35795
  invoiceId
35783
35796
  })),
@@ -36046,7 +36059,7 @@ const RefundInvoiceReturnSchema = Schema.Struct({
36046
36059
  data: CustomerRefundSchema
36047
36060
  });
36048
36061
  const refundInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/refund`);
36049
- function buildKey$c({
36062
+ function buildKey$g({
36050
36063
  access_token: accessToken,
36051
36064
  apiUrl,
36052
36065
  businessId,
@@ -36091,7 +36104,7 @@ const useRefundInvoice = ({ invoiceId }) => {
36091
36104
  return updateInvoiceWithRefund(invoice);
36092
36105
  }, [invoiceId]);
36093
36106
  const rawMutationResponse = useSWRMutation(
36094
- () => buildKey$c(__spreadProps(__spreadValues({}, data), {
36107
+ () => buildKey$g(__spreadProps(__spreadValues({}, data), {
36095
36108
  businessId,
36096
36109
  invoiceId
36097
36110
  })),
@@ -36279,7 +36292,7 @@ const ResetInvoiceReturnSchema = Schema.Struct({
36279
36292
  data: InvoiceSchema
36280
36293
  });
36281
36294
  const resetInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/reset`);
36282
- function buildKey$b({
36295
+ function buildKey$f({
36283
36296
  access_token: accessToken,
36284
36297
  apiUrl,
36285
36298
  businessId,
@@ -36317,7 +36330,7 @@ const useResetInvoice = ({ invoiceId }) => {
36317
36330
  const { data } = useAuth();
36318
36331
  const { businessId } = useLayerContext();
36319
36332
  const rawMutationResponse = useSWRMutation(
36320
- () => buildKey$b(__spreadProps(__spreadValues({}, data), {
36333
+ () => buildKey$f(__spreadProps(__spreadValues({}, data), {
36321
36334
  businessId,
36322
36335
  invoiceId
36323
36336
  })),
@@ -36380,7 +36393,7 @@ const VoidInvoiceReturnSchema = Schema.Struct({
36380
36393
  data: InvoiceSchema
36381
36394
  });
36382
36395
  const voidInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/void`);
36383
- function buildKey$a({
36396
+ function buildKey$e({
36384
36397
  access_token: accessToken,
36385
36398
  apiUrl,
36386
36399
  businessId,
@@ -36418,7 +36431,7 @@ const useVoidInvoice = ({ invoiceId }) => {
36418
36431
  const { data } = useAuth();
36419
36432
  const { businessId } = useLayerContext();
36420
36433
  const rawMutationResponse = useSWRMutation(
36421
- () => buildKey$a(__spreadProps(__spreadValues({}, data), {
36434
+ () => buildKey$e(__spreadProps(__spreadValues({}, data), {
36422
36435
  businessId,
36423
36436
  invoiceId
36424
36437
  })),
@@ -36537,7 +36550,7 @@ const InvoiceWriteoffSchema = Schema.Struct({
36537
36550
  });
36538
36551
  const CREATE_INVOICE_WRITEOFF_TAG_KEY = "#writeoff-invoice";
36539
36552
  const writeoffInvoice = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/write-off`);
36540
- function buildKey$9({
36553
+ function buildKey$d({
36541
36554
  access_token: accessToken,
36542
36555
  apiUrl,
36543
36556
  businessId,
@@ -36588,7 +36601,7 @@ const useWriteoffInvoice = ({ invoiceId }) => {
36588
36601
  return updateInvoiceWithWriteoff(invoice);
36589
36602
  }, [invoiceId]);
36590
36603
  const rawMutationResponse = useSWRMutation(
36591
- () => buildKey$9(__spreadProps(__spreadValues({}, data), {
36604
+ () => buildKey$d(__spreadProps(__spreadValues({}, data), {
36592
36605
  businessId,
36593
36606
  invoiceId
36594
36607
  })),
@@ -37584,7 +37597,7 @@ var UpsertDedicatedInvoicePaymentMode = /* @__PURE__ */ ((UpsertDedicatedInvoice
37584
37597
  })(UpsertDedicatedInvoicePaymentMode || {});
37585
37598
  const createDedicatedInvoicePayment = post(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/`);
37586
37599
  const updateDedicatedInvoicePayment = put(({ businessId, invoiceId, invoicePaymentId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}/payment/${invoicePaymentId}`);
37587
- function buildKey$8({
37600
+ function buildKey$c({
37588
37601
  access_token: accessToken,
37589
37602
  apiUrl,
37590
37603
  businessId,
@@ -37669,7 +37682,7 @@ const useUpsertDedicatedInvoicePayment = (props) => {
37669
37682
  return updateInvoiceWithPayment(invoice, invoicePayment);
37670
37683
  }, [invoiceId]);
37671
37684
  const rawMutationResponse = useSWRMutation(
37672
- () => buildKey$8(__spreadProps(__spreadValues({}, data), {
37685
+ () => buildKey$c(__spreadProps(__spreadValues({}, data), {
37673
37686
  businessId,
37674
37687
  invoiceId,
37675
37688
  invoicePaymentId
@@ -37969,8 +37982,8 @@ const getClassnameForSubComponent = (className, suffix) => {
37969
37982
  };
37970
37983
  const METER_CLASS_NAME = "Layer__Meter";
37971
37984
  const Meter = forwardRef(
37972
- function Meter2(_cd, ref) {
37973
- var _dd = _cd, { className, label, meterOnly } = _dd, restProps = __objRest(_dd, ["className", "label", "meterOnly"]);
37985
+ function Meter2(_ed, ref) {
37986
+ var _fd = _ed, { className, label, meterOnly } = _fd, restProps = __objRest(_fd, ["className", "label", "meterOnly"]);
37974
37987
  return /* @__PURE__ */ jsx(Meter$1, __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, restProps), { className: classNames(METER_CLASS_NAME, className), ref }), meterOnly && { "aria-label": label }), { children: ({ percentage, valueText }) => /* @__PURE__ */ jsxs(VStack, { gap: "3xs", fluid: true, children: [
37975
37988
  !meterOnly && /* @__PURE__ */ jsxs(HStack, { justify: "space-between", children: [
37976
37989
  /* @__PURE__ */ jsx(Label, { slot: "label", children: label }),
@@ -38085,11 +38098,11 @@ const ProfitAndLossView = (props) => {
38085
38098
  const containerRef = useRef(null);
38086
38099
  return /* @__PURE__ */ jsx(Container, { name: COMPONENT_NAME$3, ref: containerRef, children: /* @__PURE__ */ jsx(ProfitAndLoss, { children: /* @__PURE__ */ jsx(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
38087
38100
  };
38088
- const ProfitAndLossPanel = (_ed) => {
38089
- var _fd = _ed, {
38101
+ const ProfitAndLossPanel = (_gd) => {
38102
+ var _hd = _gd, {
38090
38103
  containerRef,
38091
38104
  stringOverrides
38092
- } = _fd, props = __objRest(_fd, [
38105
+ } = _hd, props = __objRest(_hd, [
38093
38106
  "containerRef",
38094
38107
  "stringOverrides"
38095
38108
  ]);
@@ -38352,13 +38365,13 @@ function ExpandableDataTable({
38352
38365
  );
38353
38366
  }
38354
38367
  const UNIFIED_REPORT_TAG_KEY = "#unified-report";
38355
- function buildKey$7(_gd) {
38356
- var _hd = _gd, {
38368
+ function buildKey$b(_id) {
38369
+ var _jd = _id, {
38357
38370
  access_token: accessToken,
38358
38371
  apiUrl,
38359
38372
  businessId,
38360
38373
  report
38361
- } = _hd, dateParams = __objRest(_hd, [
38374
+ } = _jd, dateParams = __objRest(_jd, [
38362
38375
  "access_token",
38363
38376
  "apiUrl",
38364
38377
  "businessId",
@@ -38374,8 +38387,8 @@ function buildKey$7(_gd) {
38374
38387
  }, dateParams);
38375
38388
  }
38376
38389
  }
38377
- const getUnifiedReport = get((_id) => {
38378
- var _jd = _id, { businessId, report } = _jd, dateParams = __objRest(_jd, ["businessId", "report"]);
38390
+ const getUnifiedReport = get((_kd) => {
38391
+ var _ld = _kd, { businessId, report } = _ld, dateParams = __objRest(_ld, ["businessId", "report"]);
38379
38392
  const parameters = toDefinedSearchParameters(__spreadValues({}, dateParams));
38380
38393
  return `/v1/businesses/${businessId}/reports/unified/${report}?${parameters}`;
38381
38394
  });
@@ -38404,13 +38417,13 @@ class UnifiedReportSWRResponse {
38404
38417
  return this.swrResponse.mutate;
38405
38418
  }
38406
38419
  }
38407
- function useUnifiedReport(_kd) {
38408
- var _ld = _kd, { report } = _ld, dateParams = __objRest(_ld, ["report"]);
38420
+ function useUnifiedReport(_md) {
38421
+ var _nd = _md, { report } = _nd, dateParams = __objRest(_nd, ["report"]);
38409
38422
  const { data: auth } = useAuth();
38410
38423
  const { apiUrl } = useEnvironment();
38411
38424
  const { businessId } = useLayerContext();
38412
38425
  const swrResponse = useSWR(
38413
- () => buildKey$7(__spreadValues(__spreadProps(__spreadValues({}, auth), {
38426
+ () => buildKey$b(__spreadValues(__spreadProps(__spreadValues({}, auth), {
38414
38427
  apiUrl,
38415
38428
  businessId,
38416
38429
  report
@@ -38526,7 +38539,7 @@ class DownloadUnifiedReportSWRResponse {
38526
38539
  return this.swrResponse.error !== void 0;
38527
38540
  }
38528
38541
  }
38529
- function buildKey$6({
38542
+ function buildKey$a({
38530
38543
  access_token: accessToken,
38531
38544
  apiUrl,
38532
38545
  businessId,
@@ -38577,7 +38590,7 @@ function useUnifiedReportDownload({ onSuccess } = {}) {
38577
38590
  const { businessId } = useLayerContext();
38578
38591
  const reportWithDateParams = useUnifiedReportWithDateParams();
38579
38592
  const rawMutationResponse = useSWRMutation(
38580
- () => buildKey$6(__spreadProps(__spreadValues({}, auth), {
38593
+ () => buildKey$a(__spreadProps(__spreadValues({}, auth), {
38581
38594
  businessId,
38582
38595
  reportWithDateParams
38583
38596
  })),
@@ -38953,7 +38966,7 @@ const useBills = () => {
38953
38966
  refetch
38954
38967
  };
38955
38968
  };
38956
- function buildKey$5({
38969
+ function buildKey$9({
38957
38970
  access_token: accessToken,
38958
38971
  apiUrl,
38959
38972
  businessId,
@@ -39087,7 +39100,7 @@ const useBillsRecordPayment = ({ refetchAllBills }) => {
39087
39100
  };
39088
39101
  }, [billsToPay, paymentDate, paymentMethod]);
39089
39102
  const createPaymentMutation = useSWRMutation(
39090
- () => buildKey$5({
39103
+ () => buildKey$9({
39091
39104
  access_token: auth == null ? void 0 : auth.access_token,
39092
39105
  apiUrl: auth == null ? void 0 : auth.apiUrl,
39093
39106
  businessId,
@@ -39416,7 +39429,7 @@ const BillsPaymentRecorded = ({
39416
39429
  ] })
39417
39430
  ] });
39418
39431
  };
39419
- function buildKey$4({
39432
+ function buildKey$8({
39420
39433
  access_token: accessToken,
39421
39434
  apiUrl,
39422
39435
  businessId,
@@ -39437,7 +39450,7 @@ const useUnpaidBillsByVendor = ({ vendorId }) => {
39437
39450
  const { data: auth } = useAuth();
39438
39451
  const { apiUrl } = useEnvironment();
39439
39452
  return useSWR(
39440
- () => buildKey$4(__spreadProps(__spreadValues({}, auth), {
39453
+ () => buildKey$8(__spreadProps(__spreadValues({}, auth), {
39441
39454
  apiUrl,
39442
39455
  businessId,
39443
39456
  vendorId
@@ -39935,19 +39948,19 @@ const VendorsProvider = ({ children }) => {
39935
39948
  const vendors = useVendors();
39936
39949
  return /* @__PURE__ */ jsx(VendorsContext.Provider, { value: vendors, children });
39937
39950
  };
39938
- const SelectVendor = (_md) => {
39939
- var _nd = _md, { withContext = true } = _nd, props = __objRest(_nd, ["withContext"]);
39951
+ const SelectVendor = (_od) => {
39952
+ var _pd = _od, { withContext = true } = _pd, props = __objRest(_pd, ["withContext"]);
39940
39953
  if (withContext) {
39941
39954
  return /* @__PURE__ */ jsx(VendorsProvider, { children: /* @__PURE__ */ jsx(SelectVendorContent, __spreadValues({}, props)) });
39942
39955
  }
39943
39956
  return /* @__PURE__ */ jsx(SelectVendorContent, __spreadValues({}, props));
39944
39957
  };
39945
- const SelectVendorContent = (_od) => {
39946
- var _pd = _od, {
39958
+ const SelectVendorContent = (_qd) => {
39959
+ var _rd = _qd, {
39947
39960
  value,
39948
39961
  onChange,
39949
39962
  placeholder = "Select vendor"
39950
- } = _pd, props = __objRest(_pd, [
39963
+ } = _rd, props = __objRest(_rd, [
39951
39964
  "value",
39952
39965
  "onChange",
39953
39966
  "placeholder"
@@ -40714,8 +40727,8 @@ const BillsTableWithPanel = ({
40714
40727
  }
40715
40728
  );
40716
40729
  };
40717
- const Bills = (_qd) => {
40718
- var _rd = _qd, { context = true } = _rd, props = __objRest(_rd, ["context"]);
40730
+ const Bills = (_sd) => {
40731
+ var _td = _sd, { context = true } = _td, props = __objRest(_td, ["context"]);
40719
40732
  if (context) {
40720
40733
  return /* @__PURE__ */ jsx(BillsProvider, { children: /* @__PURE__ */ jsx(BillsContent, __spreadValues({}, props)) });
40721
40734
  }
@@ -40773,8 +40786,8 @@ const getTimezoneDisplay = (date) => {
40773
40786
  };
40774
40787
  const LINK_CLASS_NAME = "Layer__UI__Link";
40775
40788
  const Link = forwardRef(
40776
- function Link2(_sd, ref) {
40777
- var _td = _sd, {
40789
+ function Link2(_ud, ref) {
40790
+ var _vd = _ud, {
40778
40791
  children,
40779
40792
  size = "md",
40780
40793
  ellipsis,
@@ -40783,7 +40796,7 @@ const Link = forwardRef(
40783
40796
  href,
40784
40797
  target,
40785
40798
  rel
40786
- } = _td, restProps = __objRest(_td, [
40799
+ } = _vd, restProps = __objRest(_vd, [
40787
40800
  "children",
40788
40801
  "size",
40789
40802
  "ellipsis",
@@ -41308,6 +41321,18 @@ const VehicleSchema = Schema.Struct({
41308
41321
  deletedAt: pipe(
41309
41322
  Schema.propertySignature(Schema.NullishOr(Schema.Date)),
41310
41323
  Schema.fromKey("deleted_at")
41324
+ ),
41325
+ archivedAt: pipe(
41326
+ Schema.propertySignature(Schema.NullishOr(Schema.Date)),
41327
+ Schema.fromKey("archived_at")
41328
+ ),
41329
+ isPrimary: pipe(
41330
+ Schema.propertySignature(Schema.Boolean),
41331
+ Schema.fromKey("is_primary")
41332
+ ),
41333
+ isEligibleForDeletion: pipe(
41334
+ Schema.propertySignature(Schema.Boolean),
41335
+ Schema.fromKey("is_eligible_for_deletion")
41311
41336
  )
41312
41337
  });
41313
41338
  Schema.Struct({
@@ -41315,7 +41340,8 @@ Schema.Struct({
41315
41340
  year: Schema.Number,
41316
41341
  licensePlate: Schema.String,
41317
41342
  vin: Schema.String,
41318
- description: Schema.String
41343
+ description: Schema.String,
41344
+ isPrimary: Schema.Boolean
41319
41345
  });
41320
41346
  const UpsertVehicleSchema = Schema.Struct({
41321
41347
  makeAndModel: pipe(
@@ -41328,7 +41354,11 @@ const UpsertVehicleSchema = Schema.Struct({
41328
41354
  Schema.fromKey("license_plate")
41329
41355
  ),
41330
41356
  vin: Schema.NullishOr(Schema.String),
41331
- description: Schema.NullishOr(Schema.String)
41357
+ description: Schema.NullishOr(Schema.String),
41358
+ isPrimary: pipe(
41359
+ Schema.propertySignature(Schema.Boolean),
41360
+ Schema.fromKey("is_primary")
41361
+ )
41332
41362
  });
41333
41363
  const CalendarDateFromSelf = Schema.declare(
41334
41364
  (input) => input instanceof CalendarDate
@@ -41475,6 +41505,7 @@ const TripsRouteStoreContext = createContext(
41475
41505
  selectedVehicle: null,
41476
41506
  purposeFilter: TripPurposeFilterValue.All
41477
41507
  },
41508
+ currentTripsPage: 0,
41478
41509
  setTableFilters: () => {
41479
41510
  },
41480
41511
  navigate: {
@@ -41482,6 +41513,10 @@ const TripsRouteStoreContext = createContext(
41482
41513
  },
41483
41514
  toVehicleManagement: () => {
41484
41515
  }
41516
+ },
41517
+ actions: {
41518
+ setCurrentTripsPage: () => {
41519
+ }
41485
41520
  }
41486
41521
  }))
41487
41522
  );
@@ -41499,6 +41534,15 @@ function useTripsNavigation() {
41499
41534
  const store = useContext(TripsRouteStoreContext);
41500
41535
  return useStore(store, (state) => state.navigate);
41501
41536
  }
41537
+ function useCurrentTripsPage() {
41538
+ const store = useContext(TripsRouteStoreContext);
41539
+ const currentTripsPage = useStore(store, (state) => state.currentTripsPage);
41540
+ const setCurrentTripsPage = useStore(store, (state) => state.actions.setCurrentTripsPage);
41541
+ return useMemo(
41542
+ () => ({ currentTripsPage, setCurrentTripsPage }),
41543
+ [currentTripsPage, setCurrentTripsPage]
41544
+ );
41545
+ }
41502
41546
  function TripsRouteStoreProvider(props) {
41503
41547
  const [store] = useState(
41504
41548
  () => createStore((set2) => ({
@@ -41511,6 +41555,7 @@ function TripsRouteStoreProvider(props) {
41511
41555
  selectedVehicle: null,
41512
41556
  purposeFilter: TripPurposeFilterValue.All
41513
41557
  },
41558
+ currentTripsPage: 0,
41514
41559
  setTableFilters: (patchFilters) => {
41515
41560
  set2((state) => ({
41516
41561
  tableFilters: __spreadValues(__spreadValues({}, state.tableFilters), patchFilters)
@@ -41533,65 +41578,28 @@ function TripsRouteStoreProvider(props) {
41533
41578
  }
41534
41579
  }));
41535
41580
  }
41581
+ },
41582
+ actions: {
41583
+ setCurrentTripsPage: (page) => {
41584
+ set2({ currentTripsPage: page });
41585
+ }
41536
41586
  }
41537
41587
  }))
41538
41588
  );
41539
41589
  return /* @__PURE__ */ jsx(TripsRouteStoreContext.Provider, { value: store, children: props.children });
41540
41590
  }
41541
- const getTripFormDefaultValues = (trip) => {
41542
- if (trip) {
41543
- return {
41544
- vehicle: trip.vehicle,
41545
- tripDate: trip.tripDate,
41546
- distance: trip.distance,
41547
- purpose: trip.purpose,
41548
- startAddress: trip.startAddress || "",
41549
- endAddress: trip.endAddress || "",
41550
- description: trip.description || ""
41551
- };
41552
- }
41553
- return {
41554
- vehicle: null,
41555
- tripDate: today(getLocalTimeZone()),
41556
- distance: BIG_DECIMAL_ZERO,
41557
- purpose: TripPurpose.Business,
41558
- startAddress: "",
41559
- endAddress: "",
41560
- description: ""
41561
- };
41562
- };
41563
- const validateTripForm = ({ trip }) => {
41564
- const { vehicle, tripDate, distance, purpose } = trip;
41565
- const errors = [];
41566
- if (tripDate === null) {
41567
- errors.push({ tripDate: "Trip date is a required field." });
41568
- }
41569
- if (tripDate && tripDate.compare(today(getLocalTimeZone())) > 0) {
41570
- errors.push({ tripDate: "Trip date cannot be in the future." });
41571
- }
41572
- if (!BigDecimal.isPositive(distance)) {
41573
- errors.push({ distance: "Distance must be greater than zero." });
41574
- }
41575
- if (!purpose) {
41576
- errors.push({ purpose: "Purpose is a required field." });
41591
+ function useAutoResetPageIndex(filters, data) {
41592
+ const autoResetPageIndexRef = useRef(false);
41593
+ const prevFiltersRef = useRef(filters);
41594
+ if (prevFiltersRef.current !== filters) {
41595
+ autoResetPageIndexRef.current = true;
41596
+ prevFiltersRef.current = filters;
41577
41597
  }
41578
- if (vehicle === null) {
41579
- errors.push({ vehicle: "Vehicle is a required field." });
41580
- }
41581
- return errors.length > 0 ? errors : null;
41582
- };
41583
- const convertTripFormToUpsertTrip = (form) => {
41584
- var _a;
41585
- return {
41586
- vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
41587
- tripDate: form.tripDate,
41588
- distance: form.distance,
41589
- purpose: form.purpose,
41590
- startAddress: form.startAddress.trim() || null,
41591
- endAddress: form.endAddress.trim() || null,
41592
- description: form.description.trim() || null
41593
- };
41594
- };
41598
+ useEffect(() => {
41599
+ autoResetPageIndexRef.current = false;
41600
+ }, [data]);
41601
+ return autoResetPageIndexRef;
41602
+ }
41595
41603
  const LIST_TRIPS_TAG_KEY = "#list-trips";
41596
41604
  const ListTripsResponseSchema = Schema.Struct({
41597
41605
  data: Schema.Array(TripSchema),
@@ -41715,6 +41723,243 @@ function useTripsGlobalCacheActions() {
41715
41723
  );
41716
41724
  return { patchTripByKey, forceReloadTrips };
41717
41725
  }
41726
+ const ListVehiclesResponseSchema = Schema.Struct({
41727
+ data: Schema.Array(VehicleSchema)
41728
+ });
41729
+ const listVehicles = get(({ businessId, allowArchived }) => {
41730
+ const parameters = toDefinedSearchParameters({ allowArchived });
41731
+ return `/v1/businesses/${businessId}/mileage/vehicles?${parameters}`;
41732
+ });
41733
+ const VEHICLES_TAG_KEY = "#list-vehicles";
41734
+ function buildKey$7({
41735
+ access_token: accessToken,
41736
+ apiUrl,
41737
+ businessId,
41738
+ allowArchived
41739
+ }) {
41740
+ if (accessToken && apiUrl) {
41741
+ return {
41742
+ accessToken,
41743
+ apiUrl,
41744
+ businessId,
41745
+ allowArchived,
41746
+ tags: [VEHICLES_TAG_KEY]
41747
+ };
41748
+ }
41749
+ }
41750
+ class ListVehiclesSWRResponse {
41751
+ constructor(swrResponse) {
41752
+ __publicField(this, "swrResponse");
41753
+ this.swrResponse = swrResponse;
41754
+ }
41755
+ get data() {
41756
+ var _a;
41757
+ return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
41758
+ }
41759
+ get isLoading() {
41760
+ return this.swrResponse.isLoading;
41761
+ }
41762
+ get isValidating() {
41763
+ return this.swrResponse.isValidating;
41764
+ }
41765
+ get isError() {
41766
+ return this.swrResponse.error !== void 0;
41767
+ }
41768
+ }
41769
+ function useListVehicles({ allowArchived } = {}) {
41770
+ const { data } = useAuth();
41771
+ const { businessId } = useLayerContext();
41772
+ const response = useSWR(
41773
+ () => buildKey$7(__spreadProps(__spreadValues({}, data), {
41774
+ businessId,
41775
+ allowArchived
41776
+ })),
41777
+ ({ accessToken, apiUrl, businessId: businessId2, allowArchived: allowArchived2 }) => listVehicles(
41778
+ apiUrl,
41779
+ accessToken,
41780
+ {
41781
+ params: {
41782
+ businessId: businessId2,
41783
+ allowArchived: allowArchived2
41784
+ }
41785
+ }
41786
+ )().then(Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
41787
+ );
41788
+ return new ListVehiclesSWRResponse(response);
41789
+ }
41790
+ const withUpdatedVehicle = (updated) => (vehicle) => vehicle.id === updated.id ? updated : vehicle;
41791
+ function useVehiclesGlobalCacheActions() {
41792
+ const { patchCache, forceReload } = useGlobalCacheActions();
41793
+ const patchVehicleByKey = useCallback(
41794
+ (updatedVehicle) => patchCache(
41795
+ (tags) => tags.includes(VEHICLES_TAG_KEY),
41796
+ (currentData) => {
41797
+ if (!currentData) return currentData;
41798
+ return __spreadProps(__spreadValues({}, currentData), {
41799
+ data: currentData.data.map(withUpdatedVehicle(updatedVehicle))
41800
+ });
41801
+ }
41802
+ ),
41803
+ [patchCache]
41804
+ );
41805
+ const forceReloadVehicles = useCallback(
41806
+ () => forceReload((tags) => tags.includes(VEHICLES_TAG_KEY)),
41807
+ [forceReload]
41808
+ );
41809
+ return { patchVehicleByKey, forceReloadVehicles };
41810
+ }
41811
+ const DELETE_TRIP_TAG_KEY = "#delete-trip";
41812
+ const deleteTrip = del(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
41813
+ function buildKey$6({
41814
+ access_token: accessToken,
41815
+ apiUrl,
41816
+ businessId,
41817
+ tripId
41818
+ }) {
41819
+ if (accessToken && apiUrl) {
41820
+ return {
41821
+ accessToken,
41822
+ apiUrl,
41823
+ businessId,
41824
+ tripId,
41825
+ tags: [DELETE_TRIP_TAG_KEY]
41826
+ };
41827
+ }
41828
+ }
41829
+ class DeleteTripSWRResponse {
41830
+ constructor(swrResponse) {
41831
+ __publicField(this, "swrResponse");
41832
+ this.swrResponse = swrResponse;
41833
+ }
41834
+ get trigger() {
41835
+ return this.swrResponse.trigger;
41836
+ }
41837
+ get isMutating() {
41838
+ return this.swrResponse.isMutating;
41839
+ }
41840
+ get isError() {
41841
+ return this.swrResponse.error !== void 0;
41842
+ }
41843
+ }
41844
+ const useDeleteTrip = ({ tripId }) => {
41845
+ const { data } = useAuth();
41846
+ const { businessId } = useLayerContext();
41847
+ const rawMutationResponse = useSWRMutation(
41848
+ () => buildKey$6(__spreadProps(__spreadValues({}, data), {
41849
+ businessId,
41850
+ tripId
41851
+ })),
41852
+ ({ accessToken, apiUrl, businessId: businessId2, tripId: tripId2 }) => {
41853
+ return deleteTrip(
41854
+ apiUrl,
41855
+ accessToken,
41856
+ { params: { businessId: businessId2, tripId: tripId2 } }
41857
+ );
41858
+ },
41859
+ {
41860
+ revalidate: false,
41861
+ throwOnError: true
41862
+ }
41863
+ );
41864
+ const mutationResponse = new DeleteTripSWRResponse(rawMutationResponse);
41865
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
41866
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
41867
+ const originalTrigger = mutationResponse.trigger;
41868
+ const stableProxiedTrigger = useCallback(
41869
+ (...triggerParameters) => __async(null, null, function* () {
41870
+ const triggerResult = yield originalTrigger(...triggerParameters);
41871
+ void forceReloadTrips();
41872
+ void forceReloadVehicles();
41873
+ return triggerResult;
41874
+ }),
41875
+ [originalTrigger, forceReloadTrips, forceReloadVehicles]
41876
+ );
41877
+ return new Proxy(mutationResponse, {
41878
+ get(target, prop) {
41879
+ if (prop === "trigger") {
41880
+ return stableProxiedTrigger;
41881
+ }
41882
+ return Reflect.get(target, prop);
41883
+ }
41884
+ });
41885
+ };
41886
+ function TripDeleteConfirmationModal({
41887
+ isOpen,
41888
+ onOpenChange,
41889
+ trip
41890
+ }) {
41891
+ const { trigger: deleteTrip2 } = useDeleteTrip({ tripId: trip.id });
41892
+ const onConfirm = useCallback(() => __async(null, null, function* () {
41893
+ yield deleteTrip2();
41894
+ }), [deleteTrip2]);
41895
+ return /* @__PURE__ */ jsx(
41896
+ BaseConfirmationModal,
41897
+ {
41898
+ isOpen,
41899
+ onOpenChange,
41900
+ title: "Delete this trip?",
41901
+ description: "This trip will be permanently deleted. This action cannot be undone.",
41902
+ onConfirm,
41903
+ confirmLabel: "Delete trip",
41904
+ cancelLabel: "Cancel",
41905
+ errorText: "Failed to delete trip. Please check your connection and try again."
41906
+ }
41907
+ );
41908
+ }
41909
+ const getTripFormDefaultValues = (trip) => {
41910
+ if (trip) {
41911
+ return {
41912
+ vehicle: trip.vehicle,
41913
+ tripDate: trip.tripDate,
41914
+ distance: trip.distance,
41915
+ purpose: trip.purpose,
41916
+ startAddress: trip.startAddress || "",
41917
+ endAddress: trip.endAddress || "",
41918
+ description: trip.description || ""
41919
+ };
41920
+ }
41921
+ return {
41922
+ vehicle: null,
41923
+ tripDate: today(getLocalTimeZone()),
41924
+ distance: BIG_DECIMAL_ZERO,
41925
+ purpose: TripPurpose.Business,
41926
+ startAddress: "",
41927
+ endAddress: "",
41928
+ description: ""
41929
+ };
41930
+ };
41931
+ const validateTripForm = ({ trip }) => {
41932
+ const { vehicle, tripDate, distance, purpose } = trip;
41933
+ const errors = [];
41934
+ if (tripDate === null) {
41935
+ errors.push({ tripDate: "Trip date is a required field." });
41936
+ }
41937
+ if (tripDate && tripDate.compare(today(getLocalTimeZone())) > 0) {
41938
+ errors.push({ tripDate: "Trip date cannot be in the future." });
41939
+ }
41940
+ if (!BigDecimal.isPositive(distance)) {
41941
+ errors.push({ distance: "Distance must be greater than zero." });
41942
+ }
41943
+ if (!purpose) {
41944
+ errors.push({ purpose: "Purpose is a required field." });
41945
+ }
41946
+ if (vehicle === null) {
41947
+ errors.push({ vehicle: "Vehicle is a required field." });
41948
+ }
41949
+ return errors.length > 0 ? errors : null;
41950
+ };
41951
+ const convertTripFormToUpsertTrip = (form) => {
41952
+ var _a;
41953
+ return {
41954
+ vehicleId: (_a = form.vehicle) == null ? void 0 : _a.id,
41955
+ tripDate: form.tripDate,
41956
+ distance: form.distance,
41957
+ purpose: form.purpose,
41958
+ startAddress: form.startAddress.trim() || null,
41959
+ endAddress: form.endAddress.trim() || null,
41960
+ description: form.description.trim() || null
41961
+ };
41962
+ };
41718
41963
  const UPSERT_TRIP_TAG_KEY = "#upsert-trip";
41719
41964
  var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
41720
41965
  UpsertTripMode2["Create"] = "Create";
@@ -41723,7 +41968,7 @@ var UpsertTripMode = /* @__PURE__ */ ((UpsertTripMode2) => {
41723
41968
  })(UpsertTripMode || {});
41724
41969
  const createTrip = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/trips`);
41725
41970
  const updateTrip = patch(({ businessId, tripId }) => `/v1/businesses/${businessId}/mileage/trips/${tripId}`);
41726
- function buildKey$3({
41971
+ function buildKey$5({
41727
41972
  access_token: accessToken,
41728
41973
  apiUrl,
41729
41974
  businessId,
@@ -41795,7 +42040,7 @@ const useUpsertTrip = (props) => {
41795
42040
  const { mode } = props;
41796
42041
  const tripId = mode === "Update" ? props.tripId : void 0;
41797
42042
  const rawMutationResponse = useSWRMutation(
41798
- () => buildKey$3(__spreadProps(__spreadValues({}, data), {
42043
+ () => buildKey$5(__spreadProps(__spreadValues({}, data), {
41799
42044
  businessId,
41800
42045
  tripId
41801
42046
  })),
@@ -41814,6 +42059,7 @@ const useUpsertTrip = (props) => {
41814
42059
  );
41815
42060
  const mutationResponse = new UpsertTripSWRResponse(rawMutationResponse);
41816
42061
  const { patchTripByKey, forceReloadTrips } = useTripsGlobalCacheActions();
42062
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
41817
42063
  const originalTrigger = mutationResponse.trigger;
41818
42064
  const stableProxiedTrigger = useCallback(
41819
42065
  (...triggerParameters) => __async(null, null, function* () {
@@ -41823,9 +42069,10 @@ const useUpsertTrip = (props) => {
41823
42069
  } else {
41824
42070
  void forceReloadTrips();
41825
42071
  }
42072
+ void forceReloadVehicles();
41826
42073
  return triggerResult;
41827
42074
  }),
41828
- [originalTrigger, mode, patchTripByKey, forceReloadTrips]
42075
+ [originalTrigger, mode, patchTripByKey, forceReloadTrips, forceReloadVehicles]
41829
42076
  );
41830
42077
  return new Proxy(mutationResponse, {
41831
42078
  get(target, prop) {
@@ -41928,67 +42175,6 @@ const TripPurposeComboBox = ({ value, onValueChange, isReadOnly, className }) =>
41928
42175
  )
41929
42176
  ] });
41930
42177
  };
41931
- const ListVehiclesResponseSchema = Schema.Struct({
41932
- data: Schema.Array(VehicleSchema)
41933
- });
41934
- const listVehicles = get(({ businessId }) => {
41935
- return `/v1/businesses/${businessId}/mileage/vehicles`;
41936
- });
41937
- const VEHICLES_TAG_KEY = "#list-vehicles";
41938
- function buildKey$2({
41939
- access_token: accessToken,
41940
- apiUrl,
41941
- businessId,
41942
- query
41943
- }) {
41944
- if (accessToken && apiUrl) {
41945
- return {
41946
- accessToken,
41947
- apiUrl,
41948
- businessId,
41949
- query,
41950
- tags: [VEHICLES_TAG_KEY]
41951
- };
41952
- }
41953
- }
41954
- class ListVehiclesSWRResponse {
41955
- constructor(swrResponse) {
41956
- __publicField(this, "swrResponse");
41957
- this.swrResponse = swrResponse;
41958
- }
41959
- get data() {
41960
- var _a;
41961
- return (_a = this.swrResponse.data) == null ? void 0 : _a.data;
41962
- }
41963
- get isLoading() {
41964
- return this.swrResponse.isLoading;
41965
- }
41966
- get isValidating() {
41967
- return this.swrResponse.isValidating;
41968
- }
41969
- get isError() {
41970
- return this.swrResponse.error !== void 0;
41971
- }
41972
- }
41973
- function useListVehicles() {
41974
- const { data } = useAuth();
41975
- const { businessId } = useLayerContext();
41976
- const response = useSWR(
41977
- () => buildKey$2(__spreadProps(__spreadValues({}, data), {
41978
- businessId
41979
- })),
41980
- ({ accessToken, apiUrl, businessId: businessId2 }) => listVehicles(
41981
- apiUrl,
41982
- accessToken,
41983
- {
41984
- params: {
41985
- businessId: businessId2
41986
- }
41987
- }
41988
- )().then(Schema.decodeUnknownPromise(ListVehiclesResponseSchema))
41989
- );
41990
- return new ListVehiclesSWRResponse(response);
41991
- }
41992
42178
  const getVehicleDisplayName = (vehicle) => `${vehicle.year} ${vehicle.makeAndModel}`;
41993
42179
  class VehicleAsOption {
41994
42180
  constructor(vehicle) {
@@ -42207,7 +42393,7 @@ const TripsTableHeaderMenu = () => {
42207
42393
  );
42208
42394
  };
42209
42395
  const COMPONENT_NAME = "TripsTable";
42210
- const getColumnConfig = (onSelectTrip) => ({
42396
+ const getColumnConfig = ({ onSelectTrip, onDeleteTrip }) => ({
42211
42397
  [
42212
42398
  "TripDate"
42213
42399
  /* TripDate */
@@ -42271,27 +42457,32 @@ const getColumnConfig = (onSelectTrip) => ({
42271
42457
  cell: (row) => /* @__PURE__ */ jsx(Span, { ellipsis: true, withTooltip: true, children: row.description })
42272
42458
  },
42273
42459
  [
42274
- "Expand"
42275
- /* Expand */
42460
+ "Actions"
42461
+ /* Actions */
42276
42462
  ]: {
42277
- id: "Expand",
42278
- cell: (row) => /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(ChevronRightFill, {}) })
42463
+ id: "Actions",
42464
+ cell: (row) => /* @__PURE__ */ jsxs(HStack, { gap: "3xs", children: [
42465
+ /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onSelectTrip(row), "aria-label": "View trip", variant: "ghost", children: /* @__PURE__ */ jsx(Edit, { size: 20 }) }),
42466
+ /* @__PURE__ */ jsx(Button, { inset: true, icon: true, onPress: () => onDeleteTrip(row), "aria-label": "Delete trip", variant: "ghost", children: /* @__PURE__ */ jsx(Trash2, { size: 20 }) })
42467
+ ] })
42279
42468
  }
42280
42469
  });
42281
42470
  const TripsTable = () => {
42282
42471
  var _a;
42283
42472
  const [isTripDrawerOpen, setIsTripDrawerOpen] = useState(false);
42284
42473
  const [selectedTrip, setSelectedTrip] = useState(null);
42474
+ const [tripToDelete, setTripToDelete] = useState(null);
42285
42475
  const { tableFilters, setTableFilters } = useTripsTableFilters();
42286
42476
  const { query, selectedVehicle, purposeFilter } = tableFilters;
42477
+ const { currentTripsPage, setCurrentTripsPage } = useCurrentTripsPage();
42287
42478
  const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: query });
42288
42479
  useEffect(() => {
42289
42480
  setTableFilters({ query: searchQuery });
42290
42481
  }, [searchQuery, setTableFilters]);
42291
42482
  const filterParams = useMemo(() => {
42292
42483
  const params = {};
42293
- if (searchQuery) {
42294
- params.query = searchQuery;
42484
+ if (query) {
42485
+ params.query = query;
42295
42486
  }
42296
42487
  if (selectedVehicle) {
42297
42488
  params.vehicleId = selectedVehicle.id;
@@ -42300,9 +42491,10 @@ const TripsTable = () => {
42300
42491
  params.purpose = purposeFilter;
42301
42492
  }
42302
42493
  return params;
42303
- }, [searchQuery, selectedVehicle, purposeFilter]);
42494
+ }, [query, selectedVehicle, purposeFilter]);
42304
42495
  const { data, isLoading, isError, size, setSize } = useListTrips(filterParams);
42305
42496
  const trips = useMemo(() => data == null ? void 0 : data.flatMap(({ data: data2 }) => data2), [data]);
42497
+ const autoResetPageIndexRef = useAutoResetPageIndex(filterParams, data);
42306
42498
  const paginationMeta = (_a = data == null ? void 0 : data[data.length - 1]) == null ? void 0 : _a.meta.pagination;
42307
42499
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
42308
42500
  const fetchMore = useCallback(() => {
@@ -42314,17 +42506,23 @@ const TripsTable = () => {
42314
42506
  setSelectedTrip(trip);
42315
42507
  setIsTripDrawerOpen(true);
42316
42508
  }, []);
42509
+ const onDeleteTrip = useCallback((trip) => {
42510
+ setTripToDelete(trip);
42511
+ }, []);
42317
42512
  const onRecordTrip = useCallback(() => {
42318
42513
  setSelectedTrip(null);
42319
42514
  setIsTripDrawerOpen(true);
42320
42515
  }, []);
42321
42516
  const paginationProps = useMemo(() => {
42322
42517
  return {
42518
+ initialPage: currentTripsPage,
42519
+ onSetPage: setCurrentTripsPage,
42323
42520
  pageSize: 20,
42324
42521
  hasMore,
42325
- fetchMore
42522
+ fetchMore,
42523
+ autoResetPageIndexRef
42326
42524
  };
42327
- }, [fetchMore, hasMore]);
42525
+ }, [currentTripsPage, setCurrentTripsPage, fetchMore, hasMore, autoResetPageIndexRef]);
42328
42526
  const handlePurposeFilterChange = useCallback((newPurposeFilter) => {
42329
42527
  setTableFilters({ purposeFilter: newPurposeFilter });
42330
42528
  }, [setTableFilters]);
@@ -42375,7 +42573,7 @@ const TripsTable = () => {
42375
42573
  spacing: true
42376
42574
  }
42377
42575
  );
42378
- const columnConfig = useMemo(() => getColumnConfig(onSelectTrip), [onSelectTrip]);
42576
+ const columnConfig = useMemo(() => getColumnConfig({ onSelectTrip, onDeleteTrip }), [onSelectTrip, onDeleteTrip]);
42379
42577
  const HeaderFilters = useCallback(() => /* @__PURE__ */ jsxs(HStack, { gap: "sm", align: "center", children: [
42380
42578
  /* @__PURE__ */ jsx(PurposeToggle, {}),
42381
42579
  /* @__PURE__ */ jsx(VehicleFilter, {})
@@ -42444,6 +42642,18 @@ const TripsTable = () => {
42444
42642
  )
42445
42643
  ] })
42446
42644
  }
42645
+ ),
42646
+ tripToDelete && /* @__PURE__ */ jsx(
42647
+ TripDeleteConfirmationModal,
42648
+ {
42649
+ isOpen: !!tripToDelete,
42650
+ onOpenChange: (isOpen) => {
42651
+ if (!isOpen) {
42652
+ setTripToDelete(null);
42653
+ }
42654
+ },
42655
+ trip: tripToDelete
42656
+ }
42447
42657
  )
42448
42658
  ] });
42449
42659
  };
@@ -42454,7 +42664,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
42454
42664
  year: vehicle.year,
42455
42665
  licensePlate: vehicle.licensePlate || "",
42456
42666
  vin: vehicle.vin || "",
42457
- description: vehicle.description || ""
42667
+ description: vehicle.description || "",
42668
+ isPrimary: vehicle.isPrimary
42458
42669
  };
42459
42670
  }
42460
42671
  return {
@@ -42462,7 +42673,8 @@ const getVehicleFormDefaultValues = (vehicle) => {
42462
42673
  year: Number.NaN,
42463
42674
  licensePlate: "",
42464
42675
  vin: "",
42465
- description: ""
42676
+ description: "",
42677
+ isPrimary: false
42466
42678
  };
42467
42679
  };
42468
42680
  const validateVehicleForm = ({ vehicle }) => {
@@ -42486,7 +42698,8 @@ const convertVehicleFormToUpsertVehicle = (form) => {
42486
42698
  year: form.year,
42487
42699
  licensePlate: form.licensePlate.trim() || null,
42488
42700
  vin: form.vin.trim() || null,
42489
- description: form.description.trim() || null
42701
+ description: form.description.trim() || null,
42702
+ isPrimary: form.isPrimary
42490
42703
  };
42491
42704
  };
42492
42705
  const UPSERT_VEHICLE_TAG_KEY = "#upsert-vehicle";
@@ -42497,7 +42710,7 @@ var UpsertVehicleMode = /* @__PURE__ */ ((UpsertVehicleMode2) => {
42497
42710
  })(UpsertVehicleMode || {});
42498
42711
  const createVehicle = post(({ businessId }) => `/v1/businesses/${businessId}/mileage/vehicles`);
42499
42712
  const updateVehicle = patch(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
42500
- function buildKey$1({
42713
+ function buildKey$4({
42501
42714
  access_token: accessToken,
42502
42715
  apiUrl,
42503
42716
  businessId,
@@ -42516,6 +42729,24 @@ function buildKey$1({
42516
42729
  const UpsertVehicleReturnSchema = Schema.Struct({
42517
42730
  data: VehicleSchema
42518
42731
  });
42732
+ class UpsertVehicleSWRResponse {
42733
+ constructor(swrResponse) {
42734
+ __publicField(this, "swrResponse");
42735
+ this.swrResponse = swrResponse;
42736
+ }
42737
+ get trigger() {
42738
+ return this.swrResponse.trigger;
42739
+ }
42740
+ get isMutating() {
42741
+ return this.swrResponse.isMutating;
42742
+ }
42743
+ get data() {
42744
+ return this.swrResponse.data;
42745
+ }
42746
+ get error() {
42747
+ return this.swrResponse.error;
42748
+ }
42749
+ }
42519
42750
  const CreateParamsSchema = Schema.Struct({
42520
42751
  businessId: Schema.UUID,
42521
42752
  vehicleId: Schema.Undefined
@@ -42549,11 +42780,10 @@ function getRequestFn(mode, params) {
42549
42780
  const useUpsertVehicle = (props) => {
42550
42781
  const { data } = useAuth();
42551
42782
  const { businessId } = useLayerContext();
42552
- const { mutate } = useSWRConfig();
42553
42783
  const { mode } = props;
42554
42784
  const vehicleId = mode === "Update" ? props.vehicleId : void 0;
42555
42785
  const rawMutationResponse = useSWRMutation(
42556
- () => buildKey$1(__spreadProps(__spreadValues({}, data), {
42786
+ () => buildKey$4(__spreadProps(__spreadValues({}, data), {
42557
42787
  businessId,
42558
42788
  vehicleId
42559
42789
  })),
@@ -42571,43 +42801,31 @@ const useUpsertVehicle = (props) => {
42571
42801
  }
42572
42802
  );
42573
42803
  const mutationResponse = new UpsertVehicleSWRResponse(rawMutationResponse);
42804
+ const { patchVehicleByKey, forceReloadVehicles } = useVehiclesGlobalCacheActions();
42805
+ const { forceReloadTrips } = useTripsGlobalCacheActions();
42574
42806
  const originalTrigger = mutationResponse.trigger;
42575
42807
  const stableProxiedTrigger = useCallback(
42576
42808
  (...triggerParameters) => __async(null, null, function* () {
42577
42809
  const triggerResult = yield originalTrigger(...triggerParameters);
42578
- void mutate((key) => {
42579
- if (typeof key === "object" && key !== null && "tags" in key) {
42580
- const tags = key.tags;
42581
- return tags.includes(VEHICLES_TAG_KEY);
42582
- }
42583
- return false;
42584
- });
42810
+ if (mode === "Update") {
42811
+ void patchVehicleByKey(triggerResult.data);
42812
+ void forceReloadTrips();
42813
+ } else {
42814
+ void forceReloadVehicles();
42815
+ }
42585
42816
  return triggerResult;
42586
42817
  }),
42587
- [originalTrigger, mutate]
42818
+ [originalTrigger, mode, patchVehicleByKey, forceReloadTrips, forceReloadVehicles]
42588
42819
  );
42589
- return __spreadProps(__spreadValues({}, mutationResponse), {
42590
- trigger: stableProxiedTrigger
42820
+ return new Proxy(mutationResponse, {
42821
+ get(target, prop) {
42822
+ if (prop === "trigger") {
42823
+ return stableProxiedTrigger;
42824
+ }
42825
+ return Reflect.get(target, prop);
42826
+ }
42591
42827
  });
42592
42828
  };
42593
- class UpsertVehicleSWRResponse {
42594
- constructor(swrResponse) {
42595
- __publicField(this, "swrResponse");
42596
- this.swrResponse = swrResponse;
42597
- }
42598
- get trigger() {
42599
- return this.swrResponse.trigger;
42600
- }
42601
- get isMutating() {
42602
- return this.swrResponse.isMutating;
42603
- }
42604
- get data() {
42605
- return this.swrResponse.data;
42606
- }
42607
- get error() {
42608
- return this.swrResponse.error;
42609
- }
42610
- }
42611
42829
  const useVehicleForm = (props) => {
42612
42830
  const [submitError, setSubmitError] = useState(void 0);
42613
42831
  const { onSuccess, vehicle } = props;
@@ -42723,6 +42941,15 @@ const VehicleForm = (props) => {
42723
42941
  className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__Description`
42724
42942
  }
42725
42943
  ) }),
42944
+ /* @__PURE__ */ jsx(form.AppField, { name: "isPrimary", children: (field) => /* @__PURE__ */ jsx(
42945
+ field.FormSwitchField,
42946
+ {
42947
+ label: "Set as primary vehicle",
42948
+ inline: true,
42949
+ isReadOnly,
42950
+ className: `${VEHICLE_FORM_FIELD_CSS_PREFIX}__IsPrimary`
42951
+ }
42952
+ ) }),
42726
42953
  /* @__PURE__ */ jsx(VStack, { justify: "end", className: `${VEHICLE_FORM_CSS_PREFIX}__Submit`, children: /* @__PURE__ */ jsx(form.Subscribe, { selector: (state) => [state.canSubmit, state.isSubmitting], children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ jsx(
42727
42954
  Button,
42728
42955
  {
@@ -42737,6 +42964,309 @@ const VehicleForm = (props) => {
42737
42964
  ) }) })
42738
42965
  ] });
42739
42966
  };
42967
+ const ARCHIVE_VEHICLE_TAG_KEY = "#archive-vehicle";
42968
+ const ArchiveVehicleReturnSchema = Schema.Struct({
42969
+ data: VehicleSchema
42970
+ });
42971
+ const archiveVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/archive`);
42972
+ function buildKey$3({
42973
+ access_token: accessToken,
42974
+ apiUrl,
42975
+ businessId,
42976
+ vehicleId
42977
+ }) {
42978
+ if (accessToken && apiUrl) {
42979
+ return {
42980
+ accessToken,
42981
+ apiUrl,
42982
+ businessId,
42983
+ vehicleId,
42984
+ tags: [ARCHIVE_VEHICLE_TAG_KEY]
42985
+ };
42986
+ }
42987
+ }
42988
+ class ArchiveVehicleSWRResponse {
42989
+ constructor(swrResponse) {
42990
+ __publicField(this, "swrResponse");
42991
+ this.swrResponse = swrResponse;
42992
+ }
42993
+ get data() {
42994
+ return this.swrResponse.data;
42995
+ }
42996
+ get trigger() {
42997
+ return this.swrResponse.trigger;
42998
+ }
42999
+ get isMutating() {
43000
+ return this.swrResponse.isMutating;
43001
+ }
43002
+ get isError() {
43003
+ return this.swrResponse.error !== void 0;
43004
+ }
43005
+ }
43006
+ const useArchiveVehicle = ({ vehicleId }) => {
43007
+ const { data } = useAuth();
43008
+ const { businessId } = useLayerContext();
43009
+ const rawMutationResponse = useSWRMutation(
43010
+ () => buildKey$3(__spreadProps(__spreadValues({}, data), {
43011
+ businessId,
43012
+ vehicleId
43013
+ })),
43014
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43015
+ return archiveVehicle(
43016
+ apiUrl,
43017
+ accessToken,
43018
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43019
+ ).then(Schema.decodeUnknownPromise(ArchiveVehicleReturnSchema));
43020
+ },
43021
+ {
43022
+ revalidate: false,
43023
+ throwOnError: true
43024
+ }
43025
+ );
43026
+ const mutationResponse = new ArchiveVehicleSWRResponse(rawMutationResponse);
43027
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
43028
+ const originalTrigger = mutationResponse.trigger;
43029
+ const stableProxiedTrigger = useCallback(
43030
+ (...triggerParameters) => __async(null, null, function* () {
43031
+ const triggerResult = yield originalTrigger(...triggerParameters);
43032
+ void patchVehicleByKey(triggerResult.data);
43033
+ return triggerResult;
43034
+ }),
43035
+ [originalTrigger, patchVehicleByKey]
43036
+ );
43037
+ return new Proxy(mutationResponse, {
43038
+ get(target, prop) {
43039
+ if (prop === "trigger") {
43040
+ return stableProxiedTrigger;
43041
+ }
43042
+ return Reflect.get(target, prop);
43043
+ }
43044
+ });
43045
+ };
43046
+ function VehicleArchiveConfirmationModal({
43047
+ isOpen,
43048
+ onOpenChange,
43049
+ vehicle
43050
+ }) {
43051
+ const { trigger: archiveVehicle2 } = useArchiveVehicle({ vehicleId: vehicle.id });
43052
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43053
+ yield archiveVehicle2();
43054
+ }), [archiveVehicle2]);
43055
+ const vehicleName = getVehicleDisplayName(vehicle);
43056
+ return /* @__PURE__ */ jsx(
43057
+ BaseConfirmationModal,
43058
+ {
43059
+ isOpen,
43060
+ onOpenChange,
43061
+ title: "Archive this vehicle?",
43062
+ description: `${vehicleName} will be hidden from your active vehicles list. You can reactivate it at any time.`,
43063
+ onConfirm,
43064
+ confirmLabel: "Archive vehicle",
43065
+ cancelLabel: "Cancel",
43066
+ errorText: "Failed to archive vehicle. Please check your connection and try again."
43067
+ }
43068
+ );
43069
+ }
43070
+ const DELETE_VEHICLE_TAG_KEY = "#delete-vehicle";
43071
+ const deleteVehicle = del(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}`);
43072
+ function buildKey$2({
43073
+ access_token: accessToken,
43074
+ apiUrl,
43075
+ businessId,
43076
+ vehicleId
43077
+ }) {
43078
+ if (accessToken && apiUrl) {
43079
+ return {
43080
+ accessToken,
43081
+ apiUrl,
43082
+ businessId,
43083
+ vehicleId,
43084
+ tags: [DELETE_VEHICLE_TAG_KEY]
43085
+ };
43086
+ }
43087
+ }
43088
+ class DeleteVehicleSWRResponse {
43089
+ constructor(swrResponse) {
43090
+ __publicField(this, "swrResponse");
43091
+ this.swrResponse = swrResponse;
43092
+ }
43093
+ get trigger() {
43094
+ return this.swrResponse.trigger;
43095
+ }
43096
+ get isMutating() {
43097
+ return this.swrResponse.isMutating;
43098
+ }
43099
+ get isError() {
43100
+ return this.swrResponse.error !== void 0;
43101
+ }
43102
+ }
43103
+ const useDeleteVehicle = ({ vehicleId }) => {
43104
+ const { data } = useAuth();
43105
+ const { businessId } = useLayerContext();
43106
+ const rawMutationResponse = useSWRMutation(
43107
+ () => buildKey$2(__spreadProps(__spreadValues({}, data), {
43108
+ businessId,
43109
+ vehicleId
43110
+ })),
43111
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43112
+ return deleteVehicle(
43113
+ apiUrl,
43114
+ accessToken,
43115
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43116
+ );
43117
+ },
43118
+ {
43119
+ revalidate: false,
43120
+ throwOnError: true
43121
+ }
43122
+ );
43123
+ const mutationResponse = new DeleteVehicleSWRResponse(rawMutationResponse);
43124
+ const { forceReloadVehicles } = useVehiclesGlobalCacheActions();
43125
+ const originalTrigger = mutationResponse.trigger;
43126
+ const stableProxiedTrigger = useCallback(
43127
+ (...triggerParameters) => __async(null, null, function* () {
43128
+ const triggerResult = yield originalTrigger(...triggerParameters);
43129
+ void forceReloadVehicles();
43130
+ return triggerResult;
43131
+ }),
43132
+ [originalTrigger, forceReloadVehicles]
43133
+ );
43134
+ return new Proxy(mutationResponse, {
43135
+ get(target, prop) {
43136
+ if (prop === "trigger") {
43137
+ return stableProxiedTrigger;
43138
+ }
43139
+ return Reflect.get(target, prop);
43140
+ }
43141
+ });
43142
+ };
43143
+ function VehicleDeleteConfirmationModal({
43144
+ isOpen,
43145
+ onOpenChange,
43146
+ vehicle
43147
+ }) {
43148
+ const { trigger: deleteVehicle2 } = useDeleteVehicle({ vehicleId: vehicle.id });
43149
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43150
+ yield deleteVehicle2();
43151
+ }), [deleteVehicle2]);
43152
+ const vehicleName = getVehicleDisplayName(vehicle);
43153
+ return /* @__PURE__ */ jsx(
43154
+ BaseConfirmationModal,
43155
+ {
43156
+ isOpen,
43157
+ onOpenChange,
43158
+ title: "Delete this vehicle?",
43159
+ description: `${vehicleName} will be permanently deleted. This action cannot be undone.`,
43160
+ onConfirm,
43161
+ confirmLabel: "Delete vehicle",
43162
+ cancelLabel: "Cancel",
43163
+ errorText: "Failed to delete vehicle. Please check your connection and try again."
43164
+ }
43165
+ );
43166
+ }
43167
+ const REACTIVATE_VEHICLE_TAG_KEY = "#reactivate-vehicle";
43168
+ const ReactivateVehicleReturnSchema = Schema.Struct({
43169
+ data: VehicleSchema
43170
+ });
43171
+ const reactivateVehicle = post(({ businessId, vehicleId }) => `/v1/businesses/${businessId}/mileage/vehicles/${vehicleId}/reactivate`);
43172
+ function buildKey$1({
43173
+ access_token: accessToken,
43174
+ apiUrl,
43175
+ businessId,
43176
+ vehicleId
43177
+ }) {
43178
+ if (accessToken && apiUrl) {
43179
+ return {
43180
+ accessToken,
43181
+ apiUrl,
43182
+ businessId,
43183
+ vehicleId,
43184
+ tags: [REACTIVATE_VEHICLE_TAG_KEY]
43185
+ };
43186
+ }
43187
+ }
43188
+ class ReactivateVehicleSWRResponse {
43189
+ constructor(swrResponse) {
43190
+ __publicField(this, "swrResponse");
43191
+ this.swrResponse = swrResponse;
43192
+ }
43193
+ get data() {
43194
+ return this.swrResponse.data;
43195
+ }
43196
+ get trigger() {
43197
+ return this.swrResponse.trigger;
43198
+ }
43199
+ get isMutating() {
43200
+ return this.swrResponse.isMutating;
43201
+ }
43202
+ get isError() {
43203
+ return this.swrResponse.error !== void 0;
43204
+ }
43205
+ }
43206
+ const useReactivateVehicle = ({ vehicleId }) => {
43207
+ const { data } = useAuth();
43208
+ const { businessId } = useLayerContext();
43209
+ const rawMutationResponse = useSWRMutation(
43210
+ () => buildKey$1(__spreadProps(__spreadValues({}, data), {
43211
+ businessId,
43212
+ vehicleId
43213
+ })),
43214
+ ({ accessToken, apiUrl, businessId: businessId2, vehicleId: vehicleId2 }) => {
43215
+ return reactivateVehicle(
43216
+ apiUrl,
43217
+ accessToken,
43218
+ { params: { businessId: businessId2, vehicleId: vehicleId2 } }
43219
+ ).then(Schema.decodeUnknownPromise(ReactivateVehicleReturnSchema));
43220
+ },
43221
+ {
43222
+ revalidate: false,
43223
+ throwOnError: true
43224
+ }
43225
+ );
43226
+ const mutationResponse = new ReactivateVehicleSWRResponse(rawMutationResponse);
43227
+ const { patchVehicleByKey } = useVehiclesGlobalCacheActions();
43228
+ const originalTrigger = mutationResponse.trigger;
43229
+ const stableProxiedTrigger = useCallback(
43230
+ (...triggerParameters) => __async(null, null, function* () {
43231
+ const triggerResult = yield originalTrigger(...triggerParameters);
43232
+ void patchVehicleByKey(triggerResult.data);
43233
+ return triggerResult;
43234
+ }),
43235
+ [originalTrigger, patchVehicleByKey]
43236
+ );
43237
+ return new Proxy(mutationResponse, {
43238
+ get(target, prop) {
43239
+ if (prop === "trigger") {
43240
+ return stableProxiedTrigger;
43241
+ }
43242
+ return Reflect.get(target, prop);
43243
+ }
43244
+ });
43245
+ };
43246
+ function VehicleReactivateConfirmationModal({
43247
+ isOpen,
43248
+ onOpenChange,
43249
+ vehicle
43250
+ }) {
43251
+ const { trigger: reactivateVehicle2 } = useReactivateVehicle({ vehicleId: vehicle.id });
43252
+ const onConfirm = useCallback(() => __async(null, null, function* () {
43253
+ yield reactivateVehicle2();
43254
+ }), [reactivateVehicle2]);
43255
+ const vehicleName = getVehicleDisplayName(vehicle);
43256
+ return /* @__PURE__ */ jsx(
43257
+ BaseConfirmationModal,
43258
+ {
43259
+ isOpen,
43260
+ onOpenChange,
43261
+ title: "Reactivate this vehicle?",
43262
+ description: `${vehicleName} will be restored to your active vehicles list and available for tracking trips.`,
43263
+ onConfirm,
43264
+ confirmLabel: "Reactivate vehicle",
43265
+ cancelLabel: "Cancel",
43266
+ errorText: "Failed to reactivate vehicle. Please check your connection and try again."
43267
+ }
43268
+ );
43269
+ }
42740
43270
  const VEHICLE_CARD_FIELDS = [
42741
43271
  { label: "Make and model", key: "makeAndModel" },
42742
43272
  { label: "Year", key: "year" },
@@ -42745,20 +43275,73 @@ const VEHICLE_CARD_FIELDS = [
42745
43275
  { label: "Description", key: "description" }
42746
43276
  ];
42747
43277
  const VehicleCard = ({ vehicle, onEdit }) => {
42748
- return /* @__PURE__ */ jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxs(VStack, { gap: "md", pi: "md", pb: "md", children: [
42749
- /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
42750
- /* @__PURE__ */ jsx(Heading$1, { size: "sm", ellipsis: true, children: getVehicleDisplayName(vehicle) }),
42751
- /* @__PURE__ */ jsx(Car, { size: 20, className: "Layer__VehicleCard__icon" })
42752
- ] }),
42753
- /* @__PURE__ */ jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxs(HStack, { justify: "space-between", gap: "md", children: [
42754
- /* @__PURE__ */ jsx(Span, { size: "sm", variant: "subtle", children: label }),
42755
- /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
42756
- ] }, key)) }),
42757
- /* @__PURE__ */ jsx(Button, { variant: "text", onPress: () => onEdit(vehicle), children: "Edit vehicle" })
42758
- ] }) });
43278
+ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
43279
+ const [isArchiveModalOpen, setIsArchiveModalOpen] = useState(false);
43280
+ const [isReactivateModalOpen, setIsReactivateModalOpen] = useState(false);
43281
+ const vehicleName = getVehicleDisplayName(vehicle);
43282
+ const isArchived = vehicle.archivedAt !== null && vehicle.archivedAt !== void 0;
43283
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
43284
+ /* @__PURE__ */ jsx(Card, { className: "Layer__VehicleCard", children: /* @__PURE__ */ jsxs(VStack, { pi: "md", pbs: "md", pbe: "xs", children: [
43285
+ /* @__PURE__ */ jsxs(VStack, { gap: "md", children: [
43286
+ /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", gap: "md", children: [
43287
+ /* @__PURE__ */ jsxs(HStack, { gap: "xs", className: "Layer__VehicleCard__Header", children: [
43288
+ /* @__PURE__ */ jsx(Heading$1, { size: "sm", ellipsis: true, children: vehicleName }),
43289
+ vehicle.isPrimary && /* @__PURE__ */ jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.INFO, children: "Primary" }),
43290
+ isArchived && /* @__PURE__ */ jsx(Badge, { size: BadgeSize.SMALL, variant: BadgeVariant.WARNING, children: "Archived" })
43291
+ ] }),
43292
+ /* @__PURE__ */ jsx(Car, { size: 20, className: "Layer__VehicleCard__Icon" })
43293
+ ] }),
43294
+ /* @__PURE__ */ jsx(VStack, { gap: "xs", children: VEHICLE_CARD_FIELDS.map(({ label, key }) => /* @__PURE__ */ jsxs(HStack, { justify: "space-between", gap: "md", children: [
43295
+ /* @__PURE__ */ jsx(Span, { size: "sm", variant: "subtle", children: label }),
43296
+ /* @__PURE__ */ jsx(Span, { size: "sm", weight: "bold", withTooltip: true, children: vehicle[key] || "-" })
43297
+ ] }, key)) })
43298
+ ] }),
43299
+ /* @__PURE__ */ jsx(VStack, { pbs: "md", pbe: "xs", children: /* @__PURE__ */ jsx(Separator, {}) }),
43300
+ /* @__PURE__ */ jsxs(HStack, { gap: "3xs", justify: "end", children: [
43301
+ !isArchived && /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => onEdit(vehicle), children: [
43302
+ /* @__PURE__ */ jsx(Edit, { size: 16 }),
43303
+ "Edit"
43304
+ ] }),
43305
+ isArchived ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsReactivateModalOpen(true), children: [
43306
+ /* @__PURE__ */ jsx(RotateCcw, { size: 16 }),
43307
+ "Reactivate"
43308
+ ] }) : vehicle.isEligibleForDeletion ? /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsDeleteModalOpen(true), children: [
43309
+ /* @__PURE__ */ jsx(Trash2, { size: 16 }),
43310
+ "Delete"
43311
+ ] }) : /* @__PURE__ */ jsxs(Button, { variant: "ghost", onPress: () => setIsArchiveModalOpen(true), children: [
43312
+ /* @__PURE__ */ jsx(Archive, { size: 16 }),
43313
+ "Archive"
43314
+ ] })
43315
+ ] })
43316
+ ] }) }),
43317
+ /* @__PURE__ */ jsx(
43318
+ VehicleDeleteConfirmationModal,
43319
+ {
43320
+ isOpen: isDeleteModalOpen,
43321
+ onOpenChange: setIsDeleteModalOpen,
43322
+ vehicle
43323
+ }
43324
+ ),
43325
+ /* @__PURE__ */ jsx(
43326
+ VehicleArchiveConfirmationModal,
43327
+ {
43328
+ isOpen: isArchiveModalOpen,
43329
+ onOpenChange: setIsArchiveModalOpen,
43330
+ vehicle
43331
+ }
43332
+ ),
43333
+ /* @__PURE__ */ jsx(
43334
+ VehicleReactivateConfirmationModal,
43335
+ {
43336
+ isOpen: isReactivateModalOpen,
43337
+ onOpenChange: setIsReactivateModalOpen,
43338
+ vehicle
43339
+ }
43340
+ )
43341
+ ] });
42759
43342
  };
42760
- const VehicleManagementGrid = ({ onEditVehicle }) => {
42761
- const { data, isLoading, isError } = useListVehicles();
43343
+ const VehicleManagementGrid = ({ onEditVehicle, showArchived }) => {
43344
+ const { data, isLoading, isError } = useListVehicles({ allowArchived: showArchived });
42762
43345
  const vehicles = useMemo(() => data ? asMutable(data) : void 0, [data]);
42763
43346
  if (isLoading) {
42764
43347
  return /* @__PURE__ */ jsx(VStack, { align: "center", justify: "center", pi: "lg", pb: "lg", children: /* @__PURE__ */ jsx(Loader, {}) });
@@ -42788,9 +43371,12 @@ const VehicleManagementGrid = ({ onEditVehicle }) => {
42788
43371
  }
42789
43372
  return /* @__PURE__ */ jsx(HStack, { className: "Layer__VehicleManagementGrid", children: vehicles.map((vehicle) => /* @__PURE__ */ jsx(VehicleCard, { vehicle, onEdit: onEditVehicle }, vehicle.id)) });
42790
43373
  };
42791
- const VehicleManagementDetailHeader = ({ onAddVehicle }) => {
42792
- return /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
42793
- /* @__PURE__ */ jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
43374
+ const VehicleManagementDetailHeader = ({ onAddVehicle, showArchived, onShowArchivedChange }) => {
43375
+ return /* @__PURE__ */ jsxs(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", gap: "3xl", children: [
43376
+ /* @__PURE__ */ jsxs(HStack, { gap: "md", align: "center", children: [
43377
+ /* @__PURE__ */ jsx(Heading$1, { size: "sm", children: "Manage vehicles" }),
43378
+ /* @__PURE__ */ jsx(Switch, { isSelected: showArchived, onChange: onShowArchivedChange, children: /* @__PURE__ */ jsx(Span, { size: "sm", noWrap: true, children: "Show archived" }) })
43379
+ ] }),
42794
43380
  /* @__PURE__ */ jsxs(Button, { variant: "solid", onPress: onAddVehicle, children: [
42795
43381
  "Add Vehicle",
42796
43382
  /* @__PURE__ */ jsx(Plus$1, { size: 14 })
@@ -42801,6 +43387,7 @@ const VehicleManagementDetail = () => {
42801
43387
  const { toTripsTable } = useTripsNavigation();
42802
43388
  const [isVehicleDrawerOpen, setIsVehicleDrawerOpen] = useState(false);
42803
43389
  const [selectedVehicle, setSelectedVehicle] = useState(void 0);
43390
+ const [showArchived, setShowArchived] = useState(false);
42804
43391
  const handleAddVehicle = useCallback(() => {
42805
43392
  setSelectedVehicle(void 0);
42806
43393
  setIsVehicleDrawerOpen(true);
@@ -42813,9 +43400,20 @@ const VehicleManagementDetail = () => {
42813
43400
  setIsVehicleDrawerOpen(false);
42814
43401
  setSelectedVehicle(void 0);
42815
43402
  }, []);
42816
- const Header3 = useCallback(() => {
42817
- return /* @__PURE__ */ jsx(VehicleManagementDetailHeader, { onAddVehicle: handleAddVehicle });
42818
- }, [handleAddVehicle]);
43403
+ const stateRef = useRef({ showArchived, setShowArchived, handleAddVehicle });
43404
+ stateRef.current = { showArchived, setShowArchived, handleAddVehicle };
43405
+ const HeaderRef = useRef(() => {
43406
+ const { showArchived: currentShowArchived, setShowArchived: currentSetShowArchived, handleAddVehicle: currentHandleAddVehicle } = stateRef.current;
43407
+ return /* @__PURE__ */ jsx(
43408
+ VehicleManagementDetailHeader,
43409
+ {
43410
+ onAddVehicle: currentHandleAddVehicle,
43411
+ showArchived: currentShowArchived,
43412
+ onShowArchivedChange: currentSetShowArchived
43413
+ }
43414
+ );
43415
+ });
43416
+ const Header3 = HeaderRef.current;
42819
43417
  return /* @__PURE__ */ jsxs(Fragment, { children: [
42820
43418
  /* @__PURE__ */ jsx(
42821
43419
  BaseDetailView,
@@ -42823,7 +43421,7 @@ const VehicleManagementDetail = () => {
42823
43421
  slots: { Header: Header3, BackIcon: BackArrow },
42824
43422
  name: "VehicleManagementDetail",
42825
43423
  onGoBack: toTripsTable,
42826
- children: /* @__PURE__ */ jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle })
43424
+ children: /* @__PURE__ */ jsx(VehicleManagementGrid, { onEditVehicle: handleEditVehicle, showArchived })
42827
43425
  }
42828
43426
  ),
42829
43427
  /* @__PURE__ */ jsx(Drawer, { isOpen: isVehicleDrawerOpen, onOpenChange: setIsVehicleDrawerOpen, "aria-label": selectedVehicle ? "Vehicle details" : "Add vehicle", children: ({ close: close2 }) => /* @__PURE__ */ jsxs(VStack, { pb: "lg", children: [
@@ -42902,7 +43500,7 @@ const ProjectProfitabilityView = ({
42902
43500
  }
42903
43501
  ) }),
42904
43502
  /* @__PURE__ */ jsx(
42905
- Select$1,
43503
+ ReactSelect,
42906
43504
  {
42907
43505
  className: "Layer__category-menu Layer__select",
42908
43506
  classNamePrefix: "Layer__select",
@@ -43489,14 +44087,14 @@ const BusinessProvider = ({
43489
44087
  }
43490
44088
  );
43491
44089
  };
43492
- const LayerProvider = (_ud) => {
43493
- var _vd = _ud, {
44090
+ const LayerProvider = (_wd) => {
44091
+ var _xd = _wd, {
43494
44092
  appId,
43495
44093
  appSecret,
43496
44094
  businessAccessToken,
43497
44095
  environment,
43498
44096
  usePlaidSandbox
43499
- } = _vd, restProps = __objRest(_vd, [
44097
+ } = _xd, restProps = __objRest(_xd, [
43500
44098
  "appId",
43501
44099
  "appSecret",
43502
44100
  "businessAccessToken",