@layerfi/components 0.1.136 → 0.1.137-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,7 +27,7 @@ import { Text } from "react-aria-components/Text";
27
27
  import { mergeRefs } from "react-merge-refs";
28
28
  import useResizeObserver from "@react-hook/resize-observer";
29
29
  import { Button } from "react-aria-components/Button";
30
- import { AlertCircle, AlertTriangle, Archive, ArchiveRestore, ArrowRight, ArrowUpRight, Briefcase, Car, Check, CheckCircle, CheckIcon, ChevronDown, ChevronLeft, ChevronRight, Circle, Clock, Clock3, CopyIcon, Download, Edit, ExternalLink, FileDownIcon, FileSpreadsheet, FileText, Filter, HandCoins, Hourglass, Info, Layers2Icon, List, LoaderCircle, Lock, Menu, MenuIcon, Minus, PencilRuler, Play, Plus, RefreshCcw, RotateCcw, Save, Search, SearchX, Trash, Trash2, TriangleAlert, UploadCloud, UserRoundPen, Video, X, XCircle, XIcon } from "lucide-react";
30
+ import { AlertCircle, AlertTriangle, Archive, ArchiveRestore, ArrowRight, ArrowUpRight, Briefcase, Car, Check, CheckCircle, CheckIcon, ChevronDown, ChevronLeft, ChevronRight, Circle, Clock, Clock3, CopyIcon, Download, Edit, ExternalLink, FileDownIcon, FileSpreadsheet, FileText, Filter, HandCoins, Hourglass, Info, Layers2Icon, List, LoaderCircle, Lock, Menu, MenuIcon, Minus, Pencil, PencilRuler, Play, Plus, RefreshCcw, RotateCcw, Save, Search, SearchX, Trash, Trash2, TriangleAlert, UploadCloud, UserRoundPen, Video, X, XCircle, XIcon } from "lucide-react";
31
31
  import { DurationFormat } from "@formatjs/intl-durationformat";
32
32
  import { Dialog, DialogTrigger } from "react-aria-components/Dialog";
33
33
  import { Modal, ModalOverlay } from "react-aria-components/Modal";
@@ -256,7 +256,7 @@ var getIntlLocale = (locale) => {
256
256
  };
257
257
  var package_default = {
258
258
  name: "@layerfi/components",
259
- version: "0.1.136",
259
+ version: "0.1.137-alpha",
260
260
  description: "Layer React Components",
261
261
  main: "dist/cjs/index.cjs",
262
262
  module: "dist/esm/index.mjs",
@@ -701,7 +701,7 @@ function _requestOAuthToken() {
701
701
  return _requestOAuthToken.apply(this, arguments);
702
702
  }
703
703
  var AUTH_TAG_KEY = "#auth";
704
- function buildKey$90({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }) {
704
+ function buildKey$91({ appId, appSecret, businessAccessToken, apiUrl, authUrl, scope }) {
705
705
  if (businessAccessToken) return {
706
706
  apiUrl,
707
707
  businessAccessToken,
@@ -724,7 +724,7 @@ var FALLBACK_REFRESH_MS = DEFAULT_EXPIRES_IN_SECONDS / 2 * 1e3;
724
724
  function useAuth() {
725
725
  const { apiUrl, authUrl, scope } = useEnvironment();
726
726
  const { appId, appSecret, businessAccessToken } = useAuthInput();
727
- return useSWR(() => buildKey$90({
727
+ return useSWR(() => buildKey$91({
728
728
  appId,
729
729
  appSecret,
730
730
  businessAccessToken,
@@ -772,7 +772,7 @@ var useLayerContext = () => {
772
772
  var BANK_ACCOUNTS_TAG_KEY = "#bank-accounts";
773
773
  var requiresNotification = (bankAccount) => bankAccount.is_disconnected && bankAccount.notify_when_disconnected;
774
774
  var listBankAccounts = get(({ businessId }) => `/v1/businesses/${businessId}/bank-accounts`);
775
- function buildKey$89({ access_token: accessToken, apiUrl, businessId }) {
775
+ function buildKey$90({ access_token: accessToken, apiUrl, businessId }) {
776
776
  if (accessToken && apiUrl) return {
777
777
  accessToken,
778
778
  apiUrl,
@@ -793,7 +793,7 @@ function useListBankAccounts() {
793
793
  const { businessId } = useLayerContext();
794
794
  const { apiUrl } = useEnvironment();
795
795
  const { data: auth } = useAuth();
796
- return new ListBankAccountsSWRResponse(useSWR(() => buildKey$89(_objectSpread2(_objectSpread2({}, auth), {}, {
796
+ return new ListBankAccountsSWRResponse(useSWR(() => buildKey$90(_objectSpread2(_objectSpread2({}, auth), {}, {
797
797
  apiUrl,
798
798
  businessId
799
799
  })), ({ accessToken, apiUrl, businessId }) => listBankAccounts(apiUrl, accessToken, { params: { businessId } })().then(({ data }) => data)));
@@ -3795,7 +3795,7 @@ var useLocalizedKey = () => {
3795
3795
  var _excluded$119 = ["trigger"];
3796
3796
  var UNLINK_BANK_ACCOUNT_TAG_KEY = "#unlink-bank-account";
3797
3797
  var unlinkBankAccount = del(({ businessId, bankAccountId }) => `/v1/businesses/${businessId}/bank-accounts/${bankAccountId}`);
3798
- function buildKey$88({ access_token: accessToken, apiUrl, businessId }) {
3798
+ function buildKey$89({ access_token: accessToken, apiUrl, businessId }) {
3799
3799
  if (accessToken && apiUrl) return {
3800
3800
  accessToken,
3801
3801
  apiUrl,
@@ -3808,7 +3808,7 @@ function useUnlinkBankAccount() {
3808
3808
  const { businessId } = useLayerContext();
3809
3809
  const { apiUrl } = useEnvironment();
3810
3810
  const { data: auth } = useAuth();
3811
- const _useSWRMutation = useSWRMutation(() => withLocale(buildKey$88({
3811
+ const _useSWRMutation = useSWRMutation(() => withLocale(buildKey$89({
3812
3812
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
3813
3813
  apiUrl,
3814
3814
  businessId
@@ -4005,7 +4005,7 @@ var BankTransactionsSWRResponse = class extends SWRInfiniteResult {
4005
4005
  return this.data && this.data.length > 0 ? this.data[this.data.length - 1].meta.pagination.has_more : false;
4006
4006
  }
4007
4007
  };
4008
- function keyLoader$10(previousPageData, { access_token: accessToken, apiUrl, businessId, categorized, direction, query, startDate, endDate, tagFilterQueryString }) {
4008
+ function keyLoader$11(previousPageData, { access_token: accessToken, apiUrl, businessId, categorized, direction, query, startDate, endDate, tagFilterQueryString }) {
4009
4009
  if (accessToken && apiUrl) return {
4010
4010
  accessToken,
4011
4011
  apiUrl,
@@ -4024,7 +4024,7 @@ function useBankTransactions({ categorized, direction, query, startDate, endDate
4024
4024
  const withLocale = useLocalizedKey();
4025
4025
  const { data } = useAuth();
4026
4026
  const { businessId } = useLayerContext();
4027
- const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$10(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
4027
+ const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$11(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
4028
4028
  businessId,
4029
4029
  categorized,
4030
4030
  direction,
@@ -5414,24 +5414,24 @@ var BankTransactionType = /* @__PURE__ */ function(BankTransactionType) {
5414
5414
  var BankTransactionTypeSchema = Schema$1.Enums(BankTransactionType);
5415
5415
  var CreateCategorizationRuleSchema = Schema$1.Struct({
5416
5416
  applyRetroactively: pipe$1(Schema$1.optional(Schema$1.Boolean), Schema$1.fromKey("apply_retroactively")),
5417
- createdBySuggestionId: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("created_by_suggestion_id")),
5418
- externalId: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("external_id")),
5419
- name: Schema$1.NullishOr(Schema$1.String),
5420
- category: Schema$1.NullishOr(AccountIdentifierSchema),
5421
- suggestion1: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_1")),
5422
- suggestion2: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_2")),
5423
- suggestion3: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_3")),
5424
- businessNameFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("business_name_filter")),
5425
- clientNameFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("client_name_filter")),
5426
- merchantTypeFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("merchant_type_filter")),
5427
- transactionDescriptionFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_description_filter")),
5428
- transactionTypeFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_type_filter")),
5429
- bankDirectionFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(BankDirectionFilterSchema)), Schema$1.fromKey("bank_direction_filter")),
5430
- amountMinFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_min_filter")),
5431
- amountMaxFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_max_filter")),
5432
- counterpartyFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.UUID)), Schema$1.fromKey("counterparty_filter")),
5433
- bankTransactionTypeFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(BankTransactionTypeSchema)), Schema$1.fromKey("bank_transaction_type_filter")),
5434
- mccFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("mcc_filter"))
5417
+ createdBySuggestionId: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("created_by_suggestion_id")),
5418
+ externalId: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("external_id")),
5419
+ name: Schema$1.optional(Schema$1.NullishOr(Schema$1.String)),
5420
+ category: Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)),
5421
+ suggestion1: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_1")),
5422
+ suggestion2: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_2")),
5423
+ suggestion3: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_3")),
5424
+ businessNameFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("business_name_filter")),
5425
+ clientNameFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("client_name_filter")),
5426
+ merchantTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("merchant_type_filter")),
5427
+ transactionDescriptionFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_description_filter")),
5428
+ transactionTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_type_filter")),
5429
+ bankDirectionFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(BankDirectionFilterSchema)), Schema$1.fromKey("bank_direction_filter")),
5430
+ amountMinFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_min_filter")),
5431
+ amountMaxFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_max_filter")),
5432
+ counterpartyFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.UUID)), Schema$1.fromKey("counterparty_filter")),
5433
+ bankTransactionTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(BankTransactionTypeSchema)), Schema$1.fromKey("bank_transaction_type_filter")),
5434
+ mccFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("mcc_filter"))
5435
5435
  });
5436
5436
  var CreateCategorizationRuleForCounterpartySchema = Schema$1.Struct({
5437
5437
  type: Schema$1.Literal("Create_Categorization_Rule_For_Counterparty"),
@@ -5440,6 +5440,25 @@ var CreateCategorizationRuleForCounterpartySchema = Schema$1.Struct({
5440
5440
  suggestionPrompt: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("suggestion_prompt")),
5441
5441
  transactionsThatWillBeAffected: pipe$1(Schema$1.propertySignature(Schema$1.Array(MinimalBankTransactionSchema)), Schema$1.fromKey("transactions_that_will_be_affected"))
5442
5442
  });
5443
+ var PatchCategorizationRuleSchema = Schema$1.Struct({
5444
+ externalId: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("external_id")),
5445
+ name: Schema$1.optional(Schema$1.NullishOr(Schema$1.String)),
5446
+ category: Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)),
5447
+ suggestion1: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_1")),
5448
+ suggestion2: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_2")),
5449
+ suggestion3: pipe$1(Schema$1.optional(Schema$1.NullishOr(AccountIdentifierSchema)), Schema$1.fromKey("suggestion_3")),
5450
+ businessNameFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("business_name_filter")),
5451
+ clientNameFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("client_name_filter")),
5452
+ merchantTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("merchant_type_filter")),
5453
+ transactionDescriptionFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_description_filter")),
5454
+ transactionTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("transaction_type_filter")),
5455
+ bankDirectionFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(BankDirectionFilterSchema)), Schema$1.fromKey("bank_direction_filter")),
5456
+ amountMinFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_min_filter")),
5457
+ amountMaxFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_max_filter")),
5458
+ counterpartyFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.UUID)), Schema$1.fromKey("counterparty_filter")),
5459
+ bankTransactionTypeFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(BankTransactionTypeSchema)), Schema$1.fromKey("bank_transaction_type_filter")),
5460
+ mccFilter: pipe$1(Schema$1.optional(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("mcc_filter"))
5461
+ });
5443
5462
  var CategorizationRuleSchema = Schema$1.Struct({
5444
5463
  id: Schema$1.String,
5445
5464
  businessId: pipe$1(Schema$1.propertySignature(Schema$1.String), Schema$1.fromKey("business_id")),
@@ -5451,6 +5470,8 @@ var CategorizationRuleSchema = Schema$1.Struct({
5451
5470
  counterpartyFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(BankTransactionCounterpartySchema)), Schema$1.fromKey("counterparty_filter")),
5452
5471
  readableTransactionDescriptionFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.String)), Schema$1.fromKey("readable_transaction_description_filter")),
5453
5472
  bankDirectionFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(BankDirectionFilterSchema)), Schema$1.fromKey("bank_direction_filter")),
5473
+ amountMinFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_min_filter")),
5474
+ amountMaxFilter: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.Number)), Schema$1.fromKey("amount_max_filter")),
5454
5475
  createdAt: pipe$1(Schema$1.propertySignature(Schema$1.Date), Schema$1.fromKey("created_at")),
5455
5476
  updatedAt: pipe$1(Schema$1.propertySignature(Schema$1.Date), Schema$1.fromKey("updated_at")),
5456
5477
  archivedAt: pipe$1(Schema$1.propertySignature(Schema$1.NullishOr(Schema$1.Date)), Schema$1.fromKey("archived_at"))
@@ -6172,7 +6193,7 @@ var getBookkeepingStatus = get(({ businessId }) => {
6172
6193
  });
6173
6194
  var BOOKKEEPING_TAG_KEY = "#bookkeeping";
6174
6195
  var BOOKKEEPING_STATUS_TAG_KEY = "#bookkeeping-status";
