@layerfi/components 0.1.8 → 0.1.9

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/esm/index.js CHANGED
@@ -261,8 +261,8 @@ var matchBankTransaction = put(
261
261
  // src/api/layer/categories.ts
262
262
  var getCategories = get(({ businessId }) => `/v1/businesses/${businessId}/categories`);
263
263
 
264
- // src/api/layer/chart_of_accounts.ts
265
- var getChartOfAccounts = get(
264
+ // src/api/layer/ledger_accounts.ts
265
+ var getLedgerAccounts = get(
266
266
  ({ businessId }) => `/v1/businesses/${businessId}/ledger/accounts`
267
267
  );
268
268
  var createAccount = post(
@@ -283,7 +283,7 @@ var Layer = {
283
283
  getBalanceSheet,
284
284
  getBankTransactions,
285
285
  getCategories,
286
- getChartOfAccounts,
286
+ getLedgerAccounts,
287
287
  getProfitAndLoss
288
288
  };
289
289
 
@@ -328,23 +328,41 @@ var useBalanceSheet = (date = /* @__PURE__ */ new Date()) => {
328
328
 
329
329
  // src/icons/DownloadCloud.tsx
330
330
  import * as React from "react";
331
- var DownloadCloud = (props) => /* @__PURE__ */ React.createElement(
331
+ var DownloadCloud = ({ size = 18, ...props }) => /* @__PURE__ */ React.createElement(
332
332
  "svg",
333
333
  {
334
334
  xmlns: "http://www.w3.org/2000/svg",
335
- width: 24,
336
- height: 24,
335
+ viewBox: "0 0 18 18",
337
336
  fill: "none",
338
- ...props
337
+ ...props,
338
+ width: size,
339
+ height: size
339
340
  },
340
341
  /* @__PURE__ */ React.createElement(
341
342
  "path",
342
343
  {
343
- stroke: "#000",
344
+ d: "M6 12.75L9 15.75L12 12.75",
345
+ stroke: "currentColor",
344
346
  strokeLinecap: "round",
345
- strokeLinejoin: "round",
346
- strokeWidth: 2,
347
- d: "M4 16.242A4.5 4.5 0 0 1 6.08 8.02a6.002 6.002 0 0 1 11.84 0A4.5 4.5 0 0 1 20 16.242M8 17l4 4m0 0 4-4m-4 4v-9"
347
+ strokeLinejoin: "round"
348
+ }
349
+ ),
350
+ /* @__PURE__ */ React.createElement(
351
+ "path",
352
+ {
353
+ d: "M9 9V15.75",
354
+ stroke: "currentColor",
355
+ strokeLinecap: "round",
356
+ strokeLinejoin: "round"
357
+ }
358
+ ),
359
+ /* @__PURE__ */ React.createElement(
360
+ "path",
361
+ {
362
+ d: "M15.66 13.5675C16.3121 13.109 16.801 12.4546 17.056 11.6994C17.3109 10.9441 17.3186 10.1273 17.0778 9.36737C16.837 8.60748 16.3604 7.94407 15.7171 7.47342C15.0737 7.00278 14.2971 6.74938 13.5 6.75H12.555C12.3294 5.87091 11.9074 5.05444 11.3206 4.36206C10.7338 3.66969 9.99762 3.11945 9.16742 2.75277C8.33721 2.38609 7.43464 2.21252 6.52766 2.24514C5.62067 2.27776 4.7329 2.51571 3.93118 2.94107C3.12946 3.36644 2.43468 3.96814 1.89915 4.70087C1.36362 5.43361 1.0013 6.27829 0.839456 7.17132C0.677613 8.06434 0.720468 8.98245 0.964796 9.85652C1.20912 10.7306 1.64856 11.5378 2.25001 12.2175",
363
+ stroke: "currentColor",
364
+ strokeLinecap: "round",
365
+ strokeLinejoin: "round"
348
366
  }
349
367
  )
350
368
  );
@@ -563,7 +581,7 @@ var BalanceSheet = () => {
563
581
  };
564
582
 
565
583
  // src/components/BankTransactions/BankTransactions.tsx
566
- import React54, { useState as useState10, useMemo as useMemo2 } from "react";
584
+ import React55, { useState as useState10, useMemo as useMemo2 } from "react";
567
585
 
568
586
  // src/config/general.ts
569
587
  var DATE_FORMAT = "LLL d, yyyy";
@@ -719,7 +737,7 @@ var debounce = (fnc, timeout = 300) => {
719
737
  };
720
738
 
721
739
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
722
- import React46, { useEffect as useEffect6, useRef as useRef11, useState as useState9 } from "react";
740
+ import React47, { useEffect as useEffect6, useRef as useRef11, useState as useState9 } from "react";
723
741
 
724
742
  // src/icons/ChevronDownFill.tsx
725
743
  import * as React8 from "react";
@@ -747,7 +765,7 @@ var ChevronDownFill = ({ size = 18, ...props }) => /* @__PURE__ */ React8.create
747
765
  var ChevronDownFill_default = ChevronDownFill;
748
766
 
749
767
  // src/components/BankTransactionRow/BankTransactionRow.tsx
750
- import React44, { useEffect as useEffect5, useRef as useRef10, useState as useState8 } from "react";
768
+ import React45, { useEffect as useEffect5, useRef as useRef10, useState as useState8 } from "react";
751
769
 
752
770
  // src/icons/AlertCircle.tsx
753
771
  import * as React9 from "react";
@@ -1399,8 +1417,12 @@ import classNames4 from "classnames";
1399
1417
  var buildRightIcon = ({
1400
1418
  processing,
1401
1419
  error,
1402
- action
1420
+ action,
1421
+ noIcon
1403
1422
  }) => {
1423
+ if (noIcon) {
1424
+ return;
1425
+ }
1404
1426
  if (processing) {
1405
1427
  return /* @__PURE__ */ React20.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" });
1406
1428
  }
@@ -1420,6 +1442,7 @@ var SubmitButton = ({
1420
1442
  error,
1421
1443
  children,
1422
1444
  action = "save" /* SAVE */,
1445
+ noIcon,
1423
1446
  ...props
1424
1447
  }) => {
1425
1448
  const baseClassName = classNames4(
@@ -1433,7 +1456,7 @@ var SubmitButton = ({
1433
1456
  className: baseClassName,
1434
1457
  variant: "primary" /* primary */,
1435
1458
  disabled: processing || disabled,
1436
- rightIcon: buildRightIcon({ processing, error, action }),
1459
+ rightIcon: buildRightIcon({ processing, error, action, noIcon }),
1437
1460
  iconAsPrimary: true
1438
1461
  },
1439
1462
  children
@@ -1734,7 +1757,7 @@ var CategorySelect = ({
1734
1757
  };
1735
1758
 
1736
1759
  // src/components/ExpandedBankTransactionRow/ExpandedBankTransactionRow.tsx
1737
- import React42, {
1760
+ import React43, {
1738
1761
  forwardRef as forwardRef2,
1739
1762
  useImperativeHandle,
1740
1763
  useState as useState7,
@@ -2039,9 +2062,14 @@ var InputGroup = ({
2039
2062
  label,
2040
2063
  name,
2041
2064
  className,
2065
+ inline,
2042
2066
  children
2043
2067
  }) => {
2044
- const baseClassName = classNames12("Layer__input-group", className);
2068
+ const baseClassName = classNames12(
2069
+ "Layer__input-group",
2070
+ className,
2071
+ inline && "Layer__input-group--inline"
2072
+ );
2045
2073
  return /* @__PURE__ */ React33.createElement("div", { className: baseClassName }, label && /* @__PURE__ */ React33.createElement(
2046
2074
  Text,
2047
2075
  {
@@ -2141,11 +2169,45 @@ var FileInput = ({ text = "Upload", onUpload }) => {
2141
2169
  ));
2142
2170
  };
2143
2171
 
2172
+ // src/components/Input/Select.tsx
2173
+ import React36 from "react";
2174
+ import ReactSelect, {
2175
+ components as components3
2176
+ } from "react-select";
2177
+ var DropdownIndicator3 = (props) => {
2178
+ return /* @__PURE__ */ React36.createElement(components3.DropdownIndicator, { ...props }, /* @__PURE__ */ React36.createElement(ChevronDownFill_default, null));
2179
+ };
2180
+ var Select3 = ({
2181
+ name,
2182
+ options,
2183
+ className,
2184
+ classNamePrefix = "Layer__select",
2185
+ value,
2186
+ onChange,
2187
+ disabled
2188
+ }) => {
2189
+ return /* @__PURE__ */ React36.createElement(
2190
+ ReactSelect,
2191
+ {
2192
+ name,
2193
+ className: `Layer__select ${className ?? ""}`,
2194
+ classNamePrefix,
2195
+ options,
2196
+ value,
2197
+ onChange: (newValue) => newValue && onChange(newValue),
2198
+ menuPortalTarget: document.body,
2199
+ styles: { menuPortal: (base) => ({ ...base, zIndex: 9999 }) },
2200
+ components: { DropdownIndicator: DropdownIndicator3 },
2201
+ isDisabled: disabled
2202
+ }
2203
+ );
2204
+ };
2205
+
2144
2206
  // src/components/MatchForm/MatchForm.tsx
2145
- import React37 from "react";
2207
+ import React38 from "react";
2146
2208
 
2147
2209
  // src/components/BankTransactionRow/MatchBadge.tsx
2148
- import React36 from "react";
2210
+ import React37 from "react";
2149
2211
  import { parseISO as parseISO3, format as formatTime2 } from "date-fns";
2150
2212
  var MatchBadge = ({
2151
2213
  bankTransaction,
@@ -2155,11 +2217,11 @@ var MatchBadge = ({
2155
2217
  }) => {
2156
2218
  if (bankTransaction.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction.match) {
2157
2219
  const { date, amount, description } = bankTransaction.match.bank_transaction;
2158
- return /* @__PURE__ */ React36.createElement(
2220
+ return /* @__PURE__ */ React37.createElement(
2159
2221
  Badge,
2160
2222
  {
2161
- icon: /* @__PURE__ */ React36.createElement(MinimizeTwo_default, { size: 11 }),
2162
- tooltip: /* @__PURE__ */ React36.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ React36.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, formatTime2(parseISO3(date), dateFormat)), /* @__PURE__ */ React36.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ React36.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
2223
+ icon: /* @__PURE__ */ React37.createElement(MinimizeTwo_default, { size: 11 }),
2224
+ tooltip: /* @__PURE__ */ React37.createElement("span", { className: `${classNamePrefix}__match-tooltip` }, /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-tooltip__date` }, formatTime2(parseISO3(date), dateFormat)), /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-tooltip__description` }, description), /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-tooltip__amount` }, "$", centsToDollars(amount)))
2163
2225
  },
2164
2226
  text
2165
2227
  );
@@ -2177,13 +2239,13 @@ var MatchForm = ({
2177
2239
  setSelectedMatchId,
2178
2240
  matchFormError
2179
2241
  }) => {
2180
- return /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ React37.createElement(
2242
+ return /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table` }, /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__header` }, /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__date` }, "Date"), /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, "Description"), /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "Amount"), /* @__PURE__ */ React38.createElement(
2181
2243
  "div",
2182
2244
  {
2183
2245
  className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
2184
2246
  }
2185
2247
  )), bankTransaction.suggested_matches?.map((match, idx) => {
2186
- return /* @__PURE__ */ React37.createElement(
2248
+ return /* @__PURE__ */ React38.createElement(
2187
2249
  "div",
2188
2250
  {
2189
2251
  key: idx,
@@ -2199,15 +2261,15 @@ var MatchForm = ({
2199
2261
  setSelectedMatchId(match.id);
2200
2262
  }
2201
2263
  },
2202
- /* @__PURE__ */ React37.createElement(
2264
+ /* @__PURE__ */ React38.createElement(
2203
2265
  "div",
2204
2266
  {
2205
2267
  className: `Layer__nowrap ${classNamePrefix}__match-table__date`
2206
2268
  },
2207
- /* @__PURE__ */ React37.createElement("span", null, formatTime3(parseISO4(match.details.date), DATE_FORMAT)),
2208
- /* @__PURE__ */ React37.createElement("span", { className: "amount-next-to-date" }, "$", centsToDollars(match.details.amount))
2269
+ /* @__PURE__ */ React38.createElement("span", null, formatTime3(parseISO4(match.details.date), DATE_FORMAT)),
2270
+ /* @__PURE__ */ React38.createElement("span", { className: "amount-next-to-date" }, "$", centsToDollars(match.details.amount))
2209
2271
  ),
2210
- /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ React37.createElement(
2272
+ /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__desc` }, /* @__PURE__ */ React38.createElement(
2211
2273
  Text,
2212
2274
  {
2213
2275
  className: `${classNamePrefix}__match-table__desc-tooltip`,
@@ -2215,7 +2277,7 @@ var MatchForm = ({
2215
2277
  as: "span"
2216
2278
  },
2217
2279
  match.details.description
2218
- ), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ React37.createElement("span", { className: "match-badge" }, /* @__PURE__ */ React37.createElement(
2280
+ ), match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ React38.createElement("span", { className: "match-badge" }, /* @__PURE__ */ React38.createElement(
2219
2281
  MatchBadge,
2220
2282
  {
2221
2283
  classNamePrefix,
@@ -2224,13 +2286,13 @@ var MatchForm = ({
2224
2286
  text: "Matched"
2225
2287
  }
2226
2288
  ))),
2227
- /* @__PURE__ */ React37.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
2228
- /* @__PURE__ */ React37.createElement(
2289
+ /* @__PURE__ */ React38.createElement("div", { className: `${classNamePrefix}__match-table__amount` }, "$", centsToDollars(match.details.amount)),
2290
+ /* @__PURE__ */ React38.createElement(
2229
2291
  "div",
2230
2292
  {
2231
2293
  className: `${classNamePrefix}__match-table__status ${bankTransaction.match ? "" : "no-match"}`
2232
2294
  },
2233
- match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ React37.createElement(
2295
+ match.details.id === bankTransaction.match?.details.id && /* @__PURE__ */ React38.createElement(
2234
2296
  MatchBadge,
2235
2297
  {
2236
2298
  classNamePrefix,
@@ -2241,22 +2303,22 @@ var MatchForm = ({
2241
2303
  )
2242
2304
  )
2243
2305
  );
2244
- }), matchFormError && /* @__PURE__ */ React37.createElement(ErrorText, null, matchFormError));
2306
+ }), matchFormError && /* @__PURE__ */ React38.createElement(ErrorText, null, matchFormError));
2245
2307
  };
2246
2308
 
2247
2309
  // src/components/Textarea/Textarea.tsx
2248
- import React38 from "react";
2310
+ import React39 from "react";
2249
2311
  import classNames14 from "classnames";
2250
2312
  var Textarea = ({
2251
2313
  className,
2252
2314
  ...props
2253
2315
  }) => {
2254
2316
  const baseClassName = classNames14("Layer__textarea", className);
2255
- return /* @__PURE__ */ React38.createElement("textarea", { ...props, className: baseClassName });
2317
+ return /* @__PURE__ */ React39.createElement("textarea", { ...props, className: baseClassName });
2256
2318
  };
2257
2319
 
2258
2320
  // src/components/Toggle/Toggle.tsx
2259
- import React39, {
2321
+ import React40, {
2260
2322
  useEffect as useEffect2,
2261
2323
  useState as useState5
2262
2324
  } from "react";
@@ -2325,7 +2387,7 @@ var Toggle = ({
2325
2387
  }
2326
2388
  return selectedIndex;
2327
2389
  };
2328
- return /* @__PURE__ */ React39.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ React39.createElement(
2390
+ return /* @__PURE__ */ React40.createElement("div", { className: baseClassName, ref: toggleRef }, options.map((option, index) => /* @__PURE__ */ React40.createElement(
2329
2391
  ToggleOption,
2330
2392
  {
2331
2393
  ...option,
@@ -2337,7 +2399,7 @@ var Toggle = ({
2337
2399
  disabled: option.disabled ?? false,
2338
2400
  index
2339
2401
  }
2340
- )), /* @__PURE__ */ React39.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
2402
+ )), /* @__PURE__ */ React40.createElement("span", { className: "Layer__toggle__thumb", style: { ...thumbPos } }));
2341
2403
  };
2342
2404
  var ToggleOption = ({
2343
2405
  checked,
@@ -2351,7 +2413,7 @@ var ToggleOption = ({
2351
2413
  index
2352
2414
  }) => {
2353
2415
  if (disabled) {
2354
- return /* @__PURE__ */ React39.createElement(Tooltip, null, /* @__PURE__ */ React39.createElement(TooltipTrigger, null, /* @__PURE__ */ React39.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React39.createElement(
2416
+ return /* @__PURE__ */ React40.createElement(Tooltip, null, /* @__PURE__ */ React40.createElement(TooltipTrigger, null, /* @__PURE__ */ React40.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React40.createElement(
2355
2417
  "input",
2356
2418
  {
2357
2419
  type: "radio",
@@ -2362,9 +2424,9 @@ var ToggleOption = ({
2362
2424
  disabled: disabled ?? false,
2363
2425
  "data-idx": index
2364
2426
  }
2365
- ), /* @__PURE__ */ React39.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ React39.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ React39.createElement("span", null, label)))), /* @__PURE__ */ React39.createElement(TooltipContent, { className: "Layer__tooltip" }, "We could not find matching transactions"));
2427
+ ), /* @__PURE__ */ React40.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ React40.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ React40.createElement("span", null, label)))), /* @__PURE__ */ React40.createElement(TooltipContent, { className: "Layer__tooltip" }, "We could not find matching transactions"));
2366
2428
  }
2367
- return /* @__PURE__ */ React39.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React39.createElement(
2429
+ return /* @__PURE__ */ React40.createElement("label", { className: `Layer__toggle-option`, "data-checked": checked }, /* @__PURE__ */ React40.createElement(
2368
2430
  "input",
2369
2431
  {
2370
2432
  type: "radio",
@@ -2375,15 +2437,15 @@ var ToggleOption = ({
2375
2437
  disabled: disabled ?? false,
2376
2438
  "data-idx": index
2377
2439
  }
2378
- ), /* @__PURE__ */ React39.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ React39.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ React39.createElement("span", null, label)));
2440
+ ), /* @__PURE__ */ React40.createElement("span", { className: "Layer__toggle-option-content" }, leftIcon && /* @__PURE__ */ React40.createElement("span", { className: "Layer__toggle-option__icon" }, leftIcon), /* @__PURE__ */ React40.createElement("span", null, label)));
2379
2441
  };
2380
2442
 
2381
2443
  // src/components/ExpandedBankTransactionRow/APIErrorNotifications.tsx
2382
- import React41, { useEffect as useEffect3, useState as useState6 } from "react";
2444
+ import React42, { useEffect as useEffect3, useState as useState6 } from "react";
2383
2445
 
2384
2446
  // src/icons/AlertOctagon.tsx
2385
- import * as React40 from "react";
2386
- var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createElement(
2447
+ import * as React41 from "react";
2448
+ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React41.createElement(
2387
2449
  "svg",
2388
2450
  {
2389
2451
  viewBox: "0 0 18 18",
@@ -2393,7 +2455,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
2393
2455
  width: size,
2394
2456
  height: size
2395
2457
  },
2396
- /* @__PURE__ */ React40.createElement(
2458
+ /* @__PURE__ */ React41.createElement(
2397
2459
  "path",
2398
2460
  {
2399
2461
  d: "M5.895 1.5H12.105L16.5 5.895V12.105L12.105 16.5H5.895L1.5 12.105V5.895L5.895 1.5Z",
@@ -2402,7 +2464,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
2402
2464
  strokeLinejoin: "round"
2403
2465
  }
2404
2466
  ),
2405
- /* @__PURE__ */ React40.createElement(
2467
+ /* @__PURE__ */ React41.createElement(
2406
2468
  "path",
2407
2469
  {
2408
2470
  d: "M9 6V9",
@@ -2411,7 +2473,7 @@ var AlertOctagon = ({ size = 18, ...props }) => /* @__PURE__ */ React40.createEl
2411
2473
  strokeLinejoin: "round"
2412
2474
  }
2413
2475
  ),
2414
- /* @__PURE__ */ React40.createElement(
2476
+ /* @__PURE__ */ React41.createElement(
2415
2477
  "path",
2416
2478
  {
2417
2479
  d: "M9 12H9.0075",
@@ -2467,13 +2529,13 @@ var APIErrorNotifications = ({
2467
2529
  pushNotification(ERROR_TITLE, ERROR_MESSAGE);
2468
2530
  }
2469
2531
  }, [bankTransaction.error]);
2470
- return /* @__PURE__ */ React41.createElement(
2532
+ return /* @__PURE__ */ React42.createElement(
2471
2533
  "div",
2472
2534
  {
2473
2535
  className: "Layer__bank-transactions__notifications",
2474
2536
  style: containerWidth ? { left: containerWidth - 324 } : {}
2475
2537
  },
2476
- notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */ React41.createElement(
2538
+ notifications.filter((n) => n.bankTransactionId === bankTransaction.id).map((notification) => /* @__PURE__ */ React42.createElement(
2477
2539
  Notification,
2478
2540
  {
2479
2541
  key: notification.timestamp,
@@ -2501,20 +2563,20 @@ var Notification = ({
2501
2563
  deleteNotification(notification.timestamp);
2502
2564
  }, FADE_OUT_TIME_WAIT);
2503
2565
  };
2504
- return /* @__PURE__ */ React41.createElement(
2566
+ return /* @__PURE__ */ React42.createElement(
2505
2567
  "div",
2506
2568
  {
2507
2569
  className: `Layer__bank-transactions__notification ${visible ? "notification-enter" : "notification-exit"}`,
2508
2570
  onClick: hideNotification
2509
2571
  },
2510
- /* @__PURE__ */ React41.createElement("div", { className: "Layer__bank-transactions__notification-content" }, /* @__PURE__ */ React41.createElement("div", { className: "Layer__bank-transactions__notification-icon" }, /* @__PURE__ */ React41.createElement(AlertOctagon_default, { size: 14 })), /* @__PURE__ */ React41.createElement("div", { className: "Layer__bank-transactions__notification-text" }, /* @__PURE__ */ React41.createElement(
2572
+ /* @__PURE__ */ React42.createElement("div", { className: "Layer__bank-transactions__notification-content" }, /* @__PURE__ */ React42.createElement("div", { className: "Layer__bank-transactions__notification-icon" }, /* @__PURE__ */ React42.createElement(AlertOctagon_default, { size: 14 })), /* @__PURE__ */ React42.createElement("div", { className: "Layer__bank-transactions__notification-text" }, /* @__PURE__ */ React42.createElement(
2511
2573
  Text,
2512
2574
  {
2513
2575
  as: "span",
2514
2576
  className: "Layer__bank-transactions__notification-title"
2515
2577
  },
2516
2578
  notification.title
2517
- ), /* @__PURE__ */ React41.createElement(
2579
+ ), /* @__PURE__ */ React42.createElement(
2518
2580
  Text,
2519
2581
  {
2520
2582
  as: "span",
@@ -2736,14 +2798,14 @@ var ExpandedBankTransactionRow = forwardRef2(
2736
2798
  }, []);
2737
2799
  const className = "Layer__expanded-bank-transaction-row";
2738
2800
  const shouldHide = !isOpen && isOver;
2739
- return /* @__PURE__ */ React42.createElement(
2801
+ return /* @__PURE__ */ React43.createElement(
2740
2802
  "span",
2741
2803
  {
2742
2804
  className: `${className} ${className}--${isOpen ? "expanded" : "collapsed"}`,
2743
2805
  style: { height },
2744
2806
  onTransitionEnd: handleTransitionEnd
2745
2807
  },
2746
- shouldHide ? null : /* @__PURE__ */ React42.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ React42.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React42.createElement(
2808
+ shouldHide ? null : /* @__PURE__ */ React43.createElement("span", { className: `${className}__wrapper`, ref: bodyRef }, /* @__PURE__ */ React43.createElement("div", { className: `${className}__content-toggle` }, /* @__PURE__ */ React43.createElement(
2747
2809
  Toggle,
2748
2810
  {
2749
2811
  name: `purpose-${bankTransaction.id}${asListItem ? "-li" : ""}`,
@@ -2762,13 +2824,13 @@ var ExpandedBankTransactionRow = forwardRef2(
2762
2824
  selected: purpose,
2763
2825
  onChange: onChangePurpose
2764
2826
  }
2765
- )), /* @__PURE__ */ React42.createElement(
2827
+ )), /* @__PURE__ */ React43.createElement(
2766
2828
  "div",
2767
2829
  {
2768
2830
  className: `${className}__content`,
2769
2831
  id: `expanded-${bankTransaction.id}`
2770
2832
  },
2771
- /* @__PURE__ */ React42.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ React42.createElement(
2833
+ /* @__PURE__ */ React43.createElement("div", { className: `${className}__content-panels` }, /* @__PURE__ */ React43.createElement(
2772
2834
  "div",
2773
2835
  {
2774
2836
  className: classNames16(
@@ -2777,7 +2839,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2777
2839
  purpose === "match" /* match */ ? `${className}__content-panel--active` : ""
2778
2840
  )
2779
2841
  },
2780
- /* @__PURE__ */ React42.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React42.createElement(
2842
+ /* @__PURE__ */ React43.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React43.createElement(
2781
2843
  MatchForm,
2782
2844
  {
2783
2845
  classNamePrefix: className,
@@ -2790,7 +2852,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2790
2852
  matchFormError
2791
2853
  }
2792
2854
  ))
2793
- ), /* @__PURE__ */ React42.createElement(
2855
+ ), /* @__PURE__ */ React43.createElement(
2794
2856
  "div",
2795
2857
  {
2796
2858
  className: classNames16(
@@ -2799,13 +2861,13 @@ var ExpandedBankTransactionRow = forwardRef2(
2799
2861
  purpose === "categorize" /* categorize */ ? `${className}__content-panel--active` : ""
2800
2862
  )
2801
2863
  },
2802
- /* @__PURE__ */ React42.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React42.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ React42.createElement(
2864
+ /* @__PURE__ */ React43.createElement("div", { className: `${className}__content-panel-container` }, /* @__PURE__ */ React43.createElement("div", { className: `${className}__splits-inputs` }, rowState.splits.map((split, index) => /* @__PURE__ */ React43.createElement(
2803
2865
  "div",
2804
2866
  {
2805
2867
  className: `${className}__table-cell--split-entry`,
2806
2868
  key: `split-${index}`
2807
2869
  },
2808
- /* @__PURE__ */ React42.createElement(
2870
+ /* @__PURE__ */ React43.createElement(
2809
2871
  Input,
2810
2872
  {
2811
2873
  type: "text",
@@ -2818,12 +2880,12 @@ var ExpandedBankTransactionRow = forwardRef2(
2818
2880
  errorMessage: "Negative values are not allowed"
2819
2881
  }
2820
2882
  ),
2821
- /* @__PURE__ */ React42.createElement(
2883
+ /* @__PURE__ */ React43.createElement(
2822
2884
  "div",
2823
2885
  {
2824
2886
  className: `${className}__table-cell--split-entry__right-col`
2825
2887
  },
2826
- /* @__PURE__ */ React42.createElement(
2888
+ /* @__PURE__ */ React43.createElement(
2827
2889
  CategoryMenu,
2828
2890
  {
2829
2891
  bankTransaction,
@@ -2833,18 +2895,18 @@ var ExpandedBankTransactionRow = forwardRef2(
2833
2895
  className: "Layer__category-menu--full"
2834
2896
  }
2835
2897
  ),
2836
- index > 0 && /* @__PURE__ */ React42.createElement(
2898
+ index > 0 && /* @__PURE__ */ React43.createElement(
2837
2899
  Button,
2838
2900
  {
2839
2901
  className: `${className}__table-cell--split-entry__merge-btn`,
2840
2902
  onClick: () => removeSplit(index),
2841
- rightIcon: /* @__PURE__ */ React42.createElement(Trash_default, { size: 18 }),
2903
+ rightIcon: /* @__PURE__ */ React43.createElement(Trash_default, { size: 18 }),
2842
2904
  variant: "secondary" /* secondary */,
2843
2905
  iconOnly: true
2844
2906
  }
2845
2907
  )
2846
2908
  )
2847
- ))), splitFormError && /* @__PURE__ */ React42.createElement(ErrorText, null, splitFormError), /* @__PURE__ */ React42.createElement("div", { className: `${className}__total-and-btns` }, rowState.splits.length > 1 && /* @__PURE__ */ React42.createElement(
2909
+ ))), splitFormError && /* @__PURE__ */ React43.createElement(ErrorText, null, splitFormError), /* @__PURE__ */ React43.createElement("div", { className: `${className}__total-and-btns` }, rowState.splits.length > 1 && /* @__PURE__ */ React43.createElement(
2848
2910
  Input,
2849
2911
  {
2850
2912
  disabled: true,
@@ -2856,43 +2918,43 @@ var ExpandedBankTransactionRow = forwardRef2(
2856
2918
  )
2857
2919
  )}`
2858
2920
  }
2859
- ), /* @__PURE__ */ React42.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ React42.createElement(
2921
+ ), /* @__PURE__ */ React43.createElement("div", { className: `${className}__splits-buttons` }, rowState.splits.length > 1 ? /* @__PURE__ */ React43.createElement(
2860
2922
  TextButton,
2861
2923
  {
2862
2924
  onClick: addSplit,
2863
2925
  disabled: rowState.splits.length > 5
2864
2926
  },
2865
2927
  "Add new split"
2866
- ) : /* @__PURE__ */ React42.createElement(
2928
+ ) : /* @__PURE__ */ React43.createElement(
2867
2929
  Button,
2868
2930
  {
2869
2931
  onClick: addSplit,
2870
- rightIcon: /* @__PURE__ */ React42.createElement(ScissorsFullOpen_default, { size: 14 }),
2932
+ rightIcon: /* @__PURE__ */ React43.createElement(ScissorsFullOpen_default, { size: 14 }),
2871
2933
  variant: "secondary" /* secondary */,
2872
2934
  disabled: rowState.splits.length > 5
2873
2935
  },
2874
2936
  "Split"
2875
2937
  ))))
2876
2938
  )),
2877
- /* @__PURE__ */ React42.createElement(
2939
+ /* @__PURE__ */ React43.createElement(
2878
2940
  InputGroup,
2879
2941
  {
2880
2942
  className: `${className}__description`,
2881
2943
  name: "description"
2882
2944
  },
2883
- /* @__PURE__ */ React42.createElement(Textarea, { name: "description", placeholder: "Add description" })
2945
+ /* @__PURE__ */ React43.createElement(Textarea, { name: "description", placeholder: "Add description" })
2884
2946
  ),
2885
- /* @__PURE__ */ React42.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ React42.createElement(FileInput, { text: "Upload receipt" })),
2886
- asListItem ? /* @__PURE__ */ React42.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ React42.createElement(
2947
+ /* @__PURE__ */ React43.createElement("div", { className: `${className}__file-upload` }, /* @__PURE__ */ React43.createElement(FileInput, { text: "Upload receipt" })),
2948
+ asListItem ? /* @__PURE__ */ React43.createElement("div", { className: `${className}__submit-btn` }, bankTransaction.error ? /* @__PURE__ */ React43.createElement(
2887
2949
  Text,
2888
2950
  {
2889
2951
  as: "span",
2890
2952
  size: "md" /* md */,
2891
2953
  className: "Layer__unsaved-info"
2892
2954
  },
2893
- /* @__PURE__ */ React42.createElement("span", null, "Unsaved"),
2894
- /* @__PURE__ */ React42.createElement(AlertCircle_default, { size: 12 })
2895
- ) : null, /* @__PURE__ */ React42.createElement(
2955
+ /* @__PURE__ */ React43.createElement("span", null, "Unsaved"),
2956
+ /* @__PURE__ */ React43.createElement(AlertCircle_default, { size: 12 })
2957
+ ) : null, /* @__PURE__ */ React43.createElement(
2896
2958
  SubmitButton,
2897
2959
  {
2898
2960
  onClick: () => {
@@ -2907,7 +2969,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2907
2969
  },
2908
2970
  submitBtnText
2909
2971
  )) : null
2910
- ), /* @__PURE__ */ React42.createElement(
2972
+ ), /* @__PURE__ */ React43.createElement(
2911
2973
  APIErrorNotifications,
2912
2974
  {
2913
2975
  bankTransaction,
@@ -2919,7 +2981,7 @@ var ExpandedBankTransactionRow = forwardRef2(
2919
2981
  );
2920
2982
 
2921
2983
  // src/components/BankTransactionRow/SplitTooltipDetails.tsx
2922
- import React43 from "react";
2984
+ import React44 from "react";
2923
2985
  var SplitTooltipDetails = ({
2924
2986
  classNamePrefix,
2925
2987
  category
@@ -2927,7 +2989,7 @@ var SplitTooltipDetails = ({
2927
2989
  if (!category.entries) {
2928
2990
  return;
2929
2991
  }
2930
- return /* @__PURE__ */ React43.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ React43.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ React43.createElement("li", { key: idx }, /* @__PURE__ */ React43.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ React43.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
2992
+ return /* @__PURE__ */ React44.createElement("span", { className: `${classNamePrefix}__split-tooltip` }, /* @__PURE__ */ React44.createElement("ul", null, category.entries.map((entry, idx) => /* @__PURE__ */ React44.createElement("li", { key: idx }, /* @__PURE__ */ React44.createElement("span", { className: `${classNamePrefix}__split-tooltip__label` }, entry.category.display_name), /* @__PURE__ */ React44.createElement("span", { className: `${classNamePrefix}__split-tooltip__value` }, "$", centsToDollars(entry.amount))))));
2931
2993
  };
2932
2994
 
2933
2995
  // src/components/BankTransactionRow/BankTransactionRow.tsx
@@ -3018,7 +3080,7 @@ var BankTransactionRow = ({
3018
3080
  open ? openClassName : "",
3019
3081
  showComponent ? "show" : ""
3020
3082
  );
3021
- return /* @__PURE__ */ React44.createElement(React44.Fragment, null, /* @__PURE__ */ React44.createElement(
3083
+ return /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
3022
3084
  "tr",
3023
3085
  {
3024
3086
  className: rowClassName,
@@ -3029,21 +3091,21 @@ var BankTransactionRow = ({
3029
3091
  }
3030
3092
  }
3031
3093
  },
3032
- /* @__PURE__ */ React44.createElement(
3094
+ /* @__PURE__ */ React45.createElement(
3033
3095
  "td",
3034
3096
  {
3035
3097
  className: "Layer__table-cell Layer__bank-transaction-table__date-col",
3036
3098
  ...openRow
3037
3099
  },
3038
- /* @__PURE__ */ React44.createElement("span", { className: "Layer__table-cell-content" }, formatTime4(parseISO5(bankTransaction.date), dateFormat))
3100
+ /* @__PURE__ */ React45.createElement("span", { className: "Layer__table-cell-content" }, formatTime4(parseISO5(bankTransaction.date), dateFormat))
3039
3101
  ),
3040
- /* @__PURE__ */ React44.createElement(
3102
+ /* @__PURE__ */ React45.createElement(
3041
3103
  "td",
3042
3104
  {
3043
3105
  className: "Layer__table-cell Layer__bank-transactions__tx-col",
3044
3106
  ...openRow
3045
3107
  },
3046
- /* @__PURE__ */ React44.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React44.createElement(
3108
+ /* @__PURE__ */ React45.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React45.createElement(
3047
3109
  Text,
3048
3110
  {
3049
3111
  as: "span",
@@ -3056,13 +3118,13 @@ var BankTransactionRow = ({
3056
3118
  bankTransaction.counterparty_name ?? bankTransaction.description
3057
3119
  ))
3058
3120
  ),
3059
- /* @__PURE__ */ React44.createElement(
3121
+ /* @__PURE__ */ React45.createElement(
3060
3122
  "td",
3061
3123
  {
3062
3124
  className: "Layer__table-cell Layer__bank-transactions__account-col",
3063
3125
  ...openRow
3064
3126
  },
3065
- /* @__PURE__ */ React44.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React44.createElement(
3127
+ /* @__PURE__ */ React45.createElement("span", { className: "Layer__table-cell-content" }, /* @__PURE__ */ React45.createElement(
3066
3128
  Text,
3067
3129
  {
3068
3130
  as: "span",
@@ -3072,15 +3134,15 @@ var BankTransactionRow = ({
3072
3134
  bankTransaction.account_name ?? ""
3073
3135
  ))
3074
3136
  ),
3075
- /* @__PURE__ */ React44.createElement(
3137
+ /* @__PURE__ */ React45.createElement(
3076
3138
  "td",
3077
3139
  {
3078
3140
  className: `Layer__table-cell Layer__table-cell__amount-col Layer__bank-transactions__amount-col Layer__table-cell--amount ${className}__table-cell--amount-${isCredit(bankTransaction) ? "credit" : "debit"}`,
3079
3141
  ...openRow
3080
3142
  },
3081
- /* @__PURE__ */ React44.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
3143
+ /* @__PURE__ */ React45.createElement("span", { className: "Layer__table-cell-content" }, isCredit(bankTransaction) ? "+$" : " $", centsToDollars(bankTransaction.amount))
3082
3144
  ),
3083
- /* @__PURE__ */ React44.createElement(
3145
+ /* @__PURE__ */ React45.createElement(
3084
3146
  "td",
3085
3147
  {
3086
3148
  className: classNames17(
@@ -3090,12 +3152,12 @@ var BankTransactionRow = ({
3090
3152
  `${className}__actions-cell--${open ? "open" : "close"}`
3091
3153
  )
3092
3154
  },
3093
- /* @__PURE__ */ React44.createElement(
3155
+ /* @__PURE__ */ React45.createElement(
3094
3156
  "span",
3095
3157
  {
3096
3158
  className: `${className}__actions-container Layer__table-cell-content`
3097
3159
  },
3098
- editable && !open ? /* @__PURE__ */ React44.createElement(
3160
+ editable && !open ? /* @__PURE__ */ React45.createElement(
3099
3161
  CategorySelect,
3100
3162
  {
3101
3163
  bankTransaction,
@@ -3108,11 +3170,11 @@ var BankTransactionRow = ({
3108
3170
  disabled: bankTransaction.processing
3109
3171
  }
3110
3172
  ) : null,
3111
- !editable && !open ? /* @__PURE__ */ React44.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ React44.createElement(React44.Fragment, null, /* @__PURE__ */ React44.createElement(
3173
+ !editable && !open ? /* @__PURE__ */ React45.createElement(Text, { as: "span", className: `${className}__category-text` }, bankTransaction.categorization_status === "SPLIT" /* SPLIT */ && /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
3112
3174
  Badge,
3113
3175
  {
3114
- icon: /* @__PURE__ */ React44.createElement(Scissors_default, { size: 11 }),
3115
- tooltip: /* @__PURE__ */ React44.createElement(
3176
+ icon: /* @__PURE__ */ React45.createElement(Scissors_default, { size: 11 }),
3177
+ tooltip: /* @__PURE__ */ React45.createElement(
3116
3178
  SplitTooltipDetails,
3117
3179
  {
3118
3180
  classNamePrefix: className,
@@ -3121,18 +3183,18 @@ var BankTransactionRow = ({
3121
3183
  )
3122
3184
  },
3123
3185
  "Split"
3124
- ), /* @__PURE__ */ React44.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ React44.createElement(React44.Fragment, null, /* @__PURE__ */ React44.createElement(
3186
+ ), /* @__PURE__ */ React45.createElement("span", { className: `${className}__category-text__text` }, extractDescriptionForSplit(bankTransaction.category))), bankTransaction?.categorization_status === "MATCHED" /* MATCHED */ && bankTransaction?.match && /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
3125
3187
  MatchBadge,
3126
3188
  {
3127
3189
  classNamePrefix: className,
3128
3190
  bankTransaction,
3129
3191
  dateFormat
3130
3192
  }
3131
- ), /* @__PURE__ */ React44.createElement("span", { className: `${className}__category-text__text` }, `${formatTime4(
3193
+ ), /* @__PURE__ */ React45.createElement("span", { className: `${className}__category-text__text` }, `${formatTime4(
3132
3194
  parseISO5(bankTransaction.match.bank_transaction.date),
3133
3195
  dateFormat
3134
- )}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ React44.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
3135
- editable && !open && showRetry ? /* @__PURE__ */ React44.createElement(
3196
+ )}, ${bankTransaction.match.bank_transaction.description}`)), bankTransaction?.categorization_status !== "MATCHED" /* MATCHED */ && bankTransaction?.categorization_status !== "SPLIT" /* SPLIT */ && /* @__PURE__ */ React45.createElement("span", { className: `${className}__category-text__text` }, bankTransaction?.category?.display_name)) : null,
3197
+ editable && !open && showRetry ? /* @__PURE__ */ React45.createElement(
3136
3198
  RetryButton,
3137
3199
  {
3138
3200
  onClick: () => {
@@ -3146,17 +3208,17 @@ var BankTransactionRow = ({
3146
3208
  },
3147
3209
  "Retry"
3148
3210
  ) : null,
3149
- open && bankTransaction.error ? /* @__PURE__ */ React44.createElement(
3211
+ open && bankTransaction.error ? /* @__PURE__ */ React45.createElement(
3150
3212
  Text,
3151
3213
  {
3152
3214
  as: "span",
3153
3215
  size: "md" /* md */,
3154
3216
  className: "Layer__unsaved-info"
3155
3217
  },
3156
- /* @__PURE__ */ React44.createElement("span", null, "Unsaved"),
3157
- /* @__PURE__ */ React44.createElement(AlertCircle_default, { size: 12 })
3218
+ /* @__PURE__ */ React45.createElement("span", null, "Unsaved"),
3219
+ /* @__PURE__ */ React45.createElement(AlertCircle_default, { size: 12 })
3158
3220
  ) : null,
3159
- editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */ React44.createElement(
3221
+ editable && (open || !open && !showRetry) || !editable && open ? /* @__PURE__ */ React45.createElement(
3160
3222
  SubmitButton,
3161
3223
  {
3162
3224
  onClick: () => {
@@ -3171,13 +3233,13 @@ var BankTransactionRow = ({
3171
3233
  },
3172
3234
  editable ? "Approve" : "Update"
3173
3235
  ) : null,
3174
- /* @__PURE__ */ React44.createElement(
3236
+ /* @__PURE__ */ React45.createElement(
3175
3237
  IconButton,
3176
3238
  {
3177
3239
  onClick: toggleOpen,
3178
3240
  className: "Layer__bank-transaction-row__expand-button",
3179
3241
  active: open,
3180
- icon: /* @__PURE__ */ React44.createElement(
3242
+ icon: /* @__PURE__ */ React45.createElement(
3181
3243
  ChevronDownFill_default,
3182
3244
  {
3183
3245
  className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
@@ -3187,7 +3249,7 @@ var BankTransactionRow = ({
3187
3249
  )
3188
3250
  )
3189
3251
  )
3190
- ), /* @__PURE__ */ React44.createElement("tr", null, /* @__PURE__ */ React44.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ React44.createElement(
3252
+ ), /* @__PURE__ */ React45.createElement("tr", null, /* @__PURE__ */ React45.createElement("td", { colSpan: 5, className: "Layer__bank-transaction-row__expanded-td" }, /* @__PURE__ */ React45.createElement(
3191
3253
  ExpandedBankTransactionRow,
3192
3254
  {
3193
3255
  ref: expandedRowRef,
@@ -3200,11 +3262,11 @@ var BankTransactionRow = ({
3200
3262
  };
3201
3263
 
3202
3264
  // src/components/BankTransactionListItem/Assignment.tsx
3203
- import React45 from "react";
3265
+ import React46 from "react";
3204
3266
  import { parseISO as parseISO6, format as formatTime5 } from "date-fns";
3205
3267
  var Assignment = ({ bankTransaction }) => {
3206
3268
  if (bankTransaction.match && bankTransaction.categorization_status === "MATCHED" /* MATCHED */) {
3207
- return /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
3269
+ return /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(
3208
3270
  MatchBadge,
3209
3271
  {
3210
3272
  classNamePrefix: "Layer__bank-transaction-list-item",
@@ -3212,17 +3274,17 @@ var Assignment = ({ bankTransaction }) => {
3212
3274
  dateFormat: DATE_FORMAT,
3213
3275
  text: "Matched"
3214
3276
  }
3215
- ), /* @__PURE__ */ React45.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${formatTime5(
3277
+ ), /* @__PURE__ */ React46.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, `${formatTime5(
3216
3278
  parseISO6(bankTransaction.match.bank_transaction.date),
3217
3279
  DATE_FORMAT
3218
3280
  )}, ${bankTransaction.match.bank_transaction.description}`));
3219
3281
  }
3220
3282
  if (bankTransaction.categorization_status === "SPLIT" /* SPLIT */) {
3221
- return /* @__PURE__ */ React45.createElement(React45.Fragment, null, /* @__PURE__ */ React45.createElement(
3283
+ return /* @__PURE__ */ React46.createElement(React46.Fragment, null, /* @__PURE__ */ React46.createElement(
3222
3284
  Badge,
3223
3285
  {
3224
- icon: /* @__PURE__ */ React45.createElement(Scissors_default, { size: 11 }),
3225
- tooltip: /* @__PURE__ */ React45.createElement(
3286
+ icon: /* @__PURE__ */ React46.createElement(Scissors_default, { size: 11 }),
3287
+ tooltip: /* @__PURE__ */ React46.createElement(
3226
3288
  SplitTooltipDetails,
3227
3289
  {
3228
3290
  classNamePrefix: "Layer__bank-transaction-list-item",
@@ -3231,9 +3293,9 @@ var Assignment = ({ bankTransaction }) => {
3231
3293
  )
3232
3294
  },
3233
3295
  "Split"
3234
- ), /* @__PURE__ */ React45.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
3296
+ ), /* @__PURE__ */ React46.createElement(Text, { className: "Layer__bank-transaction-list-item__category-text__text" }, extractDescriptionForSplit(bankTransaction.category)));
3235
3297
  }
3236
- return /* @__PURE__ */ React45.createElement(Text, null, bankTransaction?.category?.display_name);
3298
+ return /* @__PURE__ */ React46.createElement(Text, null, bankTransaction?.category?.display_name);
3237
3299
  };
3238
3300
 
3239
3301
  // src/components/BankTransactionListItem/BankTransactionListItem.tsx
@@ -3302,26 +3364,26 @@ var BankTransactionListItem = ({
3302
3364
  open ? openClassName : "",
3303
3365
  showComponent ? "show" : ""
3304
3366
  );
3305
- return /* @__PURE__ */ React46.createElement("li", { className: rowClassName }, /* @__PURE__ */ React46.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ React46.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ React46.createElement("span", { className: `${className}__heading-date` }, formatTime6(parseISO7(bankTransaction.date), dateFormat)), /* @__PURE__ */ React46.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ React46.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ React46.createElement(
3367
+ return /* @__PURE__ */ React47.createElement("li", { className: rowClassName }, /* @__PURE__ */ React47.createElement("span", { className: `${className}__heading` }, /* @__PURE__ */ React47.createElement("div", { className: `${className}__heading__main` }, /* @__PURE__ */ React47.createElement("span", { className: `${className}__heading-date` }, formatTime6(parseISO7(bankTransaction.date), dateFormat)), /* @__PURE__ */ React47.createElement("span", { className: `${className}__heading-separator` }), /* @__PURE__ */ React47.createElement("span", { className: `${className}__heading-account-name` }, bankTransaction.account_name ?? "")), /* @__PURE__ */ React47.createElement(
3306
3368
  "div",
3307
3369
  {
3308
3370
  onClick: toggleOpen,
3309
3371
  className: "Layer__bank-transaction-row__expand-button"
3310
3372
  },
3311
- /* @__PURE__ */ React46.createElement(
3373
+ /* @__PURE__ */ React47.createElement(
3312
3374
  ChevronDownFill_default,
3313
3375
  {
3314
3376
  className: `Layer__chevron ${open ? "Layer__chevron__up" : "Layer__chevron__down"}`
3315
3377
  }
3316
3378
  )
3317
- )), /* @__PURE__ */ React46.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ React46.createElement("span", { className: `${className}__body__name` }, /* @__PURE__ */ React46.createElement(Text, { as: "span", withTooltip: "whenTruncated" /* whenTruncated */ }, bankTransaction.counterparty_name ?? bankTransaction.description)), /* @__PURE__ */ React46.createElement(
3379
+ )), /* @__PURE__ */ React47.createElement("span", { className: `${className}__body` }, /* @__PURE__ */ React47.createElement("span", { className: `${className}__body__name` }, /* @__PURE__ */ React47.createElement(Text, { as: "span", withTooltip: "whenTruncated" /* whenTruncated */ }, bankTransaction.counterparty_name ?? bankTransaction.description)), /* @__PURE__ */ React47.createElement(
3318
3380
  "span",
3319
3381
  {
3320
3382
  className: `${className}__amount-${isCredit2(bankTransaction) ? "credit" : "debit"}`
3321
3383
  },
3322
3384
  isCredit2(bankTransaction) ? "+$" : " $",
3323
3385
  centsToDollars(bankTransaction.amount)
3324
- )), /* @__PURE__ */ React46.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React46.createElement(
3386
+ )), /* @__PURE__ */ React47.createElement("span", { className: `${className}__expanded-row` }, /* @__PURE__ */ React47.createElement(
3325
3387
  ExpandedBankTransactionRow,
3326
3388
  {
3327
3389
  ref: expandedRowRef,
@@ -3332,7 +3394,7 @@ var BankTransactionListItem = ({
3332
3394
  submitBtnText: editable ? "Approve" : "Update",
3333
3395
  containerWidth
3334
3396
  }
3335
- )), /* @__PURE__ */ React46.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ React46.createElement(
3397
+ )), /* @__PURE__ */ React47.createElement("span", { className: `${className}__base-row` }, editable ? /* @__PURE__ */ React47.createElement(
3336
3398
  CategorySelect,
3337
3399
  {
3338
3400
  bankTransaction,
@@ -3344,7 +3406,7 @@ var BankTransactionListItem = ({
3344
3406
  },
3345
3407
  disabled: bankTransaction.processing
3346
3408
  }
3347
- ) : null, !editable ? /* @__PURE__ */ React46.createElement(Assignment, { bankTransaction }) : null, editable && !showRetry ? /* @__PURE__ */ React46.createElement(
3409
+ ) : null, !editable ? /* @__PURE__ */ React47.createElement(Assignment, { bankTransaction }) : null, editable && !showRetry ? /* @__PURE__ */ React47.createElement(
3348
3410
  SubmitButton,
3349
3411
  {
3350
3412
  onClick: () => {
@@ -3357,7 +3419,7 @@ var BankTransactionListItem = ({
3357
3419
  action: editable ? "save" /* SAVE */ : "update" /* UPDATE */
3358
3420
  },
3359
3421
  editable ? "Approve" : "Update"
3360
- ) : null, editable && showRetry ? /* @__PURE__ */ React46.createElement(
3422
+ ) : null, editable && showRetry ? /* @__PURE__ */ React47.createElement(
3361
3423
  RetryButton,
3362
3424
  {
3363
3425
  onClick: () => {
@@ -3370,11 +3432,11 @@ var BankTransactionListItem = ({
3370
3432
  error: "Approval failed. Check connection and retry in few seconds."
3371
3433
  },
3372
3434
  "Retry"
3373
- ) : null), bankTransaction.error && showRetry ? /* @__PURE__ */ React46.createElement(ErrorText, null, "Approval failed. Check connection and retry in few seconds.") : null);
3435
+ ) : null), bankTransaction.error && showRetry ? /* @__PURE__ */ React47.createElement(ErrorText, null, "Approval failed. Check connection and retry in few seconds.") : null);
3374
3436
  };
3375
3437
 
3376
3438
  // src/components/Container/Container.tsx
3377
- import React47, { forwardRef as forwardRef3 } from "react";
3439
+ import React48, { forwardRef as forwardRef3 } from "react";
3378
3440
 
3379
3441
  // src/config/theme.ts
3380
3442
  var SHADES = {
@@ -3613,28 +3675,30 @@ var Container = forwardRef3(
3613
3675
  );
3614
3676
  const { theme } = useLayerContext();
3615
3677
  const styles = parseStylesFromThemeConfig(theme);
3616
- return /* @__PURE__ */ React47.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
3678
+ return /* @__PURE__ */ React48.createElement("div", { ref, className: baseClassName, style: { ...styles } }, children);
3617
3679
  }
3618
3680
  );
3619
3681
 
3620
3682
  // src/components/Container/Header.tsx
3621
- import React48, { forwardRef as forwardRef4 } from "react";
3683
+ import React49, { forwardRef as forwardRef4 } from "react";
3622
3684
  import classNames20 from "classnames";
3623
3685
  var Header = forwardRef4(
3624
3686
  ({ className, children, style }, ref) => {
3625
3687
  const baseClassName = classNames20("Layer__component-header", className);
3626
- return /* @__PURE__ */ React48.createElement("header", { ref, className: baseClassName, style }, children);
3688
+ return /* @__PURE__ */ React49.createElement("header", { ref, className: baseClassName, style }, children);
3627
3689
  }
3628
3690
  );
3629
3691
 
3630
3692
  // src/components/DataState/DataState.tsx
3631
- import React49 from "react";
3693
+ import React50 from "react";
3632
3694
  var getIcon = (status) => {
3633
3695
  switch (status) {
3634
3696
  case "failed" /* failed */:
3635
- return /* @__PURE__ */ React49.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ React49.createElement(AlertOctagon_default, { size: 12 }));
3697
+ return /* @__PURE__ */ React50.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--error" }, /* @__PURE__ */ React50.createElement(AlertOctagon_default, { size: 12 }));
3698
+ case "info" /* info */:
3699
+ return /* @__PURE__ */ React50.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ React50.createElement(AlertOctagon_default, { size: 12 }));
3636
3700
  default:
3637
- return /* @__PURE__ */ React49.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ React49.createElement(CheckCircle_default, { size: 12 }));
3701
+ return /* @__PURE__ */ React50.createElement("span", { className: "Layer__data-state__icon Layer__data-state__icon--neutral" }, /* @__PURE__ */ React50.createElement(CheckCircle_default, { size: 12 }));
3638
3702
  }
3639
3703
  };
3640
3704
  var DataState = ({
@@ -3644,7 +3708,7 @@ var DataState = ({
3644
3708
  onRefresh,
3645
3709
  isLoading
3646
3710
  }) => {
3647
- return /* @__PURE__ */ React49.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ React49.createElement(
3711
+ return /* @__PURE__ */ React50.createElement("div", { className: "Layer__data-state" }, getIcon(status), /* @__PURE__ */ React50.createElement(
3648
3712
  Text,
3649
3713
  {
3650
3714
  as: "span",
@@ -3653,11 +3717,11 @@ var DataState = ({
3653
3717
  className: "Layer__data-state__title"
3654
3718
  },
3655
3719
  title
3656
- ), /* @__PURE__ */ React49.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ React49.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ React49.createElement(
3720
+ ), /* @__PURE__ */ React50.createElement(Text, { as: "span", className: "Layer__data-state__description" }, description), onRefresh && /* @__PURE__ */ React50.createElement("span", { className: "Layer__data-state__btn" }, /* @__PURE__ */ React50.createElement(
3657
3721
  Button,
3658
3722
  {
3659
3723
  variant: "secondary" /* secondary */,
3660
- rightIcon: isLoading ? /* @__PURE__ */ React49.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ React49.createElement(RefreshCcw_default, { size: 12 }),
3724
+ rightIcon: isLoading ? /* @__PURE__ */ React50.createElement(Loader_default, { size: 14, className: "Layer__anim--rotating" }) : /* @__PURE__ */ React50.createElement(RefreshCcw_default, { size: 12 }),
3661
3725
  onClick: onRefresh,
3662
3726
  disabled: isLoading
3663
3727
  },
@@ -3666,13 +3730,13 @@ var DataState = ({
3666
3730
  };
3667
3731
 
3668
3732
  // src/components/Loader/Loader.tsx
3669
- import React50 from "react";
3733
+ import React51 from "react";
3670
3734
  var Loader2 = ({ children }) => {
3671
- return /* @__PURE__ */ React50.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ React50.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
3735
+ return /* @__PURE__ */ React51.createElement("span", { className: "Layer__loader" }, /* @__PURE__ */ React51.createElement(Loader_default, { size: 28, className: "Layer__anim--rotating" }), children);
3672
3736
  };
3673
3737
 
3674
3738
  // src/components/Pagination/Pagination.tsx
3675
- import React53 from "react";
3739
+ import React54 from "react";
3676
3740
 
3677
3741
  // src/hooks/usePagination/usePagination.ts
3678
3742
  import { useMemo } from "react";
@@ -3720,8 +3784,8 @@ var usePagination = ({
3720
3784
  };
3721
3785
 
3722
3786
  // src/icons/ChevronLeft.tsx
3723
- import * as React51 from "react";
3724
- var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createElement(
3787
+ import * as React52 from "react";
3788
+ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createElement(
3725
3789
  "svg",
3726
3790
  {
3727
3791
  xmlns: "http://www.w3.org/2000/svg",
@@ -3731,7 +3795,7 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
3731
3795
  fill: "none",
3732
3796
  ...props
3733
3797
  },
3734
- /* @__PURE__ */ React51.createElement(
3798
+ /* @__PURE__ */ React52.createElement(
3735
3799
  "path",
3736
3800
  {
3737
3801
  d: "M11.25 13.5L6.75 9L11.25 4.5",
@@ -3744,8 +3808,8 @@ var ChevronLeft = ({ size = 18, ...props }) => /* @__PURE__ */ React51.createEle
3744
3808
  var ChevronLeft_default = ChevronLeft;
3745
3809
 
3746
3810
  // src/icons/ChevronRight.tsx
3747
- import * as React52 from "react";
3748
- var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createElement(
3811
+ import * as React53 from "react";
3812
+ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React53.createElement(
3749
3813
  "svg",
3750
3814
  {
3751
3815
  xmlns: "http://www.w3.org/2000/svg",
@@ -3755,7 +3819,7 @@ var ChavronRight = ({ size = 18, ...props }) => /* @__PURE__ */ React52.createEl
3755
3819
  fill: "none",
3756
3820
  ...props
3757
3821
  },
3758
- /* @__PURE__ */ React52.createElement(
3822
+ /* @__PURE__ */ React53.createElement(
3759
3823
  "path",
3760
3824
  {
3761
3825
  d: "M6.75 13.5L11.25 9L6.75 4.5",
@@ -3789,7 +3853,7 @@ var Pagination = ({
3789
3853
  return;
3790
3854
  }
3791
3855
  let lastPage = paginationRange[paginationRange.length - 1];
3792
- return /* @__PURE__ */ React53.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ React53.createElement(
3856
+ return /* @__PURE__ */ React54.createElement("ul", { className: "Layer__pagination" }, /* @__PURE__ */ React54.createElement(
3793
3857
  "li",
3794
3858
  {
3795
3859
  key: `page-prev`,
@@ -3801,12 +3865,12 @@ var Pagination = ({
3801
3865
  ),
3802
3866
  onClick: () => onPageChange(currentPage - 1)
3803
3867
  },
3804
- /* @__PURE__ */ React53.createElement(ChevronLeft_default, { size: 12 })
3868
+ /* @__PURE__ */ React54.createElement(ChevronLeft_default, { size: 12 })
3805
3869
  ), paginationRange.map((pageNumber) => {
3806
3870
  if (pageNumber === DOTS) {
3807
- return /* @__PURE__ */ React53.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
3871
+ return /* @__PURE__ */ React54.createElement("li", { className: "Layer__pagination-item Layer__pagination-dots" }, "\u2026");
3808
3872
  }
3809
- return /* @__PURE__ */ React53.createElement(
3873
+ return /* @__PURE__ */ React54.createElement(
3810
3874
  "li",
3811
3875
  {
3812
3876
  key: `page-${pageNumber}`,
@@ -3821,7 +3885,7 @@ var Pagination = ({
3821
3885
  },
3822
3886
  pageNumber
3823
3887
  );
3824
- }), /* @__PURE__ */ React53.createElement(
3888
+ }), /* @__PURE__ */ React54.createElement(
3825
3889
  "li",
3826
3890
  {
3827
3891
  key: `page-last`,
@@ -3833,7 +3897,7 @@ var Pagination = ({
3833
3897
  ),
3834
3898
  onClick: () => onPageChange(currentPage + 1)
3835
3899
  },
3836
- /* @__PURE__ */ React53.createElement(ChevronRight_default, { size: 12 })
3900
+ /* @__PURE__ */ React54.createElement(ChevronRight_default, { size: 12 })
3837
3901
  ));
3838
3902
  };
3839
3903
 
@@ -3905,7 +3969,7 @@ var BankTransactions = ({
3905
3969
  debounceContainerWidth(size?.width);
3906
3970
  });
3907
3971
  const editable = display === "review" /* review */;
3908
- return /* @__PURE__ */ React54.createElement(
3972
+ return /* @__PURE__ */ React55.createElement(
3909
3973
  Container,
3910
3974
  {
3911
3975
  className: editable ? "Layer__bank-transactions--to-review" : "Layer__bank-transactions--categorized",
@@ -3913,14 +3977,14 @@ var BankTransactions = ({
3913
3977
  asWidget,
3914
3978
  ref: containerRef
3915
3979
  },
3916
- /* @__PURE__ */ React54.createElement(
3980
+ /* @__PURE__ */ React55.createElement(
3917
3981
  Header,
3918
3982
  {
3919
3983
  className: "Layer__bank-transactions__header",
3920
3984
  style: { top: shiftStickyHeader }
3921
3985
  },
3922
- /* @__PURE__ */ React54.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
3923
- /* @__PURE__ */ React54.createElement(
3986
+ /* @__PURE__ */ React55.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Transactions"),
3987
+ /* @__PURE__ */ React55.createElement(
3924
3988
  Toggle,
3925
3989
  {
3926
3990
  name: "bank-transaction-display",
@@ -3933,15 +3997,15 @@ var BankTransactions = ({
3933
3997
  }
3934
3998
  )
3935
3999
  ),
3936
- !listView && /* @__PURE__ */ React54.createElement(
4000
+ !listView && /* @__PURE__ */ React55.createElement(
3937
4001
  "table",
3938
4002
  {
3939
4003
  width: "100%",
3940
4004
  className: "Layer__table Layer__bank-transactions__table with-cell-separators"
3941
4005
  },
3942
- /* @__PURE__ */ React54.createElement("thead", null, /* @__PURE__ */ React54.createElement("tr", null, /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ React54.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
3943
- /* @__PURE__ */ React54.createElement("tbody", null, !isLoading && bankTransactions?.map(
3944
- (bankTransaction, index) => /* @__PURE__ */ React54.createElement(
4006
+ /* @__PURE__ */ React55.createElement("thead", null, /* @__PURE__ */ React55.createElement("tr", null, /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__bank-transactions__date-col" }, "Date"), /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__bank-transactions__tx-col" }, "Transaction"), /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__bank-transactions__account-col" }, "Account"), /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__table-cell--amount Layer__table-cell__amount-col" }, "Amount"), editable ? /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__table-header--primary Layer__table-cell__category-col" }, "Categorize") : /* @__PURE__ */ React55.createElement("th", { className: "Layer__table-header Layer__table-cell__category-col" }, "Category"))),
4007
+ /* @__PURE__ */ React55.createElement("tbody", null, !isLoading && bankTransactions?.map(
4008
+ (bankTransaction, index) => /* @__PURE__ */ React55.createElement(
3945
4009
  BankTransactionRow,
3946
4010
  {
3947
4011
  index,
@@ -3955,9 +4019,9 @@ var BankTransactions = ({
3955
4019
  )
3956
4020
  ))
3957
4021
  ),
3958
- isLoading && !bankTransactions ? /* @__PURE__ */ React54.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ React54.createElement(Loader2, null)) : null,
3959
- !isLoading && listView ? /* @__PURE__ */ React54.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map(
3960
- (bankTransaction, index) => /* @__PURE__ */ React54.createElement(
4022
+ isLoading && !bankTransactions ? /* @__PURE__ */ React55.createElement("div", { className: "Layer__bank-transactions__loader-container" }, /* @__PURE__ */ React55.createElement(Loader2, null)) : null,
4023
+ !isLoading && listView ? /* @__PURE__ */ React55.createElement("ul", { className: "Layer__bank-transactions__list" }, bankTransactions?.map(
4024
+ (bankTransaction, index) => /* @__PURE__ */ React55.createElement(
3961
4025
  BankTransactionListItem,
3962
4026
  {
3963
4027
  index,
@@ -3970,7 +4034,7 @@ var BankTransactions = ({
3970
4034
  }
3971
4035
  )
3972
4036
  )) : null,
3973
- !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ React54.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React54.createElement(
4037
+ !isLoading && !error && (bankTransactions === void 0 || bankTransactions !== void 0 && bankTransactions.length === 0) ? /* @__PURE__ */ React55.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React55.createElement(
3974
4038
  DataState,
3975
4039
  {
3976
4040
  status: "allDone" /* allDone */,
@@ -3980,7 +4044,7 @@ var BankTransactions = ({
3980
4044
  isLoading: isValidating
3981
4045
  }
3982
4046
  )) : null,
3983
- !isLoading && error ? /* @__PURE__ */ React54.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React54.createElement(
4047
+ !isLoading && error ? /* @__PURE__ */ React55.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React55.createElement(
3984
4048
  DataState,
3985
4049
  {
3986
4050
  status: "failed" /* failed */,
@@ -3990,7 +4054,7 @@ var BankTransactions = ({
3990
4054
  isLoading: isValidating
3991
4055
  }
3992
4056
  )) : null,
3993
- /* @__PURE__ */ React54.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ React54.createElement(
4057
+ /* @__PURE__ */ React55.createElement("div", { className: "Layer__bank-transactions__pagination" }, /* @__PURE__ */ React55.createElement(
3994
4058
  Pagination,
3995
4059
  {
3996
4060
  currentPage,
@@ -4003,7 +4067,7 @@ var BankTransactions = ({
4003
4067
  };
4004
4068
 
4005
4069
  // src/components/Hello/Hello.tsx
4006
- import React55 from "react";
4070
+ import React56 from "react";
4007
4071
  import useSWR3 from "swr";
4008
4072
  var fetcher = (url) => fetch(url).then((res) => res.json());
4009
4073
  var Hello = ({ user }) => {
@@ -4012,33 +4076,30 @@ var Hello = ({ user }) => {
4012
4076
  fetcher
4013
4077
  );
4014
4078
  const name = (isLoading ? "..." : data?.name) || "User";
4015
- return /* @__PURE__ */ React55.createElement(React55.Fragment, null, /* @__PURE__ */ React55.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
4079
+ return /* @__PURE__ */ React56.createElement(React56.Fragment, null, /* @__PURE__ */ React56.createElement("div", { className: "hello" }, "Hello, ", name, "!"));
4016
4080
  };
4017
4081
 
4018
4082
  // src/components/LinkedAccounts/LinkedAccounts.tsx
4019
- import React57 from "react";
4083
+ import React58 from "react";
4020
4084
 
4021
4085
  // src/hooks/useLinkedAccounts/useLinkedAccounts.ts
4022
4086
  import { useEffect as useEffect7, useState as useState11 } from "react";
4023
4087
  var MOCK_DATA = [
4024
4088
  {
4025
- name: "Public Demo Banking",
4089
+ name: "Business Checking",
4026
4090
  account: "1234",
4027
4091
  amount: 1220620
4092
+ },
4093
+ {
4094
+ name: "Business Savings",
4095
+ account: "5678",
4096
+ amount: 10002062e-1
4097
+ },
4098
+ {
4099
+ name: "Account",
4100
+ account: "4321",
4101
+ amount: 4400020620
4028
4102
  }
4029
- /* Temporarily removing these to make it match test data (with one account)
4030
- * we're using in the demo.
4031
- */
4032
- // {
4033
- // name: 'Business Savings',
4034
- // account: '5678',
4035
- // amount: 1000206.2,
4036
- // },
4037
- // {
4038
- // name: 'Account',
4039
- // account: '4321',
4040
- // amount: 801.91,
4041
- // },
4042
4103
  ];
4043
4104
  var useLinkedAccounts = () => {
4044
4105
  const { auth, businessId, apiUrl } = useLayerContext();
@@ -4069,23 +4130,23 @@ var useLinkedAccounts = () => {
4069
4130
  };
4070
4131
 
4071
4132
  // src/components/LinkedAccounts/LinkedAccountThumb.tsx
4072
- import React56 from "react";
4133
+ import React57 from "react";
4073
4134
  var LinkedAccountThumb = ({ account }) => {
4074
- return /* @__PURE__ */ React56.createElement("div", { className: "Layer__linked-account-thumb" }, /* @__PURE__ */ React56.createElement("div", { className: "topbar" }, /* @__PURE__ */ React56.createElement(Text, { as: "span", className: "account-name" }, account.name), /* @__PURE__ */ React56.createElement(Text, { as: "span", className: "account-number" }, "\u2022\u2022\u2022", account.account)), /* @__PURE__ */ React56.createElement("div", { className: "bottombar" }, /* @__PURE__ */ React56.createElement(Text, { as: "span", className: "account-amount" }, "$", centsToDollars(account.amount))));
4135
+ return /* @__PURE__ */ React57.createElement("div", { className: "Layer__linked-account-thumb" }, /* @__PURE__ */ React57.createElement("div", { className: "topbar" }, /* @__PURE__ */ React57.createElement(Text, { as: "span", className: "account-name" }, account.name), /* @__PURE__ */ React57.createElement(Text, { as: "span", className: "account-number" }, "\u2022\u2022\u2022", account.account)), /* @__PURE__ */ React57.createElement("div", { className: "bottombar" }, /* @__PURE__ */ React57.createElement(Text, { as: "span", className: "account-amount" }, "$", centsToDollars(account.amount))));
4075
4136
  };
4076
4137
 
4077
4138
  // src/components/LinkedAccounts/LinkedAccounts.tsx
4078
4139
  var COMPONENT_NAME2 = "linked-accounts";
4079
4140
  var LinkedAccounts = () => {
4080
4141
  const { data, isLoading, error, isValidating, refetch } = useLinkedAccounts();
4081
- return /* @__PURE__ */ React57.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ React57.createElement(Header, { className: "Layer__linked-accounts__header" }, /* @__PURE__ */ React57.createElement(
4142
+ return /* @__PURE__ */ React58.createElement(Container, { name: COMPONENT_NAME2 }, /* @__PURE__ */ React58.createElement(Header, { className: "Layer__linked-accounts__header" }, /* @__PURE__ */ React58.createElement(
4082
4143
  Heading,
4083
4144
  {
4084
4145
  className: "Layer__linked-accounts__title",
4085
4146
  size: "secondary" /* secondary */
4086
4147
  },
4087
4148
  "Linked Accounts"
4088
- )), isLoading && /* @__PURE__ */ React57.createElement("div", { className: "Layer__linked-accounts__loader-container" }, /* @__PURE__ */ React57.createElement(Loader2, null)), error && !isLoading ? /* @__PURE__ */ React57.createElement(
4149
+ )), isLoading && /* @__PURE__ */ React58.createElement("div", { className: "Layer__linked-accounts__loader-container" }, /* @__PURE__ */ React58.createElement(Loader2, null)), error && !isLoading ? /* @__PURE__ */ React58.createElement(
4089
4150
  DataState,
4090
4151
  {
4091
4152
  status: "failed" /* failed */,
@@ -4094,11 +4155,11 @@ var LinkedAccounts = () => {
4094
4155
  onRefresh: () => refetch(),
4095
4156
  isLoading: isValidating
4096
4157
  }
4097
- ) : null, !error && !isLoading ? /* @__PURE__ */ React57.createElement("div", { className: "Layer__linked-accounts__list" }, data?.map((account, index) => /* @__PURE__ */ React57.createElement(LinkedAccountThumb, { account, key: `linked-acc-${index}` }))) : null);
4158
+ ) : null, !error && !isLoading ? /* @__PURE__ */ React58.createElement("div", { className: "Layer__linked-accounts__list" }, data?.map((account, index) => /* @__PURE__ */ React58.createElement(LinkedAccountThumb, { account, key: `linked-acc-${index}` }))) : null);
4098
4159
  };
4099
4160
 
4100
4161
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
4101
- import React65, { createContext as createContext2 } from "react";
4162
+ import React68, { createContext as createContext2 } from "react";
4102
4163
 
4103
4164
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
4104
4165
  import { useMemo as useMemo3, useState as useState12 } from "react";
@@ -4180,7 +4241,7 @@ var useProfitAndLoss = ({
4180
4241
  expenses: void 0,
4181
4242
  revenue: void 0
4182
4243
  });
4183
- const [sidebarScope, setSidebarScope] = useState12("expenses");
4244
+ const [sidebarScope, setSidebarScope] = useState12(void 0);
4184
4245
  const {
4185
4246
  data: rawData,
4186
4247
  isLoading,
@@ -4288,7 +4349,7 @@ var useProfitAndLoss = ({
4288
4349
  };
4289
4350
 
4290
4351
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
4291
- import React59, { useContext as useContext2, useMemo as useMemo4, useState as useState13 } from "react";
4352
+ import React60, { useContext as useContext2, useMemo as useMemo4, useState as useState13 } from "react";
4292
4353
 
4293
4354
  // src/utils/format.ts
4294
4355
  var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
@@ -4326,7 +4387,7 @@ var formatPercent = (value, options) => {
4326
4387
  };
4327
4388
 
4328
4389
  // src/components/ProfitAndLossChart/Indicator.tsx
4329
- import React58, { useEffect as useEffect8 } from "react";
4390
+ import React59, { useEffect as useEffect8 } from "react";
4330
4391
  var emptyViewBox = { x: 0, y: 0, width: 0, height: 0 };
4331
4392
  var Indicator = ({
4332
4393
  viewBox = {},
@@ -4338,25 +4399,26 @@ var Indicator = ({
4338
4399
  return null;
4339
4400
  }
4340
4401
  const { x: animateTo = 0, width = 0 } = "x" in viewBox ? viewBox : emptyViewBox;
4341
- const boxWidth = width * 2 + 4;
4342
- const multiplier = 1.5;
4402
+ const margin = width > 12 ? 4 : 1;
4403
+ const boxWidth = width * 2 + margin;
4404
+ const multiplier = width > 12 ? 1.2 : 1;
4343
4405
  const xOffset = (boxWidth * multiplier - boxWidth) / 2;
4406
+ const borderRadius = width > 16 ? 8 : width / 2;
4344
4407
  useEffect8(() => {
4345
4408
  setAnimateFrom(animateTo);
4346
4409
  }, [animateTo]);
4347
4410
  const actualX = animateFrom === -1 ? animateTo : animateFrom;
4348
- return /* @__PURE__ */ React58.createElement(
4411
+ return /* @__PURE__ */ React59.createElement(
4349
4412
  "rect",
4350
4413
  {
4351
4414
  className: "Layer__profit-and-loss-chart__selection-indicator",
4352
- rx: "8",
4353
- ry: "8",
4415
+ rx: borderRadius,
4416
+ ry: borderRadius,
4354
4417
  style: {
4355
4418
  width: `${boxWidth * multiplier}px`,
4356
4419
  // @ts-expect-error -- y is fine but x apparently isn't!
4357
4420
  x: actualX - xOffset,
4358
4421
  y: 22,
4359
- borderRadius: 8,
4360
4422
  height: "calc(100% - 38px)"
4361
4423
  }
4362
4424
  }
@@ -4463,6 +4525,7 @@ var ProfitAndLossChart = () => {
4463
4525
  name: getMonthName(pnl),
4464
4526
  revenue: pnl?.income.value || 0,
4465
4527
  expenses: Math.abs((pnl?.income.value || 0) - (pnl?.net_profit || 0)),
4528
+ netProfit: pnl?.net_profit || 0,
4466
4529
  selected: !!pnl && parseISO8(pnl.start_date).getMonth() >= startSelectionMonth && parseISO8(pnl.end_date).getMonth() <= endSelectionMonth
4467
4530
  });
4468
4531
  const onClick = ({ activeTooltipIndex }) => {
@@ -4481,22 +4544,24 @@ var ProfitAndLossChart = () => {
4481
4544
  label
4482
4545
  }) => {
4483
4546
  if (active && payload && payload.length) {
4484
- return /* @__PURE__ */ React59.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ React59.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ React59.createElement("li", null, /* @__PURE__ */ React59.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ React59.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ React59.createElement("li", null, /* @__PURE__ */ React59.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ React59.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0))))));
4547
+ const netProfit = payload[0].payload.netProfit ?? 0;
4548
+ const netProfitClass = netProfit > 0 ? "positive" : netProfit < 0 ? "negative" : "";
4549
+ return /* @__PURE__ */ React60.createElement("div", { className: "Layer__chart__tooltip" }, /* @__PURE__ */ React60.createElement("ul", { className: "Layer__chart__tooltip-list" }, /* @__PURE__ */ React60.createElement("li", null, /* @__PURE__ */ React60.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[0].name ?? "")), /* @__PURE__ */ React60.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[0].value ?? 0)))), /* @__PURE__ */ React60.createElement("li", null, /* @__PURE__ */ React60.createElement("label", { className: "Layer__chart__tooltip-label" }, capitalizeFirstLetter(payload[1].name ?? "")), /* @__PURE__ */ React60.createElement("span", { className: "Layer__chart__tooltip-value" }, "$", centsToDollars(Math.abs(payload[1].value ?? 0)))), /* @__PURE__ */ React60.createElement("li", null, /* @__PURE__ */ React60.createElement("label", { className: "Layer__chart__tooltip-label" }, "Net Profit"), /* @__PURE__ */ React60.createElement("span", { className: `Layer__chart__tooltip-value ${netProfitClass}` }, "$", centsToDollars(netProfit)))));
4485
4550
  }
4486
4551
  return null;
4487
4552
  };
4488
4553
  const CustomizedCursor = (props) => {
4489
- const { x, y, width, height } = props;
4490
- return /* @__PURE__ */ React59.createElement(
4554
+ const { x, width, height } = props;
4555
+ return /* @__PURE__ */ React60.createElement(
4491
4556
  Rectangle,
4492
4557
  {
4493
- fill: getColor(100)?.hex ?? "#F5F4F3",
4558
+ fill: getColor(900)?.hex ?? "#333",
4494
4559
  stroke: "none",
4495
- x,
4496
- y,
4497
- radius: 8,
4498
- width,
4499
- height: height + 24,
4560
+ x: x + width / 2 - 11,
4561
+ y: height + 44,
4562
+ radius: 2,
4563
+ width: 22,
4564
+ height: 2,
4500
4565
  className: "Layer__chart__tooltip-cursor"
4501
4566
  }
4502
4567
  );
@@ -4510,7 +4575,7 @@ var ProfitAndLossChart = () => {
4510
4575
  ]
4511
4576
  );
4512
4577
  const [animateFrom, setAnimateFrom] = useState13(-1);
4513
- return /* @__PURE__ */ React59.createElement(
4578
+ return /* @__PURE__ */ React60.createElement(
4514
4579
  ResponsiveContainer,
4515
4580
  {
4516
4581
  className: "Layer__chart-container",
@@ -4518,7 +4583,7 @@ var ProfitAndLossChart = () => {
4518
4583
  height: "100%",
4519
4584
  minHeight: 200
4520
4585
  },
4521
- /* @__PURE__ */ React59.createElement(
4586
+ /* @__PURE__ */ React60.createElement(
4522
4587
  BarChart,
4523
4588
  {
4524
4589
  margin: { left: 12, right: 12, bottom: 12 },
@@ -4527,17 +4592,17 @@ var ProfitAndLossChart = () => {
4527
4592
  barGap,
4528
4593
  className: "Layer__profit-and-loss-chart"
4529
4594
  },
4530
- /* @__PURE__ */ React59.createElement(
4595
+ /* @__PURE__ */ React60.createElement(
4531
4596
  Tooltip2,
4532
4597
  {
4533
4598
  wrapperClassName: "Layer__chart__tooltip-wrapper",
4534
- content: /* @__PURE__ */ React59.createElement(CustomTooltip, null),
4535
- cursor: /* @__PURE__ */ React59.createElement(CustomizedCursor, null),
4599
+ content: /* @__PURE__ */ React60.createElement(CustomTooltip, null),
4600
+ cursor: /* @__PURE__ */ React60.createElement(CustomizedCursor, null),
4536
4601
  animationDuration: 100,
4537
4602
  animationEasing: "ease-out"
4538
4603
  }
4539
4604
  ),
4540
- /* @__PURE__ */ React59.createElement(
4605
+ /* @__PURE__ */ React60.createElement(
4541
4606
  CartesianGrid,
4542
4607
  {
4543
4608
  vertical: false,
@@ -4545,7 +4610,7 @@ var ProfitAndLossChart = () => {
4545
4610
  strokeDasharray: "5 5"
4546
4611
  }
4547
4612
  ),
4548
- /* @__PURE__ */ React59.createElement(
4613
+ /* @__PURE__ */ React60.createElement(
4549
4614
  Legend,
4550
4615
  {
4551
4616
  verticalAlign: "top",
@@ -4553,7 +4618,7 @@ var ProfitAndLossChart = () => {
4553
4618
  wrapperStyle: { top: -24 },
4554
4619
  payload: [
4555
4620
  {
4556
- value: "Income",
4621
+ value: "Revenue",
4557
4622
  type: "circle",
4558
4623
  id: "IncomeLegend"
4559
4624
  },
@@ -4565,20 +4630,20 @@ var ProfitAndLossChart = () => {
4565
4630
  ]
4566
4631
  }
4567
4632
  ),
4568
- /* @__PURE__ */ React59.createElement(XAxis, { dataKey: "name", tickLine: false }),
4569
- /* @__PURE__ */ React59.createElement(
4633
+ /* @__PURE__ */ React60.createElement(XAxis, { dataKey: "name", tickLine: false }),
4634
+ /* @__PURE__ */ React60.createElement(
4570
4635
  Bar,
4571
4636
  {
4572
4637
  dataKey: "revenue",
4573
4638
  barSize,
4574
4639
  isAnimationActive: false,
4575
- radius: [barSize / 4, barSize / 4, 0, 0],
4640
+ radius: [2, 2, 0, 0],
4576
4641
  className: "Layer__profit-and-loss-chart__bar--income"
4577
4642
  },
4578
- /* @__PURE__ */ React59.createElement(
4643
+ /* @__PURE__ */ React60.createElement(
4579
4644
  LabelList,
4580
4645
  {
4581
- content: /* @__PURE__ */ React59.createElement(
4646
+ content: /* @__PURE__ */ React60.createElement(
4582
4647
  Indicator,
4583
4648
  {
4584
4649
  animateFrom,
@@ -4587,7 +4652,7 @@ var ProfitAndLossChart = () => {
4587
4652
  )
4588
4653
  }
4589
4654
  ),
4590
- data.map((entry) => /* @__PURE__ */ React59.createElement(
4655
+ data.map((entry) => /* @__PURE__ */ React60.createElement(
4591
4656
  Cell,
4592
4657
  {
4593
4658
  key: entry.name,
@@ -4595,16 +4660,16 @@ var ProfitAndLossChart = () => {
4595
4660
  }
4596
4661
  ))
4597
4662
  ),
4598
- /* @__PURE__ */ React59.createElement(
4663
+ /* @__PURE__ */ React60.createElement(
4599
4664
  Bar,
4600
4665
  {
4601
4666
  dataKey: "expenses",
4602
4667
  barSize,
4603
4668
  isAnimationActive: false,
4604
- radius: [barSize / 4, barSize / 4, 0, 0],
4669
+ radius: [2, 2, 0, 0],
4605
4670
  className: "Layer__profit-and-loss-chart__bar--expenses"
4606
4671
  },
4607
- data.map((entry) => /* @__PURE__ */ React59.createElement(
4672
+ data.map((entry) => /* @__PURE__ */ React60.createElement(
4608
4673
  Cell,
4609
4674
  {
4610
4675
  key: entry.name,
@@ -4617,7 +4682,7 @@ var ProfitAndLossChart = () => {
4617
4682
  };
4618
4683
 
4619
4684
  // src/components/ProfitAndLossDatePicker/ProfitAndLossDatePicker.tsx
4620
- import React60, { useContext as useContext3 } from "react";
4685
+ import React61, { useContext as useContext3 } from "react";
4621
4686
  import { add, endOfMonth as endOfMonth3, format as format5, startOfMonth as startOfMonth3 } from "date-fns";
4622
4687
  var ProfitAndLossDatePicker = () => {
4623
4688
  const { changeDateRange, dateRange } = useContext3(ProfitAndLoss.Context);
@@ -4632,42 +4697,42 @@ var ProfitAndLossDatePicker = () => {
4632
4697
  };
4633
4698
  const previousMonth = () => change({ months: -1 });
4634
4699
  const nextMonth = () => change({ months: 1 });
4635
- return /* @__PURE__ */ React60.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ React60.createElement(
4700
+ return /* @__PURE__ */ React61.createElement("div", { className: "Layer__profit-and-loss-date-picker" }, /* @__PURE__ */ React61.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ React61.createElement(
4636
4701
  "button",
4637
4702
  {
4638
4703
  "aria-label": "View Previous Month",
4639
4704
  className: "Layer__profit-and-loss-date-picker__button",
4640
4705
  onClick: previousMonth
4641
4706
  },
4642
- /* @__PURE__ */ React60.createElement(
4707
+ /* @__PURE__ */ React61.createElement(
4643
4708
  ChevronLeft_default,
4644
4709
  {
4645
4710
  className: "Layer__profit-and-loss-date-picker__button-icon",
4646
- size: 18
4711
+ size: 16
4647
4712
  }
4648
4713
  )
4649
- ), /* @__PURE__ */ React60.createElement("span", { className: "Layer__profit-and-loss-date-picker__label" }, label), /* @__PURE__ */ React60.createElement(
4714
+ ), /* @__PURE__ */ React61.createElement(
4650
4715
  "button",
4651
4716
  {
4652
4717
  "aria-label": "View Next Month",
4653
4718
  className: "Layer__profit-and-loss-date-picker__button",
4654
4719
  onClick: nextMonth
4655
4720
  },
4656
- /* @__PURE__ */ React60.createElement(
4721
+ /* @__PURE__ */ React61.createElement(
4657
4722
  ChevronRight_default,
4658
4723
  {
4659
4724
  className: "Layer__profit-and-loss-date-picker__button-icon",
4660
- size: 18
4725
+ size: 16
4661
4726
  }
4662
4727
  )
4663
4728
  ));
4664
4729
  };
4665
4730
 
4666
4731
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
4667
- import React62, { useContext as useContext4 } from "react";
4732
+ import React64, { useContext as useContext4, useMemo as useMemo5 } from "react";
4668
4733
 
4669
4734
  // src/components/SkeletonLoader/SkeletonLoader.tsx
4670
- import React61 from "react";
4735
+ import React62 from "react";
4671
4736
  import classNames21 from "classnames";
4672
4737
  var SkeletonLoader = ({
4673
4738
  height,
@@ -4678,11 +4743,161 @@ var SkeletonLoader = ({
4678
4743
  "Layer__skeleton-loader Layer__anim--skeleton-loading",
4679
4744
  className
4680
4745
  );
4681
- return /* @__PURE__ */ React61.createElement("div", { className: baseClassName, style: { width, height } });
4746
+ return /* @__PURE__ */ React62.createElement("div", { className: baseClassName, style: { width, height } });
4747
+ };
4748
+
4749
+ // src/components/ProfitAndLossSummaries/MiniChart.tsx
4750
+ import React63 from "react";
4751
+
4752
+ // src/config/charts.ts
4753
+ var INACTIVE_OPACITY_LEVELS = [
4754
+ 0.85,
4755
+ 0.7,
4756
+ 0.66,
4757
+ 0.55,
4758
+ 0.4,
4759
+ 0.33,
4760
+ 0.25,
4761
+ 0.15
4762
+ ];
4763
+ var DEFAULT_CHART_COLORS = [
4764
+ {
4765
+ color: "#7417B3",
4766
+ opacity: 1
4767
+ },
4768
+ {
4769
+ color: "#7417B3",
4770
+ opacity: 0.8
4771
+ },
4772
+ {
4773
+ color: "#7417B3",
4774
+ opacity: 0.6
4775
+ },
4776
+ {
4777
+ color: "#7417B3",
4778
+ opacity: 0.4
4779
+ },
4780
+ {
4781
+ color: "#7417B3",
4782
+ opacity: 0.2
4783
+ },
4784
+ {
4785
+ color: "#7417B3",
4786
+ opacity: 0.1
4787
+ },
4788
+ {
4789
+ color: "#006A80",
4790
+ opacity: 1
4791
+ },
4792
+ {
4793
+ color: "#006A80",
4794
+ opacity: 0.8
4795
+ },
4796
+ {
4797
+ color: "#006A80",
4798
+ opacity: 0.6
4799
+ },
4800
+ {
4801
+ color: "#006A80",
4802
+ opacity: 0.4
4803
+ },
4804
+ {
4805
+ color: "#006A80",
4806
+ opacity: 0.2
4807
+ },
4808
+ {
4809
+ color: "#006A80",
4810
+ opacity: 0.1
4811
+ },
4812
+ {
4813
+ color: "#009930",
4814
+ opacity: 1
4815
+ },
4816
+ {
4817
+ color: "#009930",
4818
+ opacity: 0.8
4819
+ },
4820
+ {
4821
+ color: "#009930",
4822
+ opacity: 0.6
4823
+ },
4824
+ {
4825
+ color: "#009930",
4826
+ opacity: 0.4
4827
+ },
4828
+ {
4829
+ color: "#009930",
4830
+ opacity: 0.2
4831
+ },
4832
+ {
4833
+ color: "#009930",
4834
+ opacity: 0.1
4835
+ }
4836
+ ];
4837
+
4838
+ // src/components/ProfitAndLossSummaries/MiniChart.tsx
4839
+ import { PieChart, Pie, Cell as Cell2 } from "recharts";
4840
+ var MiniChart = ({ data }) => {
4841
+ return /* @__PURE__ */ React63.createElement(PieChart, { width: 48, height: 48, className: "mini-chart" }, /* @__PURE__ */ React63.createElement(
4842
+ Pie,
4843
+ {
4844
+ data,
4845
+ dataKey: "value",
4846
+ nameKey: "name",
4847
+ cx: "50%",
4848
+ cy: "50%",
4849
+ innerRadius: 10,
4850
+ outerRadius: 16,
4851
+ paddingAngle: 0.2,
4852
+ fill: "#8884d8",
4853
+ width: 24,
4854
+ height: 24,
4855
+ animationDuration: 250,
4856
+ animationEasing: "ease-in-out"
4857
+ },
4858
+ data.map((entry, index) => {
4859
+ const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
4860
+ return /* @__PURE__ */ React63.createElement(
4861
+ Cell2,
4862
+ {
4863
+ key: `cell-${index}`,
4864
+ className: `Layer__profit-and-loss-detailed-charts__pie`,
4865
+ fill: entry.name === "placeholder" ? "#e6e6e6" : colorConfig.color,
4866
+ opacity: colorConfig.opacity
4867
+ }
4868
+ );
4869
+ })
4870
+ ));
4682
4871
  };
4683
4872
 
4684
4873
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
4685
4874
  import classNames22 from "classnames";
4875
+ var CHART_PLACEHOLDER = [
4876
+ {
4877
+ name: "placeholder",
4878
+ display_name: "placeholder",
4879
+ value: 1,
4880
+ type: "placeholder",
4881
+ share: 1
4882
+ }
4883
+ ];
4884
+ var buildMiniChartData = (scope, data) => {
4885
+ if (!data) {
4886
+ return CHART_PLACEHOLDER;
4887
+ }
4888
+ let items = [];
4889
+ switch (scope) {
4890
+ case "revenue":
4891
+ items = collectRevenueItems(data);
4892
+ break;
4893
+ default:
4894
+ items = collectExpensesItems(data);
4895
+ }
4896
+ if (!items || items.length === 0 || !items.find((x) => Math.abs(x.value) !== 0)) {
4897
+ return CHART_PLACEHOLDER;
4898
+ }
4899
+ return items.slice();
4900
+ };
4686
4901
  var ProfitAndLossSummaries = ({
4687
4902
  vertical,
4688
4903
  revenueLabel = "Revenue"
@@ -4693,16 +4908,22 @@ var ProfitAndLossSummaries = ({
4693
4908
  setSidebarScope,
4694
4909
  sidebarScope
4695
4910
  } = useContext4(ProfitAndLoss.Context);
4911
+ const expensesChartData = useMemo5(() => {
4912
+ return buildMiniChartData("expenses", storedData);
4913
+ }, [storedData]);
4914
+ const revenueChartData = useMemo5(() => {
4915
+ return buildMiniChartData("revenue", storedData);
4916
+ }, [storedData]);
4696
4917
  const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
4697
4918
  const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4698
4919
  const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4699
4920
  const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4700
- return /* @__PURE__ */ React62.createElement(
4921
+ return /* @__PURE__ */ React64.createElement(
4701
4922
  "div",
4702
4923
  {
4703
4924
  className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
4704
4925
  },
4705
- /* @__PURE__ */ React62.createElement(
4926
+ /* @__PURE__ */ React64.createElement(
4706
4927
  "div",
4707
4928
  {
4708
4929
  className: classNames22(
@@ -4712,16 +4933,16 @@ var ProfitAndLossSummaries = ({
4712
4933
  ),
4713
4934
  onClick: () => setSidebarScope("revenue")
4714
4935
  },
4715
- /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel),
4716
- isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, null)) : /* @__PURE__ */ React62.createElement(
4936
+ /* @__PURE__ */ React64.createElement(MiniChart, { data: revenueChartData }),
4937
+ /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ React64.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React64.createElement(SkeletonLoader, null)) : /* @__PURE__ */ React64.createElement(
4717
4938
  "span",
4718
4939
  {
4719
4940
  className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
4720
4941
  },
4721
4942
  centsToDollars(Math.abs(data?.income?.value ?? NaN))
4722
- )
4943
+ ))
4723
4944
  ),
4724
- /* @__PURE__ */ React62.createElement(
4945
+ /* @__PURE__ */ React64.createElement(
4725
4946
  "div",
4726
4947
  {
4727
4948
  className: classNames22(
@@ -4731,37 +4952,75 @@ var ProfitAndLossSummaries = ({
4731
4952
  ),
4732
4953
  onClick: () => setSidebarScope("expenses")
4733
4954
  },
4734
- /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"),
4735
- isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React62.createElement(
4955
+ /* @__PURE__ */ React64.createElement(MiniChart, { data: expensesChartData }),
4956
+ /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ React64.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), isLoading || storedData === void 0 ? /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React64.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React64.createElement(
4736
4957
  "span",
4737
4958
  {
4738
4959
  className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
4739
4960
  },
4740
- centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
4741
- )
4961
+ centsToDollars(
4962
+ Math.abs((data.income.value ?? 0) - data.net_profit)
4963
+ )
4964
+ ))
4742
4965
  ),
4743
- /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React62.createElement(
4966
+ /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__summary net-profit Layer__profit-and-loss-summaries__summary--net-profit" }, /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__text" }, /* @__PURE__ */ React64.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Net Profit"), isLoading || storedData === void 0 ? /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React64.createElement(SkeletonLoader, { className: "Layer__profit-and-loss-summaries__loader" })) : /* @__PURE__ */ React64.createElement(
4744
4967
  "span",
4745
4968
  {
4746
4969
  className: `Layer__profit-and-loss-summaries__amount ${netProfitDirectionClass}`
4747
4970
  },
4748
4971
  centsToDollars(Math.abs(data.net_profit))
4749
- ))
4972
+ )))
4750
4973
  );
4751
4974
  };
4752
4975
 
4753
4976
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
4754
- import React64, { useContext as useContext5 } from "react";
4977
+ import React67, { useContext as useContext5 } from "react";
4978
+
4979
+ // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
4980
+ import React66, { useState as useState14 } from "react";
4981
+
4982
+ // src/icons/PieChart.tsx
4983
+ import * as React65 from "react";
4984
+ var PieChart2 = ({ size = 12, ...props }) => /* @__PURE__ */ React65.createElement(
4985
+ "svg",
4986
+ {
4987
+ xmlns: "http://www.w3.org/2000/svg",
4988
+ viewBox: "0 0 12 12",
4989
+ fill: "none",
4990
+ ...props,
4991
+ width: size,
4992
+ height: size
4993
+ },
4994
+ /* @__PURE__ */ React65.createElement("g", null, /* @__PURE__ */ React65.createElement(
4995
+ "path",
4996
+ {
4997
+ d: "M10.2213 7.78271C9.92969 8.47226 9.47363 9.07989 8.89297 9.55247C8.3123 10.0251 7.62471 10.3482 6.89031 10.4936C6.1559 10.6391 5.39705 10.6024 4.68009 10.3869C3.96313 10.1713 3.30989 9.78337 2.77749 9.25701C2.24509 8.73065 1.84973 8.08189 1.62598 7.36744C1.40223 6.65298 1.3569 5.8946 1.49396 5.15858C1.63102 4.42257 1.94629 3.73133 2.41221 3.14531C2.87813 2.55928 3.48051 2.09631 4.16669 1.79688",
4998
+ stroke: "currentColor",
4999
+ "stroke-linecap": "round",
5000
+ "stroke-linejoin": "round"
5001
+ }
5002
+ ), /* @__PURE__ */ React65.createElement(
5003
+ "path",
5004
+ {
5005
+ d: "M10.5833 6.00033C10.5833 5.39843 10.4648 4.80244 10.2344 4.24636C10.0041 3.69028 9.66651 3.18502 9.24091 2.75942C8.8153 2.33382 8.31004 1.99621 7.75397 1.76588C7.19789 1.53554 6.60189 1.41699 6 1.41699V6.00033H10.5833Z",
5006
+ stroke: "currentColor",
5007
+ "stroke-linecap": "round",
5008
+ "stroke-linejoin": "round"
5009
+ }
5010
+ ))
5011
+ );
5012
+ var PieChart_default = PieChart2;
4755
5013
 
4756
5014
  // src/components/ProfitAndLossRow/ProfitAndLossRow.tsx
4757
- import React63, { useState as useState14 } from "react";
4758
5015
  var ProfitAndLossRow = ({
4759
5016
  variant,
4760
5017
  lineItem,
4761
5018
  depth = 0,
4762
5019
  maxDepth = 1,
4763
5020
  direction = "DEBIT" /* DEBIT */,
4764
- lockExpanded = false
5021
+ lockExpanded = false,
5022
+ scope,
5023
+ setSidebarScope
4765
5024
  }) => {
4766
5025
  if (!lineItem) {
4767
5026
  return null;
@@ -4798,20 +5057,36 @@ var ProfitAndLossRow = ({
4798
5057
  );
4799
5058
  displayChildren && expanded && labelClasses.push("Layer__profit-and-loss-row__label--expanded");
4800
5059
  displayChildren && expanded && valueClasses.push("Layer__profit-and-loss-row__value--expanded");
4801
- return /* @__PURE__ */ React63.createElement(React63.Fragment, null, /* @__PURE__ */ React63.createElement(
5060
+ return /* @__PURE__ */ React66.createElement(React66.Fragment, null, /* @__PURE__ */ React66.createElement(
4802
5061
  "div",
4803
5062
  {
4804
5063
  className: labelClasses.join(" "),
4805
5064
  onClick: () => !lockExpanded && toggleExpanded()
4806
5065
  },
4807
- !lockExpanded && variant !== "summation" ? /* @__PURE__ */ React63.createElement(ChevronDownFill_default, { size: 16 }) : null,
4808
- /* @__PURE__ */ React63.createElement(Text, null, display_name)
4809
- ), /* @__PURE__ */ React63.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ React63.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ React63.createElement(
5066
+ /* @__PURE__ */ React66.createElement("span", { className: "Layer__profit-and-loss-row__label__title" }, !lockExpanded && variant !== "summation" ? /* @__PURE__ */ React66.createElement(
5067
+ ChevronDownFill_default,
5068
+ {
5069
+ size: 16,
5070
+ className: "Layer__profit-and-loss-row__label__chevron"
5071
+ }
5072
+ ) : null, /* @__PURE__ */ React66.createElement(Text, null, display_name)),
5073
+ setSidebarScope && /* @__PURE__ */ React66.createElement(
5074
+ "span",
5075
+ {
5076
+ className: "Layer__profit-and-loss-row__detailed-chart-btn",
5077
+ onClick: (e) => {
5078
+ e.stopPropagation();
5079
+ setSidebarScope && setSidebarScope(scope ?? "expenses");
5080
+ }
5081
+ },
5082
+ /* @__PURE__ */ React66.createElement(PieChart_default, null)
5083
+ )
5084
+ ), /* @__PURE__ */ React66.createElement("div", { className: valueClasses.join(" ") }, /* @__PURE__ */ React66.createElement(Text, null, amountString)), canGoDeeper && hasChildren && /* @__PURE__ */ React66.createElement(
4810
5085
  "div",
4811
5086
  {
4812
5087
  className: `Layer__profit-and-loss-row__children ${expanded && "Layer__profit-and-loss-row__children--expanded"}`
4813
5088
  },
4814
- /* @__PURE__ */ React63.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ React63.createElement(
5089
+ /* @__PURE__ */ React66.createElement("div", { className: "Layer__profit-and-loss-row__children--content" }, (line_items || []).map((line_item) => /* @__PURE__ */ React66.createElement(
4815
5090
  ProfitAndLossRow,
4816
5091
  {
4817
5092
  key: line_item.display_name,
@@ -4874,26 +5149,34 @@ var empty_profit_and_loss_report_default = {
4874
5149
 
4875
5150
  // src/components/ProfitAndLossTable/ProfitAndLossTable.tsx
4876
5151
  var ProfitAndLossTable = ({ lockExpanded }) => {
4877
- const { data: actualData, isLoading } = useContext5(ProfitAndLoss.Context);
5152
+ const {
5153
+ data: actualData,
5154
+ isLoading,
5155
+ setSidebarScope
5156
+ } = useContext5(ProfitAndLoss.Context);
4878
5157
  const data = !actualData || isLoading ? empty_profit_and_loss_report_default : actualData;
4879
5158
  if (isLoading || actualData === void 0) {
4880
- return /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-table__loader-container" }, /* @__PURE__ */ React64.createElement(Loader2, null));
5159
+ return /* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-table__loader-container" }, /* @__PURE__ */ React67.createElement(Loader2, null));
4881
5160
  }
4882
- return /* @__PURE__ */ React64.createElement(React64.Fragment, null, /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table--main" }, /* @__PURE__ */ React64.createElement(
5161
+ return /* @__PURE__ */ React67.createElement(React67.Fragment, null, /* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table--main" }, /* @__PURE__ */ React67.createElement(
4883
5162
  ProfitAndLossRow,
4884
5163
  {
4885
5164
  lineItem: data.income,
4886
5165
  direction: "CREDIT" /* CREDIT */,
4887
- lockExpanded
5166
+ lockExpanded,
5167
+ scope: "revenue",
5168
+ setSidebarScope
4888
5169
  }
4889
- ), /* @__PURE__ */ React64.createElement(
5170
+ ), /* @__PURE__ */ React67.createElement(
4890
5171
  ProfitAndLossRow,
4891
5172
  {
4892
5173
  lineItem: data.cost_of_goods_sold,
4893
5174
  direction: "DEBIT" /* DEBIT */,
4894
- lockExpanded
5175
+ lockExpanded,
5176
+ scope: "expenses",
5177
+ setSidebarScope
4895
5178
  }
4896
- ), /* @__PURE__ */ React64.createElement(
5179
+ ), /* @__PURE__ */ React67.createElement(
4897
5180
  ProfitAndLossRow,
4898
5181
  {
4899
5182
  lineItem: {
@@ -4902,16 +5185,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
4902
5185
  },
4903
5186
  variant: "summation",
4904
5187
  direction: "CREDIT" /* CREDIT */,
4905
- lockExpanded
5188
+ lockExpanded,
5189
+ scope: "revenue",
5190
+ setSidebarScope
4906
5191
  }
4907
- ), /* @__PURE__ */ React64.createElement(
5192
+ ), /* @__PURE__ */ React67.createElement(
4908
5193
  ProfitAndLossRow,
4909
5194
  {
4910
5195
  lineItem: data.expenses,
4911
5196
  direction: "DEBIT" /* DEBIT */,
4912
- lockExpanded
5197
+ lockExpanded,
5198
+ scope: "expenses",
5199
+ setSidebarScope
4913
5200
  }
4914
- ), /* @__PURE__ */ React64.createElement(
5201
+ ), /* @__PURE__ */ React67.createElement(
4915
5202
  ProfitAndLossRow,
4916
5203
  {
4917
5204
  lineItem: {
@@ -4920,16 +5207,20 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
4920
5207
  },
4921
5208
  variant: "summation",
4922
5209
  direction: "CREDIT" /* CREDIT */,
4923
- lockExpanded
5210
+ lockExpanded,
5211
+ scope: "revenue",
5212
+ setSidebarScope
4924
5213
  }
4925
- ), /* @__PURE__ */ React64.createElement(
5214
+ ), /* @__PURE__ */ React67.createElement(
4926
5215
  ProfitAndLossRow,
4927
5216
  {
4928
5217
  lineItem: data.taxes,
4929
5218
  direction: "DEBIT" /* DEBIT */,
4930
- lockExpanded
5219
+ lockExpanded,
5220
+ scope: "expenses",
5221
+ setSidebarScope
4931
5222
  }
4932
- ), /* @__PURE__ */ React64.createElement(
5223
+ ), /* @__PURE__ */ React67.createElement(
4933
5224
  ProfitAndLossRow,
4934
5225
  {
4935
5226
  lineItem: {
@@ -4940,21 +5231,21 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
4940
5231
  direction: "CREDIT" /* CREDIT */,
4941
5232
  lockExpanded
4942
5233
  }
4943
- )), /* @__PURE__ */ React64.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ React64.createElement(
5234
+ )), data.other_outflows || data.personal_expenses ? /* @__PURE__ */ React67.createElement("div", { className: "Layer__profit-and-loss-table Layer__profit-and-loss-table__outflows" }, /* @__PURE__ */ React67.createElement(
4944
5235
  ProfitAndLossRow,
4945
5236
  {
4946
5237
  lineItem: data.other_outflows,
4947
5238
  direction: "DEBIT" /* DEBIT */,
4948
5239
  lockExpanded
4949
5240
  }
4950
- ), /* @__PURE__ */ React64.createElement(
5241
+ ), /* @__PURE__ */ React67.createElement(
4951
5242
  ProfitAndLossRow,
4952
5243
  {
4953
5244
  lineItem: data.personal_expenses,
4954
5245
  direction: "DEBIT" /* DEBIT */,
4955
5246
  lockExpanded
4956
5247
  }
4957
- )));
5248
+ )) : null);
4958
5249
  };
4959
5250
 
4960
5251
  // src/components/ProfitAndLoss/ProfitAndLoss.tsx
@@ -4988,7 +5279,7 @@ var PNLContext = createContext2({
4988
5279
  });
4989
5280
  var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
4990
5281
  const contextData = useProfitAndLoss({ tagFilter, reportingBasis });
4991
- return /* @__PURE__ */ React65.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ React65.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
5282
+ return /* @__PURE__ */ React68.createElement(PNLContext.Provider, { value: contextData }, /* @__PURE__ */ React68.createElement("div", { className: "Layer__component Layer__profit-and-loss" }, children));
4992
5283
  };
4993
5284
  ProfitAndLoss.Chart = ProfitAndLossChart;
4994
5285
  ProfitAndLoss.Context = PNLContext;
@@ -4997,63 +5288,273 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
4997
5288
  ProfitAndLoss.Table = ProfitAndLossTable;
4998
5289
 
4999
5290
  // src/components/ProfitAndLossView/ProfitAndLossView.tsx
5000
- import React69, { useContext as useContext7 } from "react";
5291
+ import React75, { useContext as useContext7 } from "react";
5001
5292
 
5002
5293
  // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
5003
- import React68, { useContext as useContext6, useMemo as useMemo5, useState as useState15 } from "react";
5004
- import Select3 from "react-select";
5294
+ import React74, { useContext as useContext6, useState as useState15 } from "react";
5005
5295
 
5006
- // src/icons/SortArrows.tsx
5007
- import * as React66 from "react";
5008
- var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElement(
5296
+ // src/icons/X.tsx
5297
+ import * as React69 from "react";
5298
+ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React69.createElement(
5009
5299
  "svg",
5010
5300
  {
5011
5301
  xmlns: "http://www.w3.org/2000/svg",
5012
- viewBox: "0 0 12 13",
5302
+ viewBox: "0 0 18 18",
5013
5303
  fill: "none",
5014
5304
  ...props,
5015
5305
  width: size,
5016
5306
  height: size
5017
5307
  },
5018
- /* @__PURE__ */ React66.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React66.createElement(
5019
- "path",
5020
- {
5021
- d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
5022
- stroke: "currentColor",
5023
- "stroke-linecap": "round",
5024
- "stroke-linejoin": "round",
5025
- className: "desc-arrow"
5026
- }
5027
- ), /* @__PURE__ */ React66.createElement(
5028
- "path",
5029
- {
5030
- d: "M4 2.5L4 11.1667",
5031
- stroke: "currentColor",
5032
- "stroke-linecap": "round",
5033
- "stroke-linejoin": "round",
5034
- className: "desc-arrow"
5035
- }
5036
- ), /* @__PURE__ */ React66.createElement(
5308
+ /* @__PURE__ */ React69.createElement(
5037
5309
  "path",
5038
5310
  {
5039
- d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
5311
+ d: "M13.5 4.5L4.5 13.5",
5040
5312
  stroke: "currentColor",
5041
- "stroke-linecap": "round",
5042
- "stroke-linejoin": "round",
5043
- className: "asc-arrow"
5313
+ strokeLinecap: "round",
5314
+ strokeLinejoin: "round"
5044
5315
  }
5045
- ), /* @__PURE__ */ React66.createElement(
5316
+ ),
5317
+ /* @__PURE__ */ React69.createElement(
5046
5318
  "path",
5047
5319
  {
5048
- d: "M8.66663 11.166L8.66663 2.49935",
5320
+ d: "M4.5 4.5L13.5 13.5",
5049
5321
  stroke: "currentColor",
5050
- "stroke-linecap": "round",
5051
- "stroke-linejoin": "round",
5052
- className: "asc-arrow"
5322
+ strokeLinecap: "round",
5323
+ strokeLinejoin: "round"
5053
5324
  }
5054
- )),
5055
- /* @__PURE__ */ React66.createElement("defs", null, /* @__PURE__ */ React66.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React66.createElement(
5056
- "rect",
5325
+ )
5326
+ );
5327
+ var X_default = X;
5328
+
5329
+ // src/components/ProfitAndLossDetailedCharts/DetailedChart.tsx
5330
+ import React70, { useMemo as useMemo6 } from "react";
5331
+ import {
5332
+ PieChart as PieChart3,
5333
+ Pie as Pie2,
5334
+ Cell as Cell3,
5335
+ ResponsiveContainer as ResponsiveContainer2,
5336
+ Label,
5337
+ Text as ChartText
5338
+ } from "recharts";
5339
+ var DetailedChart = ({
5340
+ filteredData,
5341
+ filteredTotal,
5342
+ hoveredItem,
5343
+ setHoveredItem,
5344
+ sidebarScope,
5345
+ date
5346
+ }) => {
5347
+ const chartData = useMemo6(() => {
5348
+ if (!filteredData) {
5349
+ return [];
5350
+ }
5351
+ return filteredData.map((x) => {
5352
+ if (x.hidden) {
5353
+ return {
5354
+ name: x.display_name,
5355
+ value: 0
5356
+ };
5357
+ }
5358
+ return {
5359
+ name: x.display_name,
5360
+ value: x.value
5361
+ };
5362
+ });
5363
+ }, [filteredData]);
5364
+ return /* @__PURE__ */ React70.createElement("div", { className: "chart-field" }, /* @__PURE__ */ React70.createElement("div", { className: "header--tablet" }, /* @__PURE__ */ React70.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ React70.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ React70.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React70.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React70.createElement(PieChart3, null, /* @__PURE__ */ React70.createElement(
5365
+ Pie2,
5366
+ {
5367
+ data: chartData,
5368
+ dataKey: "value",
5369
+ nameKey: "name",
5370
+ cx: "50%",
5371
+ cy: "50%",
5372
+ innerRadius: 105,
5373
+ outerRadius: 120,
5374
+ paddingAngle: 0.5,
5375
+ fill: "#8884d8",
5376
+ animationDuration: 200,
5377
+ animationEasing: "ease-in-out"
5378
+ },
5379
+ chartData.map((entry, index) => {
5380
+ const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
5381
+ let fill = colorConfig.color;
5382
+ let opacity = colorConfig.opacity;
5383
+ let active = true;
5384
+ if (hoveredItem && entry.name !== hoveredItem) {
5385
+ active = false;
5386
+ fill = void 0;
5387
+ opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
5388
+ }
5389
+ return /* @__PURE__ */ React70.createElement(
5390
+ Cell3,
5391
+ {
5392
+ key: `cell-${index}`,
5393
+ className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
5394
+ style: { fill },
5395
+ opacity,
5396
+ onMouseEnter: () => setHoveredItem(entry.name),
5397
+ onMouseLeave: () => setHoveredItem(void 0)
5398
+ }
5399
+ );
5400
+ }),
5401
+ /* @__PURE__ */ React70.createElement(
5402
+ Label,
5403
+ {
5404
+ position: "center",
5405
+ value: "Total",
5406
+ className: "pie-center-label-title",
5407
+ content: (props) => {
5408
+ const { cx, cy } = props.viewBox ?? {
5409
+ cx: 0,
5410
+ cy: 0
5411
+ };
5412
+ const positioningProps = {
5413
+ x: cx,
5414
+ y: (cy || 0) - 15,
5415
+ textAnchor: "middle",
5416
+ verticalAnchor: "middle"
5417
+ };
5418
+ let text = "Total";
5419
+ if (hoveredItem) {
5420
+ text = hoveredItem;
5421
+ }
5422
+ return /* @__PURE__ */ React70.createElement(
5423
+ ChartText,
5424
+ {
5425
+ ...positioningProps,
5426
+ className: "pie-center-label__title"
5427
+ },
5428
+ text
5429
+ );
5430
+ }
5431
+ }
5432
+ ),
5433
+ /* @__PURE__ */ React70.createElement(
5434
+ Label,
5435
+ {
5436
+ position: "center",
5437
+ value: "Total",
5438
+ className: "pie-center-label-title",
5439
+ content: (props) => {
5440
+ const { cx, cy } = props.viewBox ?? {
5441
+ cx: 0,
5442
+ cy: 0
5443
+ };
5444
+ const positioningProps = {
5445
+ x: cx,
5446
+ y: (cy || 0) + 5,
5447
+ textAnchor: "middle",
5448
+ verticalAnchor: "middle"
5449
+ };
5450
+ let value = filteredTotal;
5451
+ if (hoveredItem) {
5452
+ value = filteredData.find(
5453
+ (x) => x.display_name === hoveredItem
5454
+ )?.value;
5455
+ }
5456
+ return /* @__PURE__ */ React70.createElement(
5457
+ ChartText,
5458
+ {
5459
+ ...positioningProps,
5460
+ className: "pie-center-label__value"
5461
+ },
5462
+ `$${centsToDollars(value)}`
5463
+ );
5464
+ }
5465
+ }
5466
+ ),
5467
+ /* @__PURE__ */ React70.createElement(
5468
+ Label,
5469
+ {
5470
+ position: "center",
5471
+ value: "Total",
5472
+ className: "pie-center-label-title",
5473
+ content: (props) => {
5474
+ const { cx, cy } = props.viewBox ?? {
5475
+ cx: 0,
5476
+ cy: 0
5477
+ };
5478
+ const positioningProps = {
5479
+ x: cx,
5480
+ y: (cy || 0) + 25,
5481
+ height: 20,
5482
+ textAnchor: "middle",
5483
+ verticalAnchor: "middle"
5484
+ };
5485
+ if (hoveredItem) {
5486
+ return /* @__PURE__ */ React70.createElement(
5487
+ ChartText,
5488
+ {
5489
+ ...positioningProps,
5490
+ className: "pie-center-label__share"
5491
+ },
5492
+ `${formatPercent(
5493
+ filteredData.find((x) => x.display_name === hoveredItem)?.share
5494
+ )}%`
5495
+ );
5496
+ }
5497
+ return;
5498
+ }
5499
+ }
5500
+ )
5501
+ )))));
5502
+ };
5503
+
5504
+ // src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
5505
+ import React72 from "react";
5506
+
5507
+ // src/icons/SortArrows.tsx
5508
+ import * as React71 from "react";
5509
+ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React71.createElement(
5510
+ "svg",
5511
+ {
5512
+ xmlns: "http://www.w3.org/2000/svg",
5513
+ viewBox: "0 0 12 13",
5514
+ fill: "none",
5515
+ ...props,
5516
+ width: size,
5517
+ height: size
5518
+ },
5519
+ /* @__PURE__ */ React71.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React71.createElement(
5520
+ "path",
5521
+ {
5522
+ d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
5523
+ stroke: "currentColor",
5524
+ "stroke-linecap": "round",
5525
+ "stroke-linejoin": "round",
5526
+ className: "desc-arrow"
5527
+ }
5528
+ ), /* @__PURE__ */ React71.createElement(
5529
+ "path",
5530
+ {
5531
+ d: "M4 2.5L4 11.1667",
5532
+ stroke: "currentColor",
5533
+ "stroke-linecap": "round",
5534
+ "stroke-linejoin": "round",
5535
+ className: "desc-arrow"
5536
+ }
5537
+ ), /* @__PURE__ */ React71.createElement(
5538
+ "path",
5539
+ {
5540
+ d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
5541
+ stroke: "currentColor",
5542
+ "stroke-linecap": "round",
5543
+ "stroke-linejoin": "round",
5544
+ className: "asc-arrow"
5545
+ }
5546
+ ), /* @__PURE__ */ React71.createElement(
5547
+ "path",
5548
+ {
5549
+ d: "M8.66663 11.166L8.66663 2.49935",
5550
+ stroke: "currentColor",
5551
+ "stroke-linecap": "round",
5552
+ "stroke-linejoin": "round",
5553
+ className: "asc-arrow"
5554
+ }
5555
+ )),
5556
+ /* @__PURE__ */ React71.createElement("defs", null, /* @__PURE__ */ React71.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React71.createElement(
5557
+ "rect",
5057
5558
  {
5058
5559
  width: "12",
5059
5560
  height: "12",
@@ -5064,9 +5565,400 @@ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElem
5064
5565
  );
5065
5566
  var SortArrows_default = SortArrows;
5066
5567
 
5067
- // src/icons/X.tsx
5068
- import * as React67 from "react";
5069
- var X = ({ size = 18, ...props }) => /* @__PURE__ */ React67.createElement(
5568
+ // src/components/ProfitAndLossDetailedCharts/DetailedTable.tsx
5569
+ import classNames23 from "classnames";
5570
+ var DetailedTable = ({
5571
+ filteredData,
5572
+ sidebarScope,
5573
+ filters,
5574
+ sortBy,
5575
+ hoveredItem,
5576
+ setHoveredItem
5577
+ }) => {
5578
+ const buildColClass = (column) => {
5579
+ return classNames23(
5580
+ "Layer__sortable-col",
5581
+ sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
5582
+ );
5583
+ };
5584
+ return /* @__PURE__ */ React72.createElement("div", { className: "details-container" }, /* @__PURE__ */ React72.createElement("div", { className: "table" }, /* @__PURE__ */ React72.createElement("table", null, /* @__PURE__ */ React72.createElement("thead", null, /* @__PURE__ */ React72.createElement("tr", null, /* @__PURE__ */ React72.createElement(
5585
+ "th",
5586
+ {
5587
+ className: buildColClass("category"),
5588
+ onClick: () => sortBy(sidebarScope ?? "expenses", "category")
5589
+ },
5590
+ "Expense/Sale ",
5591
+ /* @__PURE__ */ React72.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5592
+ ), /* @__PURE__ */ React72.createElement(
5593
+ "th",
5594
+ {
5595
+ className: buildColClass("type"),
5596
+ onClick: () => sortBy(sidebarScope ?? "expenses", "type")
5597
+ },
5598
+ "Type ",
5599
+ /* @__PURE__ */ React72.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5600
+ ), /* @__PURE__ */ React72.createElement("th", null), /* @__PURE__ */ React72.createElement(
5601
+ "th",
5602
+ {
5603
+ className: buildColClass("value"),
5604
+ onClick: () => sortBy(sidebarScope ?? "expenses", "value")
5605
+ },
5606
+ "Value ",
5607
+ /* @__PURE__ */ React72.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5608
+ ))), /* @__PURE__ */ React72.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
5609
+ const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
5610
+ return /* @__PURE__ */ React72.createElement(
5611
+ "tr",
5612
+ {
5613
+ key: `pl-side-table-item-${idx}`,
5614
+ className: classNames23(
5615
+ "Layer__profit-and-loss-detailed-table__row",
5616
+ hoveredItem && hoveredItem === item.display_name ? "active" : ""
5617
+ ),
5618
+ onMouseEnter: () => setHoveredItem(item.display_name),
5619
+ onMouseLeave: () => setHoveredItem(void 0)
5620
+ },
5621
+ /* @__PURE__ */ React72.createElement("td", { className: "category-col" }, item.display_name),
5622
+ /* @__PURE__ */ React72.createElement("td", { className: "type-col" }, item.type),
5623
+ /* @__PURE__ */ React72.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
5624
+ /* @__PURE__ */ React72.createElement("td", { className: "share-col" }, /* @__PURE__ */ React72.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ React72.createElement(
5625
+ "div",
5626
+ {
5627
+ className: "share-icon",
5628
+ style: {
5629
+ background: colorConfig.color,
5630
+ opacity: colorConfig.opacity
5631
+ }
5632
+ }
5633
+ )))
5634
+ );
5635
+ })))));
5636
+ };
5637
+
5638
+ // src/components/ProfitAndLossDetailedCharts/Filters.tsx
5639
+ import React73 from "react";
5640
+ import Select4, { components as components4 } from "react-select";
5641
+ var Filters = ({
5642
+ filteredData,
5643
+ sidebarScope,
5644
+ filters,
5645
+ setFilterTypes
5646
+ }) => {
5647
+ return /* @__PURE__ */ React73.createElement("div", { className: "filters" }, /* @__PURE__ */ React73.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ React73.createElement(
5648
+ Select4,
5649
+ {
5650
+ className: "Layer__select type-select",
5651
+ classNamePrefix: "Layer__select",
5652
+ value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
5653
+ value: x,
5654
+ label: x
5655
+ })) : [],
5656
+ isMulti: true,
5657
+ isClearable: false,
5658
+ options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
5659
+ label: x,
5660
+ value: x
5661
+ })),
5662
+ onChange: (selected) => {
5663
+ setFilterTypes(
5664
+ sidebarScope ?? "expenses",
5665
+ selected.map((x) => x.value)
5666
+ );
5667
+ },
5668
+ components: {
5669
+ DropdownIndicator: (props) => /* @__PURE__ */ React73.createElement(components4.DropdownIndicator, { ...props }, /* @__PURE__ */ React73.createElement(ChevronDown_default, null)),
5670
+ Placeholder: (props) => /* @__PURE__ */ React73.createElement(components4.Placeholder, { ...props }, /* @__PURE__ */ React73.createElement("div", { className: "Layer__select__multi-all-placeholder-badge" }, "All"))
5671
+ }
5672
+ }
5673
+ ));
5674
+ };
5675
+
5676
+ // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
5677
+ import classNames24 from "classnames";
5678
+ import { format as format6 } from "date-fns";
5679
+ var ProfitAndLossDetailedCharts = () => {
5680
+ const {
5681
+ filteredData,
5682
+ filteredTotal,
5683
+ sortBy,
5684
+ filters,
5685
+ isLoading,
5686
+ dateRange,
5687
+ sidebarScope,
5688
+ setSidebarScope,
5689
+ setFilterTypes
5690
+ } = useContext6(ProfitAndLoss.Context);
5691
+ const [hoveredItem, setHoveredItem] = useState15();
5692
+ return /* @__PURE__ */ React74.createElement(
5693
+ "div",
5694
+ {
5695
+ className: classNames24(
5696
+ "Layer__profit-and-loss__side-panel",
5697
+ sidebarScope && "open"
5698
+ )
5699
+ },
5700
+ /* @__PURE__ */ React74.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ React74.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header" }, /* @__PURE__ */ React74.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ React74.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ React74.createElement(Text, { size: "sm" /* sm */, className: "date" }, format6(dateRange.startDate, "LLLL, y")), /* @__PURE__ */ React74.createElement(ProfitAndLossDatePicker, null)), /* @__PURE__ */ React74.createElement(
5701
+ Button,
5702
+ {
5703
+ rightIcon: /* @__PURE__ */ React74.createElement(X_default, null),
5704
+ iconOnly: true,
5705
+ onClick: () => setSidebarScope(void 0),
5706
+ variant: "secondary" /* secondary */
5707
+ }
5708
+ )), /* @__PURE__ */ React74.createElement("header", { className: "Layer__profit-and-loss-detailed-charts__header--tablet" }, /* @__PURE__ */ React74.createElement(
5709
+ Button,
5710
+ {
5711
+ onClick: () => setSidebarScope(void 0),
5712
+ variant: "secondary" /* secondary */
5713
+ },
5714
+ "Back"
5715
+ )), /* @__PURE__ */ React74.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__content" }, /* @__PURE__ */ React74.createElement(
5716
+ DetailedChart,
5717
+ {
5718
+ filteredData,
5719
+ filteredTotal,
5720
+ hoveredItem,
5721
+ setHoveredItem,
5722
+ sidebarScope,
5723
+ date: dateRange.startDate
5724
+ }
5725
+ ), /* @__PURE__ */ React74.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__table-wrapper" }, /* @__PURE__ */ React74.createElement(
5726
+ Filters,
5727
+ {
5728
+ filteredData,
5729
+ sidebarScope,
5730
+ filters,
5731
+ setFilterTypes
5732
+ }
5733
+ ), /* @__PURE__ */ React74.createElement(
5734
+ DetailedTable,
5735
+ {
5736
+ filteredData,
5737
+ sidebarScope,
5738
+ filters,
5739
+ sortBy,
5740
+ hoveredItem,
5741
+ setHoveredItem
5742
+ }
5743
+ ))))
5744
+ );
5745
+ };
5746
+
5747
+ // src/components/ProfitAndLossView/ProfitAndLossView.tsx
5748
+ var COMPONENT_NAME3 = "profit-and-loss";
5749
+ var ProfitAndLossView = (props) => {
5750
+ return /* @__PURE__ */ React75.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ React75.createElement(ProfitAndLoss, null, /* @__PURE__ */ React75.createElement("div", { className: `Layer__${COMPONENT_NAME3}__main-panel` }, /* @__PURE__ */ React75.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ React75.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ React75.createElement(Components, { ...props })), props.showDetailedCharts !== false && /* @__PURE__ */ React75.createElement(ProfitAndLossDetailedCharts, null)));
5751
+ };
5752
+ var Components = ({
5753
+ hideChart = false,
5754
+ hideTable = false
5755
+ }) => {
5756
+ const { error, isLoading, isValidating, refetch } = useContext7(
5757
+ ProfitAndLoss.Context
5758
+ );
5759
+ if (!isLoading && error) {
5760
+ return /* @__PURE__ */ React75.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React75.createElement(
5761
+ DataState,
5762
+ {
5763
+ status: "failed" /* failed */,
5764
+ title: "Something went wrong",
5765
+ description: "We couldn\u2019t load your data.",
5766
+ onRefresh: () => refetch(),
5767
+ isLoading: isValidating
5768
+ }
5769
+ ));
5770
+ }
5771
+ return /* @__PURE__ */ React75.createElement(React75.Fragment, null, !hideChart && /* @__PURE__ */ React75.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ React75.createElement(
5772
+ "div",
5773
+ {
5774
+ className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
5775
+ },
5776
+ /* @__PURE__ */ React75.createElement(ProfitAndLoss.DatePicker, null),
5777
+ /* @__PURE__ */ React75.createElement(ProfitAndLoss.Summaries, { vertical: true })
5778
+ ), /* @__PURE__ */ React75.createElement(
5779
+ "div",
5780
+ {
5781
+ className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
5782
+ },
5783
+ /* @__PURE__ */ React75.createElement(ProfitAndLoss.Chart, null)
5784
+ )), !hideTable && /* @__PURE__ */ React75.createElement(ProfitAndLoss.Table, null));
5785
+ };
5786
+
5787
+ // src/components/LedgerAccounts/LedgerAccounts.tsx
5788
+ import React82, { createContext as createContext3, useContext as useContext12 } from "react";
5789
+
5790
+ // src/hooks/useLedgerAccounts/useLedgerAccounts.tsx
5791
+ import { useState as useState16 } from "react";
5792
+ import useSWR5 from "swr";
5793
+ var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.sub_accounts || [])]).flat().filter((id) => id);
5794
+ var useLedgerAccounts = () => {
5795
+ const { auth, businessId, apiUrl } = useLayerContext();
5796
+ const [form, setForm] = useState16();
5797
+ const [showARForAccountId, setShowARForAccountId] = useState16();
5798
+ const { data, isLoading, isValidating, error, mutate } = useSWR5(
5799
+ businessId && auth?.access_token && `ledger-accounts-${businessId}`,
5800
+ Layer.getLedgerAccounts(apiUrl, auth?.access_token, {
5801
+ params: { businessId }
5802
+ })
5803
+ );
5804
+ const create = (newAccount) => {
5805
+ Layer.createAccount(apiUrl, auth?.access_token, {
5806
+ params: { businessId },
5807
+ body: newAccount
5808
+ }).then(({ data: data2 }) => (mutate(), data2));
5809
+ };
5810
+ const submitForm = () => {
5811
+ if (!form || !form.action) {
5812
+ return;
5813
+ }
5814
+ const data2 = {
5815
+ name: form.data.name || "Test name",
5816
+ normality: form.data.subType?.value,
5817
+ parent_id: form.data.parent ? {
5818
+ type: "AccountId",
5819
+ id: form.data.parent.value
5820
+ } : void 0,
5821
+ description: form.data.type?.value.toString() || "Test description"
5822
+ };
5823
+ if (form.action === "new") {
5824
+ create(data2);
5825
+ return;
5826
+ }
5827
+ if (form.action === "edit" && form.accountId) {
5828
+ return;
5829
+ }
5830
+ };
5831
+ const addAccount = () => setForm({
5832
+ action: "new",
5833
+ accountId: void 0,
5834
+ data: {
5835
+ parent: void 0,
5836
+ name: void 0,
5837
+ type: {
5838
+ value: "assets",
5839
+ label: "Assets"
5840
+ },
5841
+ subType: void 0,
5842
+ category: void 0
5843
+ }
5844
+ });
5845
+ const editAccount = (id) => {
5846
+ const allAccounts = flattenAccounts(data?.data?.accounts || []);
5847
+ const found = allAccounts?.find((x) => x.id === id);
5848
+ if (!found) {
5849
+ return;
5850
+ }
5851
+ const parent = allAccounts.find(
5852
+ (x) => x.sub_accounts?.find((el) => el.id === found.id)
5853
+ );
5854
+ setForm({
5855
+ action: "edit",
5856
+ accountId: id,
5857
+ data: {
5858
+ parent: parent ? {
5859
+ value: parent.id,
5860
+ label: parent.name
5861
+ } : void 0,
5862
+ name: found.name,
5863
+ type: {
5864
+ value: "assets",
5865
+ label: "Assets"
5866
+ },
5867
+ subType: void 0,
5868
+ category: void 0
5869
+ }
5870
+ });
5871
+ };
5872
+ const cancelForm = () => setForm(void 0);
5873
+ const changeFormData = (fieldName, value) => {
5874
+ if (!form) {
5875
+ return;
5876
+ }
5877
+ setForm({
5878
+ ...form,
5879
+ data: {
5880
+ ...form.data,
5881
+ [fieldName]: value
5882
+ }
5883
+ });
5884
+ };
5885
+ const refetch = () => mutate();
5886
+ return {
5887
+ data: data?.data,
5888
+ isLoading,
5889
+ isValidating,
5890
+ error,
5891
+ refetch,
5892
+ create,
5893
+ form,
5894
+ addAccount,
5895
+ editAccount,
5896
+ cancelForm,
5897
+ changeFormData,
5898
+ submitForm,
5899
+ showARForAccountId,
5900
+ setShowARForAccountId
5901
+ };
5902
+ };
5903
+
5904
+ // src/components/AccountsReceivable/AccountsReceivableIndex.tsx
5905
+ import React76, { useContext as useContext8, useMemo as useMemo7 } from "react";
5906
+ import classNames25 from "classnames";
5907
+ import { parseISO as parseISO9, format as formatTime7 } from "date-fns";
5908
+ var AccountsReceivable = () => {
5909
+ const { data, showARForAccountId, setShowARForAccountId } = useContext8(
5910
+ LedgerAccountsContext
5911
+ );
5912
+ const entry = useMemo7(() => {
5913
+ return flattenAccounts(data?.accounts || []).find(
5914
+ (x) => x.id === showARForAccountId
5915
+ );
5916
+ }, [showARForAccountId]);
5917
+ const baseClassName = classNames25(
5918
+ "Layer__accounts-receivable__index",
5919
+ showARForAccountId && "open"
5920
+ );
5921
+ const close = () => setShowARForAccountId(void 0);
5922
+ return /* @__PURE__ */ React76.createElement("div", { className: baseClassName }, /* @__PURE__ */ React76.createElement("div", { className: "Layer__accounts-receivable__header" }, /* @__PURE__ */ React76.createElement(Button, { onClick: close, variant: "secondary" /* secondary */ }, "Back"), /* @__PURE__ */ React76.createElement("div", { className: "Layer__accounts-receivable__title-container" }, /* @__PURE__ */ React76.createElement(
5923
+ Text,
5924
+ {
5925
+ weight: "bold" /* bold */,
5926
+ className: "Layer__accounts-receivable__title"
5927
+ },
5928
+ entry?.name || ""
5929
+ ), /* @__PURE__ */ React76.createElement(
5930
+ Button,
5931
+ {
5932
+ variant: "secondary" /* secondary */,
5933
+ rightIcon: /* @__PURE__ */ React76.createElement(DownloadCloud_default, { size: 12 })
5934
+ },
5935
+ "Download"
5936
+ )), /* @__PURE__ */ React76.createElement("div", { className: "Layer__accounts-receivable__balance-container" }, /* @__PURE__ */ React76.createElement(
5937
+ Text,
5938
+ {
5939
+ weight: "bold" /* bold */,
5940
+ className: "Layer__accounts-receivable__balance-label"
5941
+ },
5942
+ "Current balance"
5943
+ ), /* @__PURE__ */ React76.createElement(
5944
+ Text,
5945
+ {
5946
+ weight: "bold" /* bold */,
5947
+ className: "Layer__accounts-receivable__balance-value"
5948
+ },
5949
+ "$",
5950
+ centsToDollars(entry?.balance || 0)
5951
+ ))), /* @__PURE__ */ React76.createElement("table", { className: "Layer__table Layer__accounts-receivable-table" }, /* @__PURE__ */ React76.createElement("thead", null, /* @__PURE__ */ React76.createElement("tr", null, /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header" }, "Date"), /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header" }, "Journal id #"), /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header" }, "Source"), /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Debit"), /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Credit"), /* @__PURE__ */ React76.createElement("th", { className: "Layer__table-header Layer__table-cell--amount" }, "Running balance"))), /* @__PURE__ */ React76.createElement("tbody", null, entry?.entries?.map((x) => {
5952
+ return /* @__PURE__ */ React76.createElement("tr", { key: x.id }, /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, x.createdAt && formatTime7(parseISO9(x.createdAt), DATE_FORMAT))), /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, x.direction, " TBD")), /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, "TBD")), /* @__PURE__ */ React76.createElement("td", { className: "Layer__table-cell Layer__table-cell--amount" }, /* @__PURE__ */ React76.createElement("span", { className: "Layer__table-cell-content" }, "TBD")));
5953
+ }))));
5954
+ };
5955
+
5956
+ // src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
5957
+ import React79, { useContext as useContext9, useState as useState17 } from "react";
5958
+
5959
+ // src/icons/ArrowRightCircle.tsx
5960
+ import * as React77 from "react";
5961
+ var ArrowRightCircle = ({ size = 18, ...props }) => /* @__PURE__ */ React77.createElement(
5070
5962
  "svg",
5071
5963
  {
5072
5964
  xmlns: "http://www.w3.org/2000/svg",
@@ -5076,424 +5968,304 @@ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React67.createElement(
5076
5968
  width: size,
5077
5969
  height: size
5078
5970
  },
5079
- /* @__PURE__ */ React67.createElement(
5971
+ /* @__PURE__ */ React77.createElement(
5080
5972
  "path",
5081
5973
  {
5082
- d: "M13.5 4.5L4.5 13.5",
5974
+ d: "M9 16.5C13.1421 16.5 16.5 13.1421 16.5 9C16.5 4.85786 13.1421 1.5 9 1.5C4.85786 1.5 1.5 4.85786 1.5 9C1.5 13.1421 4.85786 16.5 9 16.5Z",
5083
5975
  stroke: "currentColor",
5084
- strokeLinecap: "round",
5085
- strokeLinejoin: "round"
5976
+ "stroke-linecap": "round",
5977
+ "stroke-linejoin": "round"
5086
5978
  }
5087
5979
  ),
5088
- /* @__PURE__ */ React67.createElement(
5980
+ /* @__PURE__ */ React77.createElement(
5089
5981
  "path",
5090
5982
  {
5091
- d: "M4.5 4.5L13.5 13.5",
5983
+ d: "M9 12L12 9L9 6",
5092
5984
  stroke: "currentColor",
5093
- strokeLinecap: "round",
5094
- strokeLinejoin: "round"
5985
+ "stroke-linecap": "round",
5986
+ "stroke-linejoin": "round"
5987
+ }
5988
+ ),
5989
+ /* @__PURE__ */ React77.createElement(
5990
+ "path",
5991
+ {
5992
+ d: "M6 9H12",
5993
+ stroke: "currentColor",
5994
+ "stroke-linecap": "round",
5995
+ "stroke-linejoin": "round"
5095
5996
  }
5096
5997
  )
5097
5998
  );
5098
- var X_default = X;
5999
+ var ArrowRightCircle_default = ArrowRightCircle;
5099
6000
 
5100
- // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
5101
- import classNames23 from "classnames";
5102
- import { format as format6 } from "date-fns";
5103
- import {
5104
- PieChart,
5105
- Pie,
5106
- Cell as Cell2,
5107
- ResponsiveContainer as ResponsiveContainer2,
5108
- Label,
5109
- Text as ChartText
5110
- } from "recharts";
5111
- var INACTIVE_OPACITY_LEVELS = [0.85, 0.7, 0.66, 0.55, 0.4, 0.33, 0.25, 0.15];
5112
- var DEFAULT_CHART_COLORS = [
5113
- {
5114
- color: "#7417B3",
5115
- opacity: 1
5116
- },
5117
- {
5118
- color: "#7417B3",
5119
- opacity: 0.8
5120
- },
5121
- {
5122
- color: "#7417B3",
5123
- opacity: 0.6
5124
- },
5125
- {
5126
- color: "#7417B3",
5127
- opacity: 0.4
5128
- },
5129
- {
5130
- color: "#7417B3",
5131
- opacity: 0.2
5132
- },
5133
- {
5134
- color: "#7417B3",
5135
- opacity: 0.1
5136
- },
5137
- {
5138
- color: "#006A80",
5139
- opacity: 1
5140
- },
5141
- {
5142
- color: "#006A80",
5143
- opacity: 0.8
5144
- },
5145
- {
5146
- color: "#006A80",
5147
- opacity: 0.6
5148
- },
5149
- {
5150
- color: "#006A80",
5151
- opacity: 0.4
5152
- },
5153
- {
5154
- color: "#006A80",
5155
- opacity: 0.2
5156
- },
5157
- {
5158
- color: "#006A80",
5159
- opacity: 0.1
5160
- },
5161
- {
5162
- color: "#009930",
5163
- opacity: 1
5164
- },
5165
- {
5166
- color: "#009930",
5167
- opacity: 0.8
5168
- },
5169
- {
5170
- color: "#009930",
5171
- opacity: 0.6
5172
- },
6001
+ // src/icons/Edit2.tsx
6002
+ import * as React78 from "react";
6003
+ var Edit2 = ({ size = 18, ...props }) => /* @__PURE__ */ React78.createElement(
6004
+ "svg",
5173
6005
  {
5174
- color: "#009930",
5175
- opacity: 0.4
6006
+ xmlns: "http://www.w3.org/2000/svg",
6007
+ viewBox: "0 0 18 18",
6008
+ fill: "none",
6009
+ ...props,
6010
+ width: size,
6011
+ height: size
5176
6012
  },
6013
+ /* @__PURE__ */ React78.createElement(
6014
+ "path",
6015
+ {
6016
+ d: "M12.75 2.25C12.947 2.05301 13.1808 1.89676 13.4382 1.79015C13.6956 1.68355 13.9714 1.62868 14.25 1.62868C14.5286 1.62868 14.8044 1.68355 15.0618 1.79015C15.3192 1.89676 15.553 2.05301 15.75 2.25C15.947 2.44698 16.1032 2.68083 16.2098 2.9382C16.3165 3.19557 16.3713 3.47142 16.3713 3.75C16.3713 4.02857 16.3165 4.30442 16.2098 4.56179C16.1032 4.81916 15.947 5.05302 15.75 5.25L5.625 15.375L1.5 16.5L2.625 12.375L12.75 2.25Z",
6017
+ stroke: "currentColor",
6018
+ "stroke-linecap": "round",
6019
+ "stroke-linejoin": "round"
6020
+ }
6021
+ )
6022
+ );
6023
+ var Edit2_default = Edit2;
6024
+
6025
+ // src/components/LedgerAccountsRow/LedgerAccountsRow.tsx
6026
+ import classNames26 from "classnames";
6027
+ var INDENTATION = 12;
6028
+ var LedgerAccountsRow = ({
6029
+ account,
6030
+ depth = 0
6031
+ }) => {
6032
+ const { form, editAccount, setShowARForAccountId } = useContext9(
6033
+ LedgerAccountsContext
6034
+ );
6035
+ const [isOpen, setIsOpen] = useState17(false);
6036
+ const baseClass = classNames26(
6037
+ "Layer__alt-table-row",
6038
+ isOpen ? "Layer__alt-table-row--expanded" : "Layer__alt-table-row--collapsed",
6039
+ `Layer__alt-table-row--depth-${depth}`,
6040
+ form?.accountId === account.id && "active"
6041
+ );
6042
+ return /* @__PURE__ */ React79.createElement(React79.Fragment, null, /* @__PURE__ */ React79.createElement("div", { className: baseClass, onClick: () => setIsOpen(!isOpen) }, /* @__PURE__ */ React79.createElement(
6043
+ "div",
6044
+ {
6045
+ className: "Layer__alt-table__cell Layer__coa__name",
6046
+ style: { paddingLeft: INDENTATION * depth + 16 }
6047
+ },
6048
+ account.sub_accounts && account.sub_accounts.length > 0 && /* @__PURE__ */ React79.createElement(
6049
+ ChevronDownFill_default,
6050
+ {
6051
+ size: 16,
6052
+ className: "Layer__alt-table__expand-icon"
6053
+ }
6054
+ ),
6055
+ /* @__PURE__ */ React79.createElement("span", { className: "Layer__coa__name__text" }, account.name)
6056
+ ), /* @__PURE__ */ React79.createElement("div", { className: "Layer__alt-table__cell Layer__coa__type" }, account.normality), /* @__PURE__ */ React79.createElement("div", { className: "Layer__alt-table__cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ React79.createElement("div", { className: "Layer__alt-table__cell Layer__coa__balance" }, "$", centsToDollars(Math.abs(account.balance || 0))), /* @__PURE__ */ React79.createElement("div", { className: "Layer__alt-table__cell Layer__coa__actions" }, /* @__PURE__ */ React79.createElement(
6057
+ Button,
6058
+ {
6059
+ variant: "secondary" /* secondary */,
6060
+ rightIcon: /* @__PURE__ */ React79.createElement(Edit2_default, { size: 12 }),
6061
+ onClick: (e) => {
6062
+ e.preventDefault();
6063
+ e.stopPropagation();
6064
+ editAccount(account.id);
6065
+ }
6066
+ },
6067
+ "Edit"
6068
+ ), /* @__PURE__ */ React79.createElement(
6069
+ Button,
6070
+ {
6071
+ variant: "secondary" /* secondary */,
6072
+ rightIcon: /* @__PURE__ */ React79.createElement(ArrowRightCircle_default, { size: 12 }),
6073
+ onClick: (e) => {
6074
+ e.preventDefault();
6075
+ e.stopPropagation();
6076
+ setShowARForAccountId(account.id);
6077
+ }
6078
+ },
6079
+ "Open"
6080
+ ))), isOpen && (account.sub_accounts || []).map((subAccount) => /* @__PURE__ */ React79.createElement(
6081
+ LedgerAccountsRow,
6082
+ {
6083
+ key: subAccount.id,
6084
+ account: subAccount,
6085
+ depth: depth + 1
6086
+ }
6087
+ )));
6088
+ };
6089
+
6090
+ // src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
6091
+ import React81, { useContext as useContext11 } from "react";
6092
+
6093
+ // src/components/LedgerAccountsForm/LedgerAccountsForm.tsx
6094
+ import React80, { useContext as useContext10, useMemo as useMemo8 } from "react";
6095
+ var SUB_TYPE_OPTIONS = [
5177
6096
  {
5178
- color: "#009930",
5179
- opacity: 0.2
6097
+ value: "DEBIT" /* DEBIT */,
6098
+ label: "Debit"
5180
6099
  },
5181
6100
  {
5182
- color: "#009930",
5183
- opacity: 0.1
6101
+ value: "CREDIT" /* CREDIT */,
6102
+ label: "Credit"
5184
6103
  }
5185
6104
  ];
5186
- var ProfitAndLossDetailedCharts = () => {
5187
- const {
5188
- data,
5189
- filteredData,
5190
- filteredTotal,
5191
- sortBy,
5192
- filters,
5193
- isLoading,
5194
- dateRange,
5195
- sidebarScope,
5196
- setSidebarScope,
5197
- setFilterTypes
5198
- } = useContext6(ProfitAndLoss.Context);
5199
- const [hoveredItem, setHoveredItem] = useState15();
5200
- const chartData = useMemo5(() => {
5201
- if (!filteredData) {
5202
- return [];
5203
- }
5204
- return filteredData.map((x) => {
5205
- if (x.hidden) {
5206
- return {
5207
- name: x.display_name,
5208
- value: 0
5209
- };
5210
- }
6105
+ var LedgerAccountsForm = () => {
6106
+ const { form, data, changeFormData, cancelForm, submitForm } = useContext10(
6107
+ LedgerAccountsContext
6108
+ );
6109
+ const parentOptions = useMemo8(
6110
+ () => flattenAccounts(data?.accounts || []).sort((a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0).map((x) => {
5211
6111
  return {
5212
- name: x.display_name,
5213
- value: x.value
6112
+ label: x.name,
6113
+ value: x.id
5214
6114
  };
5215
- });
5216
- }, [filteredData]);
5217
- const buildColClass = (column) => {
5218
- return classNames23(
5219
- "Layer__sortable-col",
5220
- sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
5221
- );
5222
- };
5223
- return /* @__PURE__ */ React68.createElement(
5224
- "div",
6115
+ }),
6116
+ [data?.accounts?.length]
6117
+ );
6118
+ const entry = useMemo8(() => {
6119
+ if (form?.action === "edit" && form.accountId) {
6120
+ return flattenAccounts(data?.accounts || []).find(
6121
+ (x) => x.id === form.accountId
6122
+ );
6123
+ }
6124
+ return;
6125
+ }, [data, form?.accountId]);
6126
+ console.log(entry);
6127
+ if (!form) {
6128
+ return;
6129
+ }
6130
+ return /* @__PURE__ */ React80.createElement(
6131
+ "form",
5225
6132
  {
5226
- className: classNames23(
5227
- "Layer__profit-and-loss__side-panel",
5228
- sidebarScope && "open"
5229
- )
6133
+ onSubmit: (e) => {
6134
+ e.preventDefault();
6135
+ submitForm();
6136
+ }
5230
6137
  },
5231
- /* @__PURE__ */ React68.createElement("div", { className: "Layer__profit-and-loss-detailed-charts" }, /* @__PURE__ */ React68.createElement("header", null, /* @__PURE__ */ React68.createElement("div", { className: "Layer__profit-and-loss-detailed-charts__head" }, /* @__PURE__ */ React68.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, humanizeTitle(sidebarScope)), /* @__PURE__ */ React68.createElement(Text, { size: "sm" /* sm */, className: "date" }, format6(dateRange.startDate, "LLLL, y"))), /* @__PURE__ */ React68.createElement(
6138
+ /* @__PURE__ */ React80.createElement("div", { className: "Layer__ledger-accounts__sidebar__header" }, /* @__PURE__ */ React80.createElement(Text, { size: "lg" /* lg */, weight: "bold" /* bold */, className: "title" }, form?.action === "edit" ? "Edit" : "Add New", " Account"), /* @__PURE__ */ React80.createElement("div", { className: "actions" }, /* @__PURE__ */ React80.createElement(
5232
6139
  Button,
5233
6140
  {
5234
- rightIcon: /* @__PURE__ */ React68.createElement(X_default, null),
5235
- iconOnly: true,
5236
- onClick: () => setSidebarScope(void 0),
6141
+ type: "button",
6142
+ onClick: cancelForm,
5237
6143
  variant: "secondary" /* secondary */
5238
- }
5239
- )), /* @__PURE__ */ React68.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React68.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React68.createElement(PieChart, null, /* @__PURE__ */ React68.createElement(
5240
- Pie,
5241
- {
5242
- data: chartData,
5243
- dataKey: "value",
5244
- nameKey: "name",
5245
- cx: "50%",
5246
- cy: "50%",
5247
- innerRadius: 105,
5248
- outerRadius: 120,
5249
- paddingAngle: 0.5,
5250
- fill: "#8884d8"
5251
6144
  },
5252
- chartData.map((entry, index) => {
5253
- const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
5254
- let fill = colorConfig.color;
5255
- let opacity = colorConfig.opacity;
5256
- let active = true;
5257
- if (hoveredItem && entry.name !== hoveredItem) {
5258
- active = false;
5259
- fill = void 0;
5260
- opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
5261
- }
5262
- return /* @__PURE__ */ React68.createElement(
5263
- Cell2,
5264
- {
5265
- key: `cell-${index}`,
5266
- className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
5267
- style: { fill },
5268
- opacity,
5269
- onMouseEnter: () => setHoveredItem(entry.name),
5270
- onMouseLeave: () => setHoveredItem(void 0)
5271
- }
5272
- );
5273
- }),
5274
- /* @__PURE__ */ React68.createElement(
5275
- Label,
5276
- {
5277
- position: "center",
5278
- value: "Total",
5279
- className: "pie-center-label-title",
5280
- content: (props) => {
5281
- const { cx, cy } = props.viewBox ?? {
5282
- cx: 0,
5283
- cy: 0
5284
- };
5285
- const positioningProps = {
5286
- x: cx,
5287
- y: (cy || 0) - 15,
5288
- textAnchor: "middle",
5289
- verticalAnchor: "middle"
5290
- };
5291
- let text = "Total";
5292
- if (hoveredItem) {
5293
- text = hoveredItem;
5294
- }
5295
- return /* @__PURE__ */ React68.createElement(
5296
- ChartText,
5297
- {
5298
- ...positioningProps,
5299
- className: "pie-center-label__title"
5300
- },
5301
- text
5302
- );
5303
- }
5304
- }
5305
- ),
5306
- /* @__PURE__ */ React68.createElement(
5307
- Label,
5308
- {
5309
- position: "center",
5310
- value: "Total",
5311
- className: "pie-center-label-title",
5312
- content: (props) => {
5313
- const { cx, cy } = props.viewBox ?? {
5314
- cx: 0,
5315
- cy: 0
5316
- };
5317
- const positioningProps = {
5318
- x: cx,
5319
- y: (cy || 0) + 5,
5320
- textAnchor: "middle",
5321
- verticalAnchor: "middle"
5322
- };
5323
- let value = filteredTotal;
5324
- if (hoveredItem) {
5325
- value = filteredData.find(
5326
- (x) => x.display_name === hoveredItem
5327
- )?.value;
5328
- }
5329
- return /* @__PURE__ */ React68.createElement(
5330
- ChartText,
5331
- {
5332
- ...positioningProps,
5333
- className: "pie-center-label__value"
5334
- },
5335
- `$${centsToDollars(value)}`
5336
- );
5337
- }
5338
- }
5339
- ),
5340
- /* @__PURE__ */ React68.createElement(
5341
- Label,
5342
- {
5343
- position: "center",
5344
- value: "Total",
5345
- className: "pie-center-label-title",
5346
- content: (props) => {
5347
- const { cx, cy } = props.viewBox ?? {
5348
- cx: 0,
5349
- cy: 0
5350
- };
5351
- const positioningProps = {
5352
- x: cx,
5353
- y: (cy || 0) + 25,
5354
- height: 20,
5355
- textAnchor: "middle",
5356
- verticalAnchor: "middle"
5357
- };
5358
- if (hoveredItem) {
5359
- return /* @__PURE__ */ React68.createElement(
5360
- ChartText,
5361
- {
5362
- ...positioningProps,
5363
- className: "pie-center-label__share"
5364
- },
5365
- `${formatPercent(
5366
- filteredData.find(
5367
- (x) => x.display_name === hoveredItem
5368
- )?.share
5369
- )}%`
5370
- );
5371
- }
5372
- return;
5373
- }
5374
- }
5375
- )
5376
- )))), /* @__PURE__ */ React68.createElement("div", { className: "filters" }, /* @__PURE__ */ React68.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ React68.createElement(
6145
+ "Cancel"
6146
+ ), /* @__PURE__ */ React80.createElement(SubmitButton, { type: "submit", noIcon: true, active: true }, "Save"))),
6147
+ entry && /* @__PURE__ */ React80.createElement("div", { className: "Layer__ledger-accounts__form-edit-entry" }, /* @__PURE__ */ React80.createElement(Text, { weight: "bold" /* bold */ }, entry.name), /* @__PURE__ */ React80.createElement(Text, { weight: "bold" /* bold */ }, "$", centsToDollars(entry.balance || 0))),
6148
+ /* @__PURE__ */ React80.createElement("div", { className: "Layer__ledger-accounts__form" }, /* @__PURE__ */ React80.createElement(InputGroup, { name: "parent", label: "Parent", inline: true }, /* @__PURE__ */ React80.createElement(
5377
6149
  Select3,
5378
6150
  {
5379
- className: "type-select",
5380
- classNamePrefix: "Layer__select",
5381
- value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
5382
- value: x,
5383
- label: x
5384
- })) : [],
5385
- isMulti: true,
5386
- isClearable: false,
5387
- options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
5388
- label: x,
5389
- value: x
5390
- })),
5391
- onChange: (selected) => {
5392
- setFilterTypes(
5393
- sidebarScope ?? "expenses",
5394
- selected.map((x) => x.value)
5395
- );
5396
- }
6151
+ options: parentOptions,
6152
+ value: form?.data.parent,
6153
+ onChange: (sel) => changeFormData("parent", sel)
5397
6154
  }
5398
- )), /* @__PURE__ */ React68.createElement("div", { className: "details-container" }, /* @__PURE__ */ React68.createElement("div", { className: "table" }, /* @__PURE__ */ React68.createElement("table", null, /* @__PURE__ */ React68.createElement("thead", null, /* @__PURE__ */ React68.createElement("tr", null, /* @__PURE__ */ React68.createElement(
5399
- "th",
6155
+ )), /* @__PURE__ */ React80.createElement(InputGroup, { name: "name", label: "Name", inline: true }, /* @__PURE__ */ React80.createElement(
6156
+ Input,
5400
6157
  {
5401
- className: buildColClass("category"),
5402
- onClick: () => sortBy(sidebarScope ?? "expenses", "category")
5403
- },
5404
- "Expense/Sale ",
5405
- /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5406
- ), /* @__PURE__ */ React68.createElement(
5407
- "th",
6158
+ name: "name",
6159
+ value: form?.data.name,
6160
+ onChange: (e) => changeFormData("name", e.target.value)
6161
+ }
6162
+ )), /* @__PURE__ */ React80.createElement(InputGroup, { name: "type", label: "Type", inline: true }, /* @__PURE__ */ React80.createElement(
6163
+ Select3,
5408
6164
  {
5409
- className: buildColClass("type"),
5410
- onClick: () => sortBy(sidebarScope ?? "expenses", "type")
5411
- },
5412
- "Type ",
5413
- /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5414
- ), /* @__PURE__ */ React68.createElement("th", null), /* @__PURE__ */ React68.createElement(
5415
- "th",
6165
+ options: [],
6166
+ disabled: true,
6167
+ value: form?.data.type,
6168
+ onChange: (sel) => changeFormData("type", sel)
6169
+ }
6170
+ )), /* @__PURE__ */ React80.createElement(InputGroup, { name: "subType", label: "Sub-Type", inline: true }, /* @__PURE__ */ React80.createElement(
6171
+ Select3,
5416
6172
  {
5417
- className: buildColClass("value"),
5418
- onClick: () => sortBy(sidebarScope ?? "expenses", "value")
5419
- },
5420
- "Value ",
5421
- /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5422
- ))), /* @__PURE__ */ React68.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
5423
- const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
5424
- return /* @__PURE__ */ React68.createElement(
5425
- "tr",
5426
- {
5427
- key: `pl-side-table-item-${idx}`,
5428
- className: classNames23(
5429
- "Layer__profit-and-loss-detailed-table__row",
5430
- hoveredItem && hoveredItem !== item.display_name ? "inactive" : ""
5431
- ),
5432
- onMouseEnter: () => setHoveredItem(item.display_name),
5433
- onMouseLeave: () => setHoveredItem(void 0)
5434
- },
5435
- /* @__PURE__ */ React68.createElement("td", { className: "category-col" }, item.display_name),
5436
- /* @__PURE__ */ React68.createElement("td", { className: "type-col" }, item.type),
5437
- /* @__PURE__ */ React68.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
5438
- /* @__PURE__ */ React68.createElement("td", { className: "share-col" }, /* @__PURE__ */ React68.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ React68.createElement(
5439
- "div",
5440
- {
5441
- className: "share-icon",
5442
- style: {
5443
- background: colorConfig.color,
5444
- opacity: colorConfig.opacity
5445
- }
5446
- }
5447
- )))
5448
- );
5449
- }))))))
6173
+ options: SUB_TYPE_OPTIONS,
6174
+ value: form?.data.subType,
6175
+ onChange: (sel) => changeFormData("subType", sel)
6176
+ }
6177
+ )), /* @__PURE__ */ React80.createElement(InputGroup, { name: "category", label: "Category", inline: true }, /* @__PURE__ */ React80.createElement(
6178
+ Select3,
6179
+ {
6180
+ options: [],
6181
+ value: form?.data.category,
6182
+ onChange: (sel) => changeFormData("category", sel)
6183
+ }
6184
+ )))
5450
6185
  );
5451
6186
  };
5452
6187
 
5453
- // src/components/ProfitAndLossView/ProfitAndLossView.tsx
5454
- var COMPONENT_NAME3 = "profit-and-loss";
5455
- var ProfitAndLossView = (props) => {
5456
- return /* @__PURE__ */ React69.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ React69.createElement(ProfitAndLoss, null, /* @__PURE__ */ React69.createElement("div", { className: `Layer__${COMPONENT_NAME3}__main-panel` }, /* @__PURE__ */ React69.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ React69.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ React69.createElement(Components, { ...props })), props.showDetailedCharts !== false && /* @__PURE__ */ React69.createElement(ProfitAndLossDetailedCharts, null)));
5457
- };
5458
- var Components = ({
5459
- hideChart = false,
5460
- hideTable = false
5461
- }) => {
5462
- const { error, isLoading, isValidating, refetch } = useContext7(
5463
- ProfitAndLoss.Context
5464
- );
5465
- if (!isLoading && error) {
5466
- return /* @__PURE__ */ React69.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React69.createElement(
5467
- DataState,
5468
- {
5469
- status: "failed" /* failed */,
5470
- title: "Something went wrong",
5471
- description: "We couldn\u2019t load your data.",
5472
- onRefresh: () => refetch(),
5473
- isLoading: isValidating
5474
- }
5475
- ));
5476
- }
5477
- return /* @__PURE__ */ React69.createElement(React69.Fragment, null, !hideChart && /* @__PURE__ */ React69.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ React69.createElement(
6188
+ // src/components/LedgerAccountsSidebar/LedgerAccountsSidebar.tsx
6189
+ import classNames27 from "classnames";
6190
+ var LedgerAccountsSidebar = () => {
6191
+ const { form } = useContext11(LedgerAccountsContext);
6192
+ return /* @__PURE__ */ React81.createElement(
5478
6193
  "div",
5479
6194
  {
5480
- className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
6195
+ className: classNames27(
6196
+ "Layer__ledger-accounts__sidebar",
6197
+ form ? "open" : ""
6198
+ )
5481
6199
  },
5482
- /* @__PURE__ */ React69.createElement(ProfitAndLoss.DatePicker, null),
5483
- /* @__PURE__ */ React69.createElement(ProfitAndLoss.Summaries, { vertical: true })
5484
- ), /* @__PURE__ */ React69.createElement(
5485
- "div",
6200
+ /* @__PURE__ */ React81.createElement("div", { className: "Layer__ledger-accounts__sidebar-content" }, /* @__PURE__ */ React81.createElement(LedgerAccountsForm, null))
6201
+ );
6202
+ };
6203
+
6204
+ // src/components/LedgerAccounts/LedgerAccounts.tsx
6205
+ var COMPONENT_NAME4 = "ledger-accounts";
6206
+ var LedgerAccountsContext = createContext3({
6207
+ data: void 0,
6208
+ isLoading: false,
6209
+ isValidating: false,
6210
+ error: void 0,
6211
+ refetch: () => {
6212
+ },
6213
+ create: () => {
6214
+ },
6215
+ form: void 0,
6216
+ addAccount: () => {
6217
+ },
6218
+ editAccount: () => {
6219
+ },
6220
+ cancelForm: () => {
6221
+ },
6222
+ changeFormData: () => {
6223
+ },
6224
+ submitForm: () => {
6225
+ },
6226
+ showARForAccountId: void 0,
6227
+ setShowARForAccountId: () => {
6228
+ }
6229
+ });
6230
+ var LedgerAccounts = () => {
6231
+ const contextData = useLedgerAccounts();
6232
+ return /* @__PURE__ */ React82.createElement(LedgerAccountsContext.Provider, { value: contextData }, /* @__PURE__ */ React82.createElement(LedgerAccountsContent, null));
6233
+ };
6234
+ var LedgerAccountsContent = () => {
6235
+ const { data, isLoading, addAccount, error, isValidating, refetch } = useContext12(LedgerAccountsContext);
6236
+ return /* @__PURE__ */ React82.createElement(Container, { name: COMPONENT_NAME4 }, /* @__PURE__ */ React82.createElement("div", { className: `Layer__${COMPONENT_NAME4}__main-panel` }, /* @__PURE__ */ React82.createElement(Header, { className: `Layer__${COMPONENT_NAME4}__header` }, /* @__PURE__ */ React82.createElement(Heading, { className: `Layer__${COMPONENT_NAME4}__title` }, "Chart of Accounts"), /* @__PURE__ */ React82.createElement("div", { className: `Layer__${COMPONENT_NAME4}__actions` }, /* @__PURE__ */ React82.createElement(
6237
+ Button,
5486
6238
  {
5487
- className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
6239
+ variant: "secondary" /* secondary */,
6240
+ disabled: isLoading,
6241
+ rightIcon: /* @__PURE__ */ React82.createElement(DownloadCloud_default, { size: 12 })
5488
6242
  },
5489
- /* @__PURE__ */ React69.createElement(ProfitAndLoss.Chart, null)
5490
- )), !hideTable && /* @__PURE__ */ React69.createElement(ProfitAndLoss.Table, null));
6243
+ "Download"
6244
+ ), /* @__PURE__ */ React82.createElement(Button, { onClick: () => addAccount(), disabled: isLoading }, "Add Account"))), /* @__PURE__ */ React82.createElement("div", { className: `Layer__${COMPONENT_NAME4}__table` }, /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table-row Layer__alt-table-row--header" }, /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__name" }, "Name"), /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__type" }, "Type"), /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__subtype" }, "Sub-Type"), /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__balance" }, "Balance"), /* @__PURE__ */ React82.createElement("div", { className: "Layer__alt-table__head-cell Layer__coa__actions" })), error ? /* @__PURE__ */ React82.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React82.createElement(
6245
+ DataState,
6246
+ {
6247
+ status: "failed" /* failed */,
6248
+ title: "Something went wrong",
6249
+ description: "We couldn\u2019t load your data.",
6250
+ onRefresh: () => refetch(),
6251
+ isLoading: isValidating || isLoading
6252
+ }
6253
+ )) : null, (!data || isLoading) && !error ? /* @__PURE__ */ React82.createElement("div", { className: `Layer__${COMPONENT_NAME4}__loader-container` }, /* @__PURE__ */ React82.createElement(Loader2, null)) : null, !error && data?.accounts.map((account) => /* @__PURE__ */ React82.createElement(LedgerAccountsRow, { key: account.id, account, depth: 0 })), !isLoading && !error && data?.accounts.length === 0 ? /* @__PURE__ */ React82.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React82.createElement(
6254
+ DataState,
6255
+ {
6256
+ status: "info" /* info */,
6257
+ title: "Accounts were not found",
6258
+ description: 'New account can be created with "Add Account".',
6259
+ onRefresh: () => refetch(),
6260
+ isLoading: isValidating
6261
+ }
6262
+ )) : null)), /* @__PURE__ */ React82.createElement(LedgerAccountsSidebar, null), /* @__PURE__ */ React82.createElement(AccountsReceivable, null));
5491
6263
  };
5492
6264
 
5493
6265
  // src/providers/LayerProvider/LayerProvider.tsx
5494
- import React70, { useReducer, useEffect as useEffect9 } from "react";
6266
+ import React83, { useReducer, useEffect as useEffect9 } from "react";
5495
6267
  import { add as add2, isBefore } from "date-fns";
5496
- import useSWR5, { SWRConfig } from "swr";
6268
+ import useSWR6, { SWRConfig } from "swr";
5497
6269
  var reducer = (state, action) => {
5498
6270
  switch (action.type) {
5499
6271
  case "LayerContext.setAuth" /* setAuth */:
@@ -5546,7 +6318,7 @@ var LayerProvider = ({
5546
6318
  theme,
5547
6319
  colors
5548
6320
  });
5549
- const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR5(
6321
+ const { data: auth } = appId !== void 0 && appSecret !== void 0 ? useSWR6(
5550
6322
  businessAccessToken === void 0 && appId !== void 0 && appSecret !== void 0 && isBefore(state.auth.expires_at, /* @__PURE__ */ new Date()) && "authenticate",
5551
6323
  Layer.authenticate({
5552
6324
  appId,
@@ -5581,7 +6353,7 @@ var LayerProvider = ({
5581
6353
  });
5582
6354
  }
5583
6355
  }, [businessAccessToken, auth?.access_token]);
5584
- useSWR5(
6356
+ useSWR6(
5585
6357
  businessId && auth?.access_token && `categories-${businessId}`,
5586
6358
  Layer.getCategories(apiUrl, auth?.access_token, { params: { businessId } }),
5587
6359
  {
@@ -5606,170 +6378,14 @@ var LayerProvider = ({
5606
6378
  }
5607
6379
  return;
5608
6380
  };
5609
- return /* @__PURE__ */ React70.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React70.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
5610
- };
5611
-
5612
- // src/components/ChartOfAccounts/ChartOfAccounts.tsx
5613
- import React73, { useState as useState17 } from "react";
5614
-
5615
- // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
5616
- import useSWR6 from "swr";
5617
- var useChartOfAccounts = () => {
5618
- const { auth, businessId, apiUrl } = useLayerContext();
5619
- const { data, isLoading, error, mutate } = useSWR6(
5620
- businessId && auth?.access_token && `chart-of-accounts-${businessId}`,
5621
- Layer.getChartOfAccounts(apiUrl, auth?.access_token, {
5622
- params: { businessId }
5623
- })
5624
- );
5625
- const create = (newAccount) => Layer.createAccount(apiUrl, auth?.access_token, {
5626
- params: { businessId },
5627
- body: newAccount
5628
- }).then(({ data: data2 }) => (mutate(), data2));
5629
- return { data: data?.data, isLoading, error, create };
5630
- };
5631
-
5632
- // src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
5633
- import React71, { useMemo as useMemo6, useState as useState16 } from "react";
5634
- import Select4 from "react-select";
5635
- var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
5636
- var ChartOfAccountsNewForm = () => {
5637
- const { data, create: createAccount2 } = useChartOfAccounts();
5638
- const accountOptions = useMemo6(
5639
- () => flattenAccounts(data?.accounts || []).sort(
5640
- (a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
5641
- ),
5642
- [data?.accounts?.length]
5643
- );
5644
- const [name, setName] = useState16("");
5645
- const [description, setDescription] = useState16("");
5646
- const [normality, setNormality] = useState16("DEBIT" /* DEBIT */);
5647
- const [parentAccount, setParentAccount] = useState16(
5648
- data?.accounts[0]
5649
- );
5650
- const save = () => {
5651
- createAccount2({
5652
- name,
5653
- normality,
5654
- parent_id: {
5655
- type: "AccountId",
5656
- id: parentAccount?.id || ""
5657
- },
5658
- description
5659
- });
5660
- };
5661
- return /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Name"), /* @__PURE__ */ React71.createElement(
5662
- "input",
5663
- {
5664
- name: "name",
5665
- value: name,
5666
- onChange: (event) => setName(event.target.value)
5667
- }
5668
- )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Description"), /* @__PURE__ */ React71.createElement(
5669
- "input",
5670
- {
5671
- name: "description",
5672
- value: description,
5673
- onChange: (event) => setDescription(event.target.value)
5674
- }
5675
- )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Normality"), /* @__PURE__ */ React71.createElement(
5676
- Select4,
5677
- {
5678
- isSearchable: false,
5679
- onChange: (value) => value && setNormality(value.value),
5680
- options: [
5681
- { label: "Credit", value: "CREDIT" /* CREDIT */ },
5682
- { label: "Debit", value: "DEBIT" /* DEBIT */ }
5683
- ]
5684
- }
5685
- )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Parent Account"), /* @__PURE__ */ React71.createElement(
5686
- Select4,
5687
- {
5688
- isSearchable: true,
5689
- value: parentAccount,
5690
- onChange: (value) => value && setParentAccount(value),
5691
- getOptionLabel: (a) => a.name,
5692
- getOptionValue: (a) => a.id,
5693
- options: accountOptions
5694
- }
5695
- )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ React71.createElement("button", { onClick: save }, "Save")));
5696
- };
5697
-
5698
- // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
5699
- import React72 from "react";
5700
- var ChartOfAccountsRow = ({ account, depth = 0 }) => {
5701
- const classNames24 = [
5702
- "Layer__chart-of-accounts-row__table-cell",
5703
- depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
5704
- ];
5705
- const className = classNames24.filter((id) => id).join(" ");
5706
- const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
5707
- return /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement(
5708
- "div",
5709
- {
5710
- className: `${className} Layer__chart-of-accounts-row__table-cell--name`
5711
- },
5712
- account.name
5713
- ), /* @__PURE__ */ React72.createElement(
5714
- "div",
5715
- {
5716
- className: `${className} Layer__chart-of-accounts-row__table-cell--type`
5717
- },
5718
- "Assets"
5719
- ), /* @__PURE__ */ React72.createElement(
5720
- "div",
5721
- {
5722
- className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
5723
- },
5724
- "Cash"
5725
- ), /* @__PURE__ */ React72.createElement(
5726
- "div",
5727
- {
5728
- className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
5729
- },
5730
- centsToDollars(Math.abs(account.balance || 0))
5731
- ), /* @__PURE__ */ React72.createElement(
5732
- "div",
5733
- {
5734
- className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
5735
- },
5736
- /* @__PURE__ */ React72.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
5737
- ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ React72.createElement(
5738
- ChartOfAccountsRow,
5739
- {
5740
- key: subAccount.id,
5741
- account: subAccount,
5742
- depth: depth + 1
5743
- }
5744
- )));
5745
- };
5746
-
5747
- // src/components/ChartOfAccounts/ChartOfAccounts.tsx
5748
- var ChartOfAccounts = () => {
5749
- const { data, isLoading } = useChartOfAccounts();
5750
- const [showingForm, setShowingForm] = useState17(false);
5751
- return /* @__PURE__ */ React73.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ React73.createElement(React73.Fragment, null, /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ React73.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ React73.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ React73.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ React73.createElement(
5752
- "button",
5753
- {
5754
- className: "Layer__chart-of-accounts__edit-accounts-button",
5755
- onClick: () => setShowingForm(!showingForm)
5756
- },
5757
- "Edit Accounts"
5758
- ))), showingForm && /* @__PURE__ */ React73.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ React73.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__ */ React73.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ React73.createElement(
5759
- ChartOfAccountsRow,
5760
- {
5761
- key: account.id,
5762
- account,
5763
- depth: 0
5764
- }
5765
- )))));
6381
+ return /* @__PURE__ */ React83.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React83.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
5766
6382
  };
5767
6383
  export {
5768
6384
  BalanceSheet,
5769
6385
  BankTransactions,
5770
- ChartOfAccounts,
5771
6386
  Hello,
5772
6387
  LayerProvider,
6388
+ LedgerAccounts,
5773
6389
  LinkedAccounts,
5774
6390
  ProfitAndLoss,
5775
6391
  ProfitAndLossView