@layerfi/components 0.1.104-alpha → 0.1.105

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.
@@ -3899,7 +3899,7 @@ var require_lodash = __commonJS({
3899
3899
  result2.placeholder = curryRight.placeholder;
3900
3900
  return result2;
3901
3901
  }
3902
- function debounce5(func, wait, options) {
3902
+ function debounce6(func, wait, options) {
3903
3903
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
3904
3904
  if (typeof func != "function") {
3905
3905
  throw new TypeError2(FUNC_ERROR_TEXT);
@@ -4079,7 +4079,7 @@ var require_lodash = __commonJS({
4079
4079
  leading = "leading" in options ? !!options.leading : leading;
4080
4080
  trailing = "trailing" in options ? !!options.trailing : trailing;
4081
4081
  }
4082
- return debounce5(func, wait, {
4082
+ return debounce6(func, wait, {
4083
4083
  "leading": leading,
4084
4084
  "maxWait": wait,
4085
4085
  "trailing": trailing
@@ -5093,7 +5093,7 @@ var require_lodash = __commonJS({
5093
5093
  lodash.create = create;
5094
5094
  lodash.curry = curry;
5095
5095
  lodash.curryRight = curryRight;
5096
- lodash.debounce = debounce5;
5096
+ lodash.debounce = debounce6;
5097
5097
  lodash.defaults = defaults;
5098
5098
  lodash.defaultsDeep = defaultsDeep;
5099
5099
  lodash.defer = defer;
@@ -5602,7 +5602,7 @@ var import_react12 = require("react");
5602
5602
  var import_react10 = require("react");
5603
5603
 
5604
5604
  // package.json
5605
- var version = "0.1.104-alpha";
5605
+ var version = "0.1.105";
5606
5606
 
5607
5607
  // src/models/APIError.ts
5608
5608
  var APIError = class _APIError extends Error {
@@ -27431,7 +27431,7 @@ var StatementOfCashFlowView = ({
27431
27431
  };
27432
27432
 
27433
27433
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
27434
- var import_react170 = require("react");
27434
+ var import_react171 = require("react");
27435
27435
 
27436
27436
  // src/contexts/ChartOfAccountsContext/ChartOfAccountsContext.tsx
27437
27437
  var import_react157 = require("react");
@@ -27486,6 +27486,9 @@ var LedgerAccountsContext = (0, import_react158.createContext)({
27486
27486
  setSelectedEntryId: () => {
27487
27487
  },
27488
27488
  closeSelectedEntry: () => {
27489
+ },
27490
+ hasMore: false,
27491
+ fetchMore: () => {
27489
27492
  }
27490
27493
  });
27491
27494
 
@@ -27553,6 +27556,10 @@ var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
27553
27556
  value: "FIXED_ASSET",
27554
27557
  label: "Fixed Assets"
27555
27558
  },
27559
+ {
27560
+ value: "ACCUMULATED_DEPRECIATION",
27561
+ label: "Accumulated Depreciation"
27562
+ },
27556
27563
  {
27557
27564
  value: "CASH",
27558
27565
  label: "Cash"
@@ -27560,13 +27567,33 @@ var ASSET_LEDGER_ACCOUNT_SUBTYPES = [
27560
27567
  {
27561
27568
  value: "UNDEPOSITED_FUNDS",
27562
27569
  label: "Undeposited Funds"
27570
+ },
27571
+ {
27572
+ value: "CURRENT_ASSET",
27573
+ label: "Current Assets"
27574
+ },
27575
+ {
27576
+ value: "NON_CURRENT_ASSET",
27577
+ label: "Non-Current Assets"
27578
+ },
27579
+ {
27580
+ value: "PREPAID_EXPENSES",
27581
+ label: "Prepaid Expenses"
27582
+ },
27583
+ {
27584
+ value: "DEVELOPMENT_COSTS",
27585
+ label: "Development Costs"
27586
+ },
27587
+ {
27588
+ value: "LOANS_RECEIVABLE",
27589
+ label: "Loans Receivable"
27590
+ },
27591
+ {
27592
+ value: "INTANGIBLE_ASSET",
27593
+ label: "Intangible Assets"
27563
27594
  }
27564
27595
  ];
27565
27596
  var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
27566
- {
27567
- value: "LIABILITY",
27568
- label: "Liabilities"
27569
- },
27570
27597
  {
27571
27598
  value: "ACCOUNTS_PAYABLE",
27572
27599
  label: "Accounts Payable"
@@ -27576,36 +27603,72 @@ var LIABILITY_LEDGER_ACCOUNT_SUBTYPES = [
27576
27603
  label: "Credit Cards"
27577
27604
  },
27578
27605
  {
27579
- value: "SHAREHOLDER_LOAN",
27580
- label: "Shareholder Loans"
27606
+ value: "INCOME_TAXES_PAYABLE",
27607
+ label: "Income Taxes Payable"
27608
+ },
27609
+ {
27610
+ value: "SALES_TAXES_PAYABLE",
27611
+ label: "Sales Taxes Payable"
27612
+ },
27613
+ {
27614
+ value: "OTHER_TAXES_PAYABLE",
27615
+ label: "Other Taxes Payable"
27616
+ },
27617
+ {
27618
+ value: "PAYROLL_TAXES_PAYABLE",
27619
+ label: "Payroll Taxes Payable"
27620
+ },
27621
+ {
27622
+ value: "UNEARNED_REVENUE",
27623
+ label: "Unearned Revenue"
27581
27624
  },
27582
27625
  {
27583
27626
  value: "PAYROLL_LIABILITY",
27584
27627
  label: "Payroll Liabilities"
27585
27628
  },
27586
27629
  {
27587
- value: "SALES_TAXES_PAYABLE",
27588
- label: "Sales Taxes Payable"
27630
+ value: "PAYROLL_CLEARING",
27631
+ label: "Payroll Clearing"
27589
27632
  },
27590
27633
  {
27591
27634
  value: "LINE_OF_CREDIT",
27592
27635
  label: "Lines of Credit"
27593
27636
  },
27594
- {
27595
- value: "NOTES_PAYABLE",
27596
- label: "Notes Payable"
27597
- },
27598
27637
  {
27599
27638
  value: "TIPS",
27600
27639
  label: "Tips"
27601
27640
  },
27602
27641
  {
27603
- value: "UNEARNED_REVENUE",
27604
- label: "Unearned Revenue"
27642
+ value: "REFUND_LIABILITIES",
27643
+ label: "Refund Liabilities"
27605
27644
  },
27606
27645
  {
27607
27646
  value: "UNDEPOSITED_OUTFLOWS",
27608
27647
  label: "Undeposited Outflows"
27648
+ },
27649
+ {
27650
+ value: "OUTGOING_PAYMENT_CLEARING_ACCOUNT",
27651
+ label: "Outgoing Payment Clearing Accounts"
27652
+ },
27653
+ {
27654
+ value: "OTHER_CURRENT_LIABILITY",
27655
+ label: "Current Liabilities"
27656
+ },
27657
+ {
27658
+ value: "LOANS_PAYABLE",
27659
+ label: "Loans Payable"
27660
+ },
27661
+ {
27662
+ value: "NOTES_PAYABLE",
27663
+ label: "Notes Payable"
27664
+ },
27665
+ {
27666
+ value: "SHAREHOLDER_LOAN",
27667
+ label: "Shareholder Loans"
27668
+ },
27669
+ {
27670
+ value: "NON_CURRENT_LIABILITY",
27671
+ label: "Long Term Liabilities"
27609
27672
  }
27610
27673
  ];
27611
27674
  var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
@@ -27621,6 +27684,10 @@ var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
27621
27684
  value: "COMMON_STOCK",
27622
27685
  label: "Common Stock"
27623
27686
  },
27687
+ {
27688
+ value: "PREFERRED_STOCK",
27689
+ label: "Preferred Stock"
27690
+ },
27624
27691
  {
27625
27692
  value: "ADDITIONAL_PAID_IN_CAPITAL",
27626
27693
  label: "Additional Paid In Capital"
@@ -27636,6 +27703,10 @@ var EQUITY_LEDGER_ACCOUNT_SUBTYPES = [
27636
27703
  {
27637
27704
  value: "OPENING_BALANCE_EQUITY",
27638
27705
  label: "Opening Balance Equity"
27706
+ },
27707
+ {
27708
+ value: "OTHER_EQUITY",
27709
+ label: "Other Equity"
27639
27710
  }
27640
27711
  ];
27641
27712
  var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
@@ -27650,6 +27721,18 @@ var REVENUE_LEDGER_ACCOUNT_SUBTYPES = [
27650
27721
  {
27651
27722
  value: "RETURNS_ALLOWANCES",
27652
27723
  label: "Returns & Allowances"
27724
+ },
27725
+ {
27726
+ value: "DIVIDEND_INCOME",
27727
+ label: "Dividend Income"
27728
+ },
27729
+ {
27730
+ value: "INTEREST_INCOME",
27731
+ label: "Interest Income"
27732
+ },
27733
+ {
27734
+ value: "OTHER_INCOME",
27735
+ label: "Other Income"
27653
27736
  }
27654
27737
  ];
27655
27738
  var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
@@ -27670,12 +27753,40 @@ var EXPENSE_LEDGER_ACCOUNT_SUBTYPES = [
27670
27753
  label: "Taxes & Licenses"
27671
27754
  },
27672
27755
  {
27673
- value: "BAD_DEBT",
27674
- label: "Bad Debt"
27756
+ value: "UNCATEGORIZED_EXPENSE",
27757
+ label: "Uncategorized Expense"
27675
27758
  },
27676
27759
  {
27677
27760
  value: "CHARITABLE_CONTRIBUTIONS",
27678
27761
  label: "Charitable Contributions"
27762
+ },
27763
+ {
27764
+ value: "LOAN_EXPENSES",
27765
+ label: "Loan Expenses"
27766
+ },
27767
+ {
27768
+ value: "FINANCE_COSTS",
27769
+ label: "Finance Costs"
27770
+ },
27771
+ {
27772
+ value: "INTEREST_EXPENSES",
27773
+ label: "Interest Expenses"
27774
+ },
27775
+ {
27776
+ value: "DEPRECIATION",
27777
+ label: "Depreciation"
27778
+ },
27779
+ {
27780
+ value: "AMORTIZATION",
27781
+ label: "Amortization"
27782
+ },
27783
+ {
27784
+ value: "BAD_DEBT",
27785
+ label: "Bad Debt"
27786
+ },
27787
+ {
27788
+ value: "OTHER_EXPENSES",
27789
+ label: "Other Expenses"
27679
27790
  }
27680
27791
  ];
27681
27792
  var LEDGER_ACCOUNT_SUBTYPES = [
@@ -28018,25 +28129,187 @@ var import_swr23 = require("swr");
28018
28129
  var import_react160 = require("react");
28019
28130
 
28020
28131
  // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
28021
- var import_react161 = require("react");
28132
+ var import_react162 = require("react");
28022
28133
  var import_swr24 = __toESM(require("swr"));
28023
- var useLedgerAccounts = (showReversalEntries = false) => {
28024
- const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
28134
+
28135
+ // src/features/ledger/accounts/[ledgerAccountId]/api/useListLedgerAccountLines.ts
28136
+ var import_infinite4 = __toESM(require("swr/infinite"));
28137
+ var import_react161 = require("react");
28138
+ var import_lodash4 = __toESM(require_lodash());
28139
+ var LIST_LEDGER_ACCOUNT_LINES_TAG_KEY = "#list-ledger-account-lines";
28140
+ var listLedgerAccountLines = get(({
28141
+ businessId,
28142
+ accountId,
28143
+ include_entries_before_activation,
28144
+ include_child_account_lines,
28145
+ start_date,
28146
+ end_date,
28147
+ sort_by,
28148
+ sort_order,
28149
+ cursor,
28150
+ limit,
28151
+ show_total_count
28152
+ }) => {
28153
+ const parameters = toDefinedSearchParameters({
28154
+ include_entries_before_activation,
28155
+ include_child_account_lines,
28156
+ start_date,
28157
+ end_date,
28158
+ sort_by,
28159
+ sort_order,
28160
+ cursor,
28161
+ limit,
28162
+ show_total_count
28163
+ });
28164
+ return `/v1/businesses/${businessId}/ledger/accounts/${accountId}/lines?${parameters}`;
28165
+ });
28166
+ function keyLoader4(previousPageData, {
28167
+ access_token: accessToken,
28168
+ apiUrl,
28169
+ businessId,
28170
+ accountId,
28171
+ include_entries_before_activation,
28172
+ include_child_account_lines,
28173
+ start_date,
28174
+ end_date,
28175
+ sort_by,
28176
+ sort_order,
28177
+ limit,
28178
+ show_total_count
28179
+ }) {
28180
+ var _a;
28181
+ if (accessToken && apiUrl && accountId) {
28182
+ return {
28183
+ accessToken,
28184
+ apiUrl,
28185
+ businessId,
28186
+ accountId,
28187
+ cursor: (_a = previousPageData == null ? void 0 : previousPageData.meta) == null ? void 0 : _a.pagination.cursor,
28188
+ include_entries_before_activation,
28189
+ include_child_account_lines,
28190
+ start_date,
28191
+ end_date,
28192
+ sort_by,
28193
+ sort_order,
28194
+ limit,
28195
+ show_total_count,
28196
+ tags: [LIST_LEDGER_ACCOUNT_LINES_TAG_KEY]
28197
+ };
28198
+ }
28199
+ }
28200
+ function useListLedgerAccountLines({
28201
+ accountId,
28202
+ include_entries_before_activation,
28203
+ include_child_account_lines,
28204
+ start_date,
28205
+ end_date,
28206
+ sort_by,
28207
+ sort_order,
28208
+ limit,
28209
+ show_total_count
28210
+ }) {
28211
+ const { businessId } = useLayerContext();
28025
28212
  const { apiUrl } = useEnvironment();
28026
28213
  const { data: auth } = useAuth();
28027
- const [accountId, setAccountId] = (0, import_react161.useState)();
28028
- const [selectedEntryId, setSelectedEntryId] = (0, import_react161.useState)();
28029
- const queryKey = businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
28030
- const { data, isLoading, isValidating, error, mutate } = (0, import_swr24.default)(
28031
- queryKey,
28032
- Layer.getLedgerAccountsLines(apiUrl, auth == null ? void 0 : auth.access_token, {
28033
- params: {
28214
+ return (0, import_infinite4.default)(
28215
+ (index, previousPageData) => keyLoader4(
28216
+ previousPageData,
28217
+ __spreadProps(__spreadValues({}, auth), {
28218
+ apiUrl,
28034
28219
  businessId,
28035
28220
  accountId,
28036
- includeReversals: showReversalEntries ? "true" : void 0
28221
+ include_entries_before_activation,
28222
+ include_child_account_lines,
28223
+ start_date,
28224
+ end_date,
28225
+ sort_by,
28226
+ sort_order,
28227
+ limit,
28228
+ show_total_count
28229
+ })
28230
+ ),
28231
+ ({
28232
+ accessToken,
28233
+ apiUrl: apiUrl2,
28234
+ businessId: businessId2,
28235
+ accountId: accountId2,
28236
+ cursor,
28237
+ include_entries_before_activation: include_entries_before_activation2,
28238
+ include_child_account_lines: include_child_account_lines2,
28239
+ start_date: start_date2,
28240
+ end_date: end_date2,
28241
+ sort_by: sort_by2,
28242
+ sort_order: sort_order2,
28243
+ limit: limit2,
28244
+ show_total_count: show_total_count2
28245
+ }) => listLedgerAccountLines(
28246
+ apiUrl2,
28247
+ accessToken,
28248
+ {
28249
+ params: {
28250
+ businessId: businessId2,
28251
+ accountId: accountId2,
28252
+ cursor,
28253
+ include_entries_before_activation: include_entries_before_activation2,
28254
+ include_child_account_lines: include_child_account_lines2,
28255
+ start_date: start_date2,
28256
+ end_date: end_date2,
28257
+ sort_by: sort_by2,
28258
+ sort_order: sort_order2,
28259
+ limit: limit2,
28260
+ show_total_count: show_total_count2
28261
+ }
28037
28262
  }
28038
- })
28263
+ )(),
28264
+ {
28265
+ keepPreviousData: true,
28266
+ revalidateAll: false,
28267
+ revalidateFirstPage: false,
28268
+ initialSize: 1
28269
+ }
28039
28270
  );
28271
+ }
28272
+
28273
+ // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
28274
+ var useLedgerAccounts = (showReversalEntries = false) => {
28275
+ const { businessId, read, syncTimestamps, hasBeenTouched } = useLayerContext();
28276
+ const { apiUrl } = useEnvironment();
28277
+ const { data: auth } = useAuth();
28278
+ const [accountId, setAccountId] = (0, import_react162.useState)();
28279
+ const [selectedEntryId, setSelectedEntryId] = (0, import_react162.useState)();
28280
+ const {
28281
+ data: paginatedData,
28282
+ isLoading: paginationIsLoading,
28283
+ isValidating: paginationIsValidating,
28284
+ error: paginationError,
28285
+ mutate,
28286
+ size,
28287
+ setSize
28288
+ } = useListLedgerAccountLines({
28289
+ accountId: accountId || "",
28290
+ include_child_account_lines: true,
28291
+ sort_by: "entry_at",
28292
+ sort_order: "DESC",
28293
+ limit: 150
28294
+ });
28295
+ const shouldFetch = Boolean(accountId);
28296
+ const data = (0, import_react162.useMemo)(() => {
28297
+ if (!paginatedData || !shouldFetch) return void 0;
28298
+ return paginatedData.flatMap((page) => page.data);
28299
+ }, [paginatedData, shouldFetch, showReversalEntries]);
28300
+ const hasMore = (0, import_react162.useMemo)(() => {
28301
+ var _a, _b;
28302
+ if (!shouldFetch || !paginatedData || paginatedData.length === 0) return false;
28303
+ const lastPage = paginatedData[paginatedData.length - 1];
28304
+ return Boolean(
28305
+ ((_a = lastPage.meta) == null ? void 0 : _a.pagination.cursor) && ((_b = lastPage.meta) == null ? void 0 : _b.pagination.has_more)
28306
+ );
28307
+ }, [paginatedData, shouldFetch]);
28308
+ const fetchMore = (0, import_react162.useCallback)(() => {
28309
+ if (hasMore && shouldFetch) {
28310
+ setSize(size + 1);
28311
+ }
28312
+ }, [hasMore, setSize, size, shouldFetch]);
28040
28313
  const {
28041
28314
  data: entryData,
28042
28315
  mutate: mutateEntryData,
@@ -28054,36 +28327,41 @@ var useLedgerAccounts = (showReversalEntries = false) => {
28054
28327
  setSelectedEntryId(void 0);
28055
28328
  void mutateEntryData();
28056
28329
  };
28057
- (0, import_react161.useEffect)(() => {
28058
- if (queryKey && (isLoading || isValidating)) {
28330
+ const queryKey = (0, import_react162.useMemo)(() => {
28331
+ return businessId && accountId && (auth == null ? void 0 : auth.access_token) && `ledger-accounts-lines-${businessId}-${accountId}`;
28332
+ }, [businessId, accountId, auth == null ? void 0 : auth.access_token]);
28333
+ (0, import_react162.useEffect)(() => {
28334
+ if (queryKey && shouldFetch && (paginationIsLoading || paginationIsValidating)) {
28059
28335
  read("LEDGER_ACCOUNTS" /* LEDGER_ACCOUNTS */, queryKey);
28060
28336
  }
28061
- }, [isLoading, isValidating]);
28062
- (0, import_react161.useEffect)(() => {
28063
- if (queryKey && hasBeenTouched(queryKey)) {
28337
+ }, [paginationIsLoading, paginationIsValidating, shouldFetch]);
28338
+ (0, import_react162.useEffect)(() => {
28339
+ if (queryKey && shouldFetch && hasBeenTouched(queryKey)) {
28064
28340
  void refetch();
28065
28341
  }
28066
- }, [syncTimestamps, accountId]);
28342
+ }, [syncTimestamps, accountId, shouldFetch]);
28067
28343
  return {
28068
- data: data == null ? void 0 : data.data,
28344
+ data,
28069
28345
  entryData: entryData == null ? void 0 : entryData.data,
28070
- isLoading,
28346
+ isLoading: shouldFetch ? paginationIsLoading : false,
28071
28347
  isLoadingEntry,
28072
- isValidating,
28073
- isValdiatingEntry,
28074
- error,
28348
+ isValidating: shouldFetch ? paginationIsValidating : false,
28349
+ isValidatingEntry: isValdiatingEntry,
28350
+ error: shouldFetch ? paginationError : void 0,
28075
28351
  errorEntry,
28076
28352
  refetch,
28077
28353
  accountId,
28078
28354
  setAccountId,
28079
28355
  selectedEntryId,
28080
28356
  setSelectedEntryId,
28081
- closeSelectedEntry
28357
+ closeSelectedEntry,
28358
+ hasMore,
28359
+ fetchMore
28082
28360
  };
28083
28361
  };
28084
28362
 
28085
28363
  // src/components/ChartOfAccountsTable/ChartOfAccountsTableWithPanel.tsx
28086
- var import_react166 = require("react");
28364
+ var import_react167 = require("react");
28087
28365
 
28088
28366
  // src/icons/Plus.tsx
28089
28367
  var import_jsx_runtime242 = require("react/jsx-runtime");
@@ -28124,11 +28402,11 @@ var Plus = (_a) => {
28124
28402
  var Plus_default = Plus;
28125
28403
 
28126
28404
  // src/components/ChartOfAccountsDatePicker/ChartOfAccountsDatePicker.tsx
28127
- var import_react162 = require("react");
28405
+ var import_react163 = require("react");
28128
28406
  var import_date_fns37 = require("date-fns");
28129
28407
  var import_jsx_runtime243 = require("react/jsx-runtime");
28130
28408
  var ChartOfAccountsDatePicker = () => {
28131
- const { changeDateRange, dateRange } = (0, import_react162.useContext)(ChartOfAccountsContext);
28409
+ const { changeDateRange, dateRange } = (0, import_react163.useContext)(ChartOfAccountsContext);
28132
28410
  return /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(
28133
28411
  DatePicker,
28134
28412
  {
@@ -28147,13 +28425,13 @@ var ChartOfAccountsDatePicker = () => {
28147
28425
  };
28148
28426
 
28149
28427
  // src/components/ChartOfAccountsForm/ChartOfAccountsForm.tsx
28150
- var import_react164 = require("react");
28428
+ var import_react165 = require("react");
28151
28429
 
28152
28430
  // src/components/ChartOfAccountsForm/useParentOptions.ts
28153
- var import_react163 = require("react");
28431
+ var import_react164 = require("react");
28154
28432
  var useParentOptions = (data) => {
28155
28433
  var _a;
28156
- return (0, import_react163.useMemo)(
28434
+ return (0, import_react164.useMemo)(
28157
28435
  () => flattenAccounts((data == null ? void 0 : data.accounts) || []).sort((a, b) => (a == null ? void 0 : a.name) && (b == null ? void 0 : b.name) ? a.name.localeCompare(b.name) : 0).map((x) => {
28158
28436
  return {
28159
28437
  label: x.name,
@@ -28178,9 +28456,9 @@ var ChartOfAccountsForm = ({
28178
28456
  submitForm,
28179
28457
  sendingForm,
28180
28458
  apiError
28181
- } = (0, import_react164.useContext)(ChartOfAccountsContext);
28459
+ } = (0, import_react165.useContext)(ChartOfAccountsContext);
28182
28460
  const parentOptions = useParentOptions(data);
28183
- const entry = (0, import_react164.useMemo)(() => {
28461
+ const entry = (0, import_react165.useMemo)(() => {
28184
28462
  if ((form == null ? void 0 : form.action) === "edit" && form.accountId) {
28185
28463
  return flattenAccounts((data == null ? void 0 : data.accounts) || []).find(
28186
28464
  (x) => x.id === form.accountId
@@ -28393,7 +28671,7 @@ var ChartOfAccountsSidebar = ({
28393
28671
  };
28394
28672
 
28395
28673
  // src/components/ChartOfAccountsTable/ChartOfAccountsTable.tsx
28396
- var import_react165 = require("react");
28674
+ var import_react166 = require("react");
28397
28675
 
28398
28676
  // src/icons/Edit2.tsx
28399
28677
  var import_jsx_runtime246 = require("react/jsx-runtime");
@@ -28613,11 +28891,11 @@ var ChartOfAccountsTableContent = ({
28613
28891
  expandAll,
28614
28892
  templateAccountsEditable
28615
28893
  }) => {
28616
- const { setAccountId } = (0, import_react165.useContext)(LedgerAccountsContext);
28617
- const { editAccount } = (0, import_react165.useContext)(ChartOfAccountsContext);
28618
- const [toggledKeys, setToggledKeys] = (0, import_react165.useState)({});
28619
- const sortedAccounts = (0, import_react165.useMemo)(() => sortAccountsRecursive(data.accounts), [data.accounts]);
28620
- const allRowKeys = (0, import_react165.useMemo)(() => {
28894
+ const { setAccountId } = (0, import_react166.useContext)(LedgerAccountsContext);
28895
+ const { editAccount } = (0, import_react166.useContext)(ChartOfAccountsContext);
28896
+ const [toggledKeys, setToggledKeys] = (0, import_react166.useState)({});
28897
+ const sortedAccounts = (0, import_react166.useMemo)(() => sortAccountsRecursive(data.accounts), [data.accounts]);
28898
+ const allRowKeys = (0, import_react166.useMemo)(() => {
28621
28899
  const keys = [];
28622
28900
  const collect = (accounts) => {
28623
28901
  for (const account of accounts) {
@@ -28631,7 +28909,7 @@ var ChartOfAccountsTableContent = ({
28631
28909
  collect(data.accounts);
28632
28910
  return keys;
28633
28911
  }, [data.accounts]);
28634
- (0, import_react165.useEffect)(() => {
28912
+ (0, import_react166.useEffect)(() => {
28635
28913
  if (expandAll === void 0) return;
28636
28914
  setToggledKeys(
28637
28915
  Object.fromEntries(
@@ -28639,10 +28917,10 @@ var ChartOfAccountsTableContent = ({
28639
28917
  )
28640
28918
  );
28641
28919
  }, [expandAll]);
28642
- (0, import_react165.useEffect)(() => {
28920
+ (0, import_react166.useEffect)(() => {
28643
28921
  setToggledKeys({});
28644
28922
  }, [searchQuery]);
28645
- const filteredAccounts = (0, import_react165.useMemo)(() => {
28923
+ const filteredAccounts = (0, import_react166.useMemo)(() => {
28646
28924
  if (!searchQuery) return sortedAccounts;
28647
28925
  return filterAccounts(sortedAccounts, searchQuery.toLowerCase());
28648
28926
  }, [searchQuery, sortedAccounts]);
@@ -28674,7 +28952,7 @@ var ChartOfAccountsTableContent = ({
28674
28952
  e.stopPropagation();
28675
28953
  setAccountId(account.id);
28676
28954
  };
28677
- return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(import_react165.Fragment, { children: [
28955
+ return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(import_react166.Fragment, { children: [
28678
28956
  /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)(
28679
28957
  TableRow,
28680
28958
  {
@@ -28883,8 +29161,8 @@ var ChartOfAccountsTableWithPanel = ({
28883
29161
  stringOverrides,
28884
29162
  templateAccountsEditable
28885
29163
  }) => {
28886
- const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react166.useContext)(ChartOfAccountsContext);
28887
- const [expandAll, setExpandAll] = (0, import_react166.useState)();
29164
+ const { data, isLoading, addAccount, error, isValidating, refetch, form } = (0, import_react167.useContext)(ChartOfAccountsContext);
29165
+ const [expandAll, setExpandAll] = (0, import_react167.useState)();
28888
29166
  const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: "" });
28889
29167
  return /* @__PURE__ */ (0, import_jsx_runtime249.jsxs)(
28890
29168
  Panel,
@@ -28977,10 +29255,10 @@ var ChartOfAccountsTableWithPanel = ({
28977
29255
  };
28978
29256
 
28979
29257
  // src/components/LedgerAccount/LedgerAccountIndex.tsx
28980
- var import_react169 = require("react");
29258
+ var import_react170 = require("react");
28981
29259
 
28982
29260
  // src/components/LedgerAccountEntryDetails/LedgerAccountEntryDetails.tsx
28983
- var import_react167 = require("react");
29261
+ var import_react168 = require("react");
28984
29262
 
28985
29263
  // src/utils/journal.ts
28986
29264
  var getAccountIdentifierPayload = (journalLineItem) => {
@@ -29224,8 +29502,8 @@ var LedgerAccountEntryDetails = ({
29224
29502
  stringOverrides
29225
29503
  }) => {
29226
29504
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
29227
- const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react167.useContext)(LedgerAccountsContext);
29228
- const { totalDebit, totalCredit } = (0, import_react167.useMemo)(() => {
29505
+ const { entryData, isLoadingEntry, closeSelectedEntry, errorEntry } = (0, import_react168.useContext)(LedgerAccountsContext);
29506
+ const { totalDebit, totalCredit } = (0, import_react168.useMemo)(() => {
29229
29507
  var _a2;
29230
29508
  let totalDebit2 = 0;
29231
29509
  let totalCredit2 = 0;
@@ -29371,7 +29649,7 @@ var LedgerAccountEntryDetails = ({
29371
29649
  };
29372
29650
 
29373
29651
  // src/components/LedgerAccount/LedgerAccountRow.tsx
29374
- var import_react168 = require("react");
29652
+ var import_react169 = require("react");
29375
29653
  var import_classnames75 = __toESM(require("classnames"));
29376
29654
  var import_date_fns39 = require("date-fns");
29377
29655
  var import_jsx_runtime254 = require("react/jsx-runtime");
@@ -29380,8 +29658,8 @@ var LedgerAccountRow = ({
29380
29658
  index,
29381
29659
  view
29382
29660
  }) => {
29383
- var _a, _b, _c, _d, _e, _f;
29384
- const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react168.useContext)(LedgerAccountsContext);
29661
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
29662
+ const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react169.useContext)(LedgerAccountsContext);
29385
29663
  if (view === "tablet") {
29386
29664
  return /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)(
29387
29665
  "tr",
@@ -29411,7 +29689,8 @@ var LedgerAccountRow = ({
29411
29689
  }
29412
29690
  )
29413
29691
  ] }),
29414
- /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" })
29692
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_b = (_a = row.source) == null ? void 0 : _a.display_description) != null ? _b : "" }),
29693
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { weight: "normal" /* normal */, children: (_d = (_c = row.account) == null ? void 0 : _c.name) != null ? _d : "" })
29415
29694
  ] }) }),
29416
29695
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
29417
29696
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
@@ -29448,7 +29727,8 @@ var LedgerAccountRow = ({
29448
29727
  }
29449
29728
  )
29450
29729
  ] }),
29451
- /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_d = (_c = row.source) == null ? void 0 : _c.display_description) != null ? _d : "" }),
29730
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }),
29731
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)(Text, { weight: "normal" /* normal */, children: (_h = (_g = row.account) == null ? void 0 : _g.name) != null ? _h : "" }),
29452
29732
  /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)("div", { className: "Layer__ledger_account-table__balances-mobile", children: [
29453
29733
  /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)("div", { className: "Layer__ledger_account-table__balance-item", children: [
29454
29734
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__ledger_account-table__balances-mobile__label", children: "Debit" }),
@@ -29488,7 +29768,8 @@ var LedgerAccountRow = ({
29488
29768
  children: [
29489
29769
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: row.date && (0, import_date_fns39.format)((0, import_date_fns39.parseISO)(row.date), DATE_FORMAT) }) }),
29490
29770
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: lineEntryNumber(row) }) }),
29491
- /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (_f = (_e = row.source) == null ? void 0 : _e.display_description) != null ? _f : "" }) }),
29771
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (_j = (_i = row.source) == null ? void 0 : _i.display_description) != null ? _j : "" }) }),
29772
+ /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content", children: (_l = (_k = row.account) == null ? void 0 : _k.name) != null ? _l : "" }) }),
29492
29773
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "DEBIT" /* DEBIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
29493
29774
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: row.direction === "CREDIT" /* CREDIT */ && `$${centsToDollars((row == null ? void 0 : row.amount) || 0)}` }) }),
29494
29775
  /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("td", { className: "Layer__table-cell Layer__table-cell--primary", children: /* @__PURE__ */ (0, import_jsx_runtime254.jsx)("span", { className: "Layer__table-cell-content Layer__table-cell--amount", children: `$${centsToDollars(row.running_balance)}` }) })
@@ -29507,8 +29788,8 @@ var LedgerAccount = ({
29507
29788
  stringOverrides
29508
29789
  }) => {
29509
29790
  var _a, _b, _c, _d, _e, _f, _g, _h;
29510
- const [currentPage, setCurrentPage] = (0, import_react169.useState)(1);
29511
- const { data: accountData } = (0, import_react169.useContext)(ChartOfAccountsContext);
29791
+ const [currentPage, setCurrentPage] = (0, import_react170.useState)(1);
29792
+ const { data: accountData } = (0, import_react170.useContext)(ChartOfAccountsContext);
29512
29793
  const {
29513
29794
  data: rawData,
29514
29795
  error,
@@ -29518,23 +29799,36 @@ var LedgerAccount = ({
29518
29799
  setAccountId,
29519
29800
  selectedEntryId,
29520
29801
  closeSelectedEntry,
29521
- refetch
29522
- } = (0, import_react169.useContext)(LedgerAccountsContext);
29802
+ refetch,
29803
+ hasMore,
29804
+ fetchMore
29805
+ } = (0, import_react170.useContext)(LedgerAccountsContext);
29523
29806
  const baseClassName = (0, import_classnames76.default)(
29524
29807
  "Layer__ledger-account__index",
29525
29808
  accountId && "open"
29526
29809
  );
29527
- const account = (0, import_react169.useMemo)(() => {
29810
+ const account = (0, import_react170.useMemo)(() => {
29528
29811
  return flattenAccounts((accountData == null ? void 0 : accountData.accounts) || []).find(
29529
29812
  (x) => x.id === accountId
29530
29813
  );
29531
29814
  }, [accountId]);
29532
- const data = (0, import_react169.useMemo)(() => {
29815
+ const data = (0, import_react170.useMemo)(() => {
29533
29816
  var _a2;
29817
+ if (!rawData) return void 0;
29534
29818
  const firstPageIndex = (currentPage - 1) * pageSize;
29535
29819
  const lastPageIndex = firstPageIndex + pageSize;
29536
29820
  return (_a2 = rawData == null ? void 0 : rawData.sort((a, b) => Date.parse(b.date) - Date.parse(a.date))) == null ? void 0 : _a2.slice(firstPageIndex, lastPageIndex);
29537
- }, [rawData, currentPage]);
29821
+ }, [rawData, currentPage, pageSize]);
29822
+ const handlePageChange = (page) => {
29823
+ setCurrentPage(page);
29824
+ if (rawData) {
29825
+ const requestedItemIndex = (page - 1) * pageSize + pageSize - 1;
29826
+ const lastAvailableIndex = rawData.length - 1;
29827
+ if (requestedItemIndex > lastAvailableIndex && hasMore) {
29828
+ fetchMore();
29829
+ }
29830
+ }
29831
+ };
29538
29832
  const close2 = () => {
29539
29833
  setAccountId(void 0);
29540
29834
  closeSelectedEntry();
@@ -29592,17 +29886,16 @@ var LedgerAccount = ({
29592
29886
  view === "desktop" && /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
29593
29887
  /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_b = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _b.dateColumnHeader) || "Date" }),
29594
29888
  /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_c = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _c.journalIdColumnHeader) || "Journal id #" }),
29595
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" })
29889
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_d = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _d.sourceColumnHeader) || "Source" }),
29890
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header", children: ((_e = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _e.accountColumnHeader) || "Account" })
29596
29891
  ] }),
29597
29892
  view !== "mobile" && /* @__PURE__ */ (0, import_jsx_runtime255.jsxs)(import_jsx_runtime255.Fragment, { children: [
29598
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_e = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _e.debitColumnHeader) || "Debit" }),
29599
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_f = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _f.creditColumnHeader) || "Credit" }),
29600
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_g = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _g.runningBalanceColumnHeader) || "Running balance" })
29893
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_f = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _f.debitColumnHeader) || "Debit" }),
29894
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_g = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _g.creditColumnHeader) || "Credit" }),
29895
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("th", { className: "Layer__table-header Layer__table-cell--amount", children: ((_h = stringOverrides == null ? void 0 : stringOverrides.ledgerEntriesTable) == null ? void 0 : _h.runningBalanceColumnHeader) || "Running balance" })
29601
29896
  ] })
29602
29897
  ] }) }),
29603
- /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("tbody", { children: (_h = data == null ? void 0 : data.filter(
29604
- (entry) => !entry.entry_reversal_of && !entry.entry_reversed_by
29605
- )) == null ? void 0 : _h.map((x, index) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
29898
+ /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("tbody", { children: data == null ? void 0 : data.map((x, index) => /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
29606
29899
  LedgerAccountRow,
29607
29900
  {
29608
29901
  row: x,
@@ -29618,7 +29911,9 @@ var LedgerAccount = ({
29618
29911
  currentPage,
29619
29912
  totalCount: (rawData == null ? void 0 : rawData.length) || 0,
29620
29913
  pageSize,
29621
- onPageChange: (page) => setCurrentPage(page)
29914
+ onPageChange: handlePageChange,
29915
+ hasMore,
29916
+ fetchMore
29622
29917
  }
29623
29918
  ),
29624
29919
  error ? /* @__PURE__ */ (0, import_jsx_runtime255.jsx)("div", { className: "Layer__table-state-container", children: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(
@@ -29666,7 +29961,7 @@ var ChartOfAccountsContent = ({
29666
29961
  templateAccountsEditable,
29667
29962
  showAddAccountButton
29668
29963
  }) => {
29669
- const { accountId } = (0, import_react170.useContext)(LedgerAccountsContext);
29964
+ const { accountId } = (0, import_react171.useContext)(LedgerAccountsContext);
29670
29965
  const { view, containerRef } = useElementViewSize();
29671
29966
  return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(Container, { name: "chart-of-accounts", ref: containerRef, asWidget, children: accountId ? /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(
29672
29967
  LedgerAccount,
@@ -29691,8 +29986,8 @@ var ChartOfAccountsContent = ({
29691
29986
  };
29692
29987
 
29693
29988
  // src/contexts/JournalContext/JournalContext.tsx
29694
- var import_react171 = require("react");
29695
- var JournalContext = (0, import_react171.createContext)({
29989
+ var import_react172 = require("react");
29990
+ var JournalContext = (0, import_react172.createContext)({
29696
29991
  refetch: () => {
29697
29992
  },
29698
29993
  setSelectedEntryId: () => {
@@ -29723,12 +30018,12 @@ var JournalContext = (0, import_react171.createContext)({
29723
30018
  });
29724
30019
 
29725
30020
  // src/hooks/useJournal/useJournal.tsx
29726
- var import_react173 = require("react");
30021
+ var import_react174 = require("react");
29727
30022
 
29728
30023
  // src/features/ledger/entries/api/useListLedgerEntries.ts
29729
- var import_infinite4 = __toESM(require("swr/infinite"));
29730
- var import_react172 = require("react");
29731
- var import_lodash4 = __toESM(require_lodash());
30024
+ var import_infinite5 = __toESM(require("swr/infinite"));
30025
+ var import_react173 = require("react");
30026
+ var import_lodash5 = __toESM(require_lodash());
29732
30027
  var LIST_LEDGER_ENTRIES_TAG_KEY = "#list-ledger-entries";
29733
30028
  var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, show_total_count }) => {
29734
30029
  const parameters = toDefinedSearchParameters({
@@ -29740,7 +30035,7 @@ var listLedgerEntries = get(({ businessId, sort_by, sort_order, cursor, limit, s
29740
30035
  });
29741
30036
  return `/v1/businesses/${businessId}/ledger/entries?${parameters}`;
29742
30037
  });
29743
- function keyLoader4(previousPageData, {
30038
+ function keyLoader5(previousPageData, {
29744
30039
  access_token: accessToken,
29745
30040
  apiUrl,
29746
30041
  businessId,
@@ -29773,8 +30068,8 @@ function useListLedgerEntries({
29773
30068
  const { businessId } = useLayerContext();
29774
30069
  const { apiUrl } = useEnvironment();
29775
30070
  const { data: auth } = useAuth();
29776
- return (0, import_infinite4.default)(
29777
- (index, previousPageData) => keyLoader4(
30071
+ return (0, import_infinite5.default)(
30072
+ (index, previousPageData) => keyLoader5(
29778
30073
  previousPageData,
29779
30074
  __spreadProps(__spreadValues({}, auth), {
29780
30075
  apiUrl,
@@ -29825,11 +30120,11 @@ var useJournal = () => {
29825
30120
  } = useLayerContext();
29826
30121
  const { apiUrl } = useEnvironment();
29827
30122
  const { data: auth } = useAuth();
29828
- const [selectedEntryId, setSelectedEntryId] = (0, import_react173.useState)();
29829
- const [form, setForm] = (0, import_react173.useState)();
29830
- const [addingEntry, setAddingEntry] = (0, import_react173.useState)(false);
29831
- const [sendingForm, setSendingForm] = (0, import_react173.useState)(false);
29832
- const [apiError, setApiError] = (0, import_react173.useState)(void 0);
30123
+ const [selectedEntryId, setSelectedEntryId] = (0, import_react174.useState)();
30124
+ const [form, setForm] = (0, import_react174.useState)();
30125
+ const [addingEntry, setAddingEntry] = (0, import_react174.useState)(false);
30126
+ const [sendingForm, setSendingForm] = (0, import_react174.useState)(false);
30127
+ const [apiError, setApiError] = (0, import_react174.useState)(void 0);
29833
30128
  const {
29834
30129
  data: paginatedData,
29835
30130
  isLoading,
@@ -29843,11 +30138,11 @@ var useJournal = () => {
29843
30138
  sort_order: "DESC",
29844
30139
  limit: 150
29845
30140
  });
29846
- const data = (0, import_react173.useMemo)(() => {
30141
+ const data = (0, import_react174.useMemo)(() => {
29847
30142
  if (!paginatedData) return void 0;
29848
30143
  return paginatedData.flatMap((page) => page.data);
29849
30144
  }, [paginatedData]);
29850
- const hasMore = (0, import_react173.useMemo)(() => {
30145
+ const hasMore = (0, import_react174.useMemo)(() => {
29851
30146
  var _a, _b;
29852
30147
  if (paginatedData && paginatedData.length > 0) {
29853
30148
  const lastPage = paginatedData[paginatedData.length - 1];
@@ -29857,7 +30152,7 @@ var useJournal = () => {
29857
30152
  }
29858
30153
  return false;
29859
30154
  }, [paginatedData]);
29860
- const fetchMore = (0, import_react173.useCallback)(() => {
30155
+ const fetchMore = (0, import_react174.useCallback)(() => {
29861
30156
  if (hasMore) {
29862
30157
  setSize(size + 1);
29863
30158
  }
@@ -30102,13 +30397,13 @@ var useJournal = () => {
30102
30397
  };
30103
30398
 
30104
30399
  // src/components/JournalTable/JournalTableWithPanel.tsx
30105
- var import_react179 = require("react");
30400
+ var import_react180 = require("react");
30106
30401
 
30107
30402
  // src/components/JournalSidebar/JournalSidebar.tsx
30108
- var import_react177 = require("react");
30403
+ var import_react178 = require("react");
30109
30404
 
30110
30405
  // src/components/JournalEntryDetails/JournalEntryDetails.tsx
30111
- var import_react174 = require("react");
30406
+ var import_react175 = require("react");
30112
30407
  var import_jsx_runtime257 = require("react/jsx-runtime");
30113
30408
  var JournalEntryDetails = () => {
30114
30409
  var _a, _b, _c, _d;
@@ -30120,16 +30415,16 @@ var JournalEntryDetails = () => {
30120
30415
  selectedEntryId,
30121
30416
  reverseEntry,
30122
30417
  refetch
30123
- } = (0, import_react174.useContext)(JournalContext);
30124
- const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react174.useState)(false);
30125
- const [reverseEntryError, setReverseEntryError] = (0, import_react174.useState)();
30126
- const entry = (0, import_react174.useMemo)(() => {
30418
+ } = (0, import_react175.useContext)(JournalContext);
30419
+ const [reverseEntryProcessing, setReverseEntryProcessing] = (0, import_react175.useState)(false);
30420
+ const [reverseEntryError, setReverseEntryError] = (0, import_react175.useState)();
30421
+ const entry = (0, import_react175.useMemo)(() => {
30127
30422
  if (selectedEntryId && data) {
30128
30423
  return data.find((x) => x.id === selectedEntryId);
30129
30424
  }
30130
30425
  return;
30131
30426
  }, [data, selectedEntryId]);
30132
- const sortedLineItems = (0, import_react174.useMemo)(
30427
+ const sortedLineItems = (0, import_react175.useMemo)(
30133
30428
  () => {
30134
30429
  var _a2;
30135
30430
  return (_a2 = entry == null ? void 0 : entry.line_items) == null ? void 0 : _a2.sort(
@@ -30307,10 +30602,10 @@ var JournalEntryDetails = () => {
30307
30602
  };
30308
30603
 
30309
30604
  // src/components/JournalForm/JournalForm.tsx
30310
- var import_react176 = require("react");
30605
+ var import_react177 = require("react");
30311
30606
 
30312
30607
  // src/components/JournalForm/JournalFormEntryLines.tsx
30313
- var import_react175 = require("react");
30608
+ var import_react176 = require("react");
30314
30609
  var import_jsx_runtime258 = require("react/jsx-runtime");
30315
30610
  function recursiveFlattenCategories(accounts) {
30316
30611
  const flattenedResult = accounts.flatMap((a) => {
@@ -30331,8 +30626,8 @@ var JournalFormEntryLines = ({
30331
30626
  config
30332
30627
  }) => {
30333
30628
  const { data: categories } = useCategories({ mode: "ALL" });
30334
- const { form } = (0, import_react175.useContext)(JournalContext);
30335
- const { flattenedCategories, parentOptions } = (0, import_react175.useMemo)(() => {
30629
+ const { form } = (0, import_react176.useContext)(JournalContext);
30630
+ const { flattenedCategories, parentOptions } = (0, import_react176.useMemo)(() => {
30336
30631
  const flattenedCategories2 = recursiveFlattenCategories(categories != null ? categories : []);
30337
30632
  const parentOptions2 = [...flattenedCategories2].sort((a, b) => a.display_name.localeCompare(b.display_name)).map((account) => {
30338
30633
  switch (account.type) {
@@ -30543,7 +30838,7 @@ var JournalForm = ({
30543
30838
  changeFormData,
30544
30839
  addEntryLine,
30545
30840
  removeEntryLine
30546
- } = (0, import_react176.useContext)(JournalContext);
30841
+ } = (0, import_react177.useContext)(JournalContext);
30547
30842
  return /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)(
30548
30843
  "form",
30549
30844
  {
@@ -30691,7 +30986,7 @@ var JournalSidebar = ({
30691
30986
  config,
30692
30987
  stringOverrides
30693
30988
  }) => {
30694
- const { selectedEntryId } = (0, import_react177.useContext)(JournalContext);
30989
+ const { selectedEntryId } = (0, import_react178.useContext)(JournalContext);
30695
30990
  if (selectedEntryId !== "new") {
30696
30991
  return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)(JournalEntryDetails, {});
30697
30992
  }
@@ -30699,7 +30994,7 @@ var JournalSidebar = ({
30699
30994
  };
30700
30995
 
30701
30996
  // src/components/JournalTable/JournalTable.tsx
30702
- var import_react178 = require("react");
30997
+ var import_react179 = require("react");
30703
30998
  var import_date_fns40 = require("date-fns");
30704
30999
  var import_jsx_runtime261 = require("react/jsx-runtime");
30705
31000
  var accountName = (row) => {
@@ -30727,9 +31022,9 @@ var JournalTableContent = ({
30727
31022
  data,
30728
31023
  stringOverrides
30729
31024
  }) => {
30730
- const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react178.useContext)(JournalContext);
31025
+ const { selectedEntryId, setSelectedEntryId, closeSelectedEntry } = (0, import_react179.useContext)(JournalContext);
30731
31026
  const { isOpen, setIsOpen } = useTableExpandRow();
30732
- (0, import_react178.useLayoutEffect)(() => {
31027
+ (0, import_react179.useLayoutEffect)(() => {
30733
31028
  if (data.length > 0) {
30734
31029
  setIsOpen(data.map((x) => `journal-row-${x.id}`));
30735
31030
  }
@@ -30737,7 +31032,7 @@ var JournalTableContent = ({
30737
31032
  const renderJournalRow = (row, index, rowKey, depth) => {
30738
31033
  const expandable = !!row.line_items && row.line_items.length > 0;
30739
31034
  const expanded = !expandable || isOpen(rowKey);
30740
- return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_react178.Fragment, { children: [
31035
+ return /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(import_react179.Fragment, { children: [
30741
31036
  /* @__PURE__ */ (0, import_jsx_runtime261.jsxs)(
30742
31037
  TableRow,
30743
31038
  {
@@ -30913,7 +31208,7 @@ var JournalTableWithPanel = ({
30913
31208
  stringOverrides,
30914
31209
  view
30915
31210
  }) => {
30916
- const [currentPage, setCurrentPage] = (0, import_react179.useState)(1);
31211
+ const [currentPage, setCurrentPage] = (0, import_react180.useState)(1);
30917
31212
  const {
30918
31213
  data: rawData,
30919
31214
  isLoading,
@@ -30924,8 +31219,8 @@ var JournalTableWithPanel = ({
30924
31219
  addEntry,
30925
31220
  hasMore,
30926
31221
  fetchMore
30927
- } = (0, import_react179.useContext)(JournalContext);
30928
- const data = (0, import_react179.useMemo)(
31222
+ } = (0, import_react180.useContext)(JournalContext);
31223
+ const data = (0, import_react180.useMemo)(
30929
31224
  () => {
30930
31225
  if (!rawData) return void 0;
30931
31226
  const firstPageIndex = (currentPage - 1) * pageSize;
@@ -31071,7 +31366,7 @@ var TasksHeader = ({
31071
31366
  };
31072
31367
 
31073
31368
  // src/components/Tasks/TasksList.tsx
31074
- var import_react187 = require("react");
31369
+ var import_react188 = require("react");
31075
31370
 
31076
31371
  // src/icons/SmileIcon.tsx
31077
31372
  var import_jsx_runtime266 = require("react/jsx-runtime");
@@ -31130,7 +31425,7 @@ var SmileIcon = (_a) => {
31130
31425
  var SmileIcon_default = SmileIcon;
31131
31426
 
31132
31427
  // src/components/Tasks/TasksListItem.tsx
31133
- var import_react184 = require("react");
31428
+ var import_react185 = require("react");
31134
31429
  var import_classnames77 = __toESM(require("classnames"));
31135
31430
 
31136
31431
  // src/utils/bookkeeping/tasks/getBookkeepingTaskStatusIcon.tsx
@@ -31188,7 +31483,7 @@ function completeTaskWithUpload(baseUrl, accessToken, {
31188
31483
  }
31189
31484
 
31190
31485
  // src/hooks/bookkeeping/periods/tasks/useSubmitResponseForTask.ts
31191
- var import_react180 = require("react");
31486
+ var import_react181 = require("react");
31192
31487
  function buildKey29({
31193
31488
  access_token: accessToken,
31194
31489
  apiUrl,
@@ -31231,7 +31526,7 @@ function useSubmitUserResponseForTask() {
31231
31526
  }
31232
31527
  );
31233
31528
  const { trigger: originalTrigger } = mutationResponse;
31234
- const stableProxiedTrigger = (0, import_react180.useCallback)(
31529
+ const stableProxiedTrigger = (0, import_react181.useCallback)(
31235
31530
  (...triggerParameters) => __async(null, null, function* () {
31236
31531
  const triggerResult = yield originalTrigger(...triggerParameters);
31237
31532
  void mutate((key) => withSWRKeyTags(
@@ -31258,7 +31553,7 @@ function useSubmitUserResponseForTask() {
31258
31553
  // src/hooks/bookkeeping/periods/tasks/useUploadDocumentsForTask.ts
31259
31554
  var import_swr26 = require("swr");
31260
31555
  var import_mutation19 = __toESM(require("swr/mutation"));
31261
- var import_react181 = require("react");
31556
+ var import_react182 = require("react");
31262
31557
  function buildKey30({
31263
31558
  access_token: accessToken,
31264
31559
  apiUrl,
@@ -31297,7 +31592,7 @@ function useUploadDocumentsForTask() {
31297
31592
  }
31298
31593
  );
31299
31594
  const { trigger: originalTrigger } = mutationResponse;
31300
- const stableProxiedTrigger = (0, import_react181.useCallback)(
31595
+ const stableProxiedTrigger = (0, import_react182.useCallback)(
31301
31596
  (...triggerParameters) => __async(null, null, function* () {
31302
31597
  const triggerResult = yield originalTrigger(...triggerParameters);
31303
31598
  void mutate((key) => withSWRKeyTags(
@@ -31324,7 +31619,7 @@ function useUploadDocumentsForTask() {
31324
31619
  // src/hooks/bookkeeping/periods/tasks/useDeleteUploadsOnTask.ts
31325
31620
  var import_swr27 = require("swr");
31326
31621
  var import_mutation20 = __toESM(require("swr/mutation"));
31327
- var import_react182 = require("react");
31622
+ var import_react183 = require("react");
31328
31623
  function buildKey31({
31329
31624
  access_token: accessToken,
31330
31625
  apiUrl,
@@ -31360,7 +31655,7 @@ function useDeleteUploadsOnTask() {
31360
31655
  }
31361
31656
  );
31362
31657
  const { trigger: originalTrigger } = mutationResponse;
31363
- const stableProxiedTrigger = (0, import_react182.useCallback)(
31658
+ const stableProxiedTrigger = (0, import_react183.useCallback)(
31364
31659
  (...triggerParameters) => __async(null, null, function* () {
31365
31660
  const triggerResult = yield originalTrigger(...triggerParameters);
31366
31661
  void mutate((key) => withSWRKeyTags(
@@ -31387,7 +31682,7 @@ function useDeleteUploadsOnTask() {
31387
31682
  // src/hooks/bookkeeping/periods/tasks/useUpdateTaskUploadDescription.ts
31388
31683
  var import_swr28 = require("swr");
31389
31684
  var import_mutation21 = __toESM(require("swr/mutation"));
31390
- var import_react183 = require("react");
31685
+ var import_react184 = require("react");
31391
31686
  function buildKey32({
31392
31687
  access_token: accessToken,
31393
31688
  apiUrl,
@@ -31427,7 +31722,7 @@ function useUpdateTaskUploadDescription() {
31427
31722
  }
31428
31723
  );
31429
31724
  const { trigger: originalTrigger } = mutationResponse;
31430
- const stableProxiedTrigger = (0, import_react183.useCallback)(
31725
+ const stableProxiedTrigger = (0, import_react184.useCallback)(
31431
31726
  (...triggerParameters) => __async(null, null, function* () {
31432
31727
  const triggerResult = yield originalTrigger(...triggerParameters);
31433
31728
  void mutate((key) => withSWRKeyTags(
@@ -31458,9 +31753,9 @@ var TasksListItem = ({
31458
31753
  defaultOpen
31459
31754
  }) => {
31460
31755
  var _a, _b;
31461
- const [isOpen, setIsOpen] = (0, import_react184.useState)(defaultOpen);
31462
- const [userResponse, setUserResponse] = (0, import_react184.useState)((_a = task.user_response) != null ? _a : "");
31463
- const [selectedFiles, setSelectedFiles] = (0, import_react184.useState)();
31756
+ const [isOpen, setIsOpen] = (0, import_react185.useState)(defaultOpen);
31757
+ const [userResponse, setUserResponse] = (0, import_react185.useState)((_a = task.user_response) != null ? _a : "");
31758
+ const [selectedFiles, setSelectedFiles] = (0, import_react185.useState)();
31464
31759
  const { trigger: handleSubmitUserResponseForTask } = useSubmitUserResponseForTask();
31465
31760
  const { trigger: handleUploadDocumentsForTask } = useUploadDocumentsForTask();
31466
31761
  const { trigger: handleDeleteUploadsOnTask } = useDeleteUploadsOnTask();
@@ -31478,7 +31773,7 @@ var TasksListItem = ({
31478
31773
  "Layer__tasks-list-item",
31479
31774
  isOpen && "Layer__tasks-list-item__expanded"
31480
31775
  );
31481
- (0, import_react184.useEffect)(() => {
31776
+ (0, import_react185.useEffect)(() => {
31482
31777
  setIsOpen(defaultOpen);
31483
31778
  }, [defaultOpen]);
31484
31779
  const submit = () => __async(null, null, function* () {
@@ -31493,7 +31788,7 @@ var TasksListItem = ({
31493
31788
  setIsOpen(false);
31494
31789
  setSelectedFiles(void 0);
31495
31790
  });
31496
- const uploadDocumentAction = (0, import_react184.useMemo)(() => {
31791
+ const uploadDocumentAction = (0, import_react185.useMemo)(() => {
31497
31792
  if (task.user_response_type === "UPLOAD_DOCUMENT") {
31498
31793
  if (task.status === "TODO") {
31499
31794
  if (!selectedFiles) {
@@ -31638,7 +31933,7 @@ var MobilePanel = ({ header, children, open: open2, onClose, className }) => {
31638
31933
  };
31639
31934
 
31640
31935
  // src/components/Tasks/TasksListMobile.tsx
31641
- var import_react185 = require("react");
31936
+ var import_react186 = require("react");
31642
31937
  var import_jsx_runtime270 = require("react/jsx-runtime");
31643
31938
  var MOBILE_SHOW_UNRESOLVED_TASKS_COUNT = 2;
31644
31939
  var TasksListMobile = ({
@@ -31649,7 +31944,7 @@ var TasksListMobile = ({
31649
31944
  pageSize,
31650
31945
  setCurrentPage
31651
31946
  }) => {
31652
- const [showMobilePanel, setShowMobilePanel] = (0, import_react185.useState)(false);
31947
+ const [showMobilePanel, setShowMobilePanel] = (0, import_react186.useState)(false);
31653
31948
  const unresolvedTasks = getIncompleteTasks(sortedTasks).slice(0, MOBILE_SHOW_UNRESOLVED_TASKS_COUNT);
31654
31949
  return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)("div", { className: "Layer__tasks-list", children: [
31655
31950
  unresolvedTasks.map((task, index) => /* @__PURE__ */ (0, import_jsx_runtime270.jsx)(
@@ -31697,27 +31992,27 @@ var TasksListMobile = ({
31697
31992
  };
31698
31993
 
31699
31994
  // src/hooks/array/usePaginatedList.ts
31700
- var import_react186 = require("react");
31995
+ var import_react187 = require("react");
31701
31996
  function usePaginatedList(list, pageSize) {
31702
- const [internalPageIndex, setInternalPageIndex] = (0, import_react186.useState)(0);
31997
+ const [internalPageIndex, setInternalPageIndex] = (0, import_react187.useState)(0);
31703
31998
  const pageCount = Math.max(0, Math.ceil(list.length / pageSize));
31704
31999
  const effectivePageIndex = Math.max(0, Math.min(internalPageIndex, pageCount - 1));
31705
- const pageItems = (0, import_react186.useMemo)(() => {
32000
+ const pageItems = (0, import_react187.useMemo)(() => {
31706
32001
  return list.slice(
31707
32002
  effectivePageIndex * pageSize,
31708
32003
  (effectivePageIndex + 1) * pageSize
31709
32004
  );
31710
32005
  }, [list, effectivePageIndex, pageSize]);
31711
- const next = (0, import_react186.useCallback)(() => {
32006
+ const next = (0, import_react187.useCallback)(() => {
31712
32007
  setInternalPageIndex(Math.min(effectivePageIndex + 1, pageCount - 1));
31713
32008
  }, [effectivePageIndex, pageCount]);
31714
- const set2 = (0, import_react186.useCallback)((pageIndex) => {
32009
+ const set2 = (0, import_react187.useCallback)((pageIndex) => {
31715
32010
  setInternalPageIndex(Math.max(0, Math.min(pageIndex, pageCount - 1)));
31716
32011
  }, [pageCount]);
31717
- const previous = (0, import_react186.useCallback)(() => {
32012
+ const previous = (0, import_react187.useCallback)(() => {
31718
32013
  setInternalPageIndex(Math.max(effectivePageIndex - 1, 0));
31719
32014
  }, [effectivePageIndex]);
31720
- const reset = (0, import_react186.useCallback)(() => {
32015
+ const reset = (0, import_react187.useCallback)(() => {
31721
32016
  setInternalPageIndex(0);
31722
32017
  }, []);
31723
32018
  return {
@@ -31745,7 +32040,7 @@ var TasksEmptyState = () => /* @__PURE__ */ (0, import_jsx_runtime271.jsxs)("div
31745
32040
  ] });
31746
32041
  function TasksList({ pageSize = 8, mobile }) {
31747
32042
  const { activePeriod } = useActiveBookkeepingPeriod();
31748
- const sortedTasks = (0, import_react187.useMemo)(() => {
32043
+ const sortedTasks = (0, import_react188.useMemo)(() => {
31749
32044
  var _a;
31750
32045
  const tasksInPeriod = (_a = activePeriod == null ? void 0 : activePeriod.tasks) != null ? _a : [];
31751
32046
  return tasksInPeriod.sort((taskA, taskB) => {
@@ -31887,7 +32182,7 @@ var TasksPending = () => {
31887
32182
  };
31888
32183
 
31889
32184
  // src/components/Tasks/TasksMonthSelector.tsx
31890
- var import_react188 = require("react");
32185
+ var import_react189 = require("react");
31891
32186
  var import_date_fns42 = require("date-fns");
31892
32187
 
31893
32188
  // src/components/Tasks/TaskStatusBadge.tsx
@@ -31989,7 +32284,7 @@ function useActiveYearBookkeepingPeriods() {
31989
32284
  const { date } = useGlobalDate();
31990
32285
  const { data } = useBookkeepingPeriods();
31991
32286
  const activeYear = (0, import_date_fns42.getYear)(date);
31992
- const periodsInActiveYear = (0, import_react188.useMemo)(() => {
32287
+ const periodsInActiveYear = (0, import_react189.useMemo)(() => {
31993
32288
  return data == null ? void 0 : data.filter((period) => period.year === activeYear);
31994
32289
  }, [data, activeYear]);
31995
32290
  return { periodsInActiveYear };
@@ -32000,7 +32295,7 @@ function TasksMonthSelector() {
32000
32295
  const { periodsInActiveYear } = useActiveYearBookkeepingPeriods();
32001
32296
  const activeMonthNumber = (0, import_date_fns42.getMonth)(date) + 1;
32002
32297
  const activeYear = (0, import_date_fns42.getYear)(date);
32003
- const monthsData = (0, import_react188.useMemo)(() => {
32298
+ const monthsData = (0, import_react189.useMemo)(() => {
32004
32299
  return Array.from({ length: 12 }, (_, index) => {
32005
32300
  var _a, _b;
32006
32301
  const date2 = (0, import_date_fns42.set)(
@@ -32050,13 +32345,13 @@ var import_classnames81 = __toESM(require("classnames"));
32050
32345
  var import_pluralize4 = __toESM(require("pluralize"));
32051
32346
 
32052
32347
  // src/hooks/bookkeeping/periods/useBookkeepingYearsStatus.ts
32053
- var import_react189 = require("react");
32348
+ var import_react190 = require("react");
32054
32349
  var import_date_fns43 = require("date-fns");
32055
32350
  var useBookkeepingYearsStatus = () => {
32056
32351
  const { business } = useLayerContext();
32057
32352
  const activationDate = getActivationDate(business);
32058
32353
  const { data, isLoading } = useBookkeepingPeriods();
32059
- const yearStatuses = (0, import_react189.useMemo)(() => {
32354
+ const yearStatuses = (0, import_react190.useMemo)(() => {
32060
32355
  const startYear = (0, import_date_fns43.getYear)(activationDate != null ? activationDate : /* @__PURE__ */ new Date());
32061
32356
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
32062
32357
  const count = currentYear - startYear + 1;
@@ -32071,7 +32366,7 @@ var useBookkeepingYearsStatus = () => {
32071
32366
  };
32072
32367
  }).filter(({ year }) => data == null ? void 0 : data.some((period) => period.year === year)).sort((a, b) => b.year - a.year);
32073
32368
  }, [activationDate, data]);
32074
- const earliestIncompletePeriod = (0, import_react189.useMemo)(
32369
+ const earliestIncompletePeriod = (0, import_react190.useMemo)(
32075
32370
  () => [...data != null ? data : []].sort((a, b) => {
32076
32371
  if (a.year === b.year) {
32077
32372
  return b.month - a.month;
@@ -32214,10 +32509,10 @@ var TasksPanelNotification = ({
32214
32509
  };
32215
32510
 
32216
32511
  // src/components/Tasks/TasksYearsTabs.tsx
32217
- var import_react192 = require("react");
32512
+ var import_react193 = require("react");
32218
32513
 
32219
32514
  // src/components/Tabs/Tabs.tsx
32220
- var import_react190 = require("react");
32515
+ var import_react191 = require("react");
32221
32516
 
32222
32517
  // src/components/Tabs/Tab.tsx
32223
32518
  var import_jsx_runtime279 = require("react/jsx-runtime");
@@ -32281,12 +32576,12 @@ var Tab = ({
32281
32576
  // src/components/Tabs/Tabs.tsx
32282
32577
  var import_classnames80 = __toESM(require("classnames"));
32283
32578
  var import_jsx_runtime280 = require("react/jsx-runtime");
32284
- var import_react191 = require("react");
32579
+ var import_react192 = require("react");
32285
32580
  var STARTING_PADDING = 12;
32286
32581
  var Tabs = ({ name, options, selected, onChange }) => {
32287
- const [initialized, setInitialized] = (0, import_react190.useState)(false);
32288
- const [thumbPos, setThumbPos] = (0, import_react190.useState)({ left: 0, width: 0 });
32289
- const [currentWidth, setCurrentWidth] = (0, import_react190.useState)(0);
32582
+ const [initialized, setInitialized] = (0, import_react191.useState)(false);
32583
+ const [thumbPos, setThumbPos] = (0, import_react191.useState)({ left: 0, width: 0 });
32584
+ const [currentWidth, setCurrentWidth] = (0, import_react191.useState)(0);
32290
32585
  const selectedValue = selected || options[0].value;
32291
32586
  const baseClassName = (0, import_classnames80.default)(
32292
32587
  "Layer__tabs",
@@ -32321,14 +32616,14 @@ var Tabs = ({ name, options, selected, onChange }) => {
32321
32616
  shift2 = shift2 + STARTING_PADDING;
32322
32617
  setThumbPos({ left: shift2, width });
32323
32618
  };
32324
- (0, import_react190.useEffect)(() => {
32619
+ (0, import_react191.useEffect)(() => {
32325
32620
  const selectedIndex = getSelectedIndex();
32326
32621
  updateSelectPosition(selectedIndex);
32327
32622
  setTimeout(() => {
32328
32623
  setInitialized(true);
32329
32624
  }, 400);
32330
32625
  }, []);
32331
- (0, import_react190.useEffect)(() => {
32626
+ (0, import_react191.useEffect)(() => {
32332
32627
  const selectedIndex = getSelectedIndex();
32333
32628
  updateSelectPosition(selectedIndex);
32334
32629
  }, [selectedValue, currentWidth]);
@@ -32344,7 +32639,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
32344
32639
  return /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)("div", { className: baseClassName, ref: elementRef, children: [
32345
32640
  options.map((option, index) => {
32346
32641
  var _a;
32347
- return /* @__PURE__ */ (0, import_react191.createElement)(
32642
+ return /* @__PURE__ */ (0, import_react192.createElement)(
32348
32643
  Tab,
32349
32644
  __spreadProps(__spreadValues({}, option), {
32350
32645
  key: option.value,
@@ -32376,7 +32671,7 @@ var TasksYearsTabs = () => {
32376
32671
  yearNumber: Number(year)
32377
32672
  });
32378
32673
  };
32379
- const yearsList = (0, import_react192.useMemo)(() => {
32674
+ const yearsList = (0, import_react193.useMemo)(() => {
32380
32675
  return yearStatuses == null ? void 0 : yearStatuses.sort((a, b) => a.year - b.year).map((y) => {
32381
32676
  return {
32382
32677
  value: `${y.year}`,
@@ -32479,10 +32774,10 @@ function Tasks({
32479
32774
  }
32480
32775
 
32481
32776
  // src/components/PlatformOnboarding/LinkAccounts.tsx
32482
- var import_react195 = require("react");
32777
+ var import_react196 = require("react");
32483
32778
 
32484
32779
  // src/components/PlatformOnboarding/Steps/LinkAccountsConfirmationStep.tsx
32485
- var import_react193 = require("react");
32780
+ var import_react194 = require("react");
32486
32781
  var import_react_form3 = require("@tanstack/react-form");
32487
32782
 
32488
32783
  // src/components/PlatformOnboarding/Container/LinkAccountsListContainer.tsx
@@ -32518,7 +32813,7 @@ function LinkAccountsConfirmationStep() {
32518
32813
  data: linkedAccounts,
32519
32814
  loadingStatus: linkedAccountsLoadingStatus,
32520
32815
  refetchAccounts
32521
- } = (0, import_react193.useContext)(LinkedAccountsContext);
32816
+ } = (0, import_react194.useContext)(LinkedAccountsContext);
32522
32817
  const effectiveLinkedAccounts = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
32523
32818
  const { trigger } = useConfirmAndExcludeMultiple({ onSuccess: refetchAccounts });
32524
32819
  const { previous, next } = useWizard();
@@ -32591,7 +32886,7 @@ function LinkAccountsConfirmationStep() {
32591
32886
  }
32592
32887
 
32593
32888
  // src/components/PlatformOnboarding/Steps/LinkAccountsLinkStep.tsx
32594
- var import_react194 = require("react");
32889
+ var import_react195 = require("react");
32595
32890
  var import_pluralize5 = __toESM(require("pluralize"));
32596
32891
  var import_jsx_runtime286 = require("react/jsx-runtime");
32597
32892
  function LinkAccountsLinkStep() {
@@ -32601,7 +32896,7 @@ function LinkAccountsLinkStep() {
32601
32896
  error,
32602
32897
  refetchAccounts,
32603
32898
  addConnection
32604
- } = (0, import_react194.useContext)(LinkedAccountsContext);
32899
+ } = (0, import_react195.useContext)(LinkedAccountsContext);
32605
32900
  const { next } = useWizard();
32606
32901
  const effectiveAccounts = data != null ? data : [];
32607
32902
  return /* @__PURE__ */ (0, import_jsx_runtime286.jsxs)(import_jsx_runtime286.Fragment, { children: [
@@ -32681,7 +32976,7 @@ function LinkAccounts(props) {
32681
32976
  function LinkAccountsContent({
32682
32977
  onComplete
32683
32978
  }) {
32684
- const { data: linkedAccounts, loadingStatus } = (0, import_react195.useContext)(LinkedAccountsContext);
32979
+ const { data: linkedAccounts, loadingStatus } = (0, import_react196.useContext)(LinkedAccountsContext);
32685
32980
  const linkedAccountsNeedingConfirmation = linkedAccounts ? getAccountsNeedingConfirmation(linkedAccounts) : [];
32686
32981
  const hideConfirmationStep = loadingStatus === "complete" && linkedAccountsNeedingConfirmation.length === 0;
32687
32982
  return /* @__PURE__ */ (0, import_jsx_runtime287.jsx)("section", { className: "Layer__link-accounts Layer__component", children: /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(
@@ -32699,7 +32994,7 @@ function LinkAccountsContent({
32699
32994
  }
32700
32995
 
32701
32996
  // src/components/PlatformOnboarding/PlatformOnboarding.tsx
32702
- var import_react200 = require("react");
32997
+ var import_react201 = require("react");
32703
32998
 
32704
32999
  // src/components/ProgressSteps/ProgressSteps.tsx
32705
33000
  var import_jsx_runtime288 = require("react/jsx-runtime");
@@ -33082,7 +33377,7 @@ function useBusinessPersonnel() {
33082
33377
  // src/hooks/businessPersonnel/useCreateBusinessPersonnel.ts
33083
33378
  var import_mutation22 = __toESM(require("swr/mutation"));
33084
33379
  var import_swr30 = require("swr");
33085
- var import_react196 = require("react");
33380
+ var import_react197 = require("react");
33086
33381
  var createBusinessPersonnel = post(({ businessId }) => `/v1/businesses/${businessId}/personnel`);
33087
33382
  function buildKey34({
33088
33383
  access_token: accessToken,
@@ -33120,7 +33415,7 @@ function useCreateBusinessPersonnel() {
33120
33415
  }
33121
33416
  );
33122
33417
  const { trigger: originalTrigger } = mutationResponse;
33123
- const stableProxiedTrigger = (0, import_react196.useCallback)(
33418
+ const stableProxiedTrigger = (0, import_react197.useCallback)(
33124
33419
  (...triggerParameters) => __async(null, null, function* () {
33125
33420
  const triggerResult = yield originalTrigger(...triggerParameters);
33126
33421
  void mutate((key) => withSWRKeyTags(
@@ -33154,7 +33449,7 @@ var updateBusinessPersonnel = post(({ businessId, businessPersonnelId }) => {
33154
33449
  });
33155
33450
 
33156
33451
  // src/hooks/businessPersonnel/useUpdateBusinessPersonnel.ts
33157
- var import_react197 = require("react");
33452
+ var import_react198 = require("react");
33158
33453
  function buildKey35({
33159
33454
  access_token: accessToken,
33160
33455
  apiUrl,
@@ -33197,7 +33492,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
33197
33492
  }
33198
33493
  );
33199
33494
  const { trigger: originalTrigger } = mutationResponse;
33200
- const stableProxiedTrigger = (0, import_react197.useCallback)(
33495
+ const stableProxiedTrigger = (0, import_react198.useCallback)(
33201
33496
  (...triggerParameters) => __async(null, null, function* () {
33202
33497
  const triggerResult = yield originalTrigger(...triggerParameters);
33203
33498
  void mutate((key) => withSWRKeyTags(
@@ -33224,7 +33519,7 @@ function useUpdateBusinessPersonnel({ businessPersonnelId }) {
33224
33519
  // src/hooks/business/useUpdateBusiness.ts
33225
33520
  var import_mutation24 = __toESM(require("swr/mutation"));
33226
33521
  var import_swr32 = require("swr");
33227
- var import_react198 = require("react");
33522
+ var import_react199 = require("react");
33228
33523
  var BUSINESS_TAG_KEY = "business";
33229
33524
  function buildKey36({
33230
33525
  access_token: accessToken,
@@ -33262,7 +33557,7 @@ function useUpdateBusiness() {
33262
33557
  }
33263
33558
  );
33264
33559
  const { trigger: originalTrigger } = mutationResponse;
33265
- const stableProxiedTrigger = (0, import_react198.useCallback)(
33560
+ const stableProxiedTrigger = (0, import_react199.useCallback)(
33266
33561
  (...triggerParameters) => __async(null, null, function* () {
33267
33562
  const triggerResult = yield originalTrigger(...triggerParameters);
33268
33563
  void mutate((key) => withSWRKeyTags(
@@ -33287,7 +33582,7 @@ function useUpdateBusiness() {
33287
33582
  }
33288
33583
 
33289
33584
  // src/components/BusinessForm/useBusinessForm.ts
33290
- var import_react199 = require("react");
33585
+ var import_react200 = require("react");
33291
33586
  var getPerson = (personnel) => {
33292
33587
  const owners = personnel == null ? void 0 : personnel.filter((p) => p.roles.find((x) => x.role === "OWNER"));
33293
33588
  if (owners && owners.length > 0) {
@@ -33298,7 +33593,7 @@ var getPerson = (personnel) => {
33298
33593
  var useBusinessForm = ({ onSuccess }) => {
33299
33594
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
33300
33595
  const { business } = useLayerContext();
33301
- const [submitError, setSubmitError] = (0, import_react199.useState)(void 0);
33596
+ const [submitError, setSubmitError] = (0, import_react200.useState)(void 0);
33302
33597
  const { data: personnel } = useBusinessPersonnel();
33303
33598
  const person = getPerson(personnel);
33304
33599
  const { trigger: createBusinessPersonnel2 } = useCreateBusinessPersonnel();
@@ -33714,7 +34009,7 @@ var PLATFORM_ONBOARDING_STEPS = [
33714
34009
  }
33715
34010
  ];
33716
34011
  var PlatformOnboarding = ({ onComplete }) => {
33717
- const [step, setStep] = (0, import_react200.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
34012
+ const [step, setStep] = (0, import_react201.useState)(PLATFORM_ONBOARDING_STEPS[0].id);
33718
34013
  const isFirstStep = PLATFORM_ONBOARDING_STEPS[0].id === step;
33719
34014
  const nextStep = () => {
33720
34015
  const currentStepIndex = PLATFORM_ONBOARDING_STEPS.findIndex((s) => s.id === step);
@@ -33876,7 +34171,7 @@ var BookkeepingUpsellBar = ({
33876
34171
  };
33877
34172
 
33878
34173
  // src/views/BookkeepingOverview/BookkeepingOverview.tsx
33879
- var import_react202 = require("react");
34174
+ var import_react203 = require("react");
33880
34175
 
33881
34176
  // src/views/BookkeepingOverview/internal/BookkeepingProfitAndLossSummariesContainer.tsx
33882
34177
  var import_jsx_runtime302 = require("react/jsx-runtime");
@@ -33891,15 +34186,15 @@ function BookkeepingProfitAndLossSummariesContainer({
33891
34186
  var import_classnames82 = __toESM(require("classnames"));
33892
34187
 
33893
34188
  // src/views/BookkeepingOverview/useKeepInMobileViewport.tsx
33894
- var import_react201 = require("react");
34189
+ var import_react202 = require("react");
33895
34190
  var TASKS_MOBILE_VIEWPORT_WIDTH = 1100;
33896
34191
  var useKeepInMobileViewport = () => {
33897
- const upperContentRef = (0, import_react201.useRef)(null);
33898
- const targetElementRef = (0, import_react201.useRef)(null);
33899
- const lastKnownSizeRef = (0, import_react201.useRef)(null);
33900
- const lastKnownTargetPositionRef = (0, import_react201.useRef)(null);
33901
- const upperElementInFocus = (0, import_react201.useRef)(false);
33902
- (0, import_react201.useEffect)(() => {
34192
+ const upperContentRef = (0, import_react202.useRef)(null);
34193
+ const targetElementRef = (0, import_react202.useRef)(null);
34194
+ const lastKnownSizeRef = (0, import_react202.useRef)(null);
34195
+ const lastKnownTargetPositionRef = (0, import_react202.useRef)(null);
34196
+ const upperElementInFocus = (0, import_react202.useRef)(false);
34197
+ (0, import_react202.useEffect)(() => {
33903
34198
  if (!upperContentRef.current || !targetElementRef.current) return;
33904
34199
  lastKnownSizeRef.current = upperContentRef.current.getBoundingClientRect().height;
33905
34200
  lastKnownTargetPositionRef.current = targetElementRef.current.getBoundingClientRect().top;
@@ -33956,7 +34251,7 @@ var BookkeepingOverview = ({
33956
34251
  slotProps
33957
34252
  }) => {
33958
34253
  var _a, _b, _c, _d, _e, _f;
33959
- const [pnlToggle, setPnlToggle] = (0, import_react202.useState)("expenses");
34254
+ const [pnlToggle, setPnlToggle] = (0, import_react203.useState)("expenses");
33960
34255
  const [width] = useWindowSize();
33961
34256
  const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
33962
34257
  const { upperContentRef, targetElementRef, upperElementInFocus } = useKeepInMobileViewport();
@@ -34087,7 +34382,7 @@ var BookkeepingOverview = ({
34087
34382
  };
34088
34383
 
34089
34384
  // src/views/AccountingOverview/AccountingOverview.tsx
34090
- var import_react203 = require("react");
34385
+ var import_react204 = require("react");
34091
34386
  var import_classnames83 = __toESM(require("classnames"));
34092
34387
  var import_jsx_runtime304 = require("react/jsx-runtime");
34093
34388
  var AccountingOverview = ({
@@ -34103,7 +34398,7 @@ var AccountingOverview = ({
34103
34398
  slotProps
34104
34399
  }) => {
34105
34400
  var _a, _b, _c, _d, _e;
34106
- const [pnlToggle, setPnlToggle] = (0, import_react203.useState)("expenses");
34401
+ const [pnlToggle, setPnlToggle] = (0, import_react204.useState)("expenses");
34107
34402
  const profitAndLossSummariesVariants = (_b = (_a = slotProps == null ? void 0 : slotProps.profitAndLoss) == null ? void 0 : _a.summaries) == null ? void 0 : _b.variants;
34108
34403
  return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(
34109
34404
  ProfitAndLoss,
@@ -34274,7 +34569,7 @@ var BankTransactionsWithLinkedAccounts = ({
34274
34569
  };
34275
34570
 
34276
34571
  // src/views/GeneralLedger/GeneralLedger.tsx
34277
- var import_react204 = require("react");
34572
+ var import_react205 = require("react");
34278
34573
  var import_jsx_runtime306 = require("react/jsx-runtime");
34279
34574
  var GeneralLedgerView = ({
34280
34575
  title,
@@ -34283,7 +34578,7 @@ var GeneralLedgerView = ({
34283
34578
  stringOverrides,
34284
34579
  chartOfAccountsOptions
34285
34580
  }) => {
34286
- const [activeTab, setActiveTab] = (0, import_react204.useState)("chartOfAccounts");
34581
+ const [activeTab, setActiveTab] = (0, import_react205.useState)("chartOfAccounts");
34287
34582
  return /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ProfitAndLoss, { asContainer: false, children: /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(
34288
34583
  View,
34289
34584
  {
@@ -34325,7 +34620,7 @@ var GeneralLedgerView = ({
34325
34620
  };
34326
34621
 
34327
34622
  // src/views/ProjectProfitability/ProjectProfitability.tsx
34328
- var import_react205 = require("react");
34623
+ var import_react206 = require("react");
34329
34624
  var import_react_select6 = __toESM(require("react-select"));
34330
34625
  var import_jsx_runtime307 = require("react/jsx-runtime");
34331
34626
  var ProjectProfitabilityView = ({
@@ -34335,9 +34630,9 @@ var ProjectProfitabilityView = ({
34335
34630
  datePickerMode = "monthPicker",
34336
34631
  csvMoneyFormat = "DOLLAR_STRING"
34337
34632
  }) => {
34338
- const [activeTab, setActiveTab] = (0, import_react205.useState)("overview");
34339
- const [tagFilter, setTagFilter] = (0, import_react205.useState)(null);
34340
- const [pnlTagFilter, setPnlTagFilter] = (0, import_react205.useState)(
34633
+ const [activeTab, setActiveTab] = (0, import_react206.useState)("overview");
34634
+ const [tagFilter, setTagFilter] = (0, import_react206.useState)(null);
34635
+ const [pnlTagFilter, setPnlTagFilter] = (0, import_react206.useState)(
34341
34636
  void 0
34342
34637
  );
34343
34638
  const isOptionSelected = (option, selectValue) => {
@@ -34436,26 +34731,26 @@ var ProjectProfitabilityView = ({
34436
34731
  };
34437
34732
 
34438
34733
  // src/contexts/BillsContext.tsx
34439
- var import_react208 = require("react");
34734
+ var import_react209 = require("react");
34440
34735
 
34441
34736
  // src/hooks/useBills.tsx
34442
- var import_react206 = require("react");
34737
+ var import_react207 = require("react");
34443
34738
  var import_date_fns45 = require("date-fns");
34444
- var import_infinite5 = __toESM(require("swr/infinite"));
34739
+ var import_infinite6 = __toESM(require("swr/infinite"));
34445
34740
  var PAGE_SIZE = 20;
34446
34741
  var useBills = () => {
34447
34742
  const { businessId } = useLayerContext();
34448
34743
  const { data: auth } = useAuth();
34449
34744
  const { apiUrl } = useEnvironment();
34450
- const [status, setStatus] = (0, import_react206.useState)("UNPAID");
34451
- const [vendor, setVendor] = (0, import_react206.useState)(null);
34452
- const [billInDetails, setBillInDetails] = (0, import_react206.useState)();
34453
- const [showBillInDetails, setShowBillInDetails] = (0, import_react206.useState)(false);
34454
- const [dateRange, setDateRange] = (0, import_react206.useState)({
34745
+ const [status, setStatus] = (0, import_react207.useState)("UNPAID");
34746
+ const [vendor, setVendor] = (0, import_react207.useState)(null);
34747
+ const [billInDetails, setBillInDetails] = (0, import_react207.useState)();
34748
+ const [showBillInDetails, setShowBillInDetails] = (0, import_react207.useState)(false);
34749
+ const [dateRange, setDateRange] = (0, import_react207.useState)({
34455
34750
  startDate: (0, import_date_fns45.sub)((0, import_date_fns45.startOfMonth)(/* @__PURE__ */ new Date()), { years: 1 }),
34456
34751
  endDate: (0, import_date_fns45.endOfMonth)(/* @__PURE__ */ new Date())
34457
34752
  });
34458
- const [currentPage, setCurrentPage] = (0, import_react206.useState)(1);
34753
+ const [currentPage, setCurrentPage] = (0, import_react207.useState)(1);
34459
34754
  const openBillDetails = (bill) => {
34460
34755
  setBillInDetails(bill);
34461
34756
  setShowBillInDetails(true);
@@ -34488,7 +34783,7 @@ var useBills = () => {
34488
34783
  size,
34489
34784
  setSize,
34490
34785
  mutate
34491
- } = (0, import_infinite5.default)(
34786
+ } = (0, import_infinite6.default)(
34492
34787
  getKey,
34493
34788
  (_0) => __async(null, [_0], function* ([_query, nextCursor]) {
34494
34789
  if (auth == null ? void 0 : auth.access_token) {
@@ -34510,24 +34805,24 @@ var useBills = () => {
34510
34805
  revalidateFirstPage: false
34511
34806
  }
34512
34807
  );
34513
- const data = (0, import_react206.useMemo)(() => {
34808
+ const data = (0, import_react207.useMemo)(() => {
34514
34809
  if (rawResponseData && rawResponseData.length > 0) {
34515
34810
  return rawResponseData == null ? void 0 : rawResponseData.map((x) => x == null ? void 0 : x.data).flat().filter((x) => !!x);
34516
34811
  }
34517
34812
  return void 0;
34518
34813
  }, [rawResponseData]);
34519
- const paginatedData = (0, import_react206.useMemo)(() => {
34814
+ const paginatedData = (0, import_react207.useMemo)(() => {
34520
34815
  const firstPageIndex = (currentPage - 1) * PAGE_SIZE;
34521
34816
  const lastPageIndex = firstPageIndex + PAGE_SIZE;
34522
34817
  return data == null ? void 0 : data.slice(firstPageIndex, lastPageIndex);
34523
34818
  }, [currentPage, data]);
34524
- const lastMetadata = (0, import_react206.useMemo)(() => {
34819
+ const lastMetadata = (0, import_react207.useMemo)(() => {
34525
34820
  if (rawResponseData && rawResponseData.length > 0) {
34526
34821
  return rawResponseData[rawResponseData.length - 1].meta;
34527
34822
  }
34528
34823
  return void 0;
34529
34824
  }, [rawResponseData]);
34530
- const hasMore = (0, import_react206.useMemo)(() => {
34825
+ const hasMore = (0, import_react207.useMemo)(() => {
34531
34826
  var _a, _b, _c, _d;
34532
34827
  if (rawResponseData && rawResponseData.length > 0) {
34533
34828
  const lastElement = rawResponseData[rawResponseData.length - 1];
@@ -34572,7 +34867,7 @@ var useBills = () => {
34572
34867
  };
34573
34868
 
34574
34869
  // src/components/Bills/useBillsRecordPayment.ts
34575
- var import_react207 = require("react");
34870
+ var import_react208 = require("react");
34576
34871
  var import_mutation25 = __toESM(require("swr/mutation"));
34577
34872
  function buildKey37({
34578
34873
  access_token: accessToken,
@@ -34595,13 +34890,13 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
34595
34890
  const { data: auth } = useAuth();
34596
34891
  const { apiUrl } = useEnvironment();
34597
34892
  const { billInDetails, openBillDetails } = useBillsContext();
34598
- const [showRecordPaymentForm, setShowRecordPaymentForm] = (0, import_react207.useState)(false);
34599
- const [bulkSelectionActive, setBulkSelectionActive] = (0, import_react207.useState)(false);
34600
- const [vendor, setVendorState] = (0, import_react207.useState)();
34601
- const [paymentDate, setPaymentDate] = (0, import_react207.useState)(/* @__PURE__ */ new Date());
34602
- const [paymentMethod, setPaymentMethod] = (0, import_react207.useState)("ACH");
34603
- const [billsToPay, setBillsToPay] = (0, import_react207.useState)([]);
34604
- const [dataSaved, setDataSaved] = (0, import_react207.useState)(false);
34893
+ const [showRecordPaymentForm, setShowRecordPaymentForm] = (0, import_react208.useState)(false);
34894
+ const [bulkSelectionActive, setBulkSelectionActive] = (0, import_react208.useState)(false);
34895
+ const [vendor, setVendorState] = (0, import_react208.useState)();
34896
+ const [paymentDate, setPaymentDate] = (0, import_react208.useState)(/* @__PURE__ */ new Date());
34897
+ const [paymentMethod, setPaymentMethod] = (0, import_react208.useState)("ACH");
34898
+ const [billsToPay, setBillsToPay] = (0, import_react208.useState)([]);
34899
+ const [dataSaved, setDataSaved] = (0, import_react208.useState)(false);
34605
34900
  const openBulkSelection = () => {
34606
34901
  setBulkSelectionActive(true);
34607
34902
  };
@@ -34615,7 +34910,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
34615
34910
  setVendor(void 0);
34616
34911
  setBulkSelectionActive(false);
34617
34912
  };
34618
- (0, import_react207.useEffect)(() => {
34913
+ (0, import_react208.useEffect)(() => {
34619
34914
  if (vendor && billsToPay.length === 0) {
34620
34915
  setVendor(void 0);
34621
34916
  }
@@ -34684,7 +34979,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
34684
34979
  setBillsToPay([{ bill, amount: (_b = convertFromCents((_a = bill.outstanding_balance) != null ? _a : 0)) == null ? void 0 : _b.toString() }]);
34685
34980
  setShowRecordPaymentForm(true);
34686
34981
  };
34687
- const payload = (0, import_react207.useMemo)(() => {
34982
+ const payload = (0, import_react208.useMemo)(() => {
34688
34983
  const filteredBillsToPay = billsToPay.filter((item) => {
34689
34984
  var _a;
34690
34985
  return item.amount && ((_a = item.bill) == null ? void 0 : _a.id);
@@ -34828,7 +35123,7 @@ var useBillsRecordPayment = ({ refetchAllBills }) => {
34828
35123
  // src/contexts/BillsContext.tsx
34829
35124
  var import_date_fns46 = require("date-fns");
34830
35125
  var import_jsx_runtime308 = require("react/jsx-runtime");
34831
- var BillsContext = (0, import_react208.createContext)({
35126
+ var BillsContext = (0, import_react209.createContext)({
34832
35127
  data: [],
34833
35128
  paginatedData: [],
34834
35129
  currentPage: 1,
@@ -34859,7 +35154,7 @@ var BillsContext = (0, import_react208.createContext)({
34859
35154
  refetch: () => {
34860
35155
  }
34861
35156
  });
34862
- var BillsRecordPaymentContext = (0, import_react208.createContext)({
35157
+ var BillsRecordPaymentContext = (0, import_react209.createContext)({
34863
35158
  billsToPay: [],
34864
35159
  setBill: () => {
34865
35160
  },
@@ -34903,8 +35198,8 @@ var BillsRecordPaymentContext = (0, import_react208.createContext)({
34903
35198
  isLoading: false,
34904
35199
  apiError: void 0
34905
35200
  });
34906
- var useBillsContext = () => (0, import_react208.useContext)(BillsContext);
34907
- var useBillsRecordPaymentContext = () => (0, import_react208.useContext)(BillsRecordPaymentContext);
35201
+ var useBillsContext = () => (0, import_react209.useContext)(BillsContext);
35202
+ var useBillsRecordPaymentContext = () => (0, import_react209.useContext)(BillsRecordPaymentContext);
34908
35203
  var BillsProvider = ({ children }) => {
34909
35204
  const bills = useBills();
34910
35205
  return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BillsContext.Provider, { value: bills, children: /* @__PURE__ */ (0, import_jsx_runtime308.jsx)(BillContextWithRecordPayment, { children }) });
@@ -34916,14 +35211,14 @@ var BillContextWithRecordPayment = ({ children }) => {
34916
35211
  };
34917
35212
 
34918
35213
  // src/components/Bills/useBillForm.ts
34919
- var import_react209 = require("react");
35214
+ var import_react210 = require("react");
34920
35215
  var import_react_form5 = require("@tanstack/react-form");
34921
35216
  var useBillForm = (bill) => {
34922
35217
  var _a, _b, _c, _d;
34923
35218
  const { businessId, addToast } = useLayerContext();
34924
35219
  const { apiUrl } = useEnvironment();
34925
35220
  const { data: auth } = useAuth();
34926
- const [submitError, setSubmitError] = (0, import_react209.useState)(void 0);
35221
+ const [submitError, setSubmitError] = (0, import_react210.useState)(void 0);
34927
35222
  const { openBillDetails, refetch } = useBillsContext();
34928
35223
  const form = (0, import_react_form5.useForm)({
34929
35224
  defaultValues: {
@@ -35016,7 +35311,7 @@ var useBillForm = (bill) => {
35016
35311
  var import_date_fns49 = require("date-fns");
35017
35312
 
35018
35313
  // src/components/Bills/BillsPaymentRecorded.tsx
35019
- var import_react210 = require("react");
35314
+ var import_react211 = require("react");
35020
35315
 
35021
35316
  // src/components/Input/StaticValue.tsx
35022
35317
  var import_classnames84 = __toESM(require("classnames"));
@@ -35062,11 +35357,11 @@ var BillsPaymentRecorded = ({
35062
35357
  vendor,
35063
35358
  payRemainingBalance
35064
35359
  } = useBillsRecordPaymentContext();
35065
- const totalPaid = (0, import_react210.useMemo)(
35360
+ const totalPaid = (0, import_react211.useMemo)(
35066
35361
  () => billsToPay.reduce((acc, record) => acc + (record.amount !== void 0 ? Number(record.amount) : 0), 0),
35067
35362
  [billsToPay]
35068
35363
  );
35069
- const anyUnpaid = (0, import_react210.useMemo)(
35364
+ const anyUnpaid = (0, import_react211.useMemo)(
35070
35365
  () => billsToPay.some((record) => {
35071
35366
  var _a2;
35072
35367
  return ((_a2 = record.bill) == null ? void 0 : _a2.status) !== "PAID";
@@ -35123,7 +35418,7 @@ var BillsPaymentRecorded = ({
35123
35418
  };
35124
35419
 
35125
35420
  // src/components/Bills/BillsRecordPayment.tsx
35126
- var import_react211 = require("react");
35421
+ var import_react212 = require("react");
35127
35422
  var import_date_fns47 = require("date-fns");
35128
35423
 
35129
35424
  // src/components/Bills/useUnpaidBillsByVendor.ts
@@ -35206,7 +35501,7 @@ var BillsRecordPayment = ({
35206
35501
  apiError
35207
35502
  } = useBillsRecordPaymentContext();
35208
35503
  const { data: rawAvailableBills } = useUnpaidBillsByVendor({ vendorId: vendor == null ? void 0 : vendor.id });
35209
- const availableBills = (0, import_react211.useMemo)(
35504
+ const availableBills = (0, import_react212.useMemo)(
35210
35505
  () => rawAvailableBills == null ? void 0 : rawAvailableBills.filter((b) => !billsToPay.find((x) => {
35211
35506
  var _a2;
35212
35507
  return ((_a2 = x.bill) == null ? void 0 : _a2.id) === b.id;
@@ -35398,7 +35693,7 @@ var BillsSidebar = () => {
35398
35693
  };
35399
35694
 
35400
35695
  // src/contexts/VendorsContext.tsx
35401
- var import_react212 = require("react");
35696
+ var import_react213 = require("react");
35402
35697
 
35403
35698
  // src/hooks/useVendors.ts
35404
35699
  var import_swr34 = __toESM(require("swr"));
@@ -35423,10 +35718,10 @@ var useVendors = () => {
35423
35718
 
35424
35719
  // src/contexts/VendorsContext.tsx
35425
35720
  var import_jsx_runtime313 = require("react/jsx-runtime");
35426
- var VendorsContext = (0, import_react212.createContext)({
35721
+ var VendorsContext = (0, import_react213.createContext)({
35427
35722
  data: []
35428
35723
  });
35429
- var useVendorsContext = () => (0, import_react212.useContext)(VendorsContext);
35724
+ var useVendorsContext = () => (0, import_react213.useContext)(VendorsContext);
35430
35725
  var VendorsProvider = ({ children }) => {
35431
35726
  const vendors = useVendors();
35432
35727
  return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(VendorsContext.Provider, { value: vendors, children });
@@ -35532,7 +35827,7 @@ var BillSummaryPaid = ({ bill }) => {
35532
35827
  };
35533
35828
 
35534
35829
  // src/components/Bills/BillSummaryUnpaid.tsx
35535
- var import_react213 = require("react");
35830
+ var import_react214 = require("react");
35536
35831
  var import_date_fns48 = require("date-fns");
35537
35832
  var import_jsx_runtime316 = require("react/jsx-runtime");
35538
35833
  function buildDifference(due_at) {
@@ -35560,7 +35855,7 @@ function buildDifference(due_at) {
35560
35855
  };
35561
35856
  }
35562
35857
  var BillSummaryUnpaid = ({ bill }) => {
35563
- const difference = (0, import_react213.useMemo)(() => buildDifference(bill.due_at), [bill.due_at]);
35858
+ const difference = (0, import_react214.useMemo)(() => buildDifference(bill.due_at), [bill.due_at]);
35564
35859
  return /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)("div", { className: "Layer__bill-details__summary", children: [
35565
35860
  /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)("div", { children: [
35566
35861
  /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(
@@ -35953,13 +36248,13 @@ var BillsDetails = ({
35953
36248
  };
35954
36249
 
35955
36250
  // src/components/Bills/BillsTableWithPanel.tsx
35956
- var import_react216 = require("react");
36251
+ var import_react217 = require("react");
35957
36252
 
35958
36253
  // src/components/Bills/BillsTable.tsx
35959
- var import_react215 = require("react");
36254
+ var import_react216 = require("react");
35960
36255
 
35961
36256
  // src/components/DueStatus/DueStatus.tsx
35962
- var import_react214 = require("react");
36257
+ var import_react215 = require("react");
35963
36258
  var import_date_fns50 = require("date-fns");
35964
36259
  var import_jsx_runtime319 = require("react/jsx-runtime");
35965
36260
  var dueStatusTitle = (daysDiff, paid) => {
@@ -36024,7 +36319,7 @@ var getDiff = (refDate) => {
36024
36319
  return (0, import_date_fns50.differenceInDays)(today, d);
36025
36320
  };
36026
36321
  var DueStatus = ({ dueDate, paidAt, size = "md" }) => {
36027
- const date = (0, import_react214.useMemo)(() => {
36322
+ const date = (0, import_react215.useMemo)(() => {
36028
36323
  try {
36029
36324
  const diff = getDiff(paidAt ? paidAt : dueDate);
36030
36325
  if (diff === null) {
@@ -36120,7 +36415,7 @@ var BillsTableContent = ({
36120
36415
  "Layer__bills-table__actions-col",
36121
36416
  status === "PAID" ? "Layer__bills-table__actions-col--narrow" : ""
36122
36417
  );
36123
- return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_react215.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(TableRow, { rowKey: rowKey + "-" + index, variant: "main", children: [
36418
+ return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_react216.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(TableRow, { rowKey: rowKey + "-" + index, variant: "main", children: [
36124
36419
  /* @__PURE__ */ (0, import_jsx_runtime321.jsxs)(TableCell, { primary: true, nowrap: true, className: "Layer__bills-table__vendor-col", children: [
36125
36420
  bulkSelectionActive && status === "UNPAID" && /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(
36126
36421
  CheckboxWithTooltip,
@@ -36352,11 +36647,11 @@ var BillsTableWithPanel = ({
36352
36647
  setVendor: setRecordPaymentVendor
36353
36648
  } = useBillsRecordPaymentContext();
36354
36649
  const { isDesktop, isMobile } = useSizeClass();
36355
- const totalCount = (0, import_react216.useMemo)(() => {
36650
+ const totalCount = (0, import_react217.useMemo)(() => {
36356
36651
  var _a;
36357
36652
  return (_a = rawData == null ? void 0 : rawData.length) != null ? _a : 0;
36358
36653
  }, [rawData]);
36359
- const anyBillToPaySelected = (0, import_react216.useMemo)(() => {
36654
+ const anyBillToPaySelected = (0, import_react217.useMemo)(() => {
36360
36655
  return billsToPay.length > 0;
36361
36656
  }, [billsToPay]);
36362
36657
  return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(
@@ -36550,7 +36845,7 @@ var BillsViewContent = ({
36550
36845
  };
36551
36846
 
36552
36847
  // src/views/Reports/Reports.tsx
36553
- var import_react217 = require("react");
36848
+ var import_react218 = require("react");
36554
36849
  var import_jsx_runtime327 = require("react/jsx-runtime");
36555
36850
  var getOptions = (enabledReports) => {
36556
36851
  return [
@@ -36578,7 +36873,7 @@ var Reports = ({
36578
36873
  statementOfCashFlowConfig
36579
36874
  }) => {
36580
36875
  var _a;
36581
- const [activeTab, setActiveTab] = (0, import_react217.useState)(enabledReports[0]);
36876
+ const [activeTab, setActiveTab] = (0, import_react218.useState)(enabledReports[0]);
36582
36877
  const { view, containerRef } = useElementViewSize();
36583
36878
  const options = getOptions(enabledReports);
36584
36879
  const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value = enabledReports[0])) == null ? void 0 : _a.label;
@@ -36637,11 +36932,11 @@ var ReportsPanel = ({
36637
36932
  };
36638
36933
 
36639
36934
  // src/components/ProfitAndLossView/ProfitAndLossView.tsx
36640
- var import_react218 = require("react");
36935
+ var import_react219 = require("react");
36641
36936
  var import_jsx_runtime328 = require("react/jsx-runtime");
36642
36937
  var COMPONENT_NAME9 = "profit-and-loss";
36643
36938
  var ProfitAndLossView = (props) => {
36644
- const containerRef = (0, import_react218.useRef)(null);
36939
+ const containerRef = (0, import_react219.useRef)(null);
36645
36940
  return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(Container, { name: COMPONENT_NAME9, ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(ProfitAndLoss, { children: /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(ProfitAndLossPanel, __spreadValues({ containerRef }, props)) }) });
36646
36941
  };
36647
36942
  var ProfitAndLossPanel = (_a) => {
@@ -36652,7 +36947,7 @@ var ProfitAndLossPanel = (_a) => {
36652
36947
  "containerRef",
36653
36948
  "stringOverrides"
36654
36949
  ]);
36655
- const { sidebarScope } = (0, import_react218.useContext)(ProfitAndLoss.Context);
36950
+ const { sidebarScope } = (0, import_react219.useContext)(ProfitAndLoss.Context);
36656
36951
  return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(
36657
36952
  Panel,
36658
36953
  {
@@ -36683,7 +36978,7 @@ var Components = ({
36683
36978
  hideTable = false,
36684
36979
  stringOverrides
36685
36980
  }) => {
36686
- const { error, isLoading, isValidating, refetch } = (0, import_react218.useContext)(
36981
+ const { error, isLoading, isValidating, refetch } = (0, import_react219.useContext)(
36687
36982
  ProfitAndLoss.Context
36688
36983
  );
36689
36984
  if (!isLoading && error) {