@layerfi/components 0.1.6 → 0.1.7

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
@@ -4034,7 +4034,7 @@ var MOCK_DATA = [
4034
4034
  {
4035
4035
  name: "Account",
4036
4036
  account: "4321",
4037
- amount: 4400020620
4037
+ amount: 801.91
4038
4038
  }
4039
4039
  ];
4040
4040
  var useLinkedAccounts = () => {
@@ -4098,7 +4098,63 @@ var LinkedAccounts = () => {
4098
4098
  import React65, { createContext as createContext2 } from "react";
4099
4099
 
4100
4100
  // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
4101
- import { useState as useState12 } from "react";
4101
+ import { useMemo as useMemo3, useState as useState12 } from "react";
4102
+
4103
+ // src/utils/profitAndLossUtils.ts
4104
+ var doesLineItemQualifies = (item) => {
4105
+ return !(item.is_contra || item.value === void 0 || item.value === null || isNaN(item.value) || item.value === -Infinity || item.value === Infinity || item.value < 0);
4106
+ };
4107
+ var collectSubItems = (type, item) => {
4108
+ if (!item) {
4109
+ return [];
4110
+ }
4111
+ const items = [];
4112
+ item?.line_items?.forEach((item2) => {
4113
+ if (doesLineItemQualifies(item2)) {
4114
+ items.push({
4115
+ name: item2.name,
4116
+ display_name: item2.display_name,
4117
+ value: Math.abs(item2.value || 0),
4118
+ // @TODO - confirm that's safe to do this
4119
+ type
4120
+ });
4121
+ }
4122
+ });
4123
+ return items;
4124
+ };
4125
+ var collectExpensesItems = (data) => {
4126
+ const cogs = collectSubItems("Cost of Goods Sold", data.cost_of_goods_sold);
4127
+ const expenses = collectSubItems("Operating Expenses", data.expenses);
4128
+ const taxes = collectSubItems("Taxes & Licenses", data.taxes);
4129
+ return [].concat(cogs).concat(expenses).concat(taxes);
4130
+ };
4131
+ var collectRevenueItems = (data) => {
4132
+ const income = collectSubItems("Income", data.income);
4133
+ return [].concat(income);
4134
+ };
4135
+ var humanizeTitle = (sidebarView) => {
4136
+ switch (sidebarView) {
4137
+ case "expenses":
4138
+ return "Expenses";
4139
+ case "revenue":
4140
+ return "Revenue";
4141
+ default:
4142
+ return "Profit & Loss";
4143
+ }
4144
+ };
4145
+ var applyShare = (items, total) => {
4146
+ return items.map((item) => {
4147
+ if (total === 0) {
4148
+ return item;
4149
+ }
4150
+ return {
4151
+ ...item,
4152
+ share: item.value / total
4153
+ };
4154
+ });
4155
+ };
4156
+
4157
+ // src/hooks/useProfitAndLoss/useProfitAndLoss.tsx
4102
4158
  import { startOfMonth, endOfMonth, formatISO } from "date-fns";
4103
4159
  import useSWR4 from "swr";
4104
4160
  var useProfitAndLoss = ({
@@ -4117,6 +4173,11 @@ var useProfitAndLoss = ({
4117
4173
  const [endDate, setEndDate] = useState12(
4118
4174
  initialEndDate || endOfMonth(Date.now())
4119
4175
  );
4176
+ const [filters, setFilters] = useState12({
4177
+ expenses: void 0,
4178
+ revenue: void 0
4179
+ });
4180
+ const [sidebarScope, setSidebarScope] = useState12("expenses");
4120
4181
  const {
4121
4182
  data: rawData,
4122
4183
  isLoading,
@@ -4139,6 +4200,43 @@ var useProfitAndLoss = ({
4139
4200
  })
4140
4201
  );
4141
4202
  const { data, error } = rawData || {};
4203
+ const { filteredData, filteredTotal } = useMemo3(() => {
4204
+ if (!data) {
4205
+ return { filteredData: [], filteredTotal: void 0 };
4206
+ }
4207
+ const items = sidebarScope === "revenue" ? collectRevenueItems(data) : collectExpensesItems(data);
4208
+ const filtered = items.map((x) => {
4209
+ if (sidebarScope && filters[sidebarScope]?.types && filters[sidebarScope].types.length > 0 && !filters[sidebarScope]?.types?.includes(x.type)) {
4210
+ return {
4211
+ ...x,
4212
+ hidden: true
4213
+ };
4214
+ }
4215
+ return x;
4216
+ });
4217
+ const sorted = filtered.sort((a, b) => {
4218
+ switch (filters[sidebarScope ?? "expenses"]?.sortBy) {
4219
+ case "category":
4220
+ if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
4221
+ return a.display_name.localeCompare(b.display_name);
4222
+ }
4223
+ return b.display_name.localeCompare(a.display_name);
4224
+ case "type":
4225
+ if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
4226
+ return a.type.localeCompare(b.type);
4227
+ }
4228
+ return b.type.localeCompare(a.type);
4229
+ default:
4230
+ if (filters[sidebarScope ?? "expenses"]?.sortDirection === "asc") {
4231
+ return a.value - b.value;
4232
+ }
4233
+ return b.value - a.value;
4234
+ }
4235
+ });
4236
+ const total = sorted.filter((x) => !x.hidden).reduce((x, { value }) => x + value, 0);
4237
+ const withShare = applyShare(sorted, total);
4238
+ return { filteredData: withShare, filteredTotal: total };
4239
+ }, [data, startDate, filters, sidebarScope]);
4142
4240
  const changeDateRange = ({
4143
4241
  startDate: newStartDate,
4144
4242
  endDate: newEndDate
@@ -4149,22 +4247,80 @@ var useProfitAndLoss = ({
4149
4247
  const refetch = () => {
4150
4248
  mutate();
4151
4249
  };
4250
+ const sortBy = (scope, field, direction) => {
4251
+ setFilters({
4252
+ ...filters,
4253
+ [scope]: {
4254
+ ...filters[scope],
4255
+ sortBy: field,
4256
+ sortDirection: direction ?? filters[scope]?.sortDirection === "desc" ? "asc" : "desc"
4257
+ }
4258
+ });
4259
+ };
4260
+ const setFilterTypes = (scope, types) => {
4261
+ setFilters({
4262
+ ...filters,
4263
+ [scope]: {
4264
+ ...filters[scope],
4265
+ types
4266
+ }
4267
+ });
4268
+ };
4152
4269
  return {
4153
4270
  data,
4271
+ filteredData,
4272
+ filteredTotal,
4154
4273
  isLoading,
4155
4274
  isValidating,
4156
4275
  error: error || rawError,
4157
4276
  dateRange: { startDate, endDate },
4158
4277
  refetch,
4159
- changeDateRange
4278
+ changeDateRange,
4279
+ sidebarScope,
4280
+ setSidebarScope,
4281
+ sortBy,
4282
+ filters,
4283
+ setFilterTypes
4160
4284
  };
4161
4285
  };
4162
4286
 
4163
4287
  // src/components/ProfitAndLossChart/ProfitAndLossChart.tsx
4164
- import React59, { useContext as useContext2, useMemo as useMemo3, useState as useState13 } from "react";
4288
+ import React59, { useContext as useContext2, useMemo as useMemo4, useState as useState13 } from "react";
4165
4289
 
4166
4290
  // src/utils/format.ts
4167
4291
  var capitalizeFirstLetter = (text) => text.charAt(0).toUpperCase() + text.slice(1);
4292
+ var formatPercent = (value, options) => {
4293
+ if (!value && value !== 0) {
4294
+ return;
4295
+ }
4296
+ const val = value * 100;
4297
+ let defaultOptions = {
4298
+ minimumFractionDigits: 0,
4299
+ maximumFractionDigits: 0
4300
+ };
4301
+ if (Math.abs(val) < 10) {
4302
+ defaultOptions = {
4303
+ minimumFractionDigits: 1,
4304
+ maximumFractionDigits: 1
4305
+ };
4306
+ }
4307
+ if (Math.abs(val) < 1) {
4308
+ defaultOptions = {
4309
+ minimumFractionDigits: 1,
4310
+ maximumFractionDigits: 1
4311
+ };
4312
+ }
4313
+ if (val === 0) {
4314
+ defaultOptions = {
4315
+ minimumFractionDigits: 0,
4316
+ maximumFractionDigits: 0
4317
+ };
4318
+ }
4319
+ return val.toLocaleString("en-US", {
4320
+ ...defaultOptions,
4321
+ ...options
4322
+ });
4323
+ };
4168
4324
 
4169
4325
  // src/components/ProfitAndLossChart/Indicator.tsx
4170
4326
  import React58, { useEffect as useEffect8 } from "react";
@@ -4342,7 +4498,7 @@ var ProfitAndLossChart = () => {
4342
4498
  }
4343
4499
  );
4344
4500
  };
4345
- const data = useMemo3(
4501
+ const data = useMemo4(
4346
4502
  () => monthData.map(summarizePnL),
4347
4503
  [
4348
4504
  startSelectionMonth,
@@ -4523,34 +4679,64 @@ var SkeletonLoader = ({
4523
4679
  };
4524
4680
 
4525
4681
  // src/components/ProfitAndLossSummaries/ProfitAndLossSummaries.tsx
4682
+ import classNames22 from "classnames";
4526
4683
  var ProfitAndLossSummaries = ({
4527
4684
  vertical,
4528
4685
  revenueLabel = "Revenue"
4529
4686
  }) => {
4530
- const { data: storedData, isLoading } = useContext4(ProfitAndLoss.Context);
4687
+ const {
4688
+ data: storedData,
4689
+ isLoading,
4690
+ setSidebarScope,
4691
+ sidebarScope
4692
+ } = useContext4(ProfitAndLoss.Context);
4531
4693
  const data = storedData ? storedData : { income: { value: NaN }, net_profit: NaN };
4532
- const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
4533
- const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
4534
- const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--pasitive";
4694
+ const incomeDirectionClass = (data.income.value ?? NaN) < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4695
+ const expensesDirectionClass = (data?.income?.value ?? NaN) - data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4696
+ const netProfitDirectionClass = data.net_profit < 0 ? "Layer__profit-and-loss-summaries__amount--negative" : "Layer__profit-and-loss-summaries__amount--positive";
4535
4697
  return /* @__PURE__ */ React62.createElement(
4536
4698
  "div",
4537
4699
  {
4538
4700
  className: `Layer__profit-and-loss-summaries ${vertical ? "flex-col" : ""}`
4539
4701
  },
4540
- /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--income" }, /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel), isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, null)) : /* @__PURE__ */ React62.createElement(
4541
- "span",
4702
+ /* @__PURE__ */ React62.createElement(
4703
+ "div",
4542
4704
  {
4543
- className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
4705
+ className: classNames22(
4706
+ "Layer__profit-and-loss-summaries__summary Layer__actionable",
4707
+ "Layer__profit-and-loss-summaries__summary--income",
4708
+ sidebarScope === "revenue" ? "active" : ""
4709
+ ),
4710
+ onClick: () => setSidebarScope("revenue")
4544
4711
  },
4545
- centsToDollars(Math.abs(data?.income?.value ?? NaN))
4546
- )),
4547
- /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__summary Layer__profit-and-loss-summaries__summary--expenses" }, /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"), 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(
4548
- "span",
4712
+ /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, revenueLabel),
4713
+ isLoading || storedData === void 0 ? /* @__PURE__ */ React62.createElement("div", { className: "Layer__profit-and-loss-summaries__loader" }, /* @__PURE__ */ React62.createElement(SkeletonLoader, null)) : /* @__PURE__ */ React62.createElement(
4714
+ "span",
4715
+ {
4716
+ className: `Layer__profit-and-loss-summaries__amount ${incomeDirectionClass}`
4717
+ },
4718
+ centsToDollars(Math.abs(data?.income?.value ?? NaN))
4719
+ )
4720
+ ),
4721
+ /* @__PURE__ */ React62.createElement(
4722
+ "div",
4549
4723
  {
4550
- className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
4724
+ className: classNames22(
4725
+ "Layer__profit-and-loss-summaries__summary Layer__actionable",
4726
+ "Layer__profit-and-loss-summaries__summary--expenses",
4727
+ sidebarScope === "expenses" ? "active" : ""
4728
+ ),
4729
+ onClick: () => setSidebarScope("expenses")
4551
4730
  },
4552
- centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
4553
- )),
4731
+ /* @__PURE__ */ React62.createElement("span", { className: "Layer__profit-and-loss-summaries__title" }, "Expenses"),
4732
+ 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(
4733
+ "span",
4734
+ {
4735
+ className: `Layer__profit-and-loss-summaries__amount ${expensesDirectionClass}`
4736
+ },
4737
+ centsToDollars(Math.abs((data.income.value ?? 0) - data.net_profit))
4738
+ )
4739
+ ),
4554
4740
  /* @__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(
4555
4741
  "span",
4556
4742
  {
@@ -4772,6 +4958,8 @@ var ProfitAndLossTable = ({ lockExpanded }) => {
4772
4958
  import { endOfMonth as endOfMonth4, startOfMonth as startOfMonth4 } from "date-fns";
4773
4959
  var PNLContext = createContext2({
4774
4960
  data: void 0,
4961
+ filteredData: [],
4962
+ filteredTotal: void 0,
4775
4963
  isLoading: true,
4776
4964
  isValidating: false,
4777
4965
  error: void 0,
@@ -4782,6 +4970,17 @@ var PNLContext = createContext2({
4782
4970
  changeDateRange: () => {
4783
4971
  },
4784
4972
  refetch: () => {
4973
+ },
4974
+ sidebarScope: void 0,
4975
+ setSidebarScope: () => {
4976
+ },
4977
+ sortBy: () => {
4978
+ },
4979
+ setFilterTypes: () => {
4980
+ },
4981
+ filters: {
4982
+ expenses: void 0,
4983
+ revenue: void 0
4785
4984
  }
4786
4985
  });
4787
4986
  var ProfitAndLoss = ({ children, tagFilter, reportingBasis }) => {
@@ -4795,20 +4994,473 @@ ProfitAndLoss.Summaries = ProfitAndLossSummaries;
4795
4994
  ProfitAndLoss.Table = ProfitAndLossTable;
4796
4995
 
4797
4996
  // src/components/ProfitAndLossView/ProfitAndLossView.tsx
4798
- import React66, { useContext as useContext6 } from "react";
4997
+ import React69, { useContext as useContext7 } from "react";
4998
+
4999
+ // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
5000
+ import React68, { useContext as useContext6, useMemo as useMemo5, useState as useState15 } from "react";
5001
+ import Select3 from "react-select";
5002
+
5003
+ // src/icons/SortArrows.tsx
5004
+ import * as React66 from "react";
5005
+ var SortArrows = ({ size = 13, ...props }) => /* @__PURE__ */ React66.createElement(
5006
+ "svg",
5007
+ {
5008
+ xmlns: "http://www.w3.org/2000/svg",
5009
+ viewBox: "0 0 12 13",
5010
+ fill: "none",
5011
+ ...props,
5012
+ width: size,
5013
+ height: size
5014
+ },
5015
+ /* @__PURE__ */ React66.createElement("g", { "clip-path": "url(#clip0_1758_75388)" }, /* @__PURE__ */ React66.createElement(
5016
+ "path",
5017
+ {
5018
+ d: "M1.33325 8.5L3.99992 11.1667L6.66659 8.5",
5019
+ stroke: "currentColor",
5020
+ "stroke-linecap": "round",
5021
+ "stroke-linejoin": "round",
5022
+ className: "desc-arrow"
5023
+ }
5024
+ ), /* @__PURE__ */ React66.createElement(
5025
+ "path",
5026
+ {
5027
+ d: "M4 2.5L4 11.1667",
5028
+ stroke: "currentColor",
5029
+ "stroke-linecap": "round",
5030
+ "stroke-linejoin": "round",
5031
+ className: "desc-arrow"
5032
+ }
5033
+ ), /* @__PURE__ */ React66.createElement(
5034
+ "path",
5035
+ {
5036
+ d: "M5.99988 5.16602L8.66654 2.49935L11.3332 5.16602",
5037
+ stroke: "currentColor",
5038
+ "stroke-linecap": "round",
5039
+ "stroke-linejoin": "round",
5040
+ className: "asc-arrow"
5041
+ }
5042
+ ), /* @__PURE__ */ React66.createElement(
5043
+ "path",
5044
+ {
5045
+ d: "M8.66663 11.166L8.66663 2.49935",
5046
+ stroke: "currentColor",
5047
+ "stroke-linecap": "round",
5048
+ "stroke-linejoin": "round",
5049
+ className: "asc-arrow"
5050
+ }
5051
+ )),
5052
+ /* @__PURE__ */ React66.createElement("defs", null, /* @__PURE__ */ React66.createElement("clipPath", { id: "clip0_1758_75388" }, /* @__PURE__ */ React66.createElement(
5053
+ "rect",
5054
+ {
5055
+ width: "12",
5056
+ height: "12",
5057
+ fill: "white",
5058
+ transform: "translate(0 0.5)"
5059
+ }
5060
+ )))
5061
+ );
5062
+ var SortArrows_default = SortArrows;
5063
+
5064
+ // src/icons/X.tsx
5065
+ import * as React67 from "react";
5066
+ var X = ({ size = 18, ...props }) => /* @__PURE__ */ React67.createElement(
5067
+ "svg",
5068
+ {
5069
+ xmlns: "http://www.w3.org/2000/svg",
5070
+ viewBox: "0 0 18 18",
5071
+ fill: "none",
5072
+ ...props,
5073
+ width: size,
5074
+ height: size
5075
+ },
5076
+ /* @__PURE__ */ React67.createElement(
5077
+ "path",
5078
+ {
5079
+ d: "M13.5 4.5L4.5 13.5",
5080
+ stroke: "currentColor",
5081
+ strokeLinecap: "round",
5082
+ strokeLinejoin: "round"
5083
+ }
5084
+ ),
5085
+ /* @__PURE__ */ React67.createElement(
5086
+ "path",
5087
+ {
5088
+ d: "M4.5 4.5L13.5 13.5",
5089
+ stroke: "currentColor",
5090
+ strokeLinecap: "round",
5091
+ strokeLinejoin: "round"
5092
+ }
5093
+ )
5094
+ );
5095
+ var X_default = X;
5096
+
5097
+ // src/components/ProfitAndLossDetailedCharts/ProfitAndLossDetailedCharts.tsx
5098
+ import classNames23 from "classnames";
5099
+ import { format as format6 } from "date-fns";
5100
+ import {
5101
+ PieChart,
5102
+ Pie,
5103
+ Cell as Cell2,
5104
+ ResponsiveContainer as ResponsiveContainer2,
5105
+ Label,
5106
+ Text as ChartText
5107
+ } from "recharts";
5108
+ var INACTIVE_OPACITY_LEVELS = [0.85, 0.7, 0.66, 0.55, 0.4, 0.33, 0.25, 0.15];
5109
+ var DEFAULT_CHART_COLORS = [
5110
+ {
5111
+ color: "#7417B3",
5112
+ opacity: 1
5113
+ },
5114
+ {
5115
+ color: "#7417B3",
5116
+ opacity: 0.8
5117
+ },
5118
+ {
5119
+ color: "#7417B3",
5120
+ opacity: 0.6
5121
+ },
5122
+ {
5123
+ color: "#7417B3",
5124
+ opacity: 0.4
5125
+ },
5126
+ {
5127
+ color: "#7417B3",
5128
+ opacity: 0.2
5129
+ },
5130
+ {
5131
+ color: "#7417B3",
5132
+ opacity: 0.1
5133
+ },
5134
+ {
5135
+ color: "#006A80",
5136
+ opacity: 1
5137
+ },
5138
+ {
5139
+ color: "#006A80",
5140
+ opacity: 0.8
5141
+ },
5142
+ {
5143
+ color: "#006A80",
5144
+ opacity: 0.6
5145
+ },
5146
+ {
5147
+ color: "#006A80",
5148
+ opacity: 0.4
5149
+ },
5150
+ {
5151
+ color: "#006A80",
5152
+ opacity: 0.2
5153
+ },
5154
+ {
5155
+ color: "#006A80",
5156
+ opacity: 0.1
5157
+ },
5158
+ {
5159
+ color: "#009930",
5160
+ opacity: 1
5161
+ },
5162
+ {
5163
+ color: "#009930",
5164
+ opacity: 0.8
5165
+ },
5166
+ {
5167
+ color: "#009930",
5168
+ opacity: 0.6
5169
+ },
5170
+ {
5171
+ color: "#009930",
5172
+ opacity: 0.4
5173
+ },
5174
+ {
5175
+ color: "#009930",
5176
+ opacity: 0.2
5177
+ },
5178
+ {
5179
+ color: "#009930",
5180
+ opacity: 0.1
5181
+ }
5182
+ ];
5183
+ var ProfitAndLossDetailedCharts = () => {
5184
+ const {
5185
+ data,
5186
+ filteredData,
5187
+ filteredTotal,
5188
+ sortBy,
5189
+ filters,
5190
+ isLoading,
5191
+ dateRange,
5192
+ sidebarScope,
5193
+ setSidebarScope,
5194
+ setFilterTypes
5195
+ } = useContext6(ProfitAndLoss.Context);
5196
+ const [hoveredItem, setHoveredItem] = useState15();
5197
+ const chartData = useMemo5(() => {
5198
+ if (!filteredData) {
5199
+ return [];
5200
+ }
5201
+ return filteredData.map((x) => {
5202
+ if (x.hidden) {
5203
+ return {
5204
+ name: x.display_name,
5205
+ value: 0
5206
+ };
5207
+ }
5208
+ return {
5209
+ name: x.display_name,
5210
+ value: x.value
5211
+ };
5212
+ });
5213
+ }, [filteredData]);
5214
+ const buildColClass = (column) => {
5215
+ return classNames23(
5216
+ "Layer__sortable-col",
5217
+ sidebarScope && filters[sidebarScope]?.sortBy === column ? `sort--${(sidebarScope && filters[sidebarScope]?.sortDirection) ?? "desc"}` : ""
5218
+ );
5219
+ };
5220
+ return /* @__PURE__ */ React68.createElement(
5221
+ "div",
5222
+ {
5223
+ className: classNames23(
5224
+ "Layer__profit-and-loss__side-panel",
5225
+ sidebarScope && "open"
5226
+ )
5227
+ },
5228
+ /* @__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(
5229
+ Button,
5230
+ {
5231
+ rightIcon: /* @__PURE__ */ React68.createElement(X_default, null),
5232
+ iconOnly: true,
5233
+ onClick: () => setSidebarScope(void 0),
5234
+ variant: "secondary" /* secondary */
5235
+ }
5236
+ )), /* @__PURE__ */ React68.createElement("div", { className: "chart-container" }, /* @__PURE__ */ React68.createElement(ResponsiveContainer2, null, /* @__PURE__ */ React68.createElement(PieChart, null, /* @__PURE__ */ React68.createElement(
5237
+ Pie,
5238
+ {
5239
+ data: chartData,
5240
+ dataKey: "value",
5241
+ nameKey: "name",
5242
+ cx: "50%",
5243
+ cy: "50%",
5244
+ innerRadius: 105,
5245
+ outerRadius: 120,
5246
+ paddingAngle: 0.5,
5247
+ fill: "#8884d8"
5248
+ },
5249
+ chartData.map((entry, index) => {
5250
+ const colorConfig = DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
5251
+ let fill = colorConfig.color;
5252
+ let opacity = colorConfig.opacity;
5253
+ let active = true;
5254
+ if (hoveredItem && entry.name !== hoveredItem) {
5255
+ active = false;
5256
+ fill = void 0;
5257
+ opacity = INACTIVE_OPACITY_LEVELS[index % INACTIVE_OPACITY_LEVELS.length];
5258
+ }
5259
+ return /* @__PURE__ */ React68.createElement(
5260
+ Cell2,
5261
+ {
5262
+ key: `cell-${index}`,
5263
+ className: `Layer__profit-and-loss-detailed-charts__pie ${hoveredItem && active ? "active" : "inactive"}`,
5264
+ style: { fill },
5265
+ opacity,
5266
+ onMouseEnter: () => setHoveredItem(entry.name),
5267
+ onMouseLeave: () => setHoveredItem(void 0)
5268
+ }
5269
+ );
5270
+ }),
5271
+ /* @__PURE__ */ React68.createElement(
5272
+ Label,
5273
+ {
5274
+ position: "center",
5275
+ value: "Total",
5276
+ className: "pie-center-label-title",
5277
+ content: (props) => {
5278
+ const { cx, cy } = props.viewBox ?? {
5279
+ cx: 0,
5280
+ cy: 0
5281
+ };
5282
+ const positioningProps = {
5283
+ x: cx,
5284
+ y: (cy || 0) - 15,
5285
+ textAnchor: "middle",
5286
+ verticalAnchor: "middle"
5287
+ };
5288
+ let text = "Total";
5289
+ if (hoveredItem) {
5290
+ text = hoveredItem;
5291
+ }
5292
+ return /* @__PURE__ */ React68.createElement(
5293
+ ChartText,
5294
+ {
5295
+ ...positioningProps,
5296
+ className: "pie-center-label__title"
5297
+ },
5298
+ text
5299
+ );
5300
+ }
5301
+ }
5302
+ ),
5303
+ /* @__PURE__ */ React68.createElement(
5304
+ Label,
5305
+ {
5306
+ position: "center",
5307
+ value: "Total",
5308
+ className: "pie-center-label-title",
5309
+ content: (props) => {
5310
+ const { cx, cy } = props.viewBox ?? {
5311
+ cx: 0,
5312
+ cy: 0
5313
+ };
5314
+ const positioningProps = {
5315
+ x: cx,
5316
+ y: (cy || 0) + 5,
5317
+ textAnchor: "middle",
5318
+ verticalAnchor: "middle"
5319
+ };
5320
+ let value = filteredTotal;
5321
+ if (hoveredItem) {
5322
+ value = filteredData.find(
5323
+ (x) => x.display_name === hoveredItem
5324
+ )?.value;
5325
+ }
5326
+ return /* @__PURE__ */ React68.createElement(
5327
+ ChartText,
5328
+ {
5329
+ ...positioningProps,
5330
+ className: "pie-center-label__value"
5331
+ },
5332
+ `$${centsToDollars(value)}`
5333
+ );
5334
+ }
5335
+ }
5336
+ ),
5337
+ /* @__PURE__ */ React68.createElement(
5338
+ Label,
5339
+ {
5340
+ position: "center",
5341
+ value: "Total",
5342
+ className: "pie-center-label-title",
5343
+ content: (props) => {
5344
+ const { cx, cy } = props.viewBox ?? {
5345
+ cx: 0,
5346
+ cy: 0
5347
+ };
5348
+ const positioningProps = {
5349
+ x: cx,
5350
+ y: (cy || 0) + 25,
5351
+ height: 20,
5352
+ textAnchor: "middle",
5353
+ verticalAnchor: "middle"
5354
+ };
5355
+ if (hoveredItem) {
5356
+ return /* @__PURE__ */ React68.createElement(
5357
+ ChartText,
5358
+ {
5359
+ ...positioningProps,
5360
+ className: "pie-center-label__share"
5361
+ },
5362
+ `${formatPercent(
5363
+ filteredData.find(
5364
+ (x) => x.display_name === hoveredItem
5365
+ )?.share
5366
+ )}%`
5367
+ );
5368
+ }
5369
+ return;
5370
+ }
5371
+ }
5372
+ )
5373
+ )))), /* @__PURE__ */ React68.createElement("div", { className: "filters" }, /* @__PURE__ */ React68.createElement(Text, { size: "sm" /* sm */, className: "Layer__label" }, "Filters"), /* @__PURE__ */ React68.createElement(
5374
+ Select3,
5375
+ {
5376
+ className: "type-select",
5377
+ classNamePrefix: "Layer__select",
5378
+ value: sidebarScope && filters[sidebarScope]?.types ? sidebarScope && filters[sidebarScope]?.types?.map((x) => ({
5379
+ value: x,
5380
+ label: x
5381
+ })) : [],
5382
+ isMulti: true,
5383
+ isClearable: false,
5384
+ options: [...new Set(filteredData?.map((x) => x.type))].map((x) => ({
5385
+ label: x,
5386
+ value: x
5387
+ })),
5388
+ onChange: (selected) => {
5389
+ setFilterTypes(
5390
+ sidebarScope ?? "expenses",
5391
+ selected.map((x) => x.value)
5392
+ );
5393
+ }
5394
+ }
5395
+ )), /* @__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(
5396
+ "th",
5397
+ {
5398
+ className: buildColClass("category"),
5399
+ onClick: () => sortBy(sidebarScope ?? "expenses", "category")
5400
+ },
5401
+ "Expense/Sale ",
5402
+ /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5403
+ ), /* @__PURE__ */ React68.createElement(
5404
+ "th",
5405
+ {
5406
+ className: buildColClass("type"),
5407
+ onClick: () => sortBy(sidebarScope ?? "expenses", "type")
5408
+ },
5409
+ "Type ",
5410
+ /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5411
+ ), /* @__PURE__ */ React68.createElement("th", null), /* @__PURE__ */ React68.createElement(
5412
+ "th",
5413
+ {
5414
+ className: buildColClass("value"),
5415
+ onClick: () => sortBy(sidebarScope ?? "expenses", "value")
5416
+ },
5417
+ "Value ",
5418
+ /* @__PURE__ */ React68.createElement(SortArrows_default, { className: "Layer__sort-arrows" })
5419
+ ))), /* @__PURE__ */ React68.createElement("tbody", null, filteredData.filter((x) => !x.hidden).map((item, idx) => {
5420
+ const colorConfig = DEFAULT_CHART_COLORS[idx % DEFAULT_CHART_COLORS.length];
5421
+ return /* @__PURE__ */ React68.createElement(
5422
+ "tr",
5423
+ {
5424
+ key: `pl-side-table-item-${idx}`,
5425
+ className: classNames23(
5426
+ "Layer__profit-and-loss-detailed-table__row",
5427
+ hoveredItem && hoveredItem !== item.display_name ? "inactive" : ""
5428
+ ),
5429
+ onMouseEnter: () => setHoveredItem(item.display_name),
5430
+ onMouseLeave: () => setHoveredItem(void 0)
5431
+ },
5432
+ /* @__PURE__ */ React68.createElement("td", { className: "category-col" }, item.display_name),
5433
+ /* @__PURE__ */ React68.createElement("td", { className: "type-col" }, item.type),
5434
+ /* @__PURE__ */ React68.createElement("td", { className: "value-col" }, "$", centsToDollars(item.value)),
5435
+ /* @__PURE__ */ React68.createElement("td", { className: "share-col" }, /* @__PURE__ */ React68.createElement("span", { className: "share-cell-content" }, formatPercent(item.share), "%", /* @__PURE__ */ React68.createElement(
5436
+ "div",
5437
+ {
5438
+ className: "share-icon",
5439
+ style: {
5440
+ background: colorConfig.color,
5441
+ opacity: colorConfig.opacity
5442
+ }
5443
+ }
5444
+ )))
5445
+ );
5446
+ }))))))
5447
+ );
5448
+ };
5449
+
5450
+ // src/components/ProfitAndLossView/ProfitAndLossView.tsx
4799
5451
  var COMPONENT_NAME3 = "profit-and-loss";
