@layerfi/components 0.1.106 → 0.1.107-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.
@@ -3779,7 +3779,7 @@ var require_lodash = __commonJS({
3779
3779
  }
3780
3780
  function reject(collection, predicate) {
3781
3781
  var func = isArray(collection) ? arrayFilter : baseFilter;
3782
- return func(collection, negate(getIteratee(predicate, 3)));
3782
+ return func(collection, negate2(getIteratee(predicate, 3)));
3783
3783
  }
3784
3784
  function sample(collection) {
3785
3785
  var func = isArray(collection) ? arraySample : baseSample;
@@ -3893,17 +3893,17 @@ var require_lodash = __commonJS({
3893
3893
  result2.placeholder = curryRight.placeholder;
3894
3894
  return result2;
3895
3895
  }
3896
- function debounce7(func, wait, options) {
3896
+ function debounce7(func, wait, options2) {
3897
3897
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
3898
3898
  if (typeof func != "function") {
3899
3899
  throw new TypeError2(FUNC_ERROR_TEXT);
3900
3900
  }
3901
3901
  wait = toNumber(wait) || 0;
3902
- if (isObject(options)) {
3903
- leading = !!options.leading;
3904
- maxing = "maxWait" in options;
3905
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
3906
- trailing = "trailing" in options ? !!options.trailing : trailing;
3902
+ if (isObject(options2)) {
3903
+ leading = !!options2.leading;
3904
+ maxing = "maxWait" in options2;
3905
+ maxWait = maxing ? nativeMax(toNumber(options2.maxWait) || 0, wait) : maxWait;
3906
+ trailing = "trailing" in options2 ? !!options2.trailing : trailing;
3907
3907
  }
3908
3908
  function invokeFunc(time) {
3909
3909
  var args = lastArgs, thisArg = lastThis;
@@ -4000,7 +4000,7 @@ var require_lodash = __commonJS({
4000
4000
  return memoized;
4001
4001
  }
4002
4002
  memoize.Cache = MapCache;
4003
- function negate(predicate) {
4003
+ function negate2(predicate) {
4004
4004
  if (typeof predicate != "function") {
4005
4005
  throw new TypeError2(FUNC_ERROR_TEXT);
4006
4006
  }
@@ -4064,14 +4064,14 @@ var require_lodash = __commonJS({
4064
4064
  return apply(func, this, otherArgs);
4065
4065
  });
4066
4066
  }
4067
- function throttle(func, wait, options) {
4067
+ function throttle(func, wait, options2) {
4068
4068
  var leading = true, trailing = true;
4069
4069
  if (typeof func != "function") {
4070
4070
  throw new TypeError2(FUNC_ERROR_TEXT);
4071
4071
  }
4072
- if (isObject(options)) {
4073
- leading = "leading" in options ? !!options.leading : leading;
4074
- trailing = "trailing" in options ? !!options.trailing : trailing;
4072
+ if (isObject(options2)) {
4073
+ leading = "leading" in options2 ? !!options2.leading : leading;
4074
+ trailing = "trailing" in options2 ? !!options2.trailing : trailing;
4075
4075
  }
4076
4076
  return debounce7(func, wait, {
4077
4077
  "leading": leading,
@@ -4161,7 +4161,7 @@ var require_lodash = __commonJS({
4161
4161
  function isEqual2(value, other) {
4162
4162
  return baseIsEqual(value, other);
4163
4163
  }
4164
- function isEqualWith(value, other, customizer) {
4164
+ function isEqualWith2(value, other, customizer) {
4165
4165
  customizer = typeof customizer == "function" ? customizer : undefined2;
4166
4166
  var result2 = customizer ? customizer(value, other) : undefined2;
4167
4167
  return result2 === undefined2 ? baseIsEqual(value, other, undefined2, customizer) : !!result2;
@@ -4469,7 +4469,7 @@ var require_lodash = __commonJS({
4469
4469
  return result2;
4470
4470
  });
4471
4471
  function omitBy(object, predicate) {
4472
- return pickBy(object, negate(getIteratee(predicate)));
4472
+ return pickBy(object, negate2(getIteratee(predicate)));
4473
4473
  }
4474
4474
  var pick = flatRest(function(object, paths) {
4475
4475
  return object == null ? {} : basePick(object, paths);
@@ -4714,20 +4714,20 @@ var require_lodash = __commonJS({
4714
4714
  target = baseToString(target);
4715
4715
  return string.slice(position, position + target.length) == target;
4716
4716
  }
4717
- function template(string, options, guard) {
4717
+ function template(string, options2, guard) {
4718
4718
  var settings = lodash.templateSettings;
4719
- if (guard && isIterateeCall(string, options, guard)) {
4720
- options = undefined2;
4719
+ if (guard && isIterateeCall(string, options2, guard)) {
4720
+ options2 = undefined2;
4721
4721
  }
4722
4722
  string = toString(string);
4723
- options = assignInWith({}, options, settings, customDefaultsAssignIn);
4724
- var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
4725
- var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
4723
+ options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
4724
+ var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
4725
+ var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
4726
4726
  var reDelimiters = RegExp2(
4727
- (options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$",
4727
+ (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
4728
4728
  "g"
4729
4729
  );
4730
- var sourceURL = "//# sourceURL=" + (hasOwnProperty.call(options, "sourceURL") ? (options.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
4730
+ var sourceURL = "//# sourceURL=" + (hasOwnProperty.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
4731
4731
  string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset2) {
4732
4732
  interpolateValue || (interpolateValue = esTemplateValue);
4733
4733
  source += string.slice(index, offset2).replace(reUnescapedString, escapeStringChar);
@@ -4746,7 +4746,7 @@ var require_lodash = __commonJS({
4746
4746
  return match;
4747
4747
  });
4748
4748
  source += "';\n";
4749
- var variable = hasOwnProperty.call(options, "variable") && options.variable;
4749
+ var variable = hasOwnProperty.call(options2, "variable") && options2.variable;
4750
4750
  if (!variable) {
4751
4751
  source = "with (obj) {\n" + source + "\n}\n";
4752
4752
  } else if (reForbiddenIdentifierChars.test(variable)) {
@@ -4802,12 +4802,12 @@ var require_lodash = __commonJS({
4802
4802
  var strSymbols = stringToArray(string), start = charsStartIndex(strSymbols, stringToArray(chars));
4803
4803
  return castSlice(strSymbols, start).join("");
4804
4804
  }
4805
- function truncate(string, options) {
4805
+ function truncate(string, options2) {
4806
4806
  var length = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
4807
- if (isObject(options)) {
4808
- var separator = "separator" in options ? options.separator : separator;
4809
- length = "length" in options ? toInteger(options.length) : length;
4810
- omission = "omission" in options ? baseToString(options.omission) : omission;
4807
+ if (isObject(options2)) {
4808
+ var separator = "separator" in options2 ? options2.separator : separator;
4809
+ length = "length" in options2 ? toInteger(options2.length) : length;
4810
+ omission = "omission" in options2 ? baseToString(options2.omission) : omission;
4811
4811
  }
4812
4812
  string = toString(string);
4813
4813
  var strLength = string.length;
@@ -4932,15 +4932,15 @@ var require_lodash = __commonJS({
4932
4932
  return baseInvoke(object, path, args);
4933
4933
  };
4934
4934
  });
4935
- function mixin(object, source, options) {
4935
+ function mixin(object, source, options2) {
4936
4936
  var props = keys(source), methodNames = baseFunctions(source, props);
4937
- if (options == null && !(isObject(source) && (methodNames.length || !props.length))) {
4938
- options = source;
4937
+ if (options2 == null && !(isObject(source) && (methodNames.length || !props.length))) {
4938
+ options2 = source;
4939
4939
  source = object;
4940
4940
  object = this;
4941
4941
  methodNames = baseFunctions(source, keys(source));
4942
4942
  }
4943
- var chain2 = !(isObject(options) && "chain" in options) || !!options.chain, isFunc = isFunction(object);
4943
+ var chain2 = !(isObject(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction(object);
4944
4944
  arrayEach(methodNames, function(methodName) {
4945
4945
  var func = source[methodName];
4946
4946
  object[methodName] = func;
@@ -5136,7 +5136,7 @@ var require_lodash = __commonJS({
5136
5136
  lodash.method = method;
5137
5137
  lodash.methodOf = methodOf;
5138
5138
  lodash.mixin = mixin;
5139
- lodash.negate = negate;
5139
+ lodash.negate = negate2;
5140
5140
  lodash.nthArg = nthArg;
5141
5141
  lodash.omit = omit;
5142
5142
  lodash.omitBy = omitBy;
@@ -5272,7 +5272,7 @@ var require_lodash = __commonJS({
5272
5272
  lodash.isElement = isElement;
5273
5273
  lodash.isEmpty = isEmpty;
5274
5274
  lodash.isEqual = isEqual2;
5275
- lodash.isEqualWith = isEqualWith;
5275
+ lodash.isEqualWith = isEqualWith2;
5276
5276
  lodash.isError = isError;
5277
5277
  lodash.isFinite = isFinite;
5278
5278
  lodash.isFunction = isFunction;
@@ -5443,7 +5443,7 @@ var require_lodash = __commonJS({
5443
5443
  });
5444
5444
  });
5445
5445
  LazyWrapper.prototype.reject = function(predicate) {
5446
- return this.filter(negate(getIteratee(predicate)));
5446
+ return this.filter(negate2(getIteratee(predicate)));
5447
5447
  };
5448
5448
  LazyWrapper.prototype.slice = function(start, end) {
5449
5449
  start = toInteger(start);
@@ -5570,7 +5570,7 @@ import { useState as useState5 } from "react";
5570
5570
  import { useReducer, useEffect as useEffect2 } from "react";
5571
5571
 
5572
5572
  // package.json
5573
- var version = "0.1.106";
5573
+ var version = "0.1.107-alpha";
5574
5574
 
5575
5575
  // src/models/APIError.ts
5576
5576
  var APIError = class _APIError extends Error {
@@ -5616,21 +5616,21 @@ var CUSTOM_PREFIX = "Layer-";
5616
5616
  var CUSTOM_HEADERS = {
5617
5617
  [`${CUSTOM_PREFIX}React-Version`]: version
5618
5618
  };
5619
- var get = (url) => (baseUrl, accessToken, options) => () => fetch(`${baseUrl}${url((options == null ? void 0 : options.params) || {})}`, {
5619
+ var get = (url) => (baseUrl, accessToken, options2) => () => fetch(`${baseUrl}${url((options2 == null ? void 0 : options2.params) || {})}`, {
5620
5620
  headers: __spreadValues({
5621
5621
  "Authorization": "Bearer " + (accessToken || ""),
5622
5622
  "Content-Type": "application/json"
5623
5623
  }, CUSTOM_HEADERS),
5624
5624
  method: "GET"
5625
5625
  }).then((res) => handleResponse(res)).catch((error) => handleException(error));
5626
- var request = (verb) => (url) => (baseUrl, accessToken, options) => fetch(`${baseUrl}${url((options == null ? void 0 : options.params) || {})}`, {
5626
+ var request = (verb) => (url) => (baseUrl, accessToken, options2) => fetch(`${baseUrl}${url((options2 == null ? void 0 : options2.params) || {})}`, {
5627
5627
  headers: __spreadValues({
5628
5628
  "Authorization": "Bearer " + (accessToken || ""),
5629
5629
  "Content-Type": "application/json",
5630
5630
  "Cache-Control": "no-cache"
5631
5631
  }, CUSTOM_HEADERS),
5632
5632
  method: verb.toUpperCase(),
5633
- body: JSON.stringify(options == null ? void 0 : options.body)
5633
+ body: JSON.stringify(options2 == null ? void 0 : options2.body)
5634
5634
  }).then((res) => handleResponse(res)).catch((error) => handleException(error));
5635
5635
  var patch = request("patch");
5636
5636
  var post = request("post");
@@ -5937,6 +5937,7 @@ var breakPlaidItemConnection = post(
5937
5937
 
5938
5938
  // src/utils/time/timeUtils.ts
5939
5939
  import { differenceInDays, formatISO as formatISO2 } from "date-fns";
5940
+ import { ZonedDateTime } from "@internationalized/date";
5940
5941
  var toLocalDateString = (date) => formatISO2(date.valueOf(), { representation: "date" });
5941
5942
  function getDueDifference(dueDate) {
5942
5943
  const today = /* @__PURE__ */ new Date();
@@ -5945,6 +5946,9 @@ function getDueDifference(dueDate) {
5945
5946
  normalizedDue.setHours(0, 0, 0, 0);
5946
5947
  return differenceInDays(normalizedDue, today);
5947
5948
  }
5949
+ function isZonedDateTime(val) {
5950
+ return val instanceof ZonedDateTime;
5951
+ }
5948
5952
 
5949
5953
  // src/api/layer/profit_and_loss.ts
5950
5954
  var getProfitAndLoss = (apiUrl, accessToken, params) => {
@@ -7118,12 +7122,12 @@ var RANGE_MODE_LOOKUP = {
7118
7122
  }
7119
7123
  };
7120
7124
  function withCorrectedRange(fn) {
7121
- return (options) => {
7122
- const { start, end } = options;
7125
+ return (options2) => {
7126
+ const { start, end } = options2;
7123
7127
  if (start > end) {
7124
- return fn(__spreadProps(__spreadValues({}, options), { start: end, end: start }));
7128
+ return fn(__spreadProps(__spreadValues({}, options2), { start: end, end: start }));
7125
7129
  }
7126
- return fn(__spreadProps(__spreadValues({}, options), { start, end }));
7130
+ return fn(__spreadProps(__spreadValues({}, options2), { start, end }));
7127
7131
  };
7128
7132
  }
7129
7133
  function buildStore() {
@@ -7356,7 +7360,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7356
7360
  connection_external_id: "11111",
7357
7361
  connection_needs_repair_as_of: null,
7358
7362
  is_syncing: true,
7359
- user_created: false
7363
+ user_created: false,
7364
+ reconnect_with_new_credentials: false
7360
7365
  },
7361
7366
  {
7362
7367
  id: "f98ec50a-c370-484d-a35b-d00207436075",
@@ -7381,7 +7386,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7381
7386
  connection_external_id: "11111",
7382
7387
  connection_needs_repair_as_of: null,
7383
7388
  is_syncing: false,
7384
- user_created: false
7389
+ user_created: false,
7390
+ reconnect_with_new_credentials: false
7385
7391
  },
7386
7392
  {
7387
7393
  id: "843f1748-fdaa-422d-a73d-2489a40c8dc7",
@@ -7406,7 +7412,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7406
7412
  connection_external_id: "11111",
7407
7413
  connection_needs_repair_as_of: "2024-03-06T16:44:35.715458Z",
7408
7414
  is_syncing: false,
7409
- user_created: false
7415
+ user_created: false,
7416
+ reconnect_with_new_credentials: false
7410
7417
  },
7411
7418
  {
7412
7419
  id: "8f430e29-e339-4d71-a08a-fce469c7a7c1",
@@ -7431,7 +7438,8 @@ var LINKED_ACCOUNTS_MOCK_DATA = [
7431
7438
  connection_external_id: "11111",
7432
7439
  connection_needs_repair_as_of: null,
7433
7440
  is_syncing: false,
7434
- user_created: false
7441
+ user_created: false,
7442
+ reconnect_with_new_credentials: false
7435
7443
  }
7436
7444
  ];
7437
7445
 
@@ -9211,10 +9219,10 @@ import { jsx as jsx21 } from "react/jsx-runtime";
9211
9219
  var Tooltip = (_a) => {
9212
9220
  var _b = _a, {
9213
9221
  children
9214
- } = _b, options = __objRest(_b, [
9222
+ } = _b, options2 = __objRest(_b, [
9215
9223
  "children"
9216
9224
  ]);
9217
- const tooltip = useTooltip(options);
9225
+ const tooltip = useTooltip(options2);
9218
9226
  return /* @__PURE__ */ jsx21(TooltipContext.Provider, { value: tooltip, children });
9219
9227
  };
9220
9228
  var TooltipTrigger = forwardRef3(function TooltipTrigger2(_a, propRef) {
@@ -10405,6 +10413,7 @@ var DataState = ({
10405
10413
  icon,
10406
10414
  spacing,
10407
10415
  inline,
10416
+ titleSize = inline ? "sm" /* sm */ : "lg" /* lg */,
10408
10417
  className
10409
10418
  }) => {
10410
10419
  const baseClassName = classNames18(
@@ -10422,7 +10431,7 @@ var DataState = ({
10422
10431
  Text,
10423
10432
  {
10424
10433
  as: "span",
10425
- size: inline ? "sm" /* sm */ : "lg" /* lg */,
10434
+ size: titleSize,
10426
10435
  weight: "bold" /* bold */,
10427
10436
  className: "Layer__data-state__title",
10428
10437
  children: title
@@ -11812,6 +11821,7 @@ var LinkedAccountItemThumb = ({
11812
11821
  }) => {
11813
11822
  var _a;
11814
11823
  const {
11824
+ addConnection,
11815
11825
  removeConnection,
11816
11826
  repairConnection,
11817
11827
  confirmAccount: confirmAccount2,
@@ -11848,10 +11858,16 @@ var LinkedAccountItemThumb = ({
11848
11858
  name: "Repair connection",
11849
11859
  action: () => {
11850
11860
  if (account.connection_external_id) {
11851
- void repairConnection(
11852
- account.external_account_source,
11853
- account.connection_external_id
11854
- );
11861
+ if (account.reconnect_with_new_credentials) {
11862
+ addConnection(
11863
+ account.external_account_source
11864
+ );
11865
+ } else {
11866
+ repairConnection(
11867
+ account.external_account_source,
11868
+ account.connection_external_id
11869
+ );
11870
+ }
11855
11871
  }
11856
11872
  }
11857
11873
  }
@@ -12585,7 +12601,7 @@ import classNames28 from "classnames";
12585
12601
  import { jsx as jsx84, jsxs as jsxs49 } from "react/jsx-runtime";
12586
12602
  var Select = ({
12587
12603
  name,
12588
- options,
12604
+ options: options2,
12589
12605
  className,
12590
12606
  classNamePrefix = "Layer__select",
12591
12607
  value,
@@ -12613,7 +12629,7 @@ var Select = ({
12613
12629
  className: baseClassName,
12614
12630
  classNamePrefix,
12615
12631
  placeholder: placeholder != null ? placeholder : "Select...",
12616
- options,
12632
+ options: options2,
12617
12633
  formatOptionLabel: formatOptionLabel2,
12618
12634
  value,
12619
12635
  onChange: (newValue) => newValue && onChange(newValue),
@@ -12641,7 +12657,7 @@ import classNames30 from "classnames";
12641
12657
  import { jsx as jsx86, jsxs as jsxs51 } from "react/jsx-runtime";
12642
12658
  var MultiSelect = ({
12643
12659
  name,
12644
- options,
12660
+ options: options2,
12645
12661
  className,
12646
12662
  classNamePrefix = "Layer__select",
12647
12663
  value,
@@ -12670,7 +12686,7 @@ var MultiSelect = ({
12670
12686
  className: baseClassName,
12671
12687
  classNamePrefix,
12672
12688
  placeholder: placeholder != null ? placeholder : "Select...",
12673
- options,
12689
+ options: options2,
12674
12690
  value,
12675
12691
  defaultValue: defaultValue2,
12676
12692
  onChange: (newValue) => newValue && onChange(newValue),
@@ -13403,7 +13419,7 @@ function useBulkSetOpeningBalanceAndDate(data, { onSuccess }) {
13403
13419
  // src/utils/format.ts
13404
13420
  import { parseISO as parseISO3, format as formatDateFns } from "date-fns";
13405
13421
  var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
13406
- var formatPercent = (value, options) => {
13422
+ var formatPercent = (value, options2) => {
13407
13423
  if (!value && value !== 0) {
13408
13424
  return;
13409
13425
  }
@@ -13430,7 +13446,7 @@ var formatPercent = (value, options) => {
13430
13446
  maximumFractionDigits: 0
13431
13447
  };
13432
13448
  }
13433
- return val.toLocaleString("en-US", __spreadValues(__spreadValues({}, defaultOptions), options));
13449
+ return val.toLocaleString("en-US", __spreadValues(__spreadValues({}, defaultOptions), options2));
13434
13450
  };
13435
13451
  var humanizeEnum = (text) => {
13436
13452
  return capitalizeFirstLetter(text.replace(/_/gi, " ").toLowerCase());
@@ -14147,12 +14163,12 @@ import { useState as useState21 } from "react";
14147
14163
  import classNames33 from "classnames";
14148
14164
  import { jsx as jsx100, jsxs as jsxs61 } from "react/jsx-runtime";
14149
14165
  var ActionableList = ({
14150
- options,
14166
+ options: options2,
14151
14167
  onClick,
14152
14168
  selectedId,
14153
14169
  showDescriptions = false
14154
14170
  }) => {
14155
- return /* @__PURE__ */ jsx100("ul", { className: "Layer__actionable-list", children: options.map((x, idx) => /* @__PURE__ */ jsxs61(
14171
+ return /* @__PURE__ */ jsx100("ul", { className: "Layer__actionable-list", children: options2.map((x, idx) => /* @__PURE__ */ jsxs61(
14156
14172
  "li",
14157
14173
  {
14158
14174
  role: "button",
@@ -14584,7 +14600,7 @@ var CategorySelect = ({
14584
14600
  }
14585
14601
  ] : [];
14586
14602
  const categoryOptions = flattenCategories2(categories != null ? categories : []);
14587
- const options = [
14603
+ const options2 = [
14588
14604
  ...matchOptions,
14589
14605
  ...suggestedOptions,
14590
14606
  ...allCategoriesDivider,
@@ -14611,7 +14627,7 @@ var CategorySelect = ({
14611
14627
  classNames: {
14612
14628
  menu: () => "Layer__select__menu--lg"
14613
14629
  },
14614
- options,
14630
+ options: options2,
14615
14631
  isSearchable: true,
14616
14632
  placeholder,
14617
14633
  defaultValue: selected,
@@ -15489,7 +15505,7 @@ import { jsx as jsx114, jsxs as jsxs73 } from "react/jsx-runtime";
15489
15505
  import { createElement } from "react";
15490
15506
  var Toggle = ({
15491
15507
  name,
15492
- options,
15508
+ options: options2,
15493
15509
  selected,
15494
15510
  onChange,
15495
15511
  size = "medium" /* medium */
@@ -15498,8 +15514,8 @@ var Toggle = ({
15498
15514
  const [thumbPos, setThumbPos] = useState23({ left: 0, width: 0 });
15499
15515
  const [initialized, setInitialized] = useState23(false);
15500
15516
  const activeOption = useMemo14(() => {
15501
- return selected ? selected : options.length > 0 ? options[0].value : void 0;
15502
- }, [selected, options]);
15517
+ return selected ? selected : options2.length > 0 ? options2[0].value : void 0;
15518
+ }, [selected, options2]);
15503
15519
  const toggleRef = useElementSize((_a, _b, c) => {
15504
15520
  if (c.width && (c == null ? void 0 : c.width) !== currentWidth) {
15505
15521
  setCurrentWidth(c.width);
@@ -15549,7 +15565,7 @@ var Toggle = ({
15549
15565
  updateThumbPosition(selectedIndex);
15550
15566
  }, [currentWidth]);
15551
15567
  const getSelectedIndex = () => {
15552
- const selectedIndex = options.findIndex(
15568
+ const selectedIndex = options2.findIndex(
15553
15569
  (option) => option.value === activeOption
15554
15570
  );
15555
15571
  if (selectedIndex === -1) {
@@ -15558,7 +15574,7 @@ var Toggle = ({
15558
15574
  return selectedIndex;
15559
15575
  };
15560
15576
  return /* @__PURE__ */ jsxs73("div", { className: baseClassName, ref: toggleRef, children: [
15561
- options.map((option, index) => {
15577
+ options2.map((option, index) => {
15562
15578
  var _a;
15563
15579
  return /* @__PURE__ */ createElement(
15564
15580
  ToggleOption,
@@ -16505,7 +16521,7 @@ function ComboBox(_a) {
16505
16521
  className,
16506
16522
  selectedValue,
16507
16523
  onSelectedValueChange,
16508
- options,
16524
+ options: options2,
16509
16525
  groups,
16510
16526
  onInputValueChange,
16511
16527
  placeholder,
@@ -16517,6 +16533,7 @@ function ComboBox(_a) {
16517
16533
  isMutating,
16518
16534
  isSearchable = true,
16519
16535
  isClearable = true,
16536
+ isReadOnly = false,
16520
16537
  displayDisabledAsSelected
16521
16538
  } = _b, ariaProps = __objRest(_b, [
16522
16539
  "className",
@@ -16534,6 +16551,7 @@ function ComboBox(_a) {
16534
16551
  "isMutating",
16535
16552
  "isSearchable",
16536
16553
  "isClearable",
16554
+ "isReadOnly",
16537
16555
  "displayDisabledAsSelected"
16538
16556
  ]);
16539
16557
  const internalInputId = useId();
@@ -16567,7 +16585,7 @@ function ComboBox(_a) {
16567
16585
  }, ariaProps), {
16568
16586
  value: selectedValue,
16569
16587
  onChange: onSelectedValueChange,
16570
- options: options != null ? options : groups,
16588
+ options: options2 != null ? options2 : groups,
16571
16589
  onInputChange: onInputValueChange,
16572
16590
  escapeClearsValue: true,
16573
16591
  placeholder,
@@ -16579,11 +16597,15 @@ function ComboBox(_a) {
16579
16597
  control: ({ isFocused, isDisabled: isDisabled2 }) => classNames41(
16580
16598
  COMBO_BOX_CLASS_NAMES.CONTROL,
16581
16599
  isFocused && `${COMBO_BOX_CLASS_NAMES.CONTROL}--focused`,
16582
- isDisabled2 && `${COMBO_BOX_CLASS_NAMES.CONTROL}--disabled`
16600
+ isDisabled2 && `${COMBO_BOX_CLASS_NAMES.CONTROL}--disabled`,
16601
+ isReadOnly && `${COMBO_BOX_CLASS_NAMES.CONTROL}--readonly`
16583
16602
  ),
16584
16603
  valueContainer: () => COMBO_BOX_CLASS_NAMES.VALUE_CONTAINER,
16585
16604
  placeholder: () => COMBO_BOX_CLASS_NAMES.PLACEHOLDER,
16586
- indicatorsContainer: () => COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER,
16605
+ indicatorsContainer: () => classNames41(
16606
+ COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER,
16607
+ isReadOnly && `${COMBO_BOX_CLASS_NAMES.INDICATORS_CONTAINER}--readonly`
16608
+ ),
16587
16609
  menu: () => COMBO_BOX_CLASS_NAMES.MENU,
16588
16610
  menuList: () => COMBO_BOX_CLASS_NAMES.MENU_LIST,
16589
16611
  group: () => COMBO_BOX_CLASS_NAMES.GROUP
@@ -16598,10 +16620,11 @@ function ComboBox(_a) {
16598
16620
  DropdownIndicator: CustomDropdownIndicatorRef.current,
16599
16621
  SingleValue: CustomSingleValue
16600
16622
  },
16601
- isClearable,
16623
+ isClearable: isClearable && !isReadOnly,
16602
16624
  isDisabled,
16603
16625
  isLoading: isLoading || isMutating,
16604
- isSearchable
16626
+ isSearchable: isSearchable && !isReadOnly,
16627
+ openMenuOnClick: !isReadOnly
16605
16628
  })
16606
16629
  ),
16607
16630
  isError ? /* @__PURE__ */ jsx118(HStack, { justify: "end", children: ErrorMessage != null ? ErrorMessage : /* @__PURE__ */ jsx118(
@@ -18139,7 +18162,6 @@ var ExpandedBankTransactionRow = forwardRef15(
18139
18162
  TextButton,
18140
18163
  {
18141
18164
  onClick: addSplit,
18142
- disabled: rowState.splits.length > 5,
18143
18165
  children: "Add new split"
18144
18166
  }
18145
18167
  ) : /* @__PURE__ */ jsx128(
@@ -18148,7 +18170,6 @@ var ExpandedBankTransactionRow = forwardRef15(
18148
18170
  onClick: addSplit,
18149
18171
  rightIcon: /* @__PURE__ */ jsx128(ScissorsFullOpen_default, { size: 14 }),
18150
18172
  variant: "secondary" /* secondary */,
18151
- disabled: rowState.splits.length > 5,
18152
18173
  children: "Split"
18153
18174
  }
18154
18175
  ) }) : /* @__PURE__ */ jsx128(Fragment16, {})
@@ -19140,16 +19161,16 @@ var BusinessForm = ({
19140
19161
  setShowRetry(true);
19141
19162
  }
19142
19163
  }, [bankTransaction.error]);
19143
- const options = useMemo25(() => {
19164
+ const options2 = useMemo25(() => {
19144
19165
  var _a;
19145
- const options2 = ((_a = bankTransaction == null ? void 0 : bankTransaction.categorization_flow) == null ? void 0 : _a.type) === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions.map(
19166
+ const options3 = ((_a = bankTransaction == null ? void 0 : bankTransaction.categorization_flow) == null ? void 0 : _a.type) === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions.map(
19146
19167
  (x) => mapCategoryToOption(x)
19147
19168
  ) : [];
19148
- if (selectedCategory && !options2.find((x) => x.id === (selectedCategory == null ? void 0 : selectedCategory.id))) {
19149
- options2.unshift(selectedCategory);
19169
+ if (selectedCategory && !options3.find((x) => x.id === (selectedCategory == null ? void 0 : selectedCategory.id))) {
19170
+ options3.unshift(selectedCategory);
19150
19171
  }
19151
- if (options2.length) {
19152
- options2.push({
19172
+ if (options3.length) {
19173
+ options3.push({
19153
19174
  label: "See all categories",
19154
19175
  id: "SELECT_CATEGORY",
19155
19176
  value: {
@@ -19159,7 +19180,7 @@ var BusinessForm = ({
19159
19180
  asLink: true
19160
19181
  });
19161
19182
  }
19162
- return options2;
19183
+ return options3;
19163
19184
  }, [bankTransaction, selectedCategory]);
19164
19185
  const onDrawerCategorySelect = (value) => {
19165
19186
  close2();
@@ -19214,7 +19235,7 @@ var BusinessForm = ({
19214
19235
  showCategorization ? /* @__PURE__ */ jsx140(
19215
19236
  ActionableList,
19216
19237
  {
19217
- options,
19238
+ options: options2,
19218
19239
  onClick: onCategorySelect,
19219
19240
  selectedId: selectedCategory == null ? void 0 : selectedCategory.id,
19220
19241
  showDescriptions: showTooltips
@@ -19258,7 +19279,7 @@ var BusinessForm = ({
19258
19279
  icon: /* @__PURE__ */ jsx140(Paperclip_default, {})
19259
19280
  }
19260
19281
  ),
19261
- options.length === 0 ? /* @__PURE__ */ jsx140(
19282
+ options2.length === 0 ? /* @__PURE__ */ jsx140(
19262
19283
  Button,
19263
19284
  {
19264
19285
  onClick: openDrawer,
@@ -19267,7 +19288,7 @@ var BusinessForm = ({
19267
19288
  children: "Select category"
19268
19289
  }
19269
19290
  ) : null,
19270
- showCategorization && options.length > 0 ? /* @__PURE__ */ jsx140(
19291
+ showCategorization && options2.length > 0 ? /* @__PURE__ */ jsx140(
19271
19292
  Button,
19272
19293
  {
19273
19294
  onClick: save,
@@ -19704,7 +19725,7 @@ var SplitForm = ({
19704
19725
  TextButton,
19705
19726
  {
19706
19727
  onClick: addSplit,
19707
- disabled: rowState.splits.length > 5 || isLoading,
19728
+ disabled: isLoading,
19708
19729
  className: "Layer__add-new-split",
19709
19730
  children: "Add new split"
19710
19731
  }
@@ -20633,9 +20654,9 @@ function runDelayedSync(block, delayMs = DEFAULT_DELAY_MS) {
20633
20654
  import { jsx as jsx159 } from "react/jsx-runtime";
20634
20655
  function useInvisibleDownload() {
20635
20656
  const invisibleDownloadRef = useRef20(null);
20636
- const triggerInvisibleDownload = useCallback18((options) => {
20657
+ const triggerInvisibleDownload = useCallback18((options2) => {
20637
20658
  var _a;
20638
- void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options));
20659
+ void ((_a = invisibleDownloadRef.current) == null ? void 0 : _a.trigger(options2));
20639
20660
  }, []);
20640
20661
  return { invisibleDownloadRef, triggerInvisibleDownload };
20641
20662
  }
@@ -20835,7 +20856,7 @@ import classNames53 from "classnames";
20835
20856
  import { jsx as jsx161, jsxs as jsxs102 } from "react/jsx-runtime";
20836
20857
  var CreatableSelect = ({
20837
20858
  name,
20838
- options,
20859
+ options: options2,
20839
20860
  className,
20840
20861
  classNamePrefix = "Layer__select",
20841
20862
  value,
@@ -20868,7 +20889,7 @@ var CreatableSelect = ({
20868
20889
  className: baseClassName,
20869
20890
  classNamePrefix,
20870
20891
  placeholder: placeholder != null ? placeholder : "Select...",
20871
- options,
20892
+ options: options2,
20872
20893
  formatOptionLabel: formatOptionLabel2,
20873
20894
  value,
20874
20895
  onChange: (newValue) => onChange(newValue),
@@ -21615,7 +21636,12 @@ var MAX_NUM_ROWS = 8;
21615
21636
  var HEADER_HEIGHT = 41;
21616
21637
  var CONTAINER_HEIGHT = ROW_HEIGHT * MAX_NUM_ROWS + HEADER_HEIGHT - 1;
21617
21638
  var CSS_PREFIX = "Layer__csv-upload__validate-csv-table";
21618
- function ValidateCsvTable({ data, headers, formatters: formatters2, className }) {
21639
+ function ValidateCsvTable({
21640
+ data,
21641
+ headers,
21642
+ formatters: formatters2,
21643
+ className
21644
+ }) {
21619
21645
  const columns = useMemo30(
21620
21646
  () => {
21621
21647
  const columnDefs = [{
@@ -21630,8 +21656,9 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21630
21656
  header: () => /* @__PURE__ */ jsx168("span", { className: `${CSS_PREFIX}__header-cell-content`, children: headers[key] }),
21631
21657
  cell: (info) => {
21632
21658
  const field = info.row.original[key];
21633
- let value = field.raw;
21634
- if (field.is_valid) {
21659
+ let value = field == null ? void 0 : field.raw;
21660
+ const isValid2 = field && field.is_valid;
21661
+ if (isValid2) {
21635
21662
  const formatter2 = formatters2 == null ? void 0 : formatters2[key];
21636
21663
  value = formatter2 ? formatter2(field.parsed) : field.parsed;
21637
21664
  }
@@ -21641,7 +21668,7 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21641
21668
  className: classNames57(
21642
21669
  "Layer__table-cell-content",
21643
21670
  `${CSS_PREFIX}__cell-content`,
21644
- !field.is_valid && `${CSS_PREFIX}__cell-content--error`
21671
+ !isValid2 && `${CSS_PREFIX}__cell-content--error`
21645
21672
  ),
21646
21673
  children: value
21647
21674
  }
@@ -21718,7 +21745,11 @@ function ValidateCsvTable({ data, headers, formatters: formatters2, className })
21718
21745
  ] })
21719
21746
  ] }) });
21720
21747
  }
21721
- var ValidateCsvTableRow = ({ row, virtualRow, rowVirtualizer }) => /* @__PURE__ */ jsx168(
21748
+ var ValidateCsvTableRow = ({
21749
+ row,
21750
+ virtualRow,
21751
+ rowVirtualizer
21752
+ }) => /* @__PURE__ */ jsx168(
21722
21753
  "tr",
21723
21754
  {
21724
21755
  className: classNames57(
@@ -21757,6 +21788,21 @@ var formatters = {
21757
21788
  return (_a = convertCentsToCurrency(parsed)) != null ? _a : "";
21758
21789
  }
21759
21790
  };
21791
+ var generateDynamicHeaders = (transactionsPreview) => {
21792
+ const hasExternalId = transactionsPreview.some(
21793
+ (transaction) => {
21794
+ var _a;
21795
+ return ((_a = transaction.external_id) == null ? void 0 : _a.parsed) != null;
21796
+ }
21797
+ );
21798
+ const hasReferenceNumber = transactionsPreview.some(
21799
+ (transaction) => {
21800
+ var _a;
21801
+ return ((_a = transaction.reference_number) == null ? void 0 : _a.parsed) != null;
21802
+ }
21803
+ );
21804
+ return __spreadValues(__spreadValues(__spreadValues({}, hasExternalId && { external_id: "External ID" }), hasReferenceNumber && { reference_number: "Reference No." }), templateHeaders);
21805
+ };
21760
21806
  function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId, onSelectFile, onUploadTransactionsSuccess }) {
21761
21807
  const { previous, next } = useWizard();
21762
21808
  const { trigger: uploadTransactions, isMutating, error: uploadTransactionsError } = useCreateCustomAccountTransactions();
@@ -21771,6 +21817,7 @@ function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId
21771
21817
  invalid_transactions_count: invalidTransactionsCount,
21772
21818
  total_transactions_count: totalTransactionsCount
21773
21819
  } = parseCsvResponse;
21820
+ const dynamicHeaders = generateDynamicHeaders(transactionsPreview);
21774
21821
  const onClickUploadTransactions = useCallback25(() => {
21775
21822
  void uploadTransactions(__spreadProps(__spreadValues({}, transactionsRequest), {
21776
21823
  customAccountId: selectedAccountId
@@ -21792,7 +21839,7 @@ function UploadTransactionsValidateCsvStep({ parseCsvResponse, selectedAccountId
21792
21839
  {
21793
21840
  className: "Layer__upload-transactions__preview_table",
21794
21841
  data: transactionsPreview,
21795
- headers: templateHeaders,
21842
+ headers: dynamicHeaders,
21796
21843
  formatters
21797
21844
  }
21798
21845
  )
@@ -23640,15 +23687,15 @@ function useProfitAndLossComparison({
23640
23687
  const effectiveComparePeriods = isPeriodsSelectEnabled ? comparePeriods : 1;
23641
23688
  const compareModeActive = useMemo36(() => effectiveComparePeriods > 1 || selectedCompareOptions.length > 1 || selectedCompareOptions.length === 1 && isNotOnlyNoneTag(selectedCompareOptions), [effectiveComparePeriods, selectedCompareOptions]);
23642
23689
  const setSelectedCompareOptions = (values) => {
23643
- const options = values.map(
23690
+ const options2 = values.map(
23644
23691
  (option) => comparisonConfig == null ? void 0 : comparisonConfig.tagComparisonOptions.find(
23645
23692
  (t) => JSON.stringify(t.tagFilterConfig) === option.value
23646
23693
  )
23647
23694
  ).filter(Boolean);
23648
- if (options.length === 0 && (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter)) {
23695
+ if (options2.length === 0 && (comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter)) {
23649
23696
  setSelectedCompareOptionsState([comparisonConfig == null ? void 0 : comparisonConfig.defaultTagFilter]);
23650
23697
  } else {
23651
- setSelectedCompareOptionsState(options);
23698
+ setSelectedCompareOptionsState(options2);
23652
23699
  }
23653
23700
  };
23654
23701
  const { businessId } = useLayerContext();
@@ -26726,7 +26773,7 @@ var ProfitAndLossTableComponent = ({
26726
26773
  } = useContext40(ProfitAndLoss.Context);
26727
26774
  const { isOpen, setIsOpen } = useTableExpandRow();
26728
26775
  useEffect31(() => {
26729
- setIsOpen(["income", "cost_of_goods_sold", "expenses"]);
26776
+ setIsOpen(["income", "cost_of_goods_sold", "expenses", "other_activity"]);
26730
26777
  }, []);
26731
26778
  const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
26732
26779
  if (isLoading || actualData === void 0) {
@@ -26746,7 +26793,8 @@ var ProfitAndLossTableComponent = ({
26746
26793
  depth,
26747
26794
  rowKey,
26748
26795
  rowIndex,
26749
- variant
26796
+ variant,
26797
+ showValue = true
26750
26798
  }) => {
26751
26799
  const expandable = !!lineItem.line_items && lineItem.line_items.length > 0;
26752
26800
  const expanded = expandable ? isOpen(rowKey) : true;
@@ -26769,7 +26817,7 @@ var ProfitAndLossTableComponent = ({
26769
26817
  children: lineItem.display_name
26770
26818
  }
26771
26819
  ),
26772
- /* @__PURE__ */ jsx227(TableCell, { isCurrency: true, primary: true, align: "right" /* RIGHT */, children: Number.isNaN(lineItem.value) ? 0 : lineItem.value })
26820
+ showValue && /* @__PURE__ */ jsx227(TableCell, { isCurrency: true, primary: true, align: "right" /* RIGHT */, children: Number.isNaN(lineItem.value) ? 0 : lineItem.value })
26773
26821
  ]
26774
26822
  }
26775
26823
  ),
@@ -26790,12 +26838,12 @@ var ProfitAndLossTableComponent = ({
26790
26838
  rowKey: "income",
26791
26839
  rowIndex: 0
26792
26840
  }),
26793
- data.cost_of_goods_sold ? renderLineItem({
26841
+ data.cost_of_goods_sold && renderLineItem({
26794
26842
  lineItem: data.cost_of_goods_sold,
26795
26843
  depth: 0,
26796
26844
  rowKey: "cost_of_goods_sold",
26797
26845
  rowIndex: 1
26798
- }) : null,
26846
+ }),
26799
26847
  renderLineItem({
26800
26848
  lineItem: {
26801
26849
  value: data.gross_profit,
@@ -26835,21 +26883,28 @@ var ProfitAndLossTableComponent = ({
26835
26883
  },
26836
26884
  depth: 0,
26837
26885
  rowKey: "net_profit",
26838
- rowIndex: 5,
26886
+ rowIndex: 6,
26839
26887
  variant: "summation"
26840
26888
  }),
26841
- data.personal_expenses ? renderLineItem({
26889
+ data.personal_expenses && renderLineItem({
26842
26890
  lineItem: data.personal_expenses,
26843
26891
  depth: 0,
26844
26892
  rowKey: "personal_expenses",
26845
26893
  rowIndex: 7
26846
- }) : null,
26847
- data.other_outflows ? renderLineItem({
26894
+ }),
26895
+ data.other_outflows && renderLineItem({
26848
26896
  lineItem: data.other_outflows,
26849
26897
  depth: 0,
26850
26898
  rowKey: "other_outflows",
26851
- rowIndex: 6
26852
- }) : null
26899
+ rowIndex: 8
26900
+ }),
26901
+ data.custom_line_items && renderLineItem({
26902
+ lineItem: data.custom_line_items,
26903
+ depth: 0,
26904
+ rowKey: "other_activity",
26905
+ rowIndex: 9,
26906
+ showValue: false
26907
+ })
26853
26908
  ] }) });
26854
26909
  };
26855
26910
 
@@ -30816,7 +30871,7 @@ var JournalEntryDetails = () => {
30816
30871
  ]
30817
30872
  }
30818
30873
  ) }),
30819
- /* @__PURE__ */ jsx254("div", { className: "Layer__journal__entry-details__reverse-btn-container", children: /* @__PURE__ */ jsx254(
30874
+ (entry == null ? void 0 : entry.entry_type) === "MANUAL" && /* @__PURE__ */ jsx254("div", { className: "Layer__journal__entry-details__reverse-btn-container", children: /* @__PURE__ */ jsx254(
30820
30875
  Button,
30821
30876
  {
30822
30877
  rightIcon: reverseEntryError ? /* @__PURE__ */ jsx254(AlertCircle_default, { size: 12 }) : /* @__PURE__ */ jsx254(RefreshCcw_default, { size: 12 }),
@@ -32810,11 +32865,11 @@ import classNames81 from "classnames";
32810
32865
  import { jsx as jsx277, jsxs as jsxs178 } from "react/jsx-runtime";
32811
32866
  import { createElement as createElement2 } from "react";
32812
32867
  var STARTING_PADDING = 12;
32813
- var Tabs = ({ name, options, selected, onChange }) => {
32868
+ var Tabs = ({ name, options: options2, selected, onChange }) => {
32814
32869
  const [initialized, setInitialized] = useState71(false);
32815
32870
  const [thumbPos, setThumbPos] = useState71({ left: 0, width: 0 });
32816
32871
  const [currentWidth, setCurrentWidth] = useState71(0);
32817
- const selectedValue = selected || options[0].value;
32872
+ const selectedValue = selected || options2[0].value;
32818
32873
  const baseClassName = classNames81(
32819
32874
  "Layer__tabs",
32820
32875
  initialized && "Layer__tabs--initialized"
@@ -32860,7 +32915,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
32860
32915
  updateSelectPosition(selectedIndex);
32861
32916
  }, [selectedValue, currentWidth]);
32862
32917
  const getSelectedIndex = () => {
32863
- const selectedIndex = options.findIndex(
32918
+ const selectedIndex = options2.findIndex(
32864
32919
  (option) => option.value === selectedValue
32865
32920
  );
32866
32921
  if (selectedIndex === -1) {
@@ -32869,7 +32924,7 @@ var Tabs = ({ name, options, selected, onChange }) => {
32869
32924
  return selectedIndex;
32870
32925
  };
32871
32926
  return /* @__PURE__ */ jsx277("div", { className: "Layer__tabs__container", children: /* @__PURE__ */ jsxs178("div", { className: baseClassName, ref: elementRef, children: [
32872
- options.map((option, index) => {
32927
+ options2.map((option, index) => {
32873
32928
  var _a;
32874
32929
  return /* @__PURE__ */ createElement2(
32875
32930
  Tab,
@@ -33901,11 +33956,11 @@ var FormSection = ({ children, title }) => {
33901
33956
 
33902
33957
  // src/components/Input/BusinessTypeSelect.tsx
33903
33958
  import { jsx as jsx291 } from "react/jsx-runtime";
33904
- var findSelectOption = (options, value) => {
33959
+ var findSelectOption = (options2, value) => {
33905
33960
  if (!value) {
33906
33961
  return void 0;
33907
33962
  }
33908
- return options.find((o) => o.value === value);
33963
+ return options2.find((o) => o.value === value);
33909
33964
  };
33910
33965
  var BusinessTypeSelect = ({ value, onChange }) => {
33911
33966
  const entityTypeOptions = ENTITY_TYPES;
@@ -33977,11 +34032,11 @@ var US_STATES = [
33977
34032
 
33978
34033
  // src/components/Input/USStateSelect.tsx
33979
34034
  import { jsx as jsx292 } from "react/jsx-runtime";
33980
- var findSelectOption2 = (options, selected) => {
34035
+ var findSelectOption2 = (options2, selected) => {
33981
34036
  if (!selected) {
33982
34037
  return void 0;
33983
34038
  }
33984
- return options.find(
34039
+ return options2.find(
33985
34040
  (o) => String(o.value).toLowerCase() === String(selected).toLowerCase() || String(o.label).toLowerCase() === String(selected).toLowerCase()
33986
34041
  );
33987
34042
  };
@@ -37107,8 +37162,8 @@ var Reports = ({
37107
37162
  var _a;
37108
37163
  const [activeTab, setActiveTab] = useState81(enabledReports[0]);
37109
37164
  const { view, containerRef } = useElementViewSize();
37110
- const options = getOptions(enabledReports);
37111
- const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options.find((option) => option.value === enabledReports[0])) == null ? void 0 : _a.label;
37165
+ const options2 = getOptions(enabledReports);
37166
+ const defaultTitle4 = enabledReports.length > 1 ? "Reports" : (_a = options2.find((option) => option.value === enabledReports[0])) == null ? void 0 : _a.label;
37112
37167
  const initialModeForProfitAndLoss = profitAndLossConfig ? getInitialDateRangePickerMode(profitAndLossConfig) : "monthPicker";
37113
37168
  const initialModeForStatementOfCashFlows = statementOfCashFlowConfig ? getInitialDateRangePickerMode(statementOfCashFlowConfig) : "monthPicker";
37114
37169
  const initialModes = {
@@ -37126,7 +37181,7 @@ var Reports = ({
37126
37181
  Toggle,
37127
37182
  {
37128
37183
  name: "reports-tabs",
37129
- options,
37184
+ options: options2,
37130
37185
  selected: activeTab,
37131
37186
  onChange: (opt) => setActiveTab(opt.target.value)
37132
37187
  }
@@ -37268,10 +37323,10 @@ var Components = ({
37268
37323
  };
37269
37324
 
37270
37325
  // src/components/Invoices/Invoices.tsx
37271
- import { useCallback as useCallback59, useState as useState87 } from "react";
37326
+ import { useCallback as useCallback61, useState as useState88 } from "react";
37272
37327
 
37273
37328
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
37274
- import { useCallback as useCallback55 } from "react";
37329
+ import { useCallback as useCallback57, useRef as useRef32, useState as useState85 } from "react";
37275
37330
 
37276
37331
  // src/components/BaseDetailView/BaseDetailView.tsx
37277
37332
  import { jsx as jsx326, jsxs as jsxs210 } from "react/jsx-runtime";
@@ -37286,12 +37341,19 @@ var BaseDetailView = ({ name, onGoBack, slots, children }) => {
37286
37341
  ] });
37287
37342
  };
37288
37343
 
37344
+ // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
37345
+ import { forwardRef as forwardRef25, useCallback as useCallback56, useEffect as useEffect43, useImperativeHandle as useImperativeHandle4, useRef as useRef31 } from "react";
37346
+ import classNames92 from "classnames";
37347
+
37289
37348
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
37290
- import { useState as useState84 } from "react";
37349
+ import { useCallback as useCallback54, useMemo as useMemo72, useState as useState84, useRef as useRef30 } from "react";
37291
37350
  import { useStore as useStore7 } from "@tanstack/react-form";
37292
37351
 
37293
37352
  // src/features/forms/hooks/useForm.tsx
37294
- import { createFormHookContexts, createFormHook } from "@tanstack/react-form";
37353
+ import {
37354
+ createFormHookContexts,
37355
+ createFormHook
37356
+ } from "@tanstack/react-form";
37295
37357
 
37296
37358
  // src/components/ui/Form/Form.tsx
37297
37359
  import { forwardRef as forwardRef20 } from "react";
@@ -37328,11 +37390,12 @@ var FieldError = forwardRef20(
37328
37390
  import { jsx as jsx328, jsxs as jsxs211 } from "react/jsx-runtime";
37329
37391
  function BaseFormTextField({
37330
37392
  label,
37331
- className,
37332
37393
  inline = false,
37333
37394
  showLabel = true,
37334
37395
  showFieldError = true,
37335
37396
  isTextArea = false,
37397
+ isReadOnly = false,
37398
+ className,
37336
37399
  children
37337
37400
  }) {
37338
37401
  const field = useFieldContext();
@@ -37342,11 +37405,32 @@ function BaseFormTextField({
37342
37405
  const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37343
37406
  const shouldShowErrorMessage = showFieldError && errorMessage;
37344
37407
  const additionalAriaProps = !showLabel && { "aria-label": label };
37345
- return /* @__PURE__ */ jsxs211(TextField, __spreadProps(__spreadValues({ name, isInvalid: !isValid2, inline, className, textarea: isTextArea }, additionalAriaProps), { children: [
37346
- showLabel && /* @__PURE__ */ jsx328(Label, __spreadProps(__spreadValues({ size: "sm", htmlFor: name }, !inline && { pbe: "3xs" }), { children: label })),
37347
- children,
37348
- shouldShowErrorMessage && /* @__PURE__ */ jsx328(FieldError, { children: errorMessage })
37349
- ] }));
37408
+ return /* @__PURE__ */ jsxs211(
37409
+ TextField,
37410
+ __spreadProps(__spreadValues({
37411
+ name,
37412
+ isInvalid: !isValid2,
37413
+ inline,
37414
+ className,
37415
+ textarea: isTextArea,
37416
+ isReadOnly
37417
+ }, additionalAriaProps), {
37418
+ children: [
37419
+ showLabel && /* @__PURE__ */ jsx328(
37420
+ Label,
37421
+ __spreadProps(__spreadValues({
37422
+ slot: "label",
37423
+ size: "sm",
37424
+ htmlFor: name
37425
+ }, !inline && { pbe: "3xs" }), {
37426
+ children: label
37427
+ })
37428
+ ),
37429
+ children,
37430
+ shouldShowErrorMessage && /* @__PURE__ */ jsx328(FieldError, { children: errorMessage })
37431
+ ]
37432
+ })
37433
+ );
37350
37434
  }
37351
37435
 
37352
37436
  // src/features/forms/components/FormBigDecimalField.tsx
@@ -37374,7 +37458,7 @@ var InputGroup2 = forwardRef21(
37374
37458
  );
37375
37459
 
37376
37460
  // src/features/forms/components/FormBigDecimalField.tsx
37377
- import { BigDecimal as BD2, Option as Option4 } from "effect";
37461
+ import { BigDecimal as BD2, Option as Option5 } from "effect";
37378
37462
 
37379
37463
  // src/components/ui/Input/Input.tsx
37380
37464
  import { forwardRef as forwardRef22 } from "react";
@@ -37396,12 +37480,22 @@ var Input2 = forwardRef22(
37396
37480
  );
37397
37481
 
37398
37482
  // src/utils/bigDecimalUtils.ts
37399
- import { BigDecimal as BD } from "effect";
37483
+ import { BigDecimal as BD, Option as Option4 } from "effect";
37400
37484
  var BIG_DECIMAL_ZERO = BD.fromBigInt(BigInt(0));
37401
37485
  var BIG_DECIMAL_ONE = BD.fromBigInt(BigInt(1));
37486
+ var BIG_DECIMAL_NEG_ONE = BD.fromBigInt(BigInt(-1));
37402
37487
  var BIG_DECIMAL_ONE_HUNDRED = BD.fromBigInt(BigInt(100));
37403
- var DECIMAL_CHARS_REGEX = /^[\d.,-]+$/;
37404
- var NON_NEGATIVE_DECIMAL_CHARS_REGEX = /^[\d.,]+$/;
37488
+ var buildDecimalCharRegex = ({
37489
+ allowNegative = true,
37490
+ allowPercent = false,
37491
+ allowDollar = false
37492
+ } = {}) => {
37493
+ let allowed = "\\d.,";
37494
+ if (allowNegative) allowed += "\\-";
37495
+ if (allowPercent) allowed += "%";
37496
+ if (allowDollar) allowed += "\\$";
37497
+ return new RegExp(`^[${allowed}]+$`);
37498
+ };
37405
37499
  var convertBigDecimalToCents = (amount) => {
37406
37500
  const scaled = BD.multiply(amount, BIG_DECIMAL_ONE_HUNDRED);
37407
37501
  const rounded = BD.round(scaled, { scale: 0 });
@@ -37411,14 +37505,38 @@ var convertCentsToBigDecimal = (cents) => {
37411
37505
  const decimalCents = BD.fromBigInt(BigInt(cents));
37412
37506
  return BD.unsafeDivide(decimalCents, BIG_DECIMAL_ONE_HUNDRED);
37413
37507
  };
37414
- function formatBigDecimalToString(value, maxDecimalPlaces = 10) {
37508
+ var convertPercentToDecimal = (percent) => {
37509
+ return BD.unsafeDivide(percent, BIG_DECIMAL_ONE_HUNDRED);
37510
+ };
37511
+ var roundDecimalToCents = (decimal) => {
37512
+ return BD.round(decimal, { scale: 2 });
37513
+ };
37514
+ var safeDivide = (dividend, divisor) => {
37515
+ const maybeQuotient = BD.divide(dividend, divisor);
37516
+ const quotient = Option4.match(maybeQuotient, {
37517
+ onNone: () => BIG_DECIMAL_ZERO,
37518
+ onSome: (innerQuotient) => innerQuotient
37519
+ });
37520
+ return quotient;
37521
+ };
37522
+ var negate = (value) => {
37523
+ return BD.multiply(value, BIG_DECIMAL_NEG_ONE);
37524
+ };
37525
+ function formatBigDecimalToString(value, options2 = {
37526
+ mode: "decimal",
37527
+ minDecimalPlaces: 0,
37528
+ maxDecimalPlaces: 3
37529
+ }) {
37415
37530
  const normalizedBigDecimal = BD.normalize(value);
37531
+ const { mode, minDecimalPlaces, maxDecimalPlaces } = options2;
37416
37532
  const formatter2 = new Intl.NumberFormat(
37417
37533
  "en-US",
37418
- {
37419
- minimumFractionDigits: 0,
37534
+ __spreadProps(__spreadValues(__spreadValues({
37535
+ style: "decimal"
37536
+ }, mode === "percent" && { style: "percent" }), mode === "currency" && { style: "currency", currency: "USD" }), {
37537
+ minimumFractionDigits: minDecimalPlaces,
37420
37538
  maximumFractionDigits: maxDecimalPlaces
37421
- }
37539
+ })
37422
37540
  );
37423
37541
  let decimalAsNumber = 0;
37424
37542
  try {
@@ -37430,37 +37548,59 @@ function formatBigDecimalToString(value, maxDecimalPlaces = 10) {
37430
37548
 
37431
37549
  // src/features/forms/components/FormBigDecimalField.tsx
37432
37550
  import { jsx as jsx331 } from "react/jsx-runtime";
37433
- var DEFAULT_MAX_INPUT_LENGTH = 10;
37551
+ var DEFAULT_MAX_VALUE = 1e7;
37552
+ var DEFAULT_MIN_DECIMAL_PLACES = 0;
37553
+ var DEFAULT_MAX_DECIMAL_PLACES = 3;
37554
+ var DECORATOR_CHARS_REGEX = /[,%$]/g;
37555
+ var withForceUpdate = (value) => __spreadProps(__spreadValues({}, value), {
37556
+ __forceUpdate: Symbol()
37557
+ });
37434
37558
  function FormBigDecimalField(_a) {
37435
37559
  var _b = _a, {
37436
- maxInputLength = DEFAULT_MAX_INPUT_LENGTH,
37437
- allowNegative = false
37560
+ mode = "decimal",
37561
+ allowNegative = false,
37562
+ maxValue = mode === "percent" ? 1 : DEFAULT_MAX_VALUE,
37563
+ minDecimalPlaces = mode === "currency" ? 2 : DEFAULT_MIN_DECIMAL_PLACES,
37564
+ maxDecimalPlaces = mode === "currency" ? 2 : DEFAULT_MAX_DECIMAL_PLACES
37438
37565
  } = _b, restProps = __objRest(_b, [
37439
- "maxInputLength",
37440
- "allowNegative"
37566
+ "mode",
37567
+ "allowNegative",
37568
+ "maxValue",
37569
+ "minDecimalPlaces",
37570
+ "maxDecimalPlaces"
37441
37571
  ]);
37442
37572
  const field = useFieldContext();
37443
37573
  const { name, state, handleChange, handleBlur } = field;
37444
37574
  const { value } = state;
37445
- const [inputValue, setInputValue] = useState82(formatBigDecimalToString(value, maxInputLength));
37575
+ const maxBigDecimalValue = BD2.unsafeFromNumber(maxValue);
37576
+ const formattingProps = useMemo71(() => ({
37577
+ minDecimalPlaces,
37578
+ maxDecimalPlaces,
37579
+ mode
37580
+ }), [maxDecimalPlaces, minDecimalPlaces, mode]);
37581
+ const [inputValue, setInputValue] = useState82(formatBigDecimalToString(value, formattingProps));
37446
37582
  const onInputChange = useCallback48((e) => {
37447
37583
  setInputValue(e.target.value);
37448
37584
  }, []);
37449
37585
  const onInputBlur = useCallback48(() => {
37450
- const cleaned = inputValue.replace(/,/g, "");
37451
- const maybeDecimal = BD2.fromString(cleaned);
37452
- const decimal = Option4.match(maybeDecimal, {
37586
+ const sanitizedInput = inputValue.replace(DECORATOR_CHARS_REGEX, "");
37587
+ const maybeDecimal = BD2.fromString(sanitizedInput);
37588
+ const decimal = Option5.match(maybeDecimal, {
37453
37589
  onNone: () => BIG_DECIMAL_ZERO,
37454
- onSome: (amount) => amount
37590
+ onSome: (value2) => value2
37455
37591
  });
37456
- const normalizedDecimal = BD2.normalize(decimal);
37457
- handleChange(normalizedDecimal);
37592
+ const adjustedForPercent = mode === "percent" ? convertPercentToDecimal(decimal) : decimal;
37593
+ const normalized = BD2.normalize(adjustedForPercent);
37594
+ const clamped = BD2.min(normalized, maxBigDecimalValue);
37595
+ if (!BD2.equals(clamped, value)) {
37596
+ handleChange(withForceUpdate(clamped));
37597
+ }
37458
37598
  handleBlur();
37459
- setInputValue(formatBigDecimalToString(normalizedDecimal, maxInputLength));
37460
- }, [inputValue, handleBlur, handleChange, maxInputLength]);
37599
+ setInputValue(formatBigDecimalToString(clamped, formattingProps));
37600
+ }, [inputValue, mode, maxBigDecimalValue, value, handleBlur, formattingProps, handleChange]);
37461
37601
  const allowedChars = useMemo71(
37462
- () => allowNegative ? DECIMAL_CHARS_REGEX : NON_NEGATIVE_DECIMAL_CHARS_REGEX,
37463
- [allowNegative]
37602
+ () => buildDecimalCharRegex({ allowNegative, allowPercent: mode === "percent", allowDollar: mode === "currency" }),
37603
+ [allowNegative, mode]
37464
37604
  );
37465
37605
  const onBeforeInput = useCallback48((e) => {
37466
37606
  if (e.data && !allowedChars.test(e.data)) {
@@ -37474,9 +37614,9 @@ function FormBigDecimalField(_a) {
37474
37614
  }
37475
37615
  }, [allowedChars]);
37476
37616
  useEffect41(() => {
37477
- setInputValue(formatBigDecimalToString(value, maxInputLength));
37478
- }, [value, maxInputLength]);
37479
- return /* @__PURE__ */ jsx331(BaseFormTextField, __spreadProps(__spreadValues({}, restProps), { inputMode: "decimal", children: /* @__PURE__ */ jsx331(InputGroup2, { children: /* @__PURE__ */ jsx331(
37617
+ setInputValue(formatBigDecimalToString(value, formattingProps));
37618
+ }, [value, formattingProps]);
37619
+ return /* @__PURE__ */ jsx331(BaseFormTextField, __spreadProps(__spreadValues({}, restProps), { inputMode: "decimal", children: /* @__PURE__ */ jsx331(InputGroup2, { slot: "input", children: /* @__PURE__ */ jsx331(
37480
37620
  Input2,
37481
37621
  {
37482
37622
  inset: true,
@@ -37485,7 +37625,6 @@ function FormBigDecimalField(_a) {
37485
37625
  value: inputValue,
37486
37626
  onChange: onInputChange,
37487
37627
  onBlur: onInputBlur,
37488
- maxLength: maxInputLength,
37489
37628
  onBeforeInput,
37490
37629
  onPaste
37491
37630
  }
@@ -37493,7 +37632,6 @@ function FormBigDecimalField(_a) {
37493
37632
  }
37494
37633
 
37495
37634
  // src/features/forms/components/FormCheckboxField.tsx
37496
- import { useCallback as useCallback49 } from "react";
37497
37635
  import classNames89 from "classnames";
37498
37636
  import { jsx as jsx332 } from "react/jsx-runtime";
37499
37637
  var FORM_CHECKBOX_FIELD_CLASSNAME = "Layer__FormCheckboxField";
@@ -37502,104 +37640,165 @@ function FormCheckboxField({
37502
37640
  className,
37503
37641
  inline = false,
37504
37642
  showLabel = true,
37505
- showErrorInTooltip = true
37643
+ showFieldError = true,
37644
+ isReadOnly = false
37506
37645
  }) {
37507
37646
  const field = useFieldContext();
37508
37647
  const { name, state, handleChange, handleBlur } = field;
37509
37648
  const { meta, value } = state;
37510
37649
  const { errors, isValid: isValid2 } = meta;
37511
37650
  const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37512
- const tooltipProps = showErrorInTooltip ? { tooltip: errorMessage } : {};
37651
+ const tooltipProps = showFieldError ? { tooltip: errorMessage } : {};
37513
37652
  const additionalAriaProps = !showLabel && { "aria-label": label };
37514
37653
  const checkboxClassNames = classNames89(
37515
37654
  FORM_CHECKBOX_FIELD_CLASSNAME,
37516
37655
  inline && `${FORM_CHECKBOX_FIELD_CLASSNAME}--inline`,
37517
37656
  className
37518
37657
  );
37519
- const onChange = useCallback49((isSelected) => {
37520
- handleChange(isSelected);
37521
- }, [handleChange]);
37522
37658
  return /* @__PURE__ */ jsx332(
37523
37659
  CheckboxWithTooltip,
37524
37660
  __spreadProps(__spreadValues(__spreadValues(__spreadValues({
37525
37661
  className: checkboxClassNames,
37526
37662
  isSelected: value,
37527
37663
  isInvalid: !isValid2,
37528
- onChange,
37664
+ onChange: handleChange,
37529
37665
  onBlur: handleBlur,
37530
37666
  name,
37531
37667
  value: name,
37532
- size: "lg"
37668
+ size: "lg",
37669
+ isReadOnly
37533
37670
  }, tooltipProps), additionalAriaProps), !isValid2 && { variant: "error" }), {
37534
37671
  children: showLabel && /* @__PURE__ */ jsx332(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
37535
37672
  })
37536
37673
  );
37537
37674
  }
37538
37675
 
37539
- // src/features/forms/components/FormCurrencyField.tsx
37540
- import { useCallback as useCallback50, useEffect as useEffect42, useState as useState83 } from "react";
37541
- import CurrencyInput2 from "react-currency-input-field";
37542
- import { BigDecimal as BD3, Option as Option5 } from "effect";
37676
+ // src/features/forms/components/FormDateField.tsx
37677
+ import { useState as useState83, useEffect as useEffect42, useCallback as useCallback49 } from "react";
37678
+
37679
+ // src/components/ui/Date/Date.tsx
37680
+ import { forwardRef as forwardRef23 } from "react";
37681
+ import classNames90 from "classnames";
37682
+ import {
37683
+ DateField as ReactAriaDateField,
37684
+ DateSegment as ReactAriaDateSegment,
37685
+ DateInput as ReactAriaDateInput
37686
+ } from "react-aria-components";
37543
37687
  import { jsx as jsx333 } from "react/jsx-runtime";
37544
- var ZERO_CENTS_INPUT_VALUE = "0.00";
37545
- var getCurrencyInputValueFromCents = (cents) => !Number.isNaN(cents) ? centsToDollarsWithoutCommas(cents) : ZERO_CENTS_INPUT_VALUE;
37546
- function FormCurrencyField(props) {
37688
+ var DATE_FIELD_CLASS_NAME = "Layer__UI__DateField";
37689
+ var DateField = forwardRef23(
37690
+ function DateField2(_a, ref) {
37691
+ var _b = _a, { inline, className, isReadOnly } = _b, restProps = __objRest(_b, ["inline", "className", "isReadOnly"]);
37692
+ const dataProperties = toDataProperties({ inline, readonly: isReadOnly });
37693
+ return /* @__PURE__ */ jsx333(
37694
+ ReactAriaDateField,
37695
+ __spreadProps(__spreadValues(__spreadValues({}, dataProperties), restProps), {
37696
+ isReadOnly,
37697
+ className: classNames90(DATE_FIELD_CLASS_NAME, className),
37698
+ ref
37699
+ })
37700
+ );
37701
+ }
37702
+ );
37703
+ var DATE_INPUT_CLASS_NAME = "Layer__UI__DateInput";
37704
+ var DateInput = forwardRef23(
37705
+ function DateInput2(_a, ref) {
37706
+ var _b = _a, { inset } = _b, restProps = __objRest(_b, ["inset"]);
37707
+ const dataProperties = toDataProperties({ inset });
37708
+ return /* @__PURE__ */ jsx333(
37709
+ ReactAriaDateInput,
37710
+ __spreadProps(__spreadValues(__spreadValues({}, dataProperties), restProps), {
37711
+ className: classNames90(DATE_INPUT_CLASS_NAME),
37712
+ ref
37713
+ })
37714
+ );
37715
+ }
37716
+ );
37717
+ var DATE_SEGMENT_CLASS_NAME = "Layer__UI__DateSegment";
37718
+ var DateSegment = forwardRef23(
37719
+ function DateSegment2(_a, ref) {
37720
+ var _b = _a, { isReadOnly } = _b, restProps = __objRest(_b, ["isReadOnly"]);
37721
+ const dataProperties = toDataProperties({ interactive: !isReadOnly });
37722
+ return /* @__PURE__ */ jsx333(
37723
+ ReactAriaDateSegment,
37724
+ __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37725
+ className: DATE_SEGMENT_CLASS_NAME,
37726
+ ref
37727
+ })
37728
+ );
37729
+ }
37730
+ );
37731
+
37732
+ // src/features/forms/components/FormDateField.tsx
37733
+ import { jsx as jsx334, jsxs as jsxs212 } from "react/jsx-runtime";
37734
+ function FormDateField({
37735
+ label,
37736
+ className,
37737
+ inline = false,
37738
+ showLabel = true,
37739
+ showFieldError = true,
37740
+ isReadOnly = false
37741
+ }) {
37547
37742
  const field = useFieldContext();
37548
- const { label } = props;
37549
37743
  const { name, state, handleChange, handleBlur } = field;
37550
- const { value } = state;
37551
- const [inputValue, setInputValue] = useState83(getCurrencyInputValueFromCents(value));
37552
- const onInputChange = useCallback50((newValue) => {
37553
- setInputValue(newValue != null ? newValue : ZERO_CENTS_INPUT_VALUE);
37554
- }, []);
37555
- const onInputBlur = useCallback50(() => {
37556
- const maybeAmount = BD3.fromString(inputValue);
37557
- const cents = Option5.match(maybeAmount, {
37558
- onNone: () => 0,
37559
- onSome: (amount) => convertBigDecimalToCents(amount)
37560
- });
37561
- handleChange(cents);
37562
- handleBlur();
37563
- setInputValue(getCurrencyInputValueFromCents(cents));
37564
- }, [inputValue, handleChange, handleBlur]);
37744
+ const { meta, value } = state;
37745
+ const { errors, isValid: isValid2 } = meta;
37746
+ const [localDate, setLocalDate] = useState83(value);
37565
37747
  useEffect42(() => {
37566
- setInputValue(getCurrencyInputValueFromCents(value));
37748
+ setLocalDate(value);
37567
37749
  }, [value]);
37568
- return /* @__PURE__ */ jsx333(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx333(InputGroup2, { children: /* @__PURE__ */ jsx333(
37569
- CurrencyInput2,
37570
- {
37750
+ const onBlur = useCallback49(() => {
37751
+ const nextDate = isZonedDateTime(localDate) ? localDate : null;
37752
+ handleChange(nextDate);
37753
+ handleBlur();
37754
+ }, [handleBlur, handleChange, localDate]);
37755
+ const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37756
+ const shouldShowErrorMessage = showFieldError && errorMessage;
37757
+ const additionalAriaProps = !showLabel && { "aria-label": label };
37758
+ return /* @__PURE__ */ jsxs212(
37759
+ DateField,
37760
+ __spreadProps(__spreadValues({
37571
37761
  name,
37572
- intlConfig: {
37573
- locale: "en-US",
37574
- currency: "USD"
37575
- },
37576
- prefix: "$",
37577
- decimalScale: 2,
37578
- decimalsLimit: 2,
37579
- disableAbbreviations: true,
37580
- value: inputValue,
37581
- onValueChange: onInputChange,
37582
- onBlur: onInputBlur,
37583
- className: "Layer__UI__Input",
37584
- "data-inset": "true",
37585
- "aria-label": label
37586
- }
37587
- ) }) }));
37762
+ granularity: "day",
37763
+ value: localDate,
37764
+ isInvalid: !isValid2,
37765
+ inline,
37766
+ className,
37767
+ onChange: setLocalDate,
37768
+ onBlur,
37769
+ isReadOnly
37770
+ }, additionalAriaProps), {
37771
+ children: [
37772
+ showLabel && /* @__PURE__ */ jsx334(
37773
+ Label,
37774
+ __spreadProps(__spreadValues({
37775
+ slot: "label",
37776
+ size: "sm",
37777
+ htmlFor: name
37778
+ }, !inline && { pbe: "3xs" }), {
37779
+ children: label
37780
+ })
37781
+ ),
37782
+ /* @__PURE__ */ jsx334(InputGroup2, { slot: "input", children: /* @__PURE__ */ jsx334(DateInput, { inset: true, children: (segment) => /* @__PURE__ */ jsx334(DateSegment, { isReadOnly, segment }) }) }),
37783
+ shouldShowErrorMessage && /* @__PURE__ */ jsx334(FieldError, { children: errorMessage })
37784
+ ]
37785
+ })
37786
+ );
37588
37787
  }
37589
37788
 
37590
37789
  // src/features/forms/components/FormTextAreaField.tsx
37591
- import { useCallback as useCallback51 } from "react";
37790
+ import { useCallback as useCallback50 } from "react";
37592
37791
 
37593
37792
  // src/components/ui/Input/TextArea.tsx
37594
- import { forwardRef as forwardRef23 } from "react";
37793
+ import { forwardRef as forwardRef24 } from "react";
37595
37794
  import { TextArea as ReactAriaTextArea } from "react-aria-components";
37596
- import { jsx as jsx334 } from "react/jsx-runtime";
37795
+ import { jsx as jsx335 } from "react/jsx-runtime";
37597
37796
  var TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
37598
- var TextArea = forwardRef23(
37797
+ var TextArea = forwardRef24(
37599
37798
  function TextArea2(_a, ref) {
37600
37799
  var _b = _a, { resize = "none" } = _b, restProps = __objRest(_b, ["resize"]);
37601
37800
  const dataProperties = toDataProperties({ resize });
37602
- return /* @__PURE__ */ jsx334(
37801
+ return /* @__PURE__ */ jsx335(
37603
37802
  ReactAriaTextArea,
37604
37803
  __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37605
37804
  className: TEXTAREA_CLASS_NAME,
@@ -37610,38 +37809,58 @@ var TextArea = forwardRef23(
37610
37809
  );
37611
37810
 
37612
37811
  // src/features/forms/components/FormTextAreaField.tsx
37613
- import { jsx as jsx335 } from "react/jsx-runtime";
37812
+ import { jsx as jsx336 } from "react/jsx-runtime";
37614
37813
  function FormTextAreaField(props) {
37615
37814
  const field = useFieldContext();
37616
37815
  const { name, state, handleChange, handleBlur } = field;
37617
37816
  const { value } = state;
37618
- const onChange = useCallback51((e) => {
37817
+ const onChange = useCallback50((e) => {
37619
37818
  handleChange(e.target.value);
37620
37819
  }, [handleChange]);
37621
- return /* @__PURE__ */ jsx335(BaseFormTextField, __spreadProps(__spreadValues({}, props), { isTextArea: true, children: /* @__PURE__ */ jsx335(TextArea, { id: name, name, value, onChange, onBlur: handleBlur }) }));
37820
+ return /* @__PURE__ */ jsx336(BaseFormTextField, __spreadProps(__spreadValues({}, props), { isTextArea: true, children: /* @__PURE__ */ jsx336(
37821
+ TextArea,
37822
+ {
37823
+ slot: "input",
37824
+ id: name,
37825
+ name,
37826
+ value,
37827
+ onChange,
37828
+ onBlur: handleBlur
37829
+ }
37830
+ ) }));
37622
37831
  }
37623
37832
 
37624
37833
  // src/features/forms/components/FormTextField.tsx
37625
- import { useCallback as useCallback52 } from "react";
37626
- import { jsx as jsx336 } from "react/jsx-runtime";
37834
+ import { useCallback as useCallback51 } from "react";
37835
+ import { jsx as jsx337 } from "react/jsx-runtime";
37627
37836
  function FormTextField(props) {
37628
37837
  const field = useFieldContext();
37629
37838
  const { name, state, handleChange, handleBlur } = field;
37630
37839
  const { value } = state;
37631
- const onChange = useCallback52((e) => {
37840
+ const onChange = useCallback51((e) => {
37632
37841
  handleChange(e.target.value);
37633
37842
  }, [handleChange]);
37634
- return /* @__PURE__ */ jsx336(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx336(InputGroup2, { children: /* @__PURE__ */ jsx336(Input2, { inset: true, id: name, name, value, onChange, onBlur: handleBlur }) }) }));
37843
+ return /* @__PURE__ */ jsx337(BaseFormTextField, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx337(InputGroup2, { slot: "input", children: /* @__PURE__ */ jsx337(
37844
+ Input2,
37845
+ {
37846
+ id: name,
37847
+ name,
37848
+ value,
37849
+ onChange,
37850
+ onBlur: handleBlur,
37851
+ inset: true
37852
+ }
37853
+ ) }) }));
37635
37854
  }
37636
37855
 
37637
37856
  // src/features/forms/hooks/useForm.tsx
37638
37857
  var { fieldContext, useFieldContext, formContext, useFormContext } = createFormHookContexts();
37639
- var { useAppForm, withForm } = createFormHook({
37858
+ var { useAppForm: useInternalAppForm } = createFormHook({
37640
37859
  fieldComponents: {
37641
37860
  BaseFormTextField,
37642
37861
  FormBigDecimalField,
37643
37862
  FormCheckboxField,
37644
- FormCurrencyField,
37863
+ FormDateField,
37645
37864
  FormTextAreaField,
37646
37865
  FormTextField
37647
37866
  },
@@ -37651,9 +37870,104 @@ var { useAppForm, withForm } = createFormHook({
37651
37870
  fieldContext,
37652
37871
  formContext
37653
37872
  });
37873
+ function useAppForm(props) {
37874
+ return useInternalAppForm(props);
37875
+ }
37876
+
37877
+ // src/features/invoices/invoiceSchemas.ts
37878
+ import { Schema as Schema10, pipe as pipe5 } from "effect";
37879
+
37880
+ // src/components/Invoices/InvoiceTermsComboBox/InvoiceTermsComboBox.tsx
37881
+ import { useCallback as useCallback52, useId as useId5 } from "react";
37882
+ import { differenceInDays as differenceInDays4, startOfDay as startOfDay2 } from "date-fns";
37883
+ import { jsx as jsx338, jsxs as jsxs213 } from "react/jsx-runtime";
37884
+ var InvoiceTermsValues = /* @__PURE__ */ ((InvoiceTermsValues2) => {
37885
+ InvoiceTermsValues2["Net10"] = "Net10";
37886
+ InvoiceTermsValues2["Net15"] = "Net15";
37887
+ InvoiceTermsValues2["Net30"] = "Net30";
37888
+ InvoiceTermsValues2["Net60"] = "Net60";
37889
+ InvoiceTermsValues2["Net90"] = "Net90";
37890
+ InvoiceTermsValues2["Custom"] = "Custom";
37891
+ return InvoiceTermsValues2;
37892
+ })(InvoiceTermsValues || {});
37893
+ var InvoiceTermsOptionConfig = {
37894
+ ["Net10" /* Net10 */]: { label: "Net 10", value: "Net10" /* Net10 */ },
37895
+ ["Net15" /* Net15 */]: { label: "Net 15", value: "Net15" /* Net15 */ },
37896
+ ["Net30" /* Net30 */]: { label: "Net 30", value: "Net30" /* Net30 */ },
37897
+ ["Net60" /* Net60 */]: { label: "Net 60", value: "Net60" /* Net60 */ },
37898
+ ["Net90" /* Net90 */]: { label: "Net 90", value: "Net90" /* Net90 */ },
37899
+ ["Custom" /* Custom */]: { label: "Custom", value: "Custom" /* Custom */ }
37900
+ };
37901
+ var options = Object.values(InvoiceTermsOptionConfig);
37902
+ var getDurationInDaysFromTerms = (terms) => {
37903
+ switch (terms) {
37904
+ case "Net10" /* Net10 */:
37905
+ return 10;
37906
+ case "Net15" /* Net15 */:
37907
+ return 15;
37908
+ case "Net30" /* Net30 */:
37909
+ return 30;
37910
+ case "Net60" /* Net60 */:
37911
+ return 60;
37912
+ case "Net90" /* Net90 */:
37913
+ return 90;
37914
+ case "Custom" /* Custom */:
37915
+ default:
37916
+ return void 0;
37917
+ }
37918
+ };
37919
+ var getInvoiceTermsFromDates = (sentAt, dueAt) => {
37920
+ if (!sentAt || !dueAt) return "Custom" /* Custom */;
37921
+ const days = differenceInDays4(
37922
+ startOfDay2(dueAt.toDate()),
37923
+ startOfDay2(sentAt.toDate())
37924
+ );
37925
+ switch (days) {
37926
+ case 10:
37927
+ return "Net10" /* Net10 */;
37928
+ case 15:
37929
+ return "Net15" /* Net15 */;
37930
+ case 30:
37931
+ return "Net30" /* Net30 */;
37932
+ case 60:
37933
+ return "Net60" /* Net60 */;
37934
+ case 90:
37935
+ return "Net90" /* Net90 */;
37936
+ default:
37937
+ return "Custom" /* Custom */;
37938
+ }
37939
+ };
37940
+ var InvoiceTermsComboBox = ({ value, onValueChange, isReadOnly }) => {
37941
+ const selectedOption = InvoiceTermsOptionConfig[value];
37942
+ const onSelectedValueChange = useCallback52((option) => {
37943
+ onValueChange((option == null ? void 0 : option.value) || null);
37944
+ }, [onValueChange]);
37945
+ const inputId = useId5();
37946
+ return /* @__PURE__ */ jsxs213(HStack, { className: "Layer__InvoiceForm__TermsComboBox Layer__InvoiceForm__Field__Terms", children: [
37947
+ /* @__PURE__ */ jsx338(Label, { size: "sm", htmlFor: inputId, children: "Terms" }),
37948
+ /* @__PURE__ */ jsx338(
37949
+ ComboBox,
37950
+ {
37951
+ options,
37952
+ onSelectedValueChange,
37953
+ selectedValue: selectedOption,
37954
+ isSearchable: false,
37955
+ isClearable: false,
37956
+ inputId,
37957
+ isReadOnly
37958
+ }
37959
+ )
37960
+ ] });
37961
+ };
37962
+
37963
+ // src/utils/schema/utils.ts
37964
+ import { Schema as Schema9 } from "effect";
37965
+ import { ZonedDateTime as ZonedDateTime2 } from "@internationalized/date";
37966
+ var ZonedDateTimeFromSelf = Schema9.declare(
37967
+ (input) => input instanceof ZonedDateTime2
37968
+ );
37654
37969
 
37655
37970
  // src/features/invoices/invoiceSchemas.ts
37656
- import { Schema as Schema9, pipe as pipe5 } from "effect";
37657
37971
  var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37658
37972
  InvoiceStatus3["Voided"] = "VOIDED";
37659
37973
  InvoiceStatus3["Paid"] = "PAID";
@@ -37663,10 +37977,10 @@ var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37663
37977
  InvoiceStatus3["Sent"] = "SENT";
37664
37978
  return InvoiceStatus3;
37665
37979
  })(InvoiceStatus || {});
37666
- var InvoiceStatusSchema = Schema9.Enums(InvoiceStatus);
37667
- var TransformedInvoiceStatusSchema = Schema9.transform(
37668
- Schema9.NonEmptyTrimmedString,
37669
- Schema9.typeSchema(InvoiceStatusSchema),
37980
+ var InvoiceStatusSchema = Schema10.Enums(InvoiceStatus);
37981
+ var TransformedInvoiceStatusSchema = Schema10.transform(
37982
+ Schema10.NonEmptyTrimmedString,
37983
+ Schema10.typeSchema(InvoiceStatusSchema),
37670
37984
  {
37671
37985
  decode: (input) => {
37672
37986
  if (Object.values(InvoiceStatusSchema.enums).includes(input)) {
@@ -37677,153 +37991,175 @@ var TransformedInvoiceStatusSchema = Schema9.transform(
37677
37991
  encode: (input) => input
37678
37992
  }
37679
37993
  );
37680
- var InvoiceLineItemSchema = Schema9.Struct({
37681
- id: Schema9.UUID,
37994
+ var InvoiceLineItemSchema = Schema10.Struct({
37995
+ id: Schema10.UUID,
37682
37996
  externalId: pipe5(
37683
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37684
- Schema9.fromKey("external_id")
37997
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
37998
+ Schema10.fromKey("external_id")
37685
37999
  ),
37686
38000
  invoiceId: pipe5(
37687
- Schema9.propertySignature(Schema9.UUID),
37688
- Schema9.fromKey("invoice_id")
38001
+ Schema10.propertySignature(Schema10.UUID),
38002
+ Schema10.fromKey("invoice_id")
37689
38003
  ),
37690
- description: Schema9.NullOr(Schema9.String),
37691
- product: Schema9.NullOr(Schema9.String),
38004
+ description: Schema10.NullOr(Schema10.String),
38005
+ product: Schema10.NullOr(Schema10.String),
37692
38006
  unitPrice: pipe5(
37693
- Schema9.propertySignature(Schema9.Number),
37694
- Schema9.fromKey("unit_price")
38007
+ Schema10.propertySignature(Schema10.Number),
38008
+ Schema10.fromKey("unit_price")
37695
38009
  ),
37696
- quantity: Schema9.BigDecimal,
37697
- subtotal: Schema9.Number,
38010
+ quantity: Schema10.BigDecimal,
38011
+ subtotal: Schema10.Number,
37698
38012
  discountAmount: pipe5(
37699
- Schema9.propertySignature(Schema9.Number),
37700
- Schema9.fromKey("discount_amount")
38013
+ Schema10.propertySignature(Schema10.Number),
38014
+ Schema10.fromKey("discount_amount")
37701
38015
  ),
37702
38016
  salesTaxTotal: pipe5(
37703
- Schema9.propertySignature(Schema9.Number),
37704
- Schema9.fromKey("sales_taxes_total")
38017
+ Schema10.propertySignature(Schema10.Number),
38018
+ Schema10.fromKey("sales_taxes_total")
37705
38019
  ),
37706
38020
  totalAmount: pipe5(
37707
- Schema9.propertySignature(Schema9.Number),
37708
- Schema9.fromKey("total_amount")
38021
+ Schema10.propertySignature(Schema10.Number),
38022
+ Schema10.fromKey("total_amount")
37709
38023
  ),
37710
- memo: Schema9.NullOr(Schema9.String)
38024
+ memo: Schema10.NullOr(Schema10.String)
37711
38025
  });
37712
- var InvoiceSchema = Schema9.Struct({
37713
- id: Schema9.UUID,
38026
+ var InvoiceSchema = Schema10.Struct({
38027
+ id: Schema10.UUID,
37714
38028
  businessId: pipe5(
37715
- Schema9.propertySignature(Schema9.UUID),
37716
- Schema9.fromKey("business_id")
38029
+ Schema10.propertySignature(Schema10.UUID),
38030
+ Schema10.fromKey("business_id")
37717
38031
  ),
37718
38032
  externalId: pipe5(
37719
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37720
- Schema9.fromKey("external_id")
38033
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38034
+ Schema10.fromKey("external_id")
37721
38035
  ),
37722
38036
  status: TransformedInvoiceStatusSchema,
37723
38037
  sentAt: pipe5(
37724
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37725
- Schema9.fromKey("sent_at")
38038
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38039
+ Schema10.fromKey("sent_at")
37726
38040
  ),
37727
38041
  dueAt: pipe5(
37728
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37729
- Schema9.fromKey("due_at")
38042
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38043
+ Schema10.fromKey("due_at")
37730
38044
  ),
37731
38045
  paidAt: pipe5(
37732
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37733
- Schema9.fromKey("paid_at")
38046
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38047
+ Schema10.fromKey("paid_at")
37734
38048
  ),
37735
38049
  voidedAt: pipe5(
37736
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37737
- Schema9.fromKey("voided_at")
38050
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38051
+ Schema10.fromKey("voided_at")
37738
38052
  ),
37739
38053
  invoiceNumber: pipe5(
37740
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37741
- Schema9.fromKey("invoice_number")
38054
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38055
+ Schema10.fromKey("invoice_number")
37742
38056
  ),
37743
38057
  recipientName: pipe5(
37744
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37745
- Schema9.fromKey("recipient_name")
38058
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38059
+ Schema10.fromKey("recipient_name")
37746
38060
  ),
37747
- customer: Schema9.NullOr(CustomerSchema),
38061
+ customer: Schema10.NullOr(CustomerSchema),
37748
38062
  lineItems: pipe5(
37749
- Schema9.propertySignature(Schema9.Array(InvoiceLineItemSchema)),
37750
- Schema9.fromKey("line_items")
38063
+ Schema10.propertySignature(Schema10.Array(InvoiceLineItemSchema)),
38064
+ Schema10.fromKey("line_items")
37751
38065
  ),
37752
- subtotal: Schema9.Number,
38066
+ subtotal: Schema10.Number,
37753
38067
  additionalDiscount: pipe5(
37754
- Schema9.propertySignature(Schema9.Number),
37755
- Schema9.fromKey("additional_discount")
38068
+ Schema10.propertySignature(Schema10.Number),
38069
+ Schema10.fromKey("additional_discount")
37756
38070
  ),
37757
38071
  additionalSalesTaxesTotal: pipe5(
37758
- Schema9.propertySignature(Schema9.Number),
37759
- Schema9.fromKey("additional_sales_taxes_total")
38072
+ Schema10.propertySignature(Schema10.Number),
38073
+ Schema10.fromKey("additional_sales_taxes_total")
37760
38074
  ),
37761
38075
  totalAmount: pipe5(
37762
- Schema9.propertySignature(Schema9.Number),
37763
- Schema9.fromKey("total_amount")
38076
+ Schema10.propertySignature(Schema10.Number),
38077
+ Schema10.fromKey("total_amount")
37764
38078
  ),
37765
38079
  outstandingBalance: pipe5(
37766
- Schema9.propertySignature(Schema9.Number),
37767
- Schema9.fromKey("outstanding_balance")
38080
+ Schema10.propertySignature(Schema10.Number),
38081
+ Schema10.fromKey("outstanding_balance")
37768
38082
  ),
37769
38083
  importedAt: pipe5(
37770
- Schema9.propertySignature(Schema9.Date),
37771
- Schema9.fromKey("imported_at")
38084
+ Schema10.propertySignature(Schema10.Date),
38085
+ Schema10.fromKey("imported_at")
37772
38086
  ),
37773
38087
  updatedAt: pipe5(
37774
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37775
- Schema9.fromKey("updated_at")
38088
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38089
+ Schema10.fromKey("updated_at")
37776
38090
  ),
37777
- memo: Schema9.NullOr(Schema9.String)
38091
+ memo: Schema10.NullOr(Schema10.String)
37778
38092
  });
37779
- var UpsertInvoiceTaxLineItemSchema = Schema9.Struct({
37780
- amount: Schema9.Number
38093
+ var UpsertInvoiceTaxLineItemSchema = Schema10.Struct({
38094
+ amount: Schema10.Number
37781
38095
  });
37782
- var UpsertInvoiceLineItemSchema = Schema9.Struct({
37783
- description: Schema9.String,
37784
- product: Schema9.String,
38096
+ var UpsertInvoiceLineItemSchema = Schema10.Struct({
38097
+ description: Schema10.String,
38098
+ product: Schema10.String,
37785
38099
  unitPrice: pipe5(
37786
- Schema9.propertySignature(Schema9.Number),
37787
- Schema9.fromKey("unit_price")
38100
+ Schema10.propertySignature(Schema10.Number),
38101
+ Schema10.fromKey("unit_price")
37788
38102
  ),
37789
- quantity: Schema9.BigDecimal
38103
+ quantity: Schema10.BigDecimal,
38104
+ salesTaxes: pipe5(
38105
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.Array(UpsertInvoiceTaxLineItemSchema))),
38106
+ Schema10.fromKey("sales_taxes")
38107
+ )
37790
38108
  });
37791
- var UpsertInvoiceSchema = Schema9.Struct({
38109
+ var UpsertInvoiceSchema = Schema10.Struct({
37792
38110
  sentAt: pipe5(
37793
- Schema9.propertySignature(Schema9.Date),
37794
- Schema9.fromKey("sent_at")
38111
+ Schema10.propertySignature(Schema10.Date),
38112
+ Schema10.fromKey("sent_at")
37795
38113
  ),
37796
38114
  dueAt: pipe5(
37797
- Schema9.propertySignature(Schema9.Date),
37798
- Schema9.fromKey("due_at")
38115
+ Schema10.propertySignature(Schema10.Date),
38116
+ Schema10.fromKey("due_at")
37799
38117
  ),
37800
38118
  invoiceNumber: pipe5(
37801
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.String)),
37802
- Schema9.fromKey("invoice_number")
38119
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.String)),
38120
+ Schema10.fromKey("invoice_number")
37803
38121
  ),
37804
38122
  customerId: pipe5(
37805
- Schema9.propertySignature(Schema9.UUID),
37806
- Schema9.fromKey("customer_id")
38123
+ Schema10.propertySignature(Schema10.UUID),
38124
+ Schema10.fromKey("customer_id")
37807
38125
  ),
37808
- memo: Schema9.NullOr(Schema9.String),
38126
+ memo: Schema10.NullOr(Schema10.String),
37809
38127
  lineItems: pipe5(
37810
- Schema9.propertySignature(Schema9.Array(UpsertInvoiceLineItemSchema)),
37811
- Schema9.fromKey("line_items")
38128
+ Schema10.propertySignature(Schema10.Array(UpsertInvoiceLineItemSchema)),
38129
+ Schema10.fromKey("line_items")
37812
38130
  ),
37813
38131
  additionalDiscount: pipe5(
37814
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.Number)),
37815
- Schema9.fromKey("additional_discount")
37816
- ),
37817
- additionalSalesTaxes: pipe5(
37818
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.Array(UpsertInvoiceTaxLineItemSchema))),
37819
- Schema9.fromKey("additional_sales_taxes")
38132
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.Number)),
38133
+ Schema10.fromKey("additional_discount")
37820
38134
  )
37821
38135
  });
38136
+ var InvoiceFormLineItemSchema = Schema10.Struct({
38137
+ description: Schema10.String,
38138
+ product: Schema10.String,
38139
+ unitPrice: Schema10.BigDecimal,
38140
+ quantity: Schema10.BigDecimal,
38141
+ amount: Schema10.BigDecimal,
38142
+ isTaxable: Schema10.Boolean
38143
+ });
38144
+ var InvoiceTermsValuesSchema = Schema10.Enums(InvoiceTermsValues);
38145
+ var InvoiceFormSchema = Schema10.Struct({
38146
+ terms: InvoiceTermsValuesSchema,
38147
+ sentAt: Schema10.NullOr(ZonedDateTimeFromSelf),
38148
+ dueAt: Schema10.NullOr(ZonedDateTimeFromSelf),
38149
+ invoiceNumber: Schema10.String,
38150
+ customer: Schema10.NullOr(CustomerSchema),
38151
+ email: Schema10.String,
38152
+ address: Schema10.String,
38153
+ lineItems: Schema10.Array(InvoiceFormLineItemSchema),
38154
+ discountRate: Schema10.BigDecimal,
38155
+ taxRate: Schema10.BigDecimal,
38156
+ memo: Schema10.String
38157
+ });
37822
38158
 
37823
38159
  // src/features/invoices/api/useUpsertInvoice.tsx
37824
38160
  import { useCallback as useCallback53 } from "react";
37825
38161
  import useSWRMutation26 from "swr/mutation";
37826
- import { Schema as Schema10, Effect } from "effect";
38162
+ import { Schema as Schema11, Effect } from "effect";
37827
38163
  var UPSERT_INVOICES_TAG_KEY = "#upsert-invoice";
37828
38164
  var createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
37829
38165
  var updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
@@ -37843,7 +38179,7 @@ function buildKey39({
37843
38179
  };
37844
38180
  }
37845
38181
  }
37846
- var UpsertInvoiceReturnSchema = Schema10.Struct({
38182
+ var UpsertInvoiceReturnSchema = Schema11.Struct({
37847
38183
  data: InvoiceSchema
37848
38184
  });
37849
38185
  var UpsertInvoiceSWRResponse = class {
@@ -37864,19 +38200,19 @@ var UpsertInvoiceSWRResponse = class {
37864
38200
  return this.swrResponse.error !== void 0;
37865
38201
  }
37866
38202
  };
37867
- var CreateParamsSchema = Schema10.Struct({
37868
- businessId: Schema10.String
38203
+ var CreateParamsSchema = Schema11.Struct({
38204
+ businessId: Schema11.String
37869
38205
  });
37870
- var UpdateParamsSchema = Schema10.Struct({
37871
- businessId: Schema10.String,
37872
- invoiceId: Schema10.String
38206
+ var UpdateParamsSchema = Schema11.Struct({
38207
+ businessId: Schema11.String,
38208
+ invoiceId: Schema11.String
37873
38209
  });
37874
38210
  var isParamsValidForMode = (mode, params) => {
37875
38211
  if (mode === "Update" /* Update */) {
37876
- return Effect.runSync(Effect.either(Schema10.decodeUnknown(UpdateParamsSchema)(params)))._tag === "Right";
38212
+ return Effect.runSync(Effect.either(Schema11.decodeUnknown(UpdateParamsSchema)(params)))._tag === "Right";
37877
38213
  }
37878
38214
  if (mode === "Create" /* Create */) {
37879
- return Effect.runSync(Effect.either(Schema10.decodeUnknown(CreateParamsSchema)(params)))._tag === "Right";
38215
+ return Effect.runSync(Effect.either(Schema11.decodeUnknown(CreateParamsSchema)(params)))._tag === "Right";
37880
38216
  }
37881
38217
  return false;
37882
38218
  };
@@ -37909,10 +38245,11 @@ var useUpsertInvoice = (props) => {
37909
38245
  apiUrl,
37910
38246
  accessToken,
37911
38247
  body
37912
- }).then(Schema10.decodeUnknownPromise(UpsertInvoiceReturnSchema));
38248
+ }).then(Schema11.decodeUnknownPromise(UpsertInvoiceReturnSchema));
37913
38249
  },
37914
38250
  {
37915
- revalidate: false
38251
+ revalidate: false,
38252
+ throwOnError: true
37916
38253
  }
37917
38254
  );
37918
38255
  const mutationResponse = new UpsertInvoiceSWRResponse(rawMutationResponse);
@@ -37935,67 +38272,283 @@ var useUpsertInvoice = (props) => {
37935
38272
  };
37936
38273
 
37937
38274
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
37938
- import { BigDecimal as BD4, Schema as Schema11 } from "effect";
37939
- var EMPTY_LINE_ITEM = {
38275
+ import { Schema as Schema12 } from "effect";
38276
+
38277
+ // src/components/Invoices/InvoiceForm/totalsUtils.ts
38278
+ import { BigDecimal as BD3 } from "effect";
38279
+ function computeSubtotal(lineItems) {
38280
+ return lineItems.reduce((sum, item) => BD3.sum(sum, item.amount), BIG_DECIMAL_ZERO);
38281
+ }
38282
+ var computeRawTaxableSubtotal = (lineItems) => lineItems.filter((item) => item.isTaxable).reduce((sum, item) => BD3.sum(sum, item.amount), BIG_DECIMAL_ZERO);
38283
+ function computeAdditionalDiscount({
38284
+ subtotal,
38285
+ discountRate
38286
+ }) {
38287
+ const rawDiscountAmount = BD3.multiply(subtotal, discountRate);
38288
+ const additionalDiscount = roundDecimalToCents(rawDiscountAmount);
38289
+ return additionalDiscount;
38290
+ }
38291
+ function computeTaxableSubtotal({
38292
+ rawTaxableSubtotal,
38293
+ discountRate
38294
+ }) {
38295
+ const discountForTaxableSubtotal = BD3.multiply(rawTaxableSubtotal, discountRate);
38296
+ const taxableSubtotal = BD3.subtract(rawTaxableSubtotal, discountForTaxableSubtotal);
38297
+ return taxableSubtotal;
38298
+ }
38299
+ function computeTaxes({
38300
+ taxableSubtotal,
38301
+ taxRate
38302
+ }) {
38303
+ const rawTaxAmount = BD3.multiply(taxableSubtotal, taxRate);
38304
+ const taxes = roundDecimalToCents(rawTaxAmount);
38305
+ return taxes;
38306
+ }
38307
+ function computeGrandTotal({
38308
+ subtotal,
38309
+ additionalDiscount,
38310
+ taxes
38311
+ }) {
38312
+ const subtotalLessDiscounts = BD3.subtract(subtotal, additionalDiscount);
38313
+ const grandTotal = BD3.sum(subtotalLessDiscounts, taxes);
38314
+ return grandTotal;
38315
+ }
38316
+ var getGrandTotalFromInvoice = (invoice) => {
38317
+ const { lineItems, discountRate, taxRate } = invoice;
38318
+ const subtotal = computeSubtotal(lineItems);
38319
+ const rawTaxableSubtotal = computeRawTaxableSubtotal(lineItems);
38320
+ const taxableSubtotal = computeTaxableSubtotal({ rawTaxableSubtotal, discountRate });
38321
+ const taxes = computeTaxes({ taxableSubtotal, taxRate });
38322
+ const additionalDiscount = computeAdditionalDiscount({ subtotal, discountRate });
38323
+ const grandTotal = computeGrandTotal({ subtotal, additionalDiscount, taxes });
38324
+ return grandTotal;
38325
+ };
38326
+
38327
+ // src/components/Invoices/InvoiceForm/formUtils.ts
38328
+ import { BigDecimal as BD4 } from "effect";
38329
+ import { startOfToday } from "date-fns";
38330
+ import { getLocalTimeZone, fromDate } from "@internationalized/date";
38331
+ var import_lodash6 = __toESM(require_lodash2());
38332
+ var getEmptyLineItem = () => ({
37940
38333
  product: "",
37941
38334
  description: "",
37942
- unitPrice: 0,
38335
+ unitPrice: BIG_DECIMAL_ZERO,
37943
38336
  quantity: BIG_DECIMAL_ONE,
37944
- amount: 0,
38337
+ amount: BIG_DECIMAL_ZERO,
37945
38338
  isTaxable: false
37946
- };
37947
- var DEFAULT_FORM_VALUES = {
37948
- invoiceNumber: "",
37949
- customer: null,
37950
- email: "",
37951
- address: "",
37952
- lineItems: [EMPTY_LINE_ITEM]
38339
+ });
38340
+ var getInvoiceFormDefaultValues = () => {
38341
+ const sentAt = fromDate(startOfToday(), getLocalTimeZone());
38342
+ const dueAt = sentAt.add({ days: 30 });
38343
+ return {
38344
+ invoiceNumber: "",
38345
+ terms: "Net30" /* Net30 */,
38346
+ sentAt,
38347
+ dueAt,
38348
+ customer: null,
38349
+ email: "",
38350
+ address: "",
38351
+ lineItems: [getEmptyLineItem()],
38352
+ memo: "",
38353
+ discountRate: BIG_DECIMAL_ZERO,
38354
+ taxRate: BIG_DECIMAL_ZERO
38355
+ };
37953
38356
  };
37954
38357
  var getInvoiceLineItemAmount = (lineItem) => {
37955
38358
  const { unitPrice, quantity } = lineItem;
37956
- return convertBigDecimalToCents(BD4.multiply(quantity, convertCentsToBigDecimal(unitPrice)));
38359
+ return BD4.multiply(quantity, convertCentsToBigDecimal(unitPrice));
37957
38360
  };
37958
- var getAugmentedInvoiceFormLineItem = (lineItem) => {
37959
- return __spreadProps(__spreadValues({}, lineItem), {
38361
+ var getInvoiceFormLineItem = (lineItem) => {
38362
+ const { product, description, unitPrice, quantity } = lineItem;
38363
+ return {
38364
+ product: product || "",
38365
+ description: description || "",
38366
+ quantity: BD4.normalize(quantity),
38367
+ unitPrice: convertCentsToBigDecimal(unitPrice),
37960
38368
  amount: getInvoiceLineItemAmount(lineItem),
37961
38369
  isTaxable: lineItem.salesTaxTotal > 0
37962
- });
38370
+ };
37963
38371
  };
37964
- var getInvoiceFormDefaultValues = (invoice) => {
38372
+ var getInvoiceFormInitialValues = (invoice) => {
37965
38373
  var _a, _b;
38374
+ const invoiceFormLineItems = invoice.lineItems.map(getInvoiceFormLineItem);
38375
+ const subtotal = computeSubtotal(invoiceFormLineItems);
38376
+ const rawTaxableSubtotal = computeRawTaxableSubtotal(invoiceFormLineItems);
38377
+ const additionalDiscount = convertCentsToBigDecimal(invoice.additionalDiscount);
38378
+ const discountRate = safeDivide(additionalDiscount, subtotal);
38379
+ const taxableSubtotal = computeTaxableSubtotal({ rawTaxableSubtotal, discountRate });
38380
+ const taxes = invoice.lineItems.reduce(
38381
+ (sum, item) => BD4.sum(sum, convertCentsToBigDecimal(item.salesTaxTotal)),
38382
+ BIG_DECIMAL_ZERO
38383
+ );
38384
+ const taxRate = safeDivide(taxes, taxableSubtotal);
38385
+ const sentAt = invoice.sentAt ? fromDate(invoice.sentAt, "UTC") : null;
38386
+ const dueAt = invoice.dueAt ? fromDate(invoice.dueAt, "UTC") : null;
37966
38387
  return {
37967
- invoiceNumber: invoice.invoiceNumber,
38388
+ terms: getInvoiceTermsFromDates(sentAt, dueAt),
38389
+ invoiceNumber: invoice.invoiceNumber || "",
38390
+ sentAt,
38391
+ dueAt,
37968
38392
  customer: invoice.customer,
37969
- email: (_a = invoice.customer) == null ? void 0 : _a.email,
37970
- address: (_b = invoice.customer) == null ? void 0 : _b.addressString,
37971
- lineItems: invoice.lineItems.map(getAugmentedInvoiceFormLineItem)
38393
+ email: ((_a = invoice.customer) == null ? void 0 : _a.email) || "",
38394
+ address: ((_b = invoice.customer) == null ? void 0 : _b.addressString) || "",
38395
+ lineItems: invoiceFormLineItems,
38396
+ discountRate,
38397
+ taxRate,
38398
+ memo: invoice.memo || ""
37972
38399
  };
37973
38400
  };
38401
+ var getIsEqualLineItems = (a, b) => {
38402
+ return (0, import_lodash6.isEqualWith)(a, b, (val1, val2, key) => {
38403
+ if (key === "unitPrice" || key === "quantity" || key === "amount") {
38404
+ return BD4.isBigDecimal(val1) && BD4.isBigDecimal(val2) && BD4.equals(val1, val2);
38405
+ }
38406
+ return void 0;
38407
+ });
38408
+ };
38409
+ var validateOnSubmit = ({ value: invoice }) => {
38410
+ const errors = [];
38411
+ if (invoice.customer === null) {
38412
+ errors.push({ customer: "Customer is a required field." });
38413
+ }
38414
+ if (!invoice.invoiceNumber.trim()) {
38415
+ errors.push({ invoiceNumber: "Invoice number is a required field." });
38416
+ }
38417
+ if (invoice.sentAt === null) {
38418
+ errors.push({ sentAt: "Invoice date is a required field." });
38419
+ }
38420
+ if (invoice.dueAt === null) {
38421
+ errors.push({ dueAt: "Due date is a required field." });
38422
+ }
38423
+ if (invoice.lineItems.length === 0) {
38424
+ errors.push({ lineItems: "Invoice requires at least one line item." });
38425
+ }
38426
+ const emptyLineItem = getEmptyLineItem();
38427
+ invoice.lineItems.some((item) => {
38428
+ if (!getIsEqualLineItems(item, emptyLineItem) && item.product === "") {
38429
+ errors.push({ lineItems: "Invoice has incomplete line items. Please include required field Product/Service." });
38430
+ return true;
38431
+ }
38432
+ });
38433
+ const grandTotal = getGrandTotalFromInvoice(invoice);
38434
+ if (BD4.isNegative(grandTotal)) {
38435
+ errors.push({ lineItems: "Invoice has a negative total." });
38436
+ }
38437
+ return errors.length > 0 ? errors : null;
38438
+ };
38439
+ function flattenValidationErrors(errors) {
38440
+ return Object.values(errors).filter(
38441
+ (value) => Array.isArray(value) && value.every((entry) => typeof entry === "object" && entry !== null)
38442
+ ).flatMap(
38443
+ (errorArray) => errorArray.flatMap(
38444
+ (entry) => Object.values(entry)
38445
+ )
38446
+ );
38447
+ }
38448
+ var convertInvoiceFormToParams = (form) => {
38449
+ var _a, _b, _c;
38450
+ return __spreadValues({
38451
+ customerId: (_a = form.customer) == null ? void 0 : _a.id,
38452
+ dueAt: (_b = form.dueAt) == null ? void 0 : _b.toDate(),
38453
+ sentAt: (_c = form.sentAt) == null ? void 0 : _c.toDate(),
38454
+ invoiceNumber: form.invoiceNumber || void 0,
38455
+ memo: form.memo,
38456
+ lineItems: form.lineItems.map((item) => {
38457
+ const baseLineItem = {
38458
+ description: item.description,
38459
+ product: item.product,
38460
+ unitPrice: convertBigDecimalToCents(item.unitPrice),
38461
+ quantity: item.quantity
38462
+ };
38463
+ return !BD4.equals(form.taxRate, BIG_DECIMAL_ZERO) && item.isTaxable ? __spreadProps(__spreadValues({}, baseLineItem), {
38464
+ salesTaxes: [
38465
+ {
38466
+ amount: convertBigDecimalToCents(
38467
+ BD4.multiply(item.amount, form.taxRate)
38468
+ )
38469
+ }
38470
+ ]
38471
+ }) : baseLineItem;
38472
+ })
38473
+ }, !BD4.equals(form.discountRate, BIG_DECIMAL_ZERO) && {
38474
+ additionalDiscount: convertBigDecimalToCents(
38475
+ BD4.multiply(computeSubtotal(form.lineItems), form.discountRate)
38476
+ )
38477
+ });
38478
+ };
38479
+
38480
+ // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
38481
+ function isUpdateMode(props) {
38482
+ return props.mode === "Update" /* Update */;
38483
+ }
37974
38484
  var useInvoiceForm = (props) => {
37975
38485
  const [submitError, setSubmitError] = useState84(void 0);
37976
38486
  const { onSuccess, mode } = props;
37977
38487
  const upsertInvoiceProps = mode === "Update" /* Update */ ? { mode, invoiceId: props.invoice.id } : { mode };
37978
38488
  const { trigger: upsertInvoice } = useUpsertInvoice(upsertInvoiceProps);
37979
- const defaultValues = mode === "Update" /* Update */ ? getInvoiceFormDefaultValues(props.invoice) : DEFAULT_FORM_VALUES;
37980
- const form = useAppForm({
37981
- defaultValues,
37982
- onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
37983
- var _a;
37984
- try {
37985
- const payload = __spreadProps(__spreadValues({}, value), {
37986
- customerId: (_a = value == null ? void 0 : value.customer) == null ? void 0 : _a.id
37987
- });
37988
- const invoiceParams = Schema11.validateSync(UpsertInvoiceSchema)(payload);
37989
- const { data: invoice } = yield upsertInvoice(invoiceParams);
37990
- setSubmitError(void 0);
37991
- onSuccess == null ? void 0 : onSuccess(invoice);
37992
- } catch (e) {
37993
- setSubmitError("Something went wrong. Please try again.");
37994
- }
37995
- })
37996
- });
38489
+ const defaultValuesRef = useRef30(
38490
+ isUpdateMode(props) ? getInvoiceFormInitialValues(props.invoice) : getInvoiceFormDefaultValues()
38491
+ );
38492
+ const defaultValues = defaultValuesRef.current;
38493
+ const onSubmit = useCallback54((_0) => __async(null, [_0], function* ({ value }) {
38494
+ try {
38495
+ const upsertInvoiceParams = convertInvoiceFormToParams(value);
38496
+ const upsertInvoiceRequest = Schema12.encodeUnknownSync(UpsertInvoiceSchema)(upsertInvoiceParams);
38497
+ const { data: invoice } = yield upsertInvoice(upsertInvoiceRequest);
38498
+ setSubmitError(void 0);
38499
+ onSuccess == null ? void 0 : onSuccess(invoice);
38500
+ } catch (e) {
38501
+ console.error(e);
38502
+ setSubmitError("Something went wrong. Please try again.");
38503
+ }
38504
+ }), [onSuccess, upsertInvoice]);
38505
+ const validators = useMemo72(() => ({
38506
+ onSubmit: validateOnSubmit
38507
+ }), []);
38508
+ const form = useAppForm({ defaultValues, onSubmit, validators });
37997
38509
  const isFormValid = useStore7(form.store, (state) => state.isValid);
37998
- return { form, submitError, isFormValid };
38510
+ const isSubmitting = useStore7(form.store, (state) => state.isSubmitting);
38511
+ const formState = useMemo72(() => ({
38512
+ isFormValid,
38513
+ isSubmitting,
38514
+ submitError
38515
+ }), [isFormValid, isSubmitting, submitError]);
38516
+ const discountRate = useStore7(form.store, (state) => state.values.discountRate);
38517
+ const taxRate = useStore7(form.store, (state) => state.values.taxRate);
38518
+ const { subtotal, rawTaxableSubtotal } = useStore7(form.store, (state) => {
38519
+ const lineItems = state.values.lineItems;
38520
+ return {
38521
+ subtotal: computeSubtotal(lineItems),
38522
+ rawTaxableSubtotal: computeRawTaxableSubtotal(lineItems)
38523
+ };
38524
+ });
38525
+ const additionalDiscount = useMemo72(
38526
+ () => computeAdditionalDiscount({ subtotal, discountRate }),
38527
+ [subtotal, discountRate]
38528
+ );
38529
+ const taxableSubtotal = useMemo72(
38530
+ () => computeTaxableSubtotal({ rawTaxableSubtotal, discountRate }),
38531
+ [rawTaxableSubtotal, discountRate]
38532
+ );
38533
+ const taxes = useMemo72(
38534
+ () => computeTaxes({ taxableSubtotal, taxRate }),
38535
+ [taxableSubtotal, taxRate]
38536
+ );
38537
+ const grandTotal = useMemo72(
38538
+ () => computeGrandTotal({ subtotal, additionalDiscount, taxes }),
38539
+ [subtotal, additionalDiscount, taxes]
38540
+ );
38541
+ const totals = useMemo72(() => ({
38542
+ subtotal,
38543
+ additionalDiscount,
38544
+ taxableSubtotal,
38545
+ taxes,
38546
+ grandTotal
38547
+ }), [additionalDiscount, grandTotal, subtotal, taxableSubtotal, taxes]);
38548
+ return useMemo72(
38549
+ () => ({ form, formState, totals }),
38550
+ [form, formState, totals]
38551
+ );
37999
38552
  };
38000
38553
 
38001
38554
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
@@ -38003,9 +38556,9 @@ import { Plus as Plus2, Trash as Trash2 } from "lucide-react";
38003
38556
  import { BigDecimal as BD5 } from "effect";
38004
38557
 
38005
38558
  // src/features/customers/components/CustomerSelector.tsx
38006
- import { useCallback as useCallback54, useId as useId5, useMemo as useMemo72 } from "react";
38007
- import classNames90 from "classnames";
38008
- import { jsx as jsx337, jsxs as jsxs212 } from "react/jsx-runtime";
38559
+ import { useCallback as useCallback55, useId as useId6, useMemo as useMemo73 } from "react";
38560
+ import classNames91 from "classnames";
38561
+ import { jsx as jsx339, jsxs as jsxs214 } from "react/jsx-runtime";
38009
38562
  function getCustomerName(customer) {
38010
38563
  var _a, _b, _c;
38011
38564
  return (_c = (_b = (_a = customer.individualName) != null ? _a : customer.companyName) != null ? _b : customer.externalId) != null ? _c : "Unknown Customer";
@@ -38036,7 +38589,7 @@ function CustomerSelector({
38036
38589
  inline,
38037
38590
  className
38038
38591
  }) {
38039
- const combinedClassName = classNames90(
38592
+ const combinedClassName = classNames91(
38040
38593
  "Layer__CustomerSelector",
38041
38594
  inline && "Layer__CustomerSelector--inline",
38042
38595
  className
@@ -38046,12 +38599,12 @@ function CustomerSelector({
38046
38599
  });
38047
38600
  const effectiveSearchQuery = searchQuery === "" ? void 0 : searchQuery;
38048
38601
  const { data, isLoading, isError } = useListCustomers({ query: effectiveSearchQuery });
38049
- const options = useMemo72(
38602
+ const options2 = useMemo73(
38050
38603
  () => (data == null ? void 0 : data.flatMap(({ data: data2 }) => data2).map((customer) => new CustomerAsOption(customer))) || [],
38051
38604
  [data]
38052
38605
  );
38053
38606
  const selectedCustomerId = selectedCustomer == null ? void 0 : selectedCustomer.id;
38054
- const handleSelectionChange = useCallback54(
38607
+ const handleSelectionChange = useCallback55(
38055
38608
  (selectedOption) => {
38056
38609
  if (selectedOption === null) {
38057
38610
  handleInputChange("");
@@ -38060,7 +38613,7 @@ function CustomerSelector({
38060
38613
  }
38061
38614
  return;
38062
38615
  }
38063
- const selectedCustomer2 = options.find(({ id }) => id === selectedOption.value);
38616
+ const selectedCustomer2 = options2.find(({ id }) => id === selectedOption.value);
38064
38617
  if (selectedCustomer2) {
38065
38618
  const selectedCustomerWithType = selectedCustomer2.original;
38066
38619
  if (selectedCustomer2.id !== selectedCustomerId) {
@@ -38070,9 +38623,9 @@ function CustomerSelector({
38070
38623
  return;
38071
38624
  }
38072
38625
  },
38073
- [options, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38626
+ [options2, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38074
38627
  );
38075
- const selectedCustomerForComboBox = useMemo72(
38628
+ const selectedCustomerForComboBox = useMemo73(
38076
38629
  () => {
38077
38630
  if (selectedCustomer === null) {
38078
38631
  return null;
@@ -38084,12 +38637,12 @@ function CustomerSelector({
38084
38637
  },
38085
38638
  [selectedCustomer]
38086
38639
  );
38087
- const EmptyMessage = useMemo72(
38088
- () => /* @__PURE__ */ jsx337(P, { variant: "subtle", children: "No matching customer" }),
38640
+ const EmptyMessage = useMemo73(
38641
+ () => /* @__PURE__ */ jsx339(P, { variant: "subtle", children: "No matching customer" }),
38089
38642
  []
38090
38643
  );
38091
- const ErrorMessage = useMemo72(
38092
- () => /* @__PURE__ */ jsx337(
38644
+ const ErrorMessage = useMemo73(
38645
+ () => /* @__PURE__ */ jsx339(
38093
38646
  P,
38094
38647
  {
38095
38648
  size: "xs",
@@ -38099,143 +38652,287 @@ function CustomerSelector({
38099
38652
  ),
38100
38653
  []
38101
38654
  );
38102
- const inputId = useId5();
38103
- const isFiltered = effectiveSearchQuery !== void 0;
38104
- const noCustomersExist = !isLoading && !isFiltered && data !== void 0 && data.every(({ data: data2 }) => data2.length === 0);
38105
- const shouldHideComponent = noCustomersExist || isReadOnly && selectedCustomer === null;
38106
- if (shouldHideComponent) {
38107
- return null;
38108
- }
38655
+ const inputId = useId6();
38109
38656
  const isLoadingWithoutFallback = isLoading && !data;
38110
38657
  const shouldDisableComboBox = isLoadingWithoutFallback || isError;
38111
- return /* @__PURE__ */ jsxs212(VStack, { className: combinedClassName, children: [
38112
- /* @__PURE__ */ jsx337(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38113
- /* @__PURE__ */ jsx337(
38658
+ return /* @__PURE__ */ jsxs214(VStack, { className: combinedClassName, children: [
38659
+ /* @__PURE__ */ jsx339(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38660
+ /* @__PURE__ */ jsx339(
38114
38661
  ComboBox,
38115
38662
  {
38116
38663
  selectedValue: selectedCustomerForComboBox,
38117
38664
  onSelectedValueChange: handleSelectionChange,
38118
- options,
38665
+ options: options2,
38119
38666
  onInputValueChange: handleInputChange,
38120
38667
  inputId,
38121
38668
  placeholder,
38122
38669
  slots: { EmptyMessage, ErrorMessage },
38123
- isDisabled: isReadOnly || shouldDisableComboBox,
38670
+ isDisabled: shouldDisableComboBox,
38124
38671
  isError,
38125
- isLoading: isLoadingWithoutFallback
38672
+ isLoading: isLoadingWithoutFallback,
38673
+ isReadOnly
38126
38674
  }
38127
38675
  )
38128
38676
  ] });
38129
38677
  }
38130
38678
 
38131
38679
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
38132
- import { jsx as jsx338, jsxs as jsxs213 } from "react/jsx-runtime";
38680
+ import { AlertTriangle } from "lucide-react";
38681
+ import { jsx as jsx340, jsxs as jsxs215 } from "react/jsx-runtime";
38133
38682
  var INVOICE_FORM_CSS_PREFIX = "Layer__InvoiceForm";
38134
38683
  var INVOICE_FORM_FIELD_CSS_PREFIX = `${INVOICE_FORM_CSS_PREFIX}__Field`;
38135
- var InvoiceForm = (props) => {
38136
- const { onSuccess, mode } = props;
38137
- const { form } = useInvoiceForm(
38684
+ var getDueAtChanged = (dueAt, previousDueAt) => dueAt === null && previousDueAt !== null || dueAt !== null && previousDueAt === null || dueAt !== null && previousDueAt !== null && dueAt.compare(previousDueAt) !== 0;
38685
+ var InvoiceFormTotalRow = ({ label, value, children }) => {
38686
+ const className = classNames92(
38687
+ `${INVOICE_FORM_CSS_PREFIX}__TotalRow`,
38688
+ children && `${INVOICE_FORM_CSS_PREFIX}__TotalRow--withField`
38689
+ );
38690
+ return /* @__PURE__ */ jsxs215(HStack, { className, align: "center", gap: "md", children: [
38691
+ /* @__PURE__ */ jsx340(Span, { children: label }),
38692
+ children,
38693
+ /* @__PURE__ */ jsx340(Span, { align: "right", children: convertCentsToCurrency(convertBigDecimalToCents(value)) })
38694
+ ] });
38695
+ };
38696
+ var InvoiceForm = forwardRef25((props, ref) => {
38697
+ const { onSuccess, onChangeFormState, isReadOnly, mode } = props;
38698
+ const { form, formState, totals } = useInvoiceForm(
38138
38699
  __spreadValues({ onSuccess }, mode === "Update" /* Update */ ? { mode, invoice: props.invoice } : { mode })
38139
38700
  );
38140
- return /* @__PURE__ */ jsxs213(Form, { className: INVOICE_FORM_CSS_PREFIX, children: [
38141
- /* @__PURE__ */ jsxs213(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, gap: "xs", children: [
38142
- /* @__PURE__ */ jsx338(
38143
- form.Field,
38144
- {
38145
- name: "customer",
38146
- listeners: {
38147
- onChange: ({ value: customer }) => {
38148
- form.setFieldValue("email", customer == null ? void 0 : customer.email);
38149
- form.setFieldValue("address", customer == null ? void 0 : customer.addressString);
38150
- }
38151
- },
38152
- children: (field) => /* @__PURE__ */ jsx338(
38153
- CustomerSelector,
38154
- {
38155
- className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38156
- selectedCustomer: field.state.value,
38157
- onSelectedCustomerChange: field.handleChange,
38158
- inline: true
38159
- }
38160
- )
38161
- }
38162
- ),
38163
- /* @__PURE__ */ jsx338(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ jsx338(field.FormTextField, { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email` }) }),
38164
- /* @__PURE__ */ jsx338(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ jsx338(field.FormTextAreaField, { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address` }) })
38165
- ] }),
38166
- /* @__PURE__ */ jsx338(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "xs", children: /* @__PURE__ */ jsx338(form.AppField, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ jsxs213(VStack, { gap: "xs", align: "baseline", children: [
38167
- field.state.value.map((_, index) => /* @__PURE__ */ jsxs213(HStack, { gap: "xs", align: "end", className: `${INVOICE_FORM_CSS_PREFIX}__LineItem`, children: [
38168
- /* @__PURE__ */ jsx338(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormTextField, { label: "Product", showLabel: index === 0 }) }),
38169
- /* @__PURE__ */ jsx338(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormTextField, { label: "Description", showLabel: index === 0 }) }),
38170
- /* @__PURE__ */ jsx338(
38171
- form.AppField,
38701
+ const { subtotal, additionalDiscount, taxableSubtotal, taxes, grandTotal } = totals;
38702
+ const lastDueAtRef = useRef31(null);
38703
+ const updateDueAtFromTermsAndSentAt = useCallback56((terms, sentAt) => {
38704
+ if (sentAt == null) return;
38705
+ const duration = getDurationInDaysFromTerms(terms);
38706
+ if (!duration) return;
38707
+ const newDueAt = sentAt.add({ days: duration });
38708
+ const dueAtChanged = getDueAtChanged(lastDueAtRef.current, newDueAt);
38709
+ if (dueAtChanged) {
38710
+ form.setFieldValue("dueAt", newDueAt);
38711
+ lastDueAtRef.current = newDueAt;
38712
+ }
38713
+ }, [form]);
38714
+ const blockNativeOnSubmit = useCallback56((e) => {
38715
+ e.preventDefault();
38716
+ e.stopPropagation();
38717
+ }, []);
38718
+ useImperativeHandle4(ref, () => ({
38719
+ submit: () => form.handleSubmit()
38720
+ }));
38721
+ useEffect43(() => {
38722
+ onChangeFormState == null ? void 0 : onChangeFormState(formState);
38723
+ }, [formState, onChangeFormState]);
38724
+ return /* @__PURE__ */ jsxs215(Form, { className: INVOICE_FORM_CSS_PREFIX, onSubmit: blockNativeOnSubmit, children: [
38725
+ /* @__PURE__ */ jsx340(form.Subscribe, { selector: (state) => state.errorMap, children: (errorMap) => {
38726
+ const validationErrors = flattenValidationErrors(errorMap);
38727
+ if (validationErrors.length > 0) {
38728
+ return /* @__PURE__ */ jsx340(HStack, { className: "Layer__InvoiceForm__FormError", children: /* @__PURE__ */ jsx340(
38729
+ DataState,
38730
+ {
38731
+ className: "Layer__InvoiceForm__FormError__DataState",
38732
+ icon: /* @__PURE__ */ jsx340(AlertTriangle, { size: 16 }),
38733
+ status: "failed" /* failed */,
38734
+ title: validationErrors[0],
38735
+ titleSize: "md" /* md */,
38736
+ inline: true
38737
+ }
38738
+ ) });
38739
+ }
38740
+ } }),
38741
+ /* @__PURE__ */ jsxs215(HStack, { gap: "xl", className: `${INVOICE_FORM_CSS_PREFIX}__Terms`, children: [
38742
+ /* @__PURE__ */ jsxs215(VStack, { gap: "xs", children: [
38743
+ /* @__PURE__ */ jsx340(
38744
+ form.Field,
38745
+ {
38746
+ name: "customer",
38747
+ listeners: {
38748
+ onChange: ({ value: customer }) => {
38749
+ form.setFieldValue("email", (customer == null ? void 0 : customer.email) || "");
38750
+ form.setFieldValue("address", (customer == null ? void 0 : customer.addressString) || "");
38751
+ }
38752
+ },
38753
+ children: (field) => /* @__PURE__ */ jsx340(
38754
+ CustomerSelector,
38755
+ {
38756
+ className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38757
+ selectedCustomer: field.state.value,
38758
+ onSelectedCustomerChange: field.handleChange,
38759
+ isReadOnly,
38760
+ inline: true
38761
+ }
38762
+ )
38763
+ }
38764
+ ),
38765
+ /* @__PURE__ */ jsx340(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ jsx340(field.FormTextField, { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email`, isReadOnly: true }) }),
38766
+ /* @__PURE__ */ jsx340(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ jsx340(field.FormTextAreaField, { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address`, isReadOnly: true }) })
38767
+ ] }),
38768
+ /* @__PURE__ */ jsxs215(VStack, { gap: "xs", children: [
38769
+ /* @__PURE__ */ jsx340(form.AppField, { name: "invoiceNumber", children: (field) => /* @__PURE__ */ jsx340(field.FormTextField, { label: "Invoice number", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__InvoiceNo`, isReadOnly }) }),
38770
+ /* @__PURE__ */ jsx340(
38771
+ form.Field,
38172
38772
  {
38173
- name: `lineItems[${index}].quantity`,
38773
+ name: "terms",
38174
38774
  listeners: {
38175
- onBlur: ({ value: quantity }) => {
38176
- const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38177
- const nextAmount = BD5.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38178
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38775
+ onChange: ({ value: terms }) => {
38776
+ const sentAt = form.getFieldValue("sentAt");
38777
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38179
38778
  }
38180
38779
  },
38181
- children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormBigDecimalField, { label: "Quantity", showLabel: index === 0 })
38780
+ children: (field) => /* @__PURE__ */ jsx340(
38781
+ InvoiceTermsComboBox,
38782
+ {
38783
+ value: field.state.value,
38784
+ onValueChange: (value) => {
38785
+ if (value !== null) {
38786
+ field.handleChange(value);
38787
+ }
38788
+ },
38789
+ isReadOnly
38790
+ }
38791
+ )
38182
38792
  }
38183
38793
  ),
38184
- /* @__PURE__ */ jsx338(
38794
+ /* @__PURE__ */ jsx340(
38185
38795
  form.AppField,
38186
38796
  {
38187
- name: `lineItems[${index}].unitPrice`,
38797
+ name: "sentAt",
38188
38798
  listeners: {
38189
- onBlur: ({ value: unitPrice }) => {
38190
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38191
- const nextAmount = BD5.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38192
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38799
+ onBlur: ({ value: sentAt }) => {
38800
+ const terms = form.getFieldValue("terms");
38801
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38193
38802
  }
38194
38803
  },
38195
- children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormCurrencyField, { label: "Rate", showLabel: index === 0 })
38804
+ children: (field) => /* @__PURE__ */ jsx340(field.FormDateField, { label: "Invoice date", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__SentAt`, isReadOnly })
38196
38805
  }
38197
38806
  ),
38198
- /* @__PURE__ */ jsx338(
38807
+ /* @__PURE__ */ jsx340(
38199
38808
  form.AppField,
38200
38809
  {
38201
- name: `lineItems[${index}].amount`,
38810
+ name: "dueAt",
38202
38811
  listeners: {
38203
- onBlur: ({ value: amount }) => {
38204
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38205
- let nextUnitPrice = BIG_DECIMAL_ZERO;
38206
- try {
38207
- nextUnitPrice = BD5.unsafeDivide(convertCentsToBigDecimal(amount), quantity);
38208
- } catch (e) {
38812
+ onBlur: ({ value: dueAt }) => {
38813
+ const terms = form.getFieldValue("terms");
38814
+ const previousDueAt = lastDueAtRef.current;
38815
+ const dueAtChanged = getDueAtChanged(dueAt, previousDueAt);
38816
+ if (terms !== "Custom" /* Custom */ && dueAtChanged) {
38817
+ form.setFieldValue("terms", "Custom" /* Custom */);
38818
+ lastDueAtRef.current = dueAt;
38209
38819
  }
38210
- form.setFieldValue(`lineItems[${index}].unitPrice`, convertBigDecimalToCents(nextUnitPrice));
38211
38820
  }
38212
38821
  },
38213
- children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormCurrencyField, { label: "Amount", showLabel: index === 0 })
38822
+ children: (field) => /* @__PURE__ */ jsx340(field.FormDateField, { label: "Due date", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__DueAt`, isReadOnly })
38214
38823
  }
38215
- ),
38216
- /* @__PURE__ */ jsx338(form.AppField, { name: `lineItems[${index}].isTaxable`, children: (innerField) => /* @__PURE__ */ jsx338(innerField.FormCheckboxField, { label: "Tax", showLabel: index === 0 }) }),
38217
- /* @__PURE__ */ jsx338(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ jsx338(Trash2, { size: 16 }) })
38218
- ] }, `lineItems[${index}]`)),
38219
- /* @__PURE__ */ jsxs213(Button2, { variant: "outlined", onClick: () => field.pushValue(EMPTY_LINE_ITEM), children: [
38220
- "Add line item",
38221
- /* @__PURE__ */ jsx338(Plus2, { size: 16 })
38824
+ )
38222
38825
  ] })
38223
- ] }) }) })
38826
+ ] }),
38827
+ /* @__PURE__ */ jsxs215(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "md", children: [
38828
+ /* @__PURE__ */ jsx340(form.Field, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ jsxs215(VStack, { gap: "xs", align: "baseline", children: [
38829
+ field.state.value.map((_value, index) => (
38830
+ /**
38831
+ * A more correct implementation would use a UUID as the key for this HStack. Specifically, it is an antipattern in
38832
+ * React to use array indices as keys. However, there are some ongoing issues with @tanstack/react-form related to
38833
+ * deleting an element from an array field. In particular, the form values for the remaining array items may become
38834
+ * momentarily undefined as they re-render due to re-indexing. Thus, we use indices here for now.
38835
+ * See here for more information: https://github.com/TanStack/form/issues/1518.
38836
+ */
38837
+ /* @__PURE__ */ jsxs215(
38838
+ HStack,
38839
+ {
38840
+ gap: "xs",
38841
+ align: "end",
38842
+ className: classNames92(`${INVOICE_FORM_CSS_PREFIX}__LineItem`, isReadOnly && `${INVOICE_FORM_CSS_PREFIX}__LineItem--readonly`),
38843
+ children: [
38844
+ /* @__PURE__ */ jsx340(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormTextField, { label: "Product/Service", showLabel: index === 0, isReadOnly }) }),
38845
+ /* @__PURE__ */ jsx340(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormTextField, { label: "Description", showLabel: index === 0, isReadOnly }) }),
38846
+ /* @__PURE__ */ jsx340(
38847
+ form.AppField,
38848
+ {
38849
+ name: `lineItems[${index}].quantity`,
38850
+ listeners: {
38851
+ onBlur: ({ value: quantity }) => {
38852
+ const amount = form.getFieldValue(`lineItems[${index}].amount`);
38853
+ const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38854
+ const nextAmount = BD5.multiply(unitPrice, quantity);
38855
+ if (!BD5.equals(amount, nextAmount)) {
38856
+ form.setFieldValue(`lineItems[${index}].amount`, withForceUpdate(nextAmount));
38857
+ }
38858
+ }
38859
+ },
38860
+ children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormBigDecimalField, { label: "Quantity", showLabel: index === 0, isReadOnly })
38861
+ }
38862
+ ),
38863
+ /* @__PURE__ */ jsx340(
38864
+ form.AppField,
38865
+ {
38866
+ name: `lineItems[${index}].unitPrice`,
38867
+ listeners: {
38868
+ onBlur: ({ value: unitPrice }) => {
38869
+ const amount = form.getFieldValue(`lineItems[${index}].amount`);
38870
+ const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38871
+ const nextAmount = BD5.multiply(unitPrice, quantity);
38872
+ if (!BD5.equals(amount, nextAmount)) {
38873
+ form.setFieldValue(`lineItems[${index}].amount`, withForceUpdate(nextAmount));
38874
+ }
38875
+ }
38876
+ },
38877
+ children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormBigDecimalField, { label: "Rate", mode: "currency", showLabel: index === 0, allowNegative: true, isReadOnly })
38878
+ }
38879
+ ),
38880
+ /* @__PURE__ */ jsx340(
38881
+ form.AppField,
38882
+ {
38883
+ name: `lineItems[${index}].amount`,
38884
+ listeners: {
38885
+ onBlur: ({ value: amount }) => {
38886
+ const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38887
+ const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38888
+ const nextUnitPrice = safeDivide(amount, quantity);
38889
+ if (!BD5.equals(unitPrice, nextUnitPrice)) {
38890
+ form.setFieldValue(`lineItems[${index}].unitPrice`, withForceUpdate(nextUnitPrice));
38891
+ }
38892
+ }
38893
+ },
38894
+ children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormBigDecimalField, { label: "Amount", mode: "currency", showLabel: index === 0, allowNegative: true, isReadOnly })
38895
+ }
38896
+ ),
38897
+ /* @__PURE__ */ jsx340(form.AppField, { name: `lineItems[${index}].isTaxable`, children: (innerField) => /* @__PURE__ */ jsx340(innerField.FormCheckboxField, { label: "Tax", showLabel: index === 0, isReadOnly }) }),
38898
+ !isReadOnly && /* @__PURE__ */ jsx340(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ jsx340(Trash2, { size: 16 }) })
38899
+ ]
38900
+ },
38901
+ index
38902
+ )
38903
+ )),
38904
+ !isReadOnly && /* @__PURE__ */ jsxs215(Button2, { variant: "outlined", onClick: () => field.pushValue(getEmptyLineItem()), children: [
38905
+ "Add line item",
38906
+ /* @__PURE__ */ jsx340(Plus2, { size: 16 })
38907
+ ] })
38908
+ ] }) }),
38909
+ /* @__PURE__ */ jsx340(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, pbs: "md", children: /* @__PURE__ */ jsxs215(HStack, { justify: "space-between", gap: "xl", children: [
38910
+ /* @__PURE__ */ jsx340(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__AdditionalTextFields`, children: /* @__PURE__ */ jsx340(form.AppField, { name: "memo", children: (field) => /* @__PURE__ */ jsx340(field.FormTextAreaField, { label: "Memo", isReadOnly }) }) }),
38911
+ /* @__PURE__ */ jsxs215(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__TotalFields`, fluid: true, children: [
38912
+ /* @__PURE__ */ jsx340(InvoiceFormTotalRow, { label: "Subtotal", value: subtotal }),
38913
+ /* @__PURE__ */ jsx340(InvoiceFormTotalRow, { label: "Discount", value: negate(additionalDiscount), children: /* @__PURE__ */ jsx340(form.AppField, { name: "discountRate", children: (field) => /* @__PURE__ */ jsx340(field.FormBigDecimalField, { label: "Discount", showLabel: false, mode: "percent", isReadOnly }) }) }),
38914
+ /* @__PURE__ */ jsx340(InvoiceFormTotalRow, { label: "Taxable subtotal", value: taxableSubtotal }),
38915
+ /* @__PURE__ */ jsx340(InvoiceFormTotalRow, { label: "Tax rate", value: taxes, children: /* @__PURE__ */ jsx340(form.AppField, { name: "taxRate", children: (field) => /* @__PURE__ */ jsx340(field.FormBigDecimalField, { label: "Tax Rate", showLabel: false, mode: "percent", isReadOnly }) }) }),
38916
+ /* @__PURE__ */ jsx340(InvoiceFormTotalRow, { label: "Total", value: grandTotal })
38917
+ ] })
38918
+ ] }) })
38919
+ ] })
38224
38920
  ] });
38225
- };
38921
+ });
38922
+ InvoiceForm.displayName = "InvoiceForm";
38226
38923
 
38227
38924
  // src/components/DataPoint/DataPoint.tsx
38228
- import { jsx as jsx339, jsxs as jsxs214 } from "react/jsx-runtime";
38925
+ import { jsx as jsx341, jsxs as jsxs216 } from "react/jsx-runtime";
38229
38926
  var DataPoint = ({ label, children }) => {
38230
- return /* @__PURE__ */ jsxs214(VStack, { gap: "3xs", children: [
38231
- /* @__PURE__ */ jsx339(Span, { variant: "subtle", size: "xs", children: label }),
38927
+ return /* @__PURE__ */ jsxs216(VStack, { gap: "3xs", children: [
38928
+ /* @__PURE__ */ jsx341(Span, { variant: "subtle", size: "xs", children: label }),
38232
38929
  children
38233
38930
  ] });
38234
38931
  };
38235
38932
 
38236
38933
  // src/components/Invoices/InvoiceStatusCell/InvoiceStatusCell.tsx
38237
38934
  import pluralize6 from "pluralize";
38238
- import { jsx as jsx340, jsxs as jsxs215 } from "react/jsx-runtime";
38935
+ import { jsx as jsx342, jsxs as jsxs217 } from "react/jsx-runtime";
38239
38936
  var getDueStatusConfig = (invoice, { inline }) => {
38240
38937
  const badgeSize = inline ? "xs" /* EXTRA_SMALL */ : "small" /* SMALL */;
38241
38938
  const iconSize = inline ? 10 : 12;
@@ -38249,7 +38946,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38249
38946
  case "PAID" /* Paid */: {
38250
38947
  return {
38251
38948
  text: "Paid",
38252
- badge: /* @__PURE__ */ jsx340(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ jsx340(CheckCircle_default, { size: iconSize }), iconOnly: true })
38949
+ badge: /* @__PURE__ */ jsx342(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ jsx342(CheckCircle_default, { size: iconSize }), iconOnly: true })
38253
38950
  };
38254
38951
  }
38255
38952
  case "VOIDED" /* Voided */: {
@@ -38272,7 +38969,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38272
38969
  return {
38273
38970
  text: "Overdue",
38274
38971
  subText: `Due ${pluralize6("day", Math.abs(dueDifference), true)} ago`,
38275
- badge: /* @__PURE__ */ jsx340(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ jsx340(AlertCircle_default, { size: iconSize }), iconOnly: true })
38972
+ badge: /* @__PURE__ */ jsx342(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ jsx342(AlertCircle_default, { size: iconSize }), iconOnly: true })
38276
38973
  };
38277
38974
  }
38278
38975
  return {
@@ -38292,73 +38989,117 @@ var InvoiceStatusCell = ({ invoice, inline = false }) => {
38292
38989
  const dueStatus = getDueStatusConfig(invoice, { inline });
38293
38990
  const Stack3 = inline ? HStack : VStack;
38294
38991
  const subText = inline && dueStatus.subText ? `(${dueStatus.subText})` : dueStatus.subText;
38295
- return /* @__PURE__ */ jsxs215(HStack, { gap: "xs", align: "center", children: [
38992
+ return /* @__PURE__ */ jsxs217(HStack, { gap: "xs", align: "center", children: [
38296
38993
  dueStatus.badge,
38297
- /* @__PURE__ */ jsxs215(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38298
- /* @__PURE__ */ jsx340(Span, { children: dueStatus.text }),
38299
- subText && /* @__PURE__ */ jsx340(Span, { variant: "subtle", size: "sm", children: subText })
38994
+ /* @__PURE__ */ jsxs217(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38995
+ /* @__PURE__ */ jsx342(Span, { children: dueStatus.text }),
38996
+ subText && /* @__PURE__ */ jsx342(Span, { variant: "subtle", size: "sm", children: subText })
38300
38997
  ] }))
38301
38998
  ] });
38302
38999
  };
38303
39000
 
38304
39001
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
38305
- import { jsx as jsx341, jsxs as jsxs216 } from "react/jsx-runtime";
39002
+ import { SquarePen } from "lucide-react";
39003
+ import { jsx as jsx343, jsxs as jsxs218 } from "react/jsx-runtime";
38306
39004
  var InvoiceDetail = (props) => {
38307
- const _a = props, { onSuccess: _onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
38308
- const Header6 = useCallback55(() => {
38309
- return /* @__PURE__ */ jsx341(InvoiceDetailHeader, __spreadValues({}, restProps));
38310
- }, [restProps]);
38311
- return /* @__PURE__ */ jsxs216(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
38312
- restProps.mode === "Update" /* Update */ && /* @__PURE__ */ jsx341(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
38313
- /* @__PURE__ */ jsx341(InvoiceForm, __spreadValues({}, props))
39005
+ const _a = props, { onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
39006
+ const [isReadOnly, setIsReadOnly] = useState85(props.mode === "Update" /* Update */);
39007
+ const formRef = useRef32(null);
39008
+ const onSubmit = useCallback57(() => {
39009
+ var _a2;
39010
+ return (_a2 = formRef.current) == null ? void 0 : _a2.submit();
39011
+ }, []);
39012
+ const [formState, setFormState] = useState85({
39013
+ isFormValid: true,
39014
+ isSubmitting: false,
39015
+ submitError: void 0
39016
+ });
39017
+ const onChangeFormState = useCallback57((nextState) => {
39018
+ setFormState(nextState);
39019
+ }, []);
39020
+ const Header6 = useCallback57(() => {
39021
+ return /* @__PURE__ */ jsx343(
39022
+ InvoiceDetailHeader,
39023
+ __spreadValues({
39024
+ onSubmit,
39025
+ isReadOnly,
39026
+ formState,
39027
+ setIsReadOnly
39028
+ }, restProps)
39029
+ );
39030
+ }, [onSubmit, isReadOnly, formState, restProps]);
39031
+ return /* @__PURE__ */ jsxs218(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
39032
+ restProps.mode === "Update" /* Update */ && /* @__PURE__ */ jsx343(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
39033
+ /* @__PURE__ */ jsx343(
39034
+ InvoiceForm,
39035
+ __spreadProps(__spreadValues({
39036
+ isReadOnly,
39037
+ onSuccess,
39038
+ onChangeFormState
39039
+ }, restProps), {
39040
+ ref: formRef
39041
+ })
39042
+ )
38314
39043
  ] });
38315
39044
  };
38316
39045
  var InvoiceDetailHeader = (props) => {
38317
- const { mode } = props;
39046
+ const { mode, onSubmit, formState, isReadOnly, setIsReadOnly } = props;
39047
+ const { isSubmitting } = formState;
38318
39048
  if (mode === "Create" /* Create */) {
38319
- return /* @__PURE__ */ jsx341(Heading2, { children: "Create Invoice" });
39049
+ return /* @__PURE__ */ jsxs218(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
39050
+ /* @__PURE__ */ jsx343(Heading2, { children: "Create Invoice" }),
39051
+ /* @__PURE__ */ jsx343(Button2, { isPending: isSubmitting, onPress: onSubmit, children: "Review & Send" })
39052
+ ] });
38320
39053
  }
38321
39054
  const invoice = props.invoice;
38322
39055
  const { invoiceNumber } = invoice;
38323
- return /* @__PURE__ */ jsx341(Heading2, { children: invoiceNumber ? `Invoice ${invoiceNumber}` : "View Invoice" });
39056
+ return /* @__PURE__ */ jsxs218(HStack, { justify: "space-between", align: "center", fluid: true, pie: "md", children: [
39057
+ /* @__PURE__ */ jsx343(Heading2, { children: invoiceNumber ? `Invoice ${invoiceNumber}` : "View Invoice" }),
39058
+ isReadOnly ? /* @__PURE__ */ jsxs218(Button2, { onPress: () => {
39059
+ setIsReadOnly(false);
39060
+ }, children: [
39061
+ "Edit Invoice",
39062
+ /* @__PURE__ */ jsx343(SquarePen, { size: 14 })
39063
+ ] }) : /* @__PURE__ */ jsx343(Button2, { isPending: isSubmitting, onPress: onSubmit, children: "Review & Resend" })
39064
+ ] });
38324
39065
  };
38325
39066
  var InvoiceDetailSubHeader = ({ invoice }) => {
38326
39067
  const { outstandingBalance, totalAmount } = invoice;
38327
- return /* @__PURE__ */ jsx341(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ jsxs216(HStack, { gap: "5xl", children: [
38328
- /* @__PURE__ */ jsx341(DataPoint, { label: "Balance due", children: /* @__PURE__ */ jsx341(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
38329
- /* @__PURE__ */ jsx341(DataPoint, { label: "Open balance", children: /* @__PURE__ */ jsx341(Span, { children: convertCentsToCurrency(totalAmount) }) }),
38330
- /* @__PURE__ */ jsx341(DataPoint, { label: "Status", children: /* @__PURE__ */ jsx341(InvoiceStatusCell, { invoice, inline: true }) })
39068
+ return /* @__PURE__ */ jsx343(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ jsxs218(HStack, { gap: "5xl", children: [
39069
+ /* @__PURE__ */ jsx343(DataPoint, { label: "Balance due", children: /* @__PURE__ */ jsx343(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
39070
+ /* @__PURE__ */ jsx343(DataPoint, { label: "Open balance", children: /* @__PURE__ */ jsx343(Span, { children: convertCentsToCurrency(totalAmount) }) }),
39071
+ /* @__PURE__ */ jsx343(DataPoint, { label: "Status", children: /* @__PURE__ */ jsx343(InvoiceStatusCell, { invoice, inline: true }) })
38331
39072
  ] }) });
38332
39073
  };
38333
39074
 
38334
39075
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38335
- import { useCallback as useCallback58, useMemo as useMemo76, useState as useState86 } from "react";
39076
+ import { useCallback as useCallback60, useMemo as useMemo77, useState as useState87 } from "react";
38336
39077
 
38337
39078
  // src/features/invoices/api/useListInvoices.tsx
38338
39079
  import useSWRInfinite7 from "swr/infinite";
38339
- var import_lodash6 = __toESM(require_lodash2());
38340
- import { useCallback as useCallback56, useMemo as useMemo73 } from "react";
38341
- import { Schema as Schema13 } from "effect";
39080
+ var import_lodash7 = __toESM(require_lodash2());
39081
+ import { useCallback as useCallback58, useMemo as useMemo74 } from "react";
39082
+ import { Schema as Schema14 } from "effect";
38342
39083
 
38343
39084
  // src/types/utility/pagination.ts
38344
- import { Schema as Schema12, pipe as pipe6 } from "effect";
38345
- var PaginatedResponseMetaSchema = Schema12.Struct({
38346
- cursor: Schema12.NullOr(Schema12.String),
39085
+ import { Schema as Schema13, pipe as pipe6 } from "effect";
39086
+ var PaginatedResponseMetaSchema = Schema13.Struct({
39087
+ cursor: Schema13.NullOr(Schema13.String),
38347
39088
  hasMore: pipe6(
38348
- Schema12.propertySignature(Schema12.Boolean),
38349
- Schema12.fromKey("has_more")
39089
+ Schema13.propertySignature(Schema13.Boolean),
39090
+ Schema13.fromKey("has_more")
38350
39091
  ),
38351
39092
  totalCount: pipe6(
38352
- Schema12.propertySignature(Schema12.UndefinedOr(Schema12.Number)),
38353
- Schema12.fromKey("total_count")
39093
+ Schema13.propertySignature(Schema13.UndefinedOr(Schema13.Number)),
39094
+ Schema13.fromKey("total_count")
38354
39095
  )
38355
39096
  });
38356
39097
 
38357
39098
  // src/features/invoices/api/useListInvoices.tsx
38358
39099
  var LIST_INVOICES_TAG_KEY = "#list-invoices";
38359
- var ListInvoicesReturnSchema = Schema13.Struct({
38360
- data: Schema13.Array(InvoiceSchema),
38361
- meta: Schema13.Struct({
39100
+ var ListInvoicesReturnSchema = Schema14.Struct({
39101
+ data: Schema14.Array(InvoiceSchema),
39102
+ meta: Schema14.Struct({
38362
39103
  pagination: PaginatedResponseMetaSchema
38363
39104
  })
38364
39105
  });
@@ -38486,7 +39227,7 @@ function useListInvoices({
38486
39227
  showTotalCount: showTotalCount2
38487
39228
  }
38488
39229
  }
38489
- )().then(Schema13.decodeUnknownPromise(ListInvoicesReturnSchema)),
39230
+ )().then(Schema14.decodeUnknownPromise(ListInvoicesReturnSchema)),
38490
39231
  {
38491
39232
  keepPreviousData: true,
38492
39233
  revalidateFirstPage: false,
@@ -38505,10 +39246,10 @@ import {
38505
39246
  } from "@tanstack/react-table";
38506
39247
 
38507
39248
  // src/components/DataTable/DataTable.tsx
38508
- import { useMemo as useMemo74 } from "react";
39249
+ import { useMemo as useMemo75 } from "react";
38509
39250
 
38510
39251
  // src/components/ui/Table/Table.tsx
38511
- import { forwardRef as forwardRef24 } from "react";
39252
+ import { forwardRef as forwardRef26 } from "react";
38512
39253
  import {
38513
39254
  Cell as ReactAriaCell,
38514
39255
  Column as ReactAriaColumn,
@@ -38517,14 +39258,14 @@ import {
38517
39258
  TableBody as ReactAriaTableBody,
38518
39259
  TableHeader as ReactAriaTableHeader
38519
39260
  } from "react-aria-components";
38520
- import classNames91 from "classnames";
38521
- import { jsx as jsx342 } from "react/jsx-runtime";
39261
+ import classNames93 from "classnames";
39262
+ import { jsx as jsx344 } from "react/jsx-runtime";
38522
39263
  var CSS_PREFIX2 = "Layer__UI__Table";
38523
- var getClassName = (component, additionalClassNames) => classNames91(`${CSS_PREFIX2}-${component}`, additionalClassNames);
38524
- var Table2 = forwardRef24(
39264
+ var getClassName = (component, additionalClassNames) => classNames93(`${CSS_PREFIX2}-${component}`, additionalClassNames);
39265
+ var Table2 = forwardRef26(
38525
39266
  (_a, ref) => {
38526
39267
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38527
- return /* @__PURE__ */ jsx342(
39268
+ return /* @__PURE__ */ jsx344(
38528
39269
  ReactAriaTable,
38529
39270
  __spreadProps(__spreadValues({
38530
39271
  className: getClassName("Table" /* Table */, className)
@@ -38538,7 +39279,7 @@ var Table2 = forwardRef24(
38538
39279
  Table2.displayName = "Table" /* Table */;
38539
39280
  var TableHeaderInner = (_a, ref) => {
38540
39281
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38541
- return /* @__PURE__ */ jsx342(
39282
+ return /* @__PURE__ */ jsx344(
38542
39283
  ReactAriaTableHeader,
38543
39284
  __spreadProps(__spreadValues({
38544
39285
  className: getClassName("TableHeader" /* TableHeader */, className)
@@ -38548,11 +39289,11 @@ var TableHeaderInner = (_a, ref) => {
38548
39289
  })
38549
39290
  );
38550
39291
  };
38551
- var TableHeader = forwardRef24(TableHeaderInner);
39292
+ var TableHeader = forwardRef26(TableHeaderInner);
38552
39293
  TableHeader.displayName = "TableHeader" /* TableHeader */;
38553
39294
  var TableBodyInner = (_a, ref) => {
38554
39295
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38555
- return /* @__PURE__ */ jsx342(
39296
+ return /* @__PURE__ */ jsx344(
38556
39297
  ReactAriaTableBody,
38557
39298
  __spreadProps(__spreadValues({
38558
39299
  className: getClassName("TableBody" /* TableBody */, className)
@@ -38562,11 +39303,11 @@ var TableBodyInner = (_a, ref) => {
38562
39303
  })
38563
39304
  );
38564
39305
  };
38565
- var TableBody2 = forwardRef24(TableBodyInner);
39306
+ var TableBody2 = forwardRef26(TableBodyInner);
38566
39307
  TableBody2.displayName = "TableBody" /* TableBody */;
38567
39308
  var RowInner = (_a, ref) => {
38568
39309
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38569
- return /* @__PURE__ */ jsx342(
39310
+ return /* @__PURE__ */ jsx344(
38570
39311
  ReactAriaTableRow,
38571
39312
  __spreadProps(__spreadValues({
38572
39313
  className: getClassName("Row" /* Row */, className)
@@ -38576,13 +39317,13 @@ var RowInner = (_a, ref) => {
38576
39317
  })
38577
39318
  );
38578
39319
  };
38579
- var Row2 = forwardRef24(RowInner);
39320
+ var Row2 = forwardRef26(RowInner);
38580
39321
  Row2.displayName = "Row" /* Row */;
38581
- var Column = forwardRef24(
39322
+ var Column = forwardRef26(
38582
39323
  (_a, ref) => {
38583
39324
  var _b = _a, { children, className, textAlign = "left" } = _b, restProps = __objRest(_b, ["children", "className", "textAlign"]);
38584
39325
  const dataProperties = toDataProperties({ "text-align": textAlign });
38585
- return /* @__PURE__ */ jsx342(
39326
+ return /* @__PURE__ */ jsx344(
38586
39327
  ReactAriaColumn,
38587
39328
  __spreadProps(__spreadValues(__spreadValues({
38588
39329
  className: getClassName("Column" /* Column */, className)
@@ -38594,10 +39335,10 @@ var Column = forwardRef24(
38594
39335
  }
38595
39336
  );
38596
39337
  Column.displayName = "Column" /* Column */;
38597
- var Cell5 = forwardRef24(
39338
+ var Cell5 = forwardRef26(
38598
39339
  (_a, ref) => {
38599
39340
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38600
- return /* @__PURE__ */ jsx342(
39341
+ return /* @__PURE__ */ jsx344(
38601
39342
  ReactAriaCell,
38602
39343
  __spreadProps(__spreadValues({
38603
39344
  className: getClassName("Cell" /* Cell */, className)
@@ -38611,7 +39352,7 @@ var Cell5 = forwardRef24(
38611
39352
  Cell5.displayName = "Cell" /* Cell */;
38612
39353
 
38613
39354
  // src/components/DataTable/DataTable.tsx
38614
- import { jsx as jsx343, jsxs as jsxs217 } from "react/jsx-runtime";
39355
+ import { jsx as jsx345, jsxs as jsxs219 } from "react/jsx-runtime";
38615
39356
  var DataTable = ({
38616
39357
  columnConfig,
38617
39358
  data,
@@ -38624,17 +39365,17 @@ var DataTable = ({
38624
39365
  const columns = Object.values(columnConfig);
38625
39366
  const { EmptyState, ErrorState } = slots;
38626
39367
  const isEmptyTable = (data == null ? void 0 : data.length) === 0;
38627
- const renderTableBody = useMemo74(() => {
39368
+ const renderTableBody = useMemo75(() => {
38628
39369
  if (isError) {
38629
- return /* @__PURE__ */ jsx343(Row2, { children: /* @__PURE__ */ jsx343(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx343(ErrorState, {}) }) });
39370
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(ErrorState, {}) }) });
38630
39371
  }
38631
39372
  if (isLoading) {
38632
- return /* @__PURE__ */ jsx343(Row2, { children: /* @__PURE__ */ jsx343(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx343(Loader2, {}) }) });
39373
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(Loader2, {}) }) });
38633
39374
  }
38634
39375
  if (isEmptyTable) {
38635
- return /* @__PURE__ */ jsx343(Row2, { children: /* @__PURE__ */ jsx343(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx343(EmptyState, {}) }) });
39376
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(EmptyState, {}) }) });
38636
39377
  }
38637
- const RowRenderer = (row) => /* @__PURE__ */ jsx343(Row2, { children: columns.map((col) => /* @__PURE__ */ jsx343(
39378
+ const RowRenderer = (row) => /* @__PURE__ */ jsx345(Row2, { children: columns.map((col) => /* @__PURE__ */ jsx345(
38638
39379
  Cell5,
38639
39380
  {
38640
39381
  className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
@@ -38645,15 +39386,15 @@ var DataTable = ({
38645
39386
  RowRenderer.displayName = "Row";
38646
39387
  return RowRenderer;
38647
39388
  }, [isError, isLoading, isEmptyTable, columns, ErrorState, EmptyState, componentName]);
38648
- return /* @__PURE__ */ jsxs217(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
38649
- /* @__PURE__ */ jsx343(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ jsx343(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
38650
- /* @__PURE__ */ jsx343(TableBody2, { items: data, children: renderTableBody })
39389
+ return /* @__PURE__ */ jsxs219(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
39390
+ /* @__PURE__ */ jsx345(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ jsx345(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
39391
+ /* @__PURE__ */ jsx345(TableBody2, { items: data, children: renderTableBody })
38651
39392
  ] });
38652
39393
  };
38653
39394
 
38654
39395
  // src/components/DataTable/PaginatedTable.tsx
38655
- import { useCallback as useCallback57, useMemo as useMemo75, useState as useState85 } from "react";
38656
- import { jsx as jsx344, jsxs as jsxs218 } from "react/jsx-runtime";
39396
+ import { useCallback as useCallback59, useMemo as useMemo76, useState as useState86 } from "react";
39397
+ import { jsx as jsx346, jsxs as jsxs220 } from "react/jsx-runtime";
38657
39398
  var EMPTY_ARRAY = [];
38658
39399
  function PaginatedTable({
38659
39400
  data,
@@ -38666,7 +39407,7 @@ function PaginatedTable({
38666
39407
  slots
38667
39408
  }) {
38668
39409
  const { pageSize = 20, hasMore, fetchMore } = paginationProps;
38669
- const [pagination, setPagination] = useState85({ pageIndex: 0, pageSize });
39410
+ const [pagination, setPagination] = useState86({ pageIndex: 0, pageSize });
38670
39411
  const columnHelper = createColumnHelper();
38671
39412
  const columns = Object.values(columnConfig);
38672
39413
  const columnDefs = columns.map((col) => {
@@ -38686,12 +39427,12 @@ function PaginatedTable({
38686
39427
  autoResetPageIndex: false
38687
39428
  });
38688
39429
  const { rows } = table.getRowModel();
38689
- const rowData = useMemo75(() => rows.map((r) => r.original), [rows]);
38690
- const onPageChange = useCallback57((page) => {
39430
+ const rowData = useMemo76(() => rows.map((r) => r.original), [rows]);
39431
+ const onPageChange = useCallback59((page) => {
38691
39432
  table.setPageIndex(page - 1);
38692
39433
  }, [table]);
38693
- return /* @__PURE__ */ jsxs218(VStack, { children: [
38694
- /* @__PURE__ */ jsx344(
39434
+ return /* @__PURE__ */ jsxs220(VStack, { children: [
39435
+ /* @__PURE__ */ jsx346(
38695
39436
  DataTable,
38696
39437
  {
38697
39438
  ariaLabel,
@@ -38703,7 +39444,7 @@ function PaginatedTable({
38703
39444
  slots
38704
39445
  }
38705
39446
  ),
38706
- !isError && !isLoading && /* @__PURE__ */ jsx344(
39447
+ !isError && !isLoading && /* @__PURE__ */ jsx346(
38707
39448
  Pagination,
38708
39449
  {
38709
39450
  currentPage: table.getState().pagination.pageIndex + 1,
@@ -38718,10 +39459,10 @@ function PaginatedTable({
38718
39459
  }
38719
39460
 
38720
39461
  // src/icons/ChevronRightFill.tsx
38721
- import { jsx as jsx345, jsxs as jsxs219 } from "react/jsx-runtime";
39462
+ import { jsx as jsx347, jsxs as jsxs221 } from "react/jsx-runtime";
38722
39463
  var ChevronRightFill = (_a) => {
38723
39464
  var _b = _a, { size = 18 } = _b, props = __objRest(_b, ["size"]);
38724
- return /* @__PURE__ */ jsxs219(
39465
+ return /* @__PURE__ */ jsxs221(
38725
39466
  "svg",
38726
39467
  __spreadProps(__spreadValues({
38727
39468
  xmlns: "http://www.w3.org/2000/svg",
@@ -38731,8 +39472,8 @@ var ChevronRightFill = (_a) => {
38731
39472
  width: size,
38732
39473
  height: size,
38733
39474
  children: [
38734
- /* @__PURE__ */ jsx345("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
38735
- /* @__PURE__ */ jsx345(
39475
+ /* @__PURE__ */ jsx347("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
39476
+ /* @__PURE__ */ jsx347(
38736
39477
  "path",
38737
39478
  {
38738
39479
  d: "M6.75 4.5L11.25 9L6.75 13.5Z",
@@ -38751,34 +39492,34 @@ var ChevronRightFill_default = ChevronRightFill;
38751
39492
  import { HandCoins, Search as Search2, Plus as Plus3 } from "lucide-react";
38752
39493
 
38753
39494
  // src/components/DataTable/DataTableHeader.tsx
38754
- import { jsx as jsx346, jsxs as jsxs220 } from "react/jsx-runtime";
39495
+ import { jsx as jsx348, jsxs as jsxs222 } from "react/jsx-runtime";
38755
39496
  var DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
38756
39497
  const { showCount, totalCount } = count != null ? count : {};
38757
39498
  const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
38758
- return /* @__PURE__ */ jsxs220(VStack, { children: [
38759
- /* @__PURE__ */ jsxs220(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
38760
- /* @__PURE__ */ jsxs220(HStack, { pis: "md", align: "center", gap: "xl", children: [
38761
- /* @__PURE__ */ jsxs220(HStack, { align: "center", gap: "sm", children: [
38762
- /* @__PURE__ */ jsx346(Span, { weight: "bold", size: "lg", children: name }),
38763
- showCount && (totalCount ? /* @__PURE__ */ jsx346(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ jsx346(BadgeLoader, {}))
39499
+ return /* @__PURE__ */ jsxs222(VStack, { children: [
39500
+ /* @__PURE__ */ jsxs222(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
39501
+ /* @__PURE__ */ jsxs222(HStack, { pis: "md", align: "center", gap: "xl", children: [
39502
+ /* @__PURE__ */ jsxs222(HStack, { align: "center", gap: "sm", children: [
39503
+ /* @__PURE__ */ jsx348(Span, { weight: "bold", size: "lg", children: name }),
39504
+ showCount && (totalCount ? /* @__PURE__ */ jsx348(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ jsx348(BadgeLoader, {}))
38764
39505
  ] }),
38765
- HeaderFilters && /* @__PURE__ */ jsx346(HeaderFilters, {})
39506
+ HeaderFilters && /* @__PURE__ */ jsx348(HeaderFilters, {})
38766
39507
  ] }),
38767
- /* @__PURE__ */ jsxs220(HStack, { pie: "md", align: "center", gap: "3xs", children: [
38768
- slotProps.SearchField && /* @__PURE__ */ jsx346(SearchField, __spreadValues({}, slotProps.SearchField)),
38769
- HeaderActions && /* @__PURE__ */ jsx346(HeaderActions, {})
39508
+ /* @__PURE__ */ jsxs222(HStack, { pie: "md", align: "center", gap: "3xs", children: [
39509
+ slotProps.SearchField && /* @__PURE__ */ jsx348(SearchField, __spreadValues({}, slotProps.SearchField)),
39510
+ HeaderActions && /* @__PURE__ */ jsx348(HeaderActions, {})
38770
39511
  ] })
38771
39512
  ] }),
38772
- Filters2 && /* @__PURE__ */ jsxs220(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
38773
- /* @__PURE__ */ jsx346(Filters2, {}),
38774
- slotProps.ClearFiltersButton && /* @__PURE__ */ jsx346(Button2, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
39513
+ Filters2 && /* @__PURE__ */ jsxs222(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
39514
+ /* @__PURE__ */ jsx348(Filters2, {}),
39515
+ slotProps.ClearFiltersButton && /* @__PURE__ */ jsx348(Button2, __spreadProps(__spreadValues({ variant: "outlined" }, slotProps.ClearFiltersButton), { children: "Clear All Filters" }))
38775
39516
  ] })
38776
39517
  ] });
38777
39518
  };
38778
39519
 
38779
39520
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38780
- import { startOfToday, endOfYesterday } from "date-fns";
38781
- import { jsx as jsx347, jsxs as jsxs221 } from "react/jsx-runtime";
39521
+ import { startOfToday as startOfToday2, endOfYesterday } from "date-fns";
39522
+ import { jsx as jsx349, jsxs as jsxs223 } from "react/jsx-runtime";
38782
39523
  var COMPONENT_NAME10 = "InvoicesTable";
38783
39524
  var InvoiceStatusOptionConfig = {
38784
39525
  ["All" /* All */]: { label: "All", value: "All" /* All */ },
@@ -38799,12 +39540,12 @@ var AmountCell = ({ invoice }) => {
38799
39540
  case "WRITTEN_OFF" /* WrittenOff */:
38800
39541
  case "VOIDED" /* Voided */:
38801
39542
  case "SENT" /* Sent */: {
38802
- return /* @__PURE__ */ jsx347(VStack, { children: /* @__PURE__ */ jsx347(Span, { align: "right", children: totalAmount }) });
39543
+ return /* @__PURE__ */ jsx349(VStack, { children: /* @__PURE__ */ jsx349(Span, { align: "right", children: totalAmount }) });
38803
39544
  }
38804
39545
  case "PARTIALLY_PAID" /* PartiallyPaid */: {
38805
- return /* @__PURE__ */ jsxs221(VStack, { children: [
38806
- /* @__PURE__ */ jsx347(Span, { align: "right", children: totalAmount }),
38807
- /* @__PURE__ */ jsxs221(Span, { align: "right", variant: "subtle", size: "sm", children: [
39546
+ return /* @__PURE__ */ jsxs223(VStack, { children: [
39547
+ /* @__PURE__ */ jsx349(Span, { align: "right", children: totalAmount }),
39548
+ /* @__PURE__ */ jsxs223(Span, { align: "right", variant: "subtle", size: "sm", children: [
38808
39549
  outstandingBalance,
38809
39550
  " ",
38810
39551
  "outstanding"
@@ -38821,7 +39562,7 @@ var AmountCell = ({ invoice }) => {
38821
39562
  };
38822
39563
  var getCustomerName2 = (invoice) => {
38823
39564
  const { recipientName, customer } = invoice;
38824
- return recipientName || (customer == null ? void 0 : customer.individualName) || (customer == null ? void 0 : customer.companyName);
39565
+ return (customer == null ? void 0 : customer.individualName) || (customer == null ? void 0 : customer.companyName) || recipientName;
38825
39566
  };
38826
39567
  var getColumnConfig = (onSelectInvoice) => ({
38827
39568
  ["SentAt" /* SentAt */]: {
@@ -38843,16 +39584,16 @@ var getColumnConfig = (onSelectInvoice) => ({
38843
39584
  ["Total" /* Total */]: {
38844
39585
  id: "Total" /* Total */,
38845
39586
  header: "Amount",
38846
- cell: (row) => /* @__PURE__ */ jsx347(AmountCell, { invoice: row })
39587
+ cell: (row) => /* @__PURE__ */ jsx349(AmountCell, { invoice: row })
38847
39588
  },
38848
39589
  ["Status" /* Status */]: {
38849
39590
  id: "Status" /* Status */,
38850
39591
  header: "Status",
38851
- cell: (row) => /* @__PURE__ */ jsx347(InvoiceStatusCell, { invoice: row })
39592
+ cell: (row) => /* @__PURE__ */ jsx349(InvoiceStatusCell, { invoice: row })
38852
39593
  },
38853
39594
  ["Expand" /* Expand */]: {
38854
39595
  id: "Expand" /* Expand */,
38855
- cell: (row) => /* @__PURE__ */ jsx347(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx347(ChevronRightFill_default, {}) })
39596
+ cell: (row) => /* @__PURE__ */ jsx349(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx349(ChevronRightFill_default, {}) })
38856
39597
  }
38857
39598
  });
38858
39599
  var UNPAID_STATUSES2 = ["SENT" /* Sent */, "PARTIALLY_PAID" /* PartiallyPaid */];
@@ -38866,7 +39607,7 @@ var getListInvoiceParams = ({ statusFilter }) => {
38866
39607
  case "Overdue" /* Overdue */:
38867
39608
  return { status: UNPAID_STATUSES2, dueAtEnd: endOfYesterday() };
38868
39609
  case "Sent" /* Sent */:
38869
- return { status: UNPAID_STATUSES2, dueAtStart: startOfToday() };
39610
+ return { status: UNPAID_STATUSES2, dueAtStart: startOfToday2() };
38870
39611
  case "Paid" /* Paid */:
38871
39612
  return { status: ["PAID" /* Paid */, "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */] };
38872
39613
  case "Written Off" /* WrittenOff */:
@@ -38881,8 +39622,8 @@ var getListInvoiceParams = ({ statusFilter }) => {
38881
39622
  }
38882
39623
  };
38883
39624
  var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38884
- const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = useState86(ALL_OPTION);
38885
- const listInvoiceParams = useMemo76(
39625
+ const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = useState87(ALL_OPTION);
39626
+ const listInvoiceParams = useMemo77(
38886
39627
  () => getListInvoiceParams({ statusFilter: selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value }),
38887
39628
  [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value]
38888
39629
  );
@@ -38890,29 +39631,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38890
39631
  const invoices = data == null ? void 0 : data.flatMap(({ data: data2 }) => data2);
38891
39632
  const paginationMeta = data == null ? void 0 : data[data.length - 1].meta.pagination;
38892
39633
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
38893
- const fetchMore = useCallback58(() => {
39634
+ const fetchMore = useCallback60(() => {
38894
39635
  if (hasMore) {
38895
39636
  void setSize(size + 1);
38896
39637
  }
38897
39638
  }, [hasMore, setSize, size]);
38898
- const paginationProps = useMemo76(() => {
39639
+ const paginationProps = useMemo77(() => {
38899
39640
  return {
38900
39641
  pageSize: 10,
38901
39642
  hasMore,
38902
39643
  fetchMore
38903
39644
  };
38904
39645
  }, [fetchMore, hasMore]);
38905
- const options = useMemo76(() => Object.values(InvoiceStatusOptionConfig), []);
38906
- const SelectedValue = useMemo76(() => {
39646
+ const options2 = useMemo77(() => Object.values(InvoiceStatusOptionConfig), []);
39647
+ const SelectedValue = useMemo77(() => {
38907
39648
  const label = selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label;
38908
39649
  return label ? `Status: ${label}` : "Status";
38909
39650
  }, [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label]);
38910
- const StatusFilter = useCallback58(
38911
- () => /* @__PURE__ */ jsx347(
39651
+ const StatusFilter = useCallback60(
39652
+ () => /* @__PURE__ */ jsx349(
38912
39653
  ComboBox,
38913
39654
  {
38914
39655
  className: "Layer__InvoicesTable__StatusFilter",
38915
- options,
39656
+ options: options2,
38916
39657
  onSelectedValueChange: (option) => setSelectedInvoiceStatusOption(option),
38917
39658
  selectedValue: selectedInvoiceStatusOption,
38918
39659
  isSearchable: false,
@@ -38922,29 +39663,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38922
39663
  "aria-label": "Status Filter"
38923
39664
  }
38924
39665
  ),
38925
- [SelectedValue, options, selectedInvoiceStatusOption]
39666
+ [SelectedValue, options2, selectedInvoiceStatusOption]
38926
39667
  );
38927
- const CreateInvoiceButton = useCallback58(
38928
- () => /* @__PURE__ */ jsxs221(Button2, { onPress: onCreateInvoice, children: [
39668
+ const CreateInvoiceButton = useCallback60(
39669
+ () => /* @__PURE__ */ jsxs223(Button2, { onPress: onCreateInvoice, children: [
38929
39670
  "Create Invoice",
38930
- /* @__PURE__ */ jsx347(Plus3, { size: 16 })
39671
+ /* @__PURE__ */ jsx349(Plus3, { size: 16 })
38931
39672
  ] }),
38932
39673
  [onCreateInvoice]
38933
39674
  );
38934
- const InvoicesTableEmptyState = useCallback58(() => {
39675
+ const InvoicesTableEmptyState = useCallback60(() => {
38935
39676
  const isFiltered = selectedInvoiceStatusOption && selectedInvoiceStatusOption !== ALL_OPTION;
38936
- return /* @__PURE__ */ jsx347(
39677
+ return /* @__PURE__ */ jsx349(
38937
39678
  DataState,
38938
39679
  {
38939
39680
  status: "allDone" /* allDone */,
38940
39681
  title: isFiltered ? "No results found" : "No invoices yet",
38941
39682
  description: isFiltered ? "We couldn\u2019t find any invoices with the current filters. Try changing or clearing them to see more results." : "Add your first invoice to start tracking what your customers owe you.",
38942
- icon: isFiltered ? /* @__PURE__ */ jsx347(Search2, {}) : /* @__PURE__ */ jsx347(HandCoins, {}),
39683
+ icon: isFiltered ? /* @__PURE__ */ jsx349(Search2, {}) : /* @__PURE__ */ jsx349(HandCoins, {}),
38943
39684
  spacing: true
38944
39685
  }
38945
39686
  );
38946
39687
  }, [selectedInvoiceStatusOption]);
38947
- const InvoicesTableErrorState = useCallback58(() => /* @__PURE__ */ jsx347(
39688
+ const InvoicesTableErrorState = useCallback60(() => /* @__PURE__ */ jsx349(
38948
39689
  DataState,
38949
39690
  {
38950
39691
  status: "failed" /* failed */,
@@ -38956,9 +39697,9 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38956
39697
  spacing: true
38957
39698
  }
38958
39699
  ), [refetch]);
38959
- const columnConfig = useMemo76(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
38960
- return /* @__PURE__ */ jsxs221(Container, { name: "InvoicesTable", children: [
38961
- /* @__PURE__ */ jsx347(
39700
+ const columnConfig = useMemo77(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
39701
+ return /* @__PURE__ */ jsxs223(Container, { name: "InvoicesTable", children: [
39702
+ /* @__PURE__ */ jsx349(
38962
39703
  DataTableHeader,
38963
39704
  {
38964
39705
  name: "Invoices",
@@ -38968,7 +39709,7 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38968
39709
  }
38969
39710
  }
38970
39711
  ),
38971
- /* @__PURE__ */ jsx347(
39712
+ /* @__PURE__ */ jsx349(
38972
39713
  PaginatedTable,
38973
39714
  {
38974
39715
  ariaLabel: "Invoices",
@@ -38988,38 +39729,38 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38988
39729
  };
38989
39730
 
38990
39731
  // src/components/Invoices/Invoices.tsx
38991
- import { jsx as jsx348 } from "react/jsx-runtime";
39732
+ import { jsx as jsx350 } from "react/jsx-runtime";
38992
39733
  var unstable_Invoices = ({
38993
39734
  showTitle = true,
38994
39735
  stringOverrides
38995
39736
  }) => {
38996
- const [invoiceFormMode, setInvoiceFormMode] = useState87(null);
38997
- const goBackToInvoicesTable = useCallback59(() => {
39737
+ const [invoiceFormMode, setInvoiceFormMode] = useState88(null);
39738
+ const goBackToInvoicesTable = useCallback61(() => {
38998
39739
  setInvoiceFormMode(null);
38999
39740
  }, []);
39000
- const onCreateInvoice = useCallback59(() => {
39741
+ const onCreateInvoice = useCallback61(() => {
39001
39742
  setInvoiceFormMode({ mode: "Create" /* Create */ });
39002
39743
  }, []);
39003
- const onSelectInvoice = useCallback59((invoice) => {
39744
+ const onSelectInvoice = useCallback61((invoice) => {
39004
39745
  setInvoiceFormMode({ mode: "Update" /* Update */, invoice });
39005
39746
  }, []);
39006
- return /* @__PURE__ */ jsx348(
39747
+ return /* @__PURE__ */ jsx350(
39007
39748
  View,
39008
39749
  {
39009
39750
  title: (stringOverrides == null ? void 0 : stringOverrides.title) || "Invoices",
39010
39751
  showHeader: showTitle,
39011
- children: invoiceFormMode !== null ? /* @__PURE__ */ jsx348(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ jsx348(InvoicesTable, { onCreateInvoice, onSelectInvoice })
39752
+ children: invoiceFormMode !== null ? /* @__PURE__ */ jsx350(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ jsx350(InvoicesTable, { onCreateInvoice, onSelectInvoice })
39012
39753
  }
39013
39754
  );
39014
39755
  };
39015
39756
 
39016
39757
  // src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
39017
- import { jsx as jsx349 } from "react/jsx-runtime";
39758
+ import { jsx as jsx351 } from "react/jsx-runtime";
39018
39759
  var BankTransactionsProvider = ({
39019
39760
  children
39020
39761
  }) => {
39021
39762
  const bankTransactionsContextData = useAugmentedBankTransactions();
39022
- return /* @__PURE__ */ jsx349(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
39763
+ return /* @__PURE__ */ jsx351(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
39023
39764
  };
39024
39765
  export {
39025
39766
  AccountingOverview,