@layerfi/components 0.1.106-alpha.1 → 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-alpha.1";
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) => {
@@ -7097,7 +7101,7 @@ function clampToPresentOrPast(date, cutoff = endOfDay(/* @__PURE__ */ new Date()
7097
7101
  }
7098
7102
  var RANGE_MODE_LOOKUP = {
7099
7103
  dayPicker: {
7100
- getStart: ({ start }) => start,
7104
+ getStart: ({ start }) => startOfMonth(start),
7101
7105
  getEnd: ({ end }) => clampToPresentOrPast(endOfDay(end))
7102
7106
  },
7103
7107
  dayRangePicker: {
@@ -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 useCallback58, 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 useCallback54 } 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,34 +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;
37434
- function FormBigDecimalField({
37435
- slotProps,
37436
- maxInputLength = DEFAULT_MAX_INPUT_LENGTH,
37437
- allowNegative = false
37438
- }) {
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
+ });
37558
+ function FormBigDecimalField(_a) {
37559
+ var _b = _a, {
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
37565
+ } = _b, restProps = __objRest(_b, [
37566
+ "mode",
37567
+ "allowNegative",
37568
+ "maxValue",
37569
+ "minDecimalPlaces",
37570
+ "maxDecimalPlaces"
37571
+ ]);
37439
37572
  const field = useFieldContext();
37440
37573
  const { name, state, handleChange, handleBlur } = field;
37441
37574
  const { value } = state;
37442
- 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));
37443
37582
  const onInputChange = useCallback48((e) => {
37444
37583
  setInputValue(e.target.value);
37445
37584
  }, []);
37446
37585
  const onInputBlur = useCallback48(() => {
37447
- const cleaned = inputValue.replace(/,/g, "");
37448
- const maybeDecimal = BD2.fromString(cleaned);
37449
- 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, {
37450
37589
  onNone: () => BIG_DECIMAL_ZERO,
37451
- onSome: (amount) => amount
37590
+ onSome: (value2) => value2
37452
37591
  });
37453
- const normalizedDecimal = BD2.normalize(decimal);
37454
- 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
+ }
37455
37598
  handleBlur();
37456
- setInputValue(formatBigDecimalToString(normalizedDecimal, maxInputLength));
37457
- }, [inputValue, handleBlur, handleChange, maxInputLength]);
37599
+ setInputValue(formatBigDecimalToString(clamped, formattingProps));
37600
+ }, [inputValue, mode, maxBigDecimalValue, value, handleBlur, formattingProps, handleChange]);
37458
37601
  const allowedChars = useMemo71(
37459
- () => allowNegative ? DECIMAL_CHARS_REGEX : NON_NEGATIVE_DECIMAL_CHARS_REGEX,
37460
- [allowNegative]
37602
+ () => buildDecimalCharRegex({ allowNegative, allowPercent: mode === "percent", allowDollar: mode === "currency" }),
37603
+ [allowNegative, mode]
37461
37604
  );
37462
37605
  const onBeforeInput = useCallback48((e) => {
37463
37606
  if (e.data && !allowedChars.test(e.data)) {
@@ -37471,9 +37614,9 @@ function FormBigDecimalField({
37471
37614
  }
37472
37615
  }, [allowedChars]);
37473
37616
  useEffect41(() => {
37474
- setInputValue(formatBigDecimalToString(value, maxInputLength));
37475
- }, [value, maxInputLength]);
37476
- return /* @__PURE__ */ jsx331(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { 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(
37477
37620
  Input2,
37478
37621
  {
37479
37622
  inset: true,
@@ -37482,77 +37625,180 @@ function FormBigDecimalField({
37482
37625
  value: inputValue,
37483
37626
  onChange: onInputChange,
37484
37627
  onBlur: onInputBlur,
37485
- maxLength: maxInputLength,
37486
37628
  onBeforeInput,
37487
37629
  onPaste
37488
37630
  }
37489
37631
  ) }) }));
37490
37632
  }
37491
37633
 
37492
- // src/features/forms/components/FormCurrencyField.tsx
37493
- import { useCallback as useCallback49, useEffect as useEffect42, useState as useState83 } from "react";
37494
- import CurrencyInput2 from "react-currency-input-field";
37495
- import { BigDecimal as BD3, Option as Option5 } from "effect";
37634
+ // src/features/forms/components/FormCheckboxField.tsx
37635
+ import classNames89 from "classnames";
37496
37636
  import { jsx as jsx332 } from "react/jsx-runtime";
37497
- var ZERO_CENTS_INPUT_VALUE = "0.00";
37498
- var getCurrencyInputValueFromCents = (cents) => !Number.isNaN(cents) ? centsToDollarsWithoutCommas(cents) : ZERO_CENTS_INPUT_VALUE;
37499
- function FormCurrencyField({ slotProps }) {
37637
+ var FORM_CHECKBOX_FIELD_CLASSNAME = "Layer__FormCheckboxField";
37638
+ function FormCheckboxField({
37639
+ label,
37640
+ className,
37641
+ inline = false,
37642
+ showLabel = true,
37643
+ showFieldError = true,
37644
+ isReadOnly = false
37645
+ }) {
37500
37646
  const field = useFieldContext();
37501
- const label = slotProps.BaseFormTextField.label;
37502
37647
  const { name, state, handleChange, handleBlur } = field;
37503
- const { value } = state;
37504
- const [inputValue, setInputValue] = useState83(getCurrencyInputValueFromCents(value));
37505
- const onInputChange = useCallback49((newValue) => {
37506
- setInputValue(newValue != null ? newValue : ZERO_CENTS_INPUT_VALUE);
37507
- }, []);
37508
- const onInputBlur = useCallback49(() => {
37509
- const maybeAmount = BD3.fromString(inputValue);
37510
- const cents = Option5.match(maybeAmount, {
37511
- onNone: () => 0,
37512
- onSome: (amount) => convertBigDecimalToCents(amount)
37513
- });
37514
- handleChange(cents);
37515
- handleBlur();
37516
- setInputValue(getCurrencyInputValueFromCents(cents));
37517
- }, [inputValue, handleChange, handleBlur]);
37648
+ const { meta, value } = state;
37649
+ const { errors, isValid: isValid2 } = meta;
37650
+ const errorMessage = errors.length !== 0 ? errors[0] : void 0;
37651
+ const tooltipProps = showFieldError ? { tooltip: errorMessage } : {};
37652
+ const additionalAriaProps = !showLabel && { "aria-label": label };
37653
+ const checkboxClassNames = classNames89(
37654
+ FORM_CHECKBOX_FIELD_CLASSNAME,
37655
+ inline && `${FORM_CHECKBOX_FIELD_CLASSNAME}--inline`,
37656
+ className
37657
+ );
37658
+ return /* @__PURE__ */ jsx332(
37659
+ CheckboxWithTooltip,
37660
+ __spreadProps(__spreadValues(__spreadValues(__spreadValues({
37661
+ className: checkboxClassNames,
37662
+ isSelected: value,
37663
+ isInvalid: !isValid2,
37664
+ onChange: handleChange,
37665
+ onBlur: handleBlur,
37666
+ name,
37667
+ value: name,
37668
+ size: "lg",
37669
+ isReadOnly
37670
+ }, tooltipProps), additionalAriaProps), !isValid2 && { variant: "error" }), {
37671
+ children: showLabel && /* @__PURE__ */ jsx332(Label, { slot: "label", size: "sm", htmlFor: name, children: label })
37672
+ })
37673
+ );
37674
+ }
37675
+
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";
37687
+ import { jsx as jsx333 } from "react/jsx-runtime";
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
+ }) {
37742
+ const field = useFieldContext();
37743
+ const { name, state, handleChange, handleBlur } = field;
37744
+ const { meta, value } = state;
37745
+ const { errors, isValid: isValid2 } = meta;
37746
+ const [localDate, setLocalDate] = useState83(value);
37518
37747
  useEffect42(() => {
37519
- setInputValue(getCurrencyInputValueFromCents(value));
37748
+ setLocalDate(value);
37520
37749
  }, [value]);
37521
- return /* @__PURE__ */ jsx332(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ jsx332(InputGroup2, { children: /* @__PURE__ */ jsx332(
37522
- CurrencyInput2,
37523
- {
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({
37524
37761
  name,
37525
- intlConfig: {
37526
- locale: "en-US",
37527
- currency: "USD"
37528
- },
37529
- prefix: "$",
37530
- decimalScale: 2,
37531
- decimalsLimit: 2,
37532
- disableAbbreviations: true,
37533
- value: inputValue,
37534
- onValueChange: onInputChange,
37535
- onBlur: onInputBlur,
37536
- className: "Layer__UI__Input",
37537
- "data-inset": "true",
37538
- "aria-label": label
37539
- }
37540
- ) }) }));
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
+ );
37541
37787
  }
37542
37788
 
37543
37789
  // src/features/forms/components/FormTextAreaField.tsx
37544
37790
  import { useCallback as useCallback50 } from "react";
37545
37791
 
37546
37792
  // src/components/ui/Input/TextArea.tsx
37547
- import { forwardRef as forwardRef23 } from "react";
37793
+ import { forwardRef as forwardRef24 } from "react";
37548
37794
  import { TextArea as ReactAriaTextArea } from "react-aria-components";
37549
- import { jsx as jsx333 } from "react/jsx-runtime";
37795
+ import { jsx as jsx335 } from "react/jsx-runtime";
37550
37796
  var TEXTAREA_CLASS_NAME = "Layer__UI__TextArea";
37551
- var TextArea = forwardRef23(
37797
+ var TextArea = forwardRef24(
37552
37798
  function TextArea2(_a, ref) {
37553
37799
  var _b = _a, { resize = "none" } = _b, restProps = __objRest(_b, ["resize"]);
37554
37800
  const dataProperties = toDataProperties({ resize });
37555
- return /* @__PURE__ */ jsx333(
37801
+ return /* @__PURE__ */ jsx335(
37556
37802
  ReactAriaTextArea,
37557
37803
  __spreadProps(__spreadValues(__spreadValues({}, restProps), dataProperties), {
37558
37804
  className: TEXTAREA_CLASS_NAME,
@@ -37563,37 +37809,58 @@ var TextArea = forwardRef23(
37563
37809
  );
37564
37810
 
37565
37811
  // src/features/forms/components/FormTextAreaField.tsx
37566
- import { jsx as jsx334 } from "react/jsx-runtime";
37567
- function FormTextAreaField({ slotProps }) {
37812
+ import { jsx as jsx336 } from "react/jsx-runtime";
37813
+ function FormTextAreaField(props) {
37568
37814
  const field = useFieldContext();
37569
37815
  const { name, state, handleChange, handleBlur } = field;
37570
37816
  const { value } = state;
37571
37817
  const onChange = useCallback50((e) => {
37572
37818
  handleChange(e.target.value);
37573
37819
  }, [handleChange]);
37574
- return /* @__PURE__ */ jsx334(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ jsx334(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
+ ) }));
37575
37831
  }
37576
37832
 
37577
37833
  // src/features/forms/components/FormTextField.tsx
37578
37834
  import { useCallback as useCallback51 } from "react";
37579
- import { jsx as jsx335 } from "react/jsx-runtime";
37580
- function FormTextField({ slotProps }) {
37835
+ import { jsx as jsx337 } from "react/jsx-runtime";
37836
+ function FormTextField(props) {
37581
37837
  const field = useFieldContext();
37582
37838
  const { name, state, handleChange, handleBlur } = field;
37583
37839
  const { value } = state;
37584
37840
  const onChange = useCallback51((e) => {
37585
37841
  handleChange(e.target.value);
37586
37842
  }, [handleChange]);
37587
- return /* @__PURE__ */ jsx335(BaseFormTextField, __spreadProps(__spreadValues({}, slotProps.BaseFormTextField), { children: /* @__PURE__ */ jsx335(InputGroup2, { children: /* @__PURE__ */ jsx335(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
+ ) }) }));
37588
37854
  }
37589
37855
 
37590
37856
  // src/features/forms/hooks/useForm.tsx
37591
37857
  var { fieldContext, useFieldContext, formContext, useFormContext } = createFormHookContexts();
37592
- var { useAppForm, withForm } = createFormHook({
37858
+ var { useAppForm: useInternalAppForm } = createFormHook({
37593
37859
  fieldComponents: {
37594
37860
  BaseFormTextField,
37595
37861
  FormBigDecimalField,
37596
- FormCurrencyField,
37862
+ FormCheckboxField,
37863
+ FormDateField,
37597
37864
  FormTextAreaField,
37598
37865
  FormTextField
37599
37866
  },
@@ -37603,9 +37870,104 @@ var { useAppForm, withForm } = createFormHook({
37603
37870
  fieldContext,
37604
37871
  formContext
37605
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
+ );
37606
37969
 
37607
37970
  // src/features/invoices/invoiceSchemas.ts
37608
- import { Schema as Schema9, pipe as pipe5 } from "effect";
37609
37971
  var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37610
37972
  InvoiceStatus3["Voided"] = "VOIDED";
37611
37973
  InvoiceStatus3["Paid"] = "PAID";
@@ -37615,10 +37977,10 @@ var InvoiceStatus = /* @__PURE__ */ ((InvoiceStatus3) => {
37615
37977
  InvoiceStatus3["Sent"] = "SENT";
37616
37978
  return InvoiceStatus3;
37617
37979
  })(InvoiceStatus || {});
37618
- var InvoiceStatusSchema = Schema9.Enums(InvoiceStatus);
37619
- var TransformedInvoiceStatusSchema = Schema9.transform(
37620
- Schema9.NonEmptyTrimmedString,
37621
- Schema9.typeSchema(InvoiceStatusSchema),
37980
+ var InvoiceStatusSchema = Schema10.Enums(InvoiceStatus);
37981
+ var TransformedInvoiceStatusSchema = Schema10.transform(
37982
+ Schema10.NonEmptyTrimmedString,
37983
+ Schema10.typeSchema(InvoiceStatusSchema),
37622
37984
  {
37623
37985
  decode: (input) => {
37624
37986
  if (Object.values(InvoiceStatusSchema.enums).includes(input)) {
@@ -37629,153 +37991,175 @@ var TransformedInvoiceStatusSchema = Schema9.transform(
37629
37991
  encode: (input) => input
37630
37992
  }
37631
37993
  );
37632
- var InvoiceLineItemSchema = Schema9.Struct({
37633
- id: Schema9.UUID,
37994
+ var InvoiceLineItemSchema = Schema10.Struct({
37995
+ id: Schema10.UUID,
37634
37996
  externalId: pipe5(
37635
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37636
- Schema9.fromKey("external_id")
37997
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
37998
+ Schema10.fromKey("external_id")
37637
37999
  ),
37638
38000
  invoiceId: pipe5(
37639
- Schema9.propertySignature(Schema9.UUID),
37640
- Schema9.fromKey("invoice_id")
38001
+ Schema10.propertySignature(Schema10.UUID),
38002
+ Schema10.fromKey("invoice_id")
37641
38003
  ),
37642
- description: Schema9.NullOr(Schema9.String),
37643
- product: Schema9.NullOr(Schema9.String),
38004
+ description: Schema10.NullOr(Schema10.String),
38005
+ product: Schema10.NullOr(Schema10.String),
37644
38006
  unitPrice: pipe5(
37645
- Schema9.propertySignature(Schema9.Number),
37646
- Schema9.fromKey("unit_price")
38007
+ Schema10.propertySignature(Schema10.Number),
38008
+ Schema10.fromKey("unit_price")
37647
38009
  ),
37648
- quantity: Schema9.BigDecimal,
37649
- subtotal: Schema9.Number,
38010
+ quantity: Schema10.BigDecimal,
38011
+ subtotal: Schema10.Number,
37650
38012
  discountAmount: pipe5(
37651
- Schema9.propertySignature(Schema9.Number),
37652
- Schema9.fromKey("discount_amount")
38013
+ Schema10.propertySignature(Schema10.Number),
38014
+ Schema10.fromKey("discount_amount")
37653
38015
  ),
37654
38016
  salesTaxTotal: pipe5(
37655
- Schema9.propertySignature(Schema9.Number),
37656
- Schema9.fromKey("sales_taxes_total")
38017
+ Schema10.propertySignature(Schema10.Number),
38018
+ Schema10.fromKey("sales_taxes_total")
37657
38019
  ),
37658
38020
  totalAmount: pipe5(
37659
- Schema9.propertySignature(Schema9.Number),
37660
- Schema9.fromKey("total_amount")
38021
+ Schema10.propertySignature(Schema10.Number),
38022
+ Schema10.fromKey("total_amount")
37661
38023
  ),
37662
- memo: Schema9.NullOr(Schema9.String)
38024
+ memo: Schema10.NullOr(Schema10.String)
37663
38025
  });
37664
- var InvoiceSchema = Schema9.Struct({
37665
- id: Schema9.UUID,
38026
+ var InvoiceSchema = Schema10.Struct({
38027
+ id: Schema10.UUID,
37666
38028
  businessId: pipe5(
37667
- Schema9.propertySignature(Schema9.UUID),
37668
- Schema9.fromKey("business_id")
38029
+ Schema10.propertySignature(Schema10.UUID),
38030
+ Schema10.fromKey("business_id")
37669
38031
  ),
37670
38032
  externalId: pipe5(
37671
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37672
- Schema9.fromKey("external_id")
38033
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38034
+ Schema10.fromKey("external_id")
37673
38035
  ),
37674
38036
  status: TransformedInvoiceStatusSchema,
37675
38037
  sentAt: pipe5(
37676
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37677
- Schema9.fromKey("sent_at")
38038
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38039
+ Schema10.fromKey("sent_at")
37678
38040
  ),
37679
38041
  dueAt: pipe5(
37680
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37681
- Schema9.fromKey("due_at")
38042
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38043
+ Schema10.fromKey("due_at")
37682
38044
  ),
37683
38045
  paidAt: pipe5(
37684
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37685
- Schema9.fromKey("paid_at")
38046
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38047
+ Schema10.fromKey("paid_at")
37686
38048
  ),
37687
38049
  voidedAt: pipe5(
37688
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37689
- Schema9.fromKey("voided_at")
38050
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38051
+ Schema10.fromKey("voided_at")
37690
38052
  ),
37691
38053
  invoiceNumber: pipe5(
37692
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37693
- Schema9.fromKey("invoice_number")
38054
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38055
+ Schema10.fromKey("invoice_number")
37694
38056
  ),
37695
38057
  recipientName: pipe5(
37696
- Schema9.propertySignature(Schema9.NullOr(Schema9.String)),
37697
- Schema9.fromKey("recipient_name")
38058
+ Schema10.propertySignature(Schema10.NullOr(Schema10.String)),
38059
+ Schema10.fromKey("recipient_name")
37698
38060
  ),
37699
- customer: Schema9.NullOr(CustomerSchema),
38061
+ customer: Schema10.NullOr(CustomerSchema),
37700
38062
  lineItems: pipe5(
37701
- Schema9.propertySignature(Schema9.Array(InvoiceLineItemSchema)),
37702
- Schema9.fromKey("line_items")
38063
+ Schema10.propertySignature(Schema10.Array(InvoiceLineItemSchema)),
38064
+ Schema10.fromKey("line_items")
37703
38065
  ),
37704
- subtotal: Schema9.Number,
38066
+ subtotal: Schema10.Number,
37705
38067
  additionalDiscount: pipe5(
37706
- Schema9.propertySignature(Schema9.Number),
37707
- Schema9.fromKey("additional_discount")
38068
+ Schema10.propertySignature(Schema10.Number),
38069
+ Schema10.fromKey("additional_discount")
37708
38070
  ),
37709
38071
  additionalSalesTaxesTotal: pipe5(
37710
- Schema9.propertySignature(Schema9.Number),
37711
- Schema9.fromKey("additional_sales_taxes_total")
38072
+ Schema10.propertySignature(Schema10.Number),
38073
+ Schema10.fromKey("additional_sales_taxes_total")
37712
38074
  ),
37713
38075
  totalAmount: pipe5(
37714
- Schema9.propertySignature(Schema9.Number),
37715
- Schema9.fromKey("total_amount")
38076
+ Schema10.propertySignature(Schema10.Number),
38077
+ Schema10.fromKey("total_amount")
37716
38078
  ),
37717
38079
  outstandingBalance: pipe5(
37718
- Schema9.propertySignature(Schema9.Number),
37719
- Schema9.fromKey("outstanding_balance")
38080
+ Schema10.propertySignature(Schema10.Number),
38081
+ Schema10.fromKey("outstanding_balance")
37720
38082
  ),
37721
38083
  importedAt: pipe5(
37722
- Schema9.propertySignature(Schema9.Date),
37723
- Schema9.fromKey("imported_at")
38084
+ Schema10.propertySignature(Schema10.Date),
38085
+ Schema10.fromKey("imported_at")
37724
38086
  ),
37725
38087
  updatedAt: pipe5(
37726
- Schema9.propertySignature(Schema9.NullOr(Schema9.Date)),
37727
- Schema9.fromKey("updated_at")
38088
+ Schema10.propertySignature(Schema10.NullOr(Schema10.Date)),
38089
+ Schema10.fromKey("updated_at")
37728
38090
  ),
37729
- memo: Schema9.NullOr(Schema9.String)
38091
+ memo: Schema10.NullOr(Schema10.String)
37730
38092
  });
37731
- var UpsertInvoiceTaxLineItemSchema = Schema9.Struct({
37732
- amount: Schema9.Number
38093
+ var UpsertInvoiceTaxLineItemSchema = Schema10.Struct({
38094
+ amount: Schema10.Number
37733
38095
  });
37734
- var UpsertInvoiceLineItemSchema = Schema9.Struct({
37735
- description: Schema9.String,
37736
- product: Schema9.String,
38096
+ var UpsertInvoiceLineItemSchema = Schema10.Struct({
38097
+ description: Schema10.String,
38098
+ product: Schema10.String,
37737
38099
  unitPrice: pipe5(
37738
- Schema9.propertySignature(Schema9.Number),
37739
- Schema9.fromKey("unit_price")
38100
+ Schema10.propertySignature(Schema10.Number),
38101
+ Schema10.fromKey("unit_price")
37740
38102
  ),
37741
- quantity: Schema9.BigDecimal
38103
+ quantity: Schema10.BigDecimal,
38104
+ salesTaxes: pipe5(
38105
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.Array(UpsertInvoiceTaxLineItemSchema))),
38106
+ Schema10.fromKey("sales_taxes")
38107
+ )
37742
38108
  });
37743
- var UpsertInvoiceSchema = Schema9.Struct({
38109
+ var UpsertInvoiceSchema = Schema10.Struct({
37744
38110
  sentAt: pipe5(
37745
- Schema9.propertySignature(Schema9.Date),
37746
- Schema9.fromKey("sent_at")
38111
+ Schema10.propertySignature(Schema10.Date),
38112
+ Schema10.fromKey("sent_at")
37747
38113
  ),
37748
38114
  dueAt: pipe5(
37749
- Schema9.propertySignature(Schema9.Date),
37750
- Schema9.fromKey("due_at")
38115
+ Schema10.propertySignature(Schema10.Date),
38116
+ Schema10.fromKey("due_at")
37751
38117
  ),
37752
38118
  invoiceNumber: pipe5(
37753
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.String)),
37754
- Schema9.fromKey("invoice_number")
38119
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.String)),
38120
+ Schema10.fromKey("invoice_number")
37755
38121
  ),
37756
38122
  customerId: pipe5(
37757
- Schema9.propertySignature(Schema9.UUID),
37758
- Schema9.fromKey("customer_id")
38123
+ Schema10.propertySignature(Schema10.UUID),
38124
+ Schema10.fromKey("customer_id")
37759
38125
  ),
37760
- memo: Schema9.NullOr(Schema9.String),
38126
+ memo: Schema10.NullOr(Schema10.String),
37761
38127
  lineItems: pipe5(
37762
- Schema9.propertySignature(Schema9.Array(UpsertInvoiceLineItemSchema)),
37763
- Schema9.fromKey("line_items")
38128
+ Schema10.propertySignature(Schema10.Array(UpsertInvoiceLineItemSchema)),
38129
+ Schema10.fromKey("line_items")
37764
38130
  ),
37765
38131
  additionalDiscount: pipe5(
37766
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.Number)),
37767
- Schema9.fromKey("additional_discount")
37768
- ),
37769
- additionalSalesTaxes: pipe5(
37770
- Schema9.propertySignature(Schema9.UndefinedOr(Schema9.Array(UpsertInvoiceTaxLineItemSchema))),
37771
- Schema9.fromKey("additional_sales_taxes")
38132
+ Schema10.propertySignature(Schema10.UndefinedOr(Schema10.Number)),
38133
+ Schema10.fromKey("additional_discount")
37772
38134
  )
37773
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
+ });
37774
38158
 
37775
38159
  // src/features/invoices/api/useUpsertInvoice.tsx
37776
- import { useCallback as useCallback52 } from "react";
38160
+ import { useCallback as useCallback53 } from "react";
37777
38161
  import useSWRMutation26 from "swr/mutation";
37778
- import { Schema as Schema10, Effect } from "effect";
38162
+ import { Schema as Schema11, Effect } from "effect";
37779
38163
  var UPSERT_INVOICES_TAG_KEY = "#upsert-invoice";
37780
38164
  var createInvoice = post(({ businessId }) => `/v1/businesses/${businessId}/invoices`);
37781
38165
  var updateInvoice = put(({ businessId, invoiceId }) => `/v1/businesses/${businessId}/invoices/${invoiceId}`);
@@ -37795,7 +38179,7 @@ function buildKey39({
37795
38179
  };
37796
38180
  }
37797
38181
  }
37798
- var UpsertInvoiceReturnSchema = Schema10.Struct({
38182
+ var UpsertInvoiceReturnSchema = Schema11.Struct({
37799
38183
  data: InvoiceSchema
37800
38184
  });
37801
38185
  var UpsertInvoiceSWRResponse = class {
@@ -37816,19 +38200,19 @@ var UpsertInvoiceSWRResponse = class {
37816
38200
  return this.swrResponse.error !== void 0;
37817
38201
  }
37818
38202
  };
37819
- var CreateParamsSchema = Schema10.Struct({
37820
- businessId: Schema10.String
38203
+ var CreateParamsSchema = Schema11.Struct({
38204
+ businessId: Schema11.String
37821
38205
  });
37822
- var UpdateParamsSchema = Schema10.Struct({
37823
- businessId: Schema10.String,
37824
- invoiceId: Schema10.String
38206
+ var UpdateParamsSchema = Schema11.Struct({
38207
+ businessId: Schema11.String,
38208
+ invoiceId: Schema11.String
37825
38209
  });
37826
38210
  var isParamsValidForMode = (mode, params) => {
37827
38211
  if (mode === "Update" /* Update */) {
37828
- return Effect.runSync(Effect.either(Schema10.decodeUnknown(UpdateParamsSchema)(params)))._tag === "Right";
38212
+ return Effect.runSync(Effect.either(Schema11.decodeUnknown(UpdateParamsSchema)(params)))._tag === "Right";
37829
38213
  }
37830
38214
  if (mode === "Create" /* Create */) {
37831
- return Effect.runSync(Effect.either(Schema10.decodeUnknown(CreateParamsSchema)(params)))._tag === "Right";
38215
+ return Effect.runSync(Effect.either(Schema11.decodeUnknown(CreateParamsSchema)(params)))._tag === "Right";
37832
38216
  }
37833
38217
  return false;
37834
38218
  };
@@ -37861,15 +38245,16 @@ var useUpsertInvoice = (props) => {
37861
38245
  apiUrl,
37862
38246
  accessToken,
37863
38247
  body
37864
- }).then(Schema10.decodeUnknownPromise(UpsertInvoiceReturnSchema));
38248
+ }).then(Schema11.decodeUnknownPromise(UpsertInvoiceReturnSchema));
37865
38249
  },
37866
38250
  {
37867
- revalidate: false
38251
+ revalidate: false,
38252
+ throwOnError: true
37868
38253
  }
37869
38254
  );
37870
38255
  const mutationResponse = new UpsertInvoiceSWRResponse(rawMutationResponse);
37871
38256
  const originalTrigger = mutationResponse.trigger;
37872
- const stableProxiedTrigger = useCallback52(
38257
+ const stableProxiedTrigger = useCallback53(
37873
38258
  (...triggerParameters) => __async(null, null, function* () {
37874
38259
  const triggerResult = yield originalTrigger(...triggerParameters);
37875
38260
  return triggerResult;
@@ -37887,65 +38272,283 @@ var useUpsertInvoice = (props) => {
37887
38272
  };
37888
38273
 
37889
38274
  // src/components/Invoices/InvoiceForm/useInvoiceForm.ts
37890
- import { BigDecimal as BD4, Schema as Schema11 } from "effect";
37891
- 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 = () => ({
37892
38333
  product: "",
37893
38334
  description: "",
37894
- unitPrice: 0,
38335
+ unitPrice: BIG_DECIMAL_ZERO,
37895
38336
  quantity: BIG_DECIMAL_ONE,
37896
- amount: 0
37897
- };
37898
- var DEFAULT_FORM_VALUES = {
37899
- invoiceNumber: "",
37900
- customer: null,
37901
- email: "",
37902
- address: "",
37903
- lineItems: [EMPTY_LINE_ITEM]
38337
+ amount: BIG_DECIMAL_ZERO,
38338
+ isTaxable: false
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
+ };
37904
38356
  };
37905
38357
  var getInvoiceLineItemAmount = (lineItem) => {
37906
38358
  const { unitPrice, quantity } = lineItem;
37907
- return convertBigDecimalToCents(BD4.multiply(quantity, convertCentsToBigDecimal(unitPrice)));
38359
+ return BD4.multiply(quantity, convertCentsToBigDecimal(unitPrice));
37908
38360
  };
37909
- var getAugmentedInvoiceFormLineItem = (lineItem) => {
37910
- return __spreadProps(__spreadValues({}, lineItem), {
37911
- amount: getInvoiceLineItemAmount(lineItem)
37912
- });
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),
38368
+ amount: getInvoiceLineItemAmount(lineItem),
38369
+ isTaxable: lineItem.salesTaxTotal > 0
38370
+ };
37913
38371
  };
37914
- var getInvoiceFormDefaultValues = (invoice) => {
38372
+ var getInvoiceFormInitialValues = (invoice) => {
37915
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;
37916
38387
  return {
37917
- invoiceNumber: invoice.invoiceNumber,
38388
+ terms: getInvoiceTermsFromDates(sentAt, dueAt),
38389
+ invoiceNumber: invoice.invoiceNumber || "",
38390
+ sentAt,
38391
+ dueAt,
37918
38392
  customer: invoice.customer,
37919
- email: (_a = invoice.customer) == null ? void 0 : _a.email,
37920
- address: (_b = invoice.customer) == null ? void 0 : _b.addressString,
37921
- 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 || ""
37922
38399
  };
37923
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
+ }
37924
38484
  var useInvoiceForm = (props) => {
37925
38485
  const [submitError, setSubmitError] = useState84(void 0);
37926
38486
  const { onSuccess, mode } = props;
37927
38487
  const upsertInvoiceProps = mode === "Update" /* Update */ ? { mode, invoiceId: props.invoice.id } : { mode };
37928
38488
  const { trigger: upsertInvoice } = useUpsertInvoice(upsertInvoiceProps);
37929
- const defaultValues = mode === "Update" /* Update */ ? getInvoiceFormDefaultValues(props.invoice) : DEFAULT_FORM_VALUES;
37930
- const form = useAppForm({
37931
- defaultValues,
37932
- onSubmit: (_0) => __async(null, [_0], function* ({ value }) {
37933
- var _a;
37934
- try {
37935
- const payload = __spreadProps(__spreadValues({}, value), {
37936
- customerId: (_a = value == null ? void 0 : value.customer) == null ? void 0 : _a.id
37937
- });
37938
- const invoiceParams = Schema11.validateSync(UpsertInvoiceSchema)(payload);
37939
- const { data: invoice } = yield upsertInvoice(invoiceParams);
37940
- setSubmitError(void 0);
37941
- onSuccess == null ? void 0 : onSuccess(invoice);
37942
- } catch (e) {
37943
- setSubmitError("Something went wrong. Please try again.");
37944
- }
37945
- })
37946
- });
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 });
37947
38509
  const isFormValid = useStore7(form.store, (state) => state.isValid);
37948
- 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
+ );
37949
38552
  };
37950
38553
 
37951
38554
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
@@ -37953,9 +38556,9 @@ import { Plus as Plus2, Trash as Trash2 } from "lucide-react";
37953
38556
  import { BigDecimal as BD5 } from "effect";
37954
38557
 
37955
38558
  // src/features/customers/components/CustomerSelector.tsx
37956
- import { useCallback as useCallback53, useId as useId5, useMemo as useMemo72 } from "react";
37957
- import classNames89 from "classnames";
37958
- import { jsx as jsx336, 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";
37959
38562
  function getCustomerName(customer) {
37960
38563
  var _a, _b, _c;
37961
38564
  return (_c = (_b = (_a = customer.individualName) != null ? _a : customer.companyName) != null ? _b : customer.externalId) != null ? _c : "Unknown Customer";
@@ -37986,7 +38589,7 @@ function CustomerSelector({
37986
38589
  inline,
37987
38590
  className
37988
38591
  }) {
37989
- const combinedClassName = classNames89(
38592
+ const combinedClassName = classNames91(
37990
38593
  "Layer__CustomerSelector",
37991
38594
  inline && "Layer__CustomerSelector--inline",
37992
38595
  className
@@ -37996,12 +38599,12 @@ function CustomerSelector({
37996
38599
  });
37997
38600
  const effectiveSearchQuery = searchQuery === "" ? void 0 : searchQuery;
37998
38601
  const { data, isLoading, isError } = useListCustomers({ query: effectiveSearchQuery });
37999
- const options = useMemo72(
38602
+ const options2 = useMemo73(
38000
38603
  () => (data == null ? void 0 : data.flatMap(({ data: data2 }) => data2).map((customer) => new CustomerAsOption(customer))) || [],
38001
38604
  [data]
38002
38605
  );
38003
38606
  const selectedCustomerId = selectedCustomer == null ? void 0 : selectedCustomer.id;
38004
- const handleSelectionChange = useCallback53(
38607
+ const handleSelectionChange = useCallback55(
38005
38608
  (selectedOption) => {
38006
38609
  if (selectedOption === null) {
38007
38610
  handleInputChange("");
@@ -38010,7 +38613,7 @@ function CustomerSelector({
38010
38613
  }
38011
38614
  return;
38012
38615
  }
38013
- const selectedCustomer2 = options.find(({ id }) => id === selectedOption.value);
38616
+ const selectedCustomer2 = options2.find(({ id }) => id === selectedOption.value);
38014
38617
  if (selectedCustomer2) {
38015
38618
  const selectedCustomerWithType = selectedCustomer2.original;
38016
38619
  if (selectedCustomer2.id !== selectedCustomerId) {
@@ -38020,9 +38623,9 @@ function CustomerSelector({
38020
38623
  return;
38021
38624
  }
38022
38625
  },
38023
- [options, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38626
+ [options2, handleInputChange, selectedCustomerId, onSelectedCustomerChange]
38024
38627
  );
38025
- const selectedCustomerForComboBox = useMemo72(
38628
+ const selectedCustomerForComboBox = useMemo73(
38026
38629
  () => {
38027
38630
  if (selectedCustomer === null) {
38028
38631
  return null;
@@ -38034,12 +38637,12 @@ function CustomerSelector({
38034
38637
  },
38035
38638
  [selectedCustomer]
38036
38639
  );
38037
- const EmptyMessage = useMemo72(
38038
- () => /* @__PURE__ */ jsx336(P, { variant: "subtle", children: "No matching customer" }),
38640
+ const EmptyMessage = useMemo73(
38641
+ () => /* @__PURE__ */ jsx339(P, { variant: "subtle", children: "No matching customer" }),
38039
38642
  []
38040
38643
  );
38041
- const ErrorMessage = useMemo72(
38042
- () => /* @__PURE__ */ jsx336(
38644
+ const ErrorMessage = useMemo73(
38645
+ () => /* @__PURE__ */ jsx339(
38043
38646
  P,
38044
38647
  {
38045
38648
  size: "xs",
@@ -38049,142 +38652,287 @@ function CustomerSelector({
38049
38652
  ),
38050
38653
  []
38051
38654
  );
38052
- const inputId = useId5();
38053
- const isFiltered = effectiveSearchQuery !== void 0;
38054
- const noCustomersExist = !isLoading && !isFiltered && data !== void 0 && data.every(({ data: data2 }) => data2.length === 0);
38055
- const shouldHideComponent = noCustomersExist || isReadOnly && selectedCustomer === null;
38056
- if (shouldHideComponent) {
38057
- return null;
38058
- }
38655
+ const inputId = useId6();
38059
38656
  const isLoadingWithoutFallback = isLoading && !data;
38060
38657
  const shouldDisableComboBox = isLoadingWithoutFallback || isError;
38061
- return /* @__PURE__ */ jsxs212(VStack, { className: combinedClassName, children: [
38062
- /* @__PURE__ */ jsx336(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38063
- /* @__PURE__ */ jsx336(
38658
+ return /* @__PURE__ */ jsxs214(VStack, { className: combinedClassName, children: [
38659
+ /* @__PURE__ */ jsx339(Label, { htmlFor: inputId, size: "sm", children: "Customer" }),
38660
+ /* @__PURE__ */ jsx339(
38064
38661
  ComboBox,
38065
38662
  {
38066
38663
  selectedValue: selectedCustomerForComboBox,
38067
38664
  onSelectedValueChange: handleSelectionChange,
38068
- options,
38665
+ options: options2,
38069
38666
  onInputValueChange: handleInputChange,
38070
38667
  inputId,
38071
38668
  placeholder,
38072
38669
  slots: { EmptyMessage, ErrorMessage },
38073
- isDisabled: isReadOnly || shouldDisableComboBox,
38670
+ isDisabled: shouldDisableComboBox,
38074
38671
  isError,
38075
- isLoading: isLoadingWithoutFallback
38672
+ isLoading: isLoadingWithoutFallback,
38673
+ isReadOnly
38076
38674
  }
38077
38675
  )
38078
38676
  ] });
38079
38677
  }
38080
38678
 
38081
38679
  // src/components/Invoices/InvoiceForm/InvoiceForm.tsx
38082
- import { jsx as jsx337, 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";
38083
38682
  var INVOICE_FORM_CSS_PREFIX = "Layer__InvoiceForm";
38084
38683
  var INVOICE_FORM_FIELD_CSS_PREFIX = `${INVOICE_FORM_CSS_PREFIX}__Field`;
38085
- var InvoiceForm = (props) => {
38086
- const { onSuccess, mode } = props;
38087
- 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(
38088
38699
  __spreadValues({ onSuccess }, mode === "Update" /* Update */ ? { mode, invoice: props.invoice } : { mode })
38089
38700
  );
38090
- return /* @__PURE__ */ jsxs213(Form, { className: INVOICE_FORM_CSS_PREFIX, children: [
38091
- /* @__PURE__ */ jsxs213(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__Metadata`, gap: "xs", children: [
38092
- /* @__PURE__ */ jsx337(
38093
- form.Field,
38094
- {
38095
- name: "customer",
38096
- listeners: {
38097
- onChange: ({ value: customer }) => {
38098
- form.setFieldValue("email", customer == null ? void 0 : customer.email);
38099
- form.setFieldValue("address", customer == null ? void 0 : customer.addressString);
38100
- }
38101
- },
38102
- children: (field) => /* @__PURE__ */ jsx337(
38103
- CustomerSelector,
38104
- {
38105
- className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Customer`,
38106
- selectedCustomer: field.state.value,
38107
- onSelectedCustomerChange: field.handleChange,
38108
- inline: true
38109
- }
38110
- )
38111
- }
38112
- ),
38113
- /* @__PURE__ */ jsx337(form.AppField, { name: "email", children: (field) => /* @__PURE__ */ jsx337(field.FormTextField, { slotProps: { BaseFormTextField: { label: "Email", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Email` } } }) }),
38114
- /* @__PURE__ */ jsx337(form.AppField, { name: "address", children: (field) => /* @__PURE__ */ jsx337(field.FormTextAreaField, { slotProps: { BaseFormTextField: { label: "Billing address", inline: true, className: `${INVOICE_FORM_FIELD_CSS_PREFIX}__Address` } } }) })
38115
- ] }),
38116
- /* @__PURE__ */ jsx337(VStack, { className: `${INVOICE_FORM_CSS_PREFIX}__LineItems`, gap: "xs", children: /* @__PURE__ */ jsx337(form.AppField, { name: "lineItems", mode: "array", children: (field) => /* @__PURE__ */ jsxs213(VStack, { gap: "xs", align: "baseline", children: [
38117
- field.state.value.map((_, index) => /* @__PURE__ */ jsxs213(HStack, { gap: "xs", align: "end", className: `${INVOICE_FORM_CSS_PREFIX}__LineItem`, children: [
38118
- /* @__PURE__ */ jsx337(form.AppField, { name: `lineItems[${index}].product`, children: (innerField) => /* @__PURE__ */ jsx337(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Product", showLabel: index === 0 } } }) }),
38119
- /* @__PURE__ */ jsx337(form.AppField, { name: `lineItems[${index}].description`, children: (innerField) => /* @__PURE__ */ jsx337(innerField.FormTextField, { slotProps: { BaseFormTextField: { label: "Description", showLabel: index === 0 } } }) }),
38120
- /* @__PURE__ */ jsx337(
38121
- 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,
38122
38730
  {
38123
- name: `lineItems[${index}].quantity`,
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",
38124
38747
  listeners: {
38125
- onBlur: ({ value: quantity }) => {
38126
- const unitPrice = form.getFieldValue(`lineItems[${index}].unitPrice`);
38127
- const nextAmount = BD5.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38128
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38748
+ onChange: ({ value: customer }) => {
38749
+ form.setFieldValue("email", (customer == null ? void 0 : customer.email) || "");
38750
+ form.setFieldValue("address", (customer == null ? void 0 : customer.addressString) || "");
38129
38751
  }
38130
38752
  },
38131
- children: (innerField) => /* @__PURE__ */ jsx337(innerField.FormBigDecimalField, { slotProps: { BaseFormTextField: { label: "Quantity", showLabel: index === 0 } } })
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
+ )
38132
38763
  }
38133
38764
  ),
38134
- /* @__PURE__ */ jsx337(
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,
38772
+ {
38773
+ name: "terms",
38774
+ listeners: {
38775
+ onChange: ({ value: terms }) => {
38776
+ const sentAt = form.getFieldValue("sentAt");
38777
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38778
+ }
38779
+ },
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
+ )
38792
+ }
38793
+ ),
38794
+ /* @__PURE__ */ jsx340(
38135
38795
  form.AppField,
38136
38796
  {
38137
- name: `lineItems[${index}].unitPrice`,
38797
+ name: "sentAt",
38138
38798
  listeners: {
38139
- onBlur: ({ value: unitPrice }) => {
38140
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38141
- const nextAmount = BD5.multiply(convertCentsToBigDecimal(unitPrice), quantity);
38142
- form.setFieldValue(`lineItems[${index}].amount`, convertBigDecimalToCents(nextAmount));
38799
+ onBlur: ({ value: sentAt }) => {
38800
+ const terms = form.getFieldValue("terms");
38801
+ updateDueAtFromTermsAndSentAt(terms, sentAt);
38143
38802
  }
38144
38803
  },
38145
- children: (innerField) => /* @__PURE__ */ jsx337(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { 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 })
38146
38805
  }
38147
38806
  ),
38148
- /* @__PURE__ */ jsx337(
38807
+ /* @__PURE__ */ jsx340(
38149
38808
  form.AppField,
38150
38809
  {
38151
- name: `lineItems[${index}].amount`,
38810
+ name: "dueAt",
38152
38811
  listeners: {
38153
- onBlur: ({ value: amount }) => {
38154
- const quantity = form.getFieldValue(`lineItems[${index}].quantity`);
38155
- let nextUnitPrice = BIG_DECIMAL_ZERO;
38156
- try {
38157
- nextUnitPrice = BD5.unsafeDivide(convertCentsToBigDecimal(amount), quantity);
38158
- } 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;
38159
38819
  }
38160
- form.setFieldValue(`lineItems[${index}].unitPrice`, convertBigDecimalToCents(nextUnitPrice));
38161
38820
  }
38162
38821
  },
38163
- children: (innerField) => /* @__PURE__ */ jsx337(innerField.FormCurrencyField, { slotProps: { BaseFormTextField: { 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 })
38164
38823
  }
38165
- ),
38166
- /* @__PURE__ */ jsx337(Button2, { variant: "outlined", icon: true, "aria-label": "Delete line item", onClick: () => field.removeValue(index), children: /* @__PURE__ */ jsx337(Trash2, { size: 16 }) })
38167
- ] }, `lineItems[${index}]`)),
38168
- /* @__PURE__ */ jsxs213(Button2, { variant: "outlined", onClick: () => field.pushValue(EMPTY_LINE_ITEM), children: [
38169
- "Add line item",
38170
- /* @__PURE__ */ jsx337(Plus2, { size: 16 })
38824
+ )
38171
38825
  ] })
38172
- ] }) }) })
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
+ ] })
38173
38920
  ] });
38174
- };
38921
+ });
38922
+ InvoiceForm.displayName = "InvoiceForm";
38175
38923
 
38176
38924
  // src/components/DataPoint/DataPoint.tsx
38177
- import { jsx as jsx338, jsxs as jsxs214 } from "react/jsx-runtime";
38925
+ import { jsx as jsx341, jsxs as jsxs216 } from "react/jsx-runtime";
38178
38926
  var DataPoint = ({ label, children }) => {
38179
- return /* @__PURE__ */ jsxs214(VStack, { gap: "3xs", children: [
38180
- /* @__PURE__ */ jsx338(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 }),
38181
38929
  children
38182
38930
  ] });
38183
38931
  };
38184
38932
 
38185
38933
  // src/components/Invoices/InvoiceStatusCell/InvoiceStatusCell.tsx
38186
38934
  import pluralize6 from "pluralize";
38187
- import { jsx as jsx339, jsxs as jsxs215 } from "react/jsx-runtime";
38935
+ import { jsx as jsx342, jsxs as jsxs217 } from "react/jsx-runtime";
38188
38936
  var getDueStatusConfig = (invoice, { inline }) => {
38189
38937
  const badgeSize = inline ? "xs" /* EXTRA_SMALL */ : "small" /* SMALL */;
38190
38938
  const iconSize = inline ? 10 : 12;
@@ -38198,7 +38946,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38198
38946
  case "PAID" /* Paid */: {
38199
38947
  return {
38200
38948
  text: "Paid",
38201
- badge: /* @__PURE__ */ jsx339(Badge, { variant: "success" /* SUCCESS */, size: badgeSize, icon: /* @__PURE__ */ jsx339(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 })
38202
38950
  };
38203
38951
  }
38204
38952
  case "VOIDED" /* Voided */: {
@@ -38221,7 +38969,7 @@ var getDueStatusConfig = (invoice, { inline }) => {
38221
38969
  return {
38222
38970
  text: "Overdue",
38223
38971
  subText: `Due ${pluralize6("day", Math.abs(dueDifference), true)} ago`,
38224
- badge: /* @__PURE__ */ jsx339(Badge, { variant: "warning" /* WARNING */, size: badgeSize, icon: /* @__PURE__ */ jsx339(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 })
38225
38973
  };
38226
38974
  }
38227
38975
  return {
@@ -38241,73 +38989,117 @@ var InvoiceStatusCell = ({ invoice, inline = false }) => {
38241
38989
  const dueStatus = getDueStatusConfig(invoice, { inline });
38242
38990
  const Stack3 = inline ? HStack : VStack;
38243
38991
  const subText = inline && dueStatus.subText ? `(${dueStatus.subText})` : dueStatus.subText;
38244
- return /* @__PURE__ */ jsxs215(HStack, { gap: "xs", align: "center", children: [
38992
+ return /* @__PURE__ */ jsxs217(HStack, { gap: "xs", align: "center", children: [
38245
38993
  dueStatus.badge,
38246
- /* @__PURE__ */ jsxs215(Stack3, __spreadProps(__spreadValues({}, inline && { gap: "3xs", align: "center" }), { children: [
38247
- /* @__PURE__ */ jsx339(Span, { children: dueStatus.text }),
38248
- subText && /* @__PURE__ */ jsx339(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 })
38249
38997
  ] }))
38250
38998
  ] });
38251
38999
  };
38252
39000
 
38253
39001
  // src/components/Invoices/InvoiceDetail/InvoiceDetail.tsx
38254
- import { jsx as jsx340, 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";
38255
39004
  var InvoiceDetail = (props) => {
38256
- const _a = props, { onSuccess: _onSuccess, onGoBack } = _a, restProps = __objRest(_a, ["onSuccess", "onGoBack"]);
38257
- const Header6 = useCallback54(() => {
38258
- return /* @__PURE__ */ jsx340(InvoiceDetailHeader, __spreadValues({}, restProps));
38259
- }, [restProps]);
38260
- return /* @__PURE__ */ jsxs216(BaseDetailView, { slots: { Header: Header6 }, name: "Invoice Detail View", onGoBack, children: [
38261
- restProps.mode === "Update" /* Update */ && /* @__PURE__ */ jsx340(InvoiceDetailSubHeader, { invoice: restProps.invoice }),
38262
- /* @__PURE__ */ jsx340(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
+ )
38263
39043
  ] });
38264
39044
  };
38265
39045
  var InvoiceDetailHeader = (props) => {
38266
- const { mode } = props;
39046
+ const { mode, onSubmit, formState, isReadOnly, setIsReadOnly } = props;
39047
+ const { isSubmitting } = formState;
38267
39048
  if (mode === "Create" /* Create */) {
38268
- return /* @__PURE__ */ jsx340(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
+ ] });
38269
39053
  }
38270
39054
  const invoice = props.invoice;
38271
39055
  const { invoiceNumber } = invoice;
38272
- return /* @__PURE__ */ jsx340(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
+ ] });
38273
39065
  };
38274
39066
  var InvoiceDetailSubHeader = ({ invoice }) => {
38275
39067
  const { outstandingBalance, totalAmount } = invoice;
38276
- return /* @__PURE__ */ jsx340(HStack, { className: "Layer__InvoiceDetail__SubHeader", children: /* @__PURE__ */ jsxs216(HStack, { gap: "5xl", children: [
38277
- /* @__PURE__ */ jsx340(DataPoint, { label: "Balance due", children: /* @__PURE__ */ jsx340(Span, { children: convertCentsToCurrency(outstandingBalance) }) }),
38278
- /* @__PURE__ */ jsx340(DataPoint, { label: "Open balance", children: /* @__PURE__ */ jsx340(Span, { children: convertCentsToCurrency(totalAmount) }) }),
38279
- /* @__PURE__ */ jsx340(DataPoint, { label: "Status", children: /* @__PURE__ */ jsx340(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 }) })
38280
39072
  ] }) });
38281
39073
  };
38282
39074
 
38283
39075
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38284
- import { useCallback as useCallback57, useMemo as useMemo76, useState as useState86 } from "react";
39076
+ import { useCallback as useCallback60, useMemo as useMemo77, useState as useState87 } from "react";
38285
39077
 
38286
39078
  // src/features/invoices/api/useListInvoices.tsx
38287
39079
  import useSWRInfinite7 from "swr/infinite";
38288
- var import_lodash6 = __toESM(require_lodash2());
38289
- import { useCallback as useCallback55, useMemo as useMemo73 } from "react";
38290
- 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";
38291
39083
 
38292
39084
  // src/types/utility/pagination.ts
38293
- import { Schema as Schema12, pipe as pipe6 } from "effect";
38294
- var PaginatedResponseMetaSchema = Schema12.Struct({
38295
- 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),
38296
39088
  hasMore: pipe6(
38297
- Schema12.propertySignature(Schema12.Boolean),
38298
- Schema12.fromKey("has_more")
39089
+ Schema13.propertySignature(Schema13.Boolean),
39090
+ Schema13.fromKey("has_more")
38299
39091
  ),
38300
39092
  totalCount: pipe6(
38301
- Schema12.propertySignature(Schema12.UndefinedOr(Schema12.Number)),
38302
- Schema12.fromKey("total_count")
39093
+ Schema13.propertySignature(Schema13.UndefinedOr(Schema13.Number)),
39094
+ Schema13.fromKey("total_count")
38303
39095
  )
38304
39096
  });
38305
39097
 
38306
39098
  // src/features/invoices/api/useListInvoices.tsx
38307
39099
  var LIST_INVOICES_TAG_KEY = "#list-invoices";
38308
- var ListInvoicesReturnSchema = Schema13.Struct({
38309
- data: Schema13.Array(InvoiceSchema),
38310
- meta: Schema13.Struct({
39100
+ var ListInvoicesReturnSchema = Schema14.Struct({
39101
+ data: Schema14.Array(InvoiceSchema),
39102
+ meta: Schema14.Struct({
38311
39103
  pagination: PaginatedResponseMetaSchema
38312
39104
  })
38313
39105
  });
@@ -38435,7 +39227,7 @@ function useListInvoices({
38435
39227
  showTotalCount: showTotalCount2
38436
39228
  }
38437
39229
  }
38438
- )().then(Schema13.decodeUnknownPromise(ListInvoicesReturnSchema)),
39230
+ )().then(Schema14.decodeUnknownPromise(ListInvoicesReturnSchema)),
38439
39231
  {
38440
39232
  keepPreviousData: true,
38441
39233
  revalidateFirstPage: false,
@@ -38454,10 +39246,10 @@ import {
38454
39246
  } from "@tanstack/react-table";
38455
39247
 
38456
39248
  // src/components/DataTable/DataTable.tsx
38457
- import { useMemo as useMemo74 } from "react";
39249
+ import { useMemo as useMemo75 } from "react";
38458
39250
 
38459
39251
  // src/components/ui/Table/Table.tsx
38460
- import { forwardRef as forwardRef24 } from "react";
39252
+ import { forwardRef as forwardRef26 } from "react";
38461
39253
  import {
38462
39254
  Cell as ReactAriaCell,
38463
39255
  Column as ReactAriaColumn,
@@ -38466,14 +39258,14 @@ import {
38466
39258
  TableBody as ReactAriaTableBody,
38467
39259
  TableHeader as ReactAriaTableHeader
38468
39260
  } from "react-aria-components";
38469
- import classNames90 from "classnames";
38470
- import { jsx as jsx341 } from "react/jsx-runtime";
39261
+ import classNames93 from "classnames";
39262
+ import { jsx as jsx344 } from "react/jsx-runtime";
38471
39263
  var CSS_PREFIX2 = "Layer__UI__Table";
38472
- var getClassName = (component, additionalClassNames) => classNames90(`${CSS_PREFIX2}-${component}`, additionalClassNames);
38473
- var Table2 = forwardRef24(
39264
+ var getClassName = (component, additionalClassNames) => classNames93(`${CSS_PREFIX2}-${component}`, additionalClassNames);
39265
+ var Table2 = forwardRef26(
38474
39266
  (_a, ref) => {
38475
39267
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38476
- return /* @__PURE__ */ jsx341(
39268
+ return /* @__PURE__ */ jsx344(
38477
39269
  ReactAriaTable,
38478
39270
  __spreadProps(__spreadValues({
38479
39271
  className: getClassName("Table" /* Table */, className)
@@ -38487,7 +39279,7 @@ var Table2 = forwardRef24(
38487
39279
  Table2.displayName = "Table" /* Table */;
38488
39280
  var TableHeaderInner = (_a, ref) => {
38489
39281
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38490
- return /* @__PURE__ */ jsx341(
39282
+ return /* @__PURE__ */ jsx344(
38491
39283
  ReactAriaTableHeader,
38492
39284
  __spreadProps(__spreadValues({
38493
39285
  className: getClassName("TableHeader" /* TableHeader */, className)
@@ -38497,11 +39289,11 @@ var TableHeaderInner = (_a, ref) => {
38497
39289
  })
38498
39290
  );
38499
39291
  };
38500
- var TableHeader = forwardRef24(TableHeaderInner);
39292
+ var TableHeader = forwardRef26(TableHeaderInner);
38501
39293
  TableHeader.displayName = "TableHeader" /* TableHeader */;
38502
39294
  var TableBodyInner = (_a, ref) => {
38503
39295
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38504
- return /* @__PURE__ */ jsx341(
39296
+ return /* @__PURE__ */ jsx344(
38505
39297
  ReactAriaTableBody,
38506
39298
  __spreadProps(__spreadValues({
38507
39299
  className: getClassName("TableBody" /* TableBody */, className)
@@ -38511,11 +39303,11 @@ var TableBodyInner = (_a, ref) => {
38511
39303
  })
38512
39304
  );
38513
39305
  };
38514
- var TableBody2 = forwardRef24(TableBodyInner);
39306
+ var TableBody2 = forwardRef26(TableBodyInner);
38515
39307
  TableBody2.displayName = "TableBody" /* TableBody */;
38516
39308
  var RowInner = (_a, ref) => {
38517
39309
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38518
- return /* @__PURE__ */ jsx341(
39310
+ return /* @__PURE__ */ jsx344(
38519
39311
  ReactAriaTableRow,
38520
39312
  __spreadProps(__spreadValues({
38521
39313
  className: getClassName("Row" /* Row */, className)
@@ -38525,13 +39317,13 @@ var RowInner = (_a, ref) => {
38525
39317
  })
38526
39318
  );
38527
39319
  };
38528
- var Row2 = forwardRef24(RowInner);
39320
+ var Row2 = forwardRef26(RowInner);
38529
39321
  Row2.displayName = "Row" /* Row */;
38530
- var Column = forwardRef24(
39322
+ var Column = forwardRef26(
38531
39323
  (_a, ref) => {
38532
39324
  var _b = _a, { children, className, textAlign = "left" } = _b, restProps = __objRest(_b, ["children", "className", "textAlign"]);
38533
39325
  const dataProperties = toDataProperties({ "text-align": textAlign });
38534
- return /* @__PURE__ */ jsx341(
39326
+ return /* @__PURE__ */ jsx344(
38535
39327
  ReactAriaColumn,
38536
39328
  __spreadProps(__spreadValues(__spreadValues({
38537
39329
  className: getClassName("Column" /* Column */, className)
@@ -38543,10 +39335,10 @@ var Column = forwardRef24(
38543
39335
  }
38544
39336
  );
38545
39337
  Column.displayName = "Column" /* Column */;
38546
- var Cell5 = forwardRef24(
39338
+ var Cell5 = forwardRef26(
38547
39339
  (_a, ref) => {
38548
39340
  var _b = _a, { children, className } = _b, restProps = __objRest(_b, ["children", "className"]);
38549
- return /* @__PURE__ */ jsx341(
39341
+ return /* @__PURE__ */ jsx344(
38550
39342
  ReactAriaCell,
38551
39343
  __spreadProps(__spreadValues({
38552
39344
  className: getClassName("Cell" /* Cell */, className)
@@ -38560,7 +39352,7 @@ var Cell5 = forwardRef24(
38560
39352
  Cell5.displayName = "Cell" /* Cell */;
38561
39353
 
38562
39354
  // src/components/DataTable/DataTable.tsx
38563
- import { jsx as jsx342, jsxs as jsxs217 } from "react/jsx-runtime";
39355
+ import { jsx as jsx345, jsxs as jsxs219 } from "react/jsx-runtime";
38564
39356
  var DataTable = ({
38565
39357
  columnConfig,
38566
39358
  data,
@@ -38573,17 +39365,17 @@ var DataTable = ({
38573
39365
  const columns = Object.values(columnConfig);
38574
39366
  const { EmptyState, ErrorState } = slots;
38575
39367
  const isEmptyTable = (data == null ? void 0 : data.length) === 0;
38576
- const renderTableBody = useMemo74(() => {
39368
+ const renderTableBody = useMemo75(() => {
38577
39369
  if (isError) {
38578
- return /* @__PURE__ */ jsx342(Row2, { children: /* @__PURE__ */ jsx342(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx342(ErrorState, {}) }) });
39370
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(ErrorState, {}) }) });
38579
39371
  }
38580
39372
  if (isLoading) {
38581
- return /* @__PURE__ */ jsx342(Row2, { children: /* @__PURE__ */ jsx342(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx342(Loader2, {}) }) });
39373
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(Loader2, {}) }) });
38582
39374
  }
38583
39375
  if (isEmptyTable) {
38584
- return /* @__PURE__ */ jsx342(Row2, { children: /* @__PURE__ */ jsx342(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx342(EmptyState, {}) }) });
39376
+ return /* @__PURE__ */ jsx345(Row2, { children: /* @__PURE__ */ jsx345(Cell5, { colSpan: columns.length, children: /* @__PURE__ */ jsx345(EmptyState, {}) }) });
38585
39377
  }
38586
- const RowRenderer = (row) => /* @__PURE__ */ jsx342(Row2, { children: columns.map((col) => /* @__PURE__ */ jsx342(
39378
+ const RowRenderer = (row) => /* @__PURE__ */ jsx345(Row2, { children: columns.map((col) => /* @__PURE__ */ jsx345(
38587
39379
  Cell5,
38588
39380
  {
38589
39381
  className: `Layer__UI__Table-Cell__${componentName}--${col.id}`,
@@ -38594,15 +39386,15 @@ var DataTable = ({
38594
39386
  RowRenderer.displayName = "Row";
38595
39387
  return RowRenderer;
38596
39388
  }, [isError, isLoading, isEmptyTable, columns, ErrorState, EmptyState, componentName]);
38597
- return /* @__PURE__ */ jsxs217(Table2, { "aria-label": ariaLabel, className: `Layer__UI__Table__${componentName}`, children: [
38598
- /* @__PURE__ */ jsx342(TableHeader, { columns, children: ({ id, header, isRowHeader }) => /* @__PURE__ */ jsx342(Column, { isRowHeader, className: `Layer__UI__Table-Column__${componentName}--${id}`, children: header }, id) }),
38599
- /* @__PURE__ */ jsx342(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 })
38600
39392
  ] });
38601
39393
  };
38602
39394
 
38603
39395
  // src/components/DataTable/PaginatedTable.tsx
38604
- import { useCallback as useCallback56, useMemo as useMemo75, useState as useState85 } from "react";
38605
- import { jsx as jsx343, 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";
38606
39398
  var EMPTY_ARRAY = [];
38607
39399
  function PaginatedTable({
38608
39400
  data,
@@ -38615,7 +39407,7 @@ function PaginatedTable({
38615
39407
  slots
38616
39408
  }) {
38617
39409
  const { pageSize = 20, hasMore, fetchMore } = paginationProps;
38618
- const [pagination, setPagination] = useState85({ pageIndex: 0, pageSize });
39410
+ const [pagination, setPagination] = useState86({ pageIndex: 0, pageSize });
38619
39411
  const columnHelper = createColumnHelper();
38620
39412
  const columns = Object.values(columnConfig);
38621
39413
  const columnDefs = columns.map((col) => {
@@ -38635,12 +39427,12 @@ function PaginatedTable({
38635
39427
  autoResetPageIndex: false
38636
39428
  });
38637
39429
  const { rows } = table.getRowModel();
38638
- const rowData = useMemo75(() => rows.map((r) => r.original), [rows]);
38639
- const onPageChange = useCallback56((page) => {
39430
+ const rowData = useMemo76(() => rows.map((r) => r.original), [rows]);
39431
+ const onPageChange = useCallback59((page) => {
38640
39432
  table.setPageIndex(page - 1);
38641
39433
  }, [table]);
38642
- return /* @__PURE__ */ jsxs218(VStack, { children: [
38643
- /* @__PURE__ */ jsx343(
39434
+ return /* @__PURE__ */ jsxs220(VStack, { children: [
39435
+ /* @__PURE__ */ jsx346(
38644
39436
  DataTable,
38645
39437
  {
38646
39438
  ariaLabel,
@@ -38652,7 +39444,7 @@ function PaginatedTable({
38652
39444
  slots
38653
39445
  }
38654
39446
  ),
38655
- !isError && !isLoading && /* @__PURE__ */ jsx343(
39447
+ !isError && !isLoading && /* @__PURE__ */ jsx346(
38656
39448
  Pagination,
38657
39449
  {
38658
39450
  currentPage: table.getState().pagination.pageIndex + 1,
@@ -38667,10 +39459,10 @@ function PaginatedTable({
38667
39459
  }
38668
39460
 
38669
39461
  // src/icons/ChevronRightFill.tsx
38670
- import { jsx as jsx344, jsxs as jsxs219 } from "react/jsx-runtime";
39462
+ import { jsx as jsx347, jsxs as jsxs221 } from "react/jsx-runtime";
38671
39463
  var ChevronRightFill = (_a) => {
38672
39464
  var _b = _a, { size = 18 } = _b, props = __objRest(_b, ["size"]);
38673
- return /* @__PURE__ */ jsxs219(
39465
+ return /* @__PURE__ */ jsxs221(
38674
39466
  "svg",
38675
39467
  __spreadProps(__spreadValues({
38676
39468
  xmlns: "http://www.w3.org/2000/svg",
@@ -38680,8 +39472,8 @@ var ChevronRightFill = (_a) => {
38680
39472
  width: size,
38681
39473
  height: size,
38682
39474
  children: [
38683
- /* @__PURE__ */ jsx344("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
38684
- /* @__PURE__ */ jsx344(
39475
+ /* @__PURE__ */ jsx347("path", { d: "M6.75 4.5L11.25 9L6.75 13.5", fill: "currentColor" }),
39476
+ /* @__PURE__ */ jsx347(
38685
39477
  "path",
38686
39478
  {
38687
39479
  d: "M6.75 4.5L11.25 9L6.75 13.5Z",
@@ -38700,34 +39492,34 @@ var ChevronRightFill_default = ChevronRightFill;
38700
39492
  import { HandCoins, Search as Search2, Plus as Plus3 } from "lucide-react";
38701
39493
 
38702
39494
  // src/components/DataTable/DataTableHeader.tsx
38703
- import { jsx as jsx345, jsxs as jsxs220 } from "react/jsx-runtime";
39495
+ import { jsx as jsx348, jsxs as jsxs222 } from "react/jsx-runtime";
38704
39496
  var DataTableHeader = ({ name, count, slotProps = {}, slots = {} }) => {
38705
39497
  const { showCount, totalCount } = count != null ? count : {};
38706
39498
  const { Filters: Filters2, HeaderActions, HeaderFilters } = slots;
38707
- return /* @__PURE__ */ jsxs220(VStack, { children: [
38708
- /* @__PURE__ */ jsxs220(HStack, { justify: "space-between", align: "center", className: "Layer__DataTableHeader__Header", children: [
38709
- /* @__PURE__ */ jsxs220(HStack, { pis: "md", align: "center", gap: "xl", children: [
38710
- /* @__PURE__ */ jsxs220(HStack, { align: "center", gap: "sm", children: [
38711
- /* @__PURE__ */ jsx345(Span, { weight: "bold", size: "lg", children: name }),
38712
- showCount && (totalCount ? /* @__PURE__ */ jsx345(Badge, { variant: "default" /* DEFAULT */, size: "medium" /* MEDIUM */, children: totalCount }) : /* @__PURE__ */ jsx345(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, {}))
38713
39505
  ] }),
38714
- HeaderFilters && /* @__PURE__ */ jsx345(HeaderFilters, {})
39506
+ HeaderFilters && /* @__PURE__ */ jsx348(HeaderFilters, {})
38715
39507
  ] }),
38716
- /* @__PURE__ */ jsxs220(HStack, { pie: "md", align: "center", gap: "3xs", children: [
38717
- slotProps.SearchField && /* @__PURE__ */ jsx345(SearchField, __spreadValues({}, slotProps.SearchField)),
38718
- HeaderActions && /* @__PURE__ */ jsx345(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, {})
38719
39511
  ] })
38720
39512
  ] }),
38721
- Filters2 && /* @__PURE__ */ jsxs220(HStack, { pis: "md", pie: "md", justify: "space-between", align: "center", className: "Layer__DataTableHeader__Filters", children: [
38722
- /* @__PURE__ */ jsx345(Filters2, {}),
38723
- slotProps.ClearFiltersButton && /* @__PURE__ */ jsx345(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" }))
38724
39516
  ] })
38725
39517
  ] });
38726
39518
  };
38727
39519
 
38728
39520
  // src/components/Invoices/InvoicesTable/InvoicesTable.tsx
38729
- import { startOfToday, endOfYesterday } from "date-fns";
38730
- import { jsx as jsx346, 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";
38731
39523
  var COMPONENT_NAME10 = "InvoicesTable";
38732
39524
  var InvoiceStatusOptionConfig = {
38733
39525
  ["All" /* All */]: { label: "All", value: "All" /* All */ },
@@ -38748,12 +39540,12 @@ var AmountCell = ({ invoice }) => {
38748
39540
  case "WRITTEN_OFF" /* WrittenOff */:
38749
39541
  case "VOIDED" /* Voided */:
38750
39542
  case "SENT" /* Sent */: {
38751
- return /* @__PURE__ */ jsx346(VStack, { children: /* @__PURE__ */ jsx346(Span, { align: "right", children: totalAmount }) });
39543
+ return /* @__PURE__ */ jsx349(VStack, { children: /* @__PURE__ */ jsx349(Span, { align: "right", children: totalAmount }) });
38752
39544
  }
38753
39545
  case "PARTIALLY_PAID" /* PartiallyPaid */: {
38754
- return /* @__PURE__ */ jsxs221(VStack, { children: [
38755
- /* @__PURE__ */ jsx346(Span, { align: "right", children: totalAmount }),
38756
- /* @__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: [
38757
39549
  outstandingBalance,
38758
39550
  " ",
38759
39551
  "outstanding"
@@ -38770,7 +39562,7 @@ var AmountCell = ({ invoice }) => {
38770
39562
  };
38771
39563
  var getCustomerName2 = (invoice) => {
38772
39564
  const { recipientName, customer } = invoice;
38773
- 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;
38774
39566
  };
38775
39567
  var getColumnConfig = (onSelectInvoice) => ({
38776
39568
  ["SentAt" /* SentAt */]: {
@@ -38792,16 +39584,16 @@ var getColumnConfig = (onSelectInvoice) => ({
38792
39584
  ["Total" /* Total */]: {
38793
39585
  id: "Total" /* Total */,
38794
39586
  header: "Amount",
38795
- cell: (row) => /* @__PURE__ */ jsx346(AmountCell, { invoice: row })
39587
+ cell: (row) => /* @__PURE__ */ jsx349(AmountCell, { invoice: row })
38796
39588
  },
38797
39589
  ["Status" /* Status */]: {
38798
39590
  id: "Status" /* Status */,
38799
39591
  header: "Status",
38800
- cell: (row) => /* @__PURE__ */ jsx346(InvoiceStatusCell, { invoice: row })
39592
+ cell: (row) => /* @__PURE__ */ jsx349(InvoiceStatusCell, { invoice: row })
38801
39593
  },
38802
39594
  ["Expand" /* Expand */]: {
38803
39595
  id: "Expand" /* Expand */,
38804
- cell: (row) => /* @__PURE__ */ jsx346(Button2, { inset: true, icon: true, onPress: () => onSelectInvoice(row), "aria-label": "View invoice", variant: "ghost", children: /* @__PURE__ */ jsx346(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, {}) })
38805
39597
  }
38806
39598
  });
38807
39599
  var UNPAID_STATUSES2 = ["SENT" /* Sent */, "PARTIALLY_PAID" /* PartiallyPaid */];
@@ -38815,7 +39607,7 @@ var getListInvoiceParams = ({ statusFilter }) => {
38815
39607
  case "Overdue" /* Overdue */:
38816
39608
  return { status: UNPAID_STATUSES2, dueAtEnd: endOfYesterday() };
38817
39609
  case "Sent" /* Sent */:
38818
- return { status: UNPAID_STATUSES2, dueAtStart: startOfToday() };
39610
+ return { status: UNPAID_STATUSES2, dueAtStart: startOfToday2() };
38819
39611
  case "Paid" /* Paid */:
38820
39612
  return { status: ["PAID" /* Paid */, "PARTIALLY_WRITTEN_OFF" /* PartiallyWrittenOff */] };
38821
39613
  case "Written Off" /* WrittenOff */:
@@ -38830,8 +39622,8 @@ var getListInvoiceParams = ({ statusFilter }) => {
38830
39622
  }
38831
39623
  };
38832
39624
  var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38833
- const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = useState86(ALL_OPTION);
38834
- const listInvoiceParams = useMemo76(
39625
+ const [selectedInvoiceStatusOption, setSelectedInvoiceStatusOption] = useState87(ALL_OPTION);
39626
+ const listInvoiceParams = useMemo77(
38835
39627
  () => getListInvoiceParams({ statusFilter: selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value }),
38836
39628
  [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.value]
38837
39629
  );
@@ -38839,29 +39631,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38839
39631
  const invoices = data == null ? void 0 : data.flatMap(({ data: data2 }) => data2);
38840
39632
  const paginationMeta = data == null ? void 0 : data[data.length - 1].meta.pagination;
38841
39633
  const hasMore = paginationMeta == null ? void 0 : paginationMeta.hasMore;
38842
- const fetchMore = useCallback57(() => {
39634
+ const fetchMore = useCallback60(() => {
38843
39635
  if (hasMore) {
38844
39636
  void setSize(size + 1);
38845
39637
  }
38846
39638
  }, [hasMore, setSize, size]);
38847
- const paginationProps = useMemo76(() => {
39639
+ const paginationProps = useMemo77(() => {
38848
39640
  return {
38849
39641
  pageSize: 10,
38850
39642
  hasMore,
38851
39643
  fetchMore
38852
39644
  };
38853
39645
  }, [fetchMore, hasMore]);
38854
- const options = useMemo76(() => Object.values(InvoiceStatusOptionConfig), []);
38855
- const SelectedValue = useMemo76(() => {
39646
+ const options2 = useMemo77(() => Object.values(InvoiceStatusOptionConfig), []);
39647
+ const SelectedValue = useMemo77(() => {
38856
39648
  const label = selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label;
38857
39649
  return label ? `Status: ${label}` : "Status";
38858
39650
  }, [selectedInvoiceStatusOption == null ? void 0 : selectedInvoiceStatusOption.label]);
38859
- const StatusFilter = useCallback57(
38860
- () => /* @__PURE__ */ jsx346(
39651
+ const StatusFilter = useCallback60(
39652
+ () => /* @__PURE__ */ jsx349(
38861
39653
  ComboBox,
38862
39654
  {
38863
39655
  className: "Layer__InvoicesTable__StatusFilter",
38864
- options,
39656
+ options: options2,
38865
39657
  onSelectedValueChange: (option) => setSelectedInvoiceStatusOption(option),
38866
39658
  selectedValue: selectedInvoiceStatusOption,
38867
39659
  isSearchable: false,
@@ -38871,29 +39663,29 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38871
39663
  "aria-label": "Status Filter"
38872
39664
  }
38873
39665
  ),
38874
- [SelectedValue, options, selectedInvoiceStatusOption]
39666
+ [SelectedValue, options2, selectedInvoiceStatusOption]
38875
39667
  );
38876
- const CreateInvoiceButton = useCallback57(
38877
- () => /* @__PURE__ */ jsxs221(Button2, { onPress: onCreateInvoice, children: [
39668
+ const CreateInvoiceButton = useCallback60(
39669
+ () => /* @__PURE__ */ jsxs223(Button2, { onPress: onCreateInvoice, children: [
38878
39670
  "Create Invoice",
38879
- /* @__PURE__ */ jsx346(Plus3, { size: 16 })
39671
+ /* @__PURE__ */ jsx349(Plus3, { size: 16 })
38880
39672
  ] }),
38881
39673
  [onCreateInvoice]
38882
39674
  );
38883
- const InvoicesTableEmptyState = useCallback57(() => {
39675
+ const InvoicesTableEmptyState = useCallback60(() => {
38884
39676
  const isFiltered = selectedInvoiceStatusOption && selectedInvoiceStatusOption !== ALL_OPTION;
38885
- return /* @__PURE__ */ jsx346(
39677
+ return /* @__PURE__ */ jsx349(
38886
39678
  DataState,
38887
39679
  {
38888
39680
  status: "allDone" /* allDone */,
38889
39681
  title: isFiltered ? "No results found" : "No invoices yet",
38890
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.",
38891
- icon: isFiltered ? /* @__PURE__ */ jsx346(Search2, {}) : /* @__PURE__ */ jsx346(HandCoins, {}),
39683
+ icon: isFiltered ? /* @__PURE__ */ jsx349(Search2, {}) : /* @__PURE__ */ jsx349(HandCoins, {}),
38892
39684
  spacing: true
38893
39685
  }
38894
39686
  );
38895
39687
  }, [selectedInvoiceStatusOption]);
38896
- const InvoicesTableErrorState = useCallback57(() => /* @__PURE__ */ jsx346(
39688
+ const InvoicesTableErrorState = useCallback60(() => /* @__PURE__ */ jsx349(
38897
39689
  DataState,
38898
39690
  {
38899
39691
  status: "failed" /* failed */,
@@ -38905,9 +39697,9 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38905
39697
  spacing: true
38906
39698
  }
38907
39699
  ), [refetch]);
38908
- const columnConfig = useMemo76(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
38909
- return /* @__PURE__ */ jsxs221(Container, { name: "InvoicesTable", children: [
38910
- /* @__PURE__ */ jsx346(
39700
+ const columnConfig = useMemo77(() => getColumnConfig(onSelectInvoice), [onSelectInvoice]);
39701
+ return /* @__PURE__ */ jsxs223(Container, { name: "InvoicesTable", children: [
39702
+ /* @__PURE__ */ jsx349(
38911
39703
  DataTableHeader,
38912
39704
  {
38913
39705
  name: "Invoices",
@@ -38917,7 +39709,7 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38917
39709
  }
38918
39710
  }
38919
39711
  ),
38920
- /* @__PURE__ */ jsx346(
39712
+ /* @__PURE__ */ jsx349(
38921
39713
  PaginatedTable,
38922
39714
  {
38923
39715
  ariaLabel: "Invoices",
@@ -38937,38 +39729,38 @@ var InvoicesTable = ({ onCreateInvoice, onSelectInvoice }) => {
38937
39729
  };
38938
39730
 
38939
39731
  // src/components/Invoices/Invoices.tsx
38940
- import { jsx as jsx347 } from "react/jsx-runtime";
39732
+ import { jsx as jsx350 } from "react/jsx-runtime";
38941
39733
  var unstable_Invoices = ({
38942
39734
  showTitle = true,
38943
39735
  stringOverrides
38944
39736
  }) => {
38945
- const [invoiceFormMode, setInvoiceFormMode] = useState87(null);
38946
- const goBackToInvoicesTable = useCallback58(() => {
39737
+ const [invoiceFormMode, setInvoiceFormMode] = useState88(null);
39738
+ const goBackToInvoicesTable = useCallback61(() => {
38947
39739
  setInvoiceFormMode(null);
38948
39740
  }, []);
38949
- const onCreateInvoice = useCallback58(() => {
39741
+ const onCreateInvoice = useCallback61(() => {
38950
39742
  setInvoiceFormMode({ mode: "Create" /* Create */ });
38951
39743
  }, []);
38952
- const onSelectInvoice = useCallback58((invoice) => {
39744
+ const onSelectInvoice = useCallback61((invoice) => {
38953
39745
  setInvoiceFormMode({ mode: "Update" /* Update */, invoice });
38954
39746
  }, []);
38955
- return /* @__PURE__ */ jsx347(
39747
+ return /* @__PURE__ */ jsx350(
38956
39748
  View,
38957
39749
  {
38958
39750
  title: (stringOverrides == null ? void 0 : stringOverrides.title) || "Invoices",
38959
39751
  showHeader: showTitle,
38960
- children: invoiceFormMode !== null ? /* @__PURE__ */ jsx347(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ jsx347(InvoicesTable, { onCreateInvoice, onSelectInvoice })
39752
+ children: invoiceFormMode !== null ? /* @__PURE__ */ jsx350(InvoiceDetail, __spreadProps(__spreadValues({}, invoiceFormMode), { onGoBack: goBackToInvoicesTable })) : /* @__PURE__ */ jsx350(InvoicesTable, { onCreateInvoice, onSelectInvoice })
38961
39753
  }
38962
39754
  );
38963
39755
  };
38964
39756
 
38965
39757
  // src/providers/BankTransactionsProvider/BankTransactionsProvider.tsx
38966
- import { jsx as jsx348 } from "react/jsx-runtime";
39758
+ import { jsx as jsx351 } from "react/jsx-runtime";
38967
39759
  var BankTransactionsProvider = ({
38968
39760
  children
38969
39761
  }) => {
38970
39762
  const bankTransactionsContextData = useAugmentedBankTransactions();
38971
- return /* @__PURE__ */ jsx348(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
39763
+ return /* @__PURE__ */ jsx351(BankTransactionsContext.Provider, { value: bankTransactionsContextData, children });
38972
39764
  };
38973
39765
  export {
38974
39766
  AccountingOverview,