4800
5452
  var ProfitAndLossView = (props) => {
4801
- return /* @__PURE__ */ React66.createElement(Container, { name: COMPONENT_NAME3 }, /* @__PURE__ */ React66.createElement(Header, { className: `Layer__${COMPONENT_NAME3}__header` }, /* @__PURE__ */ React66.createElement(Heading, { className: "Layer__bank-transactions__title" }, "Profit & Loss")), /* @__PURE__ */ React66.createElement(ProfitAndLoss, null, /* @__PURE__ */ React66.createElement(Components, { ...props })));
5453
+ 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)));
4802
5454
  };
4803
5455
  var Components = ({
4804
5456
  hideChart = false,
4805
5457
  hideTable = false
4806
5458
  }) => {
4807
- const { error, isLoading, isValidating, refetch } = useContext6(
5459
+ const { error, isLoading, isValidating, refetch } = useContext7(
4808
5460
  ProfitAndLoss.Context
4809
5461
  );
4810
5462
  if (!isLoading && error) {
4811
- return /* @__PURE__ */ React66.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React66.createElement(
5463
+ return /* @__PURE__ */ React69.createElement("div", { className: "Layer__table-state-container" }, /* @__PURE__ */ React69.createElement(
4812
5464
  DataState,
4813
5465
  {
4814
5466
  status: "failed" /* failed */,
@@ -4819,24 +5471,24 @@ var Components = ({
4819
5471
  }
4820
5472
  ));
4821
5473
  }
4822
- return /* @__PURE__ */ React66.createElement(React66.Fragment, null, !hideChart && /* @__PURE__ */ React66.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ React66.createElement(
5474
+ return /* @__PURE__ */ React69.createElement(React69.Fragment, null, !hideChart && /* @__PURE__ */ React69.createElement("div", { className: `Layer__${COMPONENT_NAME3}__chart_with_summaries` }, /* @__PURE__ */ React69.createElement(
4823
5475
  "div",
4824
5476
  {
4825
5477
  className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__summary-col`
4826
5478
  },
4827
- /* @__PURE__ */ React66.createElement(ProfitAndLoss.DatePicker, null),
4828
- /* @__PURE__ */ React66.createElement(ProfitAndLoss.Summaries, { vertical: true })
4829
- ), /* @__PURE__ */ React66.createElement(
5479
+ /* @__PURE__ */ React69.createElement(ProfitAndLoss.DatePicker, null),
5480
+ /* @__PURE__ */ React69.createElement(ProfitAndLoss.Summaries, { vertical: true })
5481
+ ), /* @__PURE__ */ React69.createElement(
4830
5482
  "div",
4831
5483
  {
4832
5484
  className: `Layer__${COMPONENT_NAME3}__chart_with_summaries__chart-col`
4833
5485
  },
4834
- /* @__PURE__ */ React66.createElement(ProfitAndLoss.Chart, null)
4835
- )), !hideTable && /* @__PURE__ */ React66.createElement(ProfitAndLoss.Table, null));
5486
+ /* @__PURE__ */ React69.createElement(ProfitAndLoss.Chart, null)
5487
+ )), !hideTable && /* @__PURE__ */ React69.createElement(ProfitAndLoss.Table, null));
4836
5488
  };
4837
5489
 
4838
5490
  // src/providers/LayerProvider/LayerProvider.tsx
4839
- import React67, { useReducer, useEffect as useEffect9 } from "react";
5491
+ import React70, { useReducer, useEffect as useEffect9 } from "react";
4840
5492
  import { add as add2, isBefore } from "date-fns";
4841
5493
  import useSWR5, { SWRConfig } from "swr";
4842
5494
  var reducer = (state, action) => {
@@ -4951,11 +5603,11 @@ var LayerProvider = ({
4951
5603
  }
4952
5604
  return;
4953
5605
  };
4954
- return /* @__PURE__ */ React67.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React67.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
5606
+ return /* @__PURE__ */ React70.createElement(SWRConfig, { value: defaultSWRConfig }, /* @__PURE__ */ React70.createElement(LayerContext.Provider, { value: { ...state, setTheme, getColor } }, children));
4955
5607
  };
4956
5608
 
4957
5609
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
4958
- import React70, { useState as useState16 } from "react";
5610
+ import React73, { useState as useState17 } from "react";
4959
5611
 
4960
5612
  // src/hooks/useChartOfAccounts/useChartOfAccounts.tsx
4961
5613
  import useSWR6 from "swr";
@@ -4975,21 +5627,21 @@ var useChartOfAccounts = () => {
4975
5627
  };
4976
5628
 
4977
5629
  // src/components/ChartOfAccountsNewForm/ChartOfAccountsNewForm.tsx
4978
- import React68, { useMemo as useMemo4, useState as useState15 } from "react";
4979
- import Select3 from "react-select";
5630
+ import React71, { useMemo as useMemo6, useState as useState16 } from "react";
5631
+ import Select4 from "react-select";
4980
5632
  var flattenAccounts = (accounts) => accounts.flatMap((a) => [a, flattenAccounts(a.subAccounts || [])]).flat().filter((id) => id);
4981
5633
  var ChartOfAccountsNewForm = () => {
4982
5634
  const { data, create: createAccount2 } = useChartOfAccounts();
4983
- const accountOptions = useMemo4(
5635
+ const accountOptions = useMemo6(
4984
5636
  () => flattenAccounts(data?.accounts || []).sort(
4985
5637
  (a, b) => a?.name && b?.name ? a.name.localeCompare(b.name) : 0
4986
5638
  ),
4987
5639
  [data?.accounts?.length]
4988
5640
  );
4989
- const [name, setName] = useState15("");
4990
- const [description, setDescription] = useState15("");
4991
- const [normality, setNormality] = useState15("DEBIT" /* DEBIT */);
4992
- const [parentAccount, setParentAccount] = useState15(
5641
+ const [name, setName] = useState16("");
5642
+ const [description, setDescription] = useState16("");
5643
+ const [normality, setNormality] = useState16("DEBIT" /* DEBIT */);
5644
+ const [parentAccount, setParentAccount] = useState16(
4993
5645
  data?.accounts[0]
4994
5646
  );
4995
5647
  const save = () => {
@@ -5003,22 +5655,22 @@ var ChartOfAccountsNewForm = () => {
5003
5655
  description
5004
5656
  });
5005
5657
  };
5006
- return /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form" }, /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React68.createElement("span", null, "Name"), /* @__PURE__ */ React68.createElement(
5658
+ 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(
5007
5659
  "input",
5008
5660
  {
5009
5661
  name: "name",
5010
5662
  value: name,
5011
5663
  onChange: (event) => setName(event.target.value)
5012
5664
  }
5013
- )), /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React68.createElement("span", null, "Description"), /* @__PURE__ */ React68.createElement(
5665
+ )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Description"), /* @__PURE__ */ React71.createElement(
5014
5666
  "input",
5015
5667
  {
5016
5668
  name: "description",
5017
5669
  value: description,
5018
5670
  onChange: (event) => setDescription(event.target.value)
5019
5671
  }
5020
- )), /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React68.createElement("span", null, "Normality"), /* @__PURE__ */ React68.createElement(
5021
- Select3,
5672
+ )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Normality"), /* @__PURE__ */ React71.createElement(
5673
+ Select4,
5022
5674
  {
5023
5675
  isSearchable: false,
5024
5676
  onChange: (value) => value && setNormality(value.value),
@@ -5027,8 +5679,8 @@ var ChartOfAccountsNewForm = () => {
5027
5679
  { label: "Debit", value: "DEBIT" /* DEBIT */ }
5028
5680
  ]
5029
5681
  }
5030
- )), /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React68.createElement("span", null, "Parent Account"), /* @__PURE__ */ React68.createElement(
5031
- Select3,
5682
+ )), /* @__PURE__ */ React71.createElement("div", { className: "Layer__chart-of-accounts-new-form__field" }, /* @__PURE__ */ React71.createElement("span", null, "Parent Account"), /* @__PURE__ */ React71.createElement(
5683
+ Select4,
5032
5684
  {
5033
5685
  isSearchable: true,
5034
5686
  value: parentAccount,
@@ -5037,49 +5689,49 @@ var ChartOfAccountsNewForm = () => {
5037
5689
  getOptionValue: (a) => a.id,
5038
5690
  options: accountOptions
5039
5691
  }
5040
- )), /* @__PURE__ */ React68.createElement("div", { className: "Layer__chart-of-accounts-new-form__field Layer__chart-of-accounts-new-form__field--actions" }, /* @__PURE__ */ React68.createElement("button", { onClick: save }, "Save")));
5692
+ )), /* @__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")));
5041
5693
  };
5042
5694
 
5043
5695
  // src/components/ChartOfAccountsRow/ChartOfAccountsRow.tsx
5044
- import React69 from "react";
5696
+ import React72 from "react";
5045
5697
  var ChartOfAccountsRow = ({ account, depth = 0 }) => {
5046
- const classNames22 = [
5698
+ const classNames24 = [
5047
5699
  "Layer__chart-of-accounts-row__table-cell",
5048
5700
  depth > 0 && `Layer__chart-of-accounts-row__table-cell--depth-${depth}`
5049
5701
  ];
5050
- const className = classNames22.filter((id) => id).join(" ");
5702
+ const className = classNames24.filter((id) => id).join(" ");
5051
5703
  const amountClassName = account.balance < 0 ? "Layer__chart-of-accounts-row__table-cell--amount-negative" : "Layer__chart-of-accounts-row__table-cell--amount-positive";
5052
- return /* @__PURE__ */ React69.createElement(React69.Fragment, null, /* @__PURE__ */ React69.createElement(
5704
+ return /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement(
5053
5705
  "div",
5054
5706
  {
5055
5707
  className: `${className} Layer__chart-of-accounts-row__table-cell--name`
5056
5708
  },
5057
5709
  account.name
5058
- ), /* @__PURE__ */ React69.createElement(
5710
+ ), /* @__PURE__ */ React72.createElement(
5059
5711
  "div",
5060
5712
  {
5061
5713
  className: `${className} Layer__chart-of-accounts-row__table-cell--type`
5062
5714
  },
5063
5715
  "Assets"
5064
- ), /* @__PURE__ */ React69.createElement(
5716
+ ), /* @__PURE__ */ React72.createElement(
5065
5717
  "div",
5066
5718
  {
5067
5719
  className: `${className} Layer__chart-of-accounts-row__table-cell--subtype`
5068
5720
  },
5069
5721
  "Cash"
5070
- ), /* @__PURE__ */ React69.createElement(
5722
+ ), /* @__PURE__ */ React72.createElement(
5071
5723
  "div",
5072
5724
  {
5073
5725
  className: `${className} Layer__chart-of-accounts-row__table-cell--balance ${amountClassName}`
5074
5726
  },
5075
5727
  centsToDollars(Math.abs(account.balance || 0))
5076
- ), /* @__PURE__ */ React69.createElement(
5728
+ ), /* @__PURE__ */ React72.createElement(
5077
5729
  "div",
5078
5730
  {
5079
5731
  className: `${className} Layer__chart-of-accounts-row__table-cell--actions`
5080
5732
  },
5081
- /* @__PURE__ */ React69.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
5082
- ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ React69.createElement(
5733
+ /* @__PURE__ */ React72.createElement("button", { className: "Layer__chart-of-accounts-row__view-entries-button" }, "View Entries")
5734
+ ), (account.subAccounts || []).map((subAccount) => /* @__PURE__ */ React72.createElement(
5083
5735
  ChartOfAccountsRow,
5084
5736
  {
5085
5737
  key: subAccount.id,
@@ -5092,15 +5744,15 @@ var ChartOfAccountsRow = ({ account, depth = 0 }) => {
5092
5744
  // src/components/ChartOfAccounts/ChartOfAccounts.tsx
5093
5745
  var ChartOfAccounts = () => {
5094
5746
  const { data, isLoading } = useChartOfAccounts();
5095
- const [showingForm, setShowingForm] = useState16(false);
5096
- return /* @__PURE__ */ React70.createElement("div", { className: "Layer__component Layer__chart-of-accounts" }, !data || isLoading ? "Loading." : /* @__PURE__ */ React70.createElement(React70.Fragment, null, /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__header" }, /* @__PURE__ */ React70.createElement("h2", { className: "Layer__chart-of-accounts__title" }, "Chart of Accounts"), /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__actions" }, /* @__PURE__ */ React70.createElement("button", { className: "Layer__chart-of-accounts__download-button" }, /* @__PURE__ */ React70.createElement(DownloadCloud_default, null), "Download"), /* @__PURE__ */ React70.createElement(
5747
+ const [showingForm, setShowingForm] = useState17(false);
5748
+ 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(
5097
5749
  "button",
5098
5750
  {
5099
5751
  className: "Layer__chart-of-accounts__edit-accounts-button",
5100
5752
  onClick: () => setShowingForm(!showingForm)
5101
5753
  },
5102
5754
  "Edit Accounts"
5103
- ))), showingForm && /* @__PURE__ */ React70.createElement(ChartOfAccountsNewForm, null), /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__table" }, /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Name"), /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Type"), /* @__PURE__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }, "Sub-Type"), /* @__PURE__ */ React70.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__ */ React70.createElement("div", { className: "Layer__chart-of-accounts__table-cell Layer__chart-of-accounts__table-cell--header" }), data.accounts.map((account) => /* @__PURE__ */ React70.createElement(
5755
+ ))), 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(
5104
5756
  ChartOfAccountsRow,
5105
5757
  {
5106
5758
  key: account.id,