6175
- function buildKey$87({ access_token: accessToken, apiUrl, businessId }) {
6196
+ function buildKey$88({ access_token: accessToken, apiUrl, businessId }) {
6176
6197
  if (accessToken && apiUrl) return {
6177
6198
  accessToken,
6178
6199
  apiUrl,
@@ -6183,7 +6204,7 @@ function buildKey$87({ access_token: accessToken, apiUrl, businessId }) {
6183
6204
  function useBookkeepingStatus() {
6184
6205
  const { data: auth } = useAuth();
6185
6206
  const { businessId } = useLayerContext();
6186
- return useSWR(() => buildKey$87(_objectSpread2(_objectSpread2({}, auth), {}, { businessId })), ({ accessToken, apiUrl, businessId }) => getBookkeepingStatus(apiUrl, accessToken, { params: { businessId } })().then(Schema.decodeUnknownPromise(BookkeepingStatusResponseSchema)).then(({ data }) => data));
6207
+ return useSWR(() => buildKey$88(_objectSpread2(_objectSpread2({}, auth), {}, { businessId })), ({ accessToken, apiUrl, businessId }) => getBookkeepingStatus(apiUrl, accessToken, { params: { businessId } })().then(Schema.decodeUnknownPromise(BookkeepingStatusResponseSchema)).then(({ data }) => data));
6187
6208
  }
6188
6209
  function useBookkeepingStatusGlobalCacheActions() {
6189
6210
  const { forceReload } = useGlobalCacheActions();
@@ -7402,7 +7423,7 @@ var BREAKPOINTS = {
7402
7423
  //#endregion
7403
7424
  //#region src/hooks/api/businesses/[business-id]/categories/useCategories.ts
7404
7425
  var CATEGORIES_TAG_KEY = "#categories";
7405
- function buildKey$86({ access_token: accessToken, apiUrl, businessId, mode }) {
7426
+ function buildKey$87({ access_token: accessToken, apiUrl, businessId, mode }) {
7406
7427
  if (accessToken && apiUrl) return {
7407
7428
  accessToken,
7408
7429
  apiUrl,
@@ -7418,7 +7439,7 @@ function useCategories({ mode } = {}) {
7418
7439
  const withLocale = useLocalizedKey();
7419
7440
  const { data: auth } = useAuth();
7420
7441
  const { businessId } = useLayerContext();
7421
- return useSWR(() => withLocale(buildKey$86(_objectSpread2(_objectSpread2({}, auth), {}, {
7442
+ return useSWR(() => withLocale(buildKey$87(_objectSpread2(_objectSpread2({}, auth), {}, {
7422
7443
  businessId,
7423
7444
  mode
7424
7445
  }))), ({ accessToken, apiUrl, businessId, mode }) => getCategories(apiUrl, accessToken, { params: {
@@ -7471,7 +7492,7 @@ var listCustomers = get(({ businessId, cursor, limit, query }) => {
7471
7492
  })}`;
7472
7493
  });
7473
7494
  var CUSTOMERS_TAG_KEY = "#customers";
7474
- function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
7495
+ function keyLoader$10(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
7475
7496
  if (!isEnabled) return;
7476
7497
  if (accessToken && apiUrl) {
7477
7498
  var _previousPageData$met;
@@ -7494,7 +7515,7 @@ function useListCustomers({ query, isEnabled = true } = {}) {
7494
7515
  const withLocale = useLocalizedKey();
7495
7516
  const { data } = useAuth();
7496
7517
  const { businessId } = useLayerContext();
7497
- const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$9(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7518
+ const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$10(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7498
7519
  businessId,
7499
7520
  query,
7500
7521
  isEnabled
@@ -7528,7 +7549,7 @@ function useCustomersGlobalCacheActions() {
7528
7549
  //#endregion
7529
7550
  //#region src/hooks/api/businesses/[business-id]/tags/dimensions/useTagDimensions.ts
7530
7551
  var TAG_DIMENSIONS_TAG_KEY = "#tag-dimensions";
7531
- function buildKey$85({ access_token: accessToken, apiUrl, businessId, isEnabled }) {
7552
+ function buildKey$86({ access_token: accessToken, apiUrl, businessId, isEnabled }) {
7532
7553
  if (!isEnabled) return;
7533
7554
  if (accessToken && apiUrl) return {
7534
7555
  accessToken,
@@ -7544,7 +7565,7 @@ function useTagDimensions({ isEnabled = true } = {}) {
7544
7565
  const { data: auth } = useAuth();
7545
7566
  const { apiUrl } = useEnvironment();
7546
7567
  const { businessId } = useLayerContext();
7547
- return new SWRQueryResult(useSWR(() => withLocale(buildKey$85(_objectSpread2(_objectSpread2({}, auth), {}, {
7568
+ return new SWRQueryResult(useSWR(() => withLocale(buildKey$86(_objectSpread2(_objectSpread2({}, auth), {}, {
7548
7569
  apiUrl,
7549
7570
  businessId,
7550
7571
  isEnabled
@@ -7568,7 +7589,7 @@ var listVendors = get(({ businessId, cursor, limit, query }) => {
7568
7589
  })}`;
7569
7590
  });
7570
7591
  var VENDORS_TAG_KEY = "#vendors";
7571
- function keyLoader$8(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
7592
+ function keyLoader$9(previousPageData, { access_token: accessToken, apiUrl, businessId, query, isEnabled }) {
7572
7593
  if (!isEnabled) return;
7573
7594
  if (accessToken && apiUrl) {
7574
7595
  var _previousPageData$met;
@@ -7586,7 +7607,7 @@ function useListVendors({ query, isEnabled = true } = {}) {
7586
7607
  const withLocale = useLocalizedKey();
7587
7608
  const { data } = useAuth();
7588
7609
  const { businessId } = useLayerContext();
7589
- const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$8(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7610
+ const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$9(previousPageData, _objectSpread2(_objectSpread2({}, data), {}, {
7590
7611
  businessId,
7591
7612
  query,
7592
7613
  isEnabled
@@ -7947,7 +7968,7 @@ var getBankTransactionsExcel = get(({ businessId, categorized, direction, query,
7947
7968
  sortOrder
7948
7969
  })}`;
7949
7970
  });
7950
- function buildKey$84({ access_token: accessToken, apiUrl, businessId }) {
7971
+ function buildKey$85({ access_token: accessToken, apiUrl, businessId }) {
7951
7972
  if (accessToken && apiUrl) return {
7952
7973
  accessToken,
7953
7974
  apiUrl,
@@ -7959,7 +7980,7 @@ function useBankTransactionsDownload() {
7959
7980
  const withLocale = useLocalizedKey();
7960
7981
  const { data } = useAuth();
7961
7982
  const { businessId } = useLayerContext();
7962
- return useSWRMutation(() => withLocale(buildKey$84(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { categorized, direction, query, startDate, endDate, tagFilterQueryString } }) => getBankTransactionsExcel(apiUrl, accessToken, { params: {
7983
+ return useSWRMutation(() => withLocale(buildKey$85(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { categorized, direction, query, startDate, endDate, tagFilterQueryString } }) => getBankTransactionsExcel(apiUrl, accessToken, { params: {
7963
7984
  businessId,
7964
7985
  categorized,
7965
7986
  query,
@@ -9075,7 +9096,7 @@ var ProfitAndLossReportSchema = Schema.Struct({
9075
9096
  //#endregion
9076
9097
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss/lines/useProfitAndLossDetailLines.tsx
9077
9098
  var LIST_PNL_DETAIL_LINES_TAG_KEY = "#list-pnl-detail-lines";
9078
- function keyLoader$7({ access_token: accessToken, apiUrl, businessId, startDate, endDate, pnlStructureLineItemName, tagFilter, reportingBasis, pnlStructure }) {
9099
+ function keyLoader$8({ access_token: accessToken, apiUrl, businessId, startDate, endDate, pnlStructureLineItemName, tagFilter, reportingBasis, pnlStructure }) {
9079
9100
  if (accessToken && apiUrl && businessId && startDate && endDate && pnlStructureLineItemName) return {
9080
9101
  accessToken,
9081
9102
  apiUrl,
@@ -9095,7 +9116,7 @@ function useProfitAndLossDetailLines({ startDate, endDate, pnlStructureLineItemN
9095
9116
  const { businessId } = useLayerContext();
9096
9117
  const { apiUrl } = useEnvironment();
9097
9118
  const { data: auth } = useAuth();
9098
- return new SWRQueryResult(useSWR(() => withLocale(keyLoader$7(_objectSpread2(_objectSpread2({}, auth), {}, {
9119
+ return new SWRQueryResult(useSWR(() => withLocale(keyLoader$8(_objectSpread2(_objectSpread2({}, auth), {}, {
9099
9120
  apiUrl,
9100
9121
  businessId,
9101
9122
  startDate,
@@ -9138,7 +9159,7 @@ var getProfitAndLossDetailLines = (apiUrl, accessToken, params) => {
9138
9159
  //#endregion
9139
9160
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss/useProfitAndLossReport.tsx
9140
9161
  var PNL_REPORT_TAG_KEY = "#profit-and-loss-report";
9141
- function buildKey$83({ access_token: accessToken, apiUrl, businessId, startDate, endDate, tagKey, tagValues, reportingBasis, includeUncategorized }) {
9162
+ function buildKey$84({ access_token: accessToken, apiUrl, businessId, startDate, endDate, tagKey, tagValues, reportingBasis, includeUncategorized }) {
9142
9163
  if (accessToken && apiUrl) return {
9143
9164
  accessToken,
9144
9165
  apiUrl,
@@ -9166,7 +9187,7 @@ function useProfitAndLossReport({ startDate, endDate, tagKey, tagValues, reporti
9166
9187
  const withLocale = useLocalizedKey();
9167
9188
  const { data } = useAuth();
9168
9189
  const { businessId } = useLayerContext();
9169
- return new SWRQueryResult(useSWR(() => withLocale(buildKey$83(_objectSpread2(_objectSpread2({}, data), {}, {
9190
+ return new SWRQueryResult(useSWR(() => withLocale(buildKey$84(_objectSpread2(_objectSpread2({}, data), {}, {
9170
9191
  businessId,
9171
9192
  startDate,
9172
9193
  endDate,
@@ -9191,7 +9212,7 @@ var useProfitAndLossReportCacheActions = () => {
9191
9212
  //#endregion
9192
9213
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss-comparison/useProfitAndLossComparisonReport.tsx
9193
9214
  var PNL_COMPARISON_REPORT_TAG_KEY = "#profit-and-loss-comparison-report";
9194
- function buildKey$82({ access_token: accessToken, apiUrl, businessId, periods, tagFilters, reportingBasis }) {
9215
+ function buildKey$83({ access_token: accessToken, apiUrl, businessId, periods, tagFilters, reportingBasis }) {
9195
9216
  if (accessToken && apiUrl && periods) return {
9196
9217
  accessToken,
9197
9218
  apiUrl,
@@ -9208,7 +9229,7 @@ function useProfitAndLossComparisonReport({ periods, tagFilters, reportingBasis
9208
9229
  const { data } = useAuth();
9209
9230
  const { businessId } = useLayerContext();
9210
9231
  const { apiUrl } = useEnvironment();
9211
- return new SWRQueryResult(useSWR(() => withLocale(buildKey$82(_objectSpread2(_objectSpread2({}, data), {}, {
9232
+ return new SWRQueryResult(useSWR(() => withLocale(buildKey$83(_objectSpread2(_objectSpread2({}, data), {}, {
9212
9233
  apiUrl,
9213
9234
  businessId,
9214
9235
  periods,
@@ -9230,7 +9251,7 @@ var useProfitAndLossComparisonReportCacheActions = () => {
9230
9251
  //#endregion
9231
9252
  //#region src/hooks/api/businesses/[business-id]/reports/profit-and-loss-summaries/useProfitAndLossSummaries.tsx
9232
9253
  var PNL_SUMMARIES_TAG_KEY = "#profit-and-loss-summaries";
9233
- function buildKey$81({ access_token: accessToken, apiUrl, businessId, startMonth, startYear, endMonth, endYear, tagKey, tagValues, reportingBasis }) {
9254
+ function buildKey$82({ access_token: accessToken, apiUrl, businessId, startMonth, startYear, endMonth, endYear, tagKey, tagValues, reportingBasis }) {
9234
9255
  if (accessToken && apiUrl) return {
9235
9256
  accessToken,
9236
9257
  apiUrl,
@@ -9260,7 +9281,7 @@ function useProfitAndLossSummaries({ startYear, startMonth, endYear, endMonth, t
9260
9281
  const withLocale = useLocalizedKey();
9261
9282
  const { data } = useAuth();
9262
9283
  const { businessId } = useLayerContext();
9263
- return new SWRQueryResult(useSWR(() => withLocale(buildKey$81(_objectSpread2(_objectSpread2({}, data), {}, {
9284
+ return new SWRQueryResult(useSWR(() => withLocale(buildKey$82(_objectSpread2(_objectSpread2({}, data), {}, {
9264
9285
  businessId,
9265
9286
  startYear,
9266
9287
  startMonth,
@@ -9323,7 +9344,7 @@ var CategorizeTransactionRequestSchema$1 = Schema.Struct({
9323
9344
  });
9324
9345
  var BulkCategorizeRequestSchema = Schema.Struct({ transactions: Schema.Array(CategorizeTransactionRequestSchema$1) });
9325
9346
  var bulkCategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-categorize`);
9326
- function buildKey$80({ access_token: accessToken, apiUrl, businessId }) {
9347
+ function buildKey$81({ access_token: accessToken, apiUrl, businessId }) {
9327
9348
  if (accessToken && apiUrl) return {
9328
9349
  accessToken,
9329
9350
  apiUrl,
@@ -9337,7 +9358,7 @@ var useBulkCategorize = () => {
9337
9358
  const { businessId, eventCallbacks } = useLayerContext();
9338
9359
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
9339
9360
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
9340
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$80(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkCategorize(apiUrl, accessToken, {
9361
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$81(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkCategorize(apiUrl, accessToken, {
9341
9362
  params: { businessId },
9342
9363
  body: Schema.encodeSync(BulkCategorizeRequestSchema)(arg)
9343
9364
  }).then(({ data }) => data), {
@@ -10453,7 +10474,7 @@ function useComboBoxSubcomponents({ placeholder, slots, displayDisabledAsSelecte
10453
10474
  }
10454
10475
  //#endregion
10455
10476
  //#region src/components/ui/ComboBox/useCommonComboBoxProps.ts
10456
- function useCommonComboBoxProps({ className, options, groups, onInputValueChange, inputId, placeholder, slots, displayDisabledAsSelected, isDisabled, isError, isReadOnly = false, isClearable = true, isSearchable = true, isLoading, isMutating, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby }) {
10477
+ function useCommonComboBoxProps({ className, options, groups, onInputValueChange, inputId, placeholder, slots, displayDisabledAsSelected, isDisabled, isError, isReadOnly = false, isClearable = true, isSearchable = true, isLoading, isMutating, filterOption, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby }) {
10457
10478
  const internalInputId = useId();
10458
10479
  const effectiveInputId = inputId !== null && inputId !== void 0 ? inputId : internalInputId;
10459
10480
  const components = useComboBoxSubcomponents({
@@ -10491,6 +10512,7 @@ function useCommonComboBoxProps({ className, options, groups, onInputValueChange
10491
10512
  openMenuOnClick: !isReadOnly,
10492
10513
  menuPlacement: "auto",
10493
10514
  menuShouldScrollIntoView: false,
10515
+ filterOption,
10494
10516
  ["aria-label"]: ariaLabel,
10495
10517
  ["aria-labelledby"]: ariaLabelledby,
10496
10518
  ["aria-describedby"]: ariaDescribedby
@@ -10501,6 +10523,7 @@ function useCommonComboBoxProps({ className, options, groups, onInputValueChange
10501
10523
  className,
10502
10524
  components,
10503
10525
  effectiveInputId,
10526
+ filterOption,
10504
10527
  groups,
10505
10528
  isClearable,
10506
10529
  isDisabled,
@@ -11845,7 +11868,7 @@ Schema.Struct({ businessId: Schema.String });
11845
11868
  var bulkMatchOrCategorize = post(({ businessId }) => {
11846
11869
  return `/v1/businesses/${businessId}/bank-transactions/bulk-match-or-categorize`;
11847
11870
  });
11848
- function buildKey$79({ access_token: accessToken, apiUrl, businessId }) {
11871
+ function buildKey$80({ access_token: accessToken, apiUrl, businessId }) {
11849
11872
  if (accessToken && apiUrl) return {
11850
11873
  accessToken,
11851
11874
  apiUrl,
@@ -11864,7 +11887,7 @@ var useBulkMatchOrCategorize = () => {
11864
11887
  const buildTransactionsPayload = useCallback(() => {
11865
11888
  return { transactions: buildBulkMatchOrCategorizePayload(selectedIds, categorizations) };
11866
11889
  }, [selectedIds, categorizations]);
11867
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$79(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkMatchOrCategorize(apiUrl, accessToken, {
11890
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$80(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkMatchOrCategorize(apiUrl, accessToken, {
11868
11891
  params: { businessId },
11869
11892
  body: Schema.encodeSync(BulkMatchOrCategorizeRequestSchema)(arg)
11870
11893
  }).then(({ data }) => data), {
@@ -11951,7 +11974,7 @@ var BankTransactionsConfirmAllModal = ({ isOpen, onOpenChange, isMobileView = fa
11951
11974
  var BULK_UNCATEGORIZE_BANK_TRANSACTIONS_TAG_KEY = "#bulk-uncategorize-bank-transactions";
11952
11975
  var BulkUncategorizeRequestSchema = Schema.Struct({ transactionIds: Schema.propertySignature(Schema.Array(Schema.UUID)).pipe(Schema.fromKey("transaction_ids")) });
11953
11976
  var bulkUncategorize = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/bulk-uncategorize`);
11954
- function buildKey$78({ access_token: accessToken, apiUrl, businessId }) {
11977
+ function buildKey$79({ access_token: accessToken, apiUrl, businessId }) {
11955
11978
  if (accessToken && apiUrl) return {
11956
11979
  accessToken,
11957
11980
  apiUrl,
@@ -11965,7 +11988,7 @@ var useBulkUncategorize = () => {
11965
11988
  const { businessId, eventCallbacks } = useLayerContext();
11966
11989
  const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
11967
11990
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
11968
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$78(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkUncategorize(apiUrl, accessToken, {
11991
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$79(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg }) => bulkUncategorize(apiUrl, accessToken, {
11969
11992
  params: { businessId },
11970
11993
  body: Schema.encodeSync(BulkUncategorizeRequestSchema)(arg)
11971
11994
  }).then(({ data }) => data), {
@@ -12347,7 +12370,7 @@ var mapRawCustomAccountToCustomAccount = (raw) => ({
12347
12370
  //#endregion
12348
12371
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/useCustomAccounts.ts
12349
12372
  var CUSTOM_ACCOUNTS_TAG_KEY = "#custom-accounts";
12350
- function buildKey$77({ access_token: accessToken, apiUrl, businessId, userCreated }) {
12373
+ function buildKey$78({ access_token: accessToken, apiUrl, businessId, userCreated }) {
12351
12374
  if (accessToken && apiUrl) return {
12352
12375
  accessToken,
12353
12376
  apiUrl,
@@ -12365,7 +12388,7 @@ function useCustomAccounts({ userCreated } = {}) {
12365
12388
  const withLocale = useLocalizedKey();
12366
12389
  const { data } = useAuth();
12367
12390
  const { businessId } = useLayerContext();
12368
- return useSWR(() => withLocale(buildKey$77(_objectSpread2(_objectSpread2({}, data), {}, {
12391
+ return useSWR(() => withLocale(buildKey$78(_objectSpread2(_objectSpread2({}, data), {}, {
12369
12392
  businessId,
12370
12393
  userCreated
12371
12394
  }))), ({ accessToken, apiUrl, businessId, userCreated }) => getCustomAccounts(apiUrl, accessToken, { params: {
@@ -12375,7 +12398,7 @@ function useCustomAccounts({ userCreated } = {}) {
12375
12398
  }
12376
12399
  //#endregion
12377
12400
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/[custom-account-id]/parse-csv/useCustomAccountParseCsv.ts
12378
- function buildKey$76({ access_token: accessToken, apiUrl, businessId }) {
12401
+ function buildKey$77({ access_token: accessToken, apiUrl, businessId }) {
12379
12402
  if (accessToken && apiUrl) return {
12380
12403
  accessToken,
12381
12404
  apiUrl,
@@ -12392,7 +12415,7 @@ function useCustomAccountParseCsv() {
12392
12415
  const withLocale = useLocalizedKey();
12393
12416
  const { data } = useAuth();
12394
12417
  const { businessId } = useLayerContext();
12395
- return useSWRMutation(() => withLocale(buildKey$76(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { customAccountId, file } }) => parseCsv(apiUrl, accessToken, {
12418
+ return useSWRMutation(() => withLocale(buildKey$77(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: { customAccountId, file } }) => parseCsv(apiUrl, accessToken, {
12396
12419
  businessId,
12397
12420
  customAccountId,
12398
12421
  file
@@ -12674,7 +12697,7 @@ get(({ businessId }) => `/v1/businesses/${businessId}/external-accounts`);
12674
12697
  //#endregion
12675
12698
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/useCreateCustomAccount.ts
12676
12699
  var createCustomAccount = post(({ businessId }) => `/v1/businesses/${businessId}/custom-accounts`);
12677
- function buildKey$75({ access_token: accessToken, apiUrl, businessId }) {
12700
+ function buildKey$76({ access_token: accessToken, apiUrl, businessId }) {
12678
12701
  if (accessToken && apiUrl) return {
12679
12702
  accessToken,
12680
12703
  apiUrl,
@@ -12687,7 +12710,7 @@ function useCreateCustomAccount() {
12687
12710
  const { data } = useAuth();
12688
12711
  const { businessId } = useLayerContext();
12689
12712
  const { mutate } = useSWRConfig();
12690
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$75(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: body }) => createCustomAccount(apiUrl, accessToken, {
12713
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$76(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, { arg: body }) => createCustomAccount(apiUrl, accessToken, {
12691
12714
  params: { businessId },
12692
12715
  body
12693
12716
  }).then(({ data }) => mapRawCustomAccountToCustomAccount(data)), { revalidate: false });
@@ -13407,6 +13430,12 @@ var fromNonRecursiveBigDecimal = (nrbd) => {
13407
13430
  var nrbdEquals = (a, b) => {
13408
13431
  return BigDecimal.equals(fromNonRecursiveBigDecimal(a), fromNonRecursiveBigDecimal(b));
13409
13432
  };
13433
+ var convertCentsToNonRecursiveBigDecimal = (cents) => {
13434
+ return toNonRecursiveBigDecimal(convertCentsToBigDecimal(cents));
13435
+ };
13436
+ var convertNonRecursiveBigDecimalToCents = (nrbd) => {
13437
+ return convertBigDecimalToCents(fromNonRecursiveBigDecimal(nrbd));
13438
+ };
13410
13439
  //#endregion
13411
13440
  //#region src/components/forms/FormNonRecursiveBigDecimalField.tsx
13412
13441
  var _excluded$69 = [
@@ -14263,7 +14292,7 @@ function UploadTransactionsUploadCsvStep({ selectedAccount, onSelectAccount, sel
14263
14292
  //#region src/hooks/api/businesses/[business-id]/custom-accounts/[custom-account-id]/transactions/useCreateCustomAccountTransactions.ts
14264
14293
  var _excluded$58 = ["customAccountId"];
14265
14294
  var createCustomAccountTransactions = post(({ businessId, customAccountId }) => `/v1/businesses/${businessId}/custom-accounts/${customAccountId}/transactions`);
14266
- function buildKey$74({ access_token: accessToken, apiUrl, businessId }) {
14295
+ function buildKey$75({ access_token: accessToken, apiUrl, businessId }) {
14267
14296
  if (accessToken && apiUrl) return {
14268
14297
  accessToken,
14269
14298
  apiUrl,
@@ -14275,7 +14304,7 @@ function useCreateCustomAccountTransactions() {
14275
14304
  const withLocale = useLocalizedKey();
14276
14305
  const { data } = useAuth();
14277
14306
  const { businessId } = useLayerContext();
14278
- return useSWRMutation(() => withLocale(buildKey$74(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, _ref) => {
14307
+ return useSWRMutation(() => withLocale(buildKey$75(_objectSpread2(_objectSpread2({}, data), {}, { businessId }))), ({ accessToken, apiUrl, businessId }, _ref) => {
14279
14308
  let { arg: _ref2 } = _ref, { customAccountId } = _ref2, body = _objectWithoutProperties(_ref2, _excluded$58);
14280
14309
  return createCustomAccountTransactions(apiUrl, accessToken, {
14281
14310
  params: {
@@ -15751,7 +15780,7 @@ var useGetBankTransactionMatchOrCategoryWithDefault = (bankTransaction) => {
15751
15780
  var _excluded$56 = ["bankTransactionId"];
15752
15781
  var CATEGORIZE_BANK_TRANSACTION_TAG = "#categorize-bank-transaction";
15753
15782
  var categorizeBankTransaction = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`);
15754
- function buildKey$73({ access_token: accessToken, apiUrl, businessId }) {
15783
+ function buildKey$74({ access_token: accessToken, apiUrl, businessId }) {
15755
15784
  if (accessToken && apiUrl) return {
15756
15785
  accessToken,
15757
15786
  apiUrl,
@@ -15767,7 +15796,7 @@ function useCategorizeBankTransaction() {
15767
15796
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
15768
15797
  const { useBankTransactionsOptions } = useBankTransactionsContext();
15769
15798
  const { forceReloadBackgroundBankTransactions } = useBankTransactionsGlobalCacheActions();
15770
- const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$73({
15799
+ const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$74({
15771
15800
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
15772
15801
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
15773
15802
  businessId
@@ -15845,7 +15874,7 @@ function useCategorizeBankTransactionWithCacheUpdate() {
15845
15874
  var _excluded$55 = ["bankTransactionId"];
15846
15875
  var matchBankTransaction = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/match`);
15847
15876
  var MATCH_BANK_TRANSACTION_TAG = "#match-bank-transaction";
15848
- function buildKey$72({ access_token: accessToken, apiUrl, businessId }) {
15877
+ function buildKey$73({ access_token: accessToken, apiUrl, businessId }) {
15849
15878
  if (accessToken && apiUrl) return {
15850
15879
  accessToken,
15851
15880
  apiUrl,
@@ -15861,7 +15890,7 @@ function useMatchBankTransaction() {
15861
15890
  const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
15862
15891
  const { useBankTransactionsOptions } = useBankTransactionsContext();
15863
15892
  const { forceReloadBackgroundBankTransactions } = useBankTransactionsGlobalCacheActions();
15864
- const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$72({
15893
+ const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$73({
15865
15894
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
15866
15895
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
15867
15896
  businessId
@@ -16254,7 +16283,7 @@ var getBookkeepingPeriods = get(({ businessId }) => {
16254
16283
  return `/v1/businesses/${businessId}/bookkeeping/periods`;
16255
16284
  });
16256
16285
  var BOOKKEEPING_PERIODS_TAG_KEY = "#bookkeeping-periods";
16257
- function buildKey$71({ access_token: accessToken, apiUrl, businessId, isActiveOrPaused }) {
16286
+ function buildKey$72({ access_token: accessToken, apiUrl, businessId, isActiveOrPaused }) {
16258
16287
  if (accessToken && apiUrl && isActiveOrPaused) return {
16259
16288
  accessToken,
16260
16289
  apiUrl,
@@ -16268,7 +16297,7 @@ function useBookkeepingPeriods() {
16268
16297
  const { businessId } = useLayerContext();
16269
16298
  const { data, isLoading: isLoadingBookkeepingStatus } = useBookkeepingStatus();
16270
16299
  const isActiveOrPaused = data ? isActiveOrPausedBookkeepingStatus(data.status) : false;
16271
- const swrResponse = useSWR(() => withLocale(buildKey$71(_objectSpread2(_objectSpread2({}, auth), {}, {
16300
+ const swrResponse = useSWR(() => withLocale(buildKey$72(_objectSpread2(_objectSpread2({}, auth), {}, {
16272
16301
  businessId,
16273
16302
  isActiveOrPaused
16274
16303
  }))), ({ accessToken, apiUrl, businessId }) => getBookkeepingPeriods(apiUrl, accessToken, { params: { businessId } })().then(({ data: { periods } }) => periods.map((period) => _objectSpread2(_objectSpread2({}, period), {}, {
@@ -16441,7 +16470,7 @@ function useMinMutatingMutation({ swrMutationResponse, minMutatingMs }) {
16441
16470
  //#endregion
16442
16471
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useSetMetadataOnBankTransaction.ts
16443
16472
  var SET_METADATA_ON_BANK_TRANSACTION_TAG_KEY = "#set-metadata-on-bank-transaction";
16444
- function buildKey$70({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16473
+ function buildKey$71({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16445
16474
  if (accessToken && apiUrl) return {
16446
16475
  accessToken,
16447
16476
  apiUrl,
@@ -16455,7 +16484,7 @@ function useSetMetadataOnBankTransaction({ bankTransactionId }) {
16455
16484
  const withLocale = useLocalizedKey();
16456
16485
  const { data } = useAuth();
16457
16486
  const { businessId } = useLayerContext();
16458
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$70(_objectSpread2(_objectSpread2({}, data), {}, {
16487
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$71(_objectSpread2(_objectSpread2({}, data), {}, {
16459
16488
  businessId,
16460
16489
  bankTransactionId
16461
16490
  }))), ({ accessToken, apiUrl, businessId, bankTransactionId }, { arg: { vendor, customer } }) => {
@@ -16504,7 +16533,7 @@ function useSetMetadataOnBankTransaction({ bankTransactionId }) {
16504
16533
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/tags/useRemoveTagFromBankTransaction.ts
16505
16534
  var REMOVE_TAG_FROM_BANK_TRANSACTION_TAG_KEY = "#remove-tag-from-bank-transaction";
16506
16535
  var removeTagFromBankTransaction = del(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
16507
- function buildKey$69({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16536
+ function buildKey$70({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16508
16537
  if (accessToken && apiUrl) return {
16509
16538
  accessToken,
16510
16539
  apiUrl,
@@ -16517,7 +16546,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
16517
16546
  const withLocale = useLocalizedKey();
16518
16547
  const { data } = useAuth();
16519
16548
  const { businessId } = useLayerContext();
16520
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$69(_objectSpread2(_objectSpread2({}, data), {}, {
16549
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$70(_objectSpread2(_objectSpread2({}, data), {}, {
16521
16550
  businessId,
16522
16551
  bankTransactionId
16523
16552
  }))), ({ accessToken, apiUrl, businessId }, { arg: { tagId } }) => removeTagFromBankTransaction(apiUrl, accessToken, {
@@ -16556,7 +16585,7 @@ function useRemoveTagFromBankTransaction({ bankTransactionId }) {
16556
16585
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/tags/useTagBankTransaction.ts
16557
16586
  var TAG_BANK_TRANSACTION_TAG_KEY = "#tag-bank-transaction";
16558
16587
  var tagBankTransaction = post(({ businessId }) => `/v1/businesses/${businessId}/bank-transactions/tags`);
16559
- function buildKey$68({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16588
+ function buildKey$69({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
16560
16589
  if (accessToken && apiUrl) return {
16561
16590
  accessToken,
16562
16591
  apiUrl,
@@ -16569,7 +16598,7 @@ function useTagBankTransaction({ bankTransactionId }) {
16569
16598
  const withLocale = useLocalizedKey();
16570
16599
  const { data } = useAuth();
16571
16600
  const { businessId } = useLayerContext();
16572
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$68(_objectSpread2(_objectSpread2({}, data), {}, {
16601
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$69(_objectSpread2(_objectSpread2({}, data), {}, {
16573
16602
  businessId,
16574
16603
  bankTransactionId
16575
16604
  }))), ({ accessToken, apiUrl, businessId, bankTransactionId }, { arg: { key, value, dimensionDisplayName, valueDisplayName } }) => tagBankTransaction(apiUrl, accessToken, {
@@ -17136,7 +17165,7 @@ function BankTransactionCustomerVendorSelector({ bankTransaction }) {
17136
17165
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useBankTransactionsMetadata.ts
17137
17166
  var getBankTransactionMetadata = get(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/metadata`);
17138
17167
  var GET_BANK_TRANSACTION_METADATA_TAG_KEY = "#bank-transaction-metadata";
17139
- function buildKey$67({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
17168
+ function buildKey$68({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
17140
17169
  if (accessToken && apiUrl) return {
17141
17170
  accessToken,
17142
17171
  apiUrl,
@@ -17149,7 +17178,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
17149
17178
  const withLocale = useLocalizedKey();
17150
17179
  const { data: auth } = useAuth();
17151
17180
  const { businessId } = useLayerContext();
17152
- return useSWR(() => withLocale(buildKey$67(_objectSpread2(_objectSpread2({}, auth), {}, {
17181
+ return useSWR(() => withLocale(buildKey$68(_objectSpread2(_objectSpread2({}, auth), {}, {
17153
17182
  businessId,
17154
17183
  bankTransactionId
17155
17184
  }))), ({ accessToken, apiUrl, businessId }) => getBankTransactionMetadata(apiUrl, accessToken, { params: {
@@ -17161,7 +17190,7 @@ function useBankTransactionMetadata({ bankTransactionId }) {
17161
17190
  //#region src/hooks/api/businesses/[business-id]/bank-transactions/[bank-transaction-id]/metadata/useUpdateBankTransactionMetadata.ts
17162
17191
  var updateBankTransactionMetadata = put(({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/metadata`);
17163
17192
  var UPDATE_BANK_TRANSACTION_METADATA_TAG_KEY = "#update-bank-transaction-metadata";
17164
- function buildKey$66({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
17193
+ function buildKey$67({ access_token: accessToken, apiUrl, businessId, bankTransactionId }) {
17165
17194
  if (accessToken && apiUrl) return {
17166
17195
  accessToken,
17167
17196
  apiUrl,
@@ -17175,7 +17204,7 @@ function useUpdateBankTransactionMetadata({ bankTransactionId, onSuccess }) {
17175
17204
  const { data: auth } = useAuth();
17176
17205
  const { businessId } = useLayerContext();
17177
17206
  const { mutate } = useSWRConfig();
17178
- const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$66({
17207
+ const mutationResponse = new SWRMutationResult(useSWRMutation(() => withLocale(buildKey$67({
17179
17208
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
17180
17209
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
17181
17210
  businessId,
@@ -17308,7 +17337,7 @@ var BankTransactionMemo = ({ bankTransactionId, isMobile }) => {
17308
17337
  //#endregion
17309
17338
  //#region src/hooks/api/businesses/[business-id]/tags/dimensions/key/[dimension-key]/useTagDimensionByKey.ts
17310
17339
  var TAG_DIMENSION_BY_KEY_TAG_KEY = "#tag-dimension-by-key";
17311
- function buildKey$65({ access_token: accessToken, apiUrl, businessId, isEnabled, dimensionKey }) {
17340
+ function buildKey$66({ access_token: accessToken, apiUrl, businessId, isEnabled, dimensionKey }) {
17312
17341
  if (!isEnabled) return;
17313
17342
  if (accessToken && apiUrl) return {
17314
17343
  accessToken,
@@ -17324,7 +17353,7 @@ function useTagDimensionByKey({ isEnabled = true, dimensionKey }) {
17324
17353
  const { data: auth } = useAuth();
17325
17354
  const { apiUrl } = useEnvironment();
17326
17355
  const { businessId } = useLayerContext();
17327
- return new SWRQueryResult(useSWR(() => withLocale(buildKey$65(_objectSpread2(_objectSpread2({}, auth), {}, {
17356
+ return new SWRQueryResult(useSWR(() => withLocale(buildKey$66(_objectSpread2(_objectSpread2({}, auth), {}, {
17328
17357
  apiUrl,
17329
17358
  isEnabled,
17330
17359
  businessId,
@@ -19977,10 +20006,10 @@ var BankTransactionsTable = ({ isLoading, bankTransactions, showDescriptions, sh
19977
20006
  //#endregion
19978
20007
  //#region src/hooks/api/businesses/[business-id]/categorization-rules/useListCategorizationRules.ts
19979
20008
  var LIST_CATEGORIZATION_RULES_TAG_KEY = "#list-categorization-rules";
19980
- var SortBy$1 = /* @__PURE__ */ function(SortBy) {
20009
+ var SortBy$2 = /* @__PURE__ */ function(SortBy) {
19981
20010
  SortBy["CreatedAt"] = "created_at";
19982
20011
  return SortBy;
19983
- }(SortBy$1 || {});
20012
+ }(SortBy$2 || {});
19984
20013
  var ListCategorizationRulesReturnSchema = Schema.Struct({
19985
20014
  data: Schema.Array(CategorizationRuleSchema),
19986
20015
  meta: Schema.Struct({ pagination: PaginatedResponseMetaSchema })
@@ -20007,7 +20036,7 @@ var listCategorizationRules = get(({ businessId, externalIds, includeArchived, s
20007
20036
  const baseUrl = `/v1/businesses/${businessId}/categorization-rules`;
20008
20037
  return parameters ? `${baseUrl}?${parameters}` : baseUrl;
20009
20038
  });
20010
- function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, includeArchived, sortBy, sortOrder, limit, showTotalCount }) {
20039
+ function keyLoader$7(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, includeArchived, sortBy, sortOrder, limit, showTotalCount }) {
20011
20040
  if (accessToken && apiUrl) {
20012
20041
  var _previousPageData$met;
20013
20042
  return {
@@ -20025,12 +20054,12 @@ function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, busi
20025
20054
  };
20026
20055
  }
20027
20056
  }
20028
- function useListCategorizationRules({ externalIds, includeArchived, sortBy = SortBy$1.CreatedAt, sortOrder = SortOrder.DESC, limit, showTotalCount = true } = {}) {
20057
+ function useListCategorizationRules({ externalIds, includeArchived, sortBy = SortBy$2.CreatedAt, sortOrder = SortOrder.DESC, limit, showTotalCount = true } = {}) {
20029
20058
  const withLocale = useLocalizedKey();
20030
20059
  const { businessId } = useLayerContext();
20031
20060
  const { apiUrl } = useEnvironment();
20032
20061
  const { data: auth } = useAuth();
20033
- const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$6(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
20062
+ const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$7(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
20034
20063
  apiUrl,
20035
20064
  businessId,
20036
20065
  externalIds,
@@ -20070,7 +20099,7 @@ function useCategorizationRulesGlobalCacheActions() {
20070
20099
  //#endregion
20071
20100
  //#region src/hooks/api/businesses/[business-id]/categorization-rules/[categorization-rule-id]/archive/useArchiveCategorizationRule.ts
20072
20101
  var ARCHIVE_CATEGORIZATION_RULE_TAG = "#archive-categorization-rule";
20073
- function buildKey$64({ access_token: accessToken, apiUrl, businessId }) {
20102
+ function buildKey$65({ access_token: accessToken, apiUrl, businessId }) {
20074
20103
  if (accessToken && apiUrl) return {
20075
20104
  accessToken,
20076
20105
  apiUrl,
@@ -20085,7 +20114,7 @@ function useArchiveCategorizationRule() {
20085
20114
  const { data: auth } = useAuth();
20086
20115
  const { businessId } = useLayerContext();
20087
20116
  const { forceReloadCategorizationRules } = useCategorizationRulesGlobalCacheActions();
20088
- const mutationResponse = useSWRMutation(() => withLocale(buildKey$64({
20117
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$65({
20089
20118
  access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
20090
20119
  apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
20091
20120
  businessId
@@ -20160,6 +20189,691 @@ var BaseDetailView = ({ name, onGoBack, slots, children, borderless = false }) =
20160
20189
  });
20161
20190
  };
20162
20191
  //#endregion
20192
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategoryMobileDrawer.tsx
20193
+ var CategoryMobileDrawer = ({ label, value, onValueChange, showLabel }) => {
20194
+ const { data: categories } = useCategories();
20195
+ const flatOptions = useMemo(() => {
20196
+ if (!categories) return [];
20197
+ return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
20198
+ }, [categories]);
20199
+ const selectedOption = useMemo(() => {
20200
+ var _flatOptions$find;
20201
+ if (!value) return null;
20202
+ return (_flatOptions$find = flatOptions.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _flatOptions$find !== void 0 ? _flatOptions$find : null;
20203
+ }, [flatOptions, value]);
20204
+ const handleSelectedValueChange = useCallback((option) => {
20205
+ onValueChange(option instanceof CategoryAsOption ? option.classification : null);
20206
+ }, [onValueChange]);
20207
+ return /* @__PURE__ */ jsxs(VStack, {
20208
+ gap: "3xs",
20209
+ children: [showLabel && /* @__PURE__ */ jsx(Label$2, {
20210
+ size: "sm",
20211
+ children: label
20212
+ }), /* @__PURE__ */ jsx(CategorySelectDrawerWithTrigger, {
20213
+ selectedValue: selectedOption,
20214
+ onSelectedValueChange: handleSelectedValueChange,
20215
+ showTooltips: false,
20216
+ slotProps: { TriggerSpan: { size: "sm" } }
20217
+ })]
20218
+ });
20219
+ };
20220
+ //#endregion
20221
+ //#region src/components/LedgerAccountCombobox/LedgerAccountCombobox.tsx
20222
+ var LedgerAccountCombobox = ({ label, value, mode, onValueChange, isReadOnly, showLabel, className }) => {
20223
+ const { data: categories, isLoading } = useCategories({ mode });
20224
+ const options = useMemo(() => {
20225
+ if (!categories) return [];
20226
+ return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
20227
+ }, [categories]);
20228
+ const selectedCategory = useMemo(() => {
20229
+ var _options$find;
20230
+ if (!value) return null;
20231
+ return (_options$find = options.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _options$find !== void 0 ? _options$find : null;
20232
+ }, [options, value]);
20233
+ const onSelectedValueChange = useCallback((option) => {
20234
+ var _option$classificatio;
20235
+ onValueChange((_option$classificatio = option === null || option === void 0 ? void 0 : option.classification) !== null && _option$classificatio !== void 0 ? _option$classificatio : null);
20236
+ }, [onValueChange]);
20237
+ const inputId = useId();
20238
+ return /* @__PURE__ */ jsxs(VStack, {
20239
+ gap: "3xs",
20240
+ className,
20241
+ children: [showLabel && /* @__PURE__ */ jsx(Label$2, {
20242
+ size: "sm",
20243
+ htmlFor: inputId,
20244
+ children: label
20245
+ }), /* @__PURE__ */ jsx(ComboBox, _objectSpread2({
20246
+ options,
20247
+ onSelectedValueChange,
20248
+ selectedValue: selectedCategory,
20249
+ inputId,
20250
+ isReadOnly,
20251
+ isLoading,
20252
+ isClearable: false
20253
+ }, !showLabel && { "aria-label": label }))]
20254
+ });
20255
+ };
20256
+ //#endregion
20257
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorySelect.tsx
20258
+ var CategorySelect = (props) => {
20259
+ const { isMobile } = useSizeClass();
20260
+ if (isMobile) return /* @__PURE__ */ jsx(CategoryMobileDrawer, _objectSpread2({}, props));
20261
+ return /* @__PURE__ */ jsx(LedgerAccountCombobox, {
20262
+ label: props.label,
20263
+ value: props.value,
20264
+ onValueChange: props.onValueChange,
20265
+ mode: CategoriesListMode.All,
20266
+ showLabel: props.showLabel
20267
+ });
20268
+ };
20269
+ //#endregion
20270
+ //#region src/hooks/api/businesses/[business-id]/counterparties/useListCounterparties.ts
20271
+ var LIST_COUNTERPARTIES_TAG_KEY = "#list-counterparties";
20272
+ var SortBy$1 = /* @__PURE__ */ function(SortBy) {
20273
+ SortBy["Name"] = "name";
20274
+ return SortBy;
20275
+ }(SortBy$1 || {});
20276
+ var ListCounterpartiesReturnSchema = Schema.Struct({
20277
+ data: Schema.Array(BankTransactionCounterpartySchema),
20278
+ meta: Schema.Struct({ pagination: PaginatedResponseMetaSchema })
20279
+ });
20280
+ var ListCounterpartiesSWRResponse = class extends SWRInfiniteResult {
20281
+ get paginationMeta() {
20282
+ return this.data && this.data.length > 0 ? this.data[this.data.length - 1].meta.pagination : void 0;
20283
+ }
20284
+ get hasMore() {
20285
+ var _this$paginationMeta;
20286
+ return (_this$paginationMeta = this.paginationMeta) === null || _this$paginationMeta === void 0 ? void 0 : _this$paginationMeta.hasMore;
20287
+ }
20288
+ };
20289
+ var listCounterparties = get(({ businessId, externalIds, q, sortBy, sortOrder, cursor, limit, showTotalCount }) => {
20290
+ const parameters = toDefinedSearchParameters({
20291
+ externalIds,
20292
+ q,
20293
+ sortBy,
20294
+ sortOrder,
20295
+ cursor,
20296
+ limit,
20297
+ showTotalCount
20298
+ });
20299
+ const baseUrl = `/v1/businesses/${businessId}/counterparties`;
20300
+ return parameters ? `${baseUrl}?${parameters}` : baseUrl;
20301
+ });
20302
+ function keyLoader$6(previousPageData, { access_token: accessToken, apiUrl, businessId, externalIds, q, sortBy, sortOrder, limit, showTotalCount }) {
20303
+ if (accessToken && apiUrl) {
20304
+ var _previousPageData$met;
20305
+ return {
20306
+ accessToken,
20307
+ apiUrl,
20308
+ businessId,
20309
+ externalIds,
20310
+ q,
20311
+ cursor: previousPageData === null || previousPageData === void 0 || (_previousPageData$met = previousPageData.meta) === null || _previousPageData$met === void 0 ? void 0 : _previousPageData$met.pagination.cursor,
20312
+ sortBy,
20313
+ sortOrder,
20314
+ limit,
20315
+ showTotalCount,
20316
+ tags: [LIST_COUNTERPARTIES_TAG_KEY]
20317
+ };
20318
+ }
20319
+ }
20320
+ function useListCounterparties({ externalIds, q, sortBy = SortBy$1.Name, sortOrder = SortOrder.ASC, limit, showTotalCount = true } = {}) {
20321
+ const withLocale = useLocalizedKey();
20322
+ const { businessId } = useLayerContext();
20323
+ const { apiUrl } = useEnvironment();
20324
+ const { data: auth } = useAuth();
20325
+ const swrResponse = useSWRInfinite((_index, previousPageData) => withLocale(keyLoader$6(previousPageData, _objectSpread2(_objectSpread2({}, auth), {}, {
20326
+ apiUrl,
20327
+ businessId,
20328
+ externalIds,
20329
+ q,
20330
+ sortBy,
20331
+ sortOrder,
20332
+ limit,
20333
+ showTotalCount
20334
+ }))), ({ accessToken, apiUrl, businessId, cursor, externalIds, q, sortBy, sortOrder, limit, showTotalCount }) => listCounterparties(apiUrl, accessToken, { params: {
20335
+ businessId,
20336
+ externalIds,
20337
+ q,
20338
+ sortBy,
20339
+ sortOrder,
20340
+ cursor,
20341
+ limit,
20342
+ showTotalCount
20343
+ } })().then(Schema.decodeUnknownPromise(ListCounterpartiesReturnSchema)), {
20344
+ keepPreviousData: true,
20345
+ revalidateFirstPage: false,
20346
+ initialSize: 1
20347
+ });
20348
+ usePreserveInfiniteSize(swrResponse);
20349
+ return new ListCounterpartiesSWRResponse(swrResponse);
20350
+ }
20351
+ //#endregion
20352
+ //#region src/components/CategorizationRules/CategorizationRuleForm/counterpartyComboBoxOption.ts
20353
+ var CounterpartyComboBoxOption = class extends BaseComboBoxOption {
20354
+ constructor(counterparty) {
20355
+ super(counterparty);
20356
+ }
20357
+ get original() {
20358
+ return this.internalValue;
20359
+ }
20360
+ get label() {
20361
+ var _this$internalValue$n;
20362
+ return (_this$internalValue$n = this.internalValue.name) !== null && _this$internalValue$n !== void 0 ? _this$internalValue$n : this.internalValue.id;
20363
+ }
20364
+ get value() {
20365
+ return this.internalValue.id;
20366
+ }
20367
+ };
20368
+ //#endregion
20369
+ //#region src/components/CategorizationRules/CategorizationRuleForm/useCounterpartyOptions.ts
20370
+ var useCounterpartyOptions = (value) => {
20371
+ const { inputValue, searchQuery, handleInputChange } = useDebouncedSearchInput({ initialInputState: "" });
20372
+ const { data, isLoading, isError } = useListCounterparties({
20373
+ q: searchQuery || void 0,
20374
+ limit: 50
20375
+ });
20376
+ const fetchedOptions = useMemo(() => {
20377
+ if (!data) return [];
20378
+ return data.flatMap(({ data: page }) => page.map((counterparty) => new CounterpartyComboBoxOption(counterparty)));
20379
+ }, [data]);
20380
+ const options = useMemo(() => {
20381
+ if (!value) return fetchedOptions;
20382
+ if (fetchedOptions.some((option) => option.value === value.id)) return fetchedOptions;
20383
+ return [new CounterpartyComboBoxOption(value), ...fetchedOptions];
20384
+ }, [fetchedOptions, value]);
20385
+ return {
20386
+ inputValue,
20387
+ searchQuery,
20388
+ handleInputChange,
20389
+ options,
20390
+ selectedOption: useMemo(() => {
20391
+ var _options$find;
20392
+ if (!value) return null;
20393
+ return (_options$find = options.find((option) => option.value === value.id)) !== null && _options$find !== void 0 ? _options$find : null;
20394
+ }, [options, value]),
20395
+ isLoading,
20396
+ isError
20397
+ };
20398
+ };
20399
+ //#endregion
20400
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartyComboBox.tsx
20401
+ var CounterpartyComboBox = ({ label, value, onValueChange, showLabel, isReadOnly, isError, placeholder }) => {
20402
+ const { t } = useTranslation();
20403
+ const inputId = useId();
20404
+ const { searchQuery, handleInputChange, options, selectedOption, isLoading, isError: isListError } = useCounterpartyOptions(value);
20405
+ const slots = useMemo(() => {
20406
+ let emptyMessageContent = t("categorizationRules:empty.no_matching_counterparties", "No matching counterparties.");
20407
+ if (isListError) emptyMessageContent = t("categorizationRules:error.load_counterparties", "Couldn’t load counterparties. Please try again.");
20408
+ else if (searchQuery === "") emptyMessageContent = t("categorizationRules:empty.no_counterparties_yet", "No counterparties yet. They will appear here automatically as your transactions are processed.");
20409
+ return {
20410
+ EmptyMessage: /* @__PURE__ */ jsx(VStack, {
20411
+ pi: "md",
20412
+ children: /* @__PURE__ */ jsx(Span, { children: emptyMessageContent })
20413
+ }),
20414
+ ErrorMessage: /* @__PURE__ */ jsx(Span, {
20415
+ size: "xs",
20416
+ status: "error",
20417
+ children: t("categorizationRules:validation.counterparty_required", "Counterparty is required.")
20418
+ })
20419
+ };
20420
+ }, [
20421
+ isListError,
20422
+ searchQuery,
20423
+ t
20424
+ ]);
20425
+ const additionalAriaProps = useMemo(() => showLabel ? {} : { "aria-label": label }, [showLabel, label]);
20426
+ const handleSelectedValueChange = useCallback((option) => {
20427
+ var _option$original;
20428
+ onValueChange((_option$original = option === null || option === void 0 ? void 0 : option.original) !== null && _option$original !== void 0 ? _option$original : null);
20429
+ }, [onValueChange]);
20430
+ return /* @__PURE__ */ jsxs(VStack, {
20431
+ gap: "3xs",
20432
+ children: [showLabel && /* @__PURE__ */ jsx(Label$2, {
20433
+ size: "sm",
20434
+ htmlFor: inputId,
20435
+ children: label
20436
+ }), /* @__PURE__ */ jsx(ComboBox, _objectSpread2({
20437
+ options,
20438
+ selectedValue: selectedOption,
20439
+ onSelectedValueChange: handleSelectedValueChange,
20440
+ onInputValueChange: handleInputChange,
20441
+ filterOption: null,
20442
+ inputId,
20443
+ isLoading,
20444
+ isReadOnly,
20445
+ isError,
20446
+ placeholder,
20447
+ slots
20448
+ }, additionalAriaProps))]
20449
+ });
20450
+ };
20451
+ //#endregion
20452
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartyMobileDrawer.tsx
20453
+ var CounterpartyMobileDrawer = ({ label, value, onValueChange, showLabel, isReadOnly, placeholder }) => {
20454
+ var _ref, _selectedOption$label;
20455
+ const { t } = useTranslation();
20456
+ const inputId = useId();
20457
+ const [isOpen, setIsOpen] = useState(false);
20458
+ const { inputValue, handleInputChange, options, selectedOption, isLoading, isError: isListError } = useCounterpartyOptions(value);
20459
+ const Header = useCallback(() => /* @__PURE__ */ jsx(ModalTitleWithClose, {
20460
+ heading: /* @__PURE__ */ jsx(ModalHeading, {
20461
+ size: "md",
20462
+ weight: "bold",
20463
+ children: label
20464
+ }),
20465
+ hideCloseButton: true,
20466
+ hideBottomPadding: true
20467
+ }), [label]);
20468
+ const drawerSlots = useMemo(() => ({ Header }), [Header]);
20469
+ const openDrawer = useCallback(() => setIsOpen(true), []);
20470
+ const triggerLabel = (_ref = (_selectedOption$label = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) !== null && _selectedOption$label !== void 0 ? _selectedOption$label : placeholder) !== null && _ref !== void 0 ? _ref : t("common:action.select_label", "Select…");
20471
+ return /* @__PURE__ */ jsxs(VStack, {
20472
+ gap: "3xs",
20473
+ children: [
20474
+ showLabel && /* @__PURE__ */ jsx(Label$2, {
20475
+ size: "sm",
20476
+ htmlFor: inputId,
20477
+ children: label
20478
+ }),
20479
+ /* @__PURE__ */ jsx(Button$1, {
20480
+ id: inputId,
20481
+ onPress: openDrawer,
20482
+ variant: "outlined",
20483
+ isDisabled: isReadOnly,
20484
+ fullWidth: true,
20485
+ flex: true,
20486
+ "aria-label": label,
20487
+ children: /* @__PURE__ */ jsxs(HStack, {
20488
+ fluid: true,
20489
+ justify: "space-between",
20490
+ align: "center",
20491
+ children: [/* @__PURE__ */ jsx(Span, {
20492
+ size: "sm",
20493
+ ellipsis: true,
20494
+ children: triggerLabel
20495
+ }), !isReadOnly && /* @__PURE__ */ jsx(ChevronDown$1, { size: 16 })]
20496
+ })
20497
+ }),
20498
+ /* @__PURE__ */ jsx(Drawer, {
20499
+ isOpen,
20500
+ onOpenChange: setIsOpen,
20501
+ variant: "mobile-drawer",
20502
+ fixedHeight: true,
20503
+ isDismissable: true,
20504
+ "aria-label": label,
20505
+ slots: drawerSlots,
20506
+ children: ({ close }) => /* @__PURE__ */ jsxs(VStack, {
20507
+ pi: "sm",
20508
+ pb: "xs",
20509
+ gap: "md",
20510
+ children: [/* @__PURE__ */ jsx(SearchField$1, {
20511
+ value: inputValue,
20512
+ onChange: handleInputChange,
20513
+ label: t("common:action.search_label", "Search")
20514
+ }), /* @__PURE__ */ jsx(MobileSelectionDrawerList, {
20515
+ ariaLabel: label,
20516
+ options,
20517
+ selectedValue: selectedOption,
20518
+ onSelectedValueChange: (option) => {
20519
+ var _option$original;
20520
+ onValueChange((_option$original = option === null || option === void 0 ? void 0 : option.original) !== null && _option$original !== void 0 ? _option$original : null);
20521
+ close();
20522
+ },
20523
+ isLoading,
20524
+ isError: isListError
20525
+ })]
20526
+ })
20527
+ })
20528
+ ]
20529
+ });
20530
+ };
20531
+ //#endregion
20532
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CounterpartySelect.tsx
20533
+ var CounterpartySelect = (props) => {
20534
+ const { isMobile } = useSizeClass();
20535
+ if (isMobile) return /* @__PURE__ */ jsx(CounterpartyMobileDrawer, _objectSpread2({}, props));
20536
+ return /* @__PURE__ */ jsx(CounterpartyComboBox, _objectSpread2({}, props));
20537
+ };
20538
+ //#endregion
20539
+ //#region src/hooks/api/businesses/[business-id]/categorization-rules/useUpsertCategorizationRule.ts
20540
+ var UPSERT_CATEGORIZATION_RULE_TAG = "#upsert-categorization-rule";
20541
+ function buildKey$64({ access_token: accessToken, apiUrl, businessId }) {
20542
+ if (accessToken && apiUrl) return {
20543
+ accessToken,
20544
+ apiUrl,
20545
+ businessId,
20546
+ tags: [UPSERT_CATEGORIZATION_RULE_TAG]
20547
+ };
20548
+ }
20549
+ var UpsertCategorizationRuleReturnSchema = Schema$1.Struct({ data: CategorizationRuleSchema });
20550
+ var createCategorizationRule$1 = post(({ businessId }) => `/v1/businesses/${businessId}/categorization-rules`);
20551
+ var updateCategorizationRule = patch(({ businessId, categorizationRuleId }) => `/v1/businesses/${businessId}/categorization-rules/${categorizationRuleId}`);
20552
+ function useUpsertCategorizationRule() {
20553
+ const withLocale = useLocalizedKey();
20554
+ const { data: auth } = useAuth();
20555
+ const { businessId } = useLayerContext();
20556
+ const { forceReloadBankTransactions } = useBankTransactionsGlobalCacheActions();
20557
+ const { debouncedInvalidateProfitAndLoss } = useProfitAndLossGlobalInvalidator();
20558
+ const { forceReloadCategorizationRules, patchCategorizationRuleByKey } = useCategorizationRulesGlobalCacheActions();
20559
+ const mutationResponse = useSWRMutation(() => withLocale(buildKey$64({
20560
+ access_token: auth === null || auth === void 0 ? void 0 : auth.access_token,
20561
+ apiUrl: auth === null || auth === void 0 ? void 0 : auth.apiUrl,
20562
+ businessId
20563
+ })), ({ accessToken, apiUrl, businessId }, { arg }) => {
20564
+ const decode = Schema$1.decodeUnknownPromise(UpsertCategorizationRuleReturnSchema);
20565
+ if (arg.mode === "create") return createCategorizationRule$1(apiUrl, accessToken, {
20566
+ params: { businessId },
20567
+ body: arg.body
20568
+ }).then(decode);
20569
+ return updateCategorizationRule(apiUrl, accessToken, {
20570
+ params: {
20571
+ businessId,
20572
+ categorizationRuleId: arg.categorizationRuleId
20573
+ },
20574
+ body: arg.body
20575
+ }).then(decode);
20576
+ }, {
20577
+ revalidate: false,
20578
+ throwOnError: true
20579
+ });
20580
+ const { trigger: originalTrigger } = mutationResponse;
20581
+ const stableProxiedTrigger = useCallback(function() {
20582
+ var _ref = _asyncToGenerator(function* (arg, options) {
20583
+ const triggerResult = yield originalTrigger(arg, options);
20584
+ if (arg.mode === "create") {
20585
+ forceReloadCategorizationRules();
20586
+ forceReloadBankTransactions();
20587
+ debouncedInvalidateProfitAndLoss();
20588
+ } else if (triggerResult) patchCategorizationRuleByKey(triggerResult.data);
20589
+ return triggerResult;
20590
+ });
20591
+ return function(_x, _x2) {
20592
+ return _ref.apply(this, arguments);
20593
+ };
20594
+ }(), [
20595
+ originalTrigger,
20596
+ forceReloadCategorizationRules,
20597
+ forceReloadBankTransactions,
20598
+ debouncedInvalidateProfitAndLoss,
20599
+ patchCategorizationRuleByKey
20600
+ ]);
20601
+ return new Proxy(mutationResponse, { get(target, prop) {
20602
+ if (prop === "trigger") return stableProxiedTrigger;
20603
+ return Reflect.get(target, prop);
20604
+ } });
20605
+ }
20606
+ //#endregion
20607
+ //#region src/components/CategorizationRules/CategorizationRuleForm/formUtils.ts
20608
+ var centsToFormAmount = (cents) => {
20609
+ if (cents == null) return null;
20610
+ return convertCentsToNonRecursiveBigDecimal(cents);
20611
+ };
20612
+ var formAmountToCents = (amount) => {
20613
+ if (amount == null) return null;
20614
+ return convertNonRecursiveBigDecimalToCents(amount);
20615
+ };
20616
+ var getCategorizationRuleFormDefaultValues = (state) => {
20617
+ if (state.mode === "edit") {
20618
+ var _rule$counterpartyFil, _rule$category, _rule$bankDirectionFi;
20619
+ const { rule } = state;
20620
+ return {
20621
+ counterparty: (_rule$counterpartyFil = rule.counterpartyFilter) !== null && _rule$counterpartyFil !== void 0 ? _rule$counterpartyFil : null,
20622
+ category: (_rule$category = rule.category) !== null && _rule$category !== void 0 ? _rule$category : null,
20623
+ bankDirectionFilter: (_rule$bankDirectionFi = rule.bankDirectionFilter) !== null && _rule$bankDirectionFi !== void 0 ? _rule$bankDirectionFi : "",
20624
+ amountMinFilter: centsToFormAmount(rule.amountMinFilter),
20625
+ amountMaxFilter: centsToFormAmount(rule.amountMaxFilter)
20626
+ };
20627
+ }
20628
+ return {
20629
+ counterparty: null,
20630
+ category: null,
20631
+ bankDirectionFilter: "",
20632
+ amountMinFilter: null,
20633
+ amountMaxFilter: null
20634
+ };
20635
+ };
20636
+ var validateCategorizationRuleForm = (values, t) => {
20637
+ const errors = [];
20638
+ if (!values.counterparty) errors.push({ counterparty: t("categorizationRules:validation.counterparty_required", "Counterparty is required.") });
20639
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) errors.push({ category: t("categorizationRules:validation.category_required", "Category is required.") });
20640
+ if (values.amountMinFilter && values.amountMaxFilter) {
20641
+ const min = fromNonRecursiveBigDecimal(values.amountMinFilter);
20642
+ const max = fromNonRecursiveBigDecimal(values.amountMaxFilter);
20643
+ if (BigDecimal.greaterThan(min, max)) errors.push({ amountMinFilter: t("categorizationRules:validation.amount_min_greater_than_max", "Minimum amount must be less than or equal to maximum amount.") });
20644
+ }
20645
+ return errors.length > 0 ? errors : null;
20646
+ };
20647
+ var convertFormToCreateBody = (values) => {
20648
+ if (!values.counterparty) throw new Error("Counterparty is required to create a categorization rule");
20649
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) throw new Error("Category is required to create a categorization rule");
20650
+ const parsed = {
20651
+ applyRetroactively: false,
20652
+ category: values.category,
20653
+ bankDirectionFilter: values.bankDirectionFilter === "" ? null : values.bankDirectionFilter,
20654
+ amountMinFilter: formAmountToCents(values.amountMinFilter),
20655
+ amountMaxFilter: formAmountToCents(values.amountMaxFilter),
20656
+ counterpartyFilter: values.counterparty.id
20657
+ };
20658
+ return Schema.encodeUnknownSync(CreateCategorizationRuleSchema)(parsed);
20659
+ };
20660
+ var convertFormToPatchBody = (values) => {
20661
+ if (!values.counterparty) throw new Error("Counterparty is required to update a categorization rule");
20662
+ if (!values.category || !isClassificationAccountIdentifier(values.category)) throw new Error("Category is required to update a categorization rule");
20663
+ const parsed = {
20664
+ category: values.category,
20665
+ bankDirectionFilter: values.bankDirectionFilter === "" ? null : values.bankDirectionFilter,
20666
+ counterpartyFilter: values.counterparty.id,
20667
+ amountMinFilter: formAmountToCents(values.amountMinFilter),
20668
+ amountMaxFilter: formAmountToCents(values.amountMaxFilter)
20669
+ };
20670
+ return Schema.encodeUnknownSync(PatchCategorizationRuleSchema)(parsed);
20671
+ };
20672
+ //#endregion
20673
+ //#region src/components/CategorizationRules/CategorizationRuleForm/useCategorizationRuleForm.ts
20674
+ var useCategorizationRuleForm = ({ formState, onSuccess }) => {
20675
+ const { t } = useTranslation();
20676
+ const [submitError, setSubmitError] = useState(void 0);
20677
+ const { trigger: upsertCategorizationRule } = useUpsertCategorizationRule();
20678
+ const formDefaults = useMemo(() => getCategorizationRuleFormDefaultValues(formState), [formState]);
20679
+ const defaultValues = useRef(formDefaults).current;
20680
+ const onSubmit = useCallback(function() {
20681
+ var _ref = _asyncToGenerator(function* ({ value }) {
20682
+ try {
20683
+ const result = formState.mode === "edit" ? yield upsertCategorizationRule({
20684
+ mode: "update",
20685
+ categorizationRuleId: formState.rule.id,
20686
+ body: convertFormToPatchBody(value)
20687
+ }) : yield upsertCategorizationRule({
20688
+ mode: "create",
20689
+ body: convertFormToCreateBody(value)
20690
+ });
20691
+ setSubmitError(void 0);
20692
+ onSuccess(result.data);
20693
+ } catch (e) {
20694
+ console.error(e);
20695
+ setSubmitError(t("common:error.something_went_wrong_please_try_again", "Something went wrong. Please try again."));
20696
+ }
20697
+ });
20698
+ return function(_x) {
20699
+ return _ref.apply(this, arguments);
20700
+ };
20701
+ }(), [
20702
+ formState,
20703
+ upsertCategorizationRule,
20704
+ onSuccess,
20705
+ t
20706
+ ]);
20707
+ const onDynamic = useCallback(({ value }) => {
20708
+ return validateCategorizationRuleForm(value, t);
20709
+ }, [t]);
20710
+ const form = useAppForm({
20711
+ defaultValues,
20712
+ onSubmit,
20713
+ validators: useMemo(() => ({ onDynamic }), [onDynamic]),
20714
+ validationLogic: revalidateLogic({
20715
+ mode: "submit",
20716
+ modeAfterSubmission: "submit"
20717
+ }),
20718
+ canSubmitWhenInvalid: true
20719
+ });
20720
+ useEffect(() => {
20721
+ form.reset(formDefaults);
20722
+ }, [form, formDefaults]);
20723
+ return useMemo(() => ({
20724
+ form,
20725
+ submitError
20726
+ }), [form, submitError]);
20727
+ };
20728
+ //#endregion
20729
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorizationRuleForm.tsx
20730
+ var CategorizationRuleForm = ({ formState, onSuccess }) => {
20731
+ const { t } = useTranslation();
20732
+ const { form, submitError } = useCategorizationRuleForm({
20733
+ formState,
20734
+ onSuccess
20735
+ });
20736
+ const blockNativeOnSubmit = useCallback((e) => {
20737
+ e.preventDefault();
20738
+ e.stopPropagation();
20739
+ }, []);
20740
+ const directionOptions = useMemo(() => [
20741
+ {
20742
+ value: "",
20743
+ label: t("categorizationRules:label.any", "Any")
20744
+ },
20745
+ {
20746
+ value: BankDirectionFilter.MONEY_IN,
20747
+ label: t("common:label.money_in", "Money in")
20748
+ },
20749
+ {
20750
+ value: BankDirectionFilter.MONEY_OUT,
20751
+ label: t("common:label.money_out", "Money out")
20752
+ }
20753
+ ], [t]);
20754
+ return /* @__PURE__ */ jsxs(Form$1, {
20755
+ className: "Layer__CategorizationRuleForm",
20756
+ onSubmit: blockNativeOnSubmit,
20757
+ children: [
20758
+ /* @__PURE__ */ jsx(form.Subscribe, {
20759
+ selector: (state) => state.errorMap,
20760
+ children: (errorMap) => {
20761
+ const validationErrors = flattenValidationErrors(errorMap);
20762
+ if (validationErrors.length > 0 || submitError) return /* @__PURE__ */ jsx(HStack, { children: /* @__PURE__ */ jsx(DataState, {
20763
+ icon: /* @__PURE__ */ jsx(AlertTriangle, { size: 16 }),
20764
+ status: DataStateStatus.failed,
20765
+ title: validationErrors[0] || submitError,
20766
+ titleSize: TextSize.md,
20767
+ inline: true
20768
+ }) });
20769
+ }
20770
+ }),
20771
+ /* @__PURE__ */ jsx(form.Field, {
20772
+ name: "counterparty",
20773
+ children: (field) => /* @__PURE__ */ jsx(CounterpartySelect, {
20774
+ label: t("common:label.counterparty", "Counterparty"),
20775
+ value: field.state.value,
20776
+ onValueChange: field.handleChange,
20777
+ placeholder: t("categorizationRules:placeholder.select_counterparty", "Select counterparty"),
20778
+ showLabel: true
20779
+ })
20780
+ }),
20781
+ /* @__PURE__ */ jsx(form.Field, {
20782
+ name: "category",
20783
+ children: (field) => /* @__PURE__ */ jsx(CategorySelect, {
20784
+ label: t("common:label.category", "Category"),
20785
+ value: field.state.value,
20786
+ onValueChange: field.handleChange,
20787
+ showLabel: true
20788
+ })
20789
+ }),
20790
+ /* @__PURE__ */ jsx(form.AppField, {
20791
+ name: "bankDirectionFilter",
20792
+ children: (field) => /* @__PURE__ */ jsx(field.FormRadioGroupField, {
20793
+ label: t("common:label.direction", "Direction"),
20794
+ orientation: "vertical",
20795
+ options: directionOptions
20796
+ })
20797
+ }),
20798
+ /* @__PURE__ */ jsxs(HStack, {
20799
+ gap: "md",
20800
+ className: "Layer__CategorizationRuleForm__AmountRow",
20801
+ children: [/* @__PURE__ */ jsx(form.AppField, {
20802
+ name: "amountMinFilter",
20803
+ children: (field) => /* @__PURE__ */ jsx(field.FormNonRecursiveBigDecimalField, {
20804
+ label: t("categorizationRules:label.amount_min", "Minimum amount"),
20805
+ mode: "currency",
20806
+ allowEmpty: true,
20807
+ placeholder: t("categorizationRules:placeholder.no_minimum", "No minimum")
20808
+ })
20809
+ }), /* @__PURE__ */ jsx(form.AppField, {
20810
+ name: "amountMaxFilter",
20811
+ children: (field) => /* @__PURE__ */ jsx(field.FormNonRecursiveBigDecimalField, {
20812
+ label: t("categorizationRules:label.amount_max", "Maximum amount"),
20813
+ mode: "currency",
20814
+ allowEmpty: true,
20815
+ placeholder: t("categorizationRules:placeholder.no_maximum", "No maximum")
20816
+ })
20817
+ })]
20818
+ }),
20819
+ /* @__PURE__ */ jsx(VStack, {
20820
+ justify: "end",
20821
+ className: "Layer__CategorizationRuleForm__Submit",
20822
+ children: /* @__PURE__ */ jsx(form.Subscribe, {
20823
+ selector: (state) => [state.canSubmit, state.isSubmitting],
20824
+ children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ jsxs(Button$1, {
20825
+ type: "submit",
20826
+ isDisabled: !canSubmit,
20827
+ isPending: isSubmitting,
20828
+ onPress: () => {
20829
+ form.handleSubmit();
20830
+ },
20831
+ children: [/* @__PURE__ */ jsx(Save, { size: 14 }), formState.mode === "edit" ? t("categorizationRules:action.save_rule", "Save Rule") : t("categorizationRules:action.create_rule", "Create Rule")]
20832
+ })
20833
+ })
20834
+ })
20835
+ ]
20836
+ });
20837
+ };
20838
+ //#endregion
20839
+ //#region src/components/CategorizationRules/CategorizationRuleForm/CategorizationRuleFormDrawer.tsx
20840
+ var CategorizationRuleFormDrawerHeader = ({ title, close }) => /* @__PURE__ */ jsx(ModalTitleWithClose, {
20841
+ heading: /* @__PURE__ */ jsx(ModalHeading, {
20842
+ size: "md",
20843
+ children: title
20844
+ }),
20845
+ onClose: close
20846
+ });
20847
+ var CategorizationRuleFormDrawer = ({ isOpen, onOpenChange, onSuccess, formState }) => {
20848
+ const { t } = useTranslation();
20849
+ const { isMobile } = useSizeClass();
20850
+ const lastFormStateRef = useRef(formState);
20851
+ if (formState) lastFormStateRef.current = formState;
20852
+ const activeFormState = formState !== null && formState !== void 0 ? formState : lastFormStateRef.current;
20853
+ const title = (activeFormState === null || activeFormState === void 0 ? void 0 : activeFormState.mode) === "edit" ? t("categorizationRules:action.edit_rule", "Edit Rule") : t("categorizationRules:action.new_rule", "New Rule");
20854
+ const Header = useCallback(({ close }) => /* @__PURE__ */ jsx(CategorizationRuleFormDrawerHeader, {
20855
+ title,
20856
+ close
20857
+ }), [title]);
20858
+ const slots = useMemo(() => ({ Header }), [Header]);
20859
+ return /* @__PURE__ */ jsx(Drawer, {
20860
+ isOpen,
20861
+ onOpenChange,
20862
+ "aria-label": title,
20863
+ variant: isMobile ? "mobile-drawer" : "drawer",
20864
+ flexBlock: isMobile,
20865
+ slots,
20866
+ children: activeFormState && /* @__PURE__ */ jsx(VStack, {
20867
+ pbe: "lg",
20868
+ pi: "md",
20869
+ children: /* @__PURE__ */ jsx(CategorizationRuleForm, {
20870
+ formState: activeFormState,
20871
+ onSuccess
20872
+ })
20873
+ })
20874
+ });
20875
+ };
20876
+ //#endregion
20163
20877
  //#region src/hooks/utils/pagination/usePaginatedList.ts
20164
20878
  function usePaginatedList({ data, pageSize, initialPage = 0, onSetPage }) {
20165
20879
  const [internalPageIndex, setInternalPageIndex] = useState(initialPage);
@@ -20342,10 +21056,20 @@ var getCategorizationRuleCounterpartyLabel = (rule) => {
20342
21056
  var _ref, _rule$counterpartyFil, _rule$counterpartyFil2;
20343
21057
  return (_ref = (_rule$counterpartyFil = (_rule$counterpartyFil2 = rule.counterpartyFilter) === null || _rule$counterpartyFil2 === void 0 ? void 0 : _rule$counterpartyFil2.name) !== null && _rule$counterpartyFil !== void 0 ? _rule$counterpartyFil : rule.readableTransactionDescriptionFilter) !== null && _ref !== void 0 ? _ref : void 0;
20344
21058
  };
21059
+ var getCategorizationRuleAmountLabel = (rule, formatCurrencyFromCents, t) => {
21060
+ const { amountMinFilter: min, amountMaxFilter: max } = rule;
21061
+ if (min == null && max == null) return t("categorizationRules:label.any_amount", "Any amount");
21062
+ if (min != null && max != null) return `${formatCurrencyFromCents(min)} – ${formatCurrencyFromCents(max)}`;
21063
+ if (min != null) return `≥ ${formatCurrencyFromCents(min)}`;
21064
+ return `≤ ${formatCurrencyFromCents(max)}`;
21065
+ };
20345
21066
  //#endregion
20346
21067
  //#region src/components/CategorizationRules/CategorizationRulesMobileList/CategorizationRulesMobileList.tsx
20347
- var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
21068
+ var CategorizationRuleMobileListItem = ({ rule, options, onEditPress, onDeletePress }) => {
20348
21069
  const { t } = useTranslation();
21070
+ const { formatCurrencyFromCents } = useIntlFormatter();
21071
+ const counterpartyLabel = getCategorizationRuleCounterpartyLabel(rule);
21072
+ const hasAmountFilter = rule.amountMinFilter != null || rule.amountMaxFilter != null;
20349
21073
  return /* @__PURE__ */ jsxs(HStack, {
20350
21074
  justify: "space-between",
20351
21075
  align: "center",
@@ -20358,7 +21082,7 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
20358
21082
  /* @__PURE__ */ jsx(Span, {
20359
21083
  weight: "bold",
20360
21084
  ellipsis: true,
20361
- children: getCategorizationRuleCounterpartyLabel(rule)
21085
+ children: counterpartyLabel
20362
21086
  }),
20363
21087
  /* @__PURE__ */ jsxs(HStack, {
20364
21088
  gap: "3xs",
@@ -20373,6 +21097,19 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
20373
21097
  children: getCategorizationRuleDirectionLabel(rule.bankDirectionFilter, t)
20374
21098
  })]
20375
21099
  }),
21100
+ hasAmountFilter && /* @__PURE__ */ jsxs(HStack, {
21101
+ gap: "3xs",
21102
+ align: "center",
21103
+ children: [/* @__PURE__ */ jsx(Span, {
21104
+ size: "sm",
21105
+ variant: "subtle",
21106
+ children: t("common:label.amount", "Amount:")
21107
+ }), /* @__PURE__ */ jsx(Span, {
21108
+ size: "sm",
21109
+ variant: "subtle",
21110
+ children: getCategorizationRuleAmountLabel(rule, formatCurrencyFromCents, t)
21111
+ })]
21112
+ }),
20376
21113
  rule.category && /* @__PURE__ */ jsxs(HStack, {
20377
21114
  gap: "3xs",
20378
21115
  align: "center",
@@ -20390,23 +21127,39 @@ var CategorizationRuleMobileListItem = ({ rule, options, onDeletePress }) => {
20390
21127
  })]
20391
21128
  })
20392
21129
  ]
20393
- }), /* @__PURE__ */ jsx(Button$1, {
20394
- inset: true,
20395
- icon: true,
20396
- onPress: () => onDeletePress(rule),
20397
- "aria-label": t("categorizationRules:action.delete_rule", "Delete rule"),
20398
- variant: "ghost",
20399
- children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
21130
+ }), /* @__PURE__ */ jsxs(HStack, {
21131
+ gap: "3xs",
21132
+ align: "center",
21133
+ children: [/* @__PURE__ */ jsx(Button$1, {
21134
+ inset: true,
21135
+ icon: true,
21136
+ onPress: () => onEditPress(rule),
21137
+ "aria-label": t("categorizationRules:action.edit_rule", "Edit Rule"),
21138
+ variant: "ghost",
21139
+ children: /* @__PURE__ */ jsx(Pencil, { size: 16 })
21140
+ }), /* @__PURE__ */ jsx(Button$1, {
21141
+ inset: true,
21142
+ icon: true,
21143
+ onPress: () => onDeletePress(rule),
21144
+ "aria-label": t("categorizationRules:action.delete_rule", "Delete Rule"),
21145
+ variant: "ghost",
21146
+ children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
21147
+ })]
20400
21148
  })]
20401
21149
  });
20402
21150
  };
20403
- var CategorizationRulesMobileList = ({ data, isLoading, isError, paginationProps, options, onDeleteRule, slots }) => {
21151
+ var CategorizationRulesMobileList = ({ data, isLoading, isError, paginationProps, options, onEditRule, onDeleteRule, slots }) => {
20404
21152
  const { t } = useTranslation();
20405
21153
  const renderItem = useCallback((rule) => /* @__PURE__ */ jsx(CategorizationRuleMobileListItem, {
20406
21154
  rule,
20407
21155
  options,
21156
+ onEditPress: onEditRule,
20408
21157
  onDeletePress: onDeleteRule
20409
- }), [options, onDeleteRule]);
21158
+ }), [
21159
+ options,
21160
+ onEditRule,
21161
+ onDeleteRule
21162
+ ]);
20410
21163
  return /* @__PURE__ */ jsx("div", {
20411
21164
  className: "Layer__CategorizationRulesMobileList",
20412
21165
  children: /* @__PURE__ */ jsx(PaginatedMobileList, {
@@ -20693,12 +21446,15 @@ var CategorizationRuleColumns = /* @__PURE__ */ function(CategorizationRuleColum
20693
21446
  CategorizationRuleColumns["Category"] = "Category";
20694
21447
  CategorizationRuleColumns["Counterparty"] = "Counterparty";
20695
21448
  CategorizationRuleColumns["Direction"] = "Direction";
21449
+ CategorizationRuleColumns["Amount"] = "Amount";
21450
+ CategorizationRuleColumns["Edit"] = "Edit";
20696
21451
  CategorizationRuleColumns["Delete"] = "Delete";
20697
21452
  return CategorizationRuleColumns;
20698
21453
  }(CategorizationRuleColumns || {});
20699
21454
  var COMPONENT_NAME$14 = "CategorizationRulesTable";
20700
- var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, options, onDeleteRule, slots }) => {
21455
+ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, options, onEditRule, onDeleteRule, slots }) => {
20701
21456
  const { t } = useTranslation();
21457
+ const { formatCurrencyFromCents } = useIntlFormatter();
20702
21458
  const columnConfig = useMemo(() => [
20703
21459
  {
20704
21460
  id: CategorizationRuleColumns.Counterparty,
@@ -20716,6 +21472,14 @@ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, opt
20716
21472
  children: getCategorizationRuleDirectionLabel(row.original.bankDirectionFilter, t)
20717
21473
  })
20718
21474
  },
21475
+ {
21476
+ id: CategorizationRuleColumns.Amount,
21477
+ header: t("common:label.amount", "Amount"),
21478
+ cell: (row) => /* @__PURE__ */ jsx(Span, {
21479
+ ellipsis: true,
21480
+ children: getCategorizationRuleAmountLabel(row.original, formatCurrencyFromCents, t)
21481
+ })
21482
+ },
20719
21483
  {
20720
21484
  id: CategorizationRuleColumns.Category,
20721
21485
  header: t("common:label.category", "Category"),
@@ -20729,20 +21493,33 @@ var CategorizationRulesTable = ({ data, isLoading, isError, paginationProps, opt
20729
21493
  },
20730
21494
  isRowHeader: true
20731
21495
  },
21496
+ {
21497
+ id: CategorizationRuleColumns.Edit,
21498
+ cell: (row) => /* @__PURE__ */ jsx(Button$1, {
21499
+ inset: true,
21500
+ icon: true,
21501
+ onPress: () => onEditRule(row.original),
21502
+ "aria-label": t("categorizationRules:action.edit_rule", "Edit Rule"),
21503
+ variant: "ghost",
21504
+ children: /* @__PURE__ */ jsx(Pencil, { size: 16 })
21505
+ })
21506
+ },
20732
21507
  {
20733
21508
  id: CategorizationRuleColumns.Delete,
20734
21509
  cell: (row) => /* @__PURE__ */ jsx(Button$1, {
20735
21510
  inset: true,
20736
21511
  icon: true,
20737
21512
  onPress: () => onDeleteRule(row.original),
20738
- "aria-label": t("categorizationRules:action.delete_rule", "Delete rule"),
21513
+ "aria-label": t("categorizationRules:action.delete_rule", "Delete Rule"),
20739
21514
  variant: "ghost",
20740
21515
  children: /* @__PURE__ */ jsx(Trash2, { size: 16 })
20741
21516
  })
20742
21517
  }
20743
21518
  ], [
20744
21519
  t,
21520
+ formatCurrencyFromCents,
20745
21521
  options,
21522
+ onEditRule,
20746
21523
  onDeleteRule
20747
21524
  ]);
20748
21525
  return /* @__PURE__ */ jsx(PaginatedTable, {
@@ -20779,19 +21556,33 @@ var CategorizationRulesErrorState = () => {
20779
21556
  className: "Layer__CategorizationRulesView__ErrorState"
20780
21557
  });
20781
21558
  };
20782
- var CategorizationRulesHeader = ({ onGoBack }) => {
21559
+ var CategorizationRulesHeader = ({ onGoBack, onCreateRule }) => {
20783
21560
  const { t } = useTranslation();
20784
21561
  return /* @__PURE__ */ jsxs(HStack, {
21562
+ fluid: true,
21563
+ justify: "space-between",
20785
21564
  align: "center",
20786
- gap: "md",
20787
- children: [onGoBack && /* @__PURE__ */ jsx(Button$1, {
20788
- variant: "outlined",
20789
- icon: true,
20790
- onPress: onGoBack,
20791
- children: /* @__PURE__ */ jsx(BackArrow, {})
20792
- }), /* @__PURE__ */ jsx(Heading$2, {
20793
- size: "sm",
20794
- children: t("categorizationRules:label.categorization_rules", "Categorization Rules")
21565
+ gap: "xs",
21566
+ children: [/* @__PURE__ */ jsxs(HStack, {
21567
+ align: "center",
21568
+ gap: "md",
21569
+ children: [onGoBack && /* @__PURE__ */ jsx(Button$1, {
21570
+ variant: "outlined",
21571
+ icon: true,
21572
+ onPress: onGoBack,
21573
+ children: /* @__PURE__ */ jsx(BackArrow, {})
21574
+ }), /* @__PURE__ */ jsx(Heading$2, {
21575
+ size: "sm",
21576
+ children: t("categorizationRules:label.categorization_rules", "Categorization Rules")
21577
+ })]
21578
+ }), /* @__PURE__ */ jsx(HStack, {
21579
+ pie: "md",
21580
+ align: "center",
21581
+ gap: "xs",
21582
+ children: /* @__PURE__ */ jsxs(Button$1, {
21583
+ onPress: onCreateRule,
21584
+ children: [t("categorizationRules:action.create_rule", "Create Rule"), /* @__PURE__ */ jsx(Plus, { size: 16 })]
21585
+ })
20795
21586
  })]
20796
21587
  });
20797
21588
  };
@@ -20801,9 +21592,19 @@ var ResponsiveCategorizationRulesView = () => {
20801
21592
  const { t } = useTranslation();
20802
21593
  const [selectedRule, setSelectedRule] = useState(null);
20803
21594
  const [showDeletionConfirmationModal, setShowDeletionConfirmationModal] = useState(false);
21595
+ const [formState, setFormState] = useState(null);
20804
21596
  const { trigger: archiveCategorizationRuleTrigger } = useArchiveCategorizationRule();
20805
21597
  const { addToast } = useLayerContext();
20806
21598
  const { isMobile } = useSizeClass();
21599
+ const onCreateRule = useCallback(() => setFormState({ mode: "create" }), []);
21600
+ const onEditRule = useCallback((rule) => setFormState({
21601
+ mode: "edit",
21602
+ rule
21603
+ }), []);
21604
+ const onFormDrawerOpenChange = useCallback((isOpen) => {
21605
+ if (!isOpen) setFormState(null);
21606
+ }, []);
21607
+ const onFormSuccess = useCallback(() => setFormState(null), []);
20807
21608
  const { data: categories, isLoading: categoriesAreLoading } = useCategories({ mode: CategoriesListMode.All });
20808
21609
  const options = useMemo(() => {
20809
21610
  if (!categories) return [];
@@ -20853,9 +21654,10 @@ var ResponsiveCategorizationRulesView = () => {
20853
21654
  ]);
20854
21655
  const isLoading = data === void 0 || rulesAreLoading || categoriesAreLoading;
20855
21656
  const { toBankTransactionsTable } = useBankTransactionsNavigation();
21657
+ const DesktopHeader = useCallback(() => /* @__PURE__ */ jsx(CategorizationRulesHeader, { onCreateRule }), [onCreateRule]);
20856
21658
  const DesktopView = useMemo(() => /* @__PURE__ */ jsx(BaseDetailView, {
20857
21659
  slots: {
20858
- Header: CategorizationRulesHeader,
21660
+ Header: DesktopHeader,
20859
21661
  BackIcon: BackArrow
20860
21662
  },
20861
21663
  name: "CategorizationRulesDrawer",
@@ -20866,6 +21668,7 @@ var ResponsiveCategorizationRulesView = () => {
20866
21668
  isError,
20867
21669
  paginationProps,
20868
21670
  options,
21671
+ onEditRule,
20869
21672
  onDeleteRule,
20870
21673
  slots: {
20871
21674
  EmptyState: CategorizationRulesEmptyState,
@@ -20873,22 +21676,28 @@ var ResponsiveCategorizationRulesView = () => {
20873
21676
  }
20874
21677
  })
20875
21678
  }), [
21679
+ DesktopHeader,
20876
21680
  toBankTransactionsTable,
20877
21681
  categorizationRules,
20878
21682
  isLoading,
20879
21683
  isError,
20880
21684
  paginationProps,
20881
21685
  options,
21686
+ onEditRule,
20882
21687
  onDeleteRule
20883
21688
  ]);
20884
21689
  const MobileView = useMemo(() => /* @__PURE__ */ jsxs(VStack, {
20885
21690
  gap: "md",
20886
- children: [/* @__PURE__ */ jsx(CategorizationRulesHeader, { onGoBack: toBankTransactionsTable }), /* @__PURE__ */ jsx(CategorizationRulesMobileList, {
21691
+ children: [/* @__PURE__ */ jsx(CategorizationRulesHeader, {
21692
+ onGoBack: toBankTransactionsTable,
21693
+ onCreateRule
21694
+ }), /* @__PURE__ */ jsx(CategorizationRulesMobileList, {
20887
21695
  data: categorizationRules,
20888
21696
  isLoading,
20889
21697
  isError,
20890
21698
  paginationProps,
20891
21699
  options,
21700
+ onEditRule,
20892
21701
  onDeleteRule,
20893
21702
  slots: {
20894
21703
  EmptyState: CategorizationRulesEmptyState,
@@ -20897,30 +21706,41 @@ var ResponsiveCategorizationRulesView = () => {
20897
21706
  })]
20898
21707
  }), [
20899
21708
  toBankTransactionsTable,
21709
+ onCreateRule,
20900
21710
  categorizationRules,
20901
21711
  isLoading,
20902
21712
  isError,
20903
21713
  paginationProps,
20904
21714
  options,
21715
+ onEditRule,
20905
21716
  onDeleteRule
20906
21717
  ]);
20907
21718
  const selectedRuleCounterpartyLabel = (_ref = selectedRule && getCategorizationRuleCounterpartyLabel(selectedRule)) !== null && _ref !== void 0 ? _ref : t("bankTransactions:label.selected_counterparty", "this counterparty");
20908
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ResponsiveComponent, {
20909
- resolveVariant: resolveVariant$2,
20910
- slots: {
20911
- Desktop: DesktopView,
20912
- Mobile: MobileView
20913
- }
20914
- }), /* @__PURE__ */ jsx(BaseConfirmationModal, {
20915
- isOpen: showDeletionConfirmationModal,
20916
- onOpenChange: setShowDeletionConfirmationModal,
20917
- title: t("categorizationRules:prompt.delete_categorization_rule", "Delete categorization rule?"),
20918
- description: t("categorizationRules:label.transaction_no_longer_automatically_categorized", "Transactions will no longer automatically be categorized by this rule. Any transactions previously categorized to {{counterparty}} will not be affected.", { counterparty: selectedRuleCounterpartyLabel }),
20919
- onConfirm: archiveCategorizationRule,
20920
- confirmLabel: t("common:action.delete_label", "Delete"),
20921
- cancelLabel: t("common:action.cancel_label", "Cancel"),
20922
- useDrawer: isMobile
20923
- })] });
21719
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
21720
+ /* @__PURE__ */ jsx(ResponsiveComponent, {
21721
+ resolveVariant: resolveVariant$2,
21722
+ slots: useMemo(() => ({
21723
+ Desktop: DesktopView,
21724
+ Mobile: MobileView
21725
+ }), [DesktopView, MobileView])
21726
+ }),
21727
+ /* @__PURE__ */ jsx(BaseConfirmationModal, {
21728
+ isOpen: showDeletionConfirmationModal,
21729
+ onOpenChange: setShowDeletionConfirmationModal,
21730
+ title: t("categorizationRules:prompt.delete_categorization_rule", "Delete categorization rule?"),
21731
+ description: t("categorizationRules:label.transaction_no_longer_automatically_categorized", "Transactions will no longer automatically be categorized by this rule. Any transactions previously categorized to {{counterparty}} will not be affected.", { counterparty: selectedRuleCounterpartyLabel }),
21732
+ onConfirm: archiveCategorizationRule,
21733
+ confirmLabel: t("common:action.delete_label", "Delete"),
21734
+ cancelLabel: t("common:action.cancel_label", "Cancel"),
21735
+ useDrawer: isMobile
21736
+ }),
21737
+ /* @__PURE__ */ jsx(CategorizationRuleFormDrawer, {
21738
+ isOpen: !!formState,
21739
+ formState,
21740
+ onOpenChange: onFormDrawerOpenChange,
21741
+ onSuccess: onFormSuccess
21742
+ })
21743
+ ] });
20924
21744
  };
20925
21745
  //#endregion
20926
21746
  //#region src/components/ErrorBoundary/ErrorBoundaryMessage.tsx
@@ -31169,42 +31989,6 @@ var DebitCreditPill = ({ value, onChange, isReadOnly = false }) => {
31169
31989
  });
31170
31990
  };
31171
31991
  //#endregion
31172
- //#region src/components/LedgerAccountCombobox/LedgerAccountCombobox.tsx
31173
- var LedgerAccountCombobox = ({ label, value, mode, onValueChange, isReadOnly, showLabel, className }) => {
31174
- const { data: categories, isLoading } = useCategories({ mode });
31175
- const options = useMemo(() => {
31176
- if (!categories) return [];
31177
- return getLeafCategories$1(categories).map((category) => new CategoryAsOption(category));
31178
- }, [categories]);
31179
- const selectedCategory = useMemo(() => {
31180
- var _options$find;
31181
- if (!value) return null;
31182
- return (_options$find = options.find((option) => ClassificationEquivalence(value, option.classification))) !== null && _options$find !== void 0 ? _options$find : null;
31183
- }, [options, value]);
31184
- const onSelectedValueChange = useCallback((option) => {
31185
- var _option$classificatio;
31186
- onValueChange((_option$classificatio = option === null || option === void 0 ? void 0 : option.classification) !== null && _option$classificatio !== void 0 ? _option$classificatio : null);
31187
- }, [onValueChange]);
31188
- const inputId = useId();
31189
- return /* @__PURE__ */ jsxs(VStack, {
31190
- gap: "3xs",
31191
- className,
31192
- children: [showLabel && /* @__PURE__ */ jsx(Label$2, {
31193
- size: "sm",
31194
- htmlFor: inputId,
31195
- children: label
31196
- }), /* @__PURE__ */ jsx(ComboBox, _objectSpread2({
31197
- options,
31198
- onSelectedValueChange,
31199
- selectedValue: selectedCategory,
31200
- inputId,
31201
- isReadOnly,
31202
- isLoading,
31203
- isClearable: false
31204
- }, !showLabel && { "aria-label": label }))]
31205
- });
31206
- };
31207
- //#endregion
31208
31992
  //#region src/components/Journal/JournalEntryForm/JournalEntryLineItem.tsx
31209
31993
  var JOURNAL_ENTRY_FORM_CSS_PREFIX$1 = "Layer__JournalEntryForm";
31210
31994
  var JournalEntryLineItem = ({ form, index, displayIndex, isReadOnly, onDeleteLine, showTags = false }) => {
@@ -38223,7 +39007,7 @@ var getInvoiceFormLineItem = (lineItem) => {
38223
39007
  return {
38224
39008
  description: description || "",
38225
39009
  quantity: toNonRecursiveBigDecimal(quantity),
38226
- unitPrice: toNonRecursiveBigDecimal(convertCentsToBigDecimal(unitPrice)),
39010
+ unitPrice: convertCentsToNonRecursiveBigDecimal(unitPrice),
38227
39011
  amount: toNonRecursiveBigDecimal(getInvoiceLineItemAmount(lineItem)),
38228
39012
  isTaxable: lineItem.salesTaxTotal > 0
38229
39013
  };
@@ -38289,7 +39073,7 @@ var convertInvoiceFormToParams = (form) => {
38289
39073
  lineItems: form.lineItems.filter((item) => !InvoiceFormLineItemEquivalence(EMPTY_LINE_ITEM, item)).map((item) => {
38290
39074
  const baseLineItem = {
38291
39075
  description: item.description.trim(),
38292
- unitPrice: convertBigDecimalToCents(fromNonRecursiveBigDecimal(item.unitPrice)),
39076
+ unitPrice: convertNonRecursiveBigDecimalToCents(item.unitPrice),
38293
39077
  quantity: fromNonRecursiveBigDecimal(item.quantity)
38294
39078
  };
38295
39079
  if (!item.isTaxable || BigDecimal.equals(form.taxRate, BIG_DECIMAL_ZERO)) return baseLineItem;
@@ -47440,7 +48224,7 @@ var getServiceFormDefaultValues = ({ service, initialName }) => {
47440
48224
  var _ref, _service$name;
47441
48225
  return {
47442
48226
  name: (_ref = (_service$name = service === null || service === void 0 ? void 0 : service.name) !== null && _service$name !== void 0 ? _service$name : initialName) !== null && _ref !== void 0 ? _ref : "",
47443
- hourlyRate: (service === null || service === void 0 ? void 0 : service.billableRatePerHourAmount) != null && !Number.isNaN(service.billableRatePerHourAmount) ? toNonRecursiveBigDecimal(convertCentsToBigDecimal(service.billableRatePerHourAmount)) : null
48227
+ hourlyRate: (service === null || service === void 0 ? void 0 : service.billableRatePerHourAmount) != null && !Number.isNaN(service.billableRatePerHourAmount) ? convertCentsToNonRecursiveBigDecimal(service.billableRatePerHourAmount) : null
47444
48228
  };
47445
48229
  };
47446
48230
  function useServiceForm(props) {
@@ -47461,7 +48245,7 @@ function useServiceForm(props) {
47461
48245
  const onSubmit = useCallback(function() {
47462
48246
  var _ref2 = _asyncToGenerator(function* ({ value }) {
47463
48247
  const trimmedName = value.name.trim();
47464
- const billableRatePerHourAmount = value.hourlyRate === null ? void 0 : convertBigDecimalToCents(fromNonRecursiveBigDecimal(value.hourlyRate));
48248
+ const billableRatePerHourAmount = value.hourlyRate === null ? void 0 : convertNonRecursiveBigDecimalToCents(value.hourlyRate);
47465
48249
  setSubmitError(null);
47466
48250
  try {
47467
48251
  if (mode === "edit") yield updateService({