@layerfi/components 0.1.2 → 0.1.4

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.
package/dist/index.js CHANGED
@@ -290,7 +290,7 @@ var getBankTransactions = get(
290
290
  businessId,
291
291
  sortBy = "date",
292
292
  sortOrder = "DESC"
293
- }) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}`
293
+ }) => `/v1/businesses/${businessId}/bank-transactions?sort_by=${sortBy}&sort_order=${sortOrder}&limit=200`
294
294
  );
295
295
  var categorizeBankTransaction = put(
296
296
  ({ businessId, bankTransactionId }) => `/v1/businesses/${businessId}/bank-transactions/${bankTransactionId}/categorize`
@@ -598,7 +598,7 @@ var BalanceSheet = () => {
598
598
  };
599
599
 
600
600
  // src/components/BankTransactions/BankTransactions.tsx
601
- var import_react29 = __toESM(require("react"));
601
+ var import_react30 = __toESM(require("react"));
602
602
 
603
603
  // src/hooks/useBankTransactions/useBankTransactions.tsx
604
604
  var import_swr2 = __toESM(require("swr"));
@@ -607,6 +607,7 @@ var useBankTransactions = () => {
607
607
  const {
608
608
  data: responseData,
609
609
  isLoading,
610
+ isValidating,
610
611
  error: responseError,
611
612
  mutate
612
613
  } = (0, import_swr2.default)(
@@ -616,12 +617,12 @@ var useBankTransactions = () => {
616
617
  })
617
618
  );
618
619
  const {
619
- data = [],
620
+ data = void 0,
620
621
  meta: metadata = {},
621
622
  error = void 0
622
623
  } = responseData || {};
623
624
  const categorize = (id, newCategory) => {
624
- const foundBT = data.find((x) => x.business_id === businessId && x.id === id);
625
+ const foundBT = data?.find((x) => x.business_id === businessId && x.id === id);
625
626
  if (foundBT) {
626
627
  updateOneLocal({ ...foundBT, processing: true, error: void 0 });
627
628
  }
@@ -638,7 +639,7 @@ var useBankTransactions = () => {
638
639
  throw errors;
639
640
  }
640
641
  }).catch((err) => {
641
- const newBT = data.find(
642
+ const newBT = data?.find(
642
643
  (x) => x.business_id === businessId && x.id === id
643
644
  );
644
645
  if (newBT) {
@@ -651,15 +652,20 @@ var useBankTransactions = () => {
651
652
  });
652
653
  };
653
654
  const updateOneLocal = (newBankTransaction) => {
654
- const updatedData = data.map(
655
+ const updatedData = data?.map(
655
656
  (bt) => bt.id === newBankTransaction.id ? newBankTransaction : bt
656
657
  );
657
658
  mutate({ data: updatedData }, { revalidate: false });
658
659
  };
660
+ const refetch = () => {
661
+ mutate();
662
+ };
659
663
  return {
660
664
  data,
661
665
  metadata,
662
666
  isLoading,
667
+ isValidating,
668
+ refetch,
663
669
  error: responseError || error,
664
670
  categorize,
665
671
  updateOneLocal
@@ -689,6 +695,11 @@ var useElementSize = (callback) => {
689
695
  return ref;
690
696
  };
691
697
 
698
+ // src/types/categories.ts
699
+ function hasSuggestions(categorization) {
700
+ return categorization.suggestions !== void 0;
701
+ }
702
+
692
703
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
693
704
  var import_react24 = __toESM(require("react"));
694
705
 
@@ -704,6 +715,7 @@ var Button = ({
704
715
  iconOnly,
705
716
  ...props
706
717
  }) => {
718
+ const buttonRef = (0, import_react8.useRef)(null);
707
719
  let justify = "center";
708
720
  if (leftIcon && rightIcon) {
709
721
  justify = "space-between";
@@ -718,7 +730,23 @@ var Button = ({
718
730
  iconOnly ? "Layer__btn--icon-only" : "",
719
731
  className
720
732
  );
721
- return /* @__PURE__ */ import_react8.default.createElement("button", { ...props, className: baseClassName }, /* @__PURE__ */ import_react8.default.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--left" }, leftIcon), !iconOnly && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--right" }, rightIcon)));
733
+ const startAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
734
+ (el) => el.beginElement()
735
+ );
736
+ const stopAnimation = () => buttonRef.current && [...buttonRef.current.getElementsByClassName("animateOnHover")].forEach(
737
+ (el) => el.endElement()
738
+ );
739
+ return /* @__PURE__ */ import_react8.default.createElement(
740
+ "button",
741
+ {
742
+ ...props,
743
+ className: baseClassName,
744
+ onMouseEnter: startAnimation,
745
+ onMouseLeave: stopAnimation,
746
+ ref: buttonRef
747
+ },
748
+ /* @__PURE__ */ import_react8.default.createElement("span", { className: `Layer__btn-content Layer__justify--${justify}` }, leftIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--left" }, leftIcon), !iconOnly && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-text" }, children), rightIcon && /* @__PURE__ */ import_react8.default.createElement("span", { className: "Layer__btn-icon Layer__btn-icon--right" }, rightIcon))
749
+ );
722
750
  };
723
751
 
724
752
  // src/components/Button/SubmitButton.tsx
@@ -1099,7 +1127,7 @@ var CategoryMenu = ({
1099
1127
  className
1100
1128
  }) => {
1101
1129
  const { categories } = useLayerContext();
1102
- const suggestedOptions = bankTransaction?.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? [
1130
+ const suggestedOptions = hasSuggestions(bankTransaction.categorization_flow) ? [
1103
1131
  {
1104
1132
  label: "Suggested",
1105
1133
  options: bankTransaction.categorization_flow.suggestions
@@ -1117,6 +1145,7 @@ var CategoryMenu = ({
1117
1145
  options: [category]
1118
1146
  };
1119
1147
  }).filter((x) => x);
1148
+ console.log("categoryOptions", categoryOptions);
1120
1149
  const options = [...suggestedOptions, ...categoryOptions];
1121
1150
  return /* @__PURE__ */ import_react14.default.createElement(
1122
1151
  import_react_select.default,
@@ -1258,66 +1287,135 @@ var RefreshCcw = ({ size = 18, ...props }) => /* @__PURE__ */ React19.createElem
1258
1287
  );
1259
1288
  var RefreshCcw_default = RefreshCcw;
1260
1289
 
1261
- // src/icons/ScissorsFullOpen.tsx
1290
+ // src/icons/Scissors.tsx
1262
1291
  var React20 = __toESM(require("react"));
1263
- var ScissorsFullOpen = ({ size = 12, ...props }) => /* @__PURE__ */ React20.createElement(
1292
+ var Scissors = ({ size = 11, ...props }) => /* @__PURE__ */ React20.createElement(
1264
1293
  "svg",
1265
1294
  {
1266
- viewBox: "0 0 12 12",
1295
+ viewBox: "0 0 11 11",
1267
1296
  fill: "none",
1268
1297
  xmlns: "http://www.w3.org/2000/svg",
1269
1298
  ...props,
1270
1299
  width: size,
1271
1300
  height: size
1272
1301
  },
1273
- /* @__PURE__ */ React20.createElement("g", { id: "scissors" }, /* @__PURE__ */ React20.createElement(
1302
+ /* @__PURE__ */ React20.createElement(
1274
1303
  "path",
1275
1304
  {
1276
- id: "Vector",
1277
- d: "M3 4.5C3.82843 4.5 4.5 3.82843 4.5 3C4.5 2.17157 3.82843 1.5 3 1.5C2.17157 1.5 1.5 2.17157 1.5 3C1.5 3.82843 2.17157 4.5 3 4.5Z",
1305
+ d: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
1278
1306
  stroke: "currentColor",
1279
1307
  strokeLinecap: "round",
1280
1308
  strokeLinejoin: "round"
1281
- }
1282
- ), /* @__PURE__ */ React20.createElement(
1309
+ },
1310
+ /* @__PURE__ */ React20.createElement(
1311
+ "animate",
1312
+ {
1313
+ attributeName: "d",
1314
+ className: "animateOnHover",
1315
+ values: "M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z;M2.50519 5.21436C3.20276 4.91424 3.52494 4.10544 3.22481 3.40788C2.92468 2.71031 2.11589 2.38813 1.41833 2.68826C0.720762 2.98839 0.398577 3.79718 0.698706 4.49474C0.998836 5.19231 1.80763 5.51449 2.50519 5.21436Z;M2.75 4.125C3.50939 4.125 4.125 3.50939 4.125 2.75C4.125 1.99061 3.50939 1.375 2.75 1.375C1.99061 1.375 1.375 1.99061 1.375 2.75C1.375 3.50939 1.99061 4.125 2.75 4.125Z",
1316
+ begin: "indefinite",
1317
+ dur: "400ms",
1318
+ repeatCount: "1",
1319
+ fill: "freeze",
1320
+ calcMode: "linear",
1321
+ keyTimes: "0;0.5;1"
1322
+ }
1323
+ )
1324
+ ),
1325
+ /* @__PURE__ */ React20.createElement(
1283
1326
  "path",
1284
1327
  {
1285
- id: "Vector_2",
1286
- d: "M3 10.5C3.82843 10.5 4.5 9.82843 4.5 9C4.5 8.17157 3.82843 7.5 3 7.5C2.17157 7.5 1.5 8.17157 1.5 9C1.5 9.82843 2.17157 10.5 3 10.5Z",
1328
+ d: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
1287
1329
  stroke: "currentColor",
1288
1330
  strokeLinecap: "round",
1289
1331
  strokeLinejoin: "round"
1290
- }
1291
- ), /* @__PURE__ */ React20.createElement(
1332
+ },
1333
+ /* @__PURE__ */ React20.createElement(
1334
+ "animate",
1335
+ {
1336
+ attributeName: "d",
1337
+ className: "animateOnHover",
1338
+ values: "M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z;M1.43277 8.38576C2.13615 8.67201 2.9384 8.33386 3.22465 7.63049C3.5109 6.92711 3.17275 6.12486 2.46937 5.83861C1.766 5.55236 0.96375 5.89051 0.6775 6.59389C0.391251 7.29726 0.729398 8.09951 1.43277 8.38576Z;M2.75 9.625C3.50939 9.625 4.125 9.00939 4.125 8.25C4.125 7.49061 3.50939 6.875 2.75 6.875C1.99061 6.875 1.375 7.49061 1.375 8.25C1.375 9.00939 1.99061 9.625 2.75 9.625Z",
1339
+ begin: "indefinite",
1340
+ dur: "400ms",
1341
+ repeatCount: "1",
1342
+ fill: "freeze",
1343
+ calcMode: "linear",
1344
+ keyTimes: "0;0.5;1"
1345
+ }
1346
+ )
1347
+ ),
1348
+ /* @__PURE__ */ React20.createElement(
1292
1349
  "path",
1293
1350
  {
1294
- id: "Vector_3",
1295
- d: "M10 2L4.06 7.94",
1351
+ d: "M9.16668 1.83325L3.72168 7.27825",
1296
1352
  stroke: "currentColor",
1297
1353
  strokeLinecap: "round",
1298
1354
  strokeLinejoin: "round"
1299
- }
1300
- ), /* @__PURE__ */ React20.createElement(
1355
+ },
1356
+ /* @__PURE__ */ React20.createElement(
1357
+ "animate",
1358
+ {
1359
+ attributeName: "d",
1360
+ className: "animateOnHover",
1361
+ values: "M9.16668 1.83325L3.72168 7.27825;M10.3129 3.58763L3.21706 6.57851;M9.16668 1.83325L3.72168 7.27825",
1362
+ begin: "indefinite",
1363
+ dur: "400ms",
1364
+ repeatCount: "1",
1365
+ fill: "freeze",
1366
+ calcMode: "linear",
1367
+ keyTimes: "0;0.5;1"
1368
+ }
1369
+ )
1370
+ ),
1371
+ /* @__PURE__ */ React20.createElement(
1301
1372
  "path",
1302
1373
  {
1303
- id: "Vector_4",
1304
- d: "M7.235 7.23999L10 9.99999",
1374
+ d: "M6.63232 6.63672L9.16691 9.16672",
1305
1375
  stroke: "currentColor",
1306
1376
  strokeLinecap: "round",
1307
1377
  strokeLinejoin: "round"
1308
- }
1309
- ), /* @__PURE__ */ React20.createElement(
1378
+ },
1379
+ /* @__PURE__ */ React20.createElement(
1380
+ "animate",
1381
+ {
1382
+ attributeName: "d",
1383
+ className: "animateOnHover",
1384
+ values: "M6.63232 6.63672L9.16691 9.16672;M7.06396 5.9873L10.3921 7.3096;M6.63232 6.63672L9.16691 9.16672",
1385
+ begin: "indefinite",
1386
+ dur: "400ms",
1387
+ repeatCount: "1",
1388
+ fill: "freeze",
1389
+ calcMode: "linear",
1390
+ keyTimes: "0;0.5;1"
1391
+ }
1392
+ )
1393
+ ),
1394
+ /* @__PURE__ */ React20.createElement(
1310
1395
  "path",
1311
1396
  {
1312
- id: "Vector_5",
1313
- d: "M4.06 4.06006L6 6.00006",
1397
+ d: "M3.72168 3.72168L5.50001 5.50001",
1314
1398
  stroke: "currentColor",
1315
1399
  strokeLinecap: "round",
1316
1400
  strokeLinejoin: "round"
1317
- }
1318
- ))
1401
+ },
1402
+ /* @__PURE__ */ React20.createElement(
1403
+ "animate",
1404
+ {
1405
+ attributeName: "d",
1406
+ className: "animateOnHover",
1407
+ values: "M3.72168 3.72168L5.50001 5.50001;M3.23828 4.45996L5.57467 5.39067;M3.72168 3.72168L5.50001 5.50001",
1408
+ begin: "indefinite",
1409
+ dur: "400ms",
1410
+ repeatCount: "1",
1411
+ fill: "freeze",
1412
+ calcMode: "linear",
1413
+ keyTimes: "0;0.5;1"
1414
+ }
1415
+ )
1416
+ )
1319
1417
  );
1320
- var ScissorsFullOpen_default = ScissorsFullOpen;
1418
+ var Scissors_default = Scissors;
1321
1419
 
1322
1420
  // src/components/Input/Input.tsx
1323
1421
  var import_react15 = __toESM(require("react"));
@@ -1653,11 +1751,11 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1653
1751
  bankTransaction,
1654
1752
  isOpen = false,
1655
1753
  asListItem = false,
1656
- showSubmitButton = false
1754
+ submitBtnText = "Save"
1657
1755
  }, ref) => {
1658
1756
  const { categorize: categorizeBankTransaction2 } = useBankTransactions();
1659
1757
  const [purpose, setPurpose] = (0, import_react22.useState)("categorize" /* categorize */);
1660
- const defaultCategory = bankTransaction.category || bankTransaction.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ && bankTransaction.categorization_flow?.suggestions?.[0];
1758
+ const defaultCategory = bankTransaction.category || hasSuggestions(bankTransaction.categorization_flow) && bankTransaction.categorization_flow?.suggestions?.[0];
1661
1759
  const [rowState, updateRowState] = (0, import_react22.useState)({
1662
1760
  splits: [
1663
1761
  {
@@ -1792,7 +1890,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1792
1890
  Button,
1793
1891
  {
1794
1892
  onClick: addSplit,
1795
- leftIcon: /* @__PURE__ */ import_react22.default.createElement(ScissorsFullOpen_default, { size: 14 }),
1893
+ leftIcon: /* @__PURE__ */ import_react22.default.createElement(Scissors_default, { size: 14 }),
1796
1894
  variant: "secondary" /* secondary */
1797
1895
  },
1798
1896
  "Split"
@@ -1815,7 +1913,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1815
1913
  /* @__PURE__ */ import_react22.default.createElement(Textarea, { name: "description", placeholder: "Enter description" })
1816
1914
  ),
1817
1915
  /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ import_react22.default.createElement(FileInput, { text: "Upload receipt" })),
1818
- asListItem || showSubmitButton ? /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react22.default.createElement(
1916
+ asListItem ? /* @__PURE__ */ import_react22.default.createElement("div", { className: `${className}__submit-btn` }, /* @__PURE__ */ import_react22.default.createElement(
1819
1917
  SubmitButton,
1820
1918
  {
1821
1919
  onClick: () => {
@@ -1828,7 +1926,7 @@ var ExpandedBankTransactionRow = (0, import_react22.forwardRef)(
1828
1926
  error: bankTransaction.error,
1829
1927
  active: true
1830
1928
  },
1831
- "Approve"
1929
+ submitBtnText
1832
1930
  )) : null
1833
1931
  ))
1834
1932
  );
@@ -1854,7 +1952,7 @@ var BankTransactionListItem = ({
1854
1952
  const [removed, setRemoved] = (0, import_react24.useState)(false);
1855
1953
  const { categorize: categorizeBankTransaction2 } = useBankTransactions();
1856
1954
  const [selectedCategory, setSelectedCategory] = (0, import_react24.useState)(
1857
- bankTransaction.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions[0] : void 0
1955
+ hasSuggestions(bankTransaction.categorization_flow) ? bankTransaction.categorization_flow.suggestions[0] : void 0
1858
1956
  );
1859
1957
  const save = () => {
1860
1958
  if (isOpen && expandedRowRef?.current) {
@@ -1906,7 +2004,8 @@ var BankTransactionListItem = ({
1906
2004
  bankTransaction,
1907
2005
  close: () => toggleOpen(bankTransaction.id),
1908
2006
  isOpen,
1909
- asListItem: true
2007
+ asListItem: true,
2008
+ submitBtnText: editable ? "Approve" : "Save"
1910
2009
  }
1911
2010
  )), /* @__PURE__ */ import_react24.default.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ import_react24.default.createElement(
1912
2011
  CategoryMenu,
@@ -1949,7 +2048,7 @@ var BankTransactionRow = ({
1949
2048
  const [removed, setRemoved] = (0, import_react25.useState)(false);
1950
2049
  const { categorize: categorizeBankTransaction2 } = useBankTransactions();
1951
2050
  const [selectedCategory, setSelectedCategory] = (0, import_react25.useState)(
1952
- bankTransaction.categorization_flow?.type === "ASK_FROM_SUGGESTIONS" /* ASK_FROM_SUGGESTIONS */ ? bankTransaction.categorization_flow.suggestions[0] : void 0
2051
+ hasSuggestions(bankTransaction.categorization_flow) ? bankTransaction.categorization_flow.suggestions[0] : void 0
1953
2052
  );
1954
2053
  const save = () => {
1955
2054
  if (isOpen && expandedRowRef?.current) {
@@ -1996,7 +2095,7 @@ var BankTransactionRow = ({
1996
2095
  contentClassName: "Layer__bank-transactions__tx-tooltip"
1997
2096
  }
1998
2097
  },
1999
- bankTransaction.counterparty_name
2098
+ bankTransaction.counterparty_name ?? bankTransaction.description
2000
2099
  ))),
2001
2100
  /* @__PURE__ */ import_react25.default.createElement("td", { className: "Layer__table-cell Layer__bank-transactions__account-col" }, /* @__PURE__ */ import_react25.default.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ import_react25.default.createElement(
2002
2101
  Text,
@@ -2039,8 +2138,8 @@ var BankTransactionRow = ({
2039
2138
  disabled: bankTransaction.processing
2040
2139
  }
2041
2140
  ) : null,
2042
- !editable ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
2043
- editable && /* @__PURE__ */ import_react25.default.createElement(
2141
+ !editable && !isOpen ? /* @__PURE__ */ import_react25.default.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction?.category?.display_name) : null,
2142
+ editable || isOpen ? /* @__PURE__ */ import_react25.default.createElement(
2044
2143
  SubmitButton,
2045
2144
  {
2046
2145
  onClick: () => {
@@ -2053,8 +2152,8 @@ var BankTransactionRow = ({
2053
2152
  error: bankTransaction.error,
2054
2153
  active: isOpen
2055
2154
  },
2056
- "Approve"
2057
- ),
2155
+ editable ? "Approve" : "Save"
2156
+ ) : null,
2058
2157
  /* @__PURE__ */ import_react25.default.createElement(
2059
2158
  "div",
2060
2159
  {
@@ -2076,8 +2175,7 @@ var BankTransactionRow = ({
2076
2175
  ref: expandedRowRef,
2077
2176
  bankTransaction,
2078
2177
  close: () => toggleOpen(bankTransaction.id),
2079
- isOpen,
2080
- showSubmitButton: !editable
2178
+ isOpen
2081
2179
  }
2082
2180
  ))));
2083
2181
  };
@@ -2104,7 +2202,6 @@ var parseColorFromTheme = (colorName, color) => {
2104
2202
  }
2105
2203
  try {
2106
2204
  if ("h" in color && "s" in color && "l" in color) {
2107
- console.log("its hsl", color);
2108
2205
  return {
2109
2206
  [`--color-${colorName}-h`]: color.h,
2110
2207
  [`--color-${colorName}-s`]: color.s,
@@ -2113,7 +2210,6 @@ var parseColorFromTheme = (colorName, color) => {
2113
2210
  }
2114
2211
  if ("r" in color && "g" in color && "b" in color) {
2115
2212
  const { h, s, l } = rgbToHsl(color);
2116
- console.log("its rgb", h, s, l);
2117
2213
  return {
2118
2214
  [`--color-${colorName}-h`]: h,
2119
2215
  [`--color-${colorName}-s`]: `${s}%`,
@@ -2121,7 +2217,6 @@ var parseColorFromTheme = (colorName, color) => {
2121
2217
  };
2122
2218
  }
2123
2219
  if ("hex" in color) {
2124
- console.log("its hex");
2125
2220
  const rgb = hexToRgb(color.hex);
2126
2221
  if (!rgb) {
2127
2222
  return {};
@@ -2131,7 +2226,6 @@ var parseColorFromTheme = (colorName, color) => {
2131
2226
  g: rgb.g.toString(),
2132
2227
  b: rgb.b.toString()
2133
2228
  });
2134
- console.log("its hex", h, s, l);
2135
2229
  return {
2136
2230
  [`--color-${colorName}-h`]: h,
2137
2231
  [`--color-${colorName}-s`]: `${s}%`,
@@ -2175,34 +2269,120 @@ var hexToRgb = (hex) => {
2175
2269
  };
2176
2270
 
2177
2271
  // src/components/Container/Container.tsx
2178
- var Container = ({ name, className, children }) => {
2179
- const baseClassName = `Layer__${name} ${className ?? ""}`;
2272
+ var import_classnames11 = __toESM(require("classnames"));
2273
+ var Container = ({
2274
+ name,
2275
+ className,
2276
+ children,
2277
+ asWidget
2278
+ }) => {
2279
+ const baseClassName = (0, import_classnames11.default)(
2280
+ "Layer__component Layer__component-container",
2281
+ `Layer__${name}`,
2282
+ asWidget ? "Layer__component--as-widget" : "",
2283
+ className
2284
+ );
2180
2285
  const { theme } = useLayerContext();
2181
2286
  const styles = parseStylesFromThemeConfig(theme);
2182
- return /* @__PURE__ */ import_react26.default.createElement(
2183
- "div",
2184
- {
2185
- className: `Layer__component Layer__component-container ${baseClassName}`,
2186
- style: { ...styles }
2187
- },
2188
- children
2189
- );
2287
+ return /* @__PURE__ */ import_react26.default.createElement("div", { className: baseClassName, style: { ...styles } }, children);
2190
2288
  };
2191
2289
 
2192
2290
  // src/components/Container/Header.tsx
2193
2291
  var import_react27 = __toESM(require("react"));
2194
- var import_classnames11 = __toESM(require("classnames"));
2292
+ var import_classnames12 = __toESM(require("classnames"));
2195
2293
  var Header = (0, import_react27.forwardRef)(
2196
2294
  ({ className, children, style }, ref) => {
2197
- const baseClassName = (0, import_classnames11.default)("Layer__component-header", className);
2295
+ const baseClassName = (0, import_classnames12.default)("Layer__component-header", className);
2198
2296
  return /* @__PURE__ */ import_react27.default.createElement("header", { ref, className: baseClassName, style }, children);
2199
2297
  }
2200
2298
  );
2201
2299
 
2202
- // src/components/Loader/Loader.tsx
2300
+ // src/components/DataState/DataState.tsx
2203
2301
  var import_react28 = __toESM(require("react"));
2302
+
2303
+ // src/icons/AlertOctagon.tsx
2304
+ var React35 = __toESM(require("react"));
2305
+ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React35.createElement(
2306
+ "svg",
2307
+ {
2308
+ viewBox: "0 0 18 18",
2309
+ fill: "none",
2310
+ xmlns: "http://www.w3.org/2000/svg",
2311
+ ...props,
2312
+ width: size,
2313
+ height: size
2314
+ },
2315
+ /* @__PURE__ */ React35.createElement(
2316
+ "path",
2317
+ {
2318
+ d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
2319
+ stroke: "currentColor",
2320
+ strokeLinecap: "round",
2321
+ strokeLinejoin: "round"
2322
+ }
2323
+ ),
2324
+ /* @__PURE__ */ React35.createElement(
2325
+ "path",
2326
+ {
2327
+ d: "M9 6V9",
2328
+ stroke: "currentColor",
2329
+ strokeLinecap: "round",
2330
+ strokeLinejoin: "round"
2331
+ }
2332
+ ),
2333
+ /* @__PURE__ */ React35.createElement(
2334
+ "path",
2335
+ {
2336
+ d: "M9 12H9.0075",
2337
+ stroke: "currentColor",
2338
+ strokeLinecap: "round",
2339
+ strokeLinejoin: "round"
2340
+ }
2341
+ )
2342
+ );
2343
+ var AlertOctagon_default = AlertOctagon;
2344
+
2345
+ // src/components/DataState/DataState.tsx
2346
+ var getIcon = (status) => {
2347
+ switch (status) {
2348
+ case "failed" /* failed */:
2349
+ return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ import_react28.default.createElement(AlertOctagon_default, { size: 12 }));
2350
+ default:
2351
+ return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ import_react28.default.createElement(CheckCircle_default, { size: 12 }));
2352
+ }
2353
+ };
2354
+ var DataState = ({
2355
+ status,
2356
+ title,
2357
+ description,
2358
+ onRefresh,
2359
+ isLoading
2360
+ }) => {
2361
+ return /* @__PURE__ */ import_react28.default.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ import_react28.default.createElement(
2362
+ Text,
2363
+ {
2364
+ as: "span",
2365
+ size: "lg" /* lg */,
2366
+ weight: "bold" /* bold */,
2367
+ className: "Layer__data-state__title"
2368
+ },
2369
+ title
2370
+ ), /* @__PURE__ */ import_react28.default.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ import_react28.default.createElement(
2371
+ Button,
2372
+ {
2373
+ variant: "secondary" /* secondary */,
2374
+ rightIcon: isLoading ? /* @__PURE__ */ import_react28.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ import_react28.default.createElement(RefreshCcw_default, { size: 12 }),
2375
+ onClick: onRefresh,
2376
+ disabled: isLoading
2377
+ },
2378
+ "Refresh"
2379
+ )));
2380
+ };
2381
+
2382
+ // src/components/Loader/Loader.tsx
2383
+ var import_react29 = __toESM(require("react"));
2204
2384
  var Loader2 = ({ children }) => {
2205
- return /* @__PURE__ */ import_react28.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react28.default.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }), children ?? "Loading...");
2385
+ return /* @__PURE__ */ import_react29.default.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ import_react29.default.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
2206
2386
  };
2207
2387
 
2208
2388
  // src/components/BankTransactions/BankTransactions.tsx
@@ -2224,16 +2404,18 @@ var filterVisibility = (display) => (bankTransaction) => {
2224
2404
  const inReview = ReviewCategories.includes(bankTransaction.categorization_status) || bankTransaction.recently_categorized;
2225
2405
  return display === "review" /* review */ && inReview || display === "categorized" /* categorized */ && categorized;
2226
2406
  };
2227
- var BankTransactions = () => {
2228
- const [display, setDisplay] = (0, import_react29.useState)("review" /* review */);
2229
- const { data, isLoading } = useBankTransactions();
2230
- const bankTransactions = data.filter(filterVisibility(display));
2407
+ var BankTransactions = ({
2408
+ asWidget = false
2409
+ }) => {
2410
+ const [display, setDisplay] = (0, import_react30.useState)("review" /* review */);
2411
+ const { data, isLoading, error, isValidating, refetch } = useBankTransactions();
2412
+ const bankTransactions = data?.filter(filterVisibility(display));
2231
2413
  const onCategorizationDisplayChange = (event) => setDisplay(
2232
2414
  event.target.value === "categorized" /* categorized */ ? "categorized" /* categorized */ : "review" /* review */
2233
2415
  );
2234
- const [openRows, setOpenRows] = (0, import_react29.useState)({});
2416
+ const [openRows, setOpenRows] = (0, import_react30.useState)({});
2235
2417
  const toggleOpen = (id) => setOpenRows({ ...openRows, [id]: !openRows[id] });
2236
- const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react29.useState)(0);
2418
+ const [shiftStickyHeader, setShiftStickyHeader] = (0, import_react30.useState)(0);
2237
2419
  const headerRef = useElementSize((_el, _en, size) => {
2238
2420
  if (size?.height && size?.height >= 90) {
2239
2421
  const newShift = -Math.floor(size.height / 2) + 6;
@@ -2245,15 +2427,15 @@ var BankTransactions = () => {
2245
2427
  }
2246
2428
  });
2247
2429
  const editable = display === "review" /* review */;
2248
- return /* @__PURE__ */ import_react29.default.createElement(Container, { name: COMPONENT_NAME }, /* @__PURE__ */ import_react29.default.createElement(
2430
+ return /* @__PURE__ */ import_react30.default.createElement(Container, { name: COMPONENT_NAME, asWidget }, /* @__PURE__ */ import_react30.default.createElement(
2249
2431
  Header,
2250
2432
  {
2251
2433
  ref: headerRef,
2252
2434
  className: "Layer__bank-transactions__header",
2253
2435
  style: { top: shiftStickyHeader }
2254
2436
  },
2255
- /* @__PURE__ */ import_react29.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
2256
- /* @__PURE__ */ import_react29.default.createElement(
2437
+ /* @__PURE__ */ import_react30.default.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
2438
+ /* @__PURE__ */ import_react30.default.createElement(
2257
2439
  Toggle,
2258
2440
  {
2259
2441
  name: "bank-transaction-display",
@@ -2265,14 +2447,14 @@ var BankTransactions = () => {
2265
2447
  onChange: onCategorizationDisplayChange
2266
2448
  }
2267
2449
  )
2268
- ), /* @__PURE__ */ import_react29.default.createElement(
2450
+ ), /* @__PURE__ */ import_react30.default.createElement(
2269
2451
  "table",
2270
2452
  {
2271
2453
  width: "100%",
2272
2454
  className: "Layer__table Layer__bank-transactions__table"
2273
2455
  },
2274
- /* @__PURE__ */ import_react29.default.createElement("thead", null, /* @__PURE__ */ import_react29.default.createElement("tr", null, /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react29.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
2275
- /* @__PURE__ */ import_react29.default.createElement("tbody", null, !isLoading && bankTransactions.map((bankTransaction) => /* @__PURE__ */ import_react29.default.createElement(
2456
+ /* @__PURE__ */ import_react30.default.createElement("thead", null, /* @__PURE__ */ import_react30.default.createElement("tr", null, /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ import_react30.default.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
2457
+ /* @__PURE__ */ import_react30.default.createElement("tbody", null, !isLoading && bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
2276
2458
  BankTransactionRow,
2277
2459
  {
2278
2460
  key: bankTransaction.id,
@@ -2283,7 +2465,7 @@ var BankTransactions = () => {
2283
2465
  editable
2284
2466
  }
2285
2467
  )))
2286
- ), isLoading || !bankTransactions || bankTransactions?.length === 0 ? /* @__PURE__ */ import_react29.default.createElement(Loader2, null) : null, !isLoading && /* @__PURE__ */ import_react29.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions.map((bankTransaction) => /* @__PURE__ */ import_react29.default.createElement(
2468
+ ), isLoading && !bankTransactions ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ import_react30.default.createElement(Loader2, null)) : null, !isLoading && /* @__PURE__ */ import_react30.default.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map((bankTransaction) => /* @__PURE__ */ import_react30.default.createElement(
2287
2469
  BankTransactionListItem,
2288
2470
  {
2289
2471
  key: bankTransaction.id,
@@ -2293,11 +2475,29 @@ var BankTransactions = () => {
2293
2475
  toggleOpen,
2294
2476
  editable
2295
2477
  }
2296
- ))));
2478
+ ))), !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
2479
+ DataState,
2480
+ {
2481
+ status: "allDone" /* allDone */,
2482
+ title: "You are up to date with transactions!",
2483
+ description: "All uncategorized transaction will be displayed here",
2484
+ onRefresh: () => refetch(),
2485
+ isLoading: isValidating
2486
+ }
2487
+ )) : null, !isLoading && error ? /* @__PURE__ */ import_react30.default.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ import_react30.default.createElement(
2488
+ DataState,
2489
+ {
2490
+ status: "failed" /* failed */,
2491
+ title: "Something went wrong",
2492
+ description: "We couldn\u2019t load your data.",
2493
+ onRefresh: () => refetch(),
2494
+ isLoading: isValidating
2495
+ }
2496
+ )) : null);
2297
2497
  };
2298
2498
 
2299
2499
  // src/components/Hello/Hello.tsx
2300
- var import_react30 = __toESM(require("react"));
2500
+ var import_react31 = __toESM(require("react"));
2301
2501
  var import_swr3 = __toESM(require("swr"));
2302
2502
  var fetcher = (url) => fetch(url).then((res) => res.json());
2303
2503
  var Hello = ({ user }) => {
@@ -2306,14 +2506,14 @@ var Hello = ({ user }) => {
2306
2506
  fetcher
2307
2507
  );
2308
2508
  const name = (isLoading ? "..." : data?.name) || "User";
2309
- return /* @__PURE__ */ import_react30.default.createElement(import_react30.default.Fragment, null, /* @__PURE__ */ import_react30.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
2509
+ return /* @__PURE__ */ import_react31.default.createElement(import_react31.default.Fragment, null, /* @__PURE__ */ import_react31.default.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
2310
2510
  };
2311
2511
 
2312
2512
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
2313
- var import_react38 = __toESM(require("react"));
2513
+ var import_react39 = __toESM(require("react"));
2314
2514
 
2315
2515
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
2316
- var import_react31 = require("react");
2516
+ var import_react32 = require("react");
2317
2517
  var import_date_fns6 = require("date-fns");
2318
2518
  var import_swr4 = __toESM(require("swr"));
2319
2519
  var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate } = {
@@ -2321,10 +2521,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
2321
2521
  endDate: (0, import_date_fns6.endOfMonth)(/* @__PURE__ */ new Date())
2322
2522
  }) => {
2323
2523
  const { auth, businessId, apiUrl } = useLayerContext();
2324
- const [startDate, setStartDate] = (0, import_react31.useState)(
2524
+ const [startDate, setStartDate] = (0, import_react32.useState)(
2325
2525
  initialStartDate || (0, import_date_fns6.startOfMonth)(Date.now())
2326
2526
  );
2327
- const [endDate, setEndDate] = (0, import_react31.useState)(
2527
+ const [endDate, setEndDate] = (0, import_react32.useState)(
2328
2528
  initialEndDate || (0, import_date_fns6.endOfMonth)(Date.now())
2329
2529
  );
2330
2530
  const {
@@ -2359,10 +2559,10 @@ var useProfitAndLoss = ({ startDate: initialStartDate, endDate: initialEndDate }
2359
2559
  };
2360
2560
 
2361
2561
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
2362
- var import_react33 = __toESM(require("react"));
2562
+ var import_react34 = __toESM(require("react"));
2363
2563
 
2364
2564
  // src/components/ProfitAndLossChart/Indicator.tsx
2365
- var import_react32 = __toESM(require("react"));
2565
+ var import_react33 = __toESM(require("react"));
2366
2566
  var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
2367
2567
  var Indicator = ({
2368
2568
  viewBox = {},
@@ -2382,11 +2582,11 @@ var Indicator = ({
2382
2582
  const boxWidth = width * 2 + 4;
2383
2583
  const multiplier = 1.5;
2384
2584
  const xOffset = (boxWidth * multiplier - boxWidth) / 2;
2385
- (0, import_react32.useEffect)(() => {
2585
+ (0, import_react33.useEffect)(() => {
2386
2586
  setAnimateFrom(animateTo);
2387
2587
  }, [animateTo]);
2388
2588
  const actualX = animateFrom === -1 ? animateTo : animateFrom;
2389
- return /* @__PURE__ */ import_react32.default.createElement(
2589
+ return /* @__PURE__ */ import_react33.default.createElement(
2390
2590
  "rect",
2391
2591
  {
2392
2592
  className: "Layer__profit-and-loss-chart__selection-indicator",
@@ -2406,7 +2606,7 @@ var import_recharts = require("recharts");
2406
2606
  var barGap = 4;
2407
2607
  var barSize = 20;
2408
2608
  var ProfitAndLossChart = () => {
2409
- const { changeDateRange, dateRange } = (0, import_react33.useContext)(ProfitAndLoss.Context);
2609
+ const { changeDateRange, dateRange } = (0, import_react34.useContext)(ProfitAndLoss.Context);
2410
2610
  const thisMonth = (0, import_date_fns7.startOfMonth)(Date.now());
2411
2611
  const startSelectionMonth = dateRange.startDate.getMonth();
2412
2612
  const endSelectionMonth = dateRange.endDate.getMonth();
@@ -2500,7 +2700,7 @@ var ProfitAndLossChart = () => {
2500
2700
  });
2501
2701
  }
2502
2702
  };
2503
- const data = (0, import_react33.useMemo)(
2703
+ const data = (0, import_react34.useMemo)(
2504
2704
  () => monthData.map(summarizePnL),
2505
2705
  [
2506
2706
  startSelectionMonth,
@@ -2508,8 +2708,8 @@ var ProfitAndLossChart = () => {
2508
2708
  ...monthData.map((m) => m?.net_profit)
2509
2709
  ]
2510
2710
  );
2511
- const [animateFrom, setAnimateFrom] = (0, import_react33.useState)(-1);
2512
- return /* @__PURE__ */ import_react33.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: 250 }, /* @__PURE__ */ import_react33.default.createElement(
2711
+ const [animateFrom, setAnimateFrom] = (0, import_react34.useState)(-1);
2712
+ return /* @__PURE__ */ import_react34.default.createElement(import_recharts.ResponsiveContainer, { width: "100%", height: 250 }, /* @__PURE__ */ import_react34.default.createElement(
2513
2713
  import_recharts.BarChart,
2514
2714
  {
2515
2715
  margin: { left: 24, right: 24, bottom: 24 },
@@ -2518,8 +2718,8 @@ var ProfitAndLossChart = () => {
2518
2718
  barGap,
2519
2719
  className: "Layer__profit-and-loss-chart"
2520
2720
  },
2521
- /* @__PURE__ */ import_react33.default.createElement(import_recharts.CartesianGrid, { vertical: false }),
2522
- /* @__PURE__ */ import_react33.default.createElement(
2721
+ /* @__PURE__ */ import_react34.default.createElement(import_recharts.CartesianGrid, { vertical: false }),
2722
+ /* @__PURE__ */ import_react34.default.createElement(
2523
2723
  import_recharts.Legend,
2524
2724
  {
2525
2725
  verticalAlign: "top",
@@ -2530,8 +2730,8 @@ var ProfitAndLossChart = () => {
2530
2730
  ]
2531
2731
  }
2532
2732
  ),
2533
- /* @__PURE__ */ import_react33.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
2534
- /* @__PURE__ */ import_react33.default.createElement(
2733
+ /* @__PURE__ */ import_react34.default.createElement(import_recharts.XAxis, { dataKey: "name", tickLine: false }),
2734
+ /* @__PURE__ */ import_react34.default.createElement(
2535
2735
  import_recharts.Bar,
2536
2736
  {
2537
2737
  dataKey: "revenue",
@@ -2540,10 +2740,10 @@ var ProfitAndLossChart = () => {
2540
2740
  radius: [barSize / 4, barSize / 4, 0, 0],
2541
2741
  className: "Layer__profit-and-loss-chart__bar--income"
2542
2742
  },
2543
- /* @__PURE__ */ import_react33.default.createElement(
2743
+ /* @__PURE__ */ import_react34.default.createElement(
2544
2744
  import_recharts.LabelList,
2545
2745
  {
2546
- content: /* @__PURE__ */ import_react33.default.createElement(
2746
+ content: /* @__PURE__ */ import_react34.default.createElement(
2547
2747
  Indicator,
2548
2748
  {
2549
2749
  animateFrom,
@@ -2552,7 +2752,7 @@ var ProfitAndLossChart = () => {
2552
2752
  )
2553
2753
  }
2554
2754
  ),
2555
- data.map((entry) => /* @__PURE__ */ import_react33.default.createElement(
2755
+ data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
2556
2756
  import_recharts.Cell,
2557
2757
  {
2558
2758
  key: entry.name,
@@ -2560,7 +2760,7 @@ var ProfitAndLossChart = () => {
2560
2760
  }
2561
2761
  ))
2562
2762
  ),
2563
- /* @__PURE__ */ import_react33.default.createElement(
2763
+ /* @__PURE__ */ import_react34.default.createElement(
2564
2764
  import_recharts.Bar,
2565
2765
  {
2566
2766
  dataKey: "expenses",
@@ -2569,7 +2769,7 @@ var ProfitAndLossChart = () => {
2569
2769
  radius: [barSize / 4, barSize / 4, 0, 0],
2570
2770
  className: "Layer__profit-and-loss-chart__bar--expenses"
2571
2771
  },
2572
- data.map((entry) => /* @__PURE__ */ import_react33.default.createElement(
2772
+ data.map((entry) => /* @__PURE__ */ import_react34.default.createElement(
2573
2773
  import_recharts.Cell,
2574
2774
  {
2575
2775
  key: entry.name,
@@ -2581,15 +2781,15 @@ var ProfitAndLossChart = () => {
2581
2781
  };
2582
2782
 
2583
2783
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
2584
- var import_react34 = __toESM(require("react"));
2784
+ var import_react35 = __toESM(require("react"));
2585
2785
 
2586
2786
  // src/icons/ChevronLeft.tsx
2587
- var React40 = __toESM(require("react"));
2787
+ var React42 = __toESM(require("react"));
2588
2788
  var ChevronLeft = ({
2589
2789
  strokeColor,
2590
2790
  size,
2591
2791
  ...props
2592
- }) => /* @__PURE__ */ React40.createElement(
2792
+ }) => /* @__PURE__ */ React42.createElement(
2593
2793
  "svg",
2594
2794
  {
2595
2795
  xmlns: "http://www.w3.org/2000/svg",
@@ -2599,7 +2799,7 @@ var ChevronLeft = ({
2599
2799
  viewBox: "0 0 24 24",
2600
2800
  ...props
2601
2801
  },
2602
- /* @__PURE__ */ React40.createElement(
2802
+ /* @__PURE__ */ React42.createElement(
2603
2803
  "path",
2604
2804
  {
2605
2805
  stroke: strokeColor ?? "#000",
@@ -2613,8 +2813,8 @@ var ChevronLeft = ({
2613
2813
  var ChevronLeft_default = ChevronLeft;
2614
2814
 
2615
2815
  // src/icons/ChevronRight.tsx
2616
- var React41 = __toESM(require("react"));
2617
- var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React41.createElement(
2816
+ var React43 = __toESM(require("react"));
2817
+ var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React43.createElement(
2618
2818
  "svg",
2619
2819
  {
2620
2820
  xmlns: "http://www.w3.org/2000/svg",
@@ -2624,7 +2824,7 @@ var ChavronRight = ({ size, ...props }) => /* @__PURE__ */ React41.createElement
2624
2824
  viewBox: "0 0 24 24",
2625
2825
  ...props
2626
2826
  },
2627
- /* @__PURE__ */ React41.createElement(
2827
+ /* @__PURE__ */ React43.createElement(
2628
2828
  "path",
2629
2829
  {
2630
2830
  stroke: "#000",
@@ -2640,7 +2840,7 @@ var ChevronRight_default = ChavronRight;
2640
2840
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
2641
2841
  var import_date_fns8 = require("date-fns");
2642
2842
  var ProfitAndLossDatePicker = () => {
2643
- const { changeDateRange, dateRange } = (0, import_react34.useContext)(ProfitAndLoss.Context);
2843
+ const { changeDateRange, dateRange } = (0, import_react35.useContext)(ProfitAndLoss.Context);
2644
2844
  const date = dateRange.startDate;
2645
2845
  const label = (0, import_date_fns8.format)(date, "LLLL y");
2646
2846
  const change = (duration) => {
@@ -2652,28 +2852,28 @@ var ProfitAndLossDatePicker = () => {
2652
2852
  };
2653
2853
  const previousMonth = () => change({ months: -1 });
2654
2854
  const nextMonth = () => change({ months: 1 });
2655
- return /* @__PURE__ */ import_react34.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react34.default.createElement(
2855
+ return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ import_react35.default.createElement(
2656
2856
  "button",
2657
2857
  {
2658
2858
  "aria-label": "View Previous Month",
2659
2859
  className: "Layer__profit-and-loss-date-picker__button",
2660
2860
  onClick: previousMonth
2661
2861
  },
2662
- /* @__PURE__ */ import_react34.default.createElement(
2862
+ /* @__PURE__ */ import_react35.default.createElement(
2663
2863
  ChevronLeft_default,
2664
2864
  {
2665
2865
  className: "Layer__profit-and-loss-date-picker__button-icon",
2666
2866
  size: 18
2667
2867
  }
2668
2868
  )
2669
- ), /* @__PURE__ */ import_react34.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react34.default.createElement(
2869
+ ), /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ import_react35.default.createElement(
2670
2870
  "button",
2671
2871
  {
2672
2872
  "aria-label": "View Next Month",
2673
2873
  className: "Layer__profit-and-loss-date-picker__button",
2674
2874
  onClick: nextMonth
2675
2875
  },
2676
- /* @__PURE__ */ import_react34.default.createElement(
2876
+ /* @__PURE__ */ import_react35.default.createElement(
2677
2877
  ChevronRight_default,
2678
2878
  {
2679
2879
  className: "Layer__profit-and-loss-date-picker__button-icon",
@@ -2684,26 +2884,26 @@ var ProfitAndLossDatePicker = () => {
2684
2884
  };
2685
2885
 
2686
2886
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
2687
- var import_react35 = __toESM(require("react"));
2887
+ var import_react36 = __toESM(require("react"));
2688
2888
  var ProfitAndLossSummaries = () => {
2689
- const { data: storedData } = (0, import_react35.useContext)(ProfitAndLoss.Context);
2889
+ const { data: storedData } = (0, import_react36.useContext)(ProfitAndLoss.Context);
2690
2890
  const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
2691
2891
  const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2692
2892
  const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2693
2893
  const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
2694
- return /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-summaries" }, /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Revenue"), /* @__PURE__ */ import_react35.default.createElement(
2894
+ return /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries" }, /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Revenue"), /* @__PURE__ */ import_react36.default.createElement(
2695
2895
  "span",
2696
2896
  {
2697
2897
  className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
2698
2898
  },
2699
2899
  centsToDollars(Math.abs(data?.income?.value ?? NaN))
2700
- )), /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), /* @__PURE__ */ import_react35.default.createElement(
2900
+ )), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), /* @__PURE__ */ import_react36.default.createElement(
2701
2901
  "span",
2702
2902
  {
2703
2903
  className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
2704
2904
  },
2705
2905
  centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
2706
- )), /* @__PURE__ */ import_react35.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react35.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), /* @__PURE__ */ import_react35.default.createElement(
2906
+ )), /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ import_react36.default.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), /* @__PURE__ */ import_react36.default.createElement(
2707
2907
  "span",
2708
2908
  {
2709
2909
  className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
@@ -2713,10 +2913,10 @@ var ProfitAndLossSummaries = () => {
2713
2913
  };
2714
2914
 
2715
2915
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
2716
- var import_react37 = __toESM(require("react"));
2916
+ var import_react38 = __toESM(require("react"));
2717
2917
 
2718
2918
  // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
2719
- var import_react36 = __toESM(require("react"));
2919
+ var import_react37 = __toESM(require("react"));
2720
2920
  var ProfitAndLossRow = ({
2721
2921
  variant,
2722
2922
  lineItem,
@@ -2729,7 +2929,7 @@ var ProfitAndLossRow = ({
2729
2929
  return null;
2730
2930
  }
2731
2931
  const { value, display_name, line_items } = lineItem;
2732
- const [expanded, setExpanded] = (0, import_react36.useState)(true);
2932
+ const [expanded, setExpanded] = (0, import_react37.useState)(true);
2733
2933
  const amount = value ?? 0;
2734
2934
  const amountString = centsToDollars(Math.abs(amount));
2735
2935
  const labelClasses = [
@@ -2760,12 +2960,12 @@ var ProfitAndLossRow = ({
2760
2960
  );
2761
2961
  displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
2762
2962
  displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
2763
- return /* @__PURE__ */ import_react36.default.createElement(import_react36.default.Fragment, null, /* @__PURE__ */ import_react36.default.createElement("div", { className: labelClasses.join(" "), onClick: toggleExpanded }, /* @__PURE__ */ import_react36.default.createElement(ChevronDown_default, { size: 16 }), display_name), /* @__PURE__ */ import_react36.default.createElement("div", { className: valueClasses.join(" ") }, amountString), canGoDeeper && hasChildren && /* @__PURE__ */ import_react36.default.createElement(
2963
+ return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement("div", { className: labelClasses.join(" "), onClick: toggleExpanded }, /* @__PURE__ */ import_react37.default.createElement(ChevronDown_default, { size: 16 }), display_name), /* @__PURE__ */ import_react37.default.createElement("div", { className: valueClasses.join(" ") }, amountString), canGoDeeper && hasChildren && /* @__PURE__ */ import_react37.default.createElement(
2764
2964
  "div",
2765
2965
  {
2766
2966
  className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
2767
2967
  },
2768
- /* @__PURE__ */ import_react36.default.createElement("div", { className: "Layer__balance-sheet-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react36.default.createElement(
2968
+ /* @__PURE__ */ import_react37.default.createElement("div", { className: "Layer__balance-sheet-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ import_react37.default.createElement(
2769
2969
  ProfitAndLossRow,
2770
2970
  {
2771
2971
  key: line_item.display_name,
@@ -2774,7 +2974,7 @@ var ProfitAndLossRow = ({
2774
2974
  maxDepth,
2775
2975
  direction
2776
2976
  }
2777
- )), summarize && /* @__PURE__ */ import_react36.default.createElement(
2977
+ )), summarize && /* @__PURE__ */ import_react37.default.createElement(
2778
2978
  ProfitAndLossRow,
2779
2979
  {
2780
2980
  key: display_name,
@@ -2837,15 +3037,15 @@ var empty_profit_and_loss_report_default = {
2837
3037
 
2838
3038
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
2839
3039
  var ProfitAndLossTable = () => {
2840
- const { data: actualData, isLoading } = (0, import_react37.useContext)(ProfitAndLoss.Context);
3040
+ const { data: actualData, isLoading } = (0, import_react38.useContext)(ProfitAndLoss.Context);
2841
3041
  const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
2842
- return /* @__PURE__ */ import_react37.default.createElement(import_react37.default.Fragment, null, /* @__PURE__ */ import_react37.default.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ import_react37.default.createElement(ProfitAndLossRow, { lineItem: data.income, direction: "CREDIT" /* CREDIT */ }), /* @__PURE__ */ import_react37.default.createElement(
3042
+ return /* @__PURE__ */ import_react38.default.createElement(import_react38.default.Fragment, null, /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table" }, /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.income, direction: "CREDIT" /* CREDIT */ }), /* @__PURE__ */ import_react38.default.createElement(
2843
3043
  ProfitAndLossRow,
2844
3044
  {
2845
3045
  lineItem: data.cost_of_goods_sold,
2846
3046
  direction: "DEBIT" /* DEBIT */
2847
3047
  }
2848
- ), /* @__PURE__ */ import_react37.default.createElement(
3048
+ ), /* @__PURE__ */ import_react38.default.createElement(
2849
3049
  ProfitAndLossRow,
2850
3050
  {
2851
3051
  lineItem: {
@@ -2855,13 +3055,13 @@ var ProfitAndLossTable = () => {
2855
3055
  variant: "summation",
2856
3056
  direction: "CREDIT" /* CREDIT */
2857
3057
  }
2858
- ), /* @__PURE__ */ import_react37.default.createElement(
3058
+ ), /* @__PURE__ */ import_react38.default.createElement(
2859
3059
  ProfitAndLossRow,
2860
3060
  {
2861
3061
  lineItem: data.expenses,
2862
3062
  direction: "DEBIT" /* DEBIT */
2863
3063
  }
2864
- ), /* @__PURE__ */ import_react37.default.createElement(
3064
+ ), /* @__PURE__ */ import_react38.default.createElement(
2865
3065
  ProfitAndLossRow,
2866
3066
  {
2867
3067
  lineItem: {
@@ -2871,7 +3071,7 @@ var ProfitAndLossTable = () => {
2871
3071
  variant: "summation",
2872
3072
  direction: "CREDIT" /* CREDIT */
2873
3073
  }
2874
- ), /* @__PURE__ */ import_react37.default.createElement(ProfitAndLossRow, { lineItem: data.taxes, direction: "DEBIT" /* DEBIT */ }), /* @__PURE__ */ import_react37.default.createElement(
3074
+ ), /* @__PURE__ */ import_react38.default.createElement(ProfitAndLossRow, { lineItem: data.taxes, direction: "DEBIT" /* DEBIT */ }), /* @__PURE__ */ import_react38.default.createElement(
2875
3075
  ProfitAndLossRow,
2876
3076
  {
2877
3077
  lineItem: {
@@ -2881,13 +3081,13 @@ var ProfitAndLossTable = () => {
2881
3081
  variant: "summation",
2882
3082
  direction: "CREDIT" /* CREDIT */
2883
3083
  }
2884
- )), /* @__PURE__ */ import_react37.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react37.default.createElement(
3084
+ )), /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ import_react38.default.createElement(
2885
3085
  ProfitAndLossRow,
2886
3086
  {
2887
3087
  lineItem: data.other_outflows,
2888
3088
  direction: "DEBIT" /* DEBIT */
2889
3089
  }
2890
- ), /* @__PURE__ */ import_react37.default.createElement(
3090
+ ), /* @__PURE__ */ import_react38.default.createElement(
2891
3091
  ProfitAndLossRow,
2892
3092
  {
2893
3093
  lineItem: data.personal_expenses,
@@ -2898,7 +3098,7 @@ var ProfitAndLossTable = () => {
2898
3098
 
2899
3099
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
2900
3100
  var import_date_fns9 = require("date-fns");
2901
- var PNLContext = (0, import_react38.createContext)({
3101
+ var PNLContext = (0, import_react39.createContext)({
2902
3102
  data: void 0,
2903
3103
  isLoading: true,
2904
3104
  error: void 0,
@@ -2911,7 +3111,7 @@ var PNLContext = (0, import_react38.createContext)({
2911
3111
  });
2912
3112
  var ProfitAndLoss = ({ children }) => {
2913
3113
  const contextData = useProfitAndLoss();
2914
- return /* @__PURE__ */ import_react38.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react38.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, /* @__PURE__ */ import_react38.default.createElement("h2", { className: "Layer__profit-and-loss__title" }, "Profit & Loss"), children));
3114
+ return /* @__PURE__ */ import_react39.default.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ import_react39.default.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, /* @__PURE__ */ import_react39.default.createElement("h2", { className: "Layer__profit-and-loss__title" }, "Profit & Loss"), children));
2915
3115
  };
2916
3116
  ProfitAndLoss.Chart = ProfitAndLossChart;
2917
3117
  ProfitAndLoss.Context = PNLContext;
@@ -2920,7 +3120,7 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
2920
3120
  ProfitAndLoss.Table = ProfitAndLossTable;
2921
3121
 
2922
3122
  // src/providers/LayerProvider/LayerProvider.tsx
2923
- var import_react39 = __toESM(require("react"));
3123
+ var import_react40 = __toESM(require("react"));
2924
3124
  var import_date_fns10 = require("date-fns");
2925
3125
  var import_swr5 = __toESM(require("swr"));
2926
3126
  var reducer = (state, action) => {
@@ -2961,7 +3161,7 @@ var LayerProvider = ({
2961
3161
  revalidateIfStale: false
2962
3162
  };
2963
3163
  const { url, scope, apiUrl } = LayerEnvironment[environment];
2964
- const [state, dispatch] = (0, import_react39.useReducer)(reducer, {
3164
+ const [state, dispatch] = (0, import_react40.useReducer)(reducer, {
2965
3165
  auth: {
2966
3166
  access_token: "",
2967
3167
  token_type: "",
@@ -2983,7 +3183,7 @@ var LayerProvider = ({
2983
3183
  }),
2984
3184
  defaultSWRConfig
2985
3185
  ) : { data: void 0 };
2986
- (0, import_react39.useEffect)(() => {
3186
+ (0, import_react40.useEffect)(() => {
2987
3187
  if (businessAccessToken) {
2988
3188
  dispatch({
2989
3189
  type: "LayerContext.setAuth" /* setAuth */,
@@ -3013,7 +3213,7 @@ var LayerProvider = ({
3013
3213
  Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
3014
3214
  defaultSWRConfig
3015
3215
  );
3016
- (0, import_react39.useEffect)(() => {
3216
+ (0, import_react40.useEffect)(() => {
3017
3217
  if (categories?.data?.categories?.length) {
3018
3218
  dispatch({
3019
3219
  type: "LayerContext.setCategories" /* setCategories */,
@@ -3025,11 +3225,11 @@ var LayerProvider = ({
3025
3225
  type: "LayerContext.setTheme" /* setTheme */,
3026
3226
  payload: { theme: theme2 }
3027
3227
  });
3028
- return /* @__PURE__ */ import_react39.default.createElement(import_swr5.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react39.default.createElement(LayerContext.Provider, { value: { ...state, setTheme } }, children));
3228
+ return /* @__PURE__ */ import_react40.default.createElement(import_swr5.SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ import_react40.default.createElement(LayerContext.Provider, { value: { ...state, setTheme } }, children));
3029
3229
  };
3030
3230
 
3031
3231
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
3032
- var import_react42 = __toESM(require("react"));
3232
+ var import_react43 = __toESM(require("react"));
3033
3233
 
3034
3234
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
3035
3235
  var import_swr6 = __toESM(require("swr"));
@@ -3049,21 +3249,21 @@ var useChartOfAccounts = () => {
3049
3249
  };
3050
3250
 
3051
3251
  // src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
3052
- var import_react40 = __toESM(require("react"));
3252
+ var import_react41 = __toESM(require("react"));
3053
3253
  var import_react_select2 = __toESM(require("react-select"));
3054
3254
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
3055
3255
  var ChartOfAccountsNewForm = () => {
3056
3256
  const { data, create: createAccount2 } = useChartOfAccounts();
3057
- const accountOptions = (0, import_react40.useMemo)(
3257
+ const accountOptions = (0, import_react41.useMemo)(
3058
3258
  () => flattenAccounts(data?.accounts || []).sort(
3059
3259
  (a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
3060
3260
  ),
3061
3261
  [data?.accounts?.length]
3062
3262
  );
3063
- const [name, setName] = (0, import_react40.useState)("");
3064
- const [description, setDescription] = (0, import_react40.useState)("");
3065
- const [normality, setNormality] = (0, import_react40.useState)("DEBIT" /* DEBIT */);
3066
- const [parentAccount, setParentAccount] = (0, import_react40.useState)(
3263
+ const [name, setName] = (0, import_react41.useState)("");
3264
+ const [description, setDescription] = (0, import_react41.useState)("");
3265
+ const [normality, setNormality] = (0, import_react41.useState)("DEBIT" /* DEBIT */);
3266
+ const [parentAccount, setParentAccount] = (0, import_react41.useState)(
3067
3267
  data?.accounts[0]
3068
3268
  );
3069
3269
  const save = () => {
@@ -3077,21 +3277,21 @@ var ChartOfAccountsNewForm = () => {
3077
3277
  description
3078
3278
  });
3079
3279
  };
3080
- return /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react40.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react40.default.createElement(
3280
+ return /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Name"), /* @__PURE__ */ import_react41.default.createElement(
3081
3281
  "input",
3082
3282
  {
3083
3283
  name: "name",
3084
3284
  value: name,
3085
3285
  onChange: (event) => setName(event.target.value)
3086
3286
  }
3087
- )), /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react40.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react40.default.createElement(
3287
+ )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Description"), /* @__PURE__ */ import_react41.default.createElement(
3088
3288
  "input",
3089
3289
  {
3090
3290
  name: "description",
3091
3291
  value: description,
3092
3292
  onChange: (event) => setDescription(event.target.value)
3093
3293
  }
3094
- )), /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react40.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react40.default.createElement(
3294
+ )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Normality"), /* @__PURE__ */ import_react41.default.createElement(
3095
3295
  import_react_select2.default,
3096
3296
  {
3097
3297
  isSearchable: false,
@@ -3101,7 +3301,7 @@ var ChartOfAccountsNewForm = () => {
3101
3301
  { label: "Debit", value: "DEBIT" /* DEBIT */ }
3102
3302
  ]
3103
3303
  }
3104
- )), /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react40.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react40.default.createElement(
3304
+ )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ import_react41.default.createElement("span", null, "Parent Account"), /* @__PURE__ */ import_react41.default.createElement(
3105
3305
  import_react_select2.default,
3106
3306
  {
3107
3307
  isSearchable: true,
@@ -3111,49 +3311,49 @@ var ChartOfAccountsNewForm = () => {
3111
3311
  getOptionValue: (a) => a.id,
3112
3312
  options: accountOptions
3113
3313
  }
3114
- )), /* @__PURE__ */ import_react40.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react40.default.createElement("button", { onClick: save }, "Save")));
3314
+ )), /* @__PURE__ */ import_react41.default.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ import_react41.default.createElement("button", { onClick: save }, "Save")));
3115
3315
  };
3116
3316
 
3117
3317
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
3118
- var import_react41 = __toESM(require("react"));
3318
+ var import_react42 = __toESM(require("react"));
3119
3319
  var ChartOfAccountsRow = ({ account, depth = 0 }) => {
3120
- const classNames12 = [
3320
+ const classNames13 = [
3121
3321
  "Layer__chart-of-accounts-row__table-cell",
3122
3322
  depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
3123
3323
  ];
3124
- const className = classNames12.filter((id) => id).join(" ");
3324
+ const className = classNames13.filter((id) => id).join(" ");
3125
3325
  const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
3126
- return /* @__PURE__ */ import_react41.default.createElement(import_react41.default.Fragment, null, /* @__PURE__ */ import_react41.default.createElement(
3326
+ return /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement(
3127
3327
  "div",
3128
3328
  {
3129
3329
  className: `${className} Layer__chart-of-accounts-row__table-cell--name`
3130
3330
  },
3131
3331
  account.name
3132
- ), /* @__PURE__ */ import_react41.default.createElement(
3332
+ ), /* @__PURE__ */ import_react42.default.createElement(
3133
3333
  "div",
3134
3334
  {
3135
3335
  className: `${className} Layer__chart-of-accounts-row__table-cell--type`
3136
3336
  },
3137
3337
  "Assets"
3138
- ), /* @__PURE__ */ import_react41.default.createElement(
3338
+ ), /* @__PURE__ */ import_react42.default.createElement(
3139
3339
  "div",
3140
3340
  {
3141
3341
  className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
3142
3342
  },
3143
3343
  "Cash"
3144
- ), /* @__PURE__ */ import_react41.default.createElement(
3344
+ ), /* @__PURE__ */ import_react42.default.createElement(
3145
3345
  "div",
3146
3346
  {
3147
3347
  className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
3148
3348
  },
3149
3349
  centsToDollars(Math.abs(account.balance || 0))
3150
- ), /* @__PURE__ */ import_react41.default.createElement(
3350
+ ), /* @__PURE__ */ import_react42.default.createElement(
3151
3351
  "div",
3152
3352
  {
3153
3353
  className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
3154
3354
  },
3155
- /* @__PURE__ */ import_react41.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
3156
- ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react41.default.createElement(
3355
+ /* @__PURE__ */ import_react42.default.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
3356
+ ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ import_react42.default.createElement(
3157
3357
  ChartOfAccountsRow,
3158
3358
  {
3159
3359
  key: subAccount.id,
@@ -3166,15 +3366,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
3166
3366
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
3167
3367
  var ChartOfAccounts = () => {
3168
3368
  const { data, isLoading } = useChartOfAccounts();
3169
- const [showingForm, setShowingForm] = (0, import_react42.useState)(false);
3170
- return /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react42.default.createElement(import_react42.default.Fragment, null, /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react42.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react42.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react42.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react42.default.createElement(
3369
+ const [showingForm, setShowingForm] = (0, import_react43.useState)(false);
3370
+ return /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ import_react43.default.createElement(import_react43.default.Fragment, null, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ import_react43.default.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ import_react43.default.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ import_react43.default.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ import_react43.default.createElement(
3171
3371
  "button",
3172
3372
  {
3173
3373
  className: "Layer__chart-of-accounts__edit-accounts-button",
3174
3374
  onClick: () => setShowingForm(!showingForm)
3175
3375
  },
3176
3376
  "Edit Accounts"
3177
- ))), showingForm && /* @__PURE__ */ import_react42.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react42.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react42.default.createElement(
3377
+ ))), showingForm && /* @__PURE__ */ import_react43.default.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header Layer__chart-of-accounts__table-cell--header-balance" }, "Balance"), /* @__PURE__ */ import_react43.default.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ import_react43.default.createElement(
3178
3378
  ChartOfAccountsRow,
3179
3379
  {
3180
3380
  key: account.